UNPKG

4.99 kBTypeScriptView Raw
1import type { ApplicationCommon } from './application-common';
2import type { EventData, Observable } from '../data/observable';
3import type { View } from '../ui/core/view';
4/**
5 * An extended JavaScript Error which will have the nativeError property initialized in case the error is caused by executing platform-specific code.
6 */
7export interface NativeScriptError extends Error {
8 /**
9 * Represents the native error object.
10 */
11 nativeException?: any;
12 /**
13 * The native stack trace.
14 */
15 stackTrace?: string;
16 /**
17 * Javascript portion of stack trace.
18 */
19 stack?: string;
20}
21/**
22 * Event data containing information for the application events.
23 */
24export interface ApplicationEventData {
25 /**
26 * The name of the event.
27 */
28 eventName: string;
29 /**
30 * Gets the native iOS event arguments. Valid only when running on iOS.
31 */
32 ios?: any;
33 /**
34 * Gets the native Android event arguments. Valid only when running on Android.
35 */
36 android?: any;
37 /**
38 * The instance that has raised the event.
39 */
40 object: ApplicationCommon | Observable;
41}
42/**
43 * Event data containing information for launch event.
44 */
45export interface LaunchEventData extends EventData {
46 /**
47 * The root view for this Window on iOS or Activity for Android.
48 * If not set a new Frame will be created as a root view in order to maintain backwards compatibility.
49 * If explicitly set to null, there will be no root view.
50 */
51 root?: View | null;
52 savedInstanceState?: any;
53 android?: android.content.Intent;
54 ios?: any;
55}
56/**
57 * Event data containing information for orientation changed event.
58 */
59export interface OrientationChangedEventData extends ApplicationEventData {
60 /**
61 * New orientation value.
62 */
63 newValue: 'portrait' | 'landscape' | 'unknown';
64}
65/**
66 * Event data containing information for system appearance changed event.
67 */
68export interface SystemAppearanceChangedEventData extends ApplicationEventData {
69 /**
70 * New system appearance value.
71 */
72 newValue: 'light' | 'dark';
73}
74/**
75 * Event data containing information for font scale changed event.
76 */
77export interface FontScaleChangedEventData extends ApplicationEventData {
78 /**
79 * New font scale value.
80 */
81 newValue: number;
82}
83/**
84 * Event data containing information about unhandled application errors.
85 */
86export interface UnhandledErrorEventData extends ApplicationEventData {
87 ios?: NativeScriptError;
88 android?: NativeScriptError;
89 error: NativeScriptError;
90}
91/**
92 * Event data containing information about discarded application errors.
93 */
94export interface DiscardedErrorEventData extends ApplicationEventData {
95 error: NativeScriptError;
96}
97/**
98 * Event data containing information about application css change.
99 */
100export interface CssChangedEventData extends ApplicationEventData {
101 cssFile?: string;
102 cssText?: string;
103}
104/**
105 * Event data containing information about root view application.
106 */
107export interface InitRootViewEventData extends ApplicationEventData {
108 rootView: View;
109}
110/**
111 * Data for the Android activity events.
112 */
113export interface AndroidActivityEventData {
114 /**
115 * The activity.
116 */
117 activity: androidx.appcompat.app.AppCompatActivity;
118 /**
119 * The name of the event.
120 */
121 eventName: string;
122 /**
123 * The instance that has raised the event.
124 */
125 object: any;
126}
127/**
128 * Data for the Android activity events with bundle.
129 */
130export interface AndroidActivityBundleEventData extends AndroidActivityEventData {
131 /**
132 * The bundle.
133 */
134 bundle: android.os.Bundle;
135}
136/**
137 * Data for the Android activity onRequestPermissions callback
138 */
139export interface AndroidActivityRequestPermissionsEventData extends AndroidActivityEventData {
140 /**
141 * The request code.
142 */
143 requestCode: number;
144 /**
145 * The Permissions.
146 */
147 permissions: Array<string>;
148 /**
149 * The Granted.
150 */
151 grantResults: Array<number>;
152}
153/**
154 * Data for the Android activity result event.
155 */
156export interface AndroidActivityResultEventData extends AndroidActivityEventData {
157 /**
158 * The request code.
159 */
160 requestCode: number;
161 /**
162 * The result code.
163 */
164 resultCode: number;
165 /**
166 * The intent.
167 */
168 intent: android.content.Intent;
169}
170/**
171 * Data for the Android activity newIntent event.
172 */
173export interface AndroidActivityNewIntentEventData extends AndroidActivityEventData {
174 /**
175 * The intent.
176 */
177 intent: any;
178}
179/**
180 * Data for the Android activity back pressed event.
181 */
182export interface AndroidActivityBackPressedEventData extends AndroidActivityEventData {
183 /**
184 * In the event handler, set this value to true if you want to cancel the back navigation and do something else instead.
185 */
186 cancel: boolean;
187}
188export interface LoadAppCSSEventData extends ApplicationEventData {
189 cssFile: string;
190}