1 | interface ModuleResolver {
|
2 | /**
|
3 | * A function used to resolve the exports for a module.
|
4 | * @param uri The name of the module to be resolved.
|
5 | */
|
6 | (uri: string): any;
|
7 | }
|
8 |
|
9 | /**
|
10 | * An extended JavaScript Error which will have the nativeException property initialized in case the error is caused by executing platform-specific code.
|
11 | */
|
12 | declare interface NativeScriptError extends Error {
|
13 | /**
|
14 | * Represents the native error object.
|
15 | */
|
16 | nativeException?: any;
|
17 | /**
|
18 | * The native stack trace.
|
19 | */
|
20 | stackTrace?: string;
|
21 | /**
|
22 | * Javascript portion of stack trace.
|
23 | */
|
24 | stack?: string;
|
25 | }
|
26 |
|
27 | //Augment the NodeJS global type with our own extensions
|
28 | declare module globalThis {
|
29 | var NativeScriptHasInitGlobal: boolean;
|
30 | var NativeScriptGlobals: {
|
31 | /**
|
32 | * Global framework event handling
|
33 | */
|
34 | events: {
|
35 | [Key in keyof import('data/observable').Observable]: import('data/observable').Observable[Key];
|
36 | };
|
37 | launched: boolean;
|
38 | // used by various classes to setup callbacks to wire up global app event handling when the app instance is ready
|
39 | appEventWiring: Array<any>;
|
40 | // determines if the app instance is ready upon bootstrap
|
41 | appInstanceReady: boolean;
|
42 |
|
43 | /**
|
44 | * Ability for classes to initialize app event handling early even before the app instance is ready during boot cycle avoiding boot race conditions
|
45 | * @param callback wire up any global event handling inside the callback
|
46 | */
|
47 | addEventWiring(callback: () => void): void;
|
48 | };
|
49 | // var android: any;
|
50 | function require(id: string): any;
|
51 |
|
52 | function moduleMerge(sourceExports: any, destExports: any): void;
|
53 |
|
54 | function registerModule(name: string, loader: (name: string) => any): void;
|
55 | /**
|
56 | * Register all modules from a webpack context.
|
57 | * The context is one created using the following webpack utility:
|
58 | * https://webpack.js.org/guides/dependency-management/#requirecontext
|
59 | *
|
60 | * The extension map is optional, modules in the webpack context will have their original file extension (e.g. may be ".ts" or ".scss" etc.),
|
61 | * while the built-in module builders in {N} will look for ".js", ".css" or ".xml" files. Adding a map such as:
|
62 | * ```
|
63 | * { ".ts": ".js" }
|
64 | * ```
|
65 | * Will resolve lookups for .js to the .ts file.
|
66 | * By default scss and ts files are mapped.
|
67 | */
|
68 | function registerWebpackModules(context: { keys(): string[]; (key: string): any }, extensionMap?: { [originalFileExtension: string]: string });
|
69 |
|
70 | /**
|
71 | * The NativeScript XML builder, style-scope, application modules use various resources such as:
|
72 | * app.css, page.xml files and modules during the application life-cycle.
|
73 | * The moduleResolvers can be used to provide additional mechanisms to locate such resources.
|
74 | * For example:
|
75 | * ```
|
76 | * global.moduleResolvers.unshift(uri => uri === "main-page" ? require("main-page") : null);
|
77 | * ```
|
78 | * More advanced scenarios will allow for specific bundlers to integrate their module resolving mechanisms.
|
79 | * When adding resolvers at the start of the array, avoid throwing and return null instead so subsequent resolvers may try to resolve the resource.
|
80 | * By default the only member of the array is global.require, as last resort - if it fails to find a module it will throw.
|
81 | */
|
82 | var moduleResolvers: ModuleResolver[];
|
83 |
|
84 | /**
|
85 | *
|
86 | * @param name Name of the module to be loaded
|
87 | * @param loadForUI Is this UI module is being loaded for UI from @nativescript/core/ui/builder.
|
88 | * Xml, css/scss and js/ts modules for pages and custom-components should load with loadForUI=true.
|
89 | * Passing "true" will enable the HMR mechanics this module. Default value is false.
|
90 | */
|
91 | function loadModule(name: string, loadForUI?: boolean): any;
|
92 |
|
93 | /**
|
94 | * Checks if the module has been registered with `registerModule` or in `registerWebpackModules`
|
95 | * @param name Name of the module
|
96 | */
|
97 | function moduleExists(name: string): boolean;
|
98 |
|
99 | function getRegisteredModules(): string[];
|
100 |
|
101 | function _unregisterModule(name: string): void;
|
102 |
|
103 | function _isModuleLoadedForUI(moduleName: string): boolean;
|
104 |
|
105 | var onGlobalLayoutListener: any;
|
106 | function zonedCallback<T = Function>(callback: T): T;
|
107 | var Reflect: any;
|
108 | function Deprecated(target: Object, key?: string | symbol, descriptor?: any): any;
|
109 | function Experimental(target: Object, key?: string | symbol, descriptor?: any): any;
|
110 |
|
111 | var __native: any;
|
112 | var __inspector: any;
|
113 | var __extends: any;
|
114 | var __onLiveSync: (context?: { type: string; path: string }) => void;
|
115 | var __onLiveSyncCore: (context?: { type: string; path: string }) => void;
|
116 | var __onUncaughtError: (error: NativeScriptError) => void;
|
117 | var __onDiscardedError: (error: NativeScriptError) => void;
|
118 | var __snapshot: boolean;
|
119 | var TNS_WEBPACK: boolean;
|
120 | var isIOS: boolean;
|
121 | var isAndroid: boolean;
|
122 | var isVisionOS: boolean;
|
123 | var isDisplayedEventFired: boolean;
|
124 | var autoLoadPolyfills: boolean;
|
125 | var __requireOverride: (name: string, dir: string) => any;
|
126 |
|
127 | // used to get the rootlayout instance to add/remove childviews
|
128 | var rootLayout: any;
|
129 | }
|
130 | declare const __DEV__: boolean;
|
131 | declare const __CSS_PARSER__: string;
|
132 | declare const __NS_WEBPACK__: boolean;
|
133 | declare const __UI_USE_EXTERNAL_RENDERER__: boolean;
|
134 | declare const __UI_USE_XML_PARSER__: boolean;
|
135 | declare const __ANDROID__: boolean;
|
136 | declare const __IOS__: boolean;
|
137 | declare const __VISIONOS__: boolean;
|
138 | declare const __APPLE__: boolean;
|
139 |
|
140 | declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
|
141 | declare function clearTimeout(timeoutId: number): void;
|
142 | declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): number;
|
143 | declare function clearInterval(intervalId: number): void;
|
144 |
|
145 | declare type ModuleType = 'markup' | 'script' | 'style';
|
146 |
|
147 | /**
|
148 | * Define a module context for Hot Module Replacement.
|
149 | */
|
150 | interface ModuleContext {
|
151 | /**
|
152 | * The type of the module for replacement.
|
153 | */
|
154 | type: ModuleType;
|
155 |
|
156 | /**
|
157 | * The path of the module for replacement.
|
158 | */
|
159 | path: string;
|
160 | }
|
161 |
|
162 | interface NodeModule {
|
163 | exports: any;
|
164 | id: string;
|
165 | filename: string;
|
166 | }
|
167 |
|
168 | declare enum RequestContext {
|
169 | 'audio',
|
170 | 'beacon',
|
171 | 'cspreport',
|
172 | 'download',
|
173 | 'embed',
|
174 | 'eventsource',
|
175 | 'favicon',
|
176 | 'fetch',
|
177 | 'font',
|
178 | 'form',
|
179 | 'frame',
|
180 | 'hyperlink',
|
181 | 'iframe',
|
182 | 'image',
|
183 | 'imageset',
|
184 | 'import',
|
185 | 'internal',
|
186 | 'location',
|
187 | 'manifest',
|
188 | 'object',
|
189 | 'ping',
|
190 | 'plugin',
|
191 | 'prefetch',
|
192 | 'script',
|
193 | 'serviceworker',
|
194 | 'sharedworker',
|
195 | 'subresource',
|
196 | 'style',
|
197 | 'track',
|
198 | 'video',
|
199 | 'worker',
|
200 | 'xmlhttprequest',
|
201 | 'xslt',
|
202 | }
|
203 |
|
204 | // Extend the lib.dom.d.ts Body interface with `formData`
|
205 | // interface Body {
|
206 | // formData(): Promise<FormData>;
|
207 | // }
|
208 |
|
209 | declare type HeaderInit = Headers | Array<string>;
|
210 |
|
211 | declare function fetch(url: string, init?: RequestInit): Promise<Response>;
|
212 |
|
213 | // declare var console: Console;
|
214 | declare var require: NodeRequire;
|
215 |
|
216 | // Extend NodeRequire with the webpack's require context extension.
|
217 | interface RequireContext {
|
218 | keys(): string[];
|
219 | (id: string): any;
|
220 | <T>(id: string): T;
|
221 | resolve(id: string): string;
|
222 | }
|
223 |
|
224 | interface WeakRef<T extends object> {
|
225 | /**
|
226 | * @deprecated Use deref instead with 8.5+
|
227 | */
|
228 | get(): T;
|
229 |
|
230 | /**
|
231 | * @deprecated You no longer need to make this call and can be safely removed.
|
232 | */
|
233 | clear(): void;
|
234 | }
|
235 |
|
236 | declare var __dirname: string;
|
237 | declare var __filename: string;
|
238 |
|
239 | declare var module: NodeModule;
|
240 | // Same as module.exports
|
241 | declare var exports: any;
|
242 |
|
243 | // Global functions
|
244 | declare function Deprecated(target: Object, key?: string | symbol, value?: any): void;
|
245 | declare function Experimental(target: Object, key?: string | symbol, value?: any): void;
|
246 |
|
247 | declare interface NativeClassOptions {
|
248 | nativeClassName?: string; // for @JavaProxy and
|
249 | protocols?: any[];
|
250 | interfaces?: any[];
|
251 | }
|
252 |
|
253 | /**
|
254 | * Decorates class that extends a native class(iOS or Android)
|
255 | */
|
256 | declare function NativeClass<T extends { new (...args: any[]): {} }>(constructor: T);
|
257 | declare function NativeClass<T extends { new (...args: any[]): {} }>(options?: NativeClassOptions);
|
258 |
|
259 | /**
|
260 | * Decorates class that implements native Java interfaces.
|
261 | * @param interfaces Implemented interfaces.
|
262 | */
|
263 | declare function Interfaces(...interfaces): ClassDecorator;
|
264 |
|
265 | /**
|
266 | * Important: Not applicable to Objective-C classes (iOS platform)
|
267 | * Decorates class that extends native Java class
|
268 | * @param interfaces An array of fully-classified Java interface names that the class must implement.
|
269 | */
|
270 | declare function Interfaces(interfaces: any[]): ClassDecorator;
|
271 |
|
272 | /**
|
273 | * Decorates class that extends native Java class
|
274 | * @param nativeClassName The name of the newly generated class. Must be unique in the application.
|
275 | */
|
276 | declare function JavaProxy(nativeClassName: string): ClassDecorator;
|
277 |
|
278 | /**
|
279 | * Important: Not applicable to Java classes (Android platform)
|
280 | * Decorates a class that implements native Objective-C protocols.
|
281 | * @param protocols An array of fully-classified Objective-C protocol names that the class must implement.
|
282 | */
|
283 | declare function ObjCClass(...protocols: any[]): ClassDecorator;
|
284 |
|
285 | /**
|
286 | * Important: Not applicable to Java methods (Android platform)
|
287 | * Decorates method that it is exposed in Objective-C.
|
288 | * The JS name of the method will be used as the name of the native method
|
289 | * and the return type will be set to `interop.types.void`
|
290 | */
|
291 | declare function ObjCMethod(): MethodDecorator;
|
292 |
|
293 | /**
|
294 | * Important: Not applicable to Java methods (Android platform)
|
295 | * Decorates method that it is exposed in Objective-C.
|
296 | * @param name The name of the method to be exposed.
|
297 | * The native return type will be set to `interop.types.void`.
|
298 | */
|
299 | declare function ObjCMethod(name: string): MethodDecorator;
|
300 |
|
301 | /**
|
302 | * Important: Not applicable to Java methods (Android platform)
|
303 | * Decorates a method to be exposed in Objective-C.
|
304 | * The JS name of the method will be used for the name of the native method.
|
305 | * @param returnType The native type of the result.
|
306 | */
|
307 | declare function ObjCMethod(returnType: any): MethodDecorator;
|
308 |
|
309 | /**
|
310 | * Important: Not applicable to Java methods (Android platform)
|
311 | * Decorates a method to be exposed in Objective-C.
|
312 | * @param name The name of the method to be exposed. Can be different than the JS function name
|
313 | * and can follow Objective-C colon syntax (for example `tableView:cellForRowAtIndexPath:`).
|
314 | * @param returnType The native type of the result.
|
315 | */
|
316 | declare function ObjCMethod(name: string, returnType: any): MethodDecorator;
|
317 |
|
318 | /**
|
319 | * Important: Not applicable to Java classes or methods (Android platform)
|
320 | * This is a shorthand decorator that can be used to decorate either a method or a class
|
321 | * to be exposed to Objective-C.
|
322 | * @param params Parameters to send to the ObjCClass or ObjCMethod decorators.
|
323 | */
|
324 | declare function ObjC(...params: any[]): ClassDecorator & MethodDecorator;
|
325 |
|
326 | /**
|
327 | * Important: Not applicable to Java method parameters (Android platform)
|
328 | * Decorates a parameter in an Objective-C exposed method with its native type.
|
329 | * @param type The native type for the parameter.
|
330 | */
|
331 | declare function ObjCParam(type: any): ParameterDecorator;
|
332 |
|
333 | declare function Log(data: any): void;
|
334 | declare function log(data: any): void;
|
335 | declare function fail(data: any): void;
|
336 |
|
337 | /**
|
338 | * Calls a function after a specified delay.
|
339 | * @param callback The function to be called.
|
340 | * @param milliseconds The time to wait before the function is called. Defaults to 0.
|
341 | */
|
342 | // declare function setTimeout(callback: Function, milliseconds?: number): number;
|
343 |
|
344 | /**
|
345 | * Clears the delay set by a call to the setTimeout function.
|
346 | * @param id The identifier returned by the previously called setTimeout() method.
|
347 | */
|
348 | // declare function clearTimeout(id: number): void;
|
349 |
|
350 | /**
|
351 | * Calls a function repeatedly with a delay between each call.
|
352 | * @param callback The function to be called.
|
353 | * @param milliseconds The delay between each function call.
|
354 | */
|
355 | // declare function setInterval(callback: Function, milliseconds?: number): number;
|
356 |
|
357 | /**
|
358 | * Clears repeated function which was set up by calling setInterval().
|
359 | * @param id The identifier returned by the setInterval() method.
|
360 | */
|
361 | // declare function clearInterval(id: number): void;
|
362 |
|
363 | declare function zonedCallback<T = Function>(callback: T): T;
|
364 |
|
365 | /**
|
366 | * Create a Java long from a number
|
367 | */
|
368 | declare function long(value: number): any;
|
369 |
|
370 | /**
|
371 | * Create a Java byte from a number
|
372 | */
|
373 | declare function byte(value: number): any;
|
374 |
|
375 | /**
|
376 | * Create a Java short from a number
|
377 | */
|
378 | declare function short(value: number): any;
|
379 |
|
380 | /**
|
381 | * Create a Java double from a number
|
382 | */
|
383 | declare function double(value: number): any;
|
384 |
|
385 | /**
|
386 | * Create a Java float from a number
|
387 | */
|
388 | declare function float(value: number): any;
|
389 |
|
390 | /**
|
391 | * Create a Java char from a string
|
392 | */
|
393 | declare function char(value: string): any;
|