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