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