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