ngxsmk-datepicker 1.4.6 → 1.4.7

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.
@@ -1,2394 +0,0 @@
1
- import {
2
- __spreadProps,
3
- __spreadValues
4
- } from "./chunk-WDMUDEB6.js";
5
-
6
- // node_modules/zone.js/fesm2015/zone.js
7
- var global = globalThis;
8
- function __symbol__(name) {
9
- const symbolPrefix = global["__Zone_symbol_prefix"] || "__zone_symbol__";
10
- return symbolPrefix + name;
11
- }
12
- function initZone() {
13
- const performance = global["performance"];
14
- function mark(name) {
15
- performance && performance["mark"] && performance["mark"](name);
16
- }
17
- function performanceMeasure(name, label) {
18
- performance && performance["measure"] && performance["measure"](name, label);
19
- }
20
- mark("Zone");
21
- class ZoneImpl {
22
- static __symbol__ = __symbol__;
23
- static assertZonePatched() {
24
- if (global["Promise"] !== patches["ZoneAwarePromise"]) {
25
- throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost 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.)");
26
- }
27
- }
28
- static get root() {
29
- let zone = ZoneImpl.current;
30
- while (zone.parent) {
31
- zone = zone.parent;
32
- }
33
- return zone;
34
- }
35
- static get current() {
36
- return _currentZoneFrame.zone;
37
- }
38
- static get currentTask() {
39
- return _currentTask;
40
- }
41
- static __load_patch(name, fn, ignoreDuplicate = false) {
42
- if (patches.hasOwnProperty(name)) {
43
- const checkDuplicate = global[__symbol__("forceDuplicateZoneCheck")] === true;
44
- if (!ignoreDuplicate && checkDuplicate) {
45
- throw Error("Already loaded patch: " + name);
46
- }
47
- } else if (!global["__Zone_disable_" + name]) {
48
- const perfName = "Zone:" + name;
49
- mark(perfName);
50
- patches[name] = fn(global, ZoneImpl, _api);
51
- performanceMeasure(perfName, perfName);
52
- }
53
- }
54
- get parent() {
55
- return this._parent;
56
- }
57
- get name() {
58
- return this._name;
59
- }
60
- _parent;
61
- _name;
62
- _properties;
63
- _zoneDelegate;
64
- constructor(parent, zoneSpec) {
65
- this._parent = parent;
66
- this._name = zoneSpec ? zoneSpec.name || "unnamed" : "<root>";
67
- this._properties = zoneSpec && zoneSpec.properties || {};
68
- this._zoneDelegate = new _ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
69
- }
70
- get(key) {
71
- const zone = this.getZoneWith(key);
72
- if (zone)
73
- return zone._properties[key];
74
- }
75
- getZoneWith(key) {
76
- let current = this;
77
- while (current) {
78
- if (current._properties.hasOwnProperty(key)) {
79
- return current;
80
- }
81
- current = current._parent;
82
- }
83
- return null;
84
- }
85
- fork(zoneSpec) {
86
- if (!zoneSpec)
87
- throw new Error("ZoneSpec required!");
88
- return this._zoneDelegate.fork(this, zoneSpec);
89
- }
90
- wrap(callback, source) {
91
- if (typeof callback !== "function") {
92
- throw new Error("Expecting function got: " + callback);
93
- }
94
- const _callback = this._zoneDelegate.intercept(this, callback, source);
95
- const zone = this;
96
- return function() {
97
- return zone.runGuarded(_callback, this, arguments, source);
98
- };
99
- }
100
- run(callback, applyThis, applyArgs, source) {
101
- _currentZoneFrame = { parent: _currentZoneFrame, zone: this };
102
- try {
103
- return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source);
104
- } finally {
105
- _currentZoneFrame = _currentZoneFrame.parent;
106
- }
107
- }
108
- runGuarded(callback, applyThis = null, applyArgs, source) {
109
- _currentZoneFrame = { parent: _currentZoneFrame, zone: this };
110
- try {
111
- try {
112
- return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source);
113
- } catch (error) {
114
- if (this._zoneDelegate.handleError(this, error)) {
115
- throw error;
116
- }
117
- }
118
- } finally {
119
- _currentZoneFrame = _currentZoneFrame.parent;
120
- }
121
- }
122
- runTask(task, applyThis, applyArgs) {
123
- if (task.zone != this) {
124
- throw new Error("A task can only be run in the zone of creation! (Creation: " + (task.zone || NO_ZONE).name + "; Execution: " + this.name + ")");
125
- }
126
- const zoneTask = task;
127
- const { type, data: { isPeriodic = false, isRefreshable = false } = {} } = task;
128
- if (task.state === notScheduled && (type === eventTask || type === macroTask)) {
129
- return;
130
- }
131
- const reEntryGuard = task.state != running;
132
- reEntryGuard && zoneTask._transitionTo(running, scheduled);
133
- const previousTask = _currentTask;
134
- _currentTask = zoneTask;
135
- _currentZoneFrame = { parent: _currentZoneFrame, zone: this };
136
- try {
137
- if (type == macroTask && task.data && !isPeriodic && !isRefreshable) {
138
- task.cancelFn = void 0;
139
- }
140
- try {
141
- return this._zoneDelegate.invokeTask(this, zoneTask, applyThis, applyArgs);
142
- } catch (error) {
143
- if (this._zoneDelegate.handleError(this, error)) {
144
- throw error;
145
- }
146
- }
147
- } finally {
148
- const state = task.state;
149
- if (state !== notScheduled && state !== unknown) {
150
- if (type == eventTask || isPeriodic || isRefreshable && state === scheduling) {
151
- reEntryGuard && zoneTask._transitionTo(scheduled, running, scheduling);
152
- } else {
153
- const zoneDelegates = zoneTask._zoneDelegates;
154
- this._updateTaskCount(zoneTask, -1);
155
- reEntryGuard && zoneTask._transitionTo(notScheduled, running, notScheduled);
156
- if (isRefreshable) {
157
- zoneTask._zoneDelegates = zoneDelegates;
158
- }
159
- }
160
- }
161
- _currentZoneFrame = _currentZoneFrame.parent;
162
- _currentTask = previousTask;
163
- }
164
- }
165
- scheduleTask(task) {
166
- if (task.zone && task.zone !== this) {
167
- let newZone = this;
168
- while (newZone) {
169
- if (newZone === task.zone) {
170
- throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${task.zone.name}`);
171
- }
172
- newZone = newZone.parent;
173
- }
174
- }
175
- task._transitionTo(scheduling, notScheduled);
176
- const zoneDelegates = [];
177
- task._zoneDelegates = zoneDelegates;
178
- task._zone = this;
179
- try {
180
- task = this._zoneDelegate.scheduleTask(this, task);
181
- } catch (err) {
182
- task._transitionTo(unknown, scheduling, notScheduled);
183
- this._zoneDelegate.handleError(this, err);
184
- throw err;
185
- }
186
- if (task._zoneDelegates === zoneDelegates) {
187
- this._updateTaskCount(task, 1);
188
- }
189
- if (task.state == scheduling) {
190
- task._transitionTo(scheduled, scheduling);
191
- }
192
- return task;
193
- }
194
- scheduleMicroTask(source, callback, data, customSchedule) {
195
- return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, void 0));
196
- }
197
- scheduleMacroTask(source, callback, data, customSchedule, customCancel) {
198
- return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel));
199
- }
200
- scheduleEventTask(source, callback, data, customSchedule, customCancel) {
201
- return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel));
202
- }
203
- cancelTask(task) {
204
- if (task.zone != this)
205
- throw new Error("A task can only be cancelled in the zone of creation! (Creation: " + (task.zone || NO_ZONE).name + "; Execution: " + this.name + ")");
206
- if (task.state !== scheduled && task.state !== running) {
207
- return;
208
- }
209
- task._transitionTo(canceling, scheduled, running);
210
- try {
211
- this._zoneDelegate.cancelTask(this, task);
212
- } catch (err) {
213
- task._transitionTo(unknown, canceling);
214
- this._zoneDelegate.handleError(this, err);
215
- throw err;
216
- }
217
- this._updateTaskCount(task, -1);
218
- task._transitionTo(notScheduled, canceling);
219
- task.runCount = -1;
220
- return task;
221
- }
222
- _updateTaskCount(task, count) {
223
- const zoneDelegates = task._zoneDelegates;
224
- if (count == -1) {
225
- task._zoneDelegates = null;
226
- }
227
- for (let i = 0; i < zoneDelegates.length; i++) {
228
- zoneDelegates[i]._updateTaskCount(task.type, count);
229
- }
230
- }
231
- }
232
- const DELEGATE_ZS = {
233
- name: "",
234
- onHasTask: (delegate, _, target, hasTaskState) => delegate.hasTask(target, hasTaskState),
235
- onScheduleTask: (delegate, _, target, task) => delegate.scheduleTask(target, task),
236
- onInvokeTask: (delegate, _, target, task, applyThis, applyArgs) => delegate.invokeTask(target, task, applyThis, applyArgs),
237
- onCancelTask: (delegate, _, target, task) => delegate.cancelTask(target, task)
238
- };
239
- class _ZoneDelegate {
240
- get zone() {
241
- return this._zone;
242
- }
243
- _zone;
244
- _taskCounts = {
245
- "microTask": 0,
246
- "macroTask": 0,
247
- "eventTask": 0
248
- };
249
- _parentDelegate;
250
- _forkDlgt;
251
- _forkZS;
252
- _forkCurrZone;
253
- _interceptDlgt;
254
- _interceptZS;
255
- _interceptCurrZone;
256
- _invokeDlgt;
257
- _invokeZS;
258
- _invokeCurrZone;
259
- _handleErrorDlgt;
260
- _handleErrorZS;
261
- _handleErrorCurrZone;
262
- _scheduleTaskDlgt;
263
- _scheduleTaskZS;
264
- _scheduleTaskCurrZone;
265
- _invokeTaskDlgt;
266
- _invokeTaskZS;
267
- _invokeTaskCurrZone;
268
- _cancelTaskDlgt;
269
- _cancelTaskZS;
270
- _cancelTaskCurrZone;
271
- _hasTaskDlgt;
272
- _hasTaskDlgtOwner;
273
- _hasTaskZS;
274
- _hasTaskCurrZone;
275
- constructor(zone, parentDelegate, zoneSpec) {
276
- this._zone = zone;
277
- this._parentDelegate = parentDelegate;
278
- this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS);
279
- this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt);
280
- this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this._zone : parentDelegate._forkCurrZone);
281
- this._interceptZS = zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS);
282
- this._interceptDlgt = zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt);
283
- this._interceptCurrZone = zoneSpec && (zoneSpec.onIntercept ? this._zone : parentDelegate._interceptCurrZone);
284
- this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS);
285
- this._invokeDlgt = zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt);
286
- this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this._zone : parentDelegate._invokeCurrZone);
287
- this._handleErrorZS = zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS);
288
- this._handleErrorDlgt = zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt);
289
- this._handleErrorCurrZone = zoneSpec && (zoneSpec.onHandleError ? this._zone : parentDelegate._handleErrorCurrZone);
290
- this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS);
291
- this._scheduleTaskDlgt = zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt);
292
- this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this._zone : parentDelegate._scheduleTaskCurrZone);
293
- this._invokeTaskZS = zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS);
294
- this._invokeTaskDlgt = zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt);
295
- this._invokeTaskCurrZone = zoneSpec && (zoneSpec.onInvokeTask ? this._zone : parentDelegate._invokeTaskCurrZone);
296
- this._cancelTaskZS = zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS);
297
- this._cancelTaskDlgt = zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt);
298
- this._cancelTaskCurrZone = zoneSpec && (zoneSpec.onCancelTask ? this._zone : parentDelegate._cancelTaskCurrZone);
299
- this._hasTaskZS = null;
300
- this._hasTaskDlgt = null;
301
- this._hasTaskDlgtOwner = null;
302
- this._hasTaskCurrZone = null;
303
- const zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask;
304
- const parentHasTask = parentDelegate && parentDelegate._hasTaskZS;
305
- if (zoneSpecHasTask || parentHasTask) {
306
- this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS;
307
- this._hasTaskDlgt = parentDelegate;
308
- this._hasTaskDlgtOwner = this;
309
- this._hasTaskCurrZone = this._zone;
310
- if (!zoneSpec.onScheduleTask) {
311
- this._scheduleTaskZS = DELEGATE_ZS;
312
- this._scheduleTaskDlgt = parentDelegate;
313
- this._scheduleTaskCurrZone = this._zone;
314
- }
315
- if (!zoneSpec.onInvokeTask) {
316
- this._invokeTaskZS = DELEGATE_ZS;
317
- this._invokeTaskDlgt = parentDelegate;
318
- this._invokeTaskCurrZone = this._zone;
319
- }
320
- if (!zoneSpec.onCancelTask) {
321
- this._cancelTaskZS = DELEGATE_ZS;
322
- this._cancelTaskDlgt = parentDelegate;
323
- this._cancelTaskCurrZone = this._zone;
324
- }
325
- }
326
- }
327
- fork(targetZone, zoneSpec) {
328
- return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : new ZoneImpl(targetZone, zoneSpec);
329
- }
330
- intercept(targetZone, callback, source) {
331
- return this._interceptZS ? this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : callback;
332
- }
333
- invoke(targetZone, callback, applyThis, applyArgs, source) {
334
- return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs);
335
- }
336
- handleError(targetZone, error) {
337
- return this._handleErrorZS ? this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : true;
338
- }
339
- scheduleTask(targetZone, task) {
340
- let returnTask = task;
341
- if (this._scheduleTaskZS) {
342
- if (this._hasTaskZS) {
343
- returnTask._zoneDelegates.push(this._hasTaskDlgtOwner);
344
- }
345
- returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task);
346
- if (!returnTask)
347
- returnTask = task;
348
- } else {
349
- if (task.scheduleFn) {
350
- task.scheduleFn(task);
351
- } else if (task.type == microTask) {
352
- scheduleMicroTask(task);
353
- } else {
354
- throw new Error("Task is missing scheduleFn.");
355
- }
356
- }
357
- return returnTask;
358
- }
359
- invokeTask(targetZone, task, applyThis, applyArgs) {
360
- return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs);
361
- }
362
- cancelTask(targetZone, task) {
363
- let value;
364
- if (this._cancelTaskZS) {
365
- value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task);
366
- } else {
367
- if (!task.cancelFn) {
368
- throw Error("Task is not cancelable");
369
- }
370
- value = task.cancelFn(task);
371
- }
372
- return value;
373
- }
374
- hasTask(targetZone, isEmpty) {
375
- try {
376
- this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty);
377
- } catch (err) {
378
- this.handleError(targetZone, err);
379
- }
380
- }
381
- _updateTaskCount(type, count) {
382
- const counts = this._taskCounts;
383
- const prev = counts[type];
384
- const next = counts[type] = prev + count;
385
- if (next < 0) {
386
- throw new Error("More tasks executed then were scheduled.");
387
- }
388
- if (prev == 0 || next == 0) {
389
- const isEmpty = {
390
- microTask: counts["microTask"] > 0,
391
- macroTask: counts["macroTask"] > 0,
392
- eventTask: counts["eventTask"] > 0,
393
- change: type
394
- };
395
- this.hasTask(this._zone, isEmpty);
396
- }
397
- }
398
- }
399
- class ZoneTask {
400
- type;
401
- source;
402
- invoke;
403
- callback;
404
- data;
405
- scheduleFn;
406
- cancelFn;
407
- _zone = null;
408
- runCount = 0;
409
- _zoneDelegates = null;
410
- _state = "notScheduled";
411
- constructor(type, source, callback, options, scheduleFn, cancelFn) {
412
- this.type = type;
413
- this.source = source;
414
- this.data = options;
415
- this.scheduleFn = scheduleFn;
416
- this.cancelFn = cancelFn;
417
- if (!callback) {
418
- throw new Error("callback is not defined");
419
- }
420
- this.callback = callback;
421
- const self2 = this;
422
- if (type === eventTask && options && options.useG) {
423
- this.invoke = ZoneTask.invokeTask;
424
- } else {
425
- this.invoke = function() {
426
- return ZoneTask.invokeTask.call(global, self2, this, arguments);
427
- };
428
- }
429
- }
430
- static invokeTask(task, target, args) {
431
- if (!task) {
432
- task = this;
433
- }
434
- _numberOfNestedTaskFrames++;
435
- try {
436
- task.runCount++;
437
- return task.zone.runTask(task, target, args);
438
- } finally {
439
- if (_numberOfNestedTaskFrames == 1) {
440
- drainMicroTaskQueue();
441
- }
442
- _numberOfNestedTaskFrames--;
443
- }
444
- }
445
- get zone() {
446
- return this._zone;
447
- }
448
- get state() {
449
- return this._state;
450
- }
451
- cancelScheduleRequest() {
452
- this._transitionTo(notScheduled, scheduling);
453
- }
454
- _transitionTo(toState, fromState1, fromState2) {
455
- if (this._state === fromState1 || this._state === fromState2) {
456
- this._state = toState;
457
- if (toState == notScheduled) {
458
- this._zoneDelegates = null;
459
- }
460
- } else {
461
- throw new Error(`${this.type} '${this.source}': can not transition to '${toState}', expecting state '${fromState1}'${fromState2 ? " or '" + fromState2 + "'" : ""}, was '${this._state}'.`);
462
- }
463
- }
464
- toString() {
465
- if (this.data && typeof this.data.handleId !== "undefined") {
466
- return this.data.handleId.toString();
467
- } else {
468
- return Object.prototype.toString.call(this);
469
- }
470
- }
471
- // add toJSON method to prevent cyclic error when
472
- // call JSON.stringify(zoneTask)
473
- toJSON() {
474
- return {
475
- type: this.type,
476
- state: this.state,
477
- source: this.source,
478
- zone: this.zone.name,
479
- runCount: this.runCount
480
- };
481
- }
482
- }
483
- const symbolSetTimeout = __symbol__("setTimeout");
484
- const symbolPromise = __symbol__("Promise");
485
- const symbolThen = __symbol__("then");
486
- let _microTaskQueue = [];
487
- let _isDrainingMicrotaskQueue = false;
488
- let nativeMicroTaskQueuePromise;
489
- function nativeScheduleMicroTask(func) {
490
- if (!nativeMicroTaskQueuePromise) {
491
- if (global[symbolPromise]) {
492
- nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0);
493
- }
494
- }
495
- if (nativeMicroTaskQueuePromise) {
496
- let nativeThen = nativeMicroTaskQueuePromise[symbolThen];
497
- if (!nativeThen) {
498
- nativeThen = nativeMicroTaskQueuePromise["then"];
499
- }
500
- nativeThen.call(nativeMicroTaskQueuePromise, func);
501
- } else {
502
- global[symbolSetTimeout](func, 0);
503
- }
504
- }
505
- function scheduleMicroTask(task) {
506
- if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) {
507
- nativeScheduleMicroTask(drainMicroTaskQueue);
508
- }
509
- task && _microTaskQueue.push(task);
510
- }
511
- function drainMicroTaskQueue() {
512
- if (!_isDrainingMicrotaskQueue) {
513
- _isDrainingMicrotaskQueue = true;
514
- while (_microTaskQueue.length) {
515
- const queue = _microTaskQueue;
516
- _microTaskQueue = [];
517
- for (let i = 0; i < queue.length; i++) {
518
- const task = queue[i];
519
- try {
520
- task.zone.runTask(task, null, null);
521
- } catch (error) {
522
- _api.onUnhandledError(error);
523
- }
524
- }
525
- }
526
- _api.microtaskDrainDone();
527
- _isDrainingMicrotaskQueue = false;
528
- }
529
- }
530
- const NO_ZONE = { name: "NO ZONE" };
531
- const notScheduled = "notScheduled", scheduling = "scheduling", scheduled = "scheduled", running = "running", canceling = "canceling", unknown = "unknown";
532
- const microTask = "microTask", macroTask = "macroTask", eventTask = "eventTask";
533
- const patches = {};
534
- const _api = {
535
- symbol: __symbol__,
536
- currentZoneFrame: () => _currentZoneFrame,
537
- onUnhandledError: noop,
538
- microtaskDrainDone: noop,
539
- scheduleMicroTask,
540
- showUncaughtError: () => !ZoneImpl[__symbol__("ignoreConsoleErrorUncaughtError")],
541
- patchEventTarget: () => [],
542
- patchOnProperties: noop,
543
- patchMethod: () => noop,
544
- bindArguments: () => [],
545
- patchThen: () => noop,
546
- patchMacroTask: () => noop,
547
- patchEventPrototype: () => noop,
548
- isIEOrEdge: () => false,
549
- getGlobalObjects: () => void 0,
550
- ObjectDefineProperty: () => noop,
551
- ObjectGetOwnPropertyDescriptor: () => void 0,
552
- ObjectCreate: () => void 0,
553
- ArraySlice: () => [],
554
- patchClass: () => noop,
555
- wrapWithCurrentZone: () => noop,
556
- filterProperties: () => [],
557
- attachOriginToPatched: () => noop,
558
- _redefineProperty: () => noop,
559
- patchCallbacks: () => noop,
560
- nativeScheduleMicroTask
561
- };
562
- let _currentZoneFrame = { parent: null, zone: new ZoneImpl(null, null) };
563
- let _currentTask = null;
564
- let _numberOfNestedTaskFrames = 0;
565
- function noop() {
566
- }
567
- performanceMeasure("Zone", "Zone");
568
- return ZoneImpl;
569
- }
570
- function loadZone() {
571
- const global2 = globalThis;
572
- const checkDuplicate = global2[__symbol__("forceDuplicateZoneCheck")] === true;
573
- if (global2["Zone"] && (checkDuplicate || typeof global2["Zone"].__symbol__ !== "function")) {
574
- throw new Error("Zone already loaded.");
575
- }
576
- global2["Zone"] ??= initZone();
577
- return global2["Zone"];
578
- }
579
- var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
580
- var ObjectDefineProperty = Object.defineProperty;
581
- var ObjectGetPrototypeOf = Object.getPrototypeOf;
582
- var ObjectCreate = Object.create;
583
- var ArraySlice = Array.prototype.slice;
584
- var ADD_EVENT_LISTENER_STR = "addEventListener";
585
- var REMOVE_EVENT_LISTENER_STR = "removeEventListener";
586
- var ZONE_SYMBOL_ADD_EVENT_LISTENER = __symbol__(ADD_EVENT_LISTENER_STR);
587
- var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = __symbol__(REMOVE_EVENT_LISTENER_STR);
588
- var TRUE_STR = "true";
589
- var FALSE_STR = "false";
590
- var ZONE_SYMBOL_PREFIX = __symbol__("");
591
- function wrapWithCurrentZone(callback, source) {
592
- return Zone.current.wrap(callback, source);
593
- }
594
- function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) {
595
- return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel);
596
- }
597
- var zoneSymbol = __symbol__;
598
- var isWindowExists = typeof window !== "undefined";
599
- var internalWindow = isWindowExists ? window : void 0;
600
- var _global = isWindowExists && internalWindow || globalThis;
601
- var REMOVE_ATTRIBUTE = "removeAttribute";
602
- function bindArguments(args, source) {
603
- for (let i = args.length - 1; i >= 0; i--) {
604
- if (typeof args[i] === "function") {
605
- args[i] = wrapWithCurrentZone(args[i], source + "_" + i);
606
- }
607
- }
608
- return args;
609
- }
610
- function patchPrototype(prototype, fnNames) {
611
- const source = prototype.constructor["name"];
612
- for (let i = 0; i < fnNames.length; i++) {
613
- const name = fnNames[i];
614
- const delegate = prototype[name];
615
- if (delegate) {
616
- const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name);
617
- if (!isPropertyWritable(prototypeDesc)) {
618
- continue;
619
- }
620
- prototype[name] = ((delegate2) => {
621
- const patched = function() {
622
- return delegate2.apply(this, bindArguments(arguments, source + "." + name));
623
- };
624
- attachOriginToPatched(patched, delegate2);
625
- return patched;
626
- })(delegate);
627
- }
628
- }
629
- }
630
- function isPropertyWritable(propertyDesc) {
631
- if (!propertyDesc) {
632
- return true;
633
- }
634
- if (propertyDesc.writable === false) {
635
- return false;
636
- }
637
- return !(typeof propertyDesc.get === "function" && typeof propertyDesc.set === "undefined");
638
- }
639
- var isWebWorker = typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
640
- var isNode = !("nw" in _global) && typeof _global.process !== "undefined" && _global.process.toString() === "[object process]";
641
- var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow["HTMLElement"]);
642
- var isMix = typeof _global.process !== "undefined" && _global.process.toString() === "[object process]" && !isWebWorker && !!(isWindowExists && internalWindow["HTMLElement"]);
643
- var zoneSymbolEventNames$1 = {};
644
- var enableBeforeunloadSymbol = zoneSymbol("enable_beforeunload");
645
- var wrapFn = function(event) {
646
- event = event || _global.event;
647
- if (!event) {
648
- return;
649
- }
650
- let eventNameSymbol = zoneSymbolEventNames$1[event.type];
651
- if (!eventNameSymbol) {
652
- eventNameSymbol = zoneSymbolEventNames$1[event.type] = zoneSymbol("ON_PROPERTY" + event.type);
653
- }
654
- const target = this || event.target || _global;
655
- const listener = target[eventNameSymbol];
656
- let result;
657
- if (isBrowser && target === internalWindow && event.type === "error") {
658
- const errorEvent = event;
659
- result = listener && listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error);
660
- if (result === true) {
661
- event.preventDefault();
662
- }
663
- } else {
664
- result = listener && listener.apply(this, arguments);
665
- if (
666
- // https://github.com/angular/angular/issues/47579
667
- // https://www.w3.org/TR/2011/WD-html5-20110525/history.html#beforeunloadevent
668
- // This is the only specific case we should check for. The spec defines that the
669
- // `returnValue` attribute represents the message to show the user. When the event
670
- // is created, this attribute must be set to the empty string.
671
- event.type === "beforeunload" && // To prevent any breaking changes resulting from this change, given that
672
- // it was already causing a significant number of failures in G3, we have hidden
673
- // that behavior behind a global configuration flag. Consumers can enable this
674
- // flag explicitly if they want the `beforeunload` event to be handled as defined
675
- // in the specification.
676
- _global[enableBeforeunloadSymbol] && // The IDL event definition is `attribute DOMString returnValue`, so we check whether
677
- // `typeof result` is a string.
678
- typeof result === "string"
679
- ) {
680
- event.returnValue = result;
681
- } else if (result != void 0 && !result) {
682
- event.preventDefault();
683
- }
684
- }
685
- return result;
686
- };
687
- function patchProperty(obj, prop, prototype) {
688
- let desc = ObjectGetOwnPropertyDescriptor(obj, prop);
689
- if (!desc && prototype) {
690
- const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop);
691
- if (prototypeDesc) {
692
- desc = { enumerable: true, configurable: true };
693
- }
694
- }
695
- if (!desc || !desc.configurable) {
696
- return;
697
- }
698
- const onPropPatchedSymbol = zoneSymbol("on" + prop + "patched");
699
- if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) {
700
- return;
701
- }
702
- delete desc.writable;
703
- delete desc.value;
704
- const originalDescGet = desc.get;
705
- const originalDescSet = desc.set;
706
- const eventName = prop.slice(2);
707
- let eventNameSymbol = zoneSymbolEventNames$1[eventName];
708
- if (!eventNameSymbol) {
709
- eventNameSymbol = zoneSymbolEventNames$1[eventName] = zoneSymbol("ON_PROPERTY" + eventName);
710
- }
711
- desc.set = function(newValue) {
712
- let target = this;
713
- if (!target && obj === _global) {
714
- target = _global;
715
- }
716
- if (!target) {
717
- return;
718
- }
719
- const previousValue = target[eventNameSymbol];
720
- if (typeof previousValue === "function") {
721
- target.removeEventListener(eventName, wrapFn);
722
- }
723
- originalDescSet?.call(target, null);
724
- target[eventNameSymbol] = newValue;
725
- if (typeof newValue === "function") {
726
- target.addEventListener(eventName, wrapFn, false);
727
- }
728
- };
729
- desc.get = function() {
730
- let target = this;
731
- if (!target && obj === _global) {
732
- target = _global;
733
- }
734
- if (!target) {
735
- return null;
736
- }
737
- const listener = target[eventNameSymbol];
738
- if (listener) {
739
- return listener;
740
- } else if (originalDescGet) {
741
- let value = originalDescGet.call(this);
742
- if (value) {
743
- desc.set.call(this, value);
744
- if (typeof target[REMOVE_ATTRIBUTE] === "function") {
745
- target.removeAttribute(prop);
746
- }
747
- return value;
748
- }
749
- }
750
- return null;
751
- };
752
- ObjectDefineProperty(obj, prop, desc);
753
- obj[onPropPatchedSymbol] = true;
754
- }
755
- function patchOnProperties(obj, properties, prototype) {
756
- if (properties) {
757
- for (let i = 0; i < properties.length; i++) {
758
- patchProperty(obj, "on" + properties[i], prototype);
759
- }
760
- } else {
761
- const onProperties = [];
762
- for (const prop in obj) {
763
- if (prop.slice(0, 2) == "on") {
764
- onProperties.push(prop);
765
- }
766
- }
767
- for (let j = 0; j < onProperties.length; j++) {
768
- patchProperty(obj, onProperties[j], prototype);
769
- }
770
- }
771
- }
772
- var originalInstanceKey = zoneSymbol("originalInstance");
773
- function patchClass(className) {
774
- const OriginalClass = _global[className];
775
- if (!OriginalClass)
776
- return;
777
- _global[zoneSymbol(className)] = OriginalClass;
778
- _global[className] = function() {
779
- const a = bindArguments(arguments, className);
780
- switch (a.length) {
781
- case 0:
782
- this[originalInstanceKey] = new OriginalClass();
783
- break;
784
- case 1:
785
- this[originalInstanceKey] = new OriginalClass(a[0]);
786
- break;
787
- case 2:
788
- this[originalInstanceKey] = new OriginalClass(a[0], a[1]);
789
- break;
790
- case 3:
791
- this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]);
792
- break;
793
- case 4:
794
- this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]);
795
- break;
796
- default:
797
- throw new Error("Arg list too long.");
798
- }
799
- };
800
- attachOriginToPatched(_global[className], OriginalClass);
801
- const instance = new OriginalClass(function() {
802
- });
803
- let prop;
804
- for (prop in instance) {
805
- if (className === "XMLHttpRequest" && prop === "responseBlob")
806
- continue;
807
- (function(prop2) {
808
- if (typeof instance[prop2] === "function") {
809
- _global[className].prototype[prop2] = function() {
810
- return this[originalInstanceKey][prop2].apply(this[originalInstanceKey], arguments);
811
- };
812
- } else {
813
- ObjectDefineProperty(_global[className].prototype, prop2, {
814
- set: function(fn) {
815
- if (typeof fn === "function") {
816
- this[originalInstanceKey][prop2] = wrapWithCurrentZone(fn, className + "." + prop2);
817
- attachOriginToPatched(this[originalInstanceKey][prop2], fn);
818
- } else {
819
- this[originalInstanceKey][prop2] = fn;
820
- }
821
- },
822
- get: function() {
823
- return this[originalInstanceKey][prop2];
824
- }
825
- });
826
- }
827
- })(prop);
828
- }
829
- for (prop in OriginalClass) {
830
- if (prop !== "prototype" && OriginalClass.hasOwnProperty(prop)) {
831
- _global[className][prop] = OriginalClass[prop];
832
- }
833
- }
834
- }
835
- function patchMethod(target, name, patchFn) {
836
- let proto = target;
837
- while (proto && !proto.hasOwnProperty(name)) {
838
- proto = ObjectGetPrototypeOf(proto);
839
- }
840
- if (!proto && target[name]) {
841
- proto = target;
842
- }
843
- const delegateName = zoneSymbol(name);
844
- let delegate = null;
845
- if (proto && (!(delegate = proto[delegateName]) || !proto.hasOwnProperty(delegateName))) {
846
- delegate = proto[delegateName] = proto[name];
847
- const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name);
848
- if (isPropertyWritable(desc)) {
849
- const patchDelegate = patchFn(delegate, delegateName, name);
850
- proto[name] = function() {
851
- return patchDelegate(this, arguments);
852
- };
853
- attachOriginToPatched(proto[name], delegate);
854
- }
855
- }
856
- return delegate;
857
- }
858
- function patchMacroTask(obj, funcName, metaCreator) {
859
- let setNative = null;
860
- function scheduleTask(task) {
861
- const data = task.data;
862
- data.args[data.cbIdx] = function() {
863
- task.invoke.apply(this, arguments);
864
- };
865
- setNative.apply(data.target, data.args);
866
- return task;
867
- }
868
- setNative = patchMethod(obj, funcName, (delegate) => function(self2, args) {
869
- const meta = metaCreator(self2, args);
870
- if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === "function") {
871
- return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask);
872
- } else {
873
- return delegate.apply(self2, args);
874
- }
875
- });
876
- }
877
- function attachOriginToPatched(patched, original) {
878
- patched[zoneSymbol("OriginalDelegate")] = original;
879
- }
880
- var isDetectedIEOrEdge = false;
881
- var ieOrEdge = false;
882
- function isIEOrEdge() {
883
- if (isDetectedIEOrEdge) {
884
- return ieOrEdge;
885
- }
886
- isDetectedIEOrEdge = true;
887
- try {
888
- const ua = internalWindow.navigator.userAgent;
889
- if (ua.indexOf("MSIE ") !== -1 || ua.indexOf("Trident/") !== -1 || ua.indexOf("Edge/") !== -1) {
890
- ieOrEdge = true;
891
- }
892
- } catch (error) {
893
- }
894
- return ieOrEdge;
895
- }
896
- function isFunction(value) {
897
- return typeof value === "function";
898
- }
899
- function isNumber(value) {
900
- return typeof value === "number";
901
- }
902
- var OPTIMIZED_ZONE_EVENT_TASK_DATA = {
903
- useG: true
904
- };
905
- var zoneSymbolEventNames = {};
906
- var globalSources = {};
907
- var EVENT_NAME_SYMBOL_REGX = new RegExp("^" + ZONE_SYMBOL_PREFIX + "(\\w+)(true|false)$");
908
- var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol("propagationStopped");
909
- function prepareEventNames(eventName, eventNameToString) {
910
- const falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR;
911
- const trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR;
912
- const symbol = ZONE_SYMBOL_PREFIX + falseEventName;
913
- const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName;
914
- zoneSymbolEventNames[eventName] = {};
915
- zoneSymbolEventNames[eventName][FALSE_STR] = symbol;
916
- zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture;
917
- }
918
- function patchEventTarget(_global2, api, apis, patchOptions) {
919
- const ADD_EVENT_LISTENER = patchOptions && patchOptions.add || ADD_EVENT_LISTENER_STR;
920
- const REMOVE_EVENT_LISTENER = patchOptions && patchOptions.rm || REMOVE_EVENT_LISTENER_STR;
921
- const LISTENERS_EVENT_LISTENER = patchOptions && patchOptions.listeners || "eventListeners";
922
- const REMOVE_ALL_LISTENERS_EVENT_LISTENER = patchOptions && patchOptions.rmAll || "removeAllListeners";
923
- const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER);
924
- const ADD_EVENT_LISTENER_SOURCE = "." + ADD_EVENT_LISTENER + ":";
925
- const PREPEND_EVENT_LISTENER = "prependListener";
926
- const PREPEND_EVENT_LISTENER_SOURCE = "." + PREPEND_EVENT_LISTENER + ":";
927
- const invokeTask = function(task, target, event) {
928
- if (task.isRemoved) {
929
- return;
930
- }
931
- const delegate = task.callback;
932
- if (typeof delegate === "object" && delegate.handleEvent) {
933
- task.callback = (event2) => delegate.handleEvent(event2);
934
- task.originalDelegate = delegate;
935
- }
936
- let error;
937
- try {
938
- task.invoke(task, target, [event]);
939
- } catch (err) {
940
- error = err;
941
- }
942
- const options = task.options;
943
- if (options && typeof options === "object" && options.once) {
944
- const delegate2 = task.originalDelegate ? task.originalDelegate : task.callback;
945
- target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate2, options);
946
- }
947
- return error;
948
- };
949
- function globalCallback(context, event, isCapture) {
950
- event = event || _global2.event;
951
- if (!event) {
952
- return;
953
- }
954
- const target = context || event.target || _global2;
955
- const tasks = target[zoneSymbolEventNames[event.type][isCapture ? TRUE_STR : FALSE_STR]];
956
- if (tasks) {
957
- const errors = [];
958
- if (tasks.length === 1) {
959
- const err = invokeTask(tasks[0], target, event);
960
- err && errors.push(err);
961
- } else {
962
- const copyTasks = tasks.slice();
963
- for (let i = 0; i < copyTasks.length; i++) {
964
- if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) {
965
- break;
966
- }
967
- const err = invokeTask(copyTasks[i], target, event);
968
- err && errors.push(err);
969
- }
970
- }
971
- if (errors.length === 1) {
972
- throw errors[0];
973
- } else {
974
- for (let i = 0; i < errors.length; i++) {
975
- const err = errors[i];
976
- api.nativeScheduleMicroTask(() => {
977
- throw err;
978
- });
979
- }
980
- }
981
- }
982
- }
983
- const globalZoneAwareCallback = function(event) {
984
- return globalCallback(this, event, false);
985
- };
986
- const globalZoneAwareCaptureCallback = function(event) {
987
- return globalCallback(this, event, true);
988
- };
989
- function patchEventTargetMethods(obj, patchOptions2) {
990
- if (!obj) {
991
- return false;
992
- }
993
- let useGlobalCallback = true;
994
- if (patchOptions2 && patchOptions2.useG !== void 0) {
995
- useGlobalCallback = patchOptions2.useG;
996
- }
997
- const validateHandler = patchOptions2 && patchOptions2.vh;
998
- let checkDuplicate = true;
999
- if (patchOptions2 && patchOptions2.chkDup !== void 0) {
1000
- checkDuplicate = patchOptions2.chkDup;
1001
- }
1002
- let returnTarget = false;
1003
- if (patchOptions2 && patchOptions2.rt !== void 0) {
1004
- returnTarget = patchOptions2.rt;
1005
- }
1006
- let proto = obj;
1007
- while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) {
1008
- proto = ObjectGetPrototypeOf(proto);
1009
- }
1010
- if (!proto && obj[ADD_EVENT_LISTENER]) {
1011
- proto = obj;
1012
- }
1013
- if (!proto) {
1014
- return false;
1015
- }
1016
- if (proto[zoneSymbolAddEventListener]) {
1017
- return false;
1018
- }
1019
- const eventNameToString = patchOptions2 && patchOptions2.eventNameToString;
1020
- const taskData = {};
1021
- const nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER];
1022
- const nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = proto[REMOVE_EVENT_LISTENER];
1023
- const nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = proto[LISTENERS_EVENT_LISTENER];
1024
- const nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER];
1025
- let nativePrependEventListener;
1026
- if (patchOptions2 && patchOptions2.prepend) {
1027
- nativePrependEventListener = proto[zoneSymbol(patchOptions2.prepend)] = proto[patchOptions2.prepend];
1028
- }
1029
- function buildEventListenerOptions(options, passive) {
1030
- if (!passive) {
1031
- return options;
1032
- }
1033
- if (typeof options === "boolean") {
1034
- return { capture: options, passive: true };
1035
- }
1036
- if (!options) {
1037
- return { passive: true };
1038
- }
1039
- if (typeof options === "object" && options.passive !== false) {
1040
- return __spreadProps(__spreadValues({}, options), { passive: true });
1041
- }
1042
- return options;
1043
- }
1044
- const customScheduleGlobal = function(task) {
1045
- if (taskData.isExisting) {
1046
- return;
1047
- }
1048
- return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options);
1049
- };
1050
- const customCancelGlobal = function(task) {
1051
- if (!task.isRemoved) {
1052
- const symbolEventNames = zoneSymbolEventNames[task.eventName];
1053
- let symbolEventName;
1054
- if (symbolEventNames) {
1055
- symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR];
1056
- }
1057
- const existingTasks = symbolEventName && task.target[symbolEventName];
1058
- if (existingTasks) {
1059
- for (let i = 0; i < existingTasks.length; i++) {
1060
- const existingTask = existingTasks[i];
1061
- if (existingTask === task) {
1062
- existingTasks.splice(i, 1);
1063
- task.isRemoved = true;
1064
- if (task.removeAbortListener) {
1065
- task.removeAbortListener();
1066
- task.removeAbortListener = null;
1067
- }
1068
- if (existingTasks.length === 0) {
1069
- task.allRemoved = true;
1070
- task.target[symbolEventName] = null;
1071
- }
1072
- break;
1073
- }
1074
- }
1075
- }
1076
- }
1077
- if (!task.allRemoved) {
1078
- return;
1079
- }
1080
- return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options);
1081
- };
1082
- const customScheduleNonGlobal = function(task) {
1083
- return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options);
1084
- };
1085
- const customSchedulePrepend = function(task) {
1086
- return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options);
1087
- };
1088
- const customCancelNonGlobal = function(task) {
1089
- return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options);
1090
- };
1091
- const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal;
1092
- const customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal;
1093
- const compareTaskCallbackVsDelegate = function(task, delegate) {
1094
- const typeOfDelegate = typeof delegate;
1095
- return typeOfDelegate === "function" && task.callback === delegate || typeOfDelegate === "object" && task.originalDelegate === delegate;
1096
- };
1097
- const compare = patchOptions2?.diff || compareTaskCallbackVsDelegate;
1098
- const unpatchedEvents = Zone[zoneSymbol("UNPATCHED_EVENTS")];
1099
- const passiveEvents = _global2[zoneSymbol("PASSIVE_EVENTS")];
1100
- function copyEventListenerOptions(options) {
1101
- if (typeof options === "object" && options !== null) {
1102
- const newOptions = __spreadValues({}, options);
1103
- if (options.signal) {
1104
- newOptions.signal = options.signal;
1105
- }
1106
- return newOptions;
1107
- }
1108
- return options;
1109
- }
1110
- const makeAddListener = function(nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget2 = false, prepend = false) {
1111
- return function() {
1112
- const target = this || _global2;
1113
- let eventName = arguments[0];
1114
- if (patchOptions2 && patchOptions2.transferEventName) {
1115
- eventName = patchOptions2.transferEventName(eventName);
1116
- }
1117
- let delegate = arguments[1];
1118
- if (!delegate) {
1119
- return nativeListener.apply(this, arguments);
1120
- }
1121
- if (isNode && eventName === "uncaughtException") {
1122
- return nativeListener.apply(this, arguments);
1123
- }
1124
- let isEventListenerObject = false;
1125
- if (typeof delegate !== "function") {
1126
- if (!delegate.handleEvent) {
1127
- return nativeListener.apply(this, arguments);
1128
- }
1129
- isEventListenerObject = true;
1130
- }
1131
- if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) {
1132
- return;
1133
- }
1134
- const passive = !!passiveEvents && passiveEvents.indexOf(eventName) !== -1;
1135
- const options = copyEventListenerOptions(buildEventListenerOptions(arguments[2], passive));
1136
- const signal = options?.signal;
1137
- if (signal?.aborted) {
1138
- return;
1139
- }
1140
- if (unpatchedEvents) {
1141
- for (let i = 0; i < unpatchedEvents.length; i++) {
1142
- if (eventName === unpatchedEvents[i]) {
1143
- if (passive) {
1144
- return nativeListener.call(target, eventName, delegate, options);
1145
- } else {
1146
- return nativeListener.apply(this, arguments);
1147
- }
1148
- }
1149
- }
1150
- }
1151
- const capture = !options ? false : typeof options === "boolean" ? true : options.capture;
1152
- const once = options && typeof options === "object" ? options.once : false;
1153
- const zone = Zone.current;
1154
- let symbolEventNames = zoneSymbolEventNames[eventName];
1155
- if (!symbolEventNames) {
1156
- prepareEventNames(eventName, eventNameToString);
1157
- symbolEventNames = zoneSymbolEventNames[eventName];
1158
- }
1159
- const symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR];
1160
- let existingTasks = target[symbolEventName];
1161
- let isExisting = false;
1162
- if (existingTasks) {
1163
- isExisting = true;
1164
- if (checkDuplicate) {
1165
- for (let i = 0; i < existingTasks.length; i++) {
1166
- if (compare(existingTasks[i], delegate)) {
1167
- return;
1168
- }
1169
- }
1170
- }
1171
- } else {
1172
- existingTasks = target[symbolEventName] = [];
1173
- }
1174
- let source;
1175
- const constructorName = target.constructor["name"];
1176
- const targetSource = globalSources[constructorName];
1177
- if (targetSource) {
1178
- source = targetSource[eventName];
1179
- }
1180
- if (!source) {
1181
- source = constructorName + addSource + (eventNameToString ? eventNameToString(eventName) : eventName);
1182
- }
1183
- taskData.options = options;
1184
- if (once) {
1185
- taskData.options.once = false;
1186
- }
1187
- taskData.target = target;
1188
- taskData.capture = capture;
1189
- taskData.eventName = eventName;
1190
- taskData.isExisting = isExisting;
1191
- const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : void 0;
1192
- if (data) {
1193
- data.taskData = taskData;
1194
- }
1195
- if (signal) {
1196
- taskData.options.signal = void 0;
1197
- }
1198
- const task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn);
1199
- if (signal) {
1200
- taskData.options.signal = signal;
1201
- const onAbort = () => task.zone.cancelTask(task);
1202
- nativeListener.call(signal, "abort", onAbort, { once: true });
1203
- task.removeAbortListener = () => signal.removeEventListener("abort", onAbort);
1204
- }
1205
- taskData.target = null;
1206
- if (data) {
1207
- data.taskData = null;
1208
- }
1209
- if (once) {
1210
- taskData.options.once = true;
1211
- }
1212
- if (typeof task.options !== "boolean") {
1213
- task.options = options;
1214
- }
1215
- task.target = target;
1216
- task.capture = capture;
1217
- task.eventName = eventName;
1218
- if (isEventListenerObject) {
1219
- task.originalDelegate = delegate;
1220
- }
1221
- if (!prepend) {
1222
- existingTasks.push(task);
1223
- } else {
1224
- existingTasks.unshift(task);
1225
- }
1226
- if (returnTarget2) {
1227
- return target;
1228
- }
1229
- };
1230
- };
1231
- proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget);
1232
- if (nativePrependEventListener) {
1233
- proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true);
1234
- }
1235
- proto[REMOVE_EVENT_LISTENER] = function() {
1236
- const target = this || _global2;
1237
- let eventName = arguments[0];
1238
- if (patchOptions2 && patchOptions2.transferEventName) {
1239
- eventName = patchOptions2.transferEventName(eventName);
1240
- }
1241
- const options = arguments[2];
1242
- const capture = !options ? false : typeof options === "boolean" ? true : options.capture;
1243
- const delegate = arguments[1];
1244
- if (!delegate) {
1245
- return nativeRemoveEventListener.apply(this, arguments);
1246
- }
1247
- if (validateHandler && !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) {
1248
- return;
1249
- }
1250
- const symbolEventNames = zoneSymbolEventNames[eventName];
1251
- let symbolEventName;
1252
- if (symbolEventNames) {
1253
- symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR];
1254
- }
1255
- const existingTasks = symbolEventName && target[symbolEventName];
1256
- if (existingTasks) {
1257
- for (let i = 0; i < existingTasks.length; i++) {
1258
- const existingTask = existingTasks[i];
1259
- if (compare(existingTask, delegate)) {
1260
- existingTasks.splice(i, 1);
1261
- existingTask.isRemoved = true;
1262
- if (existingTasks.length === 0) {
1263
- existingTask.allRemoved = true;
1264
- target[symbolEventName] = null;
1265
- if (!capture && typeof eventName === "string") {
1266
- const onPropertySymbol = ZONE_SYMBOL_PREFIX + "ON_PROPERTY" + eventName;
1267
- target[onPropertySymbol] = null;
1268
- }
1269
- }
1270
- existingTask.zone.cancelTask(existingTask);
1271
- if (returnTarget) {
1272
- return target;
1273
- }
1274
- return;
1275
- }
1276
- }
1277
- }
1278
- return nativeRemoveEventListener.apply(this, arguments);
1279
- };
1280
- proto[LISTENERS_EVENT_LISTENER] = function() {
1281
- const target = this || _global2;
1282
- let eventName = arguments[0];
1283
- if (patchOptions2 && patchOptions2.transferEventName) {
1284
- eventName = patchOptions2.transferEventName(eventName);
1285
- }
1286
- const listeners = [];
1287
- const tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName);
1288
- for (let i = 0; i < tasks.length; i++) {
1289
- const task = tasks[i];
1290
- let delegate = task.originalDelegate ? task.originalDelegate : task.callback;
1291
- listeners.push(delegate);
1292
- }
1293
- return listeners;
1294
- };
1295
- proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function() {
1296
- const target = this || _global2;
1297
- let eventName = arguments[0];
1298
- if (!eventName) {
1299
- const keys = Object.keys(target);
1300
- for (let i = 0; i < keys.length; i++) {
1301
- const prop = keys[i];
1302
- const match = EVENT_NAME_SYMBOL_REGX.exec(prop);
1303
- let evtName = match && match[1];
1304
- if (evtName && evtName !== "removeListener") {
1305
- this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName);
1306
- }
1307
- }
1308
- this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, "removeListener");
1309
- } else {
1310
- if (patchOptions2 && patchOptions2.transferEventName) {
1311
- eventName = patchOptions2.transferEventName(eventName);
1312
- }
1313
- const symbolEventNames = zoneSymbolEventNames[eventName];
1314
- if (symbolEventNames) {
1315
- const symbolEventName = symbolEventNames[FALSE_STR];
1316
- const symbolCaptureEventName = symbolEventNames[TRUE_STR];
1317
- const tasks = target[symbolEventName];
1318
- const captureTasks = target[symbolCaptureEventName];
1319
- if (tasks) {
1320
- const removeTasks = tasks.slice();
1321
- for (let i = 0; i < removeTasks.length; i++) {
1322
- const task = removeTasks[i];
1323
- let delegate = task.originalDelegate ? task.originalDelegate : task.callback;
1324
- this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options);
1325
- }
1326
- }
1327
- if (captureTasks) {
1328
- const removeTasks = captureTasks.slice();
1329
- for (let i = 0; i < removeTasks.length; i++) {
1330
- const task = removeTasks[i];
1331
- let delegate = task.originalDelegate ? task.originalDelegate : task.callback;
1332
- this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options);
1333
- }
1334
- }
1335
- }
1336
- }
1337
- if (returnTarget) {
1338
- return this;
1339
- }
1340
- };
1341
- attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener);
1342
- attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener);
1343
- if (nativeRemoveAllListeners) {
1344
- attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners);
1345
- }
1346
- if (nativeListeners) {
1347
- attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners);
1348
- }
1349
- return true;
1350
- }
1351
- let results = [];
1352
- for (let i = 0; i < apis.length; i++) {
1353
- results[i] = patchEventTargetMethods(apis[i], patchOptions);
1354
- }
1355
- return results;
1356
- }
1357
- function findEventTasks(target, eventName) {
1358
- if (!eventName) {
1359
- const foundTasks = [];
1360
- for (let prop in target) {
1361
- const match = EVENT_NAME_SYMBOL_REGX.exec(prop);
1362
- let evtName = match && match[1];
1363
- if (evtName && (!eventName || evtName === eventName)) {
1364
- const tasks = target[prop];
1365
- if (tasks) {
1366
- for (let i = 0; i < tasks.length; i++) {
1367
- foundTasks.push(tasks[i]);
1368
- }
1369
- }
1370
- }
1371
- }
1372
- return foundTasks;
1373
- }
1374
- let symbolEventName = zoneSymbolEventNames[eventName];
1375
- if (!symbolEventName) {
1376
- prepareEventNames(eventName);
1377
- symbolEventName = zoneSymbolEventNames[eventName];
1378
- }
1379
- const captureFalseTasks = target[symbolEventName[FALSE_STR]];
1380
- const captureTrueTasks = target[symbolEventName[TRUE_STR]];
1381
- if (!captureFalseTasks) {
1382
- return captureTrueTasks ? captureTrueTasks.slice() : [];
1383
- } else {
1384
- return captureTrueTasks ? captureFalseTasks.concat(captureTrueTasks) : captureFalseTasks.slice();
1385
- }
1386
- }
1387
- function patchEventPrototype(global2, api) {
1388
- const Event = global2["Event"];
1389
- if (Event && Event.prototype) {
1390
- api.patchMethod(Event.prototype, "stopImmediatePropagation", (delegate) => function(self2, args) {
1391
- self2[IMMEDIATE_PROPAGATION_SYMBOL] = true;
1392
- delegate && delegate.apply(self2, args);
1393
- });
1394
- }
1395
- }
1396
- function patchQueueMicrotask(global2, api) {
1397
- api.patchMethod(global2, "queueMicrotask", (delegate) => {
1398
- return function(self2, args) {
1399
- Zone.current.scheduleMicroTask("queueMicrotask", args[0]);
1400
- };
1401
- });
1402
- }
1403
- var taskSymbol = zoneSymbol("zoneTask");
1404
- function patchTimer(window2, setName, cancelName, nameSuffix) {
1405
- let setNative = null;
1406
- let clearNative = null;
1407
- setName += nameSuffix;
1408
- cancelName += nameSuffix;
1409
- const tasksByHandleId = {};
1410
- function scheduleTask(task) {
1411
- const data = task.data;
1412
- data.args[0] = function() {
1413
- return task.invoke.apply(this, arguments);
1414
- };
1415
- const handleOrId = setNative.apply(window2, data.args);
1416
- if (isNumber(handleOrId)) {
1417
- data.handleId = handleOrId;
1418
- } else {
1419
- data.handle = handleOrId;
1420
- data.isRefreshable = isFunction(handleOrId.refresh);
1421
- }
1422
- return task;
1423
- }
1424
- function clearTask(task) {
1425
- const { handle, handleId } = task.data;
1426
- return clearNative.call(window2, handle ?? handleId);
1427
- }
1428
- setNative = patchMethod(window2, setName, (delegate) => function(self2, args) {
1429
- if (isFunction(args[0])) {
1430
- const options = {
1431
- isRefreshable: false,
1432
- isPeriodic: nameSuffix === "Interval",
1433
- delay: nameSuffix === "Timeout" || nameSuffix === "Interval" ? args[1] || 0 : void 0,
1434
- args
1435
- };
1436
- const callback = args[0];
1437
- args[0] = function timer() {
1438
- try {
1439
- return callback.apply(this, arguments);
1440
- } finally {
1441
- const { handle: handle2, handleId: handleId2, isPeriodic: isPeriodic2, isRefreshable: isRefreshable2 } = options;
1442
- if (!isPeriodic2 && !isRefreshable2) {
1443
- if (handleId2) {
1444
- delete tasksByHandleId[handleId2];
1445
- } else if (handle2) {
1446
- handle2[taskSymbol] = null;
1447
- }
1448
- }
1449
- }
1450
- };
1451
- const task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask);
1452
- if (!task) {
1453
- return task;
1454
- }
1455
- const { handleId, handle, isRefreshable, isPeriodic } = task.data;
1456
- if (handleId) {
1457
- tasksByHandleId[handleId] = task;
1458
- } else if (handle) {
1459
- handle[taskSymbol] = task;
1460
- if (isRefreshable && !isPeriodic) {
1461
- const originalRefresh = handle.refresh;
1462
- handle.refresh = function() {
1463
- const { zone, state } = task;
1464
- if (state === "notScheduled") {
1465
- task._state = "scheduled";
1466
- zone._updateTaskCount(task, 1);
1467
- } else if (state === "running") {
1468
- task._state = "scheduling";
1469
- }
1470
- return originalRefresh.call(this);
1471
- };
1472
- }
1473
- }
1474
- return handle ?? handleId ?? task;
1475
- } else {
1476
- return delegate.apply(window2, args);
1477
- }
1478
- });
1479
- clearNative = patchMethod(window2, cancelName, (delegate) => function(self2, args) {
1480
- const id = args[0];
1481
- let task;
1482
- if (isNumber(id)) {
1483
- task = tasksByHandleId[id];
1484
- delete tasksByHandleId[id];
1485
- } else {
1486
- task = id?.[taskSymbol];
1487
- if (task) {
1488
- id[taskSymbol] = null;
1489
- } else {
1490
- task = id;
1491
- }
1492
- }
1493
- if (task?.type) {
1494
- if (task.cancelFn) {
1495
- task.zone.cancelTask(task);
1496
- }
1497
- } else {
1498
- delegate.apply(window2, args);
1499
- }
1500
- });
1501
- }
1502
- function patchCustomElements(_global2, api) {
1503
- const { isBrowser: isBrowser2, isMix: isMix2 } = api.getGlobalObjects();
1504
- if (!isBrowser2 && !isMix2 || !_global2["customElements"] || !("customElements" in _global2)) {
1505
- return;
1506
- }
1507
- const callbacks = [
1508
- "connectedCallback",
1509
- "disconnectedCallback",
1510
- "adoptedCallback",
1511
- "attributeChangedCallback",
1512
- "formAssociatedCallback",
1513
- "formDisabledCallback",
1514
- "formResetCallback",
1515
- "formStateRestoreCallback"
1516
- ];
1517
- api.patchCallbacks(api, _global2.customElements, "customElements", "define", callbacks);
1518
- }
1519
- function eventTargetPatch(_global2, api) {
1520
- if (Zone[api.symbol("patchEventTarget")]) {
1521
- return;
1522
- }
1523
- const { eventNames, zoneSymbolEventNames: zoneSymbolEventNames2, TRUE_STR: TRUE_STR2, FALSE_STR: FALSE_STR2, ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX2 } = api.getGlobalObjects();
1524
- for (let i = 0; i < eventNames.length; i++) {
1525
- const eventName = eventNames[i];
1526
- const falseEventName = eventName + FALSE_STR2;
1527
- const trueEventName = eventName + TRUE_STR2;
1528
- const symbol = ZONE_SYMBOL_PREFIX2 + falseEventName;
1529
- const symbolCapture = ZONE_SYMBOL_PREFIX2 + trueEventName;
1530
- zoneSymbolEventNames2[eventName] = {};
1531
- zoneSymbolEventNames2[eventName][FALSE_STR2] = symbol;
1532
- zoneSymbolEventNames2[eventName][TRUE_STR2] = symbolCapture;
1533
- }
1534
- const EVENT_TARGET = _global2["EventTarget"];
1535
- if (!EVENT_TARGET || !EVENT_TARGET.prototype) {
1536
- return;
1537
- }
1538
- api.patchEventTarget(_global2, api, [EVENT_TARGET && EVENT_TARGET.prototype]);
1539
- return true;
1540
- }
1541
- function patchEvent(global2, api) {
1542
- api.patchEventPrototype(global2, api);
1543
- }
1544
- function filterProperties(target, onProperties, ignoreProperties) {
1545
- if (!ignoreProperties || ignoreProperties.length === 0) {
1546
- return onProperties;
1547
- }
1548
- const tip = ignoreProperties.filter((ip) => ip.target === target);
1549
- if (tip.length === 0) {
1550
- return onProperties;
1551
- }
1552
- const targetIgnoreProperties = tip[0].ignoreProperties;
1553
- return onProperties.filter((op) => targetIgnoreProperties.indexOf(op) === -1);
1554
- }
1555
- function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) {
1556
- if (!target) {
1557
- return;
1558
- }
1559
- const filteredProperties = filterProperties(target, onProperties, ignoreProperties);
1560
- patchOnProperties(target, filteredProperties, prototype);
1561
- }
1562
- function getOnEventNames(target) {
1563
- return Object.getOwnPropertyNames(target).filter((name) => name.startsWith("on") && name.length > 2).map((name) => name.substring(2));
1564
- }
1565
- function propertyDescriptorPatch(api, _global2) {
1566
- if (isNode && !isMix) {
1567
- return;
1568
- }
1569
- if (Zone[api.symbol("patchEvents")]) {
1570
- return;
1571
- }
1572
- const ignoreProperties = _global2["__Zone_ignore_on_properties"];
1573
- let patchTargets = [];
1574
- if (isBrowser) {
1575
- const internalWindow2 = window;
1576
- patchTargets = patchTargets.concat([
1577
- "Document",
1578
- "SVGElement",
1579
- "Element",
1580
- "HTMLElement",
1581
- "HTMLBodyElement",
1582
- "HTMLMediaElement",
1583
- "HTMLFrameSetElement",
1584
- "HTMLFrameElement",
1585
- "HTMLIFrameElement",
1586
- "HTMLMarqueeElement",
1587
- "Worker"
1588
- ]);
1589
- const ignoreErrorProperties = [];
1590
- patchFilteredProperties(internalWindow2, getOnEventNames(internalWindow2), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow2));
1591
- }
1592
- patchTargets = patchTargets.concat([
1593
- "XMLHttpRequest",
1594
- "XMLHttpRequestEventTarget",
1595
- "IDBIndex",
1596
- "IDBRequest",
1597
- "IDBOpenDBRequest",
1598
- "IDBDatabase",
1599
- "IDBTransaction",
1600
- "IDBCursor",
1601
- "WebSocket"
1602
- ]);
1603
- for (let i = 0; i < patchTargets.length; i++) {
1604
- const target = _global2[patchTargets[i]];
1605
- target?.prototype && patchFilteredProperties(target.prototype, getOnEventNames(target.prototype), ignoreProperties);
1606
- }
1607
- }
1608
- function patchBrowser(Zone2) {
1609
- Zone2.__load_patch("legacy", (global2) => {
1610
- const legacyPatch = global2[Zone2.__symbol__("legacyPatch")];
1611
- if (legacyPatch) {
1612
- legacyPatch();
1613
- }
1614
- });
1615
- Zone2.__load_patch("timers", (global2) => {
1616
- const set = "set";
1617
- const clear = "clear";
1618
- patchTimer(global2, set, clear, "Timeout");
1619
- patchTimer(global2, set, clear, "Interval");
1620
- patchTimer(global2, set, clear, "Immediate");
1621
- });
1622
- Zone2.__load_patch("requestAnimationFrame", (global2) => {
1623
- patchTimer(global2, "request", "cancel", "AnimationFrame");
1624
- patchTimer(global2, "mozRequest", "mozCancel", "AnimationFrame");
1625
- patchTimer(global2, "webkitRequest", "webkitCancel", "AnimationFrame");
1626
- });
1627
- Zone2.__load_patch("blocking", (global2, Zone3) => {
1628
- const blockingMethods = ["alert", "prompt", "confirm"];
1629
- for (let i = 0; i < blockingMethods.length; i++) {
1630
- const name = blockingMethods[i];
1631
- patchMethod(global2, name, (delegate, symbol, name2) => {
1632
- return function(s, args) {
1633
- return Zone3.current.run(delegate, global2, args, name2);
1634
- };
1635
- });
1636
- }
1637
- });
1638
- Zone2.__load_patch("EventTarget", (global2, Zone3, api) => {
1639
- patchEvent(global2, api);
1640
- eventTargetPatch(global2, api);
1641
- const XMLHttpRequestEventTarget = global2["XMLHttpRequestEventTarget"];
1642
- if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) {
1643
- api.patchEventTarget(global2, api, [XMLHttpRequestEventTarget.prototype]);
1644
- }
1645
- });
1646
- Zone2.__load_patch("MutationObserver", (global2, Zone3, api) => {
1647
- patchClass("MutationObserver");
1648
- patchClass("WebKitMutationObserver");
1649
- });
1650
- Zone2.__load_patch("IntersectionObserver", (global2, Zone3, api) => {
1651
- patchClass("IntersectionObserver");
1652
- });
1653
- Zone2.__load_patch("FileReader", (global2, Zone3, api) => {
1654
- patchClass("FileReader");
1655
- });
1656
- Zone2.__load_patch("on_property", (global2, Zone3, api) => {
1657
- propertyDescriptorPatch(api, global2);
1658
- });
1659
- Zone2.__load_patch("customElements", (global2, Zone3, api) => {
1660
- patchCustomElements(global2, api);
1661
- });
1662
- Zone2.__load_patch("XHR", (global2, Zone3) => {
1663
- patchXHR(global2);
1664
- const XHR_TASK = zoneSymbol("xhrTask");
1665
- const XHR_SYNC = zoneSymbol("xhrSync");
1666
- const XHR_LISTENER = zoneSymbol("xhrListener");
1667
- const XHR_SCHEDULED = zoneSymbol("xhrScheduled");
1668
- const XHR_URL = zoneSymbol("xhrURL");
1669
- const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol("xhrErrorBeforeScheduled");
1670
- function patchXHR(window2) {
1671
- const XMLHttpRequest = window2["XMLHttpRequest"];
1672
- if (!XMLHttpRequest) {
1673
- return;
1674
- }
1675
- const XMLHttpRequestPrototype = XMLHttpRequest.prototype;
1676
- function findPendingTask(target) {
1677
- return target[XHR_TASK];
1678
- }
1679
- let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER];
1680
- let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
1681
- if (!oriAddListener) {
1682
- const XMLHttpRequestEventTarget = window2["XMLHttpRequestEventTarget"];
1683
- if (XMLHttpRequestEventTarget) {
1684
- const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype;
1685
- oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER];
1686
- oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
1687
- }
1688
- }
1689
- const READY_STATE_CHANGE = "readystatechange";
1690
- const SCHEDULED = "scheduled";
1691
- function scheduleTask(task) {
1692
- const data = task.data;
1693
- const target = data.target;
1694
- target[XHR_SCHEDULED] = false;
1695
- target[XHR_ERROR_BEFORE_SCHEDULED] = false;
1696
- const listener = target[XHR_LISTENER];
1697
- if (!oriAddListener) {
1698
- oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER];
1699
- oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];
1700
- }
1701
- if (listener) {
1702
- oriRemoveListener.call(target, READY_STATE_CHANGE, listener);
1703
- }
1704
- const newListener = target[XHR_LISTENER] = () => {
1705
- if (target.readyState === target.DONE) {
1706
- if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) {
1707
- const loadTasks = target[Zone3.__symbol__("loadfalse")];
1708
- if (target.status !== 0 && loadTasks && loadTasks.length > 0) {
1709
- const oriInvoke = task.invoke;
1710
- task.invoke = function() {
1711
- const loadTasks2 = target[Zone3.__symbol__("loadfalse")];
1712
- for (let i = 0; i < loadTasks2.length; i++) {
1713
- if (loadTasks2[i] === task) {
1714
- loadTasks2.splice(i, 1);
1715
- }
1716
- }
1717
- if (!data.aborted && task.state === SCHEDULED) {
1718
- oriInvoke.call(task);
1719
- }
1720
- };
1721
- loadTasks.push(task);
1722
- } else {
1723
- task.invoke();
1724
- }
1725
- } else if (!data.aborted && target[XHR_SCHEDULED] === false) {
1726
- target[XHR_ERROR_BEFORE_SCHEDULED] = true;
1727
- }
1728
- }
1729
- };
1730
- oriAddListener.call(target, READY_STATE_CHANGE, newListener);
1731
- const storedTask = target[XHR_TASK];
1732
- if (!storedTask) {
1733
- target[XHR_TASK] = task;
1734
- }
1735
- sendNative.apply(target, data.args);
1736
- target[XHR_SCHEDULED] = true;
1737
- return task;
1738
- }
1739
- function placeholderCallback() {
1740
- }
1741
- function clearTask(task) {
1742
- const data = task.data;
1743
- data.aborted = true;
1744
- return abortNative.apply(data.target, data.args);
1745
- }
1746
- const openNative = patchMethod(XMLHttpRequestPrototype, "open", () => function(self2, args) {
1747
- self2[XHR_SYNC] = args[2] == false;
1748
- self2[XHR_URL] = args[1];
1749
- return openNative.apply(self2, args);
1750
- });
1751
- const XMLHTTPREQUEST_SOURCE = "XMLHttpRequest.send";
1752
- const fetchTaskAborting = zoneSymbol("fetchTaskAborting");
1753
- const fetchTaskScheduling = zoneSymbol("fetchTaskScheduling");
1754
- const sendNative = patchMethod(XMLHttpRequestPrototype, "send", () => function(self2, args) {
1755
- if (Zone3.current[fetchTaskScheduling] === true) {
1756
- return sendNative.apply(self2, args);
1757
- }
1758
- if (self2[XHR_SYNC]) {
1759
- return sendNative.apply(self2, args);
1760
- } else {
1761
- const options = {
1762
- target: self2,
1763
- url: self2[XHR_URL],
1764
- isPeriodic: false,
1765
- args,
1766
- aborted: false
1767
- };
1768
- const task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask);
1769
- if (self2 && self2[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && task.state === SCHEDULED) {
1770
- task.invoke();
1771
- }
1772
- }
1773
- });
1774
- const abortNative = patchMethod(XMLHttpRequestPrototype, "abort", () => function(self2, args) {
1775
- const task = findPendingTask(self2);
1776
- if (task && typeof task.type == "string") {
1777
- if (task.cancelFn == null || task.data && task.data.aborted) {
1778
- return;
1779
- }
1780
- task.zone.cancelTask(task);
1781
- } else if (Zone3.current[fetchTaskAborting] === true) {
1782
- return abortNative.apply(self2, args);
1783
- }
1784
- });
1785
- }
1786
- });
1787
- Zone2.__load_patch("geolocation", (global2) => {
1788
- if (global2["navigator"] && global2["navigator"].geolocation) {
1789
- patchPrototype(global2["navigator"].geolocation, ["getCurrentPosition", "watchPosition"]);
1790
- }
1791
- });
1792
- Zone2.__load_patch("PromiseRejectionEvent", (global2, Zone3) => {
1793
- function findPromiseRejectionHandler(evtName) {
1794
- return function(e) {
1795
- const eventTasks = findEventTasks(global2, evtName);
1796
- eventTasks.forEach((eventTask) => {
1797
- const PromiseRejectionEvent = global2["PromiseRejectionEvent"];
1798
- if (PromiseRejectionEvent) {
1799
- const evt = new PromiseRejectionEvent(evtName, {
1800
- promise: e.promise,
1801
- reason: e.rejection
1802
- });
1803
- eventTask.invoke(evt);
1804
- }
1805
- });
1806
- };
1807
- }
1808
- if (global2["PromiseRejectionEvent"]) {
1809
- Zone3[zoneSymbol("unhandledPromiseRejectionHandler")] = findPromiseRejectionHandler("unhandledrejection");
1810
- Zone3[zoneSymbol("rejectionHandledHandler")] = findPromiseRejectionHandler("rejectionhandled");
1811
- }
1812
- });
1813
- Zone2.__load_patch("queueMicrotask", (global2, Zone3, api) => {
1814
- patchQueueMicrotask(global2, api);
1815
- });
1816
- }
1817
- function patchPromise(Zone2) {
1818
- Zone2.__load_patch("ZoneAwarePromise", (global2, Zone3, api) => {
1819
- const ObjectGetOwnPropertyDescriptor2 = Object.getOwnPropertyDescriptor;
1820
- const ObjectDefineProperty2 = Object.defineProperty;
1821
- function readableObjectToString(obj) {
1822
- if (obj && obj.toString === Object.prototype.toString) {
1823
- const className = obj.constructor && obj.constructor.name;
1824
- return (className ? className : "") + ": " + JSON.stringify(obj);
1825
- }
1826
- return obj ? obj.toString() : Object.prototype.toString.call(obj);
1827
- }
1828
- const __symbol__2 = api.symbol;
1829
- const _uncaughtPromiseErrors = [];
1830
- const isDisableWrappingUncaughtPromiseRejection = global2[__symbol__2("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")] !== false;
1831
- const symbolPromise = __symbol__2("Promise");
1832
- const symbolThen = __symbol__2("then");
1833
- const creationTrace = "__creationTrace__";
1834
- api.onUnhandledError = (e) => {
1835
- if (api.showUncaughtError()) {
1836
- const rejection = e && e.rejection;
1837
- if (rejection) {
1838
- 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 : void 0);
1839
- } else {
1840
- console.error(e);
1841
- }
1842
- }
1843
- };
1844
- api.microtaskDrainDone = () => {
1845
- while (_uncaughtPromiseErrors.length) {
1846
- const uncaughtPromiseError = _uncaughtPromiseErrors.shift();
1847
- try {
1848
- uncaughtPromiseError.zone.runGuarded(() => {
1849
- if (uncaughtPromiseError.throwOriginal) {
1850
- throw uncaughtPromiseError.rejection;
1851
- }
1852
- throw uncaughtPromiseError;
1853
- });
1854
- } catch (error) {
1855
- handleUnhandledRejection(error);
1856
- }
1857
- }
1858
- };
1859
- const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__2("unhandledPromiseRejectionHandler");
1860
- function handleUnhandledRejection(e) {
1861
- api.onUnhandledError(e);
1862
- try {
1863
- const handler = Zone3[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL];
1864
- if (typeof handler === "function") {
1865
- handler.call(this, e);
1866
- }
1867
- } catch (err) {
1868
- }
1869
- }
1870
- function isThenable(value) {
1871
- return value && typeof value.then === "function";
1872
- }
1873
- function forwardResolution(value) {
1874
- return value;
1875
- }
1876
- function forwardRejection(rejection) {
1877
- return ZoneAwarePromise.reject(rejection);
1878
- }
1879
- const symbolState = __symbol__2("state");
1880
- const symbolValue = __symbol__2("value");
1881
- const symbolFinally = __symbol__2("finally");
1882
- const symbolParentPromiseValue = __symbol__2("parentPromiseValue");
1883
- const symbolParentPromiseState = __symbol__2("parentPromiseState");
1884
- const source = "Promise.then";
1885
- const UNRESOLVED = null;
1886
- const RESOLVED = true;
1887
- const REJECTED = false;
1888
- const REJECTED_NO_CATCH = 0;
1889
- function makeResolver(promise, state) {
1890
- return (v) => {
1891
- try {
1892
- resolvePromise(promise, state, v);
1893
- } catch (err) {
1894
- resolvePromise(promise, false, err);
1895
- }
1896
- };
1897
- }
1898
- const once = function() {
1899
- let wasCalled = false;
1900
- return function wrapper(wrappedFunction) {
1901
- return function() {
1902
- if (wasCalled) {
1903
- return;
1904
- }
1905
- wasCalled = true;
1906
- wrappedFunction.apply(null, arguments);
1907
- };
1908
- };
1909
- };
1910
- const TYPE_ERROR = "Promise resolved with itself";
1911
- const CURRENT_TASK_TRACE_SYMBOL = __symbol__2("currentTaskTrace");
1912
- function resolvePromise(promise, state, value) {
1913
- const onceWrapper = once();
1914
- if (promise === value) {
1915
- throw new TypeError(TYPE_ERROR);
1916
- }
1917
- if (promise[symbolState] === UNRESOLVED) {
1918
- let then = null;
1919
- try {
1920
- if (typeof value === "object" || typeof value === "function") {
1921
- then = value && value.then;
1922
- }
1923
- } catch (err) {
1924
- onceWrapper(() => {
1925
- resolvePromise(promise, false, err);
1926
- })();
1927
- return promise;
1928
- }
1929
- if (state !== REJECTED && value instanceof ZoneAwarePromise && value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && value[symbolState] !== UNRESOLVED) {
1930
- clearRejectedNoCatch(value);
1931
- resolvePromise(promise, value[symbolState], value[symbolValue]);
1932
- } else if (state !== REJECTED && typeof then === "function") {
1933
- try {
1934
- then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)));
1935
- } catch (err) {
1936
- onceWrapper(() => {
1937
- resolvePromise(promise, false, err);
1938
- })();
1939
- }
1940
- } else {
1941
- promise[symbolState] = state;
1942
- const queue = promise[symbolValue];
1943
- promise[symbolValue] = value;
1944
- if (promise[symbolFinally] === symbolFinally) {
1945
- if (state === RESOLVED) {
1946
- promise[symbolState] = promise[symbolParentPromiseState];
1947
- promise[symbolValue] = promise[symbolParentPromiseValue];
1948
- }
1949
- }
1950
- if (state === REJECTED && value instanceof Error) {
1951
- const trace = Zone3.currentTask && Zone3.currentTask.data && Zone3.currentTask.data[creationTrace];
1952
- if (trace) {
1953
- ObjectDefineProperty2(value, CURRENT_TASK_TRACE_SYMBOL, {
1954
- configurable: true,
1955
- enumerable: false,
1956
- writable: true,
1957
- value: trace
1958
- });
1959
- }
1960
- }
1961
- for (let i = 0; i < queue.length; ) {
1962
- scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]);
1963
- }
1964
- if (queue.length == 0 && state == REJECTED) {
1965
- promise[symbolState] = REJECTED_NO_CATCH;
1966
- let uncaughtPromiseError = value;
1967
- try {
1968
- throw new Error("Uncaught (in promise): " + readableObjectToString(value) + (value && value.stack ? "\n" + value.stack : ""));
1969
- } catch (err) {
1970
- uncaughtPromiseError = err;
1971
- }
1972
- if (isDisableWrappingUncaughtPromiseRejection) {
1973
- uncaughtPromiseError.throwOriginal = true;
1974
- }
1975
- uncaughtPromiseError.rejection = value;
1976
- uncaughtPromiseError.promise = promise;
1977
- uncaughtPromiseError.zone = Zone3.current;
1978
- uncaughtPromiseError.task = Zone3.currentTask;
1979
- _uncaughtPromiseErrors.push(uncaughtPromiseError);
1980
- api.scheduleMicroTask();
1981
- }
1982
- }
1983
- }
1984
- return promise;
1985
- }
1986
- const REJECTION_HANDLED_HANDLER = __symbol__2("rejectionHandledHandler");
1987
- function clearRejectedNoCatch(promise) {
1988
- if (promise[symbolState] === REJECTED_NO_CATCH) {
1989
- try {
1990
- const handler = Zone3[REJECTION_HANDLED_HANDLER];
1991
- if (handler && typeof handler === "function") {
1992
- handler.call(this, { rejection: promise[symbolValue], promise });
1993
- }
1994
- } catch (err) {
1995
- }
1996
- promise[symbolState] = REJECTED;
1997
- for (let i = 0; i < _uncaughtPromiseErrors.length; i++) {
1998
- if (promise === _uncaughtPromiseErrors[i].promise) {
1999
- _uncaughtPromiseErrors.splice(i, 1);
2000
- }
2001
- }
2002
- }
2003
- }
2004
- function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) {
2005
- clearRejectedNoCatch(promise);
2006
- const promiseState = promise[symbolState];
2007
- const delegate = promiseState ? typeof onFulfilled === "function" ? onFulfilled : forwardResolution : typeof onRejected === "function" ? onRejected : forwardRejection;
2008
- zone.scheduleMicroTask(source, () => {
2009
- try {
2010
- const parentPromiseValue = promise[symbolValue];
2011
- const isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally];
2012
- if (isFinallyPromise) {
2013
- chainPromise[symbolParentPromiseValue] = parentPromiseValue;
2014
- chainPromise[symbolParentPromiseState] = promiseState;
2015
- }
2016
- const value = zone.run(delegate, void 0, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]);
2017
- resolvePromise(chainPromise, true, value);
2018
- } catch (error) {
2019
- resolvePromise(chainPromise, false, error);
2020
- }
2021
- }, chainPromise);
2022
- }
2023
- const ZONE_AWARE_PROMISE_TO_STRING = "function ZoneAwarePromise() { [native code] }";
2024
- const noop = function() {
2025
- };
2026
- const AggregateError = global2.AggregateError;
2027
- class ZoneAwarePromise {
2028
- static toString() {
2029
- return ZONE_AWARE_PROMISE_TO_STRING;
2030
- }
2031
- static resolve(value) {
2032
- if (value instanceof ZoneAwarePromise) {
2033
- return value;
2034
- }
2035
- return resolvePromise(new this(null), RESOLVED, value);
2036
- }
2037
- static reject(error) {
2038
- return resolvePromise(new this(null), REJECTED, error);
2039
- }
2040
- static withResolvers() {
2041
- const result = {};
2042
- result.promise = new ZoneAwarePromise((res, rej) => {
2043
- result.resolve = res;
2044
- result.reject = rej;
2045
- });
2046
- return result;
2047
- }
2048
- static any(values) {
2049
- if (!values || typeof values[Symbol.iterator] !== "function") {
2050
- return Promise.reject(new AggregateError([], "All promises were rejected"));
2051
- }
2052
- const promises = [];
2053
- let count = 0;
2054
- try {
2055
- for (let v of values) {
2056
- count++;
2057
- promises.push(ZoneAwarePromise.resolve(v));
2058
- }
2059
- } catch (err) {
2060
- return Promise.reject(new AggregateError([], "All promises were rejected"));
2061
- }
2062
- if (count === 0) {
2063
- return Promise.reject(new AggregateError([], "All promises were rejected"));
2064
- }
2065
- let finished = false;
2066
- const errors = [];
2067
- return new ZoneAwarePromise((resolve, reject) => {
2068
- for (let i = 0; i < promises.length; i++) {
2069
- promises[i].then((v) => {
2070
- if (finished) {
2071
- return;
2072
- }
2073
- finished = true;
2074
- resolve(v);
2075
- }, (err) => {
2076
- errors.push(err);
2077
- count--;
2078
- if (count === 0) {
2079
- finished = true;
2080
- reject(new AggregateError(errors, "All promises were rejected"));
2081
- }
2082
- });
2083
- }
2084
- });
2085
- }
2086
- static race(values) {
2087
- let resolve;
2088
- let reject;
2089
- let promise = new this((res, rej) => {
2090
- resolve = res;
2091
- reject = rej;
2092
- });
2093
- function onResolve(value) {
2094
- resolve(value);
2095
- }
2096
- function onReject(error) {
2097
- reject(error);
2098
- }
2099
- for (let value of values) {
2100
- if (!isThenable(value)) {
2101
- value = this.resolve(value);
2102
- }
2103
- value.then(onResolve, onReject);
2104
- }
2105
- return promise;
2106
- }
2107
- static all(values) {
2108
- return ZoneAwarePromise.allWithCallback(values);
2109
- }
2110
- static allSettled(values) {
2111
- const P = this && this.prototype instanceof ZoneAwarePromise ? this : ZoneAwarePromise;
2112
- return P.allWithCallback(values, {
2113
- thenCallback: (value) => ({ status: "fulfilled", value }),
2114
- errorCallback: (err) => ({ status: "rejected", reason: err })
2115
- });
2116
- }
2117
- static allWithCallback(values, callback) {
2118
- let resolve;
2119
- let reject;
2120
- let promise = new this((res, rej) => {
2121
- resolve = res;
2122
- reject = rej;
2123
- });
2124
- let unresolvedCount = 2;
2125
- let valueIndex = 0;
2126
- const resolvedValues = [];
2127
- for (let value of values) {
2128
- if (!isThenable(value)) {
2129
- value = this.resolve(value);
2130
- }
2131
- const curValueIndex = valueIndex;
2132
- try {
2133
- value.then((value2) => {
2134
- resolvedValues[curValueIndex] = callback ? callback.thenCallback(value2) : value2;
2135
- unresolvedCount--;
2136
- if (unresolvedCount === 0) {
2137
- resolve(resolvedValues);
2138
- }
2139
- }, (err) => {
2140
- if (!callback) {
2141
- reject(err);
2142
- } else {
2143
- resolvedValues[curValueIndex] = callback.errorCallback(err);
2144
- unresolvedCount--;
2145
- if (unresolvedCount === 0) {
2146
- resolve(resolvedValues);
2147
- }
2148
- }
2149
- });
2150
- } catch (thenErr) {
2151
- reject(thenErr);
2152
- }
2153
- unresolvedCount++;
2154
- valueIndex++;
2155
- }
2156
- unresolvedCount -= 2;
2157
- if (unresolvedCount === 0) {
2158
- resolve(resolvedValues);
2159
- }
2160
- return promise;
2161
- }
2162
- constructor(executor) {
2163
- const promise = this;
2164
- if (!(promise instanceof ZoneAwarePromise)) {
2165
- throw new Error("Must be an instanceof Promise.");
2166
- }
2167
- promise[symbolState] = UNRESOLVED;
2168
- promise[symbolValue] = [];
2169
- try {
2170
- const onceWrapper = once();
2171
- executor && executor(onceWrapper(makeResolver(promise, RESOLVED)), onceWrapper(makeResolver(promise, REJECTED)));
2172
- } catch (error) {
2173
- resolvePromise(promise, false, error);
2174
- }
2175
- }
2176
- get [Symbol.toStringTag]() {
2177
- return "Promise";
2178
- }
2179
- get [Symbol.species]() {
2180
- return ZoneAwarePromise;
2181
- }
2182
- then(onFulfilled, onRejected) {
2183
- let C = this.constructor?.[Symbol.species];
2184
- if (!C || typeof C !== "function") {
2185
- C = this.constructor || ZoneAwarePromise;
2186
- }
2187
- const chainPromise = new C(noop);
2188
- const zone = Zone3.current;
2189
- if (this[symbolState] == UNRESOLVED) {
2190
- this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected);
2191
- } else {
2192
- scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected);
2193
- }
2194
- return chainPromise;
2195
- }
2196
- catch(onRejected) {
2197
- return this.then(null, onRejected);
2198
- }
2199
- finally(onFinally) {
2200
- let C = this.constructor?.[Symbol.species];
2201
- if (!C || typeof C !== "function") {
2202
- C = ZoneAwarePromise;
2203
- }
2204
- const chainPromise = new C(noop);
2205
- chainPromise[symbolFinally] = symbolFinally;
2206
- const zone = Zone3.current;
2207
- if (this[symbolState] == UNRESOLVED) {
2208
- this[symbolValue].push(zone, chainPromise, onFinally, onFinally);
2209
- } else {
2210
- scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally);
2211
- }
2212
- return chainPromise;
2213
- }
2214
- }
2215
- ZoneAwarePromise["resolve"] = ZoneAwarePromise.resolve;
2216
- ZoneAwarePromise["reject"] = ZoneAwarePromise.reject;
2217
- ZoneAwarePromise["race"] = ZoneAwarePromise.race;
2218
- ZoneAwarePromise["all"] = ZoneAwarePromise.all;
2219
- const NativePromise = global2[symbolPromise] = global2["Promise"];
2220
- global2["Promise"] = ZoneAwarePromise;
2221
- const symbolThenPatched = __symbol__2("thenPatched");
2222
- function patchThen(Ctor) {
2223
- const proto = Ctor.prototype;
2224
- const prop = ObjectGetOwnPropertyDescriptor2(proto, "then");
2225
- if (prop && (prop.writable === false || !prop.configurable)) {
2226
- return;
2227
- }
2228
- const originalThen = proto.then;
2229
- proto[symbolThen] = originalThen;
2230
- Ctor.prototype.then = function(onResolve, onReject) {
2231
- const wrapped = new ZoneAwarePromise((resolve, reject) => {
2232
- originalThen.call(this, resolve, reject);
2233
- });
2234
- return wrapped.then(onResolve, onReject);
2235
- };
2236
- Ctor[symbolThenPatched] = true;
2237
- }
2238
- api.patchThen = patchThen;
2239
- function zoneify(fn) {
2240
- return function(self2, args) {
2241
- let resultPromise = fn.apply(self2, args);
2242
- if (resultPromise instanceof ZoneAwarePromise) {
2243
- return resultPromise;
2244
- }
2245
- let ctor = resultPromise.constructor;
2246
- if (!ctor[symbolThenPatched]) {
2247
- patchThen(ctor);
2248
- }
2249
- return resultPromise;
2250
- };
2251
- }
2252
- if (NativePromise) {
2253
- patchThen(NativePromise);
2254
- patchMethod(global2, "fetch", (delegate) => zoneify(delegate));
2255
- }
2256
- Promise[Zone3.__symbol__("uncaughtPromiseErrors")] = _uncaughtPromiseErrors;
2257
- return ZoneAwarePromise;
2258
- });
2259
- }
2260
- function patchToString(Zone2) {
2261
- Zone2.__load_patch("toString", (global2) => {
2262
- const originalFunctionToString = Function.prototype.toString;
2263
- const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol("OriginalDelegate");
2264
- const PROMISE_SYMBOL = zoneSymbol("Promise");
2265
- const ERROR_SYMBOL = zoneSymbol("Error");
2266
- const newFunctionToString = function toString() {
2267
- if (typeof this === "function") {
2268
- const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL];
2269
- if (originalDelegate) {
2270
- if (typeof originalDelegate === "function") {
2271
- return originalFunctionToString.call(originalDelegate);
2272
- } else {
2273
- return Object.prototype.toString.call(originalDelegate);
2274
- }
2275
- }
2276
- if (this === Promise) {
2277
- const nativePromise = global2[PROMISE_SYMBOL];
2278
- if (nativePromise) {
2279
- return originalFunctionToString.call(nativePromise);
2280
- }
2281
- }
2282
- if (this === Error) {
2283
- const nativeError = global2[ERROR_SYMBOL];
2284
- if (nativeError) {
2285
- return originalFunctionToString.call(nativeError);
2286
- }
2287
- }
2288
- }
2289
- return originalFunctionToString.call(this);
2290
- };
2291
- newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString;
2292
- Function.prototype.toString = newFunctionToString;
2293
- const originalObjectToString = Object.prototype.toString;
2294
- const PROMISE_OBJECT_TO_STRING = "[object Promise]";
2295
- Object.prototype.toString = function() {
2296
- if (typeof Promise === "function" && this instanceof Promise) {
2297
- return PROMISE_OBJECT_TO_STRING;
2298
- }
2299
- return originalObjectToString.call(this);
2300
- };
2301
- });
2302
- }
2303
- function patchCallbacks(api, target, targetName, method, callbacks) {
2304
- const symbol = Zone.__symbol__(method);
2305
- if (target[symbol]) {
2306
- return;
2307
- }
2308
- const nativeDelegate = target[symbol] = target[method];
2309
- target[method] = function(name, opts, options) {
2310
- if (opts && opts.prototype) {
2311
- callbacks.forEach(function(callback) {
2312
- const source = `${targetName}.${method}::` + callback;
2313
- const prototype = opts.prototype;
2314
- try {
2315
- if (prototype.hasOwnProperty(callback)) {
2316
- const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback);
2317
- if (descriptor && descriptor.value) {
2318
- descriptor.value = api.wrapWithCurrentZone(descriptor.value, source);
2319
- api._redefineProperty(opts.prototype, callback, descriptor);
2320
- } else if (prototype[callback]) {
2321
- prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
2322
- }
2323
- } else if (prototype[callback]) {
2324
- prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source);
2325
- }
2326
- } catch {
2327
- }
2328
- });
2329
- }
2330
- return nativeDelegate.call(target, name, opts, options);
2331
- };
2332
- api.attachOriginToPatched(target[method], nativeDelegate);
2333
- }
2334
- function patchUtil(Zone2) {
2335
- Zone2.__load_patch("util", (global2, Zone3, api) => {
2336
- const eventNames = getOnEventNames(global2);
2337
- api.patchOnProperties = patchOnProperties;
2338
- api.patchMethod = patchMethod;
2339
- api.bindArguments = bindArguments;
2340
- api.patchMacroTask = patchMacroTask;
2341
- const SYMBOL_BLACK_LISTED_EVENTS = Zone3.__symbol__("BLACK_LISTED_EVENTS");
2342
- const SYMBOL_UNPATCHED_EVENTS = Zone3.__symbol__("UNPATCHED_EVENTS");
2343
- if (global2[SYMBOL_UNPATCHED_EVENTS]) {
2344
- global2[SYMBOL_BLACK_LISTED_EVENTS] = global2[SYMBOL_UNPATCHED_EVENTS];
2345
- }
2346
- if (global2[SYMBOL_BLACK_LISTED_EVENTS]) {
2347
- Zone3[SYMBOL_BLACK_LISTED_EVENTS] = Zone3[SYMBOL_UNPATCHED_EVENTS] = global2[SYMBOL_BLACK_LISTED_EVENTS];
2348
- }
2349
- api.patchEventPrototype = patchEventPrototype;
2350
- api.patchEventTarget = patchEventTarget;
2351
- api.isIEOrEdge = isIEOrEdge;
2352
- api.ObjectDefineProperty = ObjectDefineProperty;
2353
- api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
2354
- api.ObjectCreate = ObjectCreate;
2355
- api.ArraySlice = ArraySlice;
2356
- api.patchClass = patchClass;
2357
- api.wrapWithCurrentZone = wrapWithCurrentZone;
2358
- api.filterProperties = filterProperties;
2359
- api.attachOriginToPatched = attachOriginToPatched;
2360
- api._redefineProperty = Object.defineProperty;
2361
- api.patchCallbacks = patchCallbacks;
2362
- api.getGlobalObjects = () => ({
2363
- globalSources,
2364
- zoneSymbolEventNames,
2365
- eventNames,
2366
- isBrowser,
2367
- isMix,
2368
- isNode,
2369
- TRUE_STR,
2370
- FALSE_STR,
2371
- ZONE_SYMBOL_PREFIX,
2372
- ADD_EVENT_LISTENER_STR,
2373
- REMOVE_EVENT_LISTENER_STR
2374
- });
2375
- });
2376
- }
2377
- function patchCommon(Zone2) {
2378
- patchPromise(Zone2);
2379
- patchToString(Zone2);
2380
- patchUtil(Zone2);
2381
- }
2382
- var Zone$1 = loadZone();
2383
- patchCommon(Zone$1);
2384
- patchBrowser(Zone$1);
2385
- /*! Bundled license information:
2386
-
2387
- zone.js/fesm2015/zone.js:
2388
- (**
2389
- * @license Angular v<unknown>
2390
- * (c) 2010-2025 Google LLC. https://angular.io/
2391
- * License: MIT
2392
- *)
2393
- */
2394
- //# sourceMappingURL=zone__js.js.map