UNPKG

9.4 kBTypeScriptView Raw
1import type { View } from '../ui/core/view';
2import type { NavigationEntry } from '../ui/frame/frame-interfaces';
3import type { AndroidApplication as IAndroidApplication, iOSApplication as IiOSApplication } from './';
4import type { ApplicationEventData, CssChangedEventData, DiscardedErrorEventData, FontScaleChangedEventData, LaunchEventData, OrientationChangedEventData, SystemAppearanceChangedEventData, UnhandledErrorEventData } from './application-interfaces';
5interface ApplicationEvents {
6 off(eventNames: string, callback?: any, thisArg?: any): void;
7 notify<T = ApplicationEventData>(eventData: T): void;
8 hasListeners(eventName: string): boolean;
9 on(eventNames: string, callback: (args: ApplicationEventData) => void, thisArg?: any): void;
10 /**
11 * This event is raised when application css is changed.
12 */
13 on(event: 'cssChanged', callback: (args: CssChangedEventData) => void, thisArg?: any): void;
14 /**
15 * Event raised then livesync operation is performed.
16 */
17 on(event: 'livesync', callback: (args: ApplicationEventData) => void, thisArg?: any): void;
18 /**
19 * This event is raised when application css is changed.
20 */
21 on(event: 'cssChanged', callback: (args: CssChangedEventData) => void, thisArg?: any): void;
22 /**
23 * This event is raised on application launchEvent.
24 */
25 on(event: 'launch', callback: (args: LaunchEventData) => void, thisArg?: any): void;
26 /**
27 * This event is raised after the application has performed most of its startup actions.
28 * Its intent is to be suitable for measuring app startup times.
29 * @experimental
30 */
31 on(event: 'displayed', callback: (args: ApplicationEventData) => void, thisArg?: any): void;
32 /**
33 * This event is raised when the Application is suspended.
34 */
35 on(event: 'suspend', callback: (args: ApplicationEventData) => void, thisArg?: any): void;
36 /**
37 * This event is raised when the Application is resumed after it has been suspended.
38 */
39 on(event: 'resume', callback: (args: ApplicationEventData) => void, thisArg?: any): void;
40 /**
41 * This event is raised when the Application is about to exit.
42 */
43 on(event: 'exit', callback: (args: ApplicationEventData) => void, thisArg?: any): void;
44 /**
45 * This event is raised when there is low memory on the target device.
46 */
47 on(event: 'lowMemory', callback: (args: ApplicationEventData) => void, thisArg?: any): void;
48 /**
49 * This event is raised when an uncaught error occurs while the application is running.
50 */
51 on(event: 'uncaughtError', callback: (args: UnhandledErrorEventData) => void, thisArg?: any): void;
52 /**
53 * This event is raised when an discarded error occurs while the application is running.
54 */
55 on(event: 'discardedError', callback: (args: DiscardedErrorEventData) => void, thisArg?: any): void;
56 /**
57 * This event is raised when the orientation of the application changes.
58 */
59 on(event: 'orientationChanged', callback: (args: OrientationChangedEventData) => void, thisArg?: any): void;
60 /**
61 * This event is raised when the operating system appearance changes
62 * between light and dark theme (for Android);
63 * between light and dark mode (for iOS) and vice versa.
64 */
65 on(event: 'systemAppearanceChanged', callback: (args: SystemAppearanceChangedEventData) => void, thisArg?: any): void;
66 on(event: 'fontScaleChanged', callback: (args: FontScaleChangedEventData) => void, thisArg?: any): void;
67}
68export declare class ApplicationCommon {
69 readonly launchEvent = "launch";
70 readonly suspendEvent = "suspend";
71 readonly displayedEvent = "displayed";
72 readonly backgroundEvent = "background";
73 readonly foregroundEvent = "foreground";
74 readonly resumeEvent = "resume";
75 readonly exitEvent = "exit";
76 readonly lowMemoryEvent = "lowMemory";
77 readonly uncaughtErrorEvent = "uncaughtError";
78 readonly discardedErrorEvent = "discardedError";
79 readonly orientationChangedEvent = "orientationChanged";
80 readonly systemAppearanceChangedEvent = "systemAppearanceChanged";
81 readonly fontScaleChangedEvent = "fontScaleChanged";
82 readonly livesyncEvent = "livesync";
83 readonly loadAppCssEvent = "loadAppCss";
84 readonly cssChangedEvent = "cssChanged";
85 readonly initRootViewEvent = "initRootView";
86 /**
87 * @deprecated Use `Application.android.on()` instead.
88 */
89 static on: ApplicationEvents['on'];
90 /**
91 * @deprecated Use `Application.android.once()` instead.
92 */
93 static once: ApplicationEvents['on'];
94 /**
95 * @deprecated Use `Application.android.off()` instead.
96 */
97 static off: ApplicationEvents['off'];
98 /**
99 * @deprecated Use `Application.android.notify()` instead.
100 */
101 static notify: ApplicationEvents['notify'];
102 /**
103 * @deprecated Use `Application.android.hasListeners()` instead.
104 */
105 static hasListeners: ApplicationEvents['hasListeners'];
106 on: ApplicationEvents['on'];
107 once: ApplicationEvents['on'];
108 off: ApplicationEvents['off'];
109 notify: ApplicationEvents['notify'];
110 hasListeners: ApplicationEvents['hasListeners'];
111 /**
112 * @internal - should not be constructed by the user.
113 */
114 constructor();
115 /**
116 * @internal
117 */
118 livesync(rootView: View, context?: ModuleContext): void;
119 /**
120 * Applies the the `newCssClass` to the `rootView` and removes all other css classes from `cssClasses`
121 * previously applied to the `rootView`.
122 * @param rootView
123 * @param cssClasses
124 * @param newCssClass
125 */
126 applyCssClass(rootView: View, cssClasses: string[], newCssClass: string): void;
127 private addCssClass;
128 private removeCssClass;
129 private increaseStyleScopeApplicationCssSelectorVersion;
130 private setRootViewCSSClasses;
131 /**
132 * iOS Only
133 * Dynamically change the preferred frame rate
134 * For devices (iOS 15+) which support min/max/preferred frame rate you can specify ranges
135 * For devices (iOS < 15), you can specify the max frame rate
136 * see: https://developer.apple.com/documentation/quartzcore/optimizing_promotion_refresh_rates_for_iphone_13_pro_and_ipad_pro
137 * To use, ensure your Info.plist has:
138 * ```xml
139 * <key>CADisableMinimumFrameDurationOnPhone</key>
140 * <true/>
141 * ```
142 * @param options { min?: number; max?: number; preferred?: number }
143 */
144 setMaxRefreshRate(options?: {
145 min?: number;
146 max?: number;
147 preferred?: number;
148 }): void;
149 protected mainEntry: NavigationEntry;
150 /**
151 * @returns The main entry of the application
152 */
153 getMainEntry(): NavigationEntry;
154 protected notifyLaunch(additionalLanchEventData?: any): View | null;
155 createRootView(view?: View, fireLaunchEvent?: boolean, additionalLanchEventData?: any): View;
156 getRootView(): View;
157 resetRootView(entry?: NavigationEntry | string): void;
158 initRootView(rootView: View): void;
159 /**
160 * Get application level static resources.
161 */
162 getResources(): any;
163 /**
164 * Set application level static resources.
165 */
166 setResources(res: any): void;
167 private cssFile;
168 /**
169 * Sets css file name for the application.
170 */
171 setCssFileName(cssFileName: string): void;
172 /**
173 * Gets css file name for the application.
174 */
175 getCssFileName(): string;
176 /**
177 * Loads immediately the app.css.
178 * By default the app.css file is loaded shortly after "loaded".
179 * For the Android snapshot the CSS can be parsed during the snapshot generation,
180 * as the CSS does not depend on runtime APIs, and loadAppCss will be called explicitly.
181 */
182 loadAppCss(): void;
183 addCss(cssText: string, attributeScoped?: boolean): void;
184 run(entry?: string | NavigationEntry): void;
185 private _orientation;
186 protected getOrientation(): 'portrait' | 'landscape' | 'unknown';
187 protected setOrientation(value: 'portrait' | 'landscape' | 'unknown'): void;
188 orientation(): 'portrait' | 'landscape' | 'unknown';
189 orientationChanged(rootView: View, newOrientation: 'portrait' | 'landscape' | 'unknown'): void;
190 getNativeApplication(): any;
191 hasLaunched(): boolean;
192 private _systemAppearance;
193 protected getSystemAppearance(): 'dark' | 'light' | null;
194 protected setSystemAppearance(value: 'dark' | 'light'): void;
195 systemAppearance(): 'dark' | 'light' | null;
196 /**
197 * Boolean to enable/disable systemAppearanceChanged
198 */
199 autoSystemAppearanceChanged: boolean;
200 /**
201 * enable/disable systemAppearanceChanged
202 */
203 setAutoSystemAppearanceChanged(value: boolean): void;
204 /**
205 * Updates root view classes including those of modals
206 * @param rootView the root view
207 * @param newSystemAppearance the new appearance change
208 */
209 systemAppearanceChanged(rootView: View, newSystemAppearance: 'dark' | 'light'): void;
210 private _inBackground;
211 get inBackground(): boolean;
212 setInBackground(value: boolean, additonalData?: any): void;
213 private _suspended;
214 get suspended(): boolean;
215 setSuspended(value: boolean, additonalData?: any): void;
216 started: boolean;
217 get android(): IAndroidApplication;
218 get ios(): IiOSApplication;
219 get AndroidApplication(): IAndroidApplication;
220 get iOSApplication(): IiOSApplication;
221}
222export {};