refactor: improved core barrel exports and Application class (#10286)

BREAKING CHANGES:

`Application.orientation` is no longer a function.

Migration: Remove `()` from the `Application.orientation()` call:
```diff
import { Application } from "@nativescript/core";

-console.log(Application.orientation());
+console.log(Application.orientation);
```


`Application.systemAppearance` is no longer a function.

Migration: Remove `()` from the `Application.systemAppearance()` call:
```diff
import { Application } from "@nativescript/core";

-console.log(Application.systemAppearance());
+console.log(Application.systemAppearance);
```
This commit is contained in:
Igor Randjelovic
2023-05-17 21:02:06 +02:00
committed by Nathan Walker
parent 963d0243de
commit f64355ba7a
67 changed files with 3536 additions and 3678 deletions

View File

@@ -1,6 +1,6 @@
// Types
import { EventData } from '../data/observable';
import { View } from '../ui/core/view';
import type { ApplicationCommon } from './application-common';
import type { EventData, Observable } from '../data/observable';
import type { View } from '../ui/core/view';
/**
* An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
@@ -12,98 +12,191 @@ export interface NativeScriptError extends Error {
nativeError: any;
}
export interface ApplicationEventData extends EventData {
/**
* Event data containing information for the application events.
*/
export interface ApplicationEventData {
/**
* UIApplication or undefined, unless otherwise specified. Prefer explicit
* properties where possible.
* The name of the event.
*/
ios?: any;
eventName: string;
/**
* androidx.appcompat.app.AppCompatActivity or undefined, unless otherwise
* specified. Prefer explicit properties where possible.
* Gets the native iOS event arguments. Valid only when running on iOS.
*/
android?: any;
ios?: any; // iOSApplication;
/**
* Careful with this messy type. A significant refactor is needed to make it
* strictly extend EventData['object'], which is an Observable. It's used in
* various ways:
* - By font-scale: the Application module, typeof import('.')
* - Within index.android.ts: AndroidApplication
* - Within index.ios.ts: iOSApplication
* Gets the native Android event arguments. Valid only when running on Android.
*/
object: any;
android?: any; // AndroidApplication;
/**
* The instance that has raised the event.
*/
object: ApplicationCommon | Observable;
}
export interface LaunchEventData extends ApplicationEventData {
/**
* Event data containing information for launch event.
*/
export interface LaunchEventData extends EventData {
/**
* The value stored into didFinishLaunchingWithOptions notification's
* userInfo under 'UIApplicationLaunchOptionsLocalNotificationKey';
* otherwise, null.
* The root view for this Window on iOS or Activity for Android.
* If not set a new Frame will be created as a root view in order to maintain backwards compatibility.
* If explicitly set to null, there will be no root view.
*/
ios: unknown;
root?: View | null;
savedInstanceState?: any /* android.os.Bundle */;
android?: android.content.Intent;
ios?: any /* UIApplicationLaunchOptions */;
}
/**
* Event data containing information for orientation changed event.
*/
export interface OrientationChangedEventData extends ApplicationEventData {
android: any /* globalAndroid.app.Application */;
/**
* New orientation value.
*/
newValue: 'portrait' | 'landscape' | 'unknown';
}
/**
* Event data containing information for system appearance changed event.
*/
export interface SystemAppearanceChangedEventData extends ApplicationEventData {
android: any /* globalAndroid.app.Application */;
/**
* New system appearance value.
*/
newValue: 'light' | 'dark';
}
/**
* Event data containing information for font scale changed event.
*/
export interface FontScaleChangedEventData extends ApplicationEventData {
/**
* New font scale value.
*/
newValue: number;
}
/**
* Event data containing information about unhandled application errors.
*/
export interface UnhandledErrorEventData extends ApplicationEventData {
ios?: NativeScriptError;
android?: NativeScriptError;
error: NativeScriptError;
}
/**
* Event data containing information about discarded application errors.
*/
export interface DiscardedErrorEventData extends ApplicationEventData {
error: NativeScriptError;
}
/**
* Event data containing information about application css change.
*/
export interface CssChangedEventData extends ApplicationEventData {
cssFile?: string;
cssText?: string;
}
export interface AndroidActivityEventData extends ApplicationEventData {
activity: any /* androidx.appcompat.app.AppCompatActivity */;
object: any /* AndroidApplication */;
}
/**
* Data for the Android activity events.
*/
export interface AndroidActivityEventData {
/**
* The activity.
*/
activity: androidx.appcompat.app.AppCompatActivity;
export interface AndroidActivityBundleEventData extends AndroidActivityEventData {
bundle: any /* android.os.Bundle */;
}
/**
* The name of the event.
*/
eventName: string;
export interface AndroidActivityRequestPermissionsEventData extends AndroidActivityEventData {
requestCode: number;
permissions: Array<string>;
grantResults: Array<number>;
}
export interface AndroidActivityResultEventData extends AndroidActivityEventData {
requestCode: number;
resultCode: number;
intent: any /* android.content.Intent */;
}
export interface AndroidActivityNewIntentEventData extends AndroidActivityEventData {
intent: any /* android.content.Intent */;
}
export interface AndroidActivityBackPressedEventData extends AndroidActivityEventData {
cancel: boolean;
/**
* The instance that has raised the event.
*/
object: any;
}
/**
* @deprecated
* Data for the Android activity events with bundle.
*/
export interface RootViewControllerImpl {
contentController: any;
export interface AndroidActivityBundleEventData extends AndroidActivityEventData {
/**
* The bundle.
*/
bundle: android.os.Bundle;
}
/**
* Data for the Android activity onRequestPermissions callback
*/
export interface AndroidActivityRequestPermissionsEventData extends AndroidActivityEventData {
/**
* The request code.
*/
requestCode: number;
/**
* The Permissions.
*/
permissions: Array<string>;
/**
* The Granted.
*/
grantResults: Array<number>;
}
/**
* Data for the Android activity result event.
*/
export interface AndroidActivityResultEventData extends AndroidActivityEventData {
/**
* The request code.
*/
requestCode: number;
/**
* The result code.
*/
resultCode: number;
/**
* The intent.
*/
intent: android.content.Intent;
}
/**
* Data for the Android activity newIntent event.
*/
export interface AndroidActivityNewIntentEventData extends AndroidActivityEventData {
/**
* The intent.
*/
intent: any /* android.content.Intent */;
}
/**
* Data for the Android activity back pressed event.
*/
export interface AndroidActivityBackPressedEventData extends AndroidActivityEventData {
/**
* In the event handler, set this value to true if you want to cancel the back navigation and do something else instead.
*/
cancel: boolean;
}
export interface LoadAppCSSEventData extends ApplicationEventData {