UNPKG

@nativescript/core

Version:

A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.

279 lines (278 loc) 8.13 kB
import type { EventData } from '../data/observable'; import type { View } from '../ui/core/view'; import type { CoreTypes } from '../core-types'; import type { NativeWindow } from '../native-window'; /** * An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code. */ export interface NativeScriptError extends Error { /** * Represents the native error object. */ nativeException?: any; /** * The native stack trace. */ stackTrace?: string; /** * Javascript portion of stack trace. */ stack?: string; } /** * Event data containing information for the application events. */ export interface ApplicationEventData { /** * The name of the event. */ eventName: string; /** * Gets the native iOS event arguments. Valid only when running on iOS. */ ios?: any; /** * Gets the native Android event arguments. Valid only when running on Android. */ android?: any; /** * The instance that has raised the event. */ object: any; } /** * Event data containing information for launch event. */ export interface LaunchEventData extends EventData { /** * 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. */ root?: View | null; savedInstanceState?: any; android?: android.content.Intent; ios?: any; } /** * Event data containing information for orientation changed event. */ export interface OrientationChangedEventData extends ApplicationEventData { /** * New orientation value. */ newValue: 'portrait' | 'landscape' | 'unknown'; } /** * Event data containing information for system appearance changed event. */ export interface SystemAppearanceChangedEventData extends ApplicationEventData { /** * New system appearance value. */ newValue: 'light' | 'dark'; } /** * Event data containing information for system layout direction changed event. */ export interface LayoutDirectionChangedEventData extends ApplicationEventData { /** * New layout direction value. */ newValue: CoreTypes.LayoutDirectionType; } /** * 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; } /** * Event data containing information about root view application. */ export interface InitRootViewEventData extends ApplicationEventData { rootView: View; } /** * Data for the Android activity events. */ export interface AndroidActivityEventData { /** * The activity. */ activity: androidx.appcompat.app.AppCompatActivity; /** * The NativeWindow the activity belongs to, when one is registered for it. */ window?: NativeWindow; /** * The name of the event. */ eventName: string; /** * The instance that has raised the event. */ object: any; } /** * Data for the Android activity events with bundle. */ 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; } /** * 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 { cssFile: string; } /** * iOS Event data containing information for scene lifecycle events (iOS 13+). */ export interface SceneEventData extends ApplicationEventData { /** * The UIWindowScene instance associated with this event. */ scene?: UIWindowScene; /** * The UIWindow associated with this scene (if applicable). */ uiWindow?: UIWindow; /** * The NativeWindow the scene belongs to, when one is registered for it. */ window?: NativeWindow; /** * Scene connection options (for sceneWillConnect event). */ connectionOptions?: UISceneConnectionOptions; /** * Additional user info from the notification. */ userInfo?: NSDictionary<any, any>; } /** * iOS event data for the `sceneOpenURLContexts` event, raised when a scene is asked to open URLs. * * Replaces the `applicationOpenURLOptions` app delegate callback, which UIKit no longer * calls once the app adopts scenes. Handlers registered through * `Application.ios.addDelegateHandler('applicationOpenURLOptions', ...)` still run, once per context. */ export interface SceneOpenURLContextsEventData extends SceneEventData { /** * The URL contexts to open. A single delivery may carry more than one URL. */ urlContexts: NSSet<UIOpenURLContext>; } /** * iOS event data for the `sceneContinueUserActivity` event, raised for Handoff and * universal links directed at a scene. * * Replaces the `applicationContinueUserActivityRestorationHandler` app delegate callback, * which UIKit no longer calls once the app adopts scenes. */ export interface SceneContinueUserActivityEventData extends SceneEventData { /** * The activity to continue. */ userActivity: NSUserActivity; } /** * iOS event data for the `scenePerformActionForShortcutItem` event, raised when a home * screen quick action targets a scene. * * Replaces the `applicationPerformActionForShortcutItemCompletionHandler` app delegate * callback, which UIKit no longer calls once the app adopts scenes. */ export interface ScenePerformActionForShortcutItemEventData extends SceneEventData { /** * The quick action the user selected. */ shortcutItem: UIApplicationShortcutItem; /** * Reports back to iOS whether the action was handled. Only the first call is delivered; * later ones are ignored. * * Unless a legacy `applicationPerformActionForShortcutItemCompletionHandler` handler is * registered — in which case that handler owns the result — the action is reported as * unhandled as soon as the listeners return, so a listener that wants to report otherwise * must call this before returning. */ completionHandler: (handled: boolean) => void; }