UNPKG

9.45 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 * @param skipCssUpdate
126 */
127 applyCssClass(rootView: View, cssClasses: string[], newCssClass: string, skipCssUpdate?: boolean): void;
128 private addCssClass;
129 private removeCssClass;
130 private increaseStyleScopeApplicationCssSelectorVersion;
131 private setRootViewCSSClasses;
132 /**
133 * iOS Only
134 * Dynamically change the preferred frame rate
135 * For devices (iOS 15+) which support min/max/preferred frame rate you can specify ranges
136 * For devices (iOS < 15), you can specify the max frame rate
137 * see: https://developer.apple.com/documentation/quartzcore/optimizing_promotion_refresh_rates_for_iphone_13_pro_and_ipad_pro
138 * To use, ensure your Info.plist has:
139 * ```xml
140 * <key>CADisableMinimumFrameDurationOnPhone</key>
141 * <true/>
142 * ```
143 * @param options { min?: number; max?: number; preferred?: number }
144 */
145 setMaxRefreshRate(options?: {
146 min?: number;
147 max?: number;
148 preferred?: number;
149 }): void;
150 protected mainEntry: NavigationEntry;
151 /**
152 * @returns The main entry of the application
153 */
154 getMainEntry(): NavigationEntry;
155 protected notifyLaunch(additionalLanchEventData?: any): View | null;
156 createRootView(view?: View, fireLaunchEvent?: boolean, additionalLanchEventData?: any): View;
157 getRootView(): View;
158 resetRootView(entry?: NavigationEntry | string): void;
159 initRootView(rootView: View): void;
160 /**
161 * Get application level static resources.
162 */
163 getResources(): any;
164 /**
165 * Set application level static resources.
166 */
167 setResources(res: any): void;
168 private cssFile;
169 /**
170 * Sets css file name for the application.
171 */
172 setCssFileName(cssFileName: string): void;
173 /**
174 * Gets css file name for the application.
175 */
176 getCssFileName(): string;
177 /**
178 * Loads immediately the app.css.
179 * By default the app.css file is loaded shortly after "loaded".
180 * For the Android snapshot the CSS can be parsed during the snapshot generation,
181 * as the CSS does not depend on runtime APIs, and loadAppCss will be called explicitly.
182 */
183 loadAppCss(): void;
184 addCss(cssText: string, attributeScoped?: boolean): void;
185 run(entry?: string | NavigationEntry): void;
186 private _orientation;
187 protected getOrientation(): 'portrait' | 'landscape' | 'unknown';
188 protected setOrientation(value: 'portrait' | 'landscape' | 'unknown'): void;
189 orientation(): 'portrait' | 'landscape' | 'unknown';
190 orientationChanged(rootView: View, newOrientation: 'portrait' | 'landscape' | 'unknown'): void;
191 getNativeApplication(): any;
192 hasLaunched(): boolean;
193 private _systemAppearance;
194 protected getSystemAppearance(): 'dark' | 'light' | null;
195 protected setSystemAppearance(value: 'dark' | 'light'): void;
196 systemAppearance(): 'dark' | 'light' | null;
197 /**
198 * Boolean to enable/disable systemAppearanceChanged
199 */
200 autoSystemAppearanceChanged: boolean;
201 /**
202 * enable/disable systemAppearanceChanged
203 */
204 setAutoSystemAppearanceChanged(value: boolean): void;
205 /**
206 * Updates root view classes including those of modals
207 * @param rootView the root view
208 * @param newSystemAppearance the new appearance change
209 */
210 systemAppearanceChanged(rootView: View, newSystemAppearance: 'dark' | 'light'): void;
211 private _inBackground;
212 get inBackground(): boolean;
213 setInBackground(value: boolean, additonalData?: any): void;
214 private _suspended;
215 get suspended(): boolean;
216 setSuspended(value: boolean, additonalData?: any): void;
217 started: boolean;
218 get android(): IAndroidApplication;
219 get ios(): IiOSApplication;
220 get AndroidApplication(): IAndroidApplication;
221 get iOSApplication(): IiOSApplication;
222}
223export {};