diff --git a/dist/async-test.js b/dist/async-test.js index ff32608d3..e71ba6392 100644 --- a/dist/async-test.js +++ b/dist/async-test.js @@ -1,68 +1,81 @@ -(function () { - var AsyncTestZoneSpec = (function () { - function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { - this._pendingMicroTasks = false; - this._pendingMacroTasks = false; - this._alreadyErrored = false; - this.runZone = Zone.current; - this._finishCallback = finishCallback; - this._failCallback = failCallback; - this.name = 'asyncTestZone for ' + namePrefix; +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +var AsyncTestZoneSpec = (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this.runZone = Zone.current; + this._finishCallback = finishCallback; + this._failCallback = failCallback; + this.name = 'asyncTestZone for ' + namePrefix; + } + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { + _this._finishCallback(); + } + }, 0); + }); } - AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { - var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { - // We do this because we would like to catch unhandled rejected promises. - this.runZone.run(function () { - setTimeout(function () { - if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this._finishCallback(); - } - }, 0); - }); - } - }; - // Note - we need to use onInvoke at the moment to call finish when a test is - // fully synchronous. TODO(juliemr): remove this when the logic for - // onHasTask changes and it calls whenever the task queues are dirty. - AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - try { - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - finally { - this._finishCallbackIfDone(); - } - }; - AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - // Let the parent try to handle the error. - var result = parentZoneDelegate.handleError(targetZone, error); - if (result) { - this._failCallback(error); - this._alreadyErrored = true; - } - return false; - }; - AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, currentZone, targetZone, task) { - if (task.type == 'macroTask' && task.source == 'setInterval') { - this._failCallback('Cannot use setInterval from within an async zone test.'); - return; - } - return delegate.scheduleTask(targetZone, task); - }; - AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { - delegate.hasTask(target, hasTaskState); - if (hasTaskState.change == 'microTask') { - this._pendingMicroTasks = hasTaskState.microTask; - this._finishCallbackIfDone(); - } - else if (hasTaskState.change == 'macroTask') { - this._pendingMacroTasks = hasTaskState.macroTask; - this._finishCallbackIfDone(); - } - }; - return AsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; -})(); \ No newline at end of file + }; + // Note - we need to use onInvoke at the moment to call finish when a test is + // fully synchronous. TODO(juliemr): remove this when the logic for + // onHasTask changes and it calls whenever the task queues are dirty. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + this._finishCallbackIfDone(); + } + }; + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this._failCallback(error); + this._alreadyErrored = true; + } + return false; + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, currentZone, targetZone, task) { + if (task.type == 'macroTask' && task.source == 'setInterval') { + this._failCallback('Cannot use setInterval from within an async zone test.'); + return; + } + return delegate.scheduleTask(targetZone, task); + }; + AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + delegate.hasTask(target, hasTaskState); + if (hasTaskState.change == 'microTask') { + this._pendingMicroTasks = hasTaskState.microTask; + this._finishCallbackIfDone(); + } + else if (hasTaskState.change == 'macroTask') { + this._pendingMacroTasks = hasTaskState.macroTask; + this._finishCallbackIfDone(); + } + }; + return AsyncTestZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + +}))); diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index 937e1b8a2..3ff9f9f2d 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -1,238 +1,251 @@ -(function (global) { - var Scheduler = (function () { - function Scheduler() { - // Next scheduler id. - this.nextId = 0; - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - this._schedulerQueue = []; - // Current simulated time in millis. - this._currentTime = 0; +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +var Scheduler = (function () { + function Scheduler() { + // Next scheduler id. + this.nextId = 0; + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + } + Scheduler.prototype.scheduleFunction = function (cb, delay, args, id) { + if (args === void 0) { args = []; } + if (id === void 0) { id = -1; } + var currentId = id < 0 ? this.nextId++ : id; + var endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + var newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay + }; + var i = 0; + for (; i < this._schedulerQueue.length; i++) { + var currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } } - Scheduler.prototype.scheduleFunction = function (cb, delay, args, id) { - if (args === void 0) { args = []; } - if (id === void 0) { id = -1; } - var currentId = id < 0 ? this.nextId++ : id; - var endTime = this._currentTime + delay; - // Insert so that scheduler queue remains sorted by end time. - var newEntry = { - endTime: endTime, - id: currentId, - func: cb, - args: args, - delay: delay - }; - var i = 0; - for (; i < this._schedulerQueue.length; i++) { - var currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; - } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + }; + Scheduler.prototype.removeScheduledFunctionWithId = function (id) { + for (var i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - }; - Scheduler.prototype.removeScheduledFunctionWithId = function (id) { - for (var i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; - } + } + }; + Scheduler.prototype.tick = function (millis) { + if (millis === void 0) { millis = 0; } + this._currentTime += millis; + while (this._schedulerQueue.length > 0) { + var current = this._schedulerQueue[0]; + if (this._currentTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; } - }; - Scheduler.prototype.tick = function (millis) { - if (millis === void 0) { millis = 0; } - this._currentTime += millis; - while (this._schedulerQueue.length > 0) { - var current = this._schedulerQueue[0]; - if (this._currentTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. + else { + // Time to run scheduled function. Remove it from the head of queue. + var current_1 = this._schedulerQueue.shift(); + var retval = current_1.func.apply(global, current_1.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. break; } - else { - // Time to run scheduled function. Remove it from the head of queue. - var current_1 = this._schedulerQueue.shift(); - var retval = current_1.func.apply(global, current_1.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } } - }; - return Scheduler; - }()); - var FakeAsyncTestZoneSpec = (function () { - function FakeAsyncTestZoneSpec(namePrefix) { - this._scheduler = new Scheduler(); - this._microtasks = []; - this._lastError = null; - this._uncaughtPromiseErrors = Promise[Zone['__symbol__']('uncaughtPromiseErrors')]; - this.pendingPeriodicTimers = []; - this.pendingTimers = []; - this.properties = { 'FakeAsyncTestZoneSpec': this }; - this.name = 'fakeAsyncTestZone for ' + namePrefix; } - FakeAsyncTestZoneSpec.assertInZone = function () { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - }; - FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { - var _this = this; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i - 0] = arguments[_i]; - } - fn.apply(global, args); - if (_this._lastError === null) { - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); - } - // Flush microtasks only on success. - _this.flushMicrotasks(); - } - else { - if (completers.onError != null) { - completers.onError.apply(global); - } - } - // Return true if there were no errors, false otherwise. - return _this._lastError === null; - }; - }; - FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { - var index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); - } - }; - FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); - }; - }; - FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { - var _this = this; - return function () { - // Requeue the timer callback if it's not been canceled. - if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { - _this._scheduler.scheduleFunction(fn, interval, args, id); - } - }; - }; - FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); - }; - }; - FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args) { - var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); - var id = this._scheduler.scheduleFunction(cb, delay, args); - this.pendingTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { + }; + return Scheduler; +}()); +var FakeAsyncTestZoneSpec = (function () { + function FakeAsyncTestZoneSpec(namePrefix) { + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone['__symbol__']('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + } + FakeAsyncTestZoneSpec.assertInZone = function () { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + }; + FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { + var _this = this; + return function () { var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; } - var id = this._scheduler.nextId; - var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; - var cb = this._fnAndFlush(fn, completers); - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args); - this.pendingPeriodicTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { - var error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - }; - FakeAsyncTestZoneSpec.prototype.tick = function (millis) { - if (millis === void 0) { millis = 0; } - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); + fn.apply(global, args); + if (_this._lastError === null) { + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + _this.flushMicrotasks(); } - }; - FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { - var _this = this; - FakeAsyncTestZoneSpec.assertInZone(); - var flushErrors = function () { - if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - _this._resetLastErrorAndThrow(); + else { + if (completers.onError != null) { + completers.onError.apply(global); } - }; - while (this._microtasks.length > 0) { - var microtask = this._microtasks.shift(); - microtask(); } - flushErrors(); - }; - FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - this._microtasks.push(task.invoke); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data['handleId'] = - this._setTimeout(task.invoke, task.data['delay'], task.data['args']); - break; - case 'setInterval': - task.data['handleId'] = - this._setInterval(task.invoke, task.data['delay'], task.data['args']); - break; - case 'XMLHttpRequest.send': - throw new Error('Cannot make XHRs from within a fake async test.'); - default: - task = delegate.scheduleTask(target, task); - } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; + // Return true if there were no errors, false otherwise. + return _this._lastError === null; + }; + }; + FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { + var index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); + } + }; + FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { + var _this = this; + return function () { + // Requeue the timer callback if it's not been canceled. + if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { + _this._scheduler.scheduleFunction(fn, interval, args, id); } - return task; }; - FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - switch (task.source) { - case 'setTimeout': - return this._clearTimeout(task.data['handleId']); - case 'setInterval': - return this._clearInterval(task.data['handleId']); - default: - return delegate.cancelTask(target, task); + }; + FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args) { + var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + var id = this._scheduler.scheduleFunction(cb, delay, args); + this.pendingTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + var id = this._scheduler.nextId; + var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + var cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args); + this.pendingPeriodicTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { + var error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + }; + FakeAsyncTestZoneSpec.prototype.tick = function (millis) { + if (millis === void 0) { millis = 0; } + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + }; + FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { + var _this = this; + FakeAsyncTestZoneSpec.assertInZone(); + var flushErrors = function () { + if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + _this._resetLastErrorAndThrow(); } }; - FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - this._lastError = error; - return false; // Don't propagate error to parent zone. - }; - return FakeAsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); \ No newline at end of file + while (this._microtasks.length > 0) { + var microtask = this._microtasks.shift(); + microtask(); + } + flushErrors(); + }; + FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + this._microtasks.push(task.invoke); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = + this._setTimeout(task.invoke, task.data['delay'], task.data['args']); + break; + case 'setInterval': + task.data['handleId'] = + this._setInterval(task.invoke, task.data['delay'], task.data['args']); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test.'); + default: + task = delegate.scheduleTask(target, task); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + return delegate.cancelTask(target, task); + } + }; + FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + }; + return FakeAsyncTestZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; + +}))); diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index c088e34d0..48bd03c1c 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -1,3 +1,16 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + var __extends = (undefined && undefined.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } @@ -108,4 +121,6 @@ var __extends = (undefined && undefined.__extends) || function (d, b) { }; return ZoneQueueRunner; }(QueueRunner)); -})(); \ No newline at end of file +})(); + +}))); diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index 5f185560f..916e90019 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -var __extends=function(e,n){function r(){this.constructor=e}for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)};!function(){function e(e){return function(){return i.run(e,this,arguments)}}function n(e){return 0==e.length?function(){return c.run(e,this)}:function(n){return c.run(e,this,[n])}}if(!Zone)throw new Error("Missing: zone.js");if("undefined"==typeof jasmine)throw new Error("Missing: jasmine.js");if(jasmine.__zone_patch__)throw new Error("'jasmine' has already been patched with 'Zone'.");jasmine.__zone_patch__=!0;var r=Zone.SyncTestZoneSpec,t=Zone.ProxyZoneSpec;if(!r)throw new Error("Missing: SyncTestZoneSpec");if(!t)throw new Error("Missing: ProxyZoneSpec");var o=Zone.current,i=o.fork(new r("jasmine.describe")),c=null,u=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var r=u[n];u[n]=function(n,t){return r.call(this,n,e(t))}}),["it","xit","fit"].forEach(function(e){var r=u[e];u[e]=function(e,t,o){return arguments[1]=n(t),r.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var r=u[e];u[e]=function(e,t){return arguments[0]=n(e),r.apply(this,arguments)}});var s=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){n.onComplete=function(e){return function(){c=null,o.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete),e.call(this,n)}return __extends(n,e),n.prototype.execute=function(){var n=this;if(Zone.current!==o)throw new Error("Unexpected Zone: "+Zone.current.name);c=o.fork(new t),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return e.prototype.execute.call(n)})},n}(s)}(); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";var e=function(e,n){function r(){this.constructor=e}for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)};!function(){function n(e){return function(){return c.run(e,this,arguments)}}function r(e){return 0==e.length?function(){return u.run(e,this)}:function(n){return u.run(e,this,[n])}}if(!Zone)throw new Error("Missing: zone.js");if("undefined"==typeof jasmine)throw new Error("Missing: jasmine.js");if(jasmine.__zone_patch__)throw new Error("'jasmine' has already been patched with 'Zone'.");jasmine.__zone_patch__=!0;var t=Zone.SyncTestZoneSpec,o=Zone.ProxyZoneSpec;if(!t)throw new Error("Missing: SyncTestZoneSpec");if(!o)throw new Error("Missing: ProxyZoneSpec");var i=Zone.current,c=i.fork(new t("jasmine.describe")),u=null,s=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(e){var r=s[e];s[e]=function(e,t){return r.call(this,e,n(t))}}),["it","xit","fit"].forEach(function(e){var n=s[e];s[e]=function(e,t,o){return arguments[1]=r(t),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=s[e];s[e]=function(e,t){return arguments[0]=r(e),n.apply(this,arguments)}});var f=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(e){e.onComplete=function(e){return function(){u=null,i.scheduleMicroTask("jasmine.onComplete",e)}}(e.onComplete),n.call(this,e)}return e(r,n),r.prototype.execute=function(){var e=this;if(Zone.current!==i)throw new Error("Unexpected Zone: "+Zone.current.name);u=i.fork(new o),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return n.prototype.execute.call(e)})},r}(f)}()}); \ No newline at end of file diff --git a/dist/long-stack-trace-zone.js b/dist/long-stack-trace-zone.js index 33f2fff0a..e68ac62fc 100644 --- a/dist/long-stack-trace-zone.js +++ b/dist/long-stack-trace-zone.js @@ -1,132 +1,145 @@ -(function () { - var NEWLINE = '\n'; - var SEP = ' ------------- '; - var IGNORE_FRAMES = []; - var creationTrace = '__creationTrace__'; - var LongStackTrace = (function () { - function LongStackTrace() { - this.error = getStacktrace(); - this.timestamp = new Date(); - } - return LongStackTrace; - }()); - function getStacktraceWithUncaughtError() { - return new Error('STACKTRACE TRACKING'); +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +var NEWLINE = '\n'; +var SEP = ' ------------- '; +var IGNORE_FRAMES = []; +var creationTrace = '__creationTrace__'; +var LongStackTrace = (function () { + function LongStackTrace() { + this.error = getStacktrace(); + this.timestamp = new Date(); } - function getStacktraceWithCaughtError() { - try { - throw getStacktraceWithUncaughtError(); - } - catch (e) { - return e; - } + return LongStackTrace; +}()); +function getStacktraceWithUncaughtError() { + return new Error('STACKTRACE TRACKING'); +} +function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); } - // Some implementations of exception handling don't create a stack trace if the exception - // isn't thrown, however it's faster not to actually throw the exception. - var error = getStacktraceWithUncaughtError(); - var coughtError = getStacktraceWithCaughtError(); - var getStacktrace = error.stack - ? getStacktraceWithUncaughtError - : (coughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); - function getFrames(error) { - return error.stack ? error.stack.split(NEWLINE) : []; + catch (e) { + return e; } - function addErrorStack(lines, error) { - var trace = getFrames(error); - for (var i = 0; i < trace.length; i++) { - var frame = trace[i]; - // Filter out the Frames which are part of stack capturing. - if (!(i < IGNORE_FRAMES.length && IGNORE_FRAMES[i] === frame)) { - lines.push(trace[i]); - } +} +// Some implementations of exception handling don't create a stack trace if the exception +// isn't thrown, however it's faster not to actually throw the exception. +var error = getStacktraceWithUncaughtError(); +var coughtError = getStacktraceWithCaughtError(); +var getStacktrace = error.stack + ? getStacktraceWithUncaughtError + : (coughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); +function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; +} +function addErrorStack(lines, error) { + var trace = getFrames(error); + for (var i = 0; i < trace.length; i++) { + var frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!(i < IGNORE_FRAMES.length && IGNORE_FRAMES[i] === frame)) { + lines.push(trace[i]); } } - function renderLongStackTrace(frames, stack) { - var longTrace = [stack]; - if (frames) { - var timestamp = new Date().getTime(); - for (var i = 0; i < frames.length; i++) { - var traceFrames = frames[i]; - var lastTime = traceFrames.timestamp; - longTrace.push(SEP + " Elapsed: " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime + " " + SEP); - addErrorStack(longTrace, traceFrames.error); - timestamp = lastTime.getTime(); - } +} +function renderLongStackTrace(frames, stack) { + var longTrace = [stack]; + if (frames) { + var timestamp = new Date().getTime(); + for (var i = 0; i < frames.length; i++) { + var traceFrames = frames[i]; + var lastTime = traceFrames.timestamp; + longTrace.push(SEP + " Elapsed: " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime + " " + SEP); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); } - return longTrace.join(NEWLINE); } - Zone['longStackTraceZoneSpec'] = { - name: 'long-stack-trace', - longStackTraceLimit: 10, - onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { - var currentTask = Zone.currentTask; - var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; - trace = [new LongStackTrace()].concat(trace); - if (trace.length > this.longStackTraceLimit) { - trace.length = this.longStackTraceLimit; + return longTrace.join(NEWLINE); +} +Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + var currentTask = Zone.currentTask; + var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; + } + if (!task.data) + task.data = {}; + task.data[creationTrace] = trace; + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + var parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + var stackSetSucceded = null; + try { + var descriptor = Object.getOwnPropertyDescriptor(error, 'stack'); + if (descriptor && descriptor.configurable) { + var delegateGet_1 = descriptor.get; + var value_1 = descriptor.value; + descriptor = { + get: function () { + return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], delegateGet_1 ? delegateGet_1.apply(this) : value_1); + } + }; + Object.defineProperty(error, 'stack', descriptor); + stackSetSucceded = true; + } } - if (!task.data) - task.data = {}; - task.data[creationTrace] = trace; - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { - var parentTask = Zone.currentTask || error.task; - if (error instanceof Error && parentTask) { - var stackSetSucceded = null; + catch (e) { } + var longStack = stackSetSucceded ? null : renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + if (!stackSetSucceded) { try { - var descriptor = Object.getOwnPropertyDescriptor(error, 'stack'); - if (descriptor && descriptor.configurable) { - var delegateGet_1 = descriptor.get; - var value_1 = descriptor.value; - descriptor = { - get: function () { - return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], delegateGet_1 ? delegateGet_1.apply(this) : value_1); - } - }; - Object.defineProperty(error, 'stack', descriptor); - stackSetSucceded = true; - } + stackSetSucceded = error.stack = longStack; } catch (e) { } - var longStack = stackSetSucceded ? null : renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); - if (!stackSetSucceded) { - try { - stackSetSucceded = error.stack = longStack; - } - catch (e) { } - } - if (!stackSetSucceded) { - try { - stackSetSucceded = error.longStack = longStack; - } - catch (e) { } + } + if (!stackSetSucceded) { + try { + stackSetSucceded = error.longStack = longStack; } + catch (e) { } } - return parentZoneDelegate.handleError(targetZone, error); - } - }; - function captureStackTraces(stackTraces, count) { - if (count > 0) { - stackTraces.push(getFrames((new LongStackTrace()).error)); - captureStackTraces(stackTraces, count - 1); } + return parentZoneDelegate.handleError(targetZone, error); } - function computeIgnoreFrames() { - var frames = []; - captureStackTraces(frames, 2); - var frames1 = frames[0]; - var frames2 = frames[1]; - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - var frame2 = frames2[i]; - if (frame1 === frame2) { - IGNORE_FRAMES.push(frame1); - } - else { - break; - } +}; +function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); + } +} +function computeIgnoreFrames() { + var frames = []; + captureStackTraces(frames, 2); + var frames1 = frames[0]; + var frames2 = frames[1]; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + var frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES.push(frame1); + } + else { + break; } } - computeIgnoreFrames(); -})(); \ No newline at end of file +} +computeIgnoreFrames(); + +}))); diff --git a/dist/long-stack-trace-zone.min.js b/dist/long-stack-trace-zone.min.js index b64649941..db33700a3 100644 --- a/dist/long-stack-trace-zone.min.js +++ b/dist/long-stack-trace-zone.min.js @@ -1 +1 @@ -!function(){function t(){return new Error("STACKTRACE TRACKING")}function r(){try{throw t()}catch(r){return r}}function a(t){return t.stack?t.stack.split(i):[]}function n(t,r){for(var n=a(r),e=0;e0&&(t.push(a((new l).error)),c(t,r-1))}function o(){var t=[];c(t,2);for(var r=t[0],a=t[1],n=0;nthis.longStackTraceLimit&&(c.length=this.longStackTraceLimit),n.data||(n.data={}),n.data[f]=c,t.scheduleTask(a,n)},onHandleError:function(t,r,a,n){var c=Zone.currentTask||n.task;if(n instanceof Error&&c){var o=null;try{var i=Object.getOwnPropertyDescriptor(n,"stack");if(i&&i.configurable){var u=i.get,s=i.value;i={get:function(){return e(c.data&&c.data[f],u?u.apply(this):s)}},Object.defineProperty(n,"stack",i),o=!0}}catch(l){}var h=o?null:e(c.data&&c.data[f],n.stack);if(!o)try{o=n.stack=h}catch(l){}if(!o)try{o=n.longStack=h}catch(l){}}return t.handleError(a,n)}},o()}(); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(this,function(){"use strict";function t(){return new Error("STACKTRACE TRACKING")}function e(){try{throw t()}catch(e){return e}}function n(t){return t.stack?t.stack.split(i):[]}function r(t,e){for(var r=n(e),a=0;a0&&(t.push(n((new l).error)),c(t,e-1))}function o(){var t=[];c(t,2);for(var e=t[0],n=t[1],r=0;rthis.longStackTraceLimit&&(c.length=this.longStackTraceLimit),r.data||(r.data={}),r.data[f]=c,t.scheduleTask(n,r)},onHandleError:function(t,e,n,r){var c=Zone.currentTask||r.task;if(r instanceof Error&&c){var o=null;try{var i=Object.getOwnPropertyDescriptor(r,"stack");if(i&&i.configurable){var u=i.get,s=i.value;i={get:function(){return a(c.data&&c.data[f],u?u.apply(this):s)}},Object.defineProperty(r,"stack",i),o=!0}}catch(l){}var h=o?null:a(c.data&&c.data[f],r.stack);if(!o)try{o=r.stack=h}catch(l){}if(!o)try{o=r.longStack=h}catch(l){}}return t.handleError(n,r)}},o()}); \ No newline at end of file diff --git a/dist/proxy.js b/dist/proxy.js index a3d0f9972..bc1d8e8b2 100644 --- a/dist/proxy.js +++ b/dist/proxy.js @@ -1,108 +1,121 @@ -(function () { - var ProxyZoneSpec = (function () { - function ProxyZoneSpec(defaultSpecDelegate) { - if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } - this.defaultSpecDelegate = defaultSpecDelegate; - this.name = 'ProxyZone'; - this.properties = { 'ProxyZoneSpec': this }; - this.propertyKeys = null; - this.setDelegate(defaultSpecDelegate); - } - ProxyZoneSpec.get = function () { - return Zone.current.get('ProxyZoneSpec'); - }; - ProxyZoneSpec.isLoaded = function () { - return ProxyZoneSpec.get() instanceof ProxyZoneSpec; - }; - ProxyZoneSpec.assertPresent = function () { - if (!this.isLoaded()) { - throw new Error("Expected to be running in 'ProxyZone', but it was not found."); - } - return ProxyZoneSpec.get(); - }; - ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { - var _this = this; - this._delegateSpec = delegateSpec; - this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); - this.propertyKeys = null; - if (delegateSpec && delegateSpec.properties) { - this.propertyKeys = Object.keys(delegateSpec.properties); - this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); - } - }; - ProxyZoneSpec.prototype.getDelegate = function () { - return this._delegateSpec; - }; - ProxyZoneSpec.prototype.resetDelegate = function () { - this.setDelegate(this.defaultSpecDelegate); - }; - ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { - if (this._delegateSpec && this._delegateSpec.onFork) { - return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); - } - else { - return parentZoneDelegate.fork(targetZone, zoneSpec); - } - }; - ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { - if (this._delegateSpec && this._delegateSpec.onIntercept) { - return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); - } - else { - return parentZoneDelegate.intercept(targetZone, delegate, source); - } - }; - ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - if (this._delegateSpec && this._delegateSpec.onInvoke) { - return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); - } - else { - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - }; - ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - if (this._delegateSpec && this._delegateSpec.onHandleError) { - return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); - } - else { - return parentZoneDelegate.handleError(targetZone, error); - } - }; - ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (this._delegateSpec && this._delegateSpec.onScheduleTask) { - return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.scheduleTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (this._delegateSpec && this._delegateSpec.onFork) { - return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); - } - else { - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } - }; - ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (this._delegateSpec && this._delegateSpec.onCancelTask) { - return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.cancelTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { - if (this._delegateSpec && this._delegateSpec.onHasTask) { - this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); - } - else { - delegate.hasTask(target, hasTaskState); - } - }; - return ProxyZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['ProxyZoneSpec'] = ProxyZoneSpec; -})(); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +var ProxyZoneSpec = (function () { + function ProxyZoneSpec(defaultSpecDelegate) { + if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } + this.defaultSpecDelegate = defaultSpecDelegate; + this.name = 'ProxyZone'; + this.properties = { 'ProxyZoneSpec': this }; + this.propertyKeys = null; + this.setDelegate(defaultSpecDelegate); + } + ProxyZoneSpec.get = function () { + return Zone.current.get('ProxyZoneSpec'); + }; + ProxyZoneSpec.isLoaded = function () { + return ProxyZoneSpec.get() instanceof ProxyZoneSpec; + }; + ProxyZoneSpec.assertPresent = function () { + if (!this.isLoaded()) { + throw new Error("Expected to be running in 'ProxyZone', but it was not found."); + } + return ProxyZoneSpec.get(); + }; + ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { + var _this = this; + this._delegateSpec = delegateSpec; + this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); + this.propertyKeys = null; + if (delegateSpec && delegateSpec.properties) { + this.propertyKeys = Object.keys(delegateSpec.properties); + this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); + } + }; + ProxyZoneSpec.prototype.getDelegate = function () { + return this._delegateSpec; + }; + ProxyZoneSpec.prototype.resetDelegate = function () { + this.setDelegate(this.defaultSpecDelegate); + }; + ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); + } + else { + return parentZoneDelegate.fork(targetZone, zoneSpec); + } + }; + ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { + if (this._delegateSpec && this._delegateSpec.onIntercept) { + return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); + } + else { + return parentZoneDelegate.intercept(targetZone, delegate, source); + } + }; + ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + if (this._delegateSpec && this._delegateSpec.onInvoke) { + return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); + } + else { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + }; + ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + if (this._delegateSpec && this._delegateSpec.onHandleError) { + return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); + } + else { + return parentZoneDelegate.handleError(targetZone, error); + } + }; + ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (this._delegateSpec && this._delegateSpec.onScheduleTask) { + return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.scheduleTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); + } + else { + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } + }; + ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (this._delegateSpec && this._delegateSpec.onCancelTask) { + return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.cancelTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + if (this._delegateSpec && this._delegateSpec.onHasTask) { + this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); + } + else { + delegate.hasTask(target, hasTaskState); + } + }; + return ProxyZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['ProxyZoneSpec'] = ProxyZoneSpec; + +}))); diff --git a/dist/proxy.min.js b/dist/proxy.min.js index b2ee177bc..591695710 100644 --- a/dist/proxy.min.js +++ b/dist/proxy.min.js @@ -1 +1 @@ -!function(){var e=function(){function e(e){void 0===e&&(e=null),this.defaultSpecDelegate=e,this.name="ProxyZone",this.properties={ProxyZoneSpec:this},this.propertyKeys=null,this.setDelegate(e)}return e.get=function(){return Zone.current.get("ProxyZoneSpec")},e.isLoaded=function(){return e.get()instanceof e},e.assertPresent=function(){if(!this.isLoaded())throw new Error("Expected to be running in 'ProxyZone', but it was not found.");return e.get()},e.prototype.setDelegate=function(e){var t=this;this._delegateSpec=e,this.propertyKeys&&this.propertyKeys.forEach(function(e){return delete t.properties[e]}),this.propertyKeys=null,e&&e.properties&&(this.propertyKeys=Object.keys(e.properties),this.propertyKeys.forEach(function(n){return t.properties[n]=e.properties[n]}))},e.prototype.getDelegate=function(){return this._delegateSpec},e.prototype.resetDelegate=function(){this.setDelegate(this.defaultSpecDelegate)},e.prototype.onFork=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onFork?this._delegateSpec.onFork(e,t,n,o):e.fork(n,o)},e.prototype.onIntercept=function(e,t,n,o,r){return this._delegateSpec&&this._delegateSpec.onIntercept?this._delegateSpec.onIntercept(e,t,n,o,r):e.intercept(n,o,r)},e.prototype.onInvoke=function(e,t,n,o,r,s,p){return this._delegateSpec&&this._delegateSpec.onInvoke?this._delegateSpec.onInvoke(e,t,n,o,r,s,p):e.invoke(n,o,r,s,p)},e.prototype.onHandleError=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onHandleError?this._delegateSpec.onHandleError(e,t,n,o):e.handleError(n,o)},e.prototype.onScheduleTask=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onScheduleTask?this._delegateSpec.onScheduleTask(e,t,n,o):e.scheduleTask(n,o)},e.prototype.onInvokeTask=function(e,t,n,o,r,s){return this._delegateSpec&&this._delegateSpec.onFork?this._delegateSpec.onInvokeTask(e,t,n,o,r,s):e.invokeTask(n,o,r,s)},e.prototype.onCancelTask=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onCancelTask?this._delegateSpec.onCancelTask(e,t,n,o):e.cancelTask(n,o)},e.prototype.onHasTask=function(e,t,n,o){this._delegateSpec&&this._delegateSpec.onHasTask?this._delegateSpec.onHasTask(e,t,n,o):e.hasTask(n,o)},e}();Zone.ProxyZoneSpec=e}(); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";var e=function(){function e(e){void 0===e&&(e=null),this.defaultSpecDelegate=e,this.name="ProxyZone",this.properties={ProxyZoneSpec:this},this.propertyKeys=null,this.setDelegate(e)}return e.get=function(){return Zone.current.get("ProxyZoneSpec")},e.isLoaded=function(){return e.get()instanceof e},e.assertPresent=function(){if(!this.isLoaded())throw new Error("Expected to be running in 'ProxyZone', but it was not found.");return e.get()},e.prototype.setDelegate=function(e){var t=this;this._delegateSpec=e,this.propertyKeys&&this.propertyKeys.forEach(function(e){return delete t.properties[e]}),this.propertyKeys=null,e&&e.properties&&(this.propertyKeys=Object.keys(e.properties),this.propertyKeys.forEach(function(n){return t.properties[n]=e.properties[n]}))},e.prototype.getDelegate=function(){return this._delegateSpec},e.prototype.resetDelegate=function(){this.setDelegate(this.defaultSpecDelegate)},e.prototype.onFork=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onFork?this._delegateSpec.onFork(e,t,n,o):e.fork(n,o)},e.prototype.onIntercept=function(e,t,n,o,r){return this._delegateSpec&&this._delegateSpec.onIntercept?this._delegateSpec.onIntercept(e,t,n,o,r):e.intercept(n,o,r)},e.prototype.onInvoke=function(e,t,n,o,r,s,p){return this._delegateSpec&&this._delegateSpec.onInvoke?this._delegateSpec.onInvoke(e,t,n,o,r,s,p):e.invoke(n,o,r,s,p)},e.prototype.onHandleError=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onHandleError?this._delegateSpec.onHandleError(e,t,n,o):e.handleError(n,o)},e.prototype.onScheduleTask=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onScheduleTask?this._delegateSpec.onScheduleTask(e,t,n,o):e.scheduleTask(n,o)},e.prototype.onInvokeTask=function(e,t,n,o,r,s){return this._delegateSpec&&this._delegateSpec.onFork?this._delegateSpec.onInvokeTask(e,t,n,o,r,s):e.invokeTask(n,o,r,s)},e.prototype.onCancelTask=function(e,t,n,o){return this._delegateSpec&&this._delegateSpec.onCancelTask?this._delegateSpec.onCancelTask(e,t,n,o):e.cancelTask(n,o)},e.prototype.onHasTask=function(e,t,n,o){this._delegateSpec&&this._delegateSpec.onHasTask?this._delegateSpec.onHasTask(e,t,n,o):e.hasTask(n,o)},e}();Zone.ProxyZoneSpec=e}); \ No newline at end of file diff --git a/dist/sync-test.js b/dist/sync-test.js index 948398208..214e9daab 100644 --- a/dist/sync-test.js +++ b/dist/sync-test.js @@ -1,23 +1,36 @@ -(function () { - var SyncTestZoneSpec = (function () { - function SyncTestZoneSpec(namePrefix) { - this.runZone = Zone.current; - this.name = 'syncTestZone for ' + namePrefix; +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +var SyncTestZoneSpec = (function () { + function SyncTestZoneSpec(namePrefix) { + this.runZone = Zone.current; + this.name = 'syncTestZone for ' + namePrefix; + } + SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + case 'macroTask': + throw new Error("Cannot call " + task.source + " from within a sync test."); + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; } - SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - case 'macroTask': - throw new Error("Cannot call " + task.source + " from within a sync test."); - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - return SyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; -})(); \ No newline at end of file + return task; + }; + return SyncTestZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; + +}))); diff --git a/dist/task-tracking.js b/dist/task-tracking.js index ccd3e742b..0cfd9eae1 100644 --- a/dist/task-tracking.js +++ b/dist/task-tracking.js @@ -1,3 +1,16 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + /** * A `TaskTrackingZoneSpec` allows one to track all outstanding Tasks. * @@ -60,4 +73,6 @@ var TaskTrackingZoneSpec = (function () { }()); // Export the class so that new instances can be created with proper // constructor params. -Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec; \ No newline at end of file +Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec; + +}))); diff --git a/dist/task-tracking.min.js b/dist/task-tracking.min.js index 0a713fc59..efdbe8cdd 100644 --- a/dist/task-tracking.min.js +++ b/dist/task-tracking.min.js @@ -1 +1 @@ -var TaskTrackingZoneSpec=function(){function e(){this.name="TaskTrackingZone",this.microTasks=[],this.macroTasks=[],this.eventTasks=[],this.properties={TaskTrackingZone:this}}return e.get=function(){return Zone.current.get("TaskTrackingZone")},e.prototype.getTasksFor=function(e){switch(e){case"microTask":return this.microTasks;case"macroTask":return this.macroTasks;case"eventTask":return this.eventTasks}throw new Error("Unknown task format: "+e)},e.prototype.onScheduleTask=function(e,t,n,s){s.creationLocation=new Error("Task '"+s.type+"' from '"+s.source+"'.");var r=this.getTasksFor(s.type);return r.push(s),e.scheduleTask(n,s)},e.prototype.onCancelTask=function(e,t,n,s){for(var r=this.getTasksFor(s.type),a=0;a 'click', etc + var eventName = prop.substr(2); + var _prop = '_' + prop; + desc.set = function (fn) { + if (this[_prop]) { + this.removeEventListener(eventName, this[_prop]); + } + if (typeof fn === 'function') { + var wrapFn = function (event) { + var result; + result = fn.apply(this, arguments); + if (result != undefined && !result) + event.preventDefault(); + }; + this[_prop] = wrapFn; + this.addEventListener(eventName, wrapFn, false); + } + else { + this[_prop] = null; + } + }; + // The getter would return undefined for unassigned properties but the default value of an unassigned property is null + desc.get = function () { + return this[_prop] || null; + }; + Object.defineProperty(obj, prop, desc); +} + + + var EVENT_TASKS = zoneSymbol('eventTasks'); // For EventTarget var ADD_EVENT_LISTENER = 'addEventListener'; @@ -718,7 +775,11 @@ function makeZoneAwareListeners(fnName) { } var zoneAwareAddEventListener = makeZoneAwareAddListener(ADD_EVENT_LISTENER, REMOVE_EVENT_LISTENER); var zoneAwareRemoveEventListener = makeZoneAwareRemoveListener(REMOVE_EVENT_LISTENER); + var originalInstanceKey = zoneSymbol('originalInstance'); +// wrap some native API on `window` + + function createNamedFn(name, delegate) { try { return (Function('f', "return function " + name + "(){return f(this, arguments)}"))(delegate); @@ -809,15 +870,15 @@ var EE_PREPEND_LISTENER = 'prependListener'; var EE_REMOVE_LISTENER = 'removeListener'; var EE_LISTENERS = 'listeners'; var EE_ON = 'on'; -var zoneAwareAddListener = makeZoneAwareAddListener(EE_ADD_LISTENER, EE_REMOVE_LISTENER, false, true); +var zoneAwareAddListener$1 = makeZoneAwareAddListener(EE_ADD_LISTENER, EE_REMOVE_LISTENER, false, true); var zoneAwarePrependListener = makeZoneAwareAddListener(EE_PREPEND_LISTENER, EE_REMOVE_LISTENER, false, true); -var zoneAwareRemoveListener = makeZoneAwareRemoveListener(EE_REMOVE_LISTENER, false); +var zoneAwareRemoveListener$1 = makeZoneAwareRemoveListener(EE_REMOVE_LISTENER, false); var zoneAwareListeners = makeZoneAwareListeners(EE_LISTENERS); function patchEventEmitterMethods(obj) { if (obj && obj.addListener) { - patchMethod(obj, EE_ADD_LISTENER, function () { return zoneAwareAddListener; }); + patchMethod(obj, EE_ADD_LISTENER, function () { return zoneAwareAddListener$1; }); patchMethod(obj, EE_PREPEND_LISTENER, function () { return zoneAwarePrependListener; }); - patchMethod(obj, EE_REMOVE_LISTENER, function () { return zoneAwareRemoveListener; }); + patchMethod(obj, EE_REMOVE_LISTENER, function () { return zoneAwareRemoveListener$1; }); patchMethod(obj, EE_LISTENERS, function () { return zoneAwareListeners; }); obj[EE_ON] = obj[EE_ADD_LISTENER]; return true; @@ -958,4 +1019,6 @@ if (httpClient && httpClient.ClientRequest) { return new ClientRequest_1(options, zone.wrap(callback, 'http.ClientRequest')); } }; -} \ No newline at end of file +} + +}))); diff --git a/dist/zone.js b/dist/zone.js index 8cc51e1b7..a6e5c2f9b 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -1,5 +1,16 @@ -; -; +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + var Zone$1 = (function (global) { if (global.Zone) { throw new Error('Zone already loaded.'); @@ -26,25 +37,25 @@ var Zone$1 = (function (global) { enumerable: true, configurable: true }); - ; + Object.defineProperty(Zone, "currentTask", { get: function () { return _currentTask; }, enumerable: true, configurable: true }); - ; + Object.defineProperty(Zone.prototype, "parent", { get: function () { return this._parent; }, enumerable: true, configurable: true }); - ; + Object.defineProperty(Zone.prototype, "name", { get: function () { return this._name; }, enumerable: true, configurable: true }); - ; + Zone.prototype.get = function (key) { var zone = this.getZoneWith(key); if (zone) @@ -153,7 +164,7 @@ var Zone$1 = (function (global) { Zone.__symbol__ = __symbol__; return Zone; }()); - ; + var ZoneDelegate = (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 }; @@ -311,7 +322,7 @@ var Zone$1 = (function (global) { return ZoneTask; }()); function __symbol__(name) { return '__zone_symbol__' + name; } - ; + var symbolSetTimeout = __symbol__('setTimeout'); var symbolPromise = __symbol__('Promise'); var symbolThen = __symbol__('then'); @@ -418,12 +429,12 @@ var Zone$1 = (function (global) { throw new Error("Uncaught (in promise): " + value); } catch (e) { - var error = e; - error.rejection = value; - error.promise = promise; - error.zone = Zone.current; - error.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error); + var error_1 = e; + error_1.rejection = value; + error_1.promise = promise; + error_1.zone = Zone.current; + error_1.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error_1); scheduleQueueDrain(); } } @@ -589,7 +600,7 @@ function bindArguments(args, source) { } return args; } -; + function patchPrototype(prototype, fnNames) { var source = prototype.constructor['name']; var _loop_1 = function(i) { @@ -607,7 +618,7 @@ function patchPrototype(prototype, fnNames) { _loop_1(i); } } -; + var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); var isNode = (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'); var isBrowser = !isNode && !isWebWorker && !!(typeof window !== 'undefined' && window['HTMLElement']); @@ -650,7 +661,7 @@ function patchProperty(obj, prop) { }; Object.defineProperty(obj, prop, desc); } -; + function patchOnProperties(obj, properties) { var onProperties = []; for (var prop in obj) { @@ -667,7 +678,7 @@ function patchOnProperties(obj, properties) { } } } -; + var EVENT_TASKS = zoneSymbol('eventTasks'); // For EventTarget var ADD_EVENT_LISTENER = 'addEventListener'; @@ -783,6 +794,7 @@ function makeZoneAwareRemoveListener(fnName, useCapturingParam) { } }; } + var zoneAwareAddEventListener = makeZoneAwareAddListener(ADD_EVENT_LISTENER, REMOVE_EVENT_LISTENER); var zoneAwareRemoveEventListener = makeZoneAwareRemoveListener(REMOVE_EVENT_LISTENER); function patchEventTargetMethods(obj) { @@ -857,7 +869,7 @@ function patchClass(className) { } } } -; + function createNamedFn(name, delegate) { try { return (Function('f', "return function " + name + "(){return f(this, arguments)}"))(delegate); @@ -952,13 +964,13 @@ function propertyPatch() { return desc; }; } -; + function _redefineProperty(obj, prop, desc) { var originalConfigurableFlag = desc.configurable; desc = rewriteDescriptor(obj, prop, desc); return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); } -; + function isUnconfigurable(obj, prop) { return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; } @@ -1124,7 +1136,7 @@ function canPatchViaPropertyDescriptor() { Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', {}); return result; } -; + var unboundKey = zoneSymbol('unbound'); // Whenever any eventListener fires, we check the eventListener target and all parents // for `onwhatever` properties and replace them with zone-bound functions @@ -1154,9 +1166,8 @@ function patchViaCapturingAllTheEvents() { for (var i = 0; i < eventNames.length; i++) { _loop_1(i); } - ; + } -; function patchTimer(window, setName, cancelName, nameSuffix) { var setNative = null; @@ -1311,4 +1322,6 @@ if (_global['navigator'] && _global['navigator'].geolocation) { 'getCurrentPosition', 'watchPosition' ]); -} \ No newline at end of file +} + +}))); diff --git a/dist/zone.min.js b/dist/zone.min.js index 93c218a52..03e39d0bd 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1 +1 @@ -function bindArguments(e,t){for(var n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function patchPrototype(e,t){for(var n=e.constructor.name,r=function(r){var o=t[r],a=e[o];a&&(e[o]=function(e){return function(){return e.apply(this,bindArguments(arguments,n+"."+o))}}(a))},o=0;o1?new t(e,n):new t(e),a=Object.getOwnPropertyDescriptor(o,"onmessage");return a&&a.configurable===!1?(r=Object.create(o),["addEventListener","removeEventListener","send","close"].forEach(function(e){r[e]=function(){return o[e].apply(o,arguments)}})):r=o,patchOnProperties(r,["close","error","message","open"]),r};for(var n in t)e.WebSocket[n]=t[n]}function propertyDescriptorPatch(e){if(!isNode){var t="undefined"!=typeof WebSocket;canPatchViaPropertyDescriptor()?(isBrowser&&patchOnProperties(HTMLElement.prototype,eventNames),patchOnProperties(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(patchOnProperties(IDBIndex.prototype,null),patchOnProperties(IDBRequest.prototype,null),patchOnProperties(IDBOpenDBRequest.prototype,null),patchOnProperties(IDBDatabase.prototype,null),patchOnProperties(IDBTransaction.prototype,null),patchOnProperties(IDBCursor.prototype,null)),t&&patchOnProperties(WebSocket.prototype,null)):(patchViaCapturingAllTheEvents(),patchClass("XMLHttpRequest"),t&&apply(e))}}function canPatchViaPropertyDescriptor(){if(isBrowser&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{get:function(){return!0}});var t=new XMLHttpRequest,n=!!t.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{}),n}function patchViaCapturingAllTheEvents(){for(var e=function(e){var t=eventNames[e],n="on"+t;document.addEventListener(t,function(e){var t,r,o=e.target;for(r=o?o.constructor.name+"."+n:"unknown."+n;o;)o[n]&&!o[n][unboundKey]&&(t=Zone.current.wrap(o[n],r),t[unboundKey]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t",this._properties=t&&t.properties||{},this._zoneDelegate=new g(this,this._parent&&this._parent._zoneDelegate,t)}return n.assertZonePatched=function(){if(e.Promise!==M)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(n,"current",{get:function(){return _},enumerable:!0,configurable:!0}),Object.defineProperty(n,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),n.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},n.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},n.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},n.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},n.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=_;_=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{_=o}},n.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=_;_=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{_=o}},n.prototype.runTask=function(e,t,n){if(e.runCount++,e.zone!=this)throw new Error("A task can only be run in the zone which created it! (Creation: "+e.zone.name+"; Execution: "+this.name+")");var r=T;T=e;var o=_;_=this;try{"macroTask"==e.type&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{_=o,T=r}},n.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new y("microTask",this,e,t,n,r,null))},n.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new y("macroTask",this,e,t,n,r,o))},n.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new y("eventTask",this,e,t,n,r,o))},n.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.runCount=-1,e.cancelFn=null,t},n.__symbol__=t,n}(),g=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new d(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t)},e.prototype.scheduleTask=function(e,t){try{if(this._scheduleTaskZS)return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this.zone,e,t);if(t.scheduleFn)t.scheduleFn(t);else{if("microTask"!=t.type)throw new Error("Task is missing scheduleFn.");r(t)}return t}finally{e==this.zone&&this._updateTaskCount(t.type,1)}},e.prototype.invokeTask=function(e,t,n,r){try{return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this.zone,e,t,n,r):t.callback.apply(n,r)}finally{e!=this.zone||"eventTask"==t.type||t.data&&t.data.isPeriodic||this._updateTaskCount(t.type,-1)}},e.prototype.cancelTask=function(e,t){var n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this.zone,e,t);else{if(!t.cancelFn)throw new Error("Task does not support cancellation, or is already canceled.");n=t.cancelFn(t)}return e==this.zone&&this._updateTaskCount(t.type,-1),n},e.prototype.hasTask=function(e,t){return this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this.zone,e,t)},e.prototype._updateTaskCount=function(e,t){var n=this._taskCounts,r=n[e],o=n[e]=r+t;if(o<0)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),y=function(){function e(e,t,n,r,o,i,s){this.runCount=0,this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=s,this.callback=r;var c=this;this.invoke=function(){S++;try{return t.runTask(c,this,arguments)}finally{1==S&&a(),S--}}}return e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:this.toString()},e}(),v=t("setTimeout"),k=t("Promise"),b=t("then"),_=new d(null,null),T=null,m=[],E=!1,w=[],S=0,P=t("state"),D=t("value"),O="Promise.then",z=null,I=!0,R=!1,Z=0,M=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[P]=z,n[D]=[];try{t&&t(u(n,I),u(n,R))}catch(r){l(n,!1,r)}}return e.resolve=function(e){return l(new this(null),I,e)},e.reject=function(e){return l(new this(null),R,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){r=e,o=t}),s=0,c=e;s=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function t(t,n){for(var r=t.constructor.name,o=function(o){var a=n[o],i=t[a];i&&(t[a]=function(t){return function(){return t.apply(this,e(arguments,r+"."+a))}}(i))},a=0;a1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r(o,["close","error","message","open"]),o};for(var n in t)e.WebSocket[n]=t[n]}function m(e){if(!Z){var t="undefined"!=typeof WebSocket;T()?(O&&r(HTMLElement.prototype,X),r(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(r(IDBIndex.prototype,null),r(IDBRequest.prototype,null),r(IDBOpenDBRequest.prototype,null),r(IDBDatabase.prototype,null),r(IDBTransaction.prototype,null),r(IDBCursor.prototype,null)),t&&r(WebSocket.prototype,null)):(w(),c("XMLHttpRequest"),t&&b(e))}}function T(){if(O&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{get:function(){return!0}});var t=new XMLHttpRequest,n=!!t.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{}),n}function w(){for(var e=function(e){var t=X[e],n="on"+t;document.addEventListener(t,function(e){var t,r,o=e.target;for(r=o?o.constructor.name+"."+n:"unknown."+n;o;)o[n]&&!o[n][A]&&(t=Zone.current.wrap(o[n],r),t[A]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t",this._properties=t&&t.properties||{},this._zoneDelegate=new v(this,this._parent&&this._parent._zoneDelegate,t)}return n.assertZonePatched=function(){if(e.Promise!==C)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(n,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(n,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),n.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},n.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},n.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},n.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},n.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{m=o}},n.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o}},n.prototype.runTask=function(e,t,n){if(e.runCount++,e.zone!=this)throw new Error("A task can only be run in the zone which created it! (Creation: "+e.zone.name+"; Execution: "+this.name+")");var r=T;T=e;var o=m;m=this;try{"macroTask"==e.type&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o,T=r}},n.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new g("microTask",this,e,t,n,r,null))},n.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new g("macroTask",this,e,t,n,r,o))},n.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new g("eventTask",this,e,t,n,r,o))},n.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.runCount=-1,e.cancelFn=null,t},n.__symbol__=t,n}(),v=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new d(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t)},e.prototype.scheduleTask=function(e,t){try{if(this._scheduleTaskZS)return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this.zone,e,t);if(t.scheduleFn)t.scheduleFn(t);else{if("microTask"!=t.type)throw new Error("Task is missing scheduleFn.");r(t)}return t}finally{e==this.zone&&this._updateTaskCount(t.type,1)}},e.prototype.invokeTask=function(e,t,n,r){try{return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this.zone,e,t,n,r):t.callback.apply(n,r)}finally{e!=this.zone||"eventTask"==t.type||t.data&&t.data.isPeriodic||this._updateTaskCount(t.type,-1)}},e.prototype.cancelTask=function(e,t){var n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this.zone,e,t);else{if(!t.cancelFn)throw new Error("Task does not support cancellation, or is already canceled.");n=t.cancelFn(t)}return e==this.zone&&this._updateTaskCount(t.type,-1),n},e.prototype.hasTask=function(e,t){return this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this.zone,e,t)},e.prototype._updateTaskCount=function(e,t){var n=this._taskCounts,r=n[e],o=n[e]=r+t;if(o<0)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),g=function(){function e(e,t,n,r,o,i,s){this.runCount=0,this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=s,this.callback=r;var u=this;this.invoke=function(){E++;try{return t.runTask(u,this,arguments)}finally{1==E&&a(),E--}}}return e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:this.toString()},e}(),y=t("setTimeout"),k=t("Promise"),b=t("then"),m=new d(null,null),T=null,w=[],_=!1,D=[],E=0,S=t("state"),P=t("value"),Z="Promise.then",O=null,j=!0,z=!1,I=0,C=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[S]=O,n[P]=[];try{t&&t(c(n,j),c(n,z))}catch(r){l(n,!1,r)}}return e.resolve=function(e){return l(new this(null),j,e)},e.reject=function(e){return l(new this(null),z,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){r=e,o=t}),s=0,u=e;s