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