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