cedar-embeddable-editor 0.9.2 → 0.9.4

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