source: trip-planner-front/node_modules/zone.js/zone.d.ts@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 54.9 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/// <amd-module name="angular/packages/zone.js/lib/zone" />
9/**
10 * Suppress closure compiler errors about unknown 'global' variable
11 * @fileoverview
12 * @suppress {undefinedVars}
13 */
14/**
15 * Zone is a mechanism for intercepting and keeping track of asynchronous work.
16 *
17 * A Zone is a global object which is configured with rules about how to intercept and keep track
18 * of the asynchronous callbacks. Zone has these responsibilities:
19 *
20 * 1. Intercept asynchronous task scheduling
21 * 2. Wrap callbacks for error-handling and zone tracking across async operations.
22 * 3. Provide a way to attach data to zones
23 * 4. Provide a context specific last frame error handling
24 * 5. (Intercept blocking methods)
25 *
26 * A zone by itself does not do anything, instead it relies on some other code to route existing
27 * platform API through it. (The zone library ships with code which monkey patches all of the
28 * browsers's asynchronous API and redirects them through the zone for interception.)
29 *
30 * In its simplest form a zone allows one to intercept the scheduling and calling of asynchronous
31 * operations, and execute additional code before as well as after the asynchronous task. The rules
32 * of interception are configured using [ZoneConfig]. There can be many different zone instances in
33 * a system, but only one zone is active at any given time which can be retrieved using
34 * [Zone#current].
35 *
36 *
37 *
38 * ## Callback Wrapping
39 *
40 * An important aspect of the zones is that they should persist across asynchronous operations. To
41 * achieve this, when a future work is scheduled through async API, it is necessary to capture, and
42 * subsequently restore the current zone. For example if a code is running in zone `b` and it
43 * invokes `setTimeout` to scheduleTask work later, the `setTimeout` method needs to 1) capture the
44 * current zone and 2) wrap the `wrapCallback` in code which will restore the current zone `b` once
45 * the wrapCallback executes. In this way the rules which govern the current code are preserved in
46 * all future asynchronous tasks. There could be a different zone `c` which has different rules and
47 * is associated with different asynchronous tasks. As these tasks are processed, each asynchronous
48 * wrapCallback correctly restores the correct zone, as well as preserves the zone for future
49 * asynchronous callbacks.
50 *
51 * Example: Suppose a browser page consist of application code as well as third-party
52 * advertisement code. (These two code bases are independent, developed by different mutually
53 * unaware developers.) The application code may be interested in doing global error handling and
54 * so it configures the `app` zone to send all of the errors to the server for analysis, and then
55 * executes the application in the `app` zone. The advertising code is interested in the same
56 * error processing but it needs to send the errors to a different third-party. So it creates the
57 * `ads` zone with a different error handler. Now both advertising as well as application code
58 * create many asynchronous operations, but the [Zone] will ensure that all of the asynchronous
59 * operations created from the application code will execute in `app` zone with its error
60 * handler and all of the advertisement code will execute in the `ads` zone with its error handler.
61 * This will not only work for the async operations created directly, but also for all subsequent
62 * asynchronous operations.
63 *
64 * If you think of chain of asynchronous operations as a thread of execution (bit of a stretch)
65 * then [Zone#current] will act as a thread local variable.
66 *
67 *
68 *
69 * ## Asynchronous operation scheduling
70 *
71 * In addition to wrapping the callbacks to restore the zone, all operations which cause a
72 * scheduling of work for later are routed through the current zone which is allowed to intercept
73 * them by adding work before or after the wrapCallback as well as using different means of
74 * achieving the request. (Useful for unit testing, or tracking of requests). In some instances
75 * such as `setTimeout` the wrapping of the wrapCallback and scheduling is done in the same
76 * wrapCallback, but there are other examples such as `Promises` where the `then` wrapCallback is
77 * wrapped, but the execution of `then` is triggered by `Promise` scheduling `resolve` work.
78 *
79 * Fundamentally there are three kinds of tasks which can be scheduled:
80 *
81 * 1. [MicroTask] used for doing work right after the current task. This is non-cancelable which is
82 * guaranteed to run exactly once and immediately.
83 * 2. [MacroTask] used for doing work later. Such as `setTimeout`. This is typically cancelable
84 * which is guaranteed to execute at least once after some well understood delay.
85 * 3. [EventTask] used for listening on some future event. This may execute zero or more times, with
86 * an unknown delay.
87 *
88 * Each asynchronous API is modeled and routed through one of these APIs.
89 *
90 *
91 * ### [MicroTask]
92 *
93 * [MicroTask]s represent work which will be done in current VM turn as soon as possible, before VM
94 * yielding.
95 *
96 *
97 * ### [MacroTask]
98 *
99 * [MacroTask]s represent work which will be done after some delay. (Sometimes the delay is
100 * approximate such as on next available animation frame). Typically these methods include:
101 * `setTimeout`, `setImmediate`, `setInterval`, `requestAnimationFrame`, and all browser specific
102 * variants.
103 *
104 *
105 * ### [EventTask]
106 *
107 * [EventTask]s represent a request to create a listener on an event. Unlike the other task
108 * events they may never be executed, but typically execute more than once. There is no queue of
109 * events, rather their callbacks are unpredictable both in order and time.
110 *
111 *
112 * ## Global Error Handling
113 *
114 *
115 * ## Composability
116 *
117 * Zones can be composed together through [Zone.fork()]. A child zone may create its own set of
118 * rules. A child zone is expected to either:
119 *
120 * 1. Delegate the interception to a parent zone, and optionally add before and after wrapCallback
121 * hooks.
122 * 2. Process the request itself without delegation.
123 *
124 * Composability allows zones to keep their concerns clean. For example a top most zone may choose
125 * to handle error handling, while child zones may choose to do user action tracking.
126 *
127 *
128 * ## Root Zone
129 *
130 * At the start the browser will run in a special root zone, which is configured to behave exactly
131 * like the platform, making any existing code which is not zone-aware behave as expected. All
132 * zones are children of the root zone.
133 *
134 */
135interface Zone {
136 /**
137 *
138 * @returns {Zone} The parent Zone.
139 */
140 parent: Zone | null;
141 /**
142 * @returns {string} The Zone name (useful for debugging)
143 */
144 name: string;
145 /**
146 * Returns a value associated with the `key`.
147 *
148 * If the current zone does not have a key, the request is delegated to the parent zone. Use
149 * [ZoneSpec.properties] to configure the set of properties associated with the current zone.
150 *
151 * @param key The key to retrieve.
152 * @returns {any} The value for the key, or `undefined` if not found.
153 */
154 get(key: string): any;
155 /**
156 * Returns a Zone which defines a `key`.
157 *
158 * Recursively search the parent Zone until a Zone which has a property `key` is found.
159 *
160 * @param key The key to use for identification of the returned zone.
161 * @returns {Zone} The Zone which defines the `key`, `null` if not found.
162 */
163 getZoneWith(key: string): Zone | null;
164 /**
165 * Used to create a child zone.
166 *
167 * @param zoneSpec A set of rules which the child zone should follow.
168 * @returns {Zone} A new child zone.
169 */
170 fork(zoneSpec: ZoneSpec): Zone;
171 /**
172 * Wraps a callback function in a new function which will properly restore the current zone upon
173 * invocation.
174 *
175 * The wrapped function will properly forward `this` as well as `arguments` to the `callback`.
176 *
177 * Before the function is wrapped the zone can intercept the `callback` by declaring
178 * [ZoneSpec.onIntercept].
179 *
180 * @param callback the function which will be wrapped in the zone.
181 * @param source A unique debug location of the API being wrapped.
182 * @returns {function(): *} A function which will invoke the `callback` through [Zone.runGuarded].
183 */
184 wrap<F extends Function>(callback: F, source: string): F;
185 /**
186 * Invokes a function in a given zone.
187 *
188 * The invocation of `callback` can be intercepted by declaring [ZoneSpec.onInvoke].
189 *
190 * @param callback The function to invoke.
191 * @param applyThis
192 * @param applyArgs
193 * @param source A unique debug location of the API being invoked.
194 * @returns {any} Value from the `callback` function.
195 */
196 run<T>(callback: Function, applyThis?: any, applyArgs?: any[], source?: string): T;
197 /**
198 * Invokes a function in a given zone and catches any exceptions.
199 *
200 * Any exceptions thrown will be forwarded to [Zone.HandleError].
201 *
202 * The invocation of `callback` can be intercepted by declaring [ZoneSpec.onInvoke]. The
203 * handling of exceptions can be intercepted by declaring [ZoneSpec.handleError].
204 *
205 * @param callback The function to invoke.
206 * @param applyThis
207 * @param applyArgs
208 * @param source A unique debug location of the API being invoked.
209 * @returns {any} Value from the `callback` function.
210 */
211 runGuarded<T>(callback: Function, applyThis?: any, applyArgs?: any[], source?: string): T;
212 /**
213 * Execute the Task by restoring the [Zone.currentTask] in the Task's zone.
214 *
215 * @param task to run
216 * @param applyThis
217 * @param applyArgs
218 * @returns {any} Value from the `task.callback` function.
219 */
220 runTask<T>(task: Task, applyThis?: any, applyArgs?: any): T;
221 /**
222 * Schedule a MicroTask.
223 *
224 * @param source
225 * @param callback
226 * @param data
227 * @param customSchedule
228 */
229 scheduleMicroTask(source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void): MicroTask;
230 /**
231 * Schedule a MacroTask.
232 *
233 * @param source
234 * @param callback
235 * @param data
236 * @param customSchedule
237 * @param customCancel
238 */
239 scheduleMacroTask(source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, customCancel?: (task: Task) => void): MacroTask;
240 /**
241 * Schedule an EventTask.
242 *
243 * @param source
244 * @param callback
245 * @param data
246 * @param customSchedule
247 * @param customCancel
248 */
249 scheduleEventTask(source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, customCancel?: (task: Task) => void): EventTask;
250 /**
251 * Schedule an existing Task.
252 *
253 * Useful for rescheduling a task which was already canceled.
254 *
255 * @param task
256 */
257 scheduleTask<T extends Task>(task: T): T;
258 /**
259 * Allows the zone to intercept canceling of scheduled Task.
260 *
261 * The interception is configured using [ZoneSpec.onCancelTask]. The default canceler invokes
262 * the [Task.cancelFn].
263 *
264 * @param task
265 * @returns {any}
266 */
267 cancelTask(task: Task): any;
268}
269interface ZoneType {
270 /**
271 * @returns {Zone} Returns the current [Zone]. The only way to change
272 * the current zone is by invoking a run() method, which will update the current zone for the
273 * duration of the run method callback.
274 */
275 current: Zone;
276 /**
277 * @returns {Task} The task associated with the current execution.
278 */
279 currentTask: Task | null;
280 /**
281 * Verify that Zone has been correctly patched. Specifically that Promise is zone aware.
282 */
283 assertZonePatched(): void;
284 /**
285 * Return the root zone.
286 */
287 root: Zone;
288 /**
289 * load patch for specified native module, allow user to
290 * define their own patch, user can use this API after loading zone.js
291 */
292 __load_patch(name: string, fn: _PatchFn, ignoreDuplicate?: boolean): void;
293 /**
294 * Zone symbol API to generate a string with __zone_symbol__ prefix
295 */
296 __symbol__(name: string): string;
297}
298/**
299 * Patch Function to allow user define their own monkey patch module.
300 */
301declare type _PatchFn = (global: Window, Zone: ZoneType, api: _ZonePrivate) => void;
302/**
303 * _ZonePrivate interface to provide helper method to help user implement
304 * their own monkey patch module.
305 */
306interface _ZonePrivate {
307 currentZoneFrame: () => _ZoneFrame;
308 symbol: (name: string) => string;
309 scheduleMicroTask: (task?: MicroTask) => void;
310 onUnhandledError: (error: Error) => void;
311 microtaskDrainDone: () => void;
312 showUncaughtError: () => boolean;
313 patchEventTarget: (global: any, apis: any[], options?: any) => boolean[];
314 patchOnProperties: (obj: any, properties: string[] | null, prototype?: any) => void;
315 patchThen: (ctro: Function) => void;
316 patchMethod: (target: any, name: string, patchFn: (delegate: Function, delegateName: string, name: string) => (self: any, args: any[]) => any) => Function | null;
317 bindArguments: (args: any[], source: string) => any[];
318 patchMacroTask: (obj: any, funcName: string, metaCreator: (self: any, args: any[]) => any) => void;
319 patchEventPrototype: (_global: any, api: _ZonePrivate) => void;
320 isIEOrEdge: () => boolean;
321 ObjectDefineProperty: (o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => any;
322 ObjectGetOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
323 ObjectCreate(o: object | null, properties?: PropertyDescriptorMap & ThisType<any>): any;
324 ArraySlice(start?: number, end?: number): any[];
325 patchClass: (className: string) => void;
326 wrapWithCurrentZone: (callback: any, source: string) => any;
327 filterProperties: (target: any, onProperties: string[], ignoreProperties: any[]) => string[];
328 attachOriginToPatched: (target: any, origin: any) => void;
329 _redefineProperty: (target: any, callback: string, desc: any) => void;
330 patchCallbacks: (api: _ZonePrivate, target: any, targetName: string, method: string, callbacks: string[]) => void;
331 getGlobalObjects: () => {
332 globalSources: any;
333 zoneSymbolEventNames: any;
334 eventNames: string[];
335 isBrowser: boolean;
336 isMix: boolean;
337 isNode: boolean;
338 TRUE_STR: string;
339 FALSE_STR: string;
340 ZONE_SYMBOL_PREFIX: string;
341 ADD_EVENT_LISTENER_STR: string;
342 REMOVE_EVENT_LISTENER_STR: string;
343 } | undefined;
344}
345/**
346 * _ZoneFrame represents zone stack frame information
347 */
348interface _ZoneFrame {
349 parent: _ZoneFrame | null;
350 zone: Zone;
351}
352interface UncaughtPromiseError extends Error {
353 zone: Zone;
354 task: Task;
355 promise: Promise<any>;
356 rejection: any;
357 throwOriginal?: boolean;
358}
359/**
360 * Provides a way to configure the interception of zone events.
361 *
362 * Only the `name` property is required (all other are optional).
363 */
364interface ZoneSpec {
365 /**
366 * The name of the zone. Useful when debugging Zones.
367 */
368 name: string;
369 /**
370 * A set of properties to be associated with Zone. Use [Zone.get] to retrieve them.
371 */
372 properties?: {
373 [key: string]: any;
374 };
375 /**
376 * Allows the interception of zone forking.
377 *
378 * When the zone is being forked, the request is forwarded to this method for interception.
379 *
380 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
381 * @param currentZone The current [Zone] where the current interceptor has been declared.
382 * @param targetZone The [Zone] which originally received the request.
383 * @param zoneSpec The argument passed into the `fork` method.
384 */
385 onFork?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, zoneSpec: ZoneSpec) => Zone;
386 /**
387 * Allows interception of the wrapping of the callback.
388 *
389 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
390 * @param currentZone The current [Zone] where the current interceptor has been declared.
391 * @param targetZone The [Zone] which originally received the request.
392 * @param delegate The argument passed into the `wrap` method.
393 * @param source The argument passed into the `wrap` method.
394 */
395 onIntercept?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, source: string) => Function;
396 /**
397 * Allows interception of the callback invocation.
398 *
399 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
400 * @param currentZone The current [Zone] where the current interceptor has been declared.
401 * @param targetZone The [Zone] which originally received the request.
402 * @param delegate The argument passed into the `run` method.
403 * @param applyThis The argument passed into the `run` method.
404 * @param applyArgs The argument passed into the `run` method.
405 * @param source The argument passed into the `run` method.
406 */
407 onInvoke?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, applyThis: any, applyArgs?: any[], source?: string) => any;
408 /**
409 * Allows interception of the error handling.
410 *
411 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
412 * @param currentZone The current [Zone] where the current interceptor has been declared.
413 * @param targetZone The [Zone] which originally received the request.
414 * @param error The argument passed into the `handleError` method.
415 */
416 onHandleError?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any) => boolean;
417 /**
418 * Allows interception of task scheduling.
419 *
420 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
421 * @param currentZone The current [Zone] where the current interceptor has been declared.
422 * @param targetZone The [Zone] which originally received the request.
423 * @param task The argument passed into the `scheduleTask` method.
424 */
425 onScheduleTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task) => Task;
426 onInvokeTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, applyThis: any, applyArgs?: any[]) => any;
427 /**
428 * Allows interception of task cancellation.
429 *
430 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
431 * @param currentZone The current [Zone] where the current interceptor has been declared.
432 * @param targetZone The [Zone] which originally received the request.
433 * @param task The argument passed into the `cancelTask` method.
434 */
435 onCancelTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task) => any;
436 /**
437 * Notifies of changes to the task queue empty status.
438 *
439 * @param parentZoneDelegate Delegate which performs the parent [ZoneSpec] operation.
440 * @param currentZone The current [Zone] where the current interceptor has been declared.
441 * @param targetZone The [Zone] which originally received the request.
442 * @param hasTaskState
443 */
444 onHasTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, hasTaskState: HasTaskState) => void;
445}
446/**
447 * A delegate when intercepting zone operations.
448 *
449 * A ZoneDelegate is needed because a child zone can't simply invoke a method on a parent zone. For
450 * example a child zone wrap can't just call parent zone wrap. Doing so would create a callback
451 * which is bound to the parent zone. What we are interested in is intercepting the callback before
452 * it is bound to any zone. Furthermore, we also need to pass the targetZone (zone which received
453 * the original request) to the delegate.
454 *
455 * The ZoneDelegate methods mirror those of Zone with an addition of extra targetZone argument in
456 * the method signature. (The original Zone which received the request.) Some methods are renamed
457 * to prevent confusion, because they have slightly different semantics and arguments.
458 *
459 * - `wrap` => `intercept`: The `wrap` method delegates to `intercept`. The `wrap` method returns
460 * a callback which will run in a given zone, where as intercept allows wrapping the callback
461 * so that additional code can be run before and after, but does not associate the callback
462 * with the zone.
463 * - `run` => `invoke`: The `run` method delegates to `invoke` to perform the actual execution of
464 * the callback. The `run` method switches to new zone; saves and restores the `Zone.current`;
465 * and optionally performs error handling. The invoke is not responsible for error handling,
466 * or zone management.
467 *
468 * Not every method is usually overwritten in the child zone, for this reason the ZoneDelegate
469 * stores the closest zone which overwrites this behavior along with the closest ZoneSpec.
470 *
471 * NOTE: We have tried to make this API analogous to Event bubbling with target and current
472 * properties.
473 *
474 * Note: The ZoneDelegate treats ZoneSpec as class. This allows the ZoneSpec to use its `this` to
475 * store internal state.
476 */
477interface ZoneDelegate {
478 zone: Zone;
479 fork(targetZone: Zone, zoneSpec: ZoneSpec): Zone;
480 intercept(targetZone: Zone, callback: Function, source: string): Function;
481 invoke(targetZone: Zone, callback: Function, applyThis?: any, applyArgs?: any[], source?: string): any;
482 handleError(targetZone: Zone, error: any): boolean;
483 scheduleTask(targetZone: Zone, task: Task): Task;
484 invokeTask(targetZone: Zone, task: Task, applyThis?: any, applyArgs?: any[]): any;
485 cancelTask(targetZone: Zone, task: Task): any;
486 hasTask(targetZone: Zone, isEmpty: HasTaskState): void;
487}
488declare type HasTaskState = {
489 microTask: boolean;
490 macroTask: boolean;
491 eventTask: boolean;
492 change: TaskType;
493};
494/**
495 * Task type: `microTask`, `macroTask`, `eventTask`.
496 */
497declare type TaskType = 'microTask' | 'macroTask' | 'eventTask';
498/**
499 * Task type: `notScheduled`, `scheduling`, `scheduled`, `running`, `canceling`, 'unknown'.
500 */
501declare type TaskState = 'notScheduled' | 'scheduling' | 'scheduled' | 'running' | 'canceling' | 'unknown';
502/**
503 */
504interface TaskData {
505 /**
506 * A periodic [MacroTask] is such which get automatically rescheduled after it is executed.
507 */
508 isPeriodic?: boolean;
509 /**
510 * Delay in milliseconds when the Task will run.
511 */
512 delay?: number;
513 /**
514 * identifier returned by the native setTimeout.
515 */
516 handleId?: number;
517}
518/**
519 * Represents work which is executed with a clean stack.
520 *
521 * Tasks are used in Zones to mark work which is performed on clean stack frame. There are three
522 * kinds of task. [MicroTask], [MacroTask], and [EventTask].
523 *
524 * A JS VM can be modeled as a [MicroTask] queue, [MacroTask] queue, and [EventTask] set.
525 *
526 * - [MicroTask] queue represents a set of tasks which are executing right after the current stack
527 * frame becomes clean and before a VM yield. All [MicroTask]s execute in order of insertion
528 * before VM yield and the next [MacroTask] is executed.
529 * - [MacroTask] queue represents a set of tasks which are executed one at a time after each VM
530 * yield. The queue is ordered by time, and insertions can happen in any location.
531 * - [EventTask] is a set of tasks which can at any time be inserted to the end of the [MacroTask]
532 * queue. This happens when the event fires.
533 *
534 */
535interface Task {
536 /**
537 * Task type: `microTask`, `macroTask`, `eventTask`.
538 */
539 type: TaskType;
540 /**
541 * Task state: `notScheduled`, `scheduling`, `scheduled`, `running`, `canceling`, `unknown`.
542 */
543 state: TaskState;
544 /**
545 * Debug string representing the API which requested the scheduling of the task.
546 */
547 source: string;
548 /**
549 * The Function to be used by the VM upon entering the [Task]. This function will delegate to
550 * [Zone.runTask] and delegate to `callback`.
551 */
552 invoke: Function;
553 /**
554 * Function which needs to be executed by the Task after the [Zone.currentTask] has been set to
555 * the current task.
556 */
557 callback: Function;
558 /**
559 * Task specific options associated with the current task. This is passed to the `scheduleFn`.
560 */
561 data?: TaskData;
562 /**
563 * Represents the default work which needs to be done to schedule the Task by the VM.
564 *
565 * A zone may choose to intercept this function and perform its own scheduling.
566 */
567 scheduleFn?: (task: Task) => void;
568 /**
569 * Represents the default work which needs to be done to un-schedule the Task from the VM. Not all
570 * Tasks are cancelable, and therefore this method is optional.
571 *
572 * A zone may chose to intercept this function and perform its own un-scheduling.
573 */
574 cancelFn?: (task: Task) => void;
575 /**
576 * @type {Zone} The zone which will be used to invoke the `callback`. The Zone is captured
577 * at the time of Task creation.
578 */
579 readonly zone: Zone;
580 /**
581 * Number of times the task has been executed, or -1 if canceled.
582 */
583 runCount: number;
584 /**
585 * Cancel the scheduling request. This method can be called from `ZoneSpec.onScheduleTask` to
586 * cancel the current scheduling interception. Once canceled the task can be discarded or
587 * rescheduled using `Zone.scheduleTask` on a different zone.
588 */
589 cancelScheduleRequest(): void;
590}
591interface MicroTask extends Task {
592 type: 'microTask';
593}
594interface MacroTask extends Task {
595 type: 'macroTask';
596}
597interface EventTask extends Task {
598 type: 'eventTask';
599}
600declare const Zone: ZoneType;
601/**
602 * @license
603 * Copyright Google LLC All Rights Reserved.
604 *
605 * Use of this source code is governed by an MIT-style license that can be
606 * found in the LICENSE file at https://angular.io/license
607 */
608
609/**
610 * Additional `EventTarget` methods added by `Zone.js`.
611 *
612 * 1. removeAllListeners, remove all event listeners of the given event name.
613 * 2. eventListeners, get all event listeners of the given event name.
614 */
615interface EventTarget {
616 /**
617 *
618 * Remove all event listeners by name for this event target.
619 *
620 * This method is optional because it may not be available if you use `noop zone` when
621 * bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
622 *
623 * If the `eventName` is provided, will remove event listeners of that name.
624 * If the `eventName` is not provided, will remove all event listeners associated with
625 * `EventTarget`.
626 *
627 * @param eventName the name of the event, such as `click`. This parameter is optional.
628 */
629 removeAllListeners?(eventName?: string): void;
630 /**
631 *
632 * Retrieve all event listeners by name.
633 *
634 * This method is optional because it may not be available if you use `noop zone` when
635 * bootstrapping Angular application or disable the `EventTarget` monkey patch by `zone.js`.
636 *
637 * If the `eventName` is provided, will return an array of event handlers or event listener
638 * objects of the given event.
639 * If the `eventName` is not provided, will return all listeners.
640 *
641 * @param eventName the name of the event, such as click. This parameter is optional.
642 */
643 eventListeners?(eventName?: string): EventListenerOrEventListenerObject[];
644}
645/**
646 * @license
647 * Copyright Google LLC All Rights Reserved.
648 *
649 * Use of this source code is governed by an MIT-style license that can be
650 * found in the LICENSE file at https://angular.io/license
651 */
652
653/**
654 * Interface of `zone.js` configurations.
655 *
656 * You can define the following configurations on the `window/global` object before
657 * importing `zone.js` to change `zone.js` default behaviors.
658 */
659interface ZoneGlobalConfigurations {
660 /**
661 * Disable the monkey patch of the `Node.js` `EventEmitter` API.
662 *
663 * By default, `zone.js` monkey patches the `Node.js` `EventEmitter` APIs to make asynchronous
664 * callbacks of those APIs in the same zone when scheduled.
665 *
666 * Consider the following example:
667 *
668 * ```
669 * const EventEmitter = require('events');
670 * class MyEmitter extends EventEmitter {}
671 * const myEmitter = new MyEmitter();
672 *
673 * const zone = Zone.current.fork({name: 'myZone'});
674 * zone.run(() => {
675 * myEmitter.on('event', () => {
676 * console.log('an event occurs in the zone', Zone.current.name);
677 * // the callback runs in the zone when it is scheduled,
678 * // so the output is 'an event occurs in the zone myZone'.
679 * });
680 * });
681 * myEmitter.emit('event');
682 * ```
683 *
684 * If you set `__Zone_disable_EventEmitter = true` before importing `zone.js`,
685 * `zone.js` does not monkey patch the `EventEmitter` APIs and the above code
686 * outputs 'an event occurred <root>'.
687 */
688 __Zone_disable_EventEmitter?: boolean;
689
690 /**
691 * Disable the monkey patch of the `Node.js` `fs` API.
692 *
693 * By default, `zone.js` monkey patches `Node.js` `fs` APIs to make asynchronous callbacks of
694 * those APIs in the same zone when scheduled.
695 *
696 * Consider the following example:
697 *
698 * ```
699 * const fs = require('fs');
700 *
701 * const zone = Zone.current.fork({name: 'myZone'});
702 * zone.run(() => {
703 * fs.stat('/tmp/world', (err, stats) => {
704 * console.log('fs.stats() callback is invoked in the zone', Zone.current.name);
705 * // since the callback of the `fs.stat()` runs in the same zone
706 * // when it is called, so the output is 'fs.stats() callback is invoked in the zone myZone'.
707 * });
708 * });
709 * ```
710 *
711 * If you set `__Zone_disable_fs = true` before importing `zone.js`,
712 * `zone.js` does not monkey patch the `fs` API and the above code
713 * outputs 'get stats occurred <root>'.
714 */
715 __Zone_disable_fs?: boolean;
716
717 /**
718 * Disable the monkey patch of the `Node.js` `timer` API.
719 *
720 * By default, `zone.js` monkey patches the `Node.js` `timer` APIs to make asynchronous
721 * callbacks of those APIs in the same zone when scheduled.
722 *
723 * Consider the following example:
724 *
725 * ```
726 * const zone = Zone.current.fork({name: 'myZone'});
727 * zone.run(() => {
728 * setTimeout(() => {
729 * console.log('setTimeout() callback is invoked in the zone', Zone.current.name);
730 * // since the callback of `setTimeout()` runs in the same zone
731 * // when it is scheduled, so the output is 'setTimeout() callback is invoked in the zone
732 * // myZone'.
733 * });
734 * });
735 * ```
736 *
737 * If you set `__Zone_disable_timers = true` before importing `zone.js`,
738 * `zone.js` does not monkey patch the `timer` APIs and the above code
739 * outputs 'timeout <root>'.
740 */
741 __Zone_disable_node_timers?: boolean;
742
743 /**
744 * Disable the monkey patch of the `Node.js` `process.nextTick()` API.
745 *
746 * By default, `zone.js` monkey patches the `Node.js` `process.nextTick()` API to make the
747 * callback in the same zone when calling `process.nextTick()`.
748 *
749 * Consider the following example:
750 *
751 * ```
752 * const zone = Zone.current.fork({name: 'myZone'});
753 * zone.run(() => {
754 * process.nextTick(() => {
755 * console.log('process.nextTick() callback is invoked in the zone', Zone.current.name);
756 * // since the callback of `process.nextTick()` runs in the same zone
757 * // when it is scheduled, so the output is 'process.nextTick() callback is invoked in the
758 * // zone myZone'.
759 * });
760 * });
761 * ```
762 *
763 * If you set `__Zone_disable_nextTick = true` before importing `zone.js`,
764 * `zone.js` does not monkey patch the `process.nextTick()` API and the above code
765 * outputs 'nextTick <root>'.
766 */
767 __Zone_disable_nextTick?: boolean;
768
769 /**
770 * Disable the monkey patch of the `Node.js` `crypto` API.
771 *
772 * By default, `zone.js` monkey patches the `Node.js` `crypto` APIs to make asynchronous callbacks
773 * of those APIs in the same zone when called.
774 *
775 * Consider the following example:
776 *
777 * ```
778 * const crypto = require('crypto');
779 *
780 * const zone = Zone.current.fork({name: 'myZone'});
781 * zone.run(() => {
782 * crypto.randomBytes(() => {
783 * console.log('crypto.randomBytes() callback is invoked in the zone', Zone.current.name);
784 * // since the callback of `crypto.randomBytes()` runs in the same zone
785 * // when it is called, so the output is 'crypto.randomBytes() callback is invoked in the
786 * // zone myZone'.
787 * });
788 * });
789 * ```
790 *
791 * If you set `__Zone_disable_crypto = true` before importing `zone.js`,
792 * `zone.js` does not monkey patch the `crypto` API and the above code
793 * outputs 'crypto <root>'.
794 */
795 __Zone_disable_crypto?: boolean;
796
797 /**
798 * Disable the monkey patch of the `Object.defineProperty()` API.
799 *
800 * Note: This configuration is available only in the legacy bundle (dist/zone.js). This module is
801 * not available in the evergreen bundle (zone-evergreen.js).
802 *
803 * In the legacy browser, the default behavior of `zone.js` is to monkey patch
804 * `Object.defineProperty()` and `Object.create()` to try to ensure PropertyDescriptor parameter's
805 * configurable property to be true. This patch is only needed in some old mobile browsers.
806 *
807 * If you set `__Zone_disable_defineProperty = true` before importing `zone.js`,
808 * `zone.js` does not monkey patch the `Object.defineProperty()` API and does not
809 * modify desc.configurable to true.
810 *
811 */
812 __Zone_disable_defineProperty?: boolean;
813
814 /**
815 * Disable the monkey patch of the browser `registerElement()` API.
816 *
817 * NOTE: This configuration is only available in the legacy bundle (dist/zone.js), this
818 * module is not available in the evergreen bundle (zone-evergreen.js).
819 *
820 * In the legacy browser, the default behavior of `zone.js` is to monkey patch the
821 * `registerElement()` API to make asynchronous callbacks of the API in the same zone when
822 * `registerElement()` is called.
823 *
824 * Consider the following example:
825 *
826 * ```
827 * const proto = Object.create(HTMLElement.prototype);
828 * proto.createdCallback = function() {
829 * console.log('createdCallback is invoked in the zone', Zone.current.name);
830 * };
831 * proto.attachedCallback = function() {
832 * console.log('attachedCallback is invoked in the zone', Zone.current.name);
833 * };
834 * proto.detachedCallback = function() {
835 * console.log('detachedCallback is invoked in the zone', Zone.current.name);
836 * };
837 * proto.attributeChangedCallback = function() {
838 * console.log('attributeChangedCallback is invoked in the zone', Zone.current.name);
839 * };
840 *
841 * const zone = Zone.current.fork({name: 'myZone'});
842 * zone.run(() => {
843 * document.registerElement('x-elem', {prototype: proto});
844 * });
845 * ```
846 *
847 * When these callbacks are invoked, those callbacks will be in the zone when
848 * `registerElement()` is called.
849 *
850 * If you set `__Zone_disable_registerElement = true` before importing `zone.js`,
851 * `zone.js` does not monkey patch `registerElement()` API and the above code
852 * outputs '<root>'.
853 */
854 __Zone_disable_registerElement?: boolean;
855
856 /**
857 * Disable the monkey patch of the browser legacy `EventTarget` API.
858 *
859 * NOTE: This configuration is only available in the legacy bundle (dist/zone.js), this module
860 * is not available in the evergreen bundle (zone-evergreen.js).
861 *
862 * In some old browsers, the `EventTarget` is not available, so `zone.js` cannot directly monkey
863 * patch the `EventTarget`. Instead, `zone.js` patches all known HTML elements' prototypes (such
864 * as `HtmlDivElement`). The callback of the `addEventListener()` will be in the same zone when
865 * the `addEventListener()` is called.
866 *
867 * Consider the following example:
868 *
869 * ```
870 * const zone = Zone.current.fork({name: 'myZone'});
871 * zone.run(() => {
872 * div.addEventListener('click', () => {
873 * console.log('div click event listener is invoked in the zone', Zone.current.name);
874 * // the output is 'div click event listener is invoked in the zone myZone'.
875 * });
876 * });
877 * ```
878 *
879 * If you set `__Zone_disable_EventTargetLegacy = true` before importing `zone.js`
880 * In some old browsers, where `EventTarget` is not available, if you set
881 * `__Zone_disable_EventTargetLegacy = true` before importing `zone.js`, `zone.js` does not monkey
882 * patch all HTML element APIs and the above code outputs 'clicked <root>'.
883 */
884 __Zone_disable_EventTargetLegacy?: boolean;
885
886 /**
887 * Disable the monkey patch of the browser `timer` APIs.
888 *
889 * By default, `zone.js` monkey patches browser timer
890 * APIs (`setTimeout()`/`setInterval()`/`setImmediate()`) to make asynchronous callbacks of those
891 * APIs in the same zone when scheduled.
892 *
893 * Consider the following example:
894 *
895 * ```
896 * const zone = Zone.current.fork({name: 'myZone'});
897 * zone.run(() => {
898 * setTimeout(() => {
899 * console.log('setTimeout() callback is invoked in the zone', Zone.current.name);
900 * // since the callback of `setTimeout()` runs in the same zone
901 * // when it is scheduled, so the output is 'setTimeout() callback is invoked in the zone
902 * // myZone'.
903 * });
904 * });
905 * ```
906 *
907 * If you set `__Zone_disable_timers = true` before importing `zone.js`,
908 * `zone.js` does not monkey patch `timer` API and the above code
909 * outputs 'timeout <root>'.
910 *
911 */
912 __Zone_disable_timers?: boolean;
913
914 /**
915 * Disable the monkey patch of the browser `requestAnimationFrame()` API.
916 *
917 * By default, `zone.js` monkey patches the browser `requestAnimationFrame()` API
918 * to make the asynchronous callback of the `requestAnimationFrame()` in the same zone when
919 * scheduled.
920 *
921 * Consider the following example:
922 *
923 * ```
924 * const zone = Zone.current.fork({name: 'myZone'});
925 * zone.run(() => {
926 * requestAnimationFrame(() => {
927 * console.log('requestAnimationFrame() callback is invoked in the zone', Zone.current.name);
928 * // since the callback of `requestAnimationFrame()` will be in the same zone
929 * // when it is scheduled, so the output will be 'requestAnimationFrame() callback is invoked
930 * // in the zone myZone'
931 * });
932 * });
933 * ```
934 *
935 * If you set `__Zone_disable_requestAnimationFrame = true` before importing `zone.js`,
936 * `zone.js` does not monkey patch the `requestAnimationFrame()` API and the above code
937 * outputs 'raf <root>'.
938 */
939 __Zone_disable_requestAnimationFrame?: boolean;
940
941 /**
942 *
943 * Disable the monkey patching of the browser's `queueMicrotask()` API.
944 *
945 * By default, `zone.js` monkey patches the browser's `queueMicrotask()` API
946 * to ensure that `queueMicrotask()` callback is invoked in the same zone as zone used to invoke
947 * `queueMicrotask()`. And also the callback is running as `microTask` like
948 * `Promise.prototype.then()`.
949 *
950 * Consider the following example:
951 *
952 * ```
953 * const zone = Zone.current.fork({name: 'myZone'});
954 * zone.run(() => {
955 * queueMicrotask(() => {
956 * console.log('queueMicrotask() callback is invoked in the zone', Zone.current.name);
957 * // Since `queueMicrotask()` was invoked in `myZone`, same zone is restored
958 * // when 'queueMicrotask() callback is invoked, resulting in `myZone` being console logged.
959 * });
960 * });
961 * ```
962 *
963 * If you set `__Zone_disable_queueMicrotask = true` before importing `zone.js`,
964 * `zone.js` does not monkey patch the `queueMicrotask()` API and the above code
965 * output will change to: 'queueMicrotask() callback is invoked in the zone <root>'.
966 */
967 __Zone_disable_queueMicrotask?: boolean;
968
969 /**
970 *
971 * Disable the monkey patch of the browser blocking APIs(`alert()`/`prompt()`/`confirm()`).
972 */
973 __Zone_disable_blocking?: boolean;
974
975 /**
976 * Disable the monkey patch of the browser `EventTarget` APIs.
977 *
978 * By default, `zone.js` monkey patches EventTarget APIs. The callbacks of the
979 * `addEventListener()` run in the same zone when the `addEventListener()` is called.
980 *
981 * Consider the following example:
982 *
983 * ```
984 * const zone = Zone.current.fork({name: 'myZone'});
985 * zone.run(() => {
986 * div.addEventListener('click', () => {
987 * console.log('div event listener is invoked in the zone', Zone.current.name);
988 * // the output is 'div event listener is invoked in the zone myZone'.
989 * });
990 * });
991 * ```
992 *
993 * If you set `__Zone_disable_EventTarget = true` before importing `zone.js`,
994 * `zone.js` does not monkey patch EventTarget API and the above code
995 * outputs 'clicked <root>'.
996 *
997 */
998 __Zone_disable_EventTarget?: boolean;
999
1000 /**
1001 * Disable the monkey patch of the browser `FileReader` APIs.
1002 */
1003 __Zone_disable_FileReader?: boolean;
1004
1005 /**
1006 * Disable the monkey patch of the browser `MutationObserver` APIs.
1007 */
1008 __Zone_disable_MutationObserver?: boolean;
1009
1010 /**
1011 * Disable the monkey patch of the browser `IntersectionObserver` APIs.
1012 */
1013 __Zone_disable_IntersectionObserver?: boolean;
1014
1015 /**
1016 * Disable the monkey patch of the browser onProperty APIs(such as onclick).
1017 *
1018 * By default, `zone.js` monkey patches onXXX properties (such as onclick). The callbacks of onXXX
1019 * properties run in the same zone when the onXXX properties is set.
1020 *
1021 * Consider the following example:
1022 *
1023 * ```
1024 * const zone = Zone.current.fork({name: 'myZone'});
1025 * zone.run(() => {
1026 * div.onclick = () => {
1027 * console.log('div click event listener is invoked in the zone', Zone.current.name);
1028 * // the output will be 'div click event listener is invoked in the zone myZone'
1029 * }
1030 * });
1031 * ```
1032 *
1033 * If you set `__Zone_disable_on_property = true` before importing `zone.js`,
1034 * `zone.js` does not monkey patch onXXX properties and the above code
1035 * outputs 'clicked <root>'.
1036 *
1037 */
1038 __Zone_disable_on_property?: boolean;
1039
1040 /**
1041 * Disable the monkey patch of the browser `customElements` APIs.
1042 *
1043 * By default, `zone.js` monkey patches `customElements` APIs to make callbacks run in the
1044 * same zone when the `customElements.define()` is called.
1045 *
1046 * Consider the following example:
1047 *
1048 * ```
1049 * class TestCustomElement extends HTMLElement {
1050 * constructor() { super(); }
1051 * connectedCallback() {}
1052 * disconnectedCallback() {}
1053 * attributeChangedCallback(attrName, oldVal, newVal) {}
1054 * adoptedCallback() {}
1055 * }
1056 *
1057 * const zone = Zone.fork({name: 'myZone'});
1058 * zone.run(() => {
1059 * customElements.define('x-elem', TestCustomElement);
1060 * });
1061 * ```
1062 *
1063 * All those callbacks defined in TestCustomElement runs in the zone when
1064 * the `customElements.define()` is called.
1065 *
1066 * If you set `__Zone_disable_customElements = true` before importing `zone.js`,
1067 * `zone.js` does not monkey patch `customElements` APIs and the above code
1068 * runs inside <root> zone.
1069 */
1070 __Zone_disable_customElements?: boolean;
1071
1072 /**
1073 * Disable the monkey patch of the browser `XMLHttpRequest` APIs.
1074 *
1075 * By default, `zone.js` monkey patches `XMLHttpRequest` APIs to make XMLHttpRequest act
1076 * as macroTask.
1077 *
1078 * Consider the following example:
1079 *
1080 * ```
1081 * const zone = Zone.current.fork({
1082 * name: 'myZone',
1083 * onScheduleTask: (delegate, curr, target, task) => {
1084 * console.log('task is scheduled', task.type, task.source, task.zone.name);
1085 * return delegate.scheduleTask(target, task);
1086 * }
1087 * })
1088 * const xhr = new XMLHttpRequest();
1089 * zone.run(() => {
1090 * xhr.onload = function() {};
1091 * xhr.open('get', '/', true);
1092 * xhr.send();
1093 * });
1094 * ```
1095 *
1096 * In this example, the instance of XMLHttpRequest runs in the zone and acts as a macroTask. The
1097 * output is 'task is scheduled macroTask, XMLHttpRequest.send, zone'.
1098 *
1099 * If you set `__Zone_disable_XHR = true` before importing `zone.js`,
1100 * `zone.js` does not monkey patch `XMLHttpRequest` APIs and the above onScheduleTask callback
1101 * will not be called.
1102 *
1103 */
1104 __Zone_disable_XHR?: boolean;
1105
1106 /**
1107 * Disable the monkey patch of the browser geolocation APIs.
1108 *
1109 * By default, `zone.js` monkey patches geolocation APIs to make callbacks run in the same zone
1110 * when those APIs are called.
1111 *
1112 * Consider the following examples:
1113 *
1114 * ```
1115 * const zone = Zone.current.fork({
1116 * name: 'myZone'
1117 * });
1118 *
1119 * zone.run(() => {
1120 * navigator.geolocation.getCurrentPosition(pos => {
1121 * console.log('navigator.getCurrentPosition() callback is invoked in the zone',
1122 * Zone.current.name);
1123 * // output is 'navigator.getCurrentPosition() callback is invoked in the zone myZone'.
1124 * }
1125 * });
1126 * ```
1127 *
1128 * If set you `__Zone_disable_geolocation = true` before importing `zone.js`,
1129 * `zone.js` does not monkey patch geolocation APIs and the above code
1130 * outputs 'getCurrentPosition <root>'.
1131 *
1132 */
1133 __Zone_disable_geolocation?: boolean;
1134
1135 /**
1136 * Disable the monkey patch of the browser `canvas` APIs.
1137 *
1138 * By default, `zone.js` monkey patches `canvas` APIs to make callbacks run in the same zone when
1139 * those APIs are called.
1140 *
1141 * Consider the following example:
1142 *
1143 * ```
1144 * const zone = Zone.current.fork({
1145 * name: 'myZone'
1146 * });
1147 *
1148 * zone.run(() => {
1149 * canvas.toBlob(blog => {
1150 * console.log('canvas.toBlob() callback is invoked in the zone', Zone.current.name);
1151 * // output is 'canvas.toBlob() callback is invoked in the zone myZone'.
1152 * }
1153 * });
1154 * ```
1155 *
1156 * If you set `__Zone_disable_canvas = true` before importing `zone.js`,
1157 * `zone.js` does not monkey patch `canvas` APIs and the above code
1158 * outputs 'canvas.toBlob <root>'.
1159 */
1160 __Zone_disable_canvas?: boolean;
1161
1162 /**
1163 * Disable the `Promise` monkey patch.
1164 *
1165 * By default, `zone.js` monkey patches `Promise` APIs to make the `then()/catch()` callbacks in
1166 * the same zone when those callbacks are called.
1167 *
1168 * Consider the following examples:
1169 *
1170 * ```
1171 * const zone = Zone.current.fork({name: 'myZone'});
1172 *
1173 * const p = Promise.resolve(1);
1174 *
1175 * zone.run(() => {
1176 * p.then(() => {
1177 * console.log('then() callback is invoked in the zone', Zone.current.name);
1178 * // output is 'then() callback is invoked in the zone myZone'.
1179 * });
1180 * });
1181 * ```
1182 *
1183 * If you set `__Zone_disable_ZoneAwarePromise = true` before importing `zone.js`,
1184 * `zone.js` does not monkey patch `Promise` APIs and the above code
1185 * outputs 'promise then callback <root>'.
1186 */
1187 __Zone_disable_ZoneAwarePromise?: boolean;
1188
1189 /**
1190 * Define event names that users don't want monkey patched by the `zone.js`.
1191 *
1192 * By default, `zone.js` monkey patches EventTarget.addEventListener(). The event listener
1193 * callback runs in the same zone when the addEventListener() is called.
1194 *
1195 * Sometimes, you don't want all of the event names used in this patched version because it
1196 * impacts performance. For example, you might want `scroll` or `mousemove` event listeners to run
1197 * the native `addEventListener()` for better performance.
1198 *
1199 * Users can achieve this goal by defining `__zone_symbol__UNPATCHED_EVENTS = ['scroll',
1200 * 'mousemove'];` before importing `zone.js`.
1201 */
1202 __zone_symbol__UNPATCHED_EVENTS?: string[];
1203
1204 /**
1205 * Define the event names of the passive listeners.
1206 *
1207 * To add passive event listeners, you can use `elem.addEventListener('scroll', listener,
1208 * {passive: true});` or implement your own `EventManagerPlugin`.
1209 *
1210 * You can also define a global variable as follows:
1211 *
1212 * ```
1213 * __zone_symbol__PASSIVE_EVENTS = ['scroll'];
1214 * ```
1215 *
1216 * The preceding code makes all scroll event listeners passive.
1217 */
1218 __zone_symbol__PASSIVE_EVENTS?: string[];
1219
1220 /**
1221 * Disable wrapping uncaught promise rejection.
1222 *
1223 * By default, `zone.js` wraps the uncaught promise rejection in a new `Error` object
1224 * which contains additional information such as a value of the rejection and a stack trace.
1225 *
1226 * If you set `__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION = true;` before
1227 * importing `zone.js`, `zone.js` will not wrap the uncaught promise rejection.
1228 */
1229 __zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION?: boolean;
1230}
1231
1232/**
1233 * Interface of `zone-testing.js` test configurations.
1234 *
1235 * You can define the following configurations on the `window` or `global` object before
1236 * importing `zone-testing.js` to change `zone-testing.js` default behaviors in the test runner.
1237 */
1238interface ZoneTestConfigurations {
1239 /**
1240 * Disable the Jasmine integration.
1241 *
1242 * In the `zone-testing.js` bundle, by default, `zone-testing.js` monkey patches Jasmine APIs
1243 * to make Jasmine APIs run in specified zone.
1244 *
1245 * 1. Make the `describe()`/`xdescribe()`/`fdescribe()` methods run in the syncTestZone.
1246 * 2. Make the `it()`/`xit()`/`fit()`/`beforeEach()`/`afterEach()`/`beforeAll()`/`afterAll()`
1247 * methods run in the ProxyZone.
1248 *
1249 * With this patch, `async()`/`fakeAsync()` can work with the Jasmine runner.
1250 *
1251 * If you set `__Zone_disable_jasmine = true` before importing `zone-testing.js`,
1252 * `zone-testing.js` does not monkey patch the jasmine APIs and the `async()`/`fakeAsync()` cannot
1253 * work with the Jasmine runner any longer.
1254 */
1255 __Zone_disable_jasmine?: boolean;
1256
1257 /**
1258 * Disable the Mocha integration.
1259 *
1260 * In the `zone-testing.js` bundle, by default, `zone-testing.js` monkey patches the Mocha APIs
1261 * to make Mocha APIs run in the specified zone.
1262 *
1263 * 1. Make the `describe()`/`xdescribe()`/`fdescribe()` methods run in the syncTestZone.
1264 * 2. Make the `it()`/`xit()`/`fit()`/`beforeEach()`/`afterEach()`/`beforeAll()`/`afterAll()`
1265 * methods run in the ProxyZone.
1266 *
1267 * With this patch, `async()`/`fakeAsync()` can work with the Mocha runner.
1268 *
1269 * If you set `__Zone_disable_mocha = true` before importing `zone-testing.js`,
1270 * `zone-testing.js` does not monkey patch the Mocha APIs and the `async()/`fakeAsync()` can not
1271 * work with the Mocha runner any longer.
1272 */
1273 __Zone_disable_mocha?: boolean;
1274
1275 /**
1276 * Disable the Jest integration.
1277 *
1278 * In the `zone-testing.js` bundle, by default, `zone-testing.js` monkey patches Jest APIs
1279 * to make Jest APIs run in the specified zone.
1280 *
1281 * 1. Make the `describe()`/`xdescribe()`/`fdescribe()` methods run in the syncTestZone.
1282 * 2. Make the `it()`/`xit()`/`fit()`/`beforeEach()`/`afterEach()`/`before()`/`after()` methods
1283 * run in the ProxyZone.
1284 *
1285 * With this patch, `async()`/`fakeAsync()` can work with the Jest runner.
1286 *
1287 * If you set `__Zone_disable_jest = true` before importing `zone-testing.js`,
1288 * `zone-testing.js` does not monkey patch the jest APIs and `async()`/`fakeAsync()` cannot
1289 * work with the Jest runner any longer.
1290 */
1291 __Zone_disable_jest?: boolean;
1292
1293 /**
1294 * Disable monkey patch the jasmine clock APIs.
1295 *
1296 * By default, `zone-testing.js` monkey patches the `jasmine.clock()` API,
1297 * so the `jasmine.clock()` can work with the `fakeAsync()/tick()` API.
1298 *
1299 * Consider the following example:
1300 *
1301 * ```
1302 * describe('jasmine.clock integration', () => {
1303 * beforeEach(() => {
1304 * jasmine.clock().install();
1305 * });
1306 * afterEach(() => {
1307 * jasmine.clock().uninstall();
1308 * });
1309 * it('fakeAsync test', fakeAsync(() => {
1310 * setTimeout(spy, 100);
1311 * expect(spy).not.toHaveBeenCalled();
1312 * jasmine.clock().tick(100);
1313 * expect(spy).toHaveBeenCalled();
1314 * }));
1315 * });
1316 * ```
1317 *
1318 * In the `fakeAsync()` method, `jasmine.clock().tick()` works just like `tick()`.
1319 *
1320 * If you set `__zone_symbol__fakeAsyncDisablePatchingClock = true` before importing
1321 * `zone-testing.js`,`zone-testing.js` does not monkey patch the `jasmine.clock()` APIs and the
1322 * `jasmine.clock()` cannot work with `fakeAsync()` any longer.
1323 */
1324 __zone_symbol__fakeAsyncDisablePatchingClock?: boolean;
1325
1326 /**
1327 * Enable auto running into `fakeAsync()` when installing the `jasmine.clock()`.
1328 *
1329 * By default, `zone-testing.js` does not automatically run into `fakeAsync()`
1330 * if the `jasmine.clock().install()` is called.
1331 *
1332 * Consider the following example:
1333 *
1334 * ```
1335 * describe('jasmine.clock integration', () => {
1336 * beforeEach(() => {
1337 * jasmine.clock().install();
1338 * });
1339 * afterEach(() => {
1340 * jasmine.clock().uninstall();
1341 * });
1342 * it('fakeAsync test', fakeAsync(() => {
1343 * setTimeout(spy, 100);
1344 * expect(spy).not.toHaveBeenCalled();
1345 * jasmine.clock().tick(100);
1346 * expect(spy).toHaveBeenCalled();
1347 * }));
1348 * });
1349 * ```
1350 *
1351 * You must run `fakeAsync()` to make test cases in the `FakeAsyncTestZone`.
1352 *
1353 * If you set `__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched = true` before importing
1354 * `zone-testing.js`, `zone-testing.js` can run test case automatically in the
1355 * `FakeAsyncTestZone` without calling the `fakeAsync()`.
1356 *
1357 * Consider the following example:
1358 *
1359 * ```
1360 * describe('jasmine.clock integration', () => {
1361 * beforeEach(() => {
1362 * jasmine.clock().install();
1363 * });
1364 * afterEach(() => {
1365 * jasmine.clock().uninstall();
1366 * });
1367 * it('fakeAsync test', () => { // here we don't need to call fakeAsync
1368 * setTimeout(spy, 100);
1369 * expect(spy).not.toHaveBeenCalled();
1370 * jasmine.clock().tick(100);
1371 * expect(spy).toHaveBeenCalled();
1372 * });
1373 * });
1374 * ```
1375 *
1376 */
1377 __zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched?: boolean;
1378
1379 /**
1380 * Enable waiting for the unresolved promise in the `async()` test.
1381 *
1382 * In the `async()` test, `AsyncTestZone` waits for all the asynchronous tasks to finish. By
1383 * default, if some promises remain unresolved, `AsyncTestZone` does not wait and reports that it
1384 * received an unexpected result.
1385 *
1386 * Consider the following example:
1387 *
1388 * ```
1389 * describe('wait never resolved promise', () => {
1390 * it('async with never resolved promise test', async(() => {
1391 * const p = new Promise(() => {});
1392 * p.then(() => {
1393 * // do some expectation.
1394 * });
1395 * }))
1396 * });
1397 * ```
1398 *
1399 * By default, this case passes, because the callback of `p.then()` is never called. Because `p`
1400 * is an unresolved promise, there is no pending asynchronous task, which means the `async()`
1401 * method does not wait.
1402 *
1403 * If you set `__zone_symbol__supportWaitUnResolvedChainedPromise = true`, the above case
1404 * times out, because `async()` will wait for the unresolved promise.
1405 */
1406 __zone_symbol__supportWaitUnResolvedChainedPromise?: boolean;
1407}
1408
1409/**
1410 * The interface of the `zone.js` runtime configurations.
1411 *
1412 * These configurations can be defined on the `Zone` object after
1413 * importing zone.js to change behaviors. The differences between
1414 * the `ZoneRuntimeConfigurations` and the `ZoneGlobalConfigurations` are,
1415 *
1416 * 1. `ZoneGlobalConfigurations` must be defined on the `global/window` object before importing
1417 * `zone.js`. The value of the configuration cannot be changed at runtime.
1418 *
1419 * 2. `ZoneRuntimeConfigurations` must be defined on the `Zone` object after importing `zone.js`.
1420 * You can change the value of this configuration at runtime.
1421 *
1422 */
1423interface ZoneRuntimeConfigurations {
1424 /**
1425 * Ignore outputting errors to the console when uncaught Promise errors occur.
1426 *
1427 * By default, if an uncaught Promise error occurs, `zone.js` outputs the
1428 * error to the console by calling `console.error()`.
1429 *
1430 * If you set `__zone_symbol__ignoreConsoleErrorUncaughtError = true`, `zone.js` does not output
1431 * the uncaught error to `console.error()`.
1432 */
1433 __zone_symbol__ignoreConsoleErrorUncaughtError?: boolean;
1434}
Note: See TracBrowser for help on using the repository browser.