forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.d.ts
More file actions
293 lines (244 loc) · 10.5 KB
/
Copy pathapplication.d.ts
File metadata and controls
293 lines (244 loc) · 10.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/**
* Contains the application abstraction with all related methods.
*/
declare module "application" {
import cssSelector = require("ui/styling/css-selector");
import observable = require("data/observable");
/**
* 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.
*/
nativeError: any;
}
/**
* String value used when hooking to launch event.
*/
export var launchEvent: string;
/**
* String value used when hooking to uncaughtError event.
*/
export var uncaughtErrorEvent: string;
/**
* String value used when hooking to suspend event.
*/
export var suspendEvent: string;
/**
* String value used when hooking to resume event.
*/
export var resumeEvent: string;
/**
* String value used when hooking to exitevent.
*/
export var exitEvent: string;
/**
* String value used when hooking to lowMemory event.
*/
export var lowMemoryEvent: string;
/**
* Event data containing information for the application events.
*/
export interface ApplicationEventData extends observable.EventData {
/**
* 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 main page path (without the file extension) for the application starting from the application root.
* For example if you have page called "main.js" in a folder called "subFolder" and your root folder is "app" you can specify mainModule like this:
* var application = require("application");
* application.mainModule = "app/subFolder/main";
* application.start();
*/
export var mainModule: string;
/**
* An application level static resources.
*/
export var resources: any;
/**
* The application level css file name (starting from the application root). Used to set css across all pages.
* Css will be applied for every page and page css will be applied after.
*/
export var cssFile: string;
/**
* Cached css selectors created from the content of the css file.
*/
export var cssSelectorsCache: Array<cssSelector.CssSelector>;
/**
* Loads css file and parses to a css syntax tree.
*/
export function loadCss(): void;
/**
* Call this method to start the application. Important: All code after this method call will not be executed!
*/
export function start();
/**
* The main entry point event. This method is expected to use the root frame to navigate to the main application page.
*/
export function onLaunch(context: any): void;
/**
* A callback to be used when an uncaught error occurs while the application is running.
* The application will be shut down after this method returns.
* Loading new UI at this point is erroneous and may lead to unpredictable results.
* The method is intended to be used for crash reports and/or application restart.
*/
export function onUncaughtError(error: NativeScriptError): void;
/**
* This method will be called when the Application is suspended.
*/
export function onSuspend();
/**
* This method will be called when the Application is resumed after it has been suspended.
*/
export function onResume();
/**
* This method will be called when the Application is about to exitEvent.
*/
export function onExit();
/**
* This method will be called when there is low memory on the target device.
*/
export function onLowMemory();
/**
* A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
* @param eventNames - String corresponding to events (e.g. "onLaunch"). Optionally could be used more events separated by `,` (e.g. "onLaunch", "onSuspend").
* @param callback - Callback function which will be executed when event is raised.
* @param thisArg - An optional parameter which will be used as `this` context for callback execution.
*/
export function on(eventNames: string, callback: (data: any) => void, thisArg?: any);
/**
* Notifies all the registered listeners for the event provided in the data.eventName.
* @param data The data associated with the event.
*/
export function notify(data: ApplicationEventData): void;
/**
* Checks whether a listener is registered for the specified event name.
* @param eventName The name of the event to check for.
*/
export function hasListeners(eventName: string): boolean;
/**
* This event is raised on application launchEvent.
*/
export function on(event: "onLaunch", callback: (args: any) => void, thisArg?: any);
/**
* This event is raised when an uncaught error occurs while the application is running.
*/
export function on(event: "onUncaughtError", callback: (args: any) => void, thisArg?: any);
/**
* This event is raised when the Application is suspended.
*/
export function on(event: "onSuspend", callback: (args: any) => void, thisArg?: any);
/**
* This event is raised when the Application is resumed after it has been suspended.
*/
export function on(event: "onResume", callback: (args: any) => void, thisArg?: any);
/**
* This event is raised when the Application is about to exitEvent.
*/
export function on(event: "onExit", callback: (args: any) => void, thisArg?: any);
/**
* This event is raised when there is low memory on the target device.
*/
export function on(event: "onLowMemory", callback: (args: any) => void, thisArg?: any);
/**
* This is the Android-specific application object instance.
* Encapsulates methods and properties specific to the Android platform.
* Will be undefined when TargetOS is iOS.
*/
export var android: AndroidApplication;
/**
* This is the iOS-specific application object instance.
* Encapsulates methods and properties specific to the iOS platform.
* Will be undefined when TargetOS is Android.
*/
export var ios: iOSApplication;
/**
* The abstraction of an Android-specific application object.
*/
export interface AndroidApplication {
/**
* The [android Application](http://developer.android.com/reference/android/app/Application.html) object instance provided to the init of the module.
*/
nativeApp: android.app.Application;
/**
* The application's [android Context](http://developer.android.com/reference/android/content/Context.html) object instance.
*/
context: android.content.Context;
/**
* The currently active (loaded) [android Activity](http://developer.android.com/reference/android/app/Activity.html). This property is automatically updated upon Activity events.
*/
foregroundActivity: android.app.Activity;
/**
* The currently active (loaded) Context. This is typically the top-level Activity that is just created.
*/
currentContext: android.content.Context;
/**
* The main (start) Activity for the application.
*/
startActivity: android.app.Activity;
/**
* The name of the application package.
*/
packageName: string;
/**
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
* @param intent - Native (android) intent used to create the activity.
* Returns com.tns.NativeScriptActivity.extend implementation.
*/
getActivity(intent: android.content.Intent): any;
/**
* Direct handler of the [onActivityCreated method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
/**
* Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityDestroyed: (activity: android.app.Activity) => void;
/**
* Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityStarted: (activity: android.app.Activity) => void;
/**
* Direct handler of the [onActivityPaused method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityPaused: (activity: android.app.Activity) => void;
/**
* Direct handler of the [onActivityResumed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityResumed: (activity: android.app.Activity) => void;
/**
* Direct handler of the [onActivityStopped method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onActivityStopped: (activity: android.app.Activity) => void;
/**
* Direct handler of the [onActivitySaveInstanceState method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html).
*/
onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void;
/**
* Direct handler of the onActivityResult method.
*/
onActivityResult: (requestCode: number, resultCode: number, data: android.content.Intent) => void
}
/* tslint:disable */
/**
* The abstraction of an iOS-specific application object.
*/
export interface iOSApplication {
/* tslint:enable */
/**
* The root view controller for the application.
*/
rootController: UIViewController;
/**
* The [UIApplication](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html) object instance provided to the init of the module.
*/
nativeApp: UIApplication;
}
}