dealposbarcode 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3370 @@
1
+ "use strict";
2
+ (self["webpackChunkbarcode_app"] = self["webpackChunkbarcode_app"] || []).push([["polyfills"],{
3
+
4
+ /***/ 7435:
5
+ /*!**************************!*\
6
+ !*** ./src/polyfills.ts ***!
7
+ \**************************/
8
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
9
+
10
+ __webpack_require__.r(__webpack_exports__);
11
+ /* harmony import */ var zone_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! zone.js */ 4924);
12
+ /* harmony import */ var zone_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(zone_js__WEBPACK_IMPORTED_MODULE_0__);
13
+ /**
14
+ * This file includes polyfills needed by Angular and is loaded before the app.
15
+ * You can add your own extra polyfills to this file.
16
+ *
17
+ * This file is divided into 2 sections:
18
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
19
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
20
+ * file.
21
+ *
22
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
23
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
24
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
25
+ *
26
+ * Learn more in https://angular.io/guide/browser-support
27
+ */
28
+ /***************************************************************************************************
29
+ * BROWSER POLYFILLS
30
+ */
31
+ /**
32
+ * By default, zone.js will patch all possible macroTask and DomEvents
33
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
34
+ * because those flags need to be set before `zone.js` being loaded, and webpack
35
+ * will put import in the top of bundle, so user need to create a separate file
36
+ * in this directory (for example: zone-flags.ts), and put the following flags
37
+ * into that file, and then add the following code before importing zone.js.
38
+ * import './zone-flags';
39
+ *
40
+ * The flags allowed in zone-flags.ts are listed here.
41
+ *
42
+ * The following flags will work for all browsers.
43
+ *
44
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47
+ *
48
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
50
+ *
51
+ * (window as any).__Zone_enable_cross_context_check = true;
52
+ *
53
+ */
54
+ /***************************************************************************************************
55
+ * Zone JS is required by default for Angular itself.
56
+ */
57
+ // Included with Angular CLI.
58
+ /***************************************************************************************************
59
+ * APPLICATION IMPORTS
60
+ */
61
+
62
+
63
+ /***/ }),
64
+
65
+ /***/ 4924:
66
+ /*!***********************************************!*\
67
+ !*** ./node_modules/zone.js/fesm2015/zone.js ***!
68
+ \***********************************************/
69
+ /***/ (() => {
70
+
71
+
72
+ /**
73
+ * @license Angular v12.0.0-next.0
74
+ * (c) 2010-2020 Google LLC. https://angular.io/
75
+ * License: MIT
76
+ */
77
+
78
+ /**
79
+ * @license
80
+ * Copyright Google LLC All Rights Reserved.
81
+ *
82
+ * Use of this source code is governed by an MIT-style license that can be
83
+ * found in the LICENSE file at https://angular.io/license
84
+ */
85
+
86
+ const Zone$1 = function (global) {
87
+ const performance = global['performance'];
88
+
89
+ function mark(name) {
90
+ performance && performance['mark'] && performance['mark'](name);
91
+ }
92
+
93
+ function performanceMeasure(name, label) {
94
+ performance && performance['measure'] && performance['measure'](name, label);
95
+ }
96
+
97
+ mark('Zone'); // Initialize before it's accessed below.
98
+ // __Zone_symbol_prefix global can be used to override the default zone
99
+ // symbol prefix with a custom one if needed.
100
+
101
+ const symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__';
102
+
103
+ function __symbol__(name) {
104
+ return symbolPrefix + name;
105
+ }
106
+
107
+ const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true;
108
+
109
+ if (global['Zone']) {
110
+ // if global['Zone'] already exists (maybe zone.js was already loaded or
111
+ // some other lib also registered a global object named Zone), we may need
112
+ // to throw an error, but sometimes user may not want this error.
113
+ // For example,
114
+ // we have two web pages, page1 includes zone.js, page2 doesn't.
115
+ // and the 1st time user load page1 and page2, everything work fine,
116
+ // but when user load page2 again, error occurs because global['Zone'] already exists.
117
+ // so we add a flag to let user choose whether to throw this error or not.
118
+ // By default, if existing Zone is from zone.js, we will not throw the error.
119
+ if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') {
120
+ throw new Error('Zone already loaded.');
121
+ } else {
122
+ return global['Zone'];
123
+ }
124
+ }
125
+
126
+ class Zone {
127
+ constructor(parent, zoneSpec) {
128
+ this._parent = parent;
129
+ this._name = zoneSpec ? zoneSpec.name || 'unnamed' : '<root>';
130
+ this._properties = zoneSpec && zoneSpec.properties || {};
131
+ this._zoneDelegate = new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
132
+ }
133
+
134
+ static assertZonePatched() {
135
+ if (global['Promise'] !== patches['ZoneAwarePromise']) {
136
+ throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + 'has been overwritten.\n' + 'Most likely cause is that a Promise polyfill has been loaded ' + 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + 'If you must load one, do so before loading zone.js.)');
137
+ }
138
+ }
139
+
140
+ static get root() {
141
+ let zone = Zone.current;
142
+
143
+ while (zone.parent) {
144
+ zone = zone.parent;
145
+ }
146
+
147
+ return zone;
148
+ }
149
+
150
+ static get current() {
151
+ return _currentZoneFrame.zone;
152
+ }
153
+
154
+ static get currentTask() {
155
+ return _currentTask;
156
+ } // tslint:disable-next-line:require-internal-with-underscore
157
+
158
+
159
+ static __load_patch(name, fn, ignoreDuplicate = false) {
160
+ if (patches.hasOwnProperty(name)) {
161
+ // `checkDuplicate` option is defined from global variable
162
+ // so it works for all modules.
163
+ // `ignoreDuplicate` can work for the specified module
164
+ if (!ignoreDuplicate && checkDuplicate) {
165
+ throw Error('Already loaded patch: ' + name);
166
+ }
167
+ } else if (!global['__Zone_disable_' + name]) {
168
+ const perfName = 'Zone:' + name;
169
+ mark(perfName);
170
+ patches[name] = fn(global, Zone, _api);
171
+ performanceMeasure(perfName, perfName);
172
+ }
173
+ }
174
+
175
+ get parent() {
176
+ return this._parent;
177
+ }
178
+
179
+ get name() {
180
+ return this._name;
181
+ }
182
+
183
+ get(key) {
184
+ const zone = this.getZoneWith(key);
185
+ if (zone) return zone._properties[key];
186
+ }
187
+
188
+ getZoneWith(key) {
189
+ let current = this;
190
+
191
+ while (current) {
192
+ if (current._properties.hasOwnProperty(key)) {
193
+ return current;
194
+ }
195
+
196
+ current = current._parent;
197
+ }
198
+
199
+ return null;
200
+ }
201
+
202
+ fork(zoneSpec) {
203
+ if (!zoneSpec) throw new Error('ZoneSpec required!');
204
+ return this._zoneDelegate.fork(this, zoneSpec);
205
+ }
206
+
207
+ wrap(callback, source) {
208
+ if (typeof callback !== 'function') {
209
+ throw new Error('Expecting function got: ' + callback);
210
+ }
211
+
212
+ const _callback = this._zoneDelegate.intercept(this, callback, source);
213
+
214
+ const zone = this;
215
+ return function () {
216
+ return zone.runGuarded(_callback, this, arguments, source);
217
+ };
218
+ }
219
+
220
+ run(callback, applyThis, applyArgs, source) {
221
+ _currentZoneFrame = {
222
+ parent: _currentZoneFrame,
223
+ zone: this
224
+ };
225
+
226
+ try {
227
+ return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source);
228
+ } finally {
229
+ _currentZoneFrame = _currentZoneFrame.parent;
230
+ }
231
+ }
232
+
233
+ runGuarded(callback, applyThis = null, applyArgs, source) {
234
+ _currentZoneFrame = {
235
+ parent: _currentZoneFrame,
236
+ zone: this
237
+ };
238
+
239
+ try {
240
+ try {
241
+ return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source);
242
+ } catch (error) {
243
+ if (this._zoneDelegate.handleError(this, error)) {
244
+ throw error;
245
+ }
246
+ }
247
+ } finally {
248
+ _currentZoneFrame = _currentZoneFrame.parent;
249
+ }
250
+ }
251
+
252
+ runTask(task, applyThis, applyArgs) {
253
+ if (task.zone != this) {
254
+ throw new Error('A task can only be run in the zone of creation! (Creation: ' + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')');
255
+ } // https://github.com/angular/zone.js/issues/778, sometimes eventTask
256
+ // will run in notScheduled(canceled) state, we should not try to
257
+ // run such kind of task but just return
258
+
259
+
260
+ if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) {
261
+ return;
262
+ }
263
+
264
+ const reEntryGuard = task.state != running;
265
+ reEntryGuard && task._transitionTo(running, scheduled);
266
+ task.runCount++;
267
+ const previousTask = _currentTask;
268
+ _currentTask = task;
269
+ _currentZoneFrame = {
270
+ parent: _currentZoneFrame,
271
+ zone: this
272
+ };
273
+
274
+ try {
275
+ if (task.type == macroTask && task.data && !task.data.isPeriodic) {
276
+ task.cancelFn = undefined;
277
+ }
278
+
279
+ try {
280
+ return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs);
281
+ } catch (error) {
282
+ if (this._zoneDelegate.handleError(this, error)) {
283
+ throw error;
284
+ }
285
+ }
286
+ } finally {
287
+ // if the task's state is notScheduled or unknown, then it has already been cancelled
288
+ // we should not reset the state to scheduled
289
+ if (task.state !== notScheduled && task.state !== unknown) {
290
+ if (task.type == eventTask || task.data && task.data.isPeriodic) {
291
+ reEntryGuard && task._transitionTo(scheduled, running);
292
+ } else {
293
+ task.runCount = 0;
294
+
295
+ this._updateTaskCount(task, -1);
296
+
297
+ reEntryGuard && task._transitionTo(notScheduled, running, notScheduled);
298
+ }
299
+ }
300
+
301
+ _currentZoneFrame = _currentZoneFrame.parent;
302
+ _currentTask = previousTask;
303
+ }
304
+ }
305
+
306
+ scheduleTask(task) {
307
+ if (task.zone && task.zone !== this) {
308
+ // check if the task was rescheduled, the newZone
309
+ // should not be the children of the original zone
310
+ let newZone = this;
311
+
312
+ while (newZone) {
313
+ if (newZone === task.zone) {
314
+ throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${task.zone.name}`);
315
+ }
316
+
317
+ newZone = newZone.parent;
318
+ }
319
+ }
320
+
321
+ task._transitionTo(scheduling, notScheduled);
322
+
323
+ const zoneDelegates = [];
324
+ task._zoneDelegates = zoneDelegates;
325
+ task._zone = this;
326
+
327
+ try {
328
+ task = this._zoneDelegate.scheduleTask(this, task);
329
+ } catch (err) {
330
+ // should set task's state to unknown when scheduleTask throw error
331
+ // because the err may from reschedule, so the fromState maybe notScheduled
332
+ task._transitionTo(unknown, scheduling, notScheduled); // TODO: @JiaLiPassion, should we check the result from handleError?
333
+
334
+
335
+ this._zoneDelegate.handleError(this, err);
336
+
337
+ throw err;
338
+ }
339
+
340
+ if (task._zoneDelegates === zoneDelegates) {
341
+ // we have to check because internally the delegate can reschedule the task.
342
+ this._updateTaskCount(task, 1);
343
+ }
344
+
345
+ if (task.state == scheduling) {
346
+ task._transitionTo(scheduled, scheduling);
347
+ }
348
+
349
+ return task;
350
+ }
351
+
352
+ scheduleMicroTask(source, callback, data, customSchedule) {
353
+ return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined));
354
+ }
355
+
356
+ scheduleMacroTask(source, callback, data, customSchedule, customCancel) {
357
+ return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel));
358
+ }
359
+
360
+ scheduleEventTask(source, callback, data, customSchedule, customCancel) {
361
+ return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel));
362
+ }
363
+
364
+ cancelTask(task) {
365
+ if (task.zone != this) throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')');
366
+
367
+ task._transitionTo(canceling, scheduled, running);
368
+
369
+ try {
370
+ this._zoneDelegate.cancelTask(this, task);
371
+ } catch (err) {
372
+ // if error occurs when cancelTask, transit the state to unknown
373
+ task._transitionTo(unknown, canceling);
374
+
375
+ this._zoneDelegate.handleError(this, err);
376
+
377
+ throw err;
378
+ }
379
+
380
+ this._updateTaskCount(task, -1);
381
+
382
+ task._transitionTo(notScheduled, canceling);
383
+
384
+ task.runCount = 0;
385
+ return task;
386
+ }
387
+
388
+ _updateTaskCount(task, count) {
389
+ const zoneDelegates = task._zoneDelegates;
390
+
391
+ if (count == -1) {
392
+ task._zoneDelegates = null;
393
+ }
394
+
395
+ for (let i = 0; i < zoneDelegates.length; i++) {
396
+ zoneDelegates[i]._updateTaskCount(task.type, count);
397
+ }
398
+ }
399
+
400
+ } // tslint:disable-next-line:require-internal-with-underscore
401
+
402
+
403
+ Zone.__symbol__ = __symbol__;
404
+ const DELEGATE_ZS = {
405
+ name: '',
406
+ onHasTask: (delegate, _, target, hasTaskState) => delegate.hasTask(target, hasTaskState),
407
+ onScheduleTask: (delegate, _, target, task) => delegate.scheduleTask(target, task),
408
+ onInvokeTask: (delegate, _, target, task, applyThis, applyArgs) => delegate.invokeTask(target, task, applyThis, applyArgs),
409
+ onCancelTask: (delegate, _, target, task) => delegate.cancelTask(target, task)
410
+ };
411
+
412
+ class ZoneDelegate {
413
+ constructor(zone, parentDelegate, zoneSpec) {
414
+ this._taskCounts = {
415
+ 'microTask': 0,
416
+ 'macroTask': 0,
417
+ 'eventTask': 0
418
+ };
419
+ this.zone = zone;
420
+ this._parentDelegate = parentDelegate;
421
+ this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
422
+ this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt);
423
+ this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate._forkCurrZone);
424
+ this._interceptZS = zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS);
425
+ this._interceptDlgt = zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt);
426
+ this._interceptCurrZone = zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate._interceptCurrZone);
427
+ this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS);
428
+ this._invokeDlgt = zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt);
429
+ this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate._invokeCurrZone);
430
+ this._handleErrorZS = zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS);
431
+ this._handleErrorDlgt = zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt);
432
+ this._handleErrorCurrZone = zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate._handleErrorCurrZone);
433
+ this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS);
434
+ this._scheduleTaskDlgt = zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt);
435
+ this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate._scheduleTaskCurrZone);
436
+ this._invokeTaskZS = zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS);
437
+ this._invokeTaskDlgt = zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt);
438
+ this._invokeTaskCurrZone = zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate._invokeTaskCurrZone);
439
+ this._cancelTaskZS = zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS);
440
+ this._cancelTaskDlgt = zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt);
441
+ this._cancelTaskCurrZone = zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate._cancelTaskCurrZone);
442
+ this._hasTaskZS = null;
443
+ this._hasTaskDlgt = null;
444
+ this._hasTaskDlgtOwner = null;
445
+ this._hasTaskCurrZone = null;
446
+ const zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask;
447
+ const parentHasTask = parentDelegate && parentDelegate._hasTaskZS;
448
+
449
+ if (zoneSpecHasTask || parentHasTask) {
450
+ // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such
451
+ // a case all task related interceptors must go through this ZD. We can't short circuit it.
452
+ this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS;
453
+ this._hasTaskDlgt = parentDelegate;
454
+ this._hasTaskDlgtOwner = this;
455
+ this._hasTaskCurrZone = zone;
456
+
457
+ if (!zoneSpec.onScheduleTask) {
458
+ this._scheduleTaskZS = DELEGATE_ZS;
459
+ this._scheduleTaskDlgt = parentDelegate;
460
+ this._scheduleTaskCurrZone = this.zone;
461
+ }
462
+
463
+ if (!zoneSpec.onInvokeTask) {
464
+ this._invokeTaskZS = DELEGATE_ZS;
465
+ this._invokeTaskDlgt = parentDelegate;
466
+ this._invokeTaskCurrZone = this.zone;
467
+ }
468
+
469
+ if (!zoneSpec.onCancelTask) {
470
+ this._cancelTaskZS = DELEGATE_ZS;
471
+ this._cancelTaskDlgt = parentDelegate;
472
+ this._cancelTaskCurrZone = this.zone;
473
+ }
474
+ }
475
+ }
476
+
477
+ fork(targetZone, zoneSpec) {
478
+ return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : new Zone(targetZone, zoneSpec);
479
+ }
480
+
481
+ intercept(targetZone, callback, source) {
482
+ return this._interceptZS ? this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : callback;
483
+ }
484
+
485
+ invoke(targetZone, callback, applyThis, applyArgs, source) {
486
+ return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs);
487
+ }
488
+
489
+ handleError(targetZone, error) {
490
+ return this._handleErrorZS ? this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : true;
491
+ }
492
+
493
+ scheduleTask(targetZone, task) {
494
+ let returnTask = task;
495
+
496
+ if (this._scheduleTaskZS) {
497
+ if (this._hasTaskZS) {
498
+ returnTask._zoneDelegates.push(this._hasTaskDlgtOwner);
499
+ } // clang-format off
500
+
501
+
502
+ returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); // clang-format on
503
+
504
+ if (!returnTask) returnTask = task;
505
+ } else {
506
+ if (task.scheduleFn) {
507
+ task.scheduleFn(task);
508
+ } else if (task.type == microTask) {
509
+ scheduleMicroTask(task);
510
+ } else {
511
+ throw new Error('Task is missing scheduleFn.');
512
+ }
513
+ }
514
+
515
+ return returnTask;
516
+ }
517
+
518
+ invokeTask(targetZone, task, applyThis, applyArgs) {
519
+ return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs);
520
+ }
521
+
522
+ cancelTask(targetZone, task) {
523
+ let value;
524
+
525
+ if (this._cancelTaskZS) {
526
+ value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task);
527
+ } else {
528
+ if (!task.cancelFn) {
529
+ throw Error('Task is not cancelable');
530
+ }
531
+
532
+ value = task.cancelFn(task);
533
+ }
534
+
535
+ return value;
536
+ }
537
+
538
+ hasTask(targetZone, isEmpty) {
539
+ // hasTask should not throw error so other ZoneDelegate
540
+ // can still trigger hasTask callback
541
+ try {
542
+ this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty);
543
+ } catch (err) {
544
+ this.handleError(targetZone, err);
545
+ }
546
+ } // tslint:disable-next-line:require-internal-with-underscore
547
+
548
+
549
+ _updateTaskCount(type, count) {
550
+ const counts = this._taskCounts;
551
+ const prev = counts[type];
552
+ const next = counts[type] = prev + count;
553
+
554
+ if (next < 0) {
555
+ throw new Error('More tasks executed then were scheduled.');
556
+ }
557
+
558
+ if (prev == 0 || next == 0) {
559
+ const isEmpty = {
560
+ microTask: counts['microTask'] > 0,
561
+ macroTask: counts['macroTask'] > 0,
562
+ eventTask: counts['eventTask'] > 0,
563
+ change: type
564
+ };
565
+ this.hasTask(this.zone, isEmpty);
566
+ }
567
+ }
568
+
569
+ }
570
+
571
+ class ZoneTask {
572
+ constructor(type, source, callback, options, scheduleFn, cancelFn) {
573
+ // tslint:disable-next-line:require-internal-with-underscore
574
+ this._zone = null;
575
+ this.runCount = 0; // tslint:disable-next-line:require-internal-with-underscore
576
+
577
+ this._zoneDelegates = null; // tslint:disable-next-line:require-internal-with-underscore
578
+
579
+ this._state = 'notScheduled';
580
+ this.type = type;
581
+ this.source = source;
582
+ this.data = options;
583
+ this.scheduleFn = scheduleFn;
584
+ this.cancelFn = cancelFn;
585
+
586
+ if (!callback) {
587
+ throw new Error('callback is not defined');
588
+ }
589
+
590
+ this.callback = callback;
591
+ const self = this; // TODO: @JiaLiPassion options should have interface
592
+
593
+ if (type === eventTask && options && options.useG) {
594
+ this.invoke = ZoneTask.invokeTask;
595
+ } else {
596
+ this.invoke = function () {
597
+ return ZoneTask.invokeTask.call(global, self, this, arguments);
598
+ };
599
+ }
600
+ }
601
+
602
+ static invokeTask(task, target, args) {
603
+ if (!task) {
604
+ task = this;
605
+ }
606
+
607
+ _numberOfNestedTaskFrames++;
608
+
609
+ try {
610
+ task.runCount++;
611
+ return task.zone.runTask(task, target, args);
612
+ } finally {
613
+ if (_numberOfNestedTaskFrames == 1) {
614
+ drainMicroTaskQueue();
615
+ }
616
+
617
+ _numberOfNestedTaskFrames--;
618
+ }
619
+ }
620
+
621
+ get zone() {
622
+ return this._zone;
623
+ }
624
+
625
+ get state() {
626
+ return this._state;
627
+ }
628
+
629
+ cancelScheduleRequest() {
630
+ this._transitionTo(notScheduled, scheduling);
631
+ } // tslint:disable-next-line:require-internal-with-underscore
632
+
633
+
634
+ _transitionTo(toState, fromState1, fromState2) {
635
+ if (this._state === fromState1 || this._state === fromState2) {
636
+ this._state = toState;
637
+
638
+ if (toState == notScheduled) {
639
+ this._zoneDelegates = null;
640
+ }
641
+ } else {
642
+ throw new Error(`${this.type} '${this.source}': can not transition to '${toState}', expecting state '${fromState1}'${fromState2 ? ' or \'' + fromState2 + '\'' : ''}, was '${this._state}'.`);
643
+ }
644
+ }
645
+
646
+ toString() {
647
+ if (this.data && typeof this.data.handleId !== 'undefined') {
648
+ return this.data.handleId.toString();
649
+ } else {
650
+ return Object.prototype.toString.call(this);
651
+ }
652
+ } // add toJSON method to prevent cyclic error when
653
+ // call JSON.stringify(zoneTask)
654
+
655
+
656
+ toJSON() {
657
+ return {
658
+ type: this.type,
659
+ state: this.state,
660
+ source: this.source,
661
+ zone: this.zone.name,
662
+ runCount: this.runCount
663
+ };
664
+ }
665
+
666
+ } //////////////////////////////////////////////////////
667
+ //////////////////////////////////////////////////////
668
+ /// MICROTASK QUEUE
669
+ //////////////////////////////////////////////////////
670
+ //////////////////////////////////////////////////////
671
+
672
+
673
+ const symbolSetTimeout = __symbol__('setTimeout');
674
+
675
+ const symbolPromise = __symbol__('Promise');
676
+
677
+ const symbolThen = __symbol__('then');
678
+
679
+ let _microTaskQueue = [];
680
+ let _isDrainingMicrotaskQueue = false;
681
+ let nativeMicroTaskQueuePromise;
682
+
683
+ function scheduleMicroTask(task) {
684
+ // if we are not running in any task, and there has not been anything scheduled
685
+ // we must bootstrap the initial task creation by manually scheduling the drain
686
+ if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) {
687
+ // We are not running in Task, so we need to kickstart the microtask queue.
688
+ if (!nativeMicroTaskQueuePromise) {
689
+ if (global[symbolPromise]) {
690
+ nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0);
691
+ }
692
+ }
693
+
694
+ if (nativeMicroTaskQueuePromise) {
695
+ let nativeThen = nativeMicroTaskQueuePromise[symbolThen];
696
+
697
+ if (!nativeThen) {
698
+ // native Promise is not patchable, we need to use `then` directly
699
+ // issue 1078
700
+ nativeThen = nativeMicroTaskQueuePromise['then'];
701
+ }
702
+
703
+ nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue);
704
+ } else {
705
+ global[symbolSetTimeout](drainMicroTaskQueue, 0);
706
+ }
707
+ }
708
+
709
+ task && _microTaskQueue.push(task);
710
+ }
711
+
712
+ function drainMicroTaskQueue() {
713
+ if (!_isDrainingMicrotaskQueue) {
714
+ _isDrainingMicrotaskQueue = true;
715
+
716
+ while (_microTaskQueue.length) {
717
+ const queue = _microTaskQueue;
718
+ _microTaskQueue = [];
719
+
720
+ for (let i = 0; i < queue.length; i++) {
721
+ const task = queue[i];
722
+
723
+ try {
724
+ task.zone.runTask(task, null, null);
725
+ } catch (error) {
726
+ _api.onUnhandledError(error);
727
+ }
728
+ }
729
+ }
730
+
731
+ _api.microtaskDrainDone();
732
+
733
+ _isDrainingMicrotaskQueue = false;
734
+ }
735
+ } //////////////////////////////////////////////////////
736
+ //////////////////////////////////////////////////////
737
+ /// BOOTSTRAP
738
+ //////////////////////////////////////////////////////
739
+ //////////////////////////////////////////////////////
740
+
741
+
742
+ const NO_ZONE = {
743
+ name: 'NO ZONE'
744
+ };
745
+ const notScheduled = 'notScheduled',
746
+ scheduling = 'scheduling',
747
+ scheduled = 'scheduled',
748
+ running = 'running',
749
+ canceling = 'canceling',
750
+ unknown = 'unknown';
751
+ const microTask = 'microTask',
752
+ macroTask = 'macroTask',
753
+ eventTask = 'eventTask';
754
+ const patches = {};
755
+ const _api = {
756
+ symbol: __symbol__,
757
+ currentZoneFrame: () => _currentZoneFrame,
758
+ onUnhandledError: noop,
759
+ microtaskDrainDone: noop,
760
+ scheduleMicroTask: scheduleMicroTask,
761
+ showUncaughtError: () => !Zone[__symbol__('ignoreConsoleErrorUncaughtError')],
762
+ patchEventTarget: () => [],
763
+ patchOnProperties: noop,
764
+ patchMethod: () => noop,
765
+ bindArguments: () => [],
766
+ patchThen: () => noop,
767
+ patchMacroTask: () => noop,
768
+ patchEventPrototype: () => noop,
769
+ isIEOrEdge: () => false,
770
+ getGlobalObjects: () => undefined,
771
+ ObjectDefineProperty: () => noop,
772
+ ObjectGetOwnPropertyDescriptor: () => undefined,
773
+ ObjectCreate: () => undefined,
774
+ ArraySlice: () => [],
775
+ patchClass: () => noop,
776
+ wrapWithCurrentZone: () => noop,
777
+ filterProperties: () => [],
778
+ attachOriginToPatched: () => noop,
779
+ _redefineProperty: () => noop,
780
+ patchCallbacks: () => noop
781
+ };
782
+ let _currentZoneFrame = {
783
+ parent: null,
784
+ zone: new Zone(null, null)
785
+ };
786
+ let _currentTask = null;
787
+ let _numberOfNestedTaskFrames = 0;
788
+
789
+ function noop() {}
790
+
791
+ performanceMeasure('Zone', 'Zone');
792
+ return global['Zone'] = Zone;
793
+ }(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global);
794
+ /**
795
+ * @license
796
+ * Copyright Google LLC All Rights Reserved.
797
+ *
798
+ * Use of this source code is governed by an MIT-style license that can be
799
+ * found in the LICENSE file at https://angular.io/license
800
+ */
801
+
802
+ /**
803
+ * Suppress closure compiler errors about unknown 'Zone' variable
804
+ * @fileoverview
805
+ * @suppress {undefinedVars,globalThis,missingRequire}
806
+ */
807
+ /// <reference types="node"/>
808
+ // issue #989, to reduce bundle size, use short name
809
+
810
+ /** Object.getOwnPropertyDescriptor */
811
+
812
+
813
+ const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
814
+ /** Object.defineProperty */
815
+
816
+ const ObjectDefineProperty = Object.defineProperty;
817
+ /** Object.getPrototypeOf */
818
+
819
+ const ObjectGetPrototypeOf = Object.getPrototypeOf;
820
+ /** Object.create */
821
+
822
+ const ObjectCreate = Object.create;
823
+ /** Array.prototype.slice */
824
+
825
+ const ArraySlice = Array.prototype.slice;
826
+ /** addEventListener string const */
827
+
828
+ const ADD_EVENT_LISTENER_STR = 'addEventListener';
829
+ /** removeEventListener string const */
830
+
831
+ const REMOVE_EVENT_LISTENER_STR = 'removeEventListener';
832
+ /** zoneSymbol addEventListener */
833
+
834
+ const ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR);
835
+ /** zoneSymbol removeEventListener */
836
+
837
+
838
+ const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR);
839
+ /** true string const */
840
+
841
+
842
+ const TRUE_STR = 'true';
843
+ /** false string const */
844
+
845
+ const FALSE_STR = 'false';
846
+ /** Zone symbol prefix string const. */
847
+
848
+ const ZONE_SYMBOL_PREFIX = Zone.__symbol__('');
849
+
850
+ function wrapWithCurrentZone(callback, source) {
851
+ return Zone.current.wrap(callback, source);
852
+ }
853
+
854
+ function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) {
855
+ return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel);
856
+ }
857
+
858
+ const zoneSymbol = Zone.__symbol__;
859
+ const isWindowExists = typeof window !== 'undefined';
860
+ const internalWindow = isWindowExists ? window : undefined;
861
+
862
+ const _global = isWindowExists && internalWindow || typeof self === 'object' && self || global;
863
+
864
+ const REMOVE_ATTRIBUTE = 'removeAttribute';
865
+ const NULL_ON_PROP_VALUE = [null];
866
+
867
+ function bindArguments(args, source) {
868
+ for (let i = args.length - 1; i >= 0; i--) {
869
+ if (typeof args[i] === 'function') {
870
+ args[i] = wrapWithCurrentZone(args[i], source + '_' + i);
871
+ }
872
+ }
873
+
874
+ return args;
875
+ }
876
+
877
+ function patchPrototype(prototype, fnNames) {
878
+ const source = prototype.constructor['name'];
879
+
880
+ for (let i = 0; i < fnNames.length; i++) {
881
+ const name = fnNames[i];
882
+ const delegate = prototype[name];
883
+
884
+ if (delegate) {
885
+ const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name);
886
+
887
+ if (!isPropertyWritable(prototypeDesc)) {
888
+ continue;
889
+ }
890
+
891
+ prototype[name] = (delegate => {
892
+ const patched = function () {
893
+ return delegate.apply(this, bindArguments(arguments, source + '.' + name));
894
+ };
895
+
896
+ attachOriginToPatched(patched, delegate);
897
+ return patched;
898
+ })(delegate);
899
+ }
900
+ }
901
+ }
902
+
903
+ function isPropertyWritable(propertyDesc) {
904
+ if (!propertyDesc) {
905
+ return true;
906
+ }
907
+
908
+ if (propertyDesc.writable === false) {
909
+ return false;
910
+ }
911
+
912
+ return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined');
913
+ }
914
+
915
+ const isWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope; // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify
916
+ // this code.
917
+
918
+ const isNode = !('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]';
919
+ const isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs
920
+ // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify
921
+ // this code.
922
+
923
+ const isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']);
924
+ const zoneSymbolEventNames = {};
925
+
926
+ const wrapFn = function (event) {
927
+ // https://github.com/angular/zone.js/issues/911, in IE, sometimes
928
+ // event will be undefined, so we need to use window.event
929
+ event = event || _global.event;
930
+
931
+ if (!event) {
932
+ return;
933
+ }
934
+
935
+ let eventNameSymbol = zoneSymbolEventNames[event.type];
936
+
937
+ if (!eventNameSymbol) {
938
+ eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type);
939
+ }
940
+
941
+ const target = this || event.target || _global;
942
+ const listener = target[eventNameSymbol];
943
+ let result;
944
+
945
+ if (isBrowser && target === internalWindow && event.type === 'error') {
946
+ // window.onerror have different signiture
947
+ // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror
948
+ // and onerror callback will prevent default when callback return true
949
+ const errorEvent = event;
950
+ result = listener && listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error);
951
+
952
+ if (result === true) {
953
+ event.preventDefault();
954
+ }
955
+ } else {
956
+ result = listener && listener.apply(this, arguments);
957
+
958
+ if (result != undefined && !result) {
959
+ event.preventDefault();
960
+ }
961
+ }
962
+
963
+ return result;
964
+ };
965
+
966
+ function patchProperty(obj, prop, prototype) {
967
+ let desc = ObjectGetOwnPropertyDescriptor(obj, prop);
968
+
969
+ if (!desc && prototype) {
970
+ // when patch window object, use prototype to check prop exist or not
971
+ const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop);
972
+
973
+ if (prototypeDesc) {
974
+ desc = {
975
+ enumerable: true,
976
+ configurable: true
977
+ };
978
+ }
979
+ } // if the descriptor not exists or is not configurable
980
+ // just return
981
+
982
+
983
+ if (!desc || !desc.configurable) {
984
+ return;
985
+ }
986
+
987
+ const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched');
988
+
989
+ if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) {
990
+ return;
991
+ } // A property descriptor cannot have getter/setter and be writable
992
+ // deleting the writable and value properties avoids this error:
993
+ //
994
+ // TypeError: property descriptors must not specify a value or be writable when a
995
+ // getter or setter has been specified
996
+
997
+
998
+ delete desc.writable;
999
+ delete desc.value;
1000
+ const originalDescGet = desc.get;
1001
+ const originalDescSet = desc.set; // substr(2) cuz 'onclick' -> 'click', etc
1002
+
1003
+ const eventName = prop.substr(2);
1004
+ let eventNameSymbol = zoneSymbolEventNames[eventName];
1005
+
1006
+ if (!eventNameSymbol) {
1007
+ eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName);
1008
+ }
1009
+
1010
+ desc.set = function (newValue) {
1011
+ // in some of windows's onproperty callback, this is undefined
1012
+ // so we need to check it
1013
+ let target = this;
1014
+
1015
+ if (!target && obj === _global) {
1016
+ target = _global;
1017
+ }
1018
+
1019
+ if (!target) {
1020
+ return;
1021
+ }
1022
+
1023
+ let previousValue = target[eventNameSymbol];
1024
+
1025
+ if (previousValue) {
1026
+ target.removeEventListener(eventName, wrapFn);
1027
+ } // issue #978, when onload handler was added before loading zone.js
1028
+ // we should remove it with originalDescSet
1029
+
1030
+
1031
+ if (originalDescSet) {
1032
+ originalDescSet.apply(target, NULL_ON_PROP_VALUE);
1033
+ }
1034
+
1035
+ if (typeof newValue === 'function') {
1036
+ target[eventNameSymbol] = newValue;
1037
+ target.addEventListener(eventName, wrapFn, false);
1038
+ } else {
1039
+ target[eventNameSymbol] = null;
1040
+ }
1041
+ }; // The getter would return undefined for unassigned properties but the default value of an
1042
+ // unassigned property is null
1043
+
1044
+
1045
+ desc.get = function () {
1046
+ // in some of windows's onproperty callback, this is undefined
1047
+ // so we need to check it
1048
+ let target = this;
1049
+
1050
+ if (!target && obj === _global) {
1051
+ target = _global;
1052
+ }
1053
+
1054
+ if (!target) {
1055
+ return null;
1056
+ }
1057
+
1058
+ const listener = target[eventNameSymbol];
1059
+
1060
+ if (listener) {
1061
+ return listener;
1062
+ } else if (originalDescGet) {
1063
+ // result will be null when use inline event attribute,
1064
+ // such as <button onclick="func();">OK</button>
1065
+ // because the onclick function is internal raw uncompiled handler
1066
+ // the onclick will be evaluated when first time event was triggered or
1067
+ // the property is accessed, https://github.com/angular/zone.js/issues/525
1068
+ // so we should use original native get to retrieve the handler
1069
+ let value = originalDescGet && originalDescGet.call(this);
1070
+
1071
+ if (value) {
1072
+ desc.set.call(this, value);
1073
+
1074
+ if (typeof target[REMOVE_ATTRIBUTE] === 'function') {
1075
+ target.removeAttribute(prop);
1076
+ }
1077
+
1078
+ return value;
1079
+ }
1080
+ }
1081
+
1082
+ return null;
1083
+ };
1084
+
1085
+ ObjectDefineProperty(obj, prop, desc);
1086
+ obj[onPropPatchedSymbol] = true;
1087
+ }
1088
+
1089
+ function patchOnProperties(obj, properties, prototype) {
1090
+ if (properties) {
1091
+ for (let i = 0; i < properties.length; i++) {
1092
+ patchProperty(obj, 'on' + properties[i], prototype);
1093
+ }
1094
+ } else {
1095
+ const onProperties = [];
1096
+
1097
+ for (const prop in obj) {
1098
+ if (prop.substr(0, 2) == 'on') {
1099
+ onProperties.push(prop);
1100
+ }
1101
+ }
1102
+
1103
+ for (let j = 0; j < onProperties.length; j++) {
1104
+ patchProperty(obj, onProperties[j], prototype);
1105
+ }
1106
+ }
1107
+ }
1108
+
1109
+ const originalInstanceKey = zoneSymbol('originalInstance'); // wrap some native API on `window`
1110
+
1111
+ function patchClass(className) {
1112
+ const OriginalClass = _global[className];
1113
+ if (!OriginalClass) return; // keep original class in global
1114
+
1115
+ _global[zoneSymbol(className)] = OriginalClass;
1116
+
1117
+ _global[className] = function () {
1118
+ const a = bindArguments(arguments, className);
1119
+
1120
+ switch (a.length) {
1121
+ case 0:
1122
+ this[originalInstanceKey] = new OriginalClass();
1123
+ break;
1124
+
1125
+ case 1:
1126
+ this[originalInstanceKey] = new OriginalClass(a[0]);
1127
+ break;
1128
+
1129
+ case 2:
1130
+ this[originalInstanceKey] = new OriginalClass(a[0], a[1]);
1131
+ break;
1132
+
1133
+ case 3:
1134
+ this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]);
1135
+ break;
1136
+
1137
+ case 4:
1138
+ this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]);
1139
+ break;
1140
+
1141
+ default:
1142
+ throw new Error('Arg list too long.');
1143
+ }
1144
+ }; // attach original delegate to patched function
1145
+
1146
+
1147
+ attachOriginToPatched(_global[className], OriginalClass);
1148
+ const instance = new OriginalClass(function () {});
1149
+ let prop;
1150
+
1151
+ for (prop in instance) {
1152
+ // https://bugs.webkit.org/show_bug.cgi?id=44721
1153
+ if (className === 'XMLHttpRequest' && prop === 'responseBlob') continue;
1154
+
1155
+ (function (prop) {
1156
+ if (typeof instance[prop] === 'function') {
1157
+ _global[className].prototype[prop] = function () {
1158
+ return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);
1159
+ };
1160
+ } else {
1161
+ ObjectDefineProperty(_global[className].prototype, prop, {
1162
+ set: function (fn) {
1163
+ if (typeof fn === 'function') {
1164
+ this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); // keep callback in wrapped function so we can
1165
+ // use it in Function.prototype.toString to return
1166
+ // the native one.
1167
+
1168
+ attachOriginToPatched(this[originalInstanceKey][prop], fn);
1169
+ } else {
1170
+ this[originalInstanceKey][prop] = fn;
1171
+ }
1172
+ },
1173
+ get: function () {
1174
+ return this[originalInstanceKey][prop];
1175
+ }
1176
+ });
1177
+ }
1178
+ })(prop);
1179
+ }
1180
+
1181
+ for (prop in OriginalClass) {
1182
+ if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) {
1183
+ _global[className][prop] = OriginalClass[prop];
1184
+ }
1185
+ }
1186
+ }
1187
+
1188
+ function patchMethod(target, name, patchFn) {
1189
+ let proto = target;
1190
+
1191
+ while (proto && !proto.hasOwnProperty(name)) {
1192
+ proto = ObjectGetPrototypeOf(proto);
1193
+ }
1194
+
1195
+ if (!proto && target[name]) {
1196
+ // somehow we did not find it, but we can see it. This happens on IE for Window properties.
1197
+ proto = target;
1198
+ }
1199
+
1200
+ const delegateName = zoneSymbol(name);
1201
+ let delegate = null;
1202
+
1203
+ if (proto && (!(delegate = proto[delegateName]) || !proto.hasOwnProperty(delegateName))) {
1204
+ delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable
1205
+ // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob
1206
+
1207
+ const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name);
1208
+
1209
+ if (isPropertyWritable(desc)) {
1210
+ const patchDelegate = patchFn(delegate, delegateName, name);
1211
+
1212
+ proto[name] = function () {
1213
+ return patchDelegate(this, arguments);
1214
+ };
1215
+
1216
+ attachOriginToPatched(proto[name], delegate);
1217
+ }
1218
+ }
1219
+
1220
+ return delegate;
1221
+ } // TODO: @JiaLiPassion, support cancel task later if necessary
1222
+
1223
+
1224
+ function patchMacroTask(obj, funcName, metaCreator) {
1225
+ let setNative = null;
1226
+
1227
+ function scheduleTask(task) {
1228
+ const data = task.data;
1229
+
1230
+ data.args[data.cbIdx] = function () {
1231
+ task.invoke.apply(this, arguments);
1232
+ };
1233
+
1234
+ setNative.apply(data.target, data.args);
1235
+ return task;
1236
+ }
1237
+
1238
+ setNative = patchMethod(obj, funcName, delegate => function (self, args) {
1239
+ const meta = metaCreator(self, args);
1240
+
1241
+ if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') {
1242
+ return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask);
1243
+ } else {
1244
+ // cause an error by calling it directly.
1245
+ return delegate.apply(self, args);
1246
+ }
1247
+ });
1248
+ }
1249
+
1250
+ function attachOriginToPatched(patched, original) {
1251
+ patched[zoneSymbol('OriginalDelegate')] = original;
1252
+ }
1253
+
1254
+ let isDetectedIEOrEdge = false;
1255
+ let ieOrEdge = false;
1256
+
1257
+ function isIE() {
1258
+ try {
1259
+ const ua = internalWindow.navigator.userAgent;
1260
+
1261
+ if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) {
1262
+ return true;
1263
+ }
1264
+ } catch (error) {}
1265
+
1266
+ return false;
1267
+ }
1268
+
1269
+ function isIEOrEdge() {
1270
+ if (isDetectedIEOrEdge) {
1271
+ return ieOrEdge;
1272
+ }
1273
+
1274
+ isDetectedIEOrEdge = true;
1275
+
1276
+ try {
1277
+ const ua = internalWindow.navigator.userAgent;
1278
+
1279
+ if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) {
1280
+ ieOrEdge = true;
1281
+ }
1282
+ } catch (error) {}
1283
+
1284
+ return ieOrEdge;
1285
+ }
1286
+ /**
1287
+ * @license
1288
+ * Copyright Google LLC All Rights Reserved.
1289
+ *
1290
+ * Use of this source code is governed by an MIT-style license that can be
1291
+ * found in the LICENSE file at https://angular.io/license
1292
+ */
1293
+
1294
+
1295
+ Zone.__load_patch('ZoneAwarePromise', (global, Zone, api) => {
1296
+ const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1297
+ const ObjectDefineProperty = Object.defineProperty;
1298
+
1299
+ function readableObjectToString(obj) {
1300
+ if (obj && obj.toString === Object.prototype.toString) {
1301
+ const className = obj.constructor && obj.constructor.name;
1302
+ return (className ? className : '') + ': ' + JSON.stringify(obj);
1303
+ }
1304
+
1305
+ return obj ? obj.toString() : Object.prototype.toString.call(obj);
1306
+ }
1307
+
1308
+ const __symbol__ = api.symbol;
1309
+ const _uncaughtPromiseErrors = [];
1310
+ const isDisableWrappingUncaughtPromiseRejection = global[__symbol__('DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION')] === true;
1311
+
1312
+ const symbolPromise = __symbol__('Promise');
1313
+
1314
+ const symbolThen = __symbol__('then');
1315
+
1316
+ const creationTrace = '__creationTrace__';
1317
+
1318
+ api.onUnhandledError = e => {
1319
+ if (api.showUncaughtError()) {
1320
+ const rejection = e && e.rejection;
1321
+
1322
+ if (rejection) {
1323
+ console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined);
1324
+ } else {
1325
+ console.error(e);
1326
+ }
1327
+ }
1328
+ };
1329
+
1330
+ api.microtaskDrainDone = () => {
1331
+ while (_uncaughtPromiseErrors.length) {
1332
+ const uncaughtPromiseError = _uncaughtPromiseErrors.shift();
1333
+
1334
+ try {
1335
+ uncaughtPromiseError.zone.runGuarded(() => {
1336
+ if (uncaughtPromiseError.throwOriginal) {
1337
+ throw uncaughtPromiseError.rejection;
1338
+ }
1339
+
1340
+ throw uncaughtPromiseError;
1341
+ });
1342
+ } catch (error) {
1343
+ handleUnhandledRejection(error);
1344
+ }
1345
+ }
1346
+ };
1347
+
1348
+ const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler');
1349
+
1350
+ function handleUnhandledRejection(e) {
1351
+ api.onUnhandledError(e);
1352
+
1353
+ try {
1354
+ const handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL];
1355
+
1356
+ if (typeof handler === 'function') {
1357
+ handler.call(this, e);
1358
+ }
1359
+ } catch (err) {}
1360
+ }
1361
+
1362
+ function isThenable(value) {
1363
+ return value && value.then;
1364
+ }
1365
+
1366
+ function forwardResolution(value) {
1367
+ return value;
1368
+ }
1369
+
1370
+ function forwardRejection(rejection) {
1371
+ return ZoneAwarePromise.reject(rejection);
1372
+ }
1373
+
1374
+ const symbolState = __symbol__('state');
1375
+
1376
+ const symbolValue = __symbol__('value');
1377
+
1378
+ const symbolFinally = __symbol__('finally');
1379
+
1380
+ const symbolParentPromiseValue = __symbol__('parentPromiseValue');
1381
+
1382
+ const symbolParentPromiseState = __symbol__('parentPromiseState');
1383
+
1384
+ const source = 'Promise.then';
1385
+ const UNRESOLVED = null;
1386
+ const RESOLVED = true;
1387
+ const REJECTED = false;
1388
+ const REJECTED_NO_CATCH = 0;
1389
+
1390
+ function makeResolver(promise, state) {
1391
+ return v => {
1392
+ try {
1393
+ resolvePromise(promise, state, v);
1394
+ } catch (err) {
1395
+ resolvePromise(promise, false, err);
1396
+ } // Do not return value or you will break the Promise spec.
1397
+
1398
+ };
1399
+ }
1400
+
1401
+ const once = function () {
1402
+ let wasCalled = false;
1403
+ return function wrapper(wrappedFunction) {
1404
+ return function () {
1405
+ if (wasCalled) {
1406
+ return;
1407
+ }
1408
+
1409
+ wasCalled = true;
1410
+ wrappedFunction.apply(null, arguments);
1411
+ };
1412
+ };
1413
+ };
1414
+
1415
+ const TYPE_ERROR = 'Promise resolved with itself';
1416
+
1417
+ const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution
1418
+
1419
+
1420
+ function resolvePromise(promise, state, value) {
1421
+ const onceWrapper = once();
1422
+
1423
+ if (promise === value) {
1424
+ throw new TypeError(TYPE_ERROR);
1425
+ }
1426
+
1427
+ if (promise[symbolState] === UNRESOLVED) {
1428
+ // should only get value.then once based on promise spec.
1429
+ let then = null;
1430
+
1431
+ try {
1432
+ if (typeof value === 'object' || typeof value === 'function') {
1433
+ then = value && value.then;
1434
+ }
1435
+ } catch (err) {
1436
+ onceWrapper(() => {
1437
+ resolvePromise(promise, false, err);
1438
+ })();
1439
+ return promise;
1440
+ } // if (value instanceof ZoneAwarePromise) {
1441
+
1442
+
1443
+ if (state !== REJECTED && value instanceof ZoneAwarePromise && value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && value[symbolState] !== UNRESOLVED) {
1444
+ clearRejectedNoCatch(value);
1445
+ resolvePromise(promise, value[symbolState], value[symbolValue]);
1446
+ } else if (state !== REJECTED && typeof then === 'function') {
1447
+ try {
1448
+ then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)));
1449
+ } catch (err) {
1450
+ onceWrapper(() => {
1451
+ resolvePromise(promise, false, err);
1452
+ })();
1453
+ }
1454
+ } else {
1455
+ promise[symbolState] = state;
1456
+ const queue = promise[symbolValue];
1457
+ promise[symbolValue] = value;
1458
+
1459
+ if (promise[symbolFinally] === symbolFinally) {
1460
+ // the promise is generated by Promise.prototype.finally
1461
+ if (state === RESOLVED) {
1462
+ // the state is resolved, should ignore the value
1463
+ // and use parent promise value
1464
+ promise[symbolState] = promise[symbolParentPromiseState];
1465
+ promise[symbolValue] = promise[symbolParentPromiseValue];
1466
+ }
1467
+ } // record task information in value when error occurs, so we can
1468
+ // do some additional work such as render longStackTrace
1469
+
1470
+
1471
+ if (state === REJECTED && value instanceof Error) {
1472
+ // check if longStackTraceZone is here
1473
+ const trace = Zone.currentTask && Zone.currentTask.data && Zone.currentTask.data[creationTrace];
1474
+
1475
+ if (trace) {
1476
+ // only keep the long stack trace into error when in longStackTraceZone
1477
+ ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, {
1478
+ configurable: true,
1479
+ enumerable: false,
1480
+ writable: true,
1481
+ value: trace
1482
+ });
1483
+ }
1484
+ }
1485
+
1486
+ for (let i = 0; i < queue.length;) {
1487
+ scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]);
1488
+ }
1489
+
1490
+ if (queue.length == 0 && state == REJECTED) {
1491
+ promise[symbolState] = REJECTED_NO_CATCH;
1492
+ let uncaughtPromiseError = value;
1493
+
1494
+ try {
1495
+ // Here we throws a new Error to print more readable error log
1496
+ // and if the value is not an error, zone.js builds an `Error`
1497
+ // Object here to attach the stack information.
1498
+ throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + (value && value.stack ? '\n' + value.stack : ''));
1499
+ } catch (err) {
1500
+ uncaughtPromiseError = err;
1501
+ }
1502
+
1503
+ if (isDisableWrappingUncaughtPromiseRejection) {
1504
+ // If disable wrapping uncaught promise reject
1505
+ // use the value instead of wrapping it.
1506
+ uncaughtPromiseError.throwOriginal = true;
1507
+ }
1508
+
1509
+ uncaughtPromiseError.rejection = value;
1510
+ uncaughtPromiseError.promise = promise;
1511
+ uncaughtPromiseError.zone = Zone.current;
1512
+ uncaughtPromiseError.task = Zone.currentTask;
1513
+
1514
+ _uncaughtPromiseErrors.push(uncaughtPromiseError);
1515
+
1516
+ api.scheduleMicroTask(); // to make sure that it is running
1517
+ }
1518
+ }
1519
+ } // Resolving an already resolved promise is a noop.
1520
+
1521
+
1522
+ return promise;
1523
+ }
1524
+
1525
+ const REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler');
1526
+
1527
+ function clearRejectedNoCatch(promise) {
1528
+ if (promise[symbolState] === REJECTED_NO_CATCH) {
1529
+ // if the promise is rejected no catch status
1530
+ // and queue.length > 0, means there is a error handler
1531
+ // here to handle the rejected promise, we should trigger
1532
+ // windows.rejectionhandled eventHandler or nodejs rejectionHandled
1533
+ // eventHandler
1534
+ try {
1535
+ const handler = Zone[REJECTION_HANDLED_HANDLER];
1536
+
1537
+ if (handler && typeof handler === 'function') {
1538
+ handler.call(this, {
1539
+ rejection: promise[symbolValue],
1540
+ promise: promise
1541
+ });
1542
+ }
1543
+ } catch (err) {}
1544
+
1545
+ promise[symbolState] = REJECTED;
1546
+
1547
+ for (let i = 0; i < _uncaughtPromiseErrors.length; i++) {
1548
+ if (promise === _uncaughtPromiseErrors[i].promise) {
1549
+ _uncaughtPromiseErrors.splice(i, 1);
1550
+ }
1551
+ }
1552
+ }
1553
+ }
1554
+
1555
+ function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) {
1556
+ clearRejectedNoCatch(promise);
1557
+ const promiseState = promise[symbolState];
1558
+ const delegate = promiseState ? typeof onFulfilled === 'function' ? onFulfilled : forwardResolution : typeof onRejected === 'function' ? onRejected : forwardRejection;
1559
+ zone.scheduleMicroTask(source, () => {
1560
+ try {
1561
+ const parentPromiseValue = promise[symbolValue];
1562
+ const isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally];
1563
+
1564
+ if (isFinallyPromise) {
1565
+ // if the promise is generated from finally call, keep parent promise's state and value
1566
+ chainPromise[symbolParentPromiseValue] = parentPromiseValue;
1567
+ chainPromise[symbolParentPromiseState] = promiseState;
1568
+ } // should not pass value to finally callback
1569
+
1570
+
1571
+ const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]);
1572
+ resolvePromise(chainPromise, true, value);
1573
+ } catch (error) {
1574
+ // if error occurs, should always return this error
1575
+ resolvePromise(chainPromise, false, error);
1576
+ }
1577
+ }, chainPromise);
1578
+ }
1579
+
1580
+ const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }';
1581
+
1582
+ const noop = function () {};
1583
+
1584
+ class ZoneAwarePromise {
1585
+ static toString() {
1586
+ return ZONE_AWARE_PROMISE_TO_STRING;
1587
+ }
1588
+
1589
+ static resolve(value) {
1590
+ return resolvePromise(new this(null), RESOLVED, value);
1591
+ }
1592
+
1593
+ static reject(error) {
1594
+ return resolvePromise(new this(null), REJECTED, error);
1595
+ }
1596
+
1597
+ static race(values) {
1598
+ let resolve;
1599
+ let reject;
1600
+ let promise = new this((res, rej) => {
1601
+ resolve = res;
1602
+ reject = rej;
1603
+ });
1604
+
1605
+ function onResolve(value) {
1606
+ resolve(value);
1607
+ }
1608
+
1609
+ function onReject(error) {
1610
+ reject(error);
1611
+ }
1612
+
1613
+ for (let value of values) {
1614
+ if (!isThenable(value)) {
1615
+ value = this.resolve(value);
1616
+ }
1617
+
1618
+ value.then(onResolve, onReject);
1619
+ }
1620
+
1621
+ return promise;
1622
+ }
1623
+
1624
+ static all(values) {
1625
+ return ZoneAwarePromise.allWithCallback(values);
1626
+ }
1627
+
1628
+ static allSettled(values) {
1629
+ const P = this && this.prototype instanceof ZoneAwarePromise ? this : ZoneAwarePromise;
1630
+ return P.allWithCallback(values, {
1631
+ thenCallback: value => ({
1632
+ status: 'fulfilled',
1633
+ value
1634
+ }),
1635
+ errorCallback: err => ({
1636
+ status: 'rejected',
1637
+ reason: err
1638
+ })
1639
+ });
1640
+ }
1641
+
1642
+ static allWithCallback(values, callback) {
1643
+ let resolve;
1644
+ let reject;
1645
+ let promise = new this((res, rej) => {
1646
+ resolve = res;
1647
+ reject = rej;
1648
+ }); // Start at 2 to prevent prematurely resolving if .then is called immediately.
1649
+
1650
+ let unresolvedCount = 2;
1651
+ let valueIndex = 0;
1652
+ const resolvedValues = [];
1653
+
1654
+ for (let value of values) {
1655
+ if (!isThenable(value)) {
1656
+ value = this.resolve(value);
1657
+ }
1658
+
1659
+ const curValueIndex = valueIndex;
1660
+
1661
+ try {
1662
+ value.then(value => {
1663
+ resolvedValues[curValueIndex] = callback ? callback.thenCallback(value) : value;
1664
+ unresolvedCount--;
1665
+
1666
+ if (unresolvedCount === 0) {
1667
+ resolve(resolvedValues);
1668
+ }
1669
+ }, err => {
1670
+ if (!callback) {
1671
+ reject(err);
1672
+ } else {
1673
+ resolvedValues[curValueIndex] = callback.errorCallback(err);
1674
+ unresolvedCount--;
1675
+
1676
+ if (unresolvedCount === 0) {
1677
+ resolve(resolvedValues);
1678
+ }
1679
+ }
1680
+ });
1681
+ } catch (thenErr) {
1682
+ reject(thenErr);
1683
+ }
1684
+
1685
+ unresolvedCount++;
1686
+ valueIndex++;
1687
+ } // Make the unresolvedCount zero-based again.
1688
+
1689
+
1690
+ unresolvedCount -= 2;
1691
+
1692
+ if (unresolvedCount === 0) {
1693
+ resolve(resolvedValues);
1694
+ }
1695
+
1696
+ return promise;
1697
+ }
1698
+
1699
+ constructor(executor) {
1700
+ const promise = this;
1701
+
1702
+ if (!(promise instanceof ZoneAwarePromise)) {
1703
+ throw new Error('Must be an instanceof Promise.');
1704
+ }
1705
+
1706
+ promise[symbolState] = UNRESOLVED;
1707
+ promise[symbolValue] = []; // queue;
1708
+
1709
+ try {
1710
+ executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED));
1711
+ } catch (error) {
1712
+ resolvePromise(promise, false, error);
1713
+ }
1714
+ }
1715
+
1716
+ get [Symbol.toStringTag]() {
1717
+ return 'Promise';
1718
+ }
1719
+
1720
+ get [Symbol.species]() {
1721
+ return ZoneAwarePromise;
1722
+ }
1723
+
1724
+ then(onFulfilled, onRejected) {
1725
+ let C = this.constructor[Symbol.species];
1726
+
1727
+ if (!C || typeof C !== 'function') {
1728
+ C = this.constructor || ZoneAwarePromise;
1729
+ }
1730
+
1731
+ const chainPromise = new C(noop);
1732
+ const zone = Zone.current;
1733
+
1734
+ if (this[symbolState] == UNRESOLVED) {
1735
+ this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected);
1736
+ } else {
1737
+ scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected);
1738
+ }
1739
+
1740
+ return chainPromise;
1741
+ }
1742
+
1743
+ catch(onRejected) {
1744
+ return this.then(null, onRejected);
1745
+ }
1746
+
1747
+ finally(onFinally) {
1748
+ let C = this.constructor[Symbol.species];
1749
+
1750
+ if (!C || typeof C !== 'function') {
1751
+ C = ZoneAwarePromise;
1752
+ }
1753
+
1754
+ const chainPromise = new C(noop);
1755
+ chainPromise[symbolFinally] = symbolFinally;
1756
+ const zone = Zone.current;
1757
+
1758
+ if (this[symbolState] == UNRESOLVED) {
1759
+ this[symbolValue].push(zone, chainPromise, onFinally, onFinally);
1760
+ } else {
1761
+ scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally);
1762
+ }
1763
+
1764
+ return chainPromise;
1765
+ }
1766
+
1767
+ } // Protect against aggressive optimizers dropping seemingly unused properties.
1768
+ // E.g. Closure Compiler in advanced mode.
1769
+
1770
+
1771
+ ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve;
1772
+ ZoneAwarePromise['reject'] = ZoneAwarePromise.reject;
1773
+ ZoneAwarePromise['race'] = ZoneAwarePromise.race;
1774
+ ZoneAwarePromise['all'] = ZoneAwarePromise.all;
1775
+ const NativePromise = global[symbolPromise] = global['Promise'];
1776
+ global['Promise'] = ZoneAwarePromise;
1777
+
1778
+ const symbolThenPatched = __symbol__('thenPatched');
1779
+
1780
+ function patchThen(Ctor) {
1781
+ const proto = Ctor.prototype;
1782
+ const prop = ObjectGetOwnPropertyDescriptor(proto, 'then');
1783
+
1784
+ if (prop && (prop.writable === false || !prop.configurable)) {
1785
+ // check Ctor.prototype.then propertyDescriptor is writable or not
1786
+ // in meteor env, writable is false, we should ignore such case
1787
+ return;
1788
+ }
1789
+
1790
+ const originalThen = proto.then; // Keep a reference to the original method.
1791
+
1792
+ proto[symbolThen] = originalThen;
1793
+
1794
+ Ctor.prototype.then = function (onResolve, onReject) {
1795
+ const wrapped = new ZoneAwarePromise((resolve, reject) => {
1796
+ originalThen.call(this, resolve, reject);
1797
+ });
1798
+ return wrapped.then(onResolve, onReject);
1799
+ };
1800
+
1801
+ Ctor[symbolThenPatched] = true;
1802
+ }
1803
+
1804
+ api.patchThen = patchThen;
1805
+
1806
+ function zoneify(fn) {
1807
+ return function (self, args) {
1808
+ let resultPromise = fn.apply(self, args);
1809
+
1810
+ if (resultPromise instanceof ZoneAwarePromise) {
1811
+ return resultPromise;
1812
+ }
1813
+
1814
+ let ctor = resultPromise.constructor;
1815
+
1816
+ if (!ctor[symbolThenPatched]) {
1817
+ patchThen(ctor);
1818
+ }
1819
+
1820
+ return resultPromise;
1821
+ };
1822
+ }
1823
+
1824
+ if (NativePromise) {
1825
+ patchThen(NativePromise);
1826
+ patchMethod(global, 'fetch', delegate => zoneify(delegate));
1827
+ } // This is not part of public API, but it is useful for tests, so we expose it.
1828
+
1829
+
1830
+ Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors;
1831
+ return ZoneAwarePromise;
1832
+ });
1833
+ /**
1834
+ * @license
1835
+ * Copyright Google LLC All Rights Reserved.
1836
+ *
1837
+ * Use of this source code is governed by an MIT-style license that can be
1838
+ * found in the LICENSE file at https://angular.io/license
1839
+ */
1840
+ // override Function.prototype.toString to make zone.js patched function
1841
+ // look like native function
1842
+
1843
+
1844
+ Zone.__load_patch('toString', global => {
1845
+ // patch Func.prototype.toString to let them look like native
1846
+ const originalFunctionToString = Function.prototype.toString;
1847
+ const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate');
1848
+ const PROMISE_SYMBOL = zoneSymbol('Promise');
1849
+ const ERROR_SYMBOL = zoneSymbol('Error');
1850
+
1851
+ const newFunctionToString = function toString() {
1852
+ if (typeof this === 'function') {
1853
+ const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL];
1854
+
1855
+ if (originalDelegate) {
1856
+ if (typeof originalDelegate === 'function') {
1857
+ return originalFunctionToString.call(originalDelegate);
1858
+ } else {
1859
+ return Object.prototype.toString.call(originalDelegate);
1860
+ }
1861
+ }
1862
+
1863
+ if (this === Promise) {
1864
+ const nativePromise = global[PROMISE_SYMBOL];
1865
+
1866
+ if (nativePromise) {
1867
+ return originalFunctionToString.call(nativePromise);
1868
+ }
1869
+ }
1870
+
1871
+ if (this === Error) {
1872
+ const nativeError = global[ERROR_SYMBOL];
1873
+
1874
+ if (nativeError) {
1875
+ return originalFunctionToString.call(nativeError);
1876
+ }
1877
+ }
1878
+ }
1879
+
1880
+ return originalFunctionToString.call(this);
1881
+ };
1882
+
1883
+ newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString;
1884
+ Function.prototype.toString = newFunctionToString; // patch Object.prototype.toString to let them look like native
1885
+
1886
+ const originalObjectToString = Object.prototype.toString;
1887
+ const PROMISE_OBJECT_TO_STRING = '[object Promise]';
1888
+
1889
+ Object.prototype.toString = function () {
1890
+ if (typeof Promise === 'function' && this instanceof Promise) {
1891
+ return PROMISE_OBJECT_TO_STRING;
1892
+ }
1893
+
1894
+ return originalObjectToString.call(this);
1895
+ };
1896
+ });
1897
+ /**
1898
+ * @license
1899
+ * Copyright Google LLC All Rights Reserved.
1900
+ *
1901
+ * Use of this source code is governed by an MIT-style license that can be
1902
+ * found in the LICENSE file at https://angular.io/license
1903
+ */
1904
+
1905
+
1906
+ let passiveSupported = false;
1907
+
1908
+ if (typeof window !== 'undefined') {
1909
+ try {
1910
+ const options = Object.defineProperty({}, 'passive', {
1911
+ get: function () {
1912
+ passiveSupported = true;
1913
+ }
1914
+ });
1915
+ window.addEventListener('test', options, options);
1916
+ window.removeEventListener('test', options, options);
1917
+ } catch (err) {
1918
+ passiveSupported = false;
1919
+ }
1920
+ } // an identifier to tell ZoneTask do not create a new invoke closure
1921
+
1922
+
1923
+ const OPTIMIZED_ZONE_EVENT_TASK_DATA = {
1924
+ useG: true
1925
+ };
1926
+ const zoneSymbolEventNames$1 = {};
1927
+ const globalSources = {};
1928
+ const EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$');
1929
+ const IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped');
1930
+
1931
+ function prepareEventNames(eventName, eventNameToString) {
1932
+ const falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR;
1933
+ const trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR;
1934
+ const symbol = ZONE_SYMBOL_PREFIX + falseEventName;
1935
+ const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
1936
+ zoneSymbolEventNames$1[eventName] = {};
1937
+ zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol;
1938
+ zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture;
1939
+ }
1940
+
1941
+ function patchEventTarget(_global, apis, patchOptions) {
1942
+ const ADD_EVENT_LISTENER = patchOptions && patchOptions.add || ADD_EVENT_LISTENER_STR;
1943
+ const REMOVE_EVENT_LISTENER = patchOptions && patchOptions.rm || REMOVE_EVENT_LISTENER_STR;
1944
+ const LISTENERS_EVENT_LISTENER = patchOptions && patchOptions.listeners || 'eventListeners';
1945
+ const REMOVE_ALL_LISTENERS_EVENT_LISTENER = patchOptions && patchOptions.rmAll || 'removeAllListeners';
1946
+ const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER);
1947
+ const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':';
1948
+ const PREPEND_EVENT_LISTENER = 'prependListener';
1949
+ const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
1950
+
1951
+ const invokeTask = function (task, target, event) {
1952
+ // for better performance, check isRemoved which is set
1953
+ // by removeEventListener
1954
+ if (task.isRemoved) {
1955
+ return;
1956
+ }
1957
+
1958
+ const delegate = task.callback;
1959
+
1960
+ if (typeof delegate === 'object' && delegate.handleEvent) {
1961
+ // create the bind version of handleEvent when invoke
1962
+ task.callback = event => delegate.handleEvent(event);
1963
+
1964
+ task.originalDelegate = delegate;
1965
+ } // invoke static task.invoke
1966
+
1967
+
1968
+ task.invoke(task, target, [event]);
1969
+ const options = task.options;
1970
+
1971
+ if (options && typeof options === 'object' && options.once) {
1972
+ // if options.once is true, after invoke once remove listener here
1973
+ // only browser need to do this, nodejs eventEmitter will cal removeListener
1974
+ // inside EventEmitter.once
1975
+ const delegate = task.originalDelegate ? task.originalDelegate : task.callback;
1976
+ target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options);
1977
+ }
1978
+ }; // global shared zoneAwareCallback to handle all event callback with capture = false
1979
+
1980
+
1981
+ const globalZoneAwareCallback = function (event) {
1982
+ // https://github.com/angular/zone.js/issues/911, in IE, sometimes
1983
+ // event will be undefined, so we need to use window.event
1984
+ event = event || _global.event;
1985
+
1986
+ if (!event) {
1987
+ return;
1988
+ } // event.target is needed for Samsung TV and SourceBuffer
1989
+ // || global is needed https://github.com/angular/zone.js/issues/190
1990
+
1991
+
1992
+ const target = this || event.target || _global;
1993
+ const tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]];
1994
+
1995
+ if (tasks) {
1996
+ // invoke all tasks which attached to current target with given event.type and capture = false
1997
+ // for performance concern, if task.length === 1, just invoke
1998
+ if (tasks.length === 1) {
1999
+ invokeTask(tasks[0], target, event);
2000
+ } else {
2001
+ // https://github.com/angular/zone.js/issues/836
2002
+ // copy the tasks array before invoke, to avoid
2003
+ // the callback will remove itself or other listener
2004
+ const copyTasks = tasks.slice();
2005
+
2006
+ for (let i = 0; i < copyTasks.length; i++) {
2007
+ if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
2008
+ break;
2009
+ }
2010
+
2011
+ invokeTask(copyTasks[i], target, event);
2012
+ }
2013
+ }
2014
+ }
2015
+ }; // global shared zoneAwareCallback to handle all event callback with capture = true
2016
+
2017
+
2018
+ const globalZoneAwareCaptureCallback = function (event) {
2019
+ // https://github.com/angular/zone.js/issues/911, in IE, sometimes
2020
+ // event will be undefined, so we need to use window.event
2021
+ event = event || _global.event;
2022
+
2023
+ if (!event) {
2024
+ return;
2025
+ } // event.target is needed for Samsung TV and SourceBuffer
2026
+ // || global is needed https://github.com/angular/zone.js/issues/190
2027
+
2028
+
2029
+ const target = this || event.target || _global;
2030
+ const tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]];
2031
+
2032
+ if (tasks) {
2033
+ // invoke all tasks which attached to current target with given event.type and capture = false
2034
+ // for performance concern, if task.length === 1, just invoke
2035
+ if (tasks.length === 1) {
2036
+ invokeTask(tasks[0], target, event);
2037
+ } else {
2038
+ // https://github.com/angular/zone.js/issues/836
2039
+ // copy the tasks array before invoke, to avoid
2040
+ // the callback will remove itself or other listener
2041
+ const copyTasks = tasks.slice();
2042
+
2043
+ for (let i = 0; i < copyTasks.length; i++) {
2044
+ if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
2045
+ break;
2046
+ }
2047
+
2048
+ invokeTask(copyTasks[i], target, event);
2049
+ }
2050
+ }
2051
+ }
2052
+ };
2053
+
2054
+ function patchEventTargetMethods(obj, patchOptions) {
2055
+ if (!obj) {
2056
+ return false;
2057
+ }
2058
+
2059
+ let useGlobalCallback = true;
2060
+
2061
+ if (patchOptions && patchOptions.useG !== undefined) {
2062
+ useGlobalCallback = patchOptions.useG;
2063
+ }
2064
+
2065
+ const validateHandler = patchOptions && patchOptions.vh;
2066
+ let checkDuplicate = true;
2067
+
2068
+ if (patchOptions && patchOptions.chkDup !== undefined) {
2069
+ checkDuplicate = patchOptions.chkDup;
2070
+ }
2071
+
2072
+ let returnTarget = false;
2073
+
2074
+ if (patchOptions && patchOptions.rt !== undefined) {
2075
+ returnTarget = patchOptions.rt;
2076
+ }
2077
+
2078
+ let proto = obj;
2079
+
2080
+ while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) {
2081
+ proto = ObjectGetPrototypeOf(proto);
2082
+ }
2083
+
2084
+ if (!proto && obj[ADD_EVENT_LISTENER]) {
2085
+ // somehow we did not find it, but we can see it. This happens on IE for Window properties.
2086
+ proto = obj;
2087
+ }
2088
+
2089
+ if (!proto) {
2090
+ return false;
2091
+ }
2092
+
2093
+ if (proto[zoneSymbolAddEventListener]) {
2094
+ return false;
2095
+ }
2096
+
2097
+ const eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask
2098
+ // so we do not need to create a new object just for pass some data
2099
+
2100
+ const taskData = {};
2101
+ const nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER];
2102
+ const nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = proto[REMOVE_EVENT_LISTENER];
2103
+ const nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = proto[LISTENERS_EVENT_LISTENER];
2104
+ const nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER];
2105
+ let nativePrependEventListener;
2106
+
2107
+ if (patchOptions && patchOptions.prepend) {
2108
+ nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = proto[patchOptions.prepend];
2109
+ }
2110
+ /**
2111
+ * This util function will build an option object with passive option
2112
+ * to handle all possible input from the user.
2113
+ */
2114
+
2115
+
2116
+ function buildEventListenerOptions(options, passive) {
2117
+ if (!passiveSupported && typeof options === 'object' && options) {
2118
+ // doesn't support passive but user want to pass an object as options.
2119
+ // this will not work on some old browser, so we just pass a boolean
2120
+ // as useCapture parameter
2121
+ return !!options.capture;
2122
+ }
2123
+
2124
+ if (!passiveSupported || !passive) {
2125
+ return options;
2126
+ }
2127
+
2128
+ if (typeof options === 'boolean') {
2129
+ return {
2130
+ capture: options,
2131
+ passive: true
2132
+ };
2133
+ }
2134
+
2135
+ if (!options) {
2136
+ return {
2137
+ passive: true
2138
+ };
2139
+ }
2140
+
2141
+ if (typeof options === 'object' && options.passive !== false) {
2142
+ return Object.assign(Object.assign({}, options), {
2143
+ passive: true
2144
+ });
2145
+ }
2146
+
2147
+ return options;
2148
+ }
2149
+
2150
+ const customScheduleGlobal = function (task) {
2151
+ // if there is already a task for the eventName + capture,
2152
+ // just return, because we use the shared globalZoneAwareCallback here.
2153
+ if (taskData.isExisting) {
2154
+ return;
2155
+ }
2156
+
2157
+ return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options);
2158
+ };
2159
+
2160
+ const customCancelGlobal = function (task) {
2161
+ // if task is not marked as isRemoved, this call is directly
2162
+ // from Zone.prototype.cancelTask, we should remove the task
2163
+ // from tasksList of target first
2164
+ if (!task.isRemoved) {
2165
+ const symbolEventNames = zoneSymbolEventNames$1[task.eventName];
2166
+ let symbolEventName;
2167
+
2168
+ if (symbolEventNames) {
2169
+ symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR];
2170
+ }
2171
+
2172
+ const existingTasks = symbolEventName && task.target[symbolEventName];
2173
+
2174
+ if (existingTasks) {
2175
+ for (let i = 0; i < existingTasks.length; i++) {
2176
+ const existingTask = existingTasks[i];
2177
+
2178
+ if (existingTask === task) {
2179
+ existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check
2180
+
2181
+ task.isRemoved = true;
2182
+
2183
+ if (existingTasks.length === 0) {
2184
+ // all tasks for the eventName + capture have gone,
2185
+ // remove globalZoneAwareCallback and remove the task cache from target
2186
+ task.allRemoved = true;
2187
+ task.target[symbolEventName] = null;
2188
+ }
2189
+
2190
+ break;
2191
+ }
2192
+ }
2193
+ }
2194
+ } // if all tasks for the eventName + capture have gone,
2195
+ // we will really remove the global event callback,
2196
+ // if not, return
2197
+
2198
+
2199
+ if (!task.allRemoved) {
2200
+ return;
2201
+ }
2202
+
2203
+ return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options);
2204
+ };
2205
+
2206
+ const customScheduleNonGlobal = function (task) {
2207
+ return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options);
2208
+ };
2209
+
2210
+ const customSchedulePrepend = function (task) {
2211
+ return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options);
2212
+ };
2213
+
2214
+ const customCancelNonGlobal = function (task) {
2215
+ return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options);
2216
+ };
2217
+
2218
+ const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal;
2219
+ const customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal;
2220
+
2221
+ const compareTaskCallbackVsDelegate = function (task, delegate) {
2222
+ const typeOfDelegate = typeof delegate;
2223
+ return typeOfDelegate === 'function' && task.callback === delegate || typeOfDelegate === 'object' && task.originalDelegate === delegate;
2224
+ };
2225
+
2226
+ const compare = patchOptions && patchOptions.diff ? patchOptions.diff : compareTaskCallbackVsDelegate;
2227
+ const unpatchedEvents = Zone[zoneSymbol('UNPATCHED_EVENTS')];
2228
+
2229
+ const passiveEvents = _global[zoneSymbol('PASSIVE_EVENTS')];
2230
+
2231
+ const makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget = false, prepend = false) {
2232
+ return function () {
2233
+ const target = this || _global;
2234
+ let eventName = arguments[0];
2235
+
2236
+ if (patchOptions && patchOptions.transferEventName) {
2237
+ eventName = patchOptions.transferEventName(eventName);
2238
+ }
2239
+
2240
+ let delegate = arguments[1];
2241
+
2242
+ if (!delegate) {
2243
+ return nativeListener.apply(this, arguments);
2244
+ }
2245
+
2246
+ if (isNode && eventName === 'uncaughtException') {
2247
+ // don't patch uncaughtException of nodejs to prevent endless loop
2248
+ return nativeListener.apply(this, arguments);
2249
+ } // don't create the bind delegate function for handleEvent
2250
+ // case here to improve addEventListener performance
2251
+ // we will create the bind delegate when invoke
2252
+
2253
+
2254
+ let isHandleEvent = false;
2255
+
2256
+ if (typeof delegate !== 'function') {
2257
+ if (!delegate.handleEvent) {
2258
+ return nativeListener.apply(this, arguments);
2259
+ }
2260
+
2261
+ isHandleEvent = true;
2262
+ }
2263
+
2264
+ if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) {
2265
+ return;
2266
+ }
2267
+
2268
+ const passive = passiveSupported && !!passiveEvents && passiveEvents.indexOf(eventName) !== -1;
2269
+ const options = buildEventListenerOptions(arguments[2], passive);
2270
+
2271
+ if (unpatchedEvents) {
2272
+ // check upatched list
2273
+ for (let i = 0; i < unpatchedEvents.length; i++) {
2274
+ if (eventName === unpatchedEvents[i]) {
2275
+ if (passive) {
2276
+ return nativeListener.call(target, eventName, delegate, options);
2277
+ } else {
2278
+ return nativeListener.apply(this, arguments);
2279
+ }
2280
+ }
2281
+ }
2282
+ }
2283
+
2284
+ const capture = !options ? false : typeof options === 'boolean' ? true : options.capture;
2285
+ const once = options && typeof options === 'object' ? options.once : false;
2286
+ const zone = Zone.current;
2287
+ let symbolEventNames = zoneSymbolEventNames$1[eventName];
2288
+
2289
+ if (!symbolEventNames) {
2290
+ prepareEventNames(eventName, eventNameToString);
2291
+ symbolEventNames = zoneSymbolEventNames$1[eventName];
2292
+ }
2293
+
2294
+ const symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR];
2295
+ let existingTasks = target[symbolEventName];
2296
+ let isExisting = false;
2297
+
2298
+ if (existingTasks) {
2299
+ // already have task registered
2300
+ isExisting = true;
2301
+
2302
+ if (checkDuplicate) {
2303
+ for (let i = 0; i < existingTasks.length; i++) {
2304
+ if (compare(existingTasks[i], delegate)) {
2305
+ // same callback, same capture, same event name, just return
2306
+ return;
2307
+ }
2308
+ }
2309
+ }
2310
+ } else {
2311
+ existingTasks = target[symbolEventName] = [];
2312
+ }
2313
+
2314
+ let source;
2315
+ const constructorName = target.constructor['name'];
2316
+ const targetSource = globalSources[constructorName];
2317
+
2318
+ if (targetSource) {
2319
+ source = targetSource[eventName];
2320
+ }
2321
+
2322
+ if (!source) {
2323
+ source = constructorName + addSource + (eventNameToString ? eventNameToString(eventName) : eventName);
2324
+ } // do not create a new object as task.data to pass those things
2325
+ // just use the global shared one
2326
+
2327
+
2328
+ taskData.options = options;
2329
+
2330
+ if (once) {
2331
+ // if addEventListener with once options, we don't pass it to
2332
+ // native addEventListener, instead we keep the once setting
2333
+ // and handle ourselves.
2334
+ taskData.options.once = false;
2335
+ }
2336
+
2337
+ taskData.target = target;
2338
+ taskData.capture = capture;
2339
+ taskData.eventName = eventName;
2340
+ taskData.isExisting = isExisting;
2341
+ const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information
2342
+
2343
+ if (data) {
2344
+ data.taskData = taskData;
2345
+ }
2346
+
2347
+ const task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); // should clear taskData.target to avoid memory leak
2348
+ // issue, https://github.com/angular/angular/issues/20442
2349
+
2350
+ taskData.target = null; // need to clear up taskData because it is a global object
2351
+
2352
+ if (data) {
2353
+ data.taskData = null;
2354
+ } // have to save those information to task in case
2355
+ // application may call task.zone.cancelTask() directly
2356
+
2357
+
2358
+ if (once) {
2359
+ options.once = true;
2360
+ }
2361
+
2362
+ if (!(!passiveSupported && typeof task.options === 'boolean')) {
2363
+ // if not support passive, and we pass an option object
2364
+ // to addEventListener, we should save the options to task
2365
+ task.options = options;
2366
+ }
2367
+
2368
+ task.target = target;
2369
+ task.capture = capture;
2370
+ task.eventName = eventName;
2371
+
2372
+ if (isHandleEvent) {
2373
+ // save original delegate for compare to check duplicate
2374
+ task.originalDelegate = delegate;
2375
+ }
2376
+
2377
+ if (!prepend) {
2378
+ existingTasks.push(task);
2379
+ } else {
2380
+ existingTasks.unshift(task);
2381
+ }
2382
+
2383
+ if (returnTarget) {
2384
+ return target;
2385
+ }
2386
+ };
2387
+ };
2388
+
2389
+ proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget);
2390
+
2391
+ if (nativePrependEventListener) {
2392
+ proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true);
2393
+ }
2394
+
2395
+ proto[REMOVE_EVENT_LISTENER] = function () {
2396
+ const target = this || _global;
2397
+ let eventName = arguments[0];
2398
+
2399
+ if (patchOptions && patchOptions.transferEventName) {
2400
+ eventName = patchOptions.transferEventName(eventName);
2401
+ }
2402
+
2403
+ const options = arguments[2];
2404
+ const capture = !options ? false : typeof options === 'boolean' ? true : options.capture;
2405
+ const delegate = arguments[1];
2406
+
2407
+ if (!delegate) {
2408
+ return nativeRemoveEventListener.apply(this, arguments);
2409
+ }
2410
+
2411
+ if (validateHandler && !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) {
2412
+ return;
2413
+ }
2414
+
2415
+ const symbolEventNames = zoneSymbolEventNames$1[eventName];
2416
+ let symbolEventName;
2417
+
2418
+ if (symbolEventNames) {
2419
+ symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR];
2420
+ }
2421
+
2422
+ const existingTasks = symbolEventName && target[symbolEventName];
2423
+
2424
+ if (existingTasks) {
2425
+ for (let i = 0; i < existingTasks.length; i++) {
2426
+ const existingTask = existingTasks[i];
2427
+
2428
+ if (compare(existingTask, delegate)) {
2429
+ existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check
2430
+
2431
+ existingTask.isRemoved = true;
2432
+
2433
+ if (existingTasks.length === 0) {
2434
+ // all tasks for the eventName + capture have gone,
2435
+ // remove globalZoneAwareCallback and remove the task cache from target
2436
+ existingTask.allRemoved = true;
2437
+ target[symbolEventName] = null; // in the target, we have an event listener which is added by on_property
2438
+ // such as target.onclick = function() {}, so we need to clear this internal
2439
+ // property too if all delegates all removed
2440
+
2441
+ if (typeof eventName === 'string') {
2442
+ const onPropertySymbol = ZONE_SYMBOL_PREFIX + 'ON_PROPERTY' + eventName;
2443
+ target[onPropertySymbol] = null;
2444
+ }
2445
+ }
2446
+
2447
+ existingTask.zone.cancelTask(existingTask);
2448
+
2449
+ if (returnTarget) {
2450
+ return target;
2451
+ }
2452
+
2453
+ return;
2454
+ }
2455
+ }
2456
+ } // issue 930, didn't find the event name or callback
2457
+ // from zone kept existingTasks, the callback maybe
2458
+ // added outside of zone, we need to call native removeEventListener
2459
+ // to try to remove it.
2460
+
2461
+
2462
+ return nativeRemoveEventListener.apply(this, arguments);
2463
+ };
2464
+
2465
+ proto[LISTENERS_EVENT_LISTENER] = function () {
2466
+ const target = this || _global;
2467
+ let eventName = arguments[0];
2468
+
2469
+ if (patchOptions && patchOptions.transferEventName) {
2470
+ eventName = patchOptions.transferEventName(eventName);
2471
+ }
2472
+
2473
+ const listeners = [];
2474
+ const tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName);
2475
+
2476
+ for (let i = 0; i < tasks.length; i++) {
2477
+ const task = tasks[i];
2478
+ let delegate = task.originalDelegate ? task.originalDelegate : task.callback;
2479
+ listeners.push(delegate);
2480
+ }
2481
+
2482
+ return listeners;
2483
+ };
2484
+
2485
+ proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () {
2486
+ const target = this || _global;
2487
+ let eventName = arguments[0];
2488
+
2489
+ if (!eventName) {
2490
+ const keys = Object.keys(target);
2491
+
2492
+ for (let i = 0; i < keys.length; i++) {
2493
+ const prop = keys[i];
2494
+ const match = EVENT_NAME_SYMBOL_REGX.exec(prop);
2495
+ let evtName = match && match[1]; // in nodejs EventEmitter, removeListener event is
2496
+ // used for monitoring the removeListener call,
2497
+ // so just keep removeListener eventListener until
2498
+ // all other eventListeners are removed
2499
+
2500
+ if (evtName && evtName !== 'removeListener') {
2501
+ this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName);
2502
+ }
2503
+ } // remove removeListener listener finally
2504
+
2505
+
2506
+ this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener');
2507
+ } else {
2508
+ if (patchOptions && patchOptions.transferEventName) {
2509
+ eventName = patchOptions.transferEventName(eventName);
2510
+ }
2511
+
2512
+ const symbolEventNames = zoneSymbolEventNames$1[eventName];
2513
+
2514
+ if (symbolEventNames) {
2515
+ const symbolEventName = symbolEventNames[FALSE_STR];
2516
+ const symbolCaptureEventName = symbolEventNames[TRUE_STR];
2517
+ const tasks = target[symbolEventName];
2518
+ const captureTasks = target[symbolCaptureEventName];
2519
+
2520
+ if (tasks) {
2521
+ const removeTasks = tasks.slice();
2522
+
2523
+ for (let i = 0; i < removeTasks.length; i++) {
2524
+ const task = removeTasks[i];
2525
+ let delegate = task.originalDelegate ? task.originalDelegate : task.callback;
2526
+ this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options);
2527
+ }
2528
+ }
2529
+
2530
+ if (captureTasks) {
2531
+ const removeTasks = captureTasks.slice();
2532
+
2533
+ for (let i = 0; i < removeTasks.length; i++) {
2534
+ const task = removeTasks[i];
2535
+ let delegate = task.originalDelegate ? task.originalDelegate : task.callback;
2536
+ this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options);
2537
+ }
2538
+ }
2539
+ }
2540
+ }
2541
+
2542
+ if (returnTarget) {
2543
+ return this;
2544
+ }
2545
+ }; // for native toString patch
2546
+
2547
+
2548
+ attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener);
2549
+ attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener);
2550
+
2551
+ if (nativeRemoveAllListeners) {
2552
+ attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners);
2553
+ }
2554
+
2555
+ if (nativeListeners) {
2556
+ attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners);
2557
+ }
2558
+
2559
+ return true;
2560
+ }
2561
+
2562
+ let results = [];
2563
+
2564
+ for (let i = 0; i < apis.length; i++) {
2565
+ results[i] = patchEventTargetMethods(apis[i], patchOptions);
2566
+ }
2567
+
2568
+ return results;
2569
+ }
2570
+
2571
+ function findEventTasks(target, eventName) {
2572
+ if (!eventName) {
2573
+ const foundTasks = [];
2574
+
2575
+ for (let prop in target) {
2576
+ const match = EVENT_NAME_SYMBOL_REGX.exec(prop);
2577
+ let evtName = match && match[1];
2578
+
2579
+ if (evtName && (!eventName || evtName === eventName)) {
2580
+ const tasks = target[prop];
2581
+
2582
+ if (tasks) {
2583
+ for (let i = 0; i < tasks.length; i++) {
2584
+ foundTasks.push(tasks[i]);
2585
+ }
2586
+ }
2587
+ }
2588
+ }
2589
+
2590
+ return foundTasks;
2591
+ }
2592
+
2593
+ let symbolEventName = zoneSymbolEventNames$1[eventName];
2594
+
2595
+ if (!symbolEventName) {
2596
+ prepareEventNames(eventName);
2597
+ symbolEventName = zoneSymbolEventNames$1[eventName];
2598
+ }
2599
+
2600
+ const captureFalseTasks = target[symbolEventName[FALSE_STR]];
2601
+ const captureTrueTasks = target[symbolEventName[TRUE_STR]];
2602
+
2603
+ if (!captureFalseTasks) {
2604
+ return captureTrueTasks ? captureTrueTasks.slice() : [];
2605
+ } else {
2606
+ return captureTrueTasks ? captureFalseTasks.concat(captureTrueTasks) : captureFalseTasks.slice();
2607
+ }
2608
+ }
2609
+
2610
+ function patchEventPrototype(global, api) {
2611
+ const Event = global['Event'];
2612
+
2613
+ if (Event && Event.prototype) {
2614
+ api.patchMethod(Event.prototype, 'stopImmediatePropagation', delegate => function (self, args) {
2615
+ self[IMMEDIATE_PROPAGATION_SYMBOL] = true; // we need to call the native stopImmediatePropagation
2616
+ // in case in some hybrid application, some part of
2617
+ // application will be controlled by zone, some are not
2618
+
2619
+ delegate && delegate.apply(self, args);
2620
+ });
2621
+ }
2622
+ }
2623
+ /**
2624
+ * @license
2625
+ * Copyright Google LLC All Rights Reserved.
2626
+ *
2627
+ * Use of this source code is governed by an MIT-style license that can be
2628
+ * found in the LICENSE file at https://angular.io/license
2629
+ */
2630
+
2631
+
2632
+ function patchCallbacks(api, target, targetName, method, callbacks) {
2633
+ const symbol = Zone.__symbol__(method);
2634
+
2635
+ if (target[symbol]) {
2636
+ return;
2637
+ }
2638
+
2639
+ const nativeDelegate = target[symbol] = target[method];
2640
+
2641
+ target[method] = function (name, opts, options) {
2642
+ if (opts && opts.prototype) {
2643
+ callbacks.forEach(function (callback) {
2644
+ const source = `${targetName}.${method}::` + callback;
2645
+ const prototype = opts.prototype;
2646
+
2647
+ if (prototype.hasOwnProperty(callback)) {
2648
+ const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback);
2649
+
2650
+ if (descriptor && descriptor.value) {
2651
+ descriptor.value = api.wrapWithCurrentZone(descriptor.value, source);
2652
+
2653
+ api._redefineProperty(opts.prototype, callback, descriptor);
2654
+ } else if (prototype[callback]) {
2655
+ prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
2656
+ }
2657
+ } else if (prototype[callback]) {
2658
+ prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
2659
+ }
2660
+ });
2661
+ }
2662
+
2663
+ return nativeDelegate.call(target, name, opts, options);
2664
+ };
2665
+
2666
+ api.attachOriginToPatched(target[method], nativeDelegate);
2667
+ }
2668
+ /**
2669
+ * @license
2670
+ * Copyright Google LLC All Rights Reserved.
2671
+ *
2672
+ * Use of this source code is governed by an MIT-style license that can be
2673
+ * found in the LICENSE file at https://angular.io/license
2674
+ */
2675
+
2676
+
2677
+ const globalEventHandlersEventNames = ['abort', 'animationcancel', 'animationend', 'animationiteration', 'auxclick', 'beforeinput', 'blur', 'cancel', 'canplay', 'canplaythrough', 'change', 'compositionstart', 'compositionupdate', 'compositionend', 'cuechange', 'click', 'close', 'contextmenu', 'curechange', 'dblclick', 'drag', 'dragend', 'dragenter', 'dragexit', 'dragleave', 'dragover', 'drop', 'durationchange', 'emptied', 'ended', 'error', 'focus', 'focusin', 'focusout', 'gotpointercapture', 'input', 'invalid', 'keydown', 'keypress', 'keyup', 'load', 'loadstart', 'loadeddata', 'loadedmetadata', 'lostpointercapture', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'mousewheel', 'orientationchange', 'pause', 'play', 'playing', 'pointercancel', 'pointerdown', 'pointerenter', 'pointerleave', 'pointerlockchange', 'mozpointerlockchange', 'webkitpointerlockerchange', 'pointerlockerror', 'mozpointerlockerror', 'webkitpointerlockerror', 'pointermove', 'pointout', 'pointerover', 'pointerup', 'progress', 'ratechange', 'reset', 'resize', 'scroll', 'seeked', 'seeking', 'select', 'selectionchange', 'selectstart', 'show', 'sort', 'stalled', 'submit', 'suspend', 'timeupdate', 'volumechange', 'touchcancel', 'touchmove', 'touchstart', 'touchend', 'transitioncancel', 'transitionend', 'waiting', 'wheel'];
2678
+ const documentEventNames = ['afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', 'visibilitychange', 'resume'];
2679
+ const windowEventNames = ['absolutedeviceorientation', 'afterinput', 'afterprint', 'appinstalled', 'beforeinstallprompt', 'beforeprint', 'beforeunload', 'devicelight', 'devicemotion', 'deviceorientation', 'deviceorientationabsolute', 'deviceproximity', 'hashchange', 'languagechange', 'message', 'mozbeforepaint', 'offline', 'online', 'paint', 'pageshow', 'pagehide', 'popstate', 'rejectionhandled', 'storage', 'unhandledrejection', 'unload', 'userproximity', 'vrdisplayconnected', 'vrdisplaydisconnected', 'vrdisplaypresentchange'];
2680
+ const htmlElementEventNames = ['beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend'];
2681
+ const mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend'];
2682
+ const ieElementEventNames = ['activate', 'afterupdate', 'ariarequest', 'beforeactivate', 'beforedeactivate', 'beforeeditfocus', 'beforeupdate', 'cellchange', 'controlselect', 'dataavailable', 'datasetchanged', 'datasetcomplete', 'errorupdate', 'filterchange', 'layoutcomplete', 'losecapture', 'move', 'moveend', 'movestart', 'propertychange', 'resizeend', 'resizestart', 'rowenter', 'rowexit', 'rowsdelete', 'rowsinserted', 'command', 'compassneedscalibration', 'deactivate', 'help', 'mscontentzoom', 'msmanipulationstatechanged', 'msgesturechange', 'msgesturedoubletap', 'msgestureend', 'msgesturehold', 'msgesturestart', 'msgesturetap', 'msgotpointercapture', 'msinertiastart', 'mslostpointercapture', 'mspointercancel', 'mspointerdown', 'mspointerenter', 'mspointerhover', 'mspointerleave', 'mspointermove', 'mspointerout', 'mspointerover', 'mspointerup', 'pointerout', 'mssitemodejumplistitemremoved', 'msthumbnailclick', 'stop', 'storagecommit'];
2683
+ const webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror'];
2684
+ const formEventNames = ['autocomplete', 'autocompleteerror'];
2685
+ const detailEventNames = ['toggle'];
2686
+ const frameEventNames = ['load'];
2687
+ const frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror'];
2688
+ const marqueeEventNames = ['bounce', 'finish', 'start'];
2689
+ const XMLHttpRequestEventNames = ['loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', 'readystatechange'];
2690
+ const IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close'];
2691
+ const websocketEventNames = ['close', 'error', 'open', 'message'];
2692
+ const workerEventNames = ['error', 'message'];
2693
+ const eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames);
2694
+
2695
+ function filterProperties(target, onProperties, ignoreProperties) {
2696
+ if (!ignoreProperties || ignoreProperties.length === 0) {
2697
+ return onProperties;
2698
+ }
2699
+
2700
+ const tip = ignoreProperties.filter(ip => ip.target === target);
2701
+
2702
+ if (!tip || tip.length === 0) {
2703
+ return onProperties;
2704
+ }
2705
+
2706
+ const targetIgnoreProperties = tip[0].ignoreProperties;
2707
+ return onProperties.filter(op => targetIgnoreProperties.indexOf(op) === -1);
2708
+ }
2709
+
2710
+ function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) {
2711
+ // check whether target is available, sometimes target will be undefined
2712
+ // because different browser or some 3rd party plugin.
2713
+ if (!target) {
2714
+ return;
2715
+ }
2716
+
2717
+ const filteredProperties = filterProperties(target, onProperties, ignoreProperties);
2718
+ patchOnProperties(target, filteredProperties, prototype);
2719
+ }
2720
+
2721
+ function propertyDescriptorPatch(api, _global) {
2722
+ if (isNode && !isMix) {
2723
+ return;
2724
+ }
2725
+
2726
+ if (Zone[api.symbol('patchEvents')]) {
2727
+ // events are already been patched by legacy patch.
2728
+ return;
2729
+ }
2730
+
2731
+ const supportsWebSocket = typeof WebSocket !== 'undefined';
2732
+ const ignoreProperties = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox
2733
+
2734
+ if (isBrowser) {
2735
+ const internalWindow = window;
2736
+ const ignoreErrorProperties = isIE() ? [{
2737
+ target: internalWindow,
2738
+ ignoreProperties: ['error']
2739
+ }] : []; // in IE/Edge, onProp not exist in window object, but in WindowPrototype
2740
+ // so we need to pass WindowPrototype to check onProp exist or not
2741
+
2742
+ patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow));
2743
+ patchFilteredProperties(Document.prototype, eventNames, ignoreProperties);
2744
+
2745
+ if (typeof internalWindow['SVGElement'] !== 'undefined') {
2746
+ patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties);
2747
+ }
2748
+
2749
+ patchFilteredProperties(Element.prototype, eventNames, ignoreProperties);
2750
+ patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties);
2751
+ patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties);
2752
+ patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties);
2753
+ patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties);
2754
+ patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties);
2755
+ patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties);
2756
+ const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement'];
2757
+
2758
+ if (HTMLMarqueeElement) {
2759
+ patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties);
2760
+ }
2761
+
2762
+ const Worker = internalWindow['Worker'];
2763
+
2764
+ if (Worker) {
2765
+ patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties);
2766
+ }
2767
+ }
2768
+
2769
+ const XMLHttpRequest = _global['XMLHttpRequest'];
2770
+
2771
+ if (XMLHttpRequest) {
2772
+ // XMLHttpRequest is not available in ServiceWorker, so we need to check here
2773
+ patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties);
2774
+ }
2775
+
2776
+ const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget'];
2777
+
2778
+ if (XMLHttpRequestEventTarget) {
2779
+ patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties);
2780
+ }
2781
+
2782
+ if (typeof IDBIndex !== 'undefined') {
2783
+ patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties);
2784
+ patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties);
2785
+ patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties);
2786
+ patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties);
2787
+ patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties);
2788
+ patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties);
2789
+ }
2790
+
2791
+ if (supportsWebSocket) {
2792
+ patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties);
2793
+ }
2794
+ }
2795
+ /**
2796
+ * @license
2797
+ * Copyright Google LLC All Rights Reserved.
2798
+ *
2799
+ * Use of this source code is governed by an MIT-style license that can be
2800
+ * found in the LICENSE file at https://angular.io/license
2801
+ */
2802
+
2803
+
2804
+ Zone.__load_patch('util', (global, Zone, api) => {
2805
+ api.patchOnProperties = patchOnProperties;
2806
+ api.patchMethod = patchMethod;
2807
+ api.bindArguments = bindArguments;
2808
+ api.patchMacroTask = patchMacroTask; // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to
2809
+ // define which events will not be patched by `Zone.js`.
2810
+ // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep
2811
+ // the name consistent with angular repo.
2812
+ // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for
2813
+ // backwards compatibility.
2814
+
2815
+ const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS');
2816
+
2817
+ const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS');
2818
+
2819
+ if (global[SYMBOL_UNPATCHED_EVENTS]) {
2820
+ global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS];
2821
+ }
2822
+
2823
+ if (global[SYMBOL_BLACK_LISTED_EVENTS]) {
2824
+ Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS];
2825
+ }
2826
+
2827
+ api.patchEventPrototype = patchEventPrototype;
2828
+ api.patchEventTarget = patchEventTarget;
2829
+ api.isIEOrEdge = isIEOrEdge;
2830
+ api.ObjectDefineProperty = ObjectDefineProperty;
2831
+ api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
2832
+ api.ObjectCreate = ObjectCreate;
2833
+ api.ArraySlice = ArraySlice;
2834
+ api.patchClass = patchClass;
2835
+ api.wrapWithCurrentZone = wrapWithCurrentZone;
2836
+ api.filterProperties = filterProperties;
2837
+ api.attachOriginToPatched = attachOriginToPatched;
2838
+ api._redefineProperty = Object.defineProperty;
2839
+ api.patchCallbacks = patchCallbacks;
2840
+
2841
+ api.getGlobalObjects = () => ({
2842
+ globalSources,
2843
+ zoneSymbolEventNames: zoneSymbolEventNames$1,
2844
+ eventNames,
2845
+ isBrowser,
2846
+ isMix,
2847
+ isNode,
2848
+ TRUE_STR,
2849
+ FALSE_STR,
2850
+ ZONE_SYMBOL_PREFIX,
2851
+ ADD_EVENT_LISTENER_STR,
2852
+ REMOVE_EVENT_LISTENER_STR
2853
+ });
2854
+ });
2855
+ /**
2856
+ * @license
2857
+ * Copyright Google LLC All Rights Reserved.
2858
+ *
2859
+ * Use of this source code is governed by an MIT-style license that can be
2860
+ * found in the LICENSE file at https://angular.io/license
2861
+ */
2862
+
2863
+
2864
+ const taskSymbol = zoneSymbol('zoneTask');
2865
+
2866
+ function patchTimer(window, setName, cancelName, nameSuffix) {
2867
+ let setNative = null;
2868
+ let clearNative = null;
2869
+ setName += nameSuffix;
2870
+ cancelName += nameSuffix;
2871
+ const tasksByHandleId = {};
2872
+
2873
+ function scheduleTask(task) {
2874
+ const data = task.data;
2875
+
2876
+ data.args[0] = function () {
2877
+ return task.invoke.apply(this, arguments);
2878
+ };
2879
+
2880
+ data.handleId = setNative.apply(window, data.args);
2881
+ return task;
2882
+ }
2883
+
2884
+ function clearTask(task) {
2885
+ return clearNative.call(window, task.data.handleId);
2886
+ }
2887
+
2888
+ setNative = patchMethod(window, setName, delegate => function (self, args) {
2889
+ if (typeof args[0] === 'function') {
2890
+ const options = {
2891
+ isPeriodic: nameSuffix === 'Interval',
2892
+ delay: nameSuffix === 'Timeout' || nameSuffix === 'Interval' ? args[1] || 0 : undefined,
2893
+ args: args
2894
+ };
2895
+ const callback = args[0];
2896
+
2897
+ args[0] = function timer() {
2898
+ try {
2899
+ return callback.apply(this, arguments);
2900
+ } finally {
2901
+ // issue-934, task will be cancelled
2902
+ // even it is a periodic task such as
2903
+ // setInterval
2904
+ // https://github.com/angular/angular/issues/40387
2905
+ // Cleanup tasksByHandleId should be handled before scheduleTask
2906
+ // Since some zoneSpec may intercept and doesn't trigger
2907
+ // scheduleFn(scheduleTask) provided here.
2908
+ if (!options.isPeriodic) {
2909
+ if (typeof options.handleId === 'number') {
2910
+ // in non-nodejs env, we remove timerId
2911
+ // from local cache
2912
+ delete tasksByHandleId[options.handleId];
2913
+ } else if (options.handleId) {
2914
+ // Node returns complex objects as handleIds
2915
+ // we remove task reference from timer object
2916
+ options.handleId[taskSymbol] = null;
2917
+ }
2918
+ }
2919
+ }
2920
+ };
2921
+
2922
+ const task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask);
2923
+
2924
+ if (!task) {
2925
+ return task;
2926
+ } // Node.js must additionally support the ref and unref functions.
2927
+
2928
+
2929
+ const handle = task.data.handleId;
2930
+
2931
+ if (typeof handle === 'number') {
2932
+ // for non nodejs env, we save handleId: task
2933
+ // mapping in local cache for clearTimeout
2934
+ tasksByHandleId[handle] = task;
2935
+ } else if (handle) {
2936
+ // for nodejs env, we save task
2937
+ // reference in timerId Object for clearTimeout
2938
+ handle[taskSymbol] = task;
2939
+ } // check whether handle is null, because some polyfill or browser
2940
+ // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame
2941
+
2942
+
2943
+ if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && typeof handle.unref === 'function') {
2944
+ task.ref = handle.ref.bind(handle);
2945
+ task.unref = handle.unref.bind(handle);
2946
+ }
2947
+
2948
+ if (typeof handle === 'number' || handle) {
2949
+ return handle;
2950
+ }
2951
+
2952
+ return task;
2953
+ } else {
2954
+ // cause an error by calling it directly.
2955
+ return delegate.apply(window, args);
2956
+ }
2957
+ });
2958
+ clearNative = patchMethod(window, cancelName, delegate => function (self, args) {
2959
+ const id = args[0];
2960
+ let task;
2961
+
2962
+ if (typeof id === 'number') {
2963
+ // non nodejs env.
2964
+ task = tasksByHandleId[id];
2965
+ } else {
2966
+ // nodejs env.
2967
+ task = id && id[taskSymbol]; // other environments.
2968
+
2969
+ if (!task) {
2970
+ task = id;
2971
+ }
2972
+ }
2973
+
2974
+ if (task && typeof task.type === 'string') {
2975
+ if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) {
2976
+ if (typeof id === 'number') {
2977
+ delete tasksByHandleId[id];
2978
+ } else if (id) {
2979
+ id[taskSymbol] = null;
2980
+ } // Do not cancel already canceled functions
2981
+
2982
+
2983
+ task.zone.cancelTask(task);
2984
+ }
2985
+ } else {
2986
+ // cause an error by calling it directly.
2987
+ delegate.apply(window, args);
2988
+ }
2989
+ });
2990
+ }
2991
+ /**
2992
+ * @license
2993
+ * Copyright Google LLC All Rights Reserved.
2994
+ *
2995
+ * Use of this source code is governed by an MIT-style license that can be
2996
+ * found in the LICENSE file at https://angular.io/license
2997
+ */
2998
+
2999
+
3000
+ function patchCustomElements(_global, api) {
3001
+ const {
3002
+ isBrowser,
3003
+ isMix
3004
+ } = api.getGlobalObjects();
3005
+
3006
+ if (!isBrowser && !isMix || !_global['customElements'] || !('customElements' in _global)) {
3007
+ return;
3008
+ }
3009
+
3010
+ const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback'];
3011
+ api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks);
3012
+ }
3013
+ /**
3014
+ * @license
3015
+ * Copyright Google LLC All Rights Reserved.
3016
+ *
3017
+ * Use of this source code is governed by an MIT-style license that can be
3018
+ * found in the LICENSE file at https://angular.io/license
3019
+ */
3020
+
3021
+
3022
+ function eventTargetPatch(_global, api) {
3023
+ if (Zone[api.symbol('patchEventTarget')]) {
3024
+ // EventTarget is already patched.
3025
+ return;
3026
+ }
3027
+
3028
+ const {
3029
+ eventNames,
3030
+ zoneSymbolEventNames,
3031
+ TRUE_STR,
3032
+ FALSE_STR,
3033
+ ZONE_SYMBOL_PREFIX
3034
+ } = api.getGlobalObjects(); // predefine all __zone_symbol__ + eventName + true/false string
3035
+
3036
+ for (let i = 0; i < eventNames.length; i++) {
3037
+ const eventName = eventNames[i];
3038
+ const falseEventName = eventName + FALSE_STR;
3039
+ const trueEventName = eventName + TRUE_STR;
3040
+ const symbol = ZONE_SYMBOL_PREFIX + falseEventName;
3041
+ const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
3042
+ zoneSymbolEventNames[eventName] = {};
3043
+ zoneSymbolEventNames[eventName][FALSE_STR] = symbol;
3044
+ zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture;
3045
+ }
3046
+
3047
+ const EVENT_TARGET = _global['EventTarget'];
3048
+
3049
+ if (!EVENT_TARGET || !EVENT_TARGET.prototype) {
3050
+ return;
3051
+ }
3052
+
3053
+ api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]);
3054
+ return true;
3055
+ }
3056
+
3057
+ function patchEvent(global, api) {
3058
+ api.patchEventPrototype(global, api);
3059
+ }
3060
+ /**
3061
+ * @license
3062
+ * Copyright Google LLC All Rights Reserved.
3063
+ *
3064
+ * Use of this source code is governed by an MIT-style license that can be
3065
+ * found in the LICENSE file at https://angular.io/license
3066
+ */
3067
+
3068
+
3069
+ Zone.__load_patch('legacy', global => {
3070
+ const legacyPatch = global[Zone.__symbol__('legacyPatch')];
3071
+
3072
+ if (legacyPatch) {
3073
+ legacyPatch();
3074
+ }
3075
+ });
3076
+
3077
+ Zone.__load_patch('queueMicrotask', (global, Zone, api) => {
3078
+ api.patchMethod(global, 'queueMicrotask', delegate => {
3079
+ return function (self, args) {
3080
+ Zone.current.scheduleMicroTask('queueMicrotask', args[0]);
3081
+ };
3082
+ });
3083
+ });
3084
+
3085
+ Zone.__load_patch('timers', global => {
3086
+ const set = 'set';
3087
+ const clear = 'clear';
3088
+ patchTimer(global, set, clear, 'Timeout');
3089
+ patchTimer(global, set, clear, 'Interval');
3090
+ patchTimer(global, set, clear, 'Immediate');
3091
+ });
3092
+
3093
+ Zone.__load_patch('requestAnimationFrame', global => {
3094
+ patchTimer(global, 'request', 'cancel', 'AnimationFrame');
3095
+ patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame');
3096
+ patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame');
3097
+ });
3098
+
3099
+ Zone.__load_patch('blocking', (global, Zone) => {
3100
+ const blockingMethods = ['alert', 'prompt', 'confirm'];
3101
+
3102
+ for (let i = 0; i < blockingMethods.length; i++) {
3103
+ const name = blockingMethods[i];
3104
+ patchMethod(global, name, (delegate, symbol, name) => {
3105
+ return function (s, args) {
3106
+ return Zone.current.run(delegate, global, args, name);
3107
+ };
3108
+ });
3109
+ }
3110
+ });
3111
+
3112
+ Zone.__load_patch('EventTarget', (global, Zone, api) => {
3113
+ patchEvent(global, api);
3114
+ eventTargetPatch(global, api); // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener
3115
+
3116
+ const XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget'];
3117
+
3118
+ if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) {
3119
+ api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]);
3120
+ }
3121
+ });
3122
+
3123
+ Zone.__load_patch('MutationObserver', (global, Zone, api) => {
3124
+ patchClass('MutationObserver');
3125
+ patchClass('WebKitMutationObserver');
3126
+ });
3127
+
3128
+ Zone.__load_patch('IntersectionObserver', (global, Zone, api) => {
3129
+ patchClass('IntersectionObserver');
3130
+ });
3131
+
3132
+ Zone.__load_patch('FileReader', (global, Zone, api) => {
3133
+ patchClass('FileReader');
3134
+ });
3135
+
3136
+ Zone.__load_patch('on_property', (global, Zone, api) => {
3137
+ propertyDescriptorPatch(api, global);
3138
+ });
3139
+
3140
+ Zone.__load_patch('customElements', (global, Zone, api) => {
3141
+ patchCustomElements(global, api);
3142
+ });
3143
+
3144
+ Zone.__load_patch('XHR', (global, Zone) => {
3145
+ // Treat XMLHttpRequest as a macrotask.
3146
+ patchXHR(global);
3147
+ const XHR_TASK = zoneSymbol('xhrTask');
3148
+ const XHR_SYNC = zoneSymbol('xhrSync');
3149
+ const XHR_LISTENER = zoneSymbol('xhrListener');
3150
+ const XHR_SCHEDULED = zoneSymbol('xhrScheduled');
3151
+ const XHR_URL = zoneSymbol('xhrURL');
3152
+ const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled');
3153
+
3154
+ function patchXHR(window) {
3155
+ const XMLHttpRequest = window['XMLHttpRequest'];
3156
+
3157
+ if (!XMLHttpRequest) {
3158
+ // XMLHttpRequest is not available in service worker
3159
+ return;
3160
+ }
3161
+
3162
+ const XMLHttpRequestPrototype = XMLHttpRequest.prototype;
3163
+
3164
+ function findPendingTask(target) {
3165
+ return target[XHR_TASK];
3166
+ }
3167
+
3168
+ let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER];
3169
+ let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
3170
+
3171
+ if (!oriAddListener) {
3172
+ const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget'];
3173
+
3174
+ if (XMLHttpRequestEventTarget) {
3175
+ const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype;
3176
+ oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER];
3177
+ oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
3178
+ }
3179
+ }
3180
+
3181
+ const READY_STATE_CHANGE = 'readystatechange';
3182
+ const SCHEDULED = 'scheduled';
3183
+
3184
+ function scheduleTask(task) {
3185
+ const data = task.data;
3186
+ const target = data.target;
3187
+ target[XHR_SCHEDULED] = false;
3188
+ target[XHR_ERROR_BEFORE_SCHEDULED] = false; // remove existing event listener
3189
+
3190
+ const listener = target[XHR_LISTENER];
3191
+
3192
+ if (!oriAddListener) {
3193
+ oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER];
3194
+ oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
3195
+ }
3196
+
3197
+ if (listener) {
3198
+ oriRemoveListener.call(target, READY_STATE_CHANGE, listener);
3199
+ }
3200
+
3201
+ const newListener = target[XHR_LISTENER] = () => {
3202
+ if (target.readyState === target.DONE) {
3203
+ // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with
3204
+ // readyState=4 multiple times, so we need to check task state here
3205
+ if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) {
3206
+ // check whether the xhr has registered onload listener
3207
+ // if that is the case, the task should invoke after all
3208
+ // onload listeners finish.
3209
+ // Also if the request failed without response (status = 0), the load event handler
3210
+ // will not be triggered, in that case, we should also invoke the placeholder callback
3211
+ // to close the XMLHttpRequest::send macroTask.
3212
+ // https://github.com/angular/angular/issues/38795
3213
+ const loadTasks = target[Zone.__symbol__('loadfalse')];
3214
+
3215
+ if (target.status !== 0 && loadTasks && loadTasks.length > 0) {
3216
+ const oriInvoke = task.invoke;
3217
+
3218
+ task.invoke = function () {
3219
+ // need to load the tasks again, because in other
3220
+ // load listener, they may remove themselves
3221
+ const loadTasks = target[Zone.__symbol__('loadfalse')];
3222
+
3223
+ for (let i = 0; i < loadTasks.length; i++) {
3224
+ if (loadTasks[i] === task) {
3225
+ loadTasks.splice(i, 1);
3226
+ }
3227
+ }
3228
+
3229
+ if (!data.aborted && task.state === SCHEDULED) {
3230
+ oriInvoke.call(task);
3231
+ }
3232
+ };
3233
+
3234
+ loadTasks.push(task);
3235
+ } else {
3236
+ task.invoke();
3237
+ }
3238
+ } else if (!data.aborted && target[XHR_SCHEDULED] === false) {
3239
+ // error occurs when xhr.send()
3240
+ target[XHR_ERROR_BEFORE_SCHEDULED] = true;
3241
+ }
3242
+ }
3243
+ };
3244
+
3245
+ oriAddListener.call(target, READY_STATE_CHANGE, newListener);
3246
+ const storedTask = target[XHR_TASK];
3247
+
3248
+ if (!storedTask) {
3249
+ target[XHR_TASK] = task;
3250
+ }
3251
+
3252
+ sendNative.apply(target, data.args);
3253
+ target[XHR_SCHEDULED] = true;
3254
+ return task;
3255
+ }
3256
+
3257
+ function placeholderCallback() {}
3258
+
3259
+ function clearTask(task) {
3260
+ const data = task.data; // Note - ideally, we would call data.target.removeEventListener here, but it's too late
3261
+ // to prevent it from firing. So instead, we store info for the event listener.
3262
+
3263
+ data.aborted = true;
3264
+ return abortNative.apply(data.target, data.args);
3265
+ }
3266
+
3267
+ const openNative = patchMethod(XMLHttpRequestPrototype, 'open', () => function (self, args) {
3268
+ self[XHR_SYNC] = args[2] == false;
3269
+ self[XHR_URL] = args[1];
3270
+ return openNative.apply(self, args);
3271
+ });
3272
+ const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send';
3273
+ const fetchTaskAborting = zoneSymbol('fetchTaskAborting');
3274
+ const fetchTaskScheduling = zoneSymbol('fetchTaskScheduling');
3275
+ const sendNative = patchMethod(XMLHttpRequestPrototype, 'send', () => function (self, args) {
3276
+ if (Zone.current[fetchTaskScheduling] === true) {
3277
+ // a fetch is scheduling, so we are using xhr to polyfill fetch
3278
+ // and because we already schedule macroTask for fetch, we should
3279
+ // not schedule a macroTask for xhr again
3280
+ return sendNative.apply(self, args);
3281
+ }
3282
+
3283
+ if (self[XHR_SYNC]) {
3284
+ // if the XHR is sync there is no task to schedule, just execute the code.
3285
+ return sendNative.apply(self, args);
3286
+ } else {
3287
+ const options = {
3288
+ target: self,
3289
+ url: self[XHR_URL],
3290
+ isPeriodic: false,
3291
+ args: args,
3292
+ aborted: false
3293
+ };
3294
+ const task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask);
3295
+
3296
+ if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && task.state === SCHEDULED) {
3297
+ // xhr request throw error when send
3298
+ // we should invoke task instead of leaving a scheduled
3299
+ // pending macroTask
3300
+ task.invoke();
3301
+ }
3302
+ }
3303
+ });
3304
+ const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function (self, args) {
3305
+ const task = findPendingTask(self);
3306
+
3307
+ if (task && typeof task.type == 'string') {
3308
+ // If the XHR has already completed, do nothing.
3309
+ // If the XHR has already been aborted, do nothing.
3310
+ // Fix #569, call abort multiple times before done will cause
3311
+ // macroTask task count be negative number
3312
+ if (task.cancelFn == null || task.data && task.data.aborted) {
3313
+ return;
3314
+ }
3315
+
3316
+ task.zone.cancelTask(task);
3317
+ } else if (Zone.current[fetchTaskAborting] === true) {
3318
+ // the abort is called from fetch polyfill, we need to call native abort of XHR.
3319
+ return abortNative.apply(self, args);
3320
+ } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no
3321
+ // task
3322
+ // to cancel. Do nothing.
3323
+
3324
+ });
3325
+ }
3326
+ });
3327
+
3328
+ Zone.__load_patch('geolocation', global => {
3329
+ /// GEO_LOCATION
3330
+ if (global['navigator'] && global['navigator'].geolocation) {
3331
+ patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']);
3332
+ }
3333
+ });
3334
+
3335
+ Zone.__load_patch('PromiseRejectionEvent', (global, Zone) => {
3336
+ // handle unhandled promise rejection
3337
+ function findPromiseRejectionHandler(evtName) {
3338
+ return function (e) {
3339
+ const eventTasks = findEventTasks(global, evtName);
3340
+ eventTasks.forEach(eventTask => {
3341
+ // windows has added unhandledrejection event listener
3342
+ // trigger the event listener
3343
+ const PromiseRejectionEvent = global['PromiseRejectionEvent'];
3344
+
3345
+ if (PromiseRejectionEvent) {
3346
+ const evt = new PromiseRejectionEvent(evtName, {
3347
+ promise: e.promise,
3348
+ reason: e.rejection
3349
+ });
3350
+ eventTask.invoke(evt);
3351
+ }
3352
+ });
3353
+ };
3354
+ }
3355
+
3356
+ if (global['PromiseRejectionEvent']) {
3357
+ Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = findPromiseRejectionHandler('unhandledrejection');
3358
+ Zone[zoneSymbol('rejectionHandledHandler')] = findPromiseRejectionHandler('rejectionhandled');
3359
+ }
3360
+ });
3361
+
3362
+ /***/ })
3363
+
3364
+ },
3365
+ /******/ __webpack_require__ => { // webpackRuntimeModules
3366
+ /******/ var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
3367
+ /******/ var __webpack_exports__ = (__webpack_exec__(7435));
3368
+ /******/ }
3369
+ ]);
3370
+ //# sourceMappingURL=polyfills.js.map