Comparing version 0.6.23 to 0.6.24
@@ -1,68 +0,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; | ||
})(); | ||
}; | ||
// 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; | ||
}))); |
@@ -1,238 +0,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'); | ||
}; | ||
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]; | ||
} | ||
}; | ||
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); | ||
} | ||
fn.apply(global, args); | ||
if (_this._lastError === null) { | ||
if (completers.onSuccess != null) { | ||
completers.onSuccess.apply(global); | ||
} | ||
// Flush microtasks only on success. | ||
_this.flushMicrotasks(); | ||
// Flush microtasks only on success. | ||
_this.flushMicrotasks(); | ||
} | ||
else { | ||
if (completers.onError != null) { | ||
completers.onError.apply(global); | ||
} | ||
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); | ||
} | ||
// Return true if there were no errors, false otherwise. | ||
return _this._lastError === null; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { | ||
var _this = this; | ||
return function () { | ||
FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); | ||
}; | ||
}; | ||
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) { | ||
var args = []; | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
}; | ||
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); | ||
} | ||
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._dequeuePeriodicTimer = function (id) { | ||
var _this = this; | ||
return function () { | ||
FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, 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._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.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(); | ||
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); | ||
} | ||
}; | ||
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; | ||
})(typeof window === 'object' && window || typeof self === 'object' && self || global); | ||
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; | ||
}))); |
@@ -0,1 +1,14 @@ | ||
/** | ||
* @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) { | ||
@@ -111,2 +124,4 @@ for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
}(QueueRunner)); | ||
})(); | ||
})(); | ||
}))); |
@@ -1,1 +0,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)}(); | ||
!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)}()}); |
@@ -1,132 +0,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; | ||
} | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = error.longStack = longStack; | ||
} | ||
catch (e) { } | ||
} | ||
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(); | ||
})(); | ||
} | ||
computeIgnoreFrames(); | ||
}))); |
@@ -1,1 +0,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;e<n.length;e++){var c=n[e];e<s.length&&s[e]===c||t.push(n[e])}}function e(t,r){var a=[r];if(t)for(var e=(new Date).getTime(),c=0;c<t.length;c++){var o=t[c],s=o.timestamp;a.push(u+" Elapsed: "+(e-s.getTime())+" ms; At: "+s+" "+u),n(a,o.error),e=s.getTime()}return a.join(i)}function c(t,r){r>0&&(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;n<r.length;n++){var e=r[n],o=a[n];if(e!==o)break;s.push(e)}}var i="\n",u=" ------------- ",s=[],f="__creationTrace__",l=function(){function t(){this.error=g(),this.timestamp=new Date}return t}(),h=t(),k=r(),g=h.stack?t:k.stack?r:t;Zone.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,onScheduleTask:function(t,r,a,n){var e=Zone.currentTask,c=e&&e.data&&e.data[f]||[];return c=[new l].concat(c),c.length>this.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()}(); | ||
!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;a<r.length;a++){var c=r[a];a<s.length&&s[a]===c||t.push(r[a])}}function a(t,e){var n=[e];if(t)for(var a=(new Date).getTime(),c=0;c<t.length;c++){var o=t[c],s=o.timestamp;n.push(u+" Elapsed: "+(a-s.getTime())+" ms; At: "+s+" "+u),r(n,o.error),a=s.getTime()}return n.join(i)}function c(t,e){e>0&&(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;r<e.length;r++){var a=e[r],o=n[r];if(a!==o)break;s.push(a)}}var i="\n",u=" ------------- ",s=[],f="__creationTrace__",l=function(){function t(){this.error=k(),this.timestamp=new Date}return t}(),h=t(),d=e(),k=h.stack?t:d.stack?e:t;Zone.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,onScheduleTask:function(t,e,n,r){var a=Zone.currentTask,c=a&&a.data&&a.data[f]||[];return c=[new l].concat(c),c.length>this.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()}); |
@@ -1,108 +0,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); | ||
/** | ||
* @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."); | ||
} | ||
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; | ||
})(); | ||
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; | ||
}))); |
@@ -1,1 +0,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}(); | ||
!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}); |
@@ -1,23 +0,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; | ||
})(); | ||
return task; | ||
}; | ||
return SyncTestZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; | ||
}))); |
/** | ||
* @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. | ||
@@ -63,2 +76,4 @@ * | ||
// constructor params. | ||
Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec; | ||
Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec; | ||
}))); |
@@ -1,1 +0,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<r.length;a++)if(r[a]==s){r.splice(a,1);break}return e.cancelTask(n,s)},e.prototype.onInvokeTask=function(e,t,n,s,r,a){if("eventTask"===s.type)return e.invokeTask(n,s,r,a);for(var o=this.getTasksFor(s.type),k=0;k<o.length;k++)if(o[k]==s){o.splice(k,1);break}return e.invokeTask(n,s,r,a)},e.prototype.clearEvents=function(){for(;this.eventTasks.length;)Zone.current.cancelTask(this.eventTasks[0])},e}();Zone.TaskTrackingZoneSpec=TaskTrackingZoneSpec; | ||
!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(){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),o=0;o<r.length;o++)if(r[o]==s){r.splice(o,1);break}return e.cancelTask(n,s)},e.prototype.onInvokeTask=function(e,t,n,s,r,o){if("eventTask"===s.type)return e.invokeTask(n,s,r,o);for(var a=this.getTasksFor(s.type),i=0;i<a.length;i++)if(a[i]==s){a.splice(i,1);break}return e.invokeTask(n,s,r,o)},e.prototype.clearEvents=function(){for(;this.eventTasks.length;)Zone.current.cancelTask(this.eventTasks[0])},e}();Zone.TaskTrackingZoneSpec=e}); |
213
dist/wtf.js
@@ -1,108 +0,119 @@ | ||
(function (global) { | ||
; | ||
; | ||
// Detect and setup WTF. | ||
var wtfTrace = null; | ||
var wtfEvents = null; | ||
var wtfEnabled = (function () { | ||
var wtf = global['wtf']; | ||
if (wtf) { | ||
wtfTrace = wtf.trace; | ||
if (wtfTrace) { | ||
wtfEvents = wtfTrace.events; | ||
return true; | ||
} | ||
/** | ||
* @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'; | ||
// Detect and setup WTF. | ||
var wtfTrace = null; | ||
var wtfEvents = null; | ||
var wtfEnabled = (function () { | ||
var wtf = global['wtf']; | ||
if (wtf) { | ||
wtfTrace = wtf.trace; | ||
if (wtfTrace) { | ||
wtfEvents = wtfTrace.events; | ||
return true; | ||
} | ||
return false; | ||
})(); | ||
var WtfZoneSpec = (function () { | ||
function WtfZoneSpec() { | ||
this.name = 'WTF'; | ||
} | ||
return false; | ||
})(); | ||
var WtfZoneSpec = (function () { | ||
function WtfZoneSpec() { | ||
this.name = 'WTF'; | ||
} | ||
WtfZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { | ||
var retValue = parentZoneDelegate.fork(targetZone, zoneSpec); | ||
WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); | ||
return retValue; | ||
}; | ||
WtfZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { | ||
var scope = WtfZoneSpec.invokeScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeScope[source] | ||
= wtfEvents.createScope("Zone:invoke:" + source + "(ascii zone)"); | ||
} | ||
WtfZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { | ||
var retValue = parentZoneDelegate.fork(targetZone, zoneSpec); | ||
WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); | ||
return retValue; | ||
}; | ||
WtfZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { | ||
var scope = WtfZoneSpec.invokeScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeScope[source] | ||
= wtfEvents.createScope("Zone:invoke:" + source + "(ascii zone)"); | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); | ||
}; | ||
WtfZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
}; | ||
WtfZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
var key = task.type + ':' + task.source; | ||
var instance = WtfZoneSpec.scheduleInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.scheduleInstance[key] | ||
= wtfEvents.createInstance("Zone:schedule:" + key + "(ascii zone, any data)"); | ||
} | ||
var retValue = parentZoneDelegate.scheduleTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
}; | ||
WtfZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { | ||
var source = task.source; | ||
var scope = WtfZoneSpec.invokeTaskScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeTaskScope[source] | ||
= wtfEvents.createScope("Zone:invokeTask:" + source + "(ascii zone)"); | ||
} | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); | ||
}; | ||
WtfZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
var key = task.source; | ||
var instance = WtfZoneSpec.cancelInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.cancelInstance[key] | ||
= wtfEvents.createInstance("Zone:cancel:" + key + "(ascii zone, any options)"); | ||
} | ||
var retValue = parentZoneDelegate.cancelTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
}; | ||
WtfZoneSpec.forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); | ||
WtfZoneSpec.scheduleInstance = {}; | ||
WtfZoneSpec.cancelInstance = {}; | ||
WtfZoneSpec.invokeScope = {}; | ||
WtfZoneSpec.invokeTaskScope = {}; | ||
return WtfZoneSpec; | ||
}()); | ||
function shallowObj(obj, depth) { | ||
if (!depth) | ||
return null; | ||
var out = {}; | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
var value = obj[key]; | ||
switch (typeof value) { | ||
case 'object': | ||
var name_1 = value && value.constructor && value.constructor.name; | ||
value = name_1 == Object.name ? shallowObj(value, depth - 1) : name_1; | ||
break; | ||
case 'function': | ||
value = value.name || undefined; | ||
break; | ||
} | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); | ||
}; | ||
WtfZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
}; | ||
WtfZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
var key = task.type + ':' + task.source; | ||
var instance = WtfZoneSpec.scheduleInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.scheduleInstance[key] | ||
= wtfEvents.createInstance("Zone:schedule:" + key + "(ascii zone, any data)"); | ||
} | ||
var retValue = parentZoneDelegate.scheduleTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
}; | ||
WtfZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { | ||
var source = task.source; | ||
var scope = WtfZoneSpec.invokeTaskScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeTaskScope[source] | ||
= wtfEvents.createScope("Zone:invokeTask:" + source + "(ascii zone)"); | ||
} | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); | ||
}; | ||
WtfZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
var key = task.source; | ||
var instance = WtfZoneSpec.cancelInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.cancelInstance[key] | ||
= wtfEvents.createInstance("Zone:cancel:" + key + "(ascii zone, any options)"); | ||
} | ||
var retValue = parentZoneDelegate.cancelTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
}; | ||
; | ||
WtfZoneSpec.forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); | ||
WtfZoneSpec.scheduleInstance = {}; | ||
WtfZoneSpec.cancelInstance = {}; | ||
WtfZoneSpec.invokeScope = {}; | ||
WtfZoneSpec.invokeTaskScope = {}; | ||
return WtfZoneSpec; | ||
}()); | ||
function shallowObj(obj, depth) { | ||
if (!depth) | ||
return null; | ||
var out = {}; | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
var value = obj[key]; | ||
switch (typeof value) { | ||
case 'object': | ||
var name_1 = value && value.constructor && value.constructor.name; | ||
value = name_1 == Object.name ? shallowObj(value, depth - 1) : name_1; | ||
break; | ||
case 'function': | ||
value = value.name || undefined; | ||
break; | ||
} | ||
out[key] = value; | ||
} | ||
out[key] = value; | ||
} | ||
return out; | ||
} | ||
function zonePathName(zone) { | ||
var name = zone.name; | ||
return out; | ||
} | ||
function zonePathName(zone) { | ||
var name = zone.name; | ||
zone = zone.parent; | ||
while (zone != null) { | ||
name = zone.name + '::' + name; | ||
zone = zone.parent; | ||
while (zone != null) { | ||
name = zone.name + '::' + name; | ||
zone = zone.parent; | ||
} | ||
return name; | ||
} | ||
Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); | ||
})(typeof window === 'object' && window || typeof self === 'object' && self || global); | ||
return name; | ||
} | ||
Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); | ||
}))); |
@@ -1,1 +0,1 @@ | ||
!function(e){function n(e,o){if(!o)return null;var a={};for(var c in e)if(e.hasOwnProperty(c)){var t=e[c];switch(typeof t){case"object":var r=t&&t.constructor&&t.constructor.name;t=r==Object.name?n(t,o-1):r;break;case"function":t=t.name||void 0}a[c]=t}return a}function o(e){var n=e.name;for(e=e.parent;null!=e;)n=e.name+"::"+n,e=e.parent;return n}var a=null,c=null,t=function(){var n=e.wtf;return!(!n||!(a=n.trace))&&(c=a.events,!0)}(),r=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,a,c,t){var r=n.fork(c,t);return e.forkInstance(o(c),r.name),r},e.prototype.onInvoke=function(n,t,r,s,i,u,p){var l=e.invokeScope[p];return l||(l=e.invokeScope[p]=c.createScope("Zone:invoke:"+p+"(ascii zone)")),a.leaveScope(l(o(r)),n.invoke(r,s,i,u,p))},e.prototype.onHandleError=function(e,n,o,a){return e.handleError(o,a)},e.prototype.onScheduleTask=function(a,t,r,s){var i=s.type+":"+s.source,u=e.scheduleInstance[i];u||(u=e.scheduleInstance[i]=c.createInstance("Zone:schedule:"+i+"(ascii zone, any data)"));var p=a.scheduleTask(r,s);return u(o(r),n(s.data,2)),p},e.prototype.onInvokeTask=function(n,t,r,s,i,u){var p=s.source,l=e.invokeTaskScope[p];return l||(l=e.invokeTaskScope[p]=c.createScope("Zone:invokeTask:"+p+"(ascii zone)")),a.leaveScope(l(o(r)),n.invokeTask(r,s,i,u))},e.prototype.onCancelTask=function(a,t,r,s){var i=s.source,u=e.cancelInstance[i];u||(u=e.cancelInstance[i]=c.createInstance("Zone:cancel:"+i+"(ascii zone, any options)"));var p=a.cancelTask(r,s);return u(o(r),n(s.data,2)),p},e.forkInstance=t&&c.createInstance("Zone:fork(ascii zone, ascii newZone)"),e.scheduleInstance={},e.cancelInstance={},e.invokeScope={},e.invokeTaskScope={},e}();Zone.wtfZoneSpec=t?new r:null}("object"==typeof window&&window||"object"==typeof self&&self||global); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";function e(n,o){if(!o)return null;var t={};for(var a in n)if(n.hasOwnProperty(a)){var c=n[a];switch(typeof c){case"object":var r=c&&c.constructor&&c.constructor.name;c=r==Object.name?e(c,o-1):r;break;case"function":c=c.name||void 0}t[a]=c}return t}function n(e){var n=e.name;for(e=e.parent;null!=e;)n=e.name+"::"+n,e=e.parent;return n}var o=null,t=null,a=function(){var e=global.wtf;return!(!e||!(o=e.trace))&&(t=o.events,!0)}(),c=function(){function c(){this.name="WTF"}return c.prototype.onFork=function(e,o,t,a){var r=e.fork(t,a);return c.forkInstance(n(t),r.name),r},c.prototype.onInvoke=function(e,a,r,i,s,u,f){var p=c.invokeScope[f];return p||(p=c.invokeScope[f]=t.createScope("Zone:invoke:"+f+"(ascii zone)")),o.leaveScope(p(n(r)),e.invoke(r,i,s,u,f))},c.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},c.prototype.onScheduleTask=function(o,a,r,i){var s=i.type+":"+i.source,u=c.scheduleInstance[s];u||(u=c.scheduleInstance[s]=t.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var f=o.scheduleTask(r,i);return u(n(r),e(i.data,2)),f},c.prototype.onInvokeTask=function(e,a,r,i,s,u){var f=i.source,p=c.invokeTaskScope[f];return p||(p=c.invokeTaskScope[f]=t.createScope("Zone:invokeTask:"+f+"(ascii zone)")),o.leaveScope(p(n(r)),e.invokeTask(r,i,s,u))},c.prototype.onCancelTask=function(o,a,r,i){var s=i.source,u=c.cancelInstance[s];u||(u=c.cancelInstance[s]=t.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var f=o.cancelTask(r,i);return u(n(r),e(i.data,2)),f},c.forkInstance=a&&t.createInstance("Zone:fork(ascii zone, ascii newZone)"),c.scheduleInstance={},c.cancelInstance={},c.invokeScope={},c.invokeTaskScope={},c}();Zone.wtfZoneSpec=a?new c:null}); |
@@ -1,3 +0,14 @@ | ||
; | ||
; | ||
/** | ||
* @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) { | ||
@@ -29,3 +40,3 @@ if (global.Zone) { | ||
}); | ||
; | ||
Object.defineProperty(Zone, "currentTask", { | ||
@@ -36,3 +47,3 @@ get: function () { return _currentTask; }, | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "parent", { | ||
@@ -43,3 +54,3 @@ get: function () { return this._parent; }, | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "name", { | ||
@@ -50,3 +61,3 @@ get: function () { return this._name; }, | ||
}); | ||
; | ||
Zone.prototype.get = function (key) { | ||
@@ -160,3 +171,3 @@ var zone = this.getZoneWith(key); | ||
}()); | ||
; | ||
var ZoneDelegate = (function () { | ||
@@ -319,3 +330,3 @@ function ZoneDelegate(zone, parentDelegate, zoneSpec) { | ||
function __symbol__(name) { return '__zone_symbol__' + name; } | ||
; | ||
var symbolSetTimeout = __symbol__('setTimeout'); | ||
@@ -427,8 +438,8 @@ var symbolPromise = __symbol__('Promise'); | ||
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(); | ||
@@ -599,4 +610,50 @@ } | ||
} | ||
; | ||
var isNode = (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'); | ||
function patchProperty(obj, prop) { | ||
var desc = Object.getOwnPropertyDescriptor(obj, prop) || { | ||
enumerable: true, | ||
configurable: true | ||
}; | ||
// A property descriptor cannot have getter/setter and be writable | ||
// deleting the writable and value properties avoids this error: | ||
// | ||
// TypeError: property descriptors must not specify a value or be writable when a | ||
// getter or setter has been specified | ||
delete desc.writable; | ||
delete desc.value; | ||
// substr(2) cuz 'onclick' -> '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'); | ||
@@ -729,3 +786,7 @@ // For EventTarget | ||
var zoneAwareRemoveEventListener = makeZoneAwareRemoveListener(REMOVE_EVENT_LISTENER); | ||
var originalInstanceKey = zoneSymbol('originalInstance'); | ||
// wrap some native API on `window` | ||
function createNamedFn(name, delegate) { | ||
@@ -821,11 +882,11 @@ try { | ||
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; }); | ||
@@ -971,2 +1032,4 @@ obj[EE_ON] = obj[EE_ADD_LISTENER]; | ||
}; | ||
} | ||
} | ||
}))); |
@@ -1,3 +0,14 @@ | ||
; | ||
; | ||
/** | ||
* @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) { | ||
@@ -29,3 +40,3 @@ if (global.Zone) { | ||
}); | ||
; | ||
Object.defineProperty(Zone, "currentTask", { | ||
@@ -36,3 +47,3 @@ get: function () { return _currentTask; }, | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "parent", { | ||
@@ -43,3 +54,3 @@ get: function () { return this._parent; }, | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "name", { | ||
@@ -50,3 +61,3 @@ get: function () { return this._name; }, | ||
}); | ||
; | ||
Zone.prototype.get = function (key) { | ||
@@ -160,3 +171,3 @@ var zone = this.getZoneWith(key); | ||
}()); | ||
; | ||
var ZoneDelegate = (function () { | ||
@@ -319,3 +330,3 @@ function ZoneDelegate(zone, parentDelegate, zoneSpec) { | ||
function __symbol__(name) { return '__zone_symbol__' + name; } | ||
; | ||
var symbolSetTimeout = __symbol__('setTimeout'); | ||
@@ -427,8 +438,8 @@ var symbolPromise = __symbol__('Promise'); | ||
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(); | ||
@@ -599,3 +610,3 @@ } | ||
} | ||
; | ||
function patchPrototype(prototype, fnNames) { | ||
@@ -618,3 +629,3 @@ var source = prototype.constructor['name']; | ||
} | ||
; | ||
var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); | ||
@@ -662,3 +673,3 @@ var isNode = (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'); | ||
} | ||
; | ||
function patchOnProperties(obj, properties) { | ||
@@ -680,3 +691,3 @@ var onProperties = []; | ||
} | ||
; | ||
var EVENT_TASKS = zoneSymbol('eventTasks'); | ||
@@ -797,2 +808,3 @@ // For EventTarget | ||
} | ||
var zoneAwareAddEventListener = makeZoneAwareAddListener(ADD_EVENT_LISTENER, REMOVE_EVENT_LISTENER); | ||
@@ -872,3 +884,3 @@ var zoneAwareRemoveEventListener = makeZoneAwareRemoveListener(REMOVE_EVENT_LISTENER); | ||
} | ||
; | ||
function createNamedFn(name, delegate) { | ||
@@ -968,3 +980,3 @@ try { | ||
} | ||
; | ||
function _redefineProperty(obj, prop, desc) { | ||
@@ -975,3 +987,3 @@ var originalConfigurableFlag = desc.configurable; | ||
} | ||
; | ||
function isUnconfigurable(obj, prop) { | ||
@@ -1142,3 +1154,3 @@ return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; | ||
} | ||
; | ||
var unboundKey = zoneSymbol('unbound'); | ||
@@ -1173,5 +1185,4 @@ // Whenever any eventListener fires, we check the eventListener target and all parents | ||
} | ||
; | ||
} | ||
; | ||
@@ -1331,2 +1342,4 @@ function patchTimer(window, setName, cancelName, nameSuffix) { | ||
]); | ||
} | ||
} | ||
}))); |
@@ -1,1 +0,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;o<t.length;o++)r(o)}function patchProperty(e,t){var n=Object.getOwnPropertyDescriptor(e,t)||{enumerable:!0,configurable:!0};delete n.writable,delete n.value;var r=t.substr(2),o="_"+t;n.set=function(e){if(this[o]&&this.removeEventListener(r,this[o]),"function"==typeof e){var t=function(t){var n;n=e.apply(this,arguments),void 0==n||n||t.preventDefault()};this[o]=t,this.addEventListener(r,t,!1)}else this[o]=null},n.get=function(){return this[o]||null},Object.defineProperty(e,t,n)}function patchOnProperties(e,t){var n=[];for(var r in e)"on"==r.substr(0,2)&&n.push(r);for(var o=0;o<n.length;o++)patchProperty(e,n[o]);if(t)for(var a=0;a<t.length;a++)patchProperty(e,"on"+t[a])}function findExistingRegisteredTask(e,t,n,r,o){var a=e[EVENT_TASKS];if(a)for(var i=0;i<a.length;i++){var s=a[i],c=s.data;if(c.handler===t&&c.useCapturing===r&&c.eventName===n)return o&&a.splice(i,1),s}return null}function attachRegisteredEvent(e,t){var n=e[EVENT_TASKS];n||(n=e[EVENT_TASKS]=[]),n.push(t)}function makeZoneAwareAddListener(e,t,n,r){function o(e){var t=e.data;return attachRegisteredEvent(t.target,e),t.target[i](t.eventName,e.invoke,t.useCapturing)}function a(e){var t=e.data;findExistingRegisteredTask(t.target,e.invoke,t.eventName,t.useCapturing,!0),t.target[s](t.eventName,e.invoke,t.useCapturing)}void 0===n&&(n=!0),void 0===r&&(r=!1);var i=zoneSymbol(e),s=zoneSymbol(t),c=!n&&void 0;return function(t,n){var s=n[0],u=n[1],l=n[2]||c,p=t||_global$1,h=null;"function"==typeof u?h=u:u&&u.handleEvent&&(h=function(e){return u.handleEvent(e)});var f=!1;try{f=u&&"[object FunctionWrapper]"===u.toString()}catch(d){return}if(!h||f)return p[i](s,u,l);if(!r){var g=findExistingRegisteredTask(p,u,s,l,!1);if(g)return p[i](s,g.invoke,l)}var y=Zone.current,v=p.constructor.name+"."+e+":"+s,k={target:p,eventName:s,name:s,useCapturing:l,handler:u};y.scheduleEventTask(v,h,k,o,a)}}function makeZoneAwareRemoveListener(e,t){void 0===t&&(t=!0);var n=zoneSymbol(e),r=!t&&void 0;return function(e,t){var o=t[0],a=t[1],i=t[2]||r,s=e||_global$1,c=findExistingRegisteredTask(s,a,o,i,!0);c?c.zone.cancelTask(c):s[n](o,a,i)}}function patchEventTargetMethods(e){return!(!e||!e.addEventListener)&&(patchMethod(e,ADD_EVENT_LISTENER,function(){return zoneAwareAddEventListener}),patchMethod(e,REMOVE_EVENT_LISTENER,function(){return zoneAwareRemoveEventListener}),!0)}function patchClass(e){var t=_global$1[e];if(t){_global$1[e]=function(){var n=bindArguments(arguments,e);switch(n.length){case 0:this[originalInstanceKey]=new t;break;case 1:this[originalInstanceKey]=new t(n[0]);break;case 2:this[originalInstanceKey]=new t(n[0],n[1]);break;case 3:this[originalInstanceKey]=new t(n[0],n[1],n[2]);break;case 4:this[originalInstanceKey]=new t(n[0],n[1],n[2],n[3]);break;default:throw new Error("Arg list too long.")}};var n,r=new t(function(){});for(n in r)"XMLHttpRequest"===e&&"responseBlob"===n||!function(t){"function"==typeof r[t]?_global$1[e].prototype[t]=function(){return this[originalInstanceKey][t].apply(this[originalInstanceKey],arguments)}:Object.defineProperty(_global$1[e].prototype,t,{set:function(n){"function"==typeof n?this[originalInstanceKey][t]=Zone.current.wrap(n,e+"."+t):this[originalInstanceKey][t]=n},get:function(){return this[originalInstanceKey][t]}})}(n);for(n in t)"prototype"!==n&&t.hasOwnProperty(n)&&(_global$1[e][n]=t[n])}}function createNamedFn(e,t){try{return Function("f","return function "+e+"(){return f(this, arguments)}")(t)}catch(n){return function(){return t(this,arguments)}}}function patchMethod(e,t,n){for(var r=e;r&&!r.hasOwnProperty(t);)r=Object.getPrototypeOf(r);!r&&e[t]&&(r=e);var o,a=zoneSymbol(t);return r&&!(o=r[a])&&(o=r[a]=r[t],r[t]=createNamedFn(t,n(o,a,t))),o}function eventTargetPatch(e){var t=[],n=e.wtf;n?t=WTF_ISSUE_555.split(",").map(function(e){return"HTML"+e+"Element"}).concat(NO_EVENT_TARGET):e[EVENT_TARGET]?t.push(EVENT_TARGET):t=NO_EVENT_TARGET;for(var r=0;r<t.length;r++){var o=e[t[r]];patchEventTargetMethods(o&&o.prototype)}}function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);var r=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,r)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){var n=_getOwnPropertyDescriptor(e,t);return isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){var r=n.configurable;return n=rewriteDescriptor(e,t,n),_tryDefineProperty(e,t,n,r)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return n.configurable=!0,n.configurable||(e[unconfigurablesKey]||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey][t]=!0),n}function _tryDefineProperty(e,t,n,r){try{return _defineProperty(e,t,n)}catch(o){if(!n.configurable)throw o;"undefined"==typeof r?delete n.configurable:n.configurable=r;try{return _defineProperty(e,t,n)}catch(o){var a=null;try{a=JSON.stringify(n)}catch(o){a=a.toString()}console.log("Attempting to configure '"+t+"' with descriptor '"+a+"' on object '"+e+"' and got error, giving up: "+o)}}}function registerElementPatch(e){if(isBrowser&&"registerElement"in e.document){var t=document.registerElement,n=["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"];document.registerElement=function(e,r){return r&&r.prototype&&n.forEach(function(e){var t="Document.registerElement::"+e;if(r.prototype.hasOwnProperty(e)){var n=Object.getOwnPropertyDescriptor(r.prototype,e);n&&n.value?(n.value=Zone.current.wrap(n.value,t),_redefineProperty(r.prototype,e,n)):r.prototype[e]=Zone.current.wrap(r.prototype[e],t)}else r.prototype[e]&&(r.prototype[e]=Zone.current.wrap(r.prototype[e],t))}),t.apply(document,[e,r])}}}function apply(e){var t=e.WebSocket;e.EventTarget||patchEventTargetMethods(t.prototype),e.WebSocket=function(e,n){var r,o=arguments.length>1?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<eventNames.length;t++)e(t)}function patchTimer(e,t,n,r){function o(t){var n=t.data;return n.args[0]=t.invoke,n.handleId=i.apply(e,n.args),t}function a(e){return s(e.data.handleId)}var i=null,s=null;t+=r,n+=r,i=patchMethod(e,t,function(n){return function(i,s){if("function"==typeof s[0]){var c=Zone.current,u={handleId:null,isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?s[1]||0:null,args:s},l=c.scheduleMacroTask(t,s[0],u,o,a);if(!l)return l;var p=l.data.handleId;return p.ref&&p.unref&&(l.ref=p.ref.bind(p),l.unref=p.unref.bind(p)),l}return n.apply(e,s)}}),s=patchMethod(e,n,function(t){return function(n,r){var o=r[0];o&&"string"==typeof o.type?(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&o.zone.cancelTask(o):t.apply(e,r)}})}function patchXHR(e){function t(e){var t=e[XHR_TASK];return t}function n(e){var t=e.data;t.target.addEventListener("readystatechange",function(){t.target.readyState===t.target.DONE&&(t.aborted||e.invoke())});var n=t.target[XHR_TASK];return n||(t.target[XHR_TASK]=e),i.apply(t.target,t.args),e}function r(){}function o(e){var t=e.data;return t.aborted=!0,s.apply(t.target,t.args)}var a=patchMethod(e.XMLHttpRequest.prototype,"open",function(){return function(e,t){return e[XHR_SYNC]=0==t[2],a.apply(e,t)}}),i=patchMethod(e.XMLHttpRequest.prototype,"send",function(){return function(e,t){var a=Zone.current;if(e[XHR_SYNC])return i.apply(e,t);var s={target:e,isPeriodic:!1,delay:null,args:t,aborted:!1};return a.scheduleMacroTask("XMLHttpRequest.send",r,s,n,o)}}),s=patchMethod(e.XMLHttpRequest.prototype,"abort",function(e){return function(e,n){var r=t(e);if(r&&"string"==typeof r.type){if(null==r.cancelFn)return;r.zone.cancelTask(r)}}})}var Zone$1=function(e){function t(e){return"__zone_symbol__"+e}function n(){0==S&&0==m.length&&(e[k]?e[k].resolve(0)[b](a):e[v](a,0))}function r(e){n(),m.push(e)}function o(e){var t=e&&e.rejection;t&&console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0),console.error(e)}function a(){if(!E){for(E=!0;m.length;){var e=m;m=[];for(var t=0;t<e.length;t++){var n=e[t];try{n.zone.runTask(n,null,null)}catch(r){o(r)}}}for(;w.length;)for(var a=function(){var e=w.shift();try{e.zone.runGuarded(function(){throw e})}catch(t){o(t)}};w.length;)a();E=!1}}function i(e){return e&&e.then}function s(e){return e}function c(e){return M.reject(e)}function u(e,t){return function(n){l(e,t,n)}}function l(e,t,r){if(e[P]===z)if(r instanceof M&&r[P]!==z)p(r),l(e,r[P],r[D]);else if(i(r))r.then(u(e,t),u(e,!1));else{e[P]=t;var o=e[D];e[D]=r;for(var a=0;a<o.length;)h(e,o[a++],o[a++],o[a++],o[a++]);if(0==o.length&&t==R){e[P]=Z;try{throw new Error("Uncaught (in promise): "+r)}catch(s){var c=s;c.rejection=r,c.promise=e,c.zone=d.current,c.task=d.currentTask,w.push(c),n()}}}return e}function p(e){if(e[P]===Z){e[P]=R;for(var t=0;t<w.length;t++)if(e===w[t].promise){w.splice(t,1);break}}}function h(e,t,n,r,o){p(e);var a=e[P]?r||s:o||c;t.scheduleMicroTask(O,function(){try{l(n,!0,t.run(a,null,[e[D]]))}catch(r){l(n,!1,r)}})}function f(e){var n=e.prototype,r=n[t("then")]=n.then;n.then=function(e,t){var n=this;return new M(function(e,t){r.call(n,e,t)}).then(e,t)}}if(e.Zone)throw new Error("Zone already loaded.");var d=function(){function n(e,t){this._properties=null,this._parent=e,this._name=t?t.name||"unnamed":"<root>",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<c.length;s++){var u=c[s];i(u)||(u=this.resolve(u)),u.then(t,n)}return a},e.all=function(e){for(var t,n,r=new this(function(e,r){t=e,n=r}),o=0,a=[],s=0,c=e;s<c.length;s++){var u=c[s];i(u)||(u=this.resolve(u)),u.then(function(e){return function(n){a[e]=n,o--,o||t(a)}}(o),n),o++}return o||t(a),r},e.prototype.then=function(e,t){var n=new this.constructor(null),r=d.current;return this[P]==z?this[D].push(r,n,e,t):h(this,r,n,e,t),n},e.prototype["catch"]=function(e){return this.then(null,e)},e}();M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;var j=e[t("Promise")]=e.Promise;if(e.Promise=M,j&&(f(j),"undefined"!=typeof e.fetch)){var C=void 0;try{C=e.fetch()}catch(L){C=e.fetch("about:blank")}C.then(function(){return null},function(){return null}),C.constructor!=j&&f(C.constructor)}return Promise[d.__symbol__("uncaughtPromiseErrors")]=w,e.Zone=d}("object"==typeof window&&window||"object"==typeof self&&self||global),zoneSymbol=Zone.__symbol__,_global$1="object"==typeof window&&window||"object"==typeof self&&self||global,isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),isBrowser=!isNode&&!isWebWorker&&!("undefined"==typeof window||!window.HTMLElement),EVENT_TASKS=zoneSymbol("eventTasks"),ADD_EVENT_LISTENER="addEventListener",REMOVE_EVENT_LISTENER="removeEventListener",zoneAwareAddEventListener=makeZoneAwareAddListener(ADD_EVENT_LISTENER,REMOVE_EVENT_LISTENER),zoneAwareRemoveEventListener=makeZoneAwareRemoveListener(REMOVE_EVENT_LISTENER),originalInstanceKey=zoneSymbol("originalInstance"),WTF_ISSUE_555="Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video",NO_EVENT_TARGET="ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex".split(","),EVENT_TARGET="EventTarget",_defineProperty=Object[zoneSymbol("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol("unconfigurables"),eventNames="copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror".split(" "),unboundKey=zoneSymbol("unbound"),set="set",clear="clear",blockingMethods=["alert","prompt","confirm"],_global="object"==typeof window&&window||"object"==typeof self&&self||global;patchTimer(_global,set,clear,"Timeout"),patchTimer(_global,set,clear,"Interval"),patchTimer(_global,set,clear,"Immediate"),patchTimer(_global,"request","cancel","AnimationFrame"),patchTimer(_global,"mozRequest","mozCancel","AnimationFrame"),patchTimer(_global,"webkitRequest","webkitCancel","AnimationFrame");for(var i=0;i<blockingMethods.length;i++){var name=blockingMethods[i];patchMethod(_global,name,function(e,t,n){return function(t,r){return Zone.current.run(e,_global,r,n)}})}eventTargetPatch(_global),propertyDescriptorPatch(_global),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("FileReader"),propertyPatch(),registerElementPatch(_global),patchXHR(_global);var XHR_TASK=zoneSymbol("xhrTask"),XHR_SYNC=zoneSymbol("xhrSync");_global.navigator&&_global.navigator.geolocation&&patchPrototype(_global.navigator.geolocation,["getCurrentPosition","watchPosition"]); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";function e(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 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;a<n.length;a++)o(a)}function n(e,t){var n=Object.getOwnPropertyDescriptor(e,t)||{enumerable:!0,configurable:!0};delete n.writable,delete n.value;var r=t.substr(2),o="_"+t;n.set=function(e){if(this[o]&&this.removeEventListener(r,this[o]),"function"==typeof e){var t=function(t){var n;n=e.apply(this,arguments),void 0==n||n||t.preventDefault()};this[o]=t,this.addEventListener(r,t,!1)}else this[o]=null},n.get=function(){return this[o]||null},Object.defineProperty(e,t,n)}function r(e,t){var r=[];for(var o in e)"on"==o.substr(0,2)&&r.push(o);for(var a=0;a<r.length;a++)n(e,r[a]);if(t)for(var i=0;i<t.length;i++)n(e,"on"+t[i])}function o(e,t,n,r,o){var a=e[j];if(a)for(var i=0;i<a.length;i++){var s=a[i],u=s.data;if(u.handler===t&&u.useCapturing===r&&u.eventName===n)return o&&a.splice(i,1),s}return null}function a(e,t){var n=e[j];n||(n=e[j]=[]),n.push(t)}function i(e,t,n,r){function i(e){var t=e.data;return a(t.target,e),t.target[u](t.eventName,e.invoke,t.useCapturing)}function s(e){var t=e.data;o(t.target,e.invoke,t.eventName,t.useCapturing,!0),t.target[c](t.eventName,e.invoke,t.useCapturing)}void 0===n&&(n=!0),void 0===r&&(r=!1);var u=E(e),c=E(t),l=!n&&void 0;return function(t,n){var a=n[0],c=n[1],f=n[2]||l,p=t||S,h=null;"function"==typeof c?h=c:c&&c.handleEvent&&(h=function(e){return c.handleEvent(e)});var d=!1;try{d=c&&"[object FunctionWrapper]"===c.toString()}catch(v){return}if(!h||d)return p[u](a,c,f);if(!r){var g=o(p,c,a,f,!1);if(g)return p[u](a,g.invoke,f)}var y=Zone.current,k=p.constructor.name+"."+e+":"+a,b={target:p,eventName:a,name:a,useCapturing:f,handler:c};y.scheduleEventTask(k,h,b,i,s)}}function s(e,t){void 0===t&&(t=!0);var n=E(e),r=!t&&void 0;return function(e,t){var a=t[0],i=t[1],s=t[2]||r,u=e||S,c=o(u,i,a,s,!0);c?c.zone.cancelTask(c):u[n](a,i,s)}}function u(e){return!(!e||!e.addEventListener)&&(f(e,z,function(){return C}),f(e,I,function(){return M}),!0)}function c(t){var n=S[t];if(n){S[t]=function(){var r=e(arguments,t);switch(r.length){case 0:this[L]=new n;break;case 1:this[L]=new n(r[0]);break;case 2:this[L]=new n(r[0],r[1]);break;case 3:this[L]=new n(r[0],r[1],r[2]);break;case 4:this[L]=new n(r[0],r[1],r[2],r[3]);break;default:throw new Error("Arg list too long.")}};var r,o=new n(function(){});for(r in o)"XMLHttpRequest"===t&&"responseBlob"===r||!function(e){"function"==typeof o[e]?S[t].prototype[e]=function(){return this[L][e].apply(this[L],arguments)}:Object.defineProperty(S[t].prototype,e,{set:function(n){"function"==typeof n?this[L][e]=Zone.current.wrap(n,t+"."+e):this[L][e]=n},get:function(){return this[L][e]}})}(r);for(r in n)"prototype"!==r&&n.hasOwnProperty(r)&&(S[t][r]=n[r])}}function l(e,t){try{return Function("f","return function "+e+"(){return f(this, arguments)}")(t)}catch(n){return function(){return t(this,arguments)}}}function f(e,t,n){for(var r=e;r&&!r.hasOwnProperty(t);)r=Object.getPrototypeOf(r);!r&&e[t]&&(r=e);var o,a=E(t);return r&&!(o=r[a])&&(o=r[a]=r[t],r[t]=l(t,n(o,a,t))),o}function p(e){var t=[],n=e.wtf;n?t=F.split(",").map(function(e){return"HTML"+e+"Element"}).concat(H):e[R]?t.push(R):t=H;for(var r=0;r<t.length;r++){var o=e[t[r]];u(o&&o.prototype)}}function h(){Object.defineProperty=function(e,t,n){if(v(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);var r=n.configurable;return"prototype"!==t&&(n=g(e,t,n)),y(e,t,n,r)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=g(e,n,t[n])}),x(e,t)},Object.getOwnPropertyDescriptor=function(e,t){var n=B(e,t);return v(e,t)&&(n.configurable=!1),n}}function d(e,t,n){var r=n.configurable;return n=g(e,t,n),y(e,t,n,r)}function v(e,t){return e&&e[W]&&e[W][t]}function g(e,t,n){return n.configurable=!0,n.configurable||(e[W]||q(e,W,{writable:!0,value:{}}),e[W][t]=!0),n}function y(e,t,n,r){try{return q(e,t,n)}catch(o){if(!n.configurable)throw o;"undefined"==typeof r?delete n.configurable:n.configurable=r;try{return q(e,t,n)}catch(o){var a=null;try{a=JSON.stringify(n)}catch(o){a=a.toString()}console.log("Attempting to configure '"+t+"' with descriptor '"+a+"' on object '"+e+"' and got error, giving up: "+o)}}}function k(e){if(O&&"registerElement"in e.document){var t=document.registerElement,n=["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"];document.registerElement=function(e,r){return r&&r.prototype&&n.forEach(function(e){var t="Document.registerElement::"+e;if(r.prototype.hasOwnProperty(e)){var n=Object.getOwnPropertyDescriptor(r.prototype,e);n&&n.value?(n.value=Zone.current.wrap(n.value,t),d(r.prototype,e,n)):r.prototype[e]=Zone.current.wrap(r.prototype[e],t)}else r.prototype[e]&&(r.prototype[e]=Zone.current.wrap(r.prototype[e],t))}),t.apply(document,[e,r])}}}function b(e){var t=e.WebSocket;e.EventTarget||u(t.prototype),e.WebSocket=function(e,n){var o,a=arguments.length>1?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<X.length;t++)e(t)}function _(e,t,n,r){function o(t){var n=t.data;return n.args[0]=t.invoke,n.handleId=i.apply(e,n.args),t}function a(e){return s(e.data.handleId)}var i=null,s=null;t+=r,n+=r,i=f(e,t,function(n){return function(i,s){if("function"==typeof s[0]){var u=Zone.current,c={handleId:null,isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?s[1]||0:null,args:s},l=u.scheduleMacroTask(t,s[0],c,o,a);if(!l)return l;var f=l.data.handleId;return f.ref&&f.unref&&(l.ref=f.ref.bind(f),l.unref=f.unref.bind(f)),l}return n.apply(e,s)}}),s=f(e,n,function(t){return function(n,r){var o=r[0];o&&"string"==typeof o.type?(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&o.zone.cancelTask(o):t.apply(e,r)}})}function D(e){function t(e){var t=e[Q];return t}function n(e){var t=e.data;t.target.addEventListener("readystatechange",function(){t.target.readyState===t.target.DONE&&(t.aborted||e.invoke())});var n=t.target[Q];return n||(t.target[Q]=e),i.apply(t.target,t.args),e}function r(){}function o(e){var t=e.data;return t.aborted=!0,s.apply(t.target,t.args)}var a=f(e.XMLHttpRequest.prototype,"open",function(){return function(e,t){return e[Y]=0==t[2],a.apply(e,t)}}),i=f(e.XMLHttpRequest.prototype,"send",function(){return function(e,t){var a=Zone.current;if(e[Y])return i.apply(e,t);var s={target:e,isPeriodic:!1,delay:null,args:t,aborted:!1};return a.scheduleMacroTask("XMLHttpRequest.send",r,s,n,o)}}),s=f(e.XMLHttpRequest.prototype,"abort",function(e){return function(e,n){var r=t(e);if(r&&"string"==typeof r.type){if(null==r.cancelFn)return;r.zone.cancelTask(r)}}})}var E=(function(e){function t(e){return"__zone_symbol__"+e}function n(){0==E&&0==w.length&&(e[k]?e[k].resolve(0)[b](a):e[y](a,0))}function r(e){n(),w.push(e)}function o(e){var t=e&&e.rejection;t&&console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0),console.error(e)}function a(){if(!_){for(_=!0;w.length;){var e=w;w=[];for(var t=0;t<e.length;t++){var n=e[t];try{n.zone.runTask(n,null,null)}catch(r){o(r)}}}for(;D.length;)for(var a=function(){var e=D.shift();try{e.zone.runGuarded(function(){throw e})}catch(t){o(t)}};D.length;)a();_=!1}}function i(e){return e&&e.then}function s(e){return e}function u(e){return C.reject(e)}function c(e,t){return function(n){l(e,t,n)}}function l(e,t,r){if(e[S]===O)if(r instanceof C&&r[S]!==O)f(r),l(e,r[S],r[P]);else if(i(r))r.then(c(e,t),c(e,!1));else{e[S]=t;var o=e[P];e[P]=r;for(var a=0;a<o.length;)p(e,o[a++],o[a++],o[a++],o[a++]);if(0==o.length&&t==z){e[S]=I;try{throw new Error("Uncaught (in promise): "+r)}catch(s){var u=s;u.rejection=r,u.promise=e,u.zone=d.current,u.task=d.currentTask,D.push(u),n()}}}return e}function f(e){if(e[S]===I){e[S]=z;for(var t=0;t<D.length;t++)if(e===D[t].promise){D.splice(t,1);break}}}function p(e,t,n,r,o){f(e);var a=e[S]?r||s:o||u;t.scheduleMicroTask(Z,function(){try{l(n,!0,t.run(a,null,[e[P]]))}catch(r){l(n,!1,r)}})}function h(e){var n=e.prototype,r=n[t("then")]=n.then;n.then=function(e,t){var n=this;return new C(function(e,t){r.call(n,e,t)}).then(e,t)}}if(e.Zone)throw new Error("Zone already loaded.");var d=function(){function n(e,t){this._properties=null,this._parent=e,this._name=t?t.name||"unnamed":"<root>",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<u.length;s++){var c=u[s];i(c)||(c=this.resolve(c)),c.then(t,n)}return a},e.all=function(e){for(var t,n,r=new this(function(e,r){t=e,n=r}),o=0,a=[],s=0,u=e;s<u.length;s++){var c=u[s];i(c)||(c=this.resolve(c)),c.then(function(e){return function(n){a[e]=n,o--,o||t(a)}}(o),n),o++}return o||t(a),r},e.prototype.then=function(e,t){var n=new this.constructor(null),r=d.current;return this[S]==O?this[P].push(r,n,e,t):p(this,r,n,e,t),n},e.prototype["catch"]=function(e){return this.then(null,e)},e}();C.resolve=C.resolve,C.reject=C.reject,C.race=C.race,C.all=C.all;var M=e[t("Promise")]=e.Promise;if(e.Promise=C,M&&(h(M),"undefined"!=typeof e.fetch)){var L=void 0;try{L=e.fetch()}catch(F){L=e.fetch("about:blank")}L.then(function(){return null},function(){return null}),L.constructor!=M&&h(L.constructor)}return Promise[d.__symbol__("uncaughtPromiseErrors")]=D,e.Zone=d}("object"==typeof window&&window||"object"==typeof self&&self||global),Zone.__symbol__),S="object"==typeof window&&window||"object"==typeof self&&self||global,P="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,Z="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),O=!Z&&!P&&!("undefined"==typeof window||!window.HTMLElement),j=E("eventTasks"),z="addEventListener",I="removeEventListener",C=i(z,I),M=s(I),L=E("originalInstance"),F="Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video",H="ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex".split(","),R="EventTarget",q=Object[E("defineProperty")]=Object.defineProperty,B=Object[E("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,x=Object.create,W=E("unconfigurables"),X="copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror".split(" "),A=E("unbound"),N="set",G="clear",U=["alert","prompt","confirm"],K="object"==typeof window&&window||"object"==typeof self&&self||global;_(K,N,G,"Timeout"),_(K,N,G,"Interval"),_(K,N,G,"Immediate"),_(K,"request","cancel","AnimationFrame"),_(K,"mozRequest","mozCancel","AnimationFrame"),_(K,"webkitRequest","webkitCancel","AnimationFrame");for(var V=0;V<U.length;V++){var J=U[V];f(K,J,function(e,t,n){return function(t,r){return Zone.current.run(e,K,r,n)}})}p(K),m(K),c("MutationObserver"),c("WebKitMutationObserver"),c("FileReader"),h(),k(K),D(K);var Q=E("xhrTask"),Y=E("xhrSync");K.navigator&&K.navigator.geolocation&&t(K.navigator.geolocation,["getCurrentPosition","watchPosition"])}); |
@@ -1,80 +0,78 @@ | ||
(function() { | ||
class AsyncTestZoneSpec implements ZoneSpec { | ||
_finishCallback: Function; | ||
_failCallback: Function; | ||
_pendingMicroTasks: boolean = false; | ||
_pendingMacroTasks: boolean = false; | ||
_alreadyErrored: boolean = false; | ||
runZone = Zone.current; | ||
class AsyncTestZoneSpec implements ZoneSpec { | ||
_finishCallback: Function; | ||
_failCallback: Function; | ||
_pendingMicroTasks: boolean = false; | ||
_pendingMacroTasks: boolean = false; | ||
_alreadyErrored: boolean = false; | ||
runZone = Zone.current; | ||
constructor(finishCallback: Function, failCallback: Function, namePrefix: string) { | ||
this._finishCallback = finishCallback; | ||
this._failCallback = failCallback; | ||
this.name = 'asyncTestZone for ' + namePrefix; | ||
} | ||
constructor(finishCallback: Function, failCallback: Function, namePrefix: string) { | ||
this._finishCallback = finishCallback; | ||
this._failCallback = failCallback; | ||
this.name = 'asyncTestZone for ' + namePrefix; | ||
} | ||
_finishCallbackIfDone() { | ||
if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { | ||
// We do this because we would like to catch unhandled rejected promises. | ||
this.runZone.run(() => { | ||
setTimeout(() => { | ||
if (!this._alreadyErrored && !(this._pendingMicroTasks || this._pendingMacroTasks)) { | ||
this._finishCallback(); | ||
} | ||
}, 0); | ||
}); | ||
} | ||
_finishCallbackIfDone() { | ||
if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { | ||
// We do this because we would like to catch unhandled rejected promises. | ||
this.runZone.run(() => { | ||
setTimeout(() => { | ||
if (!this._alreadyErrored && !(this._pendingMicroTasks || this._pendingMacroTasks)) { | ||
this._finishCallback(); | ||
} | ||
}, 0); | ||
}); | ||
} | ||
} | ||
// ZoneSpec implementation below. | ||
// ZoneSpec implementation below. | ||
name: string; | ||
name: string; | ||
// 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. | ||
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, applyThis: any, applyArgs: any[], source: string): any { | ||
try { | ||
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); | ||
} finally { | ||
this._finishCallbackIfDone(); | ||
} | ||
// 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. | ||
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, applyThis: any, applyArgs: any[], source: string): any { | ||
try { | ||
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); | ||
} finally { | ||
this._finishCallbackIfDone(); | ||
} | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
// Let the parent try to handle the error. | ||
const result = parentZoneDelegate.handleError(targetZone, error); | ||
if (result) { | ||
this._failCallback(error); | ||
this._alreadyErrored = true; | ||
} | ||
return false; | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
// Let the parent try to handle the error. | ||
const result = parentZoneDelegate.handleError(targetZone, error); | ||
if (result) { | ||
this._failCallback(error); | ||
this._alreadyErrored = true; | ||
} | ||
return false; | ||
} | ||
onScheduleTask(delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): 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); | ||
onScheduleTask(delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): Task { | ||
if (task.type == 'macroTask' && task.source == 'setInterval') { | ||
this._failCallback('Cannot use setInterval from within an async zone test.'); | ||
return; | ||
} | ||
onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: 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 delegate.scheduleTask(targetZone, task); | ||
} | ||
onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: 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(); | ||
} | ||
} | ||
} | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; | ||
})(); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; |
@@ -1,68 +0,66 @@ | ||
(function(global: any) { | ||
interface ScheduledFunction { | ||
endTime: number; | ||
id: number, | ||
func: Function; | ||
args: any[]; | ||
delay: number; | ||
} | ||
interface ScheduledFunction { | ||
endTime: number; | ||
id: number, | ||
func: Function; | ||
args: any[]; | ||
delay: number; | ||
} | ||
class Scheduler { | ||
// Next scheduler id. | ||
public nextId: number = 0; | ||
class Scheduler { | ||
// Next scheduler id. | ||
public nextId: number = 0; | ||
// Scheduler queue with the tuple of end time and callback function - sorted by end time. | ||
private _schedulerQueue: ScheduledFunction[] = []; | ||
// Current simulated time in millis. | ||
private _currentTime: number = 0; | ||
constructor() {} | ||
scheduleFunction(cb: Function, delay: number, args: any[] = [], id: number = -1) : number { | ||
let currentId: number = id < 0 ? this.nextId++ : id; | ||
let endTime = this._currentTime + delay; | ||
// Insert so that scheduler queue remains sorted by end time. | ||
let newEntry: ScheduledFunction = { | ||
endTime: endTime, | ||
id: currentId, | ||
func: cb, | ||
args: args, | ||
delay: delay | ||
// Scheduler queue with the tuple of end time and callback function - sorted by end time. | ||
private _schedulerQueue: ScheduledFunction[] = []; | ||
// Current simulated time in millis. | ||
private _currentTime: number = 0; | ||
constructor() {} | ||
scheduleFunction(cb: Function, delay: number, args: any[] = [], id: number = -1) : number { | ||
let currentId: number = id < 0 ? this.nextId++ : id; | ||
let endTime = this._currentTime + delay; | ||
// Insert so that scheduler queue remains sorted by end time. | ||
let newEntry: ScheduledFunction = { | ||
endTime: endTime, | ||
id: currentId, | ||
func: cb, | ||
args: args, | ||
delay: delay | ||
} | ||
let i = 0; | ||
for (; i < this._schedulerQueue.length; i++) { | ||
let currentEntry = this._schedulerQueue[i]; | ||
if (newEntry.endTime < currentEntry.endTime) { | ||
break; | ||
} | ||
let i = 0; | ||
for (; i < this._schedulerQueue.length; i++) { | ||
let currentEntry = this._schedulerQueue[i]; | ||
if (newEntry.endTime < currentEntry.endTime) { | ||
break; | ||
} | ||
} | ||
this._schedulerQueue.splice(i, 0, newEntry); | ||
return currentId; | ||
} | ||
removeScheduledFunctionWithId(id: number): void { | ||
for (let 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; | ||
} | ||
removeScheduledFunctionWithId(id: number): void { | ||
for (let i = 0; i < this._schedulerQueue.length; i++) { | ||
if (this._schedulerQueue[i].id == id) { | ||
this._schedulerQueue.splice(i, 1); | ||
break; | ||
} | ||
} | ||
tick(millis: number = 0): void { | ||
this._currentTime += millis; | ||
while (this._schedulerQueue.length > 0) { | ||
let current = this._schedulerQueue[0]; | ||
if (this._currentTime < current.endTime) { | ||
// Done processing the queue since it's sorted by endTime. | ||
} | ||
tick(millis: number = 0): void { | ||
this._currentTime += millis; | ||
while (this._schedulerQueue.length > 0) { | ||
let current = this._schedulerQueue[0]; | ||
if (this._currentTime < current.endTime) { | ||
// Done processing the queue since it's sorted by endTime. | ||
break; | ||
} else { | ||
// Time to run scheduled function. Remove it from the head of queue. | ||
let current = this._schedulerQueue.shift(); | ||
let retval = current.func.apply(global, current.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. | ||
let current = this._schedulerQueue.shift(); | ||
let retval = current.func.apply(global, current.args); | ||
if (!retval) { | ||
// Uncaught exception in the current scheduled function. Stop processing the queue. | ||
break; | ||
} | ||
} | ||
@@ -72,191 +70,191 @@ } | ||
} | ||
class FakeAsyncTestZoneSpec implements ZoneSpec { | ||
static assertInZone(): void { | ||
if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { | ||
throw new Error('The code should be running in the fakeAsync zone to call this function'); | ||
} | ||
} | ||
private _scheduler: Scheduler = new Scheduler(); | ||
private _microtasks: Function[] = []; | ||
private _lastError: Error = null; | ||
private _uncaughtPromiseErrors: {rejection: any}[] = Promise[Zone['__symbol__']('uncaughtPromiseErrors')]; | ||
pendingPeriodicTimers: number[] = []; | ||
pendingTimers: number[] = []; | ||
} | ||
constructor(namePrefix: string) { | ||
this.name = 'fakeAsyncTestZone for ' + namePrefix; | ||
class FakeAsyncTestZoneSpec implements ZoneSpec { | ||
static assertInZone(): void { | ||
if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { | ||
throw new Error('The code should be running in the fakeAsync zone to call this function'); | ||
} | ||
} | ||
private _scheduler: Scheduler = new Scheduler(); | ||
private _microtasks: Function[] = []; | ||
private _lastError: Error = null; | ||
private _uncaughtPromiseErrors: {rejection: any}[] = Promise[Zone['__symbol__']('uncaughtPromiseErrors')]; | ||
pendingPeriodicTimers: number[] = []; | ||
pendingTimers: number[] = []; | ||
private _fnAndFlush(fn: Function, | ||
completers: {onSuccess?: Function, onError?: Function}): Function { | ||
return (...args): boolean => { | ||
fn.apply(global, args); | ||
if (this._lastError === null) { // Success | ||
if (completers.onSuccess != null) { | ||
completers.onSuccess.apply(global); | ||
} | ||
// Flush microtasks only on success. | ||
this.flushMicrotasks(); | ||
} else { // Failure | ||
if (completers.onError != null) { | ||
completers.onError.apply(global); | ||
} | ||
constructor(namePrefix: string) { | ||
this.name = 'fakeAsyncTestZone for ' + namePrefix; | ||
} | ||
private _fnAndFlush(fn: Function, | ||
completers: {onSuccess?: Function, onError?: Function}): Function { | ||
return (...args): boolean => { | ||
fn.apply(global, args); | ||
if (this._lastError === null) { // Success | ||
if (completers.onSuccess != null) { | ||
completers.onSuccess.apply(global); | ||
} | ||
// Return true if there were no errors, false otherwise. | ||
return this._lastError === null; | ||
// Flush microtasks only on success. | ||
this.flushMicrotasks(); | ||
} else { // Failure | ||
if (completers.onError != null) { | ||
completers.onError.apply(global); | ||
} | ||
} | ||
// Return true if there were no errors, false otherwise. | ||
return this._lastError === null; | ||
} | ||
private static _removeTimer(timers: number[], id:number): void { | ||
let index = timers.indexOf(id); | ||
if (index > -1) { | ||
timers.splice(index, 1); | ||
} | ||
} | ||
private _dequeueTimer(id: number): Function { | ||
return () => { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); | ||
}; | ||
} | ||
private _requeuePeriodicTimer( | ||
fn: Function, interval: number, args: any[], id: number): Function { | ||
return () => { | ||
// Requeue the timer callback if it's not been canceled. | ||
if (this.pendingPeriodicTimers.indexOf(id) !== -1) { | ||
this._scheduler.scheduleFunction(fn, interval, args, id); | ||
} | ||
} | ||
private static _removeTimer(timers: number[], id:number): void { | ||
let index = timers.indexOf(id); | ||
if (index > -1) { | ||
timers.splice(index, 1); | ||
} | ||
} | ||
private _dequeueTimer(id: number): Function { | ||
return () => { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); | ||
}; | ||
} | ||
private _requeuePeriodicTimer( | ||
fn: Function, interval: number, args: any[], id: number): Function { | ||
return () => { | ||
// Requeue the timer callback if it's not been canceled. | ||
if (this.pendingPeriodicTimers.indexOf(id) !== -1) { | ||
this._scheduler.scheduleFunction(fn, interval, args, id); | ||
} | ||
} | ||
} | ||
private _dequeuePeriodicTimer(id: number): Function { | ||
return () => { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); | ||
}; | ||
} | ||
private _setTimeout(fn: Function, delay: number, args: any[]): number { | ||
let removeTimerFn = this._dequeueTimer(this._scheduler.nextId); | ||
// Queue the callback and dequeue the timer on success and error. | ||
let cb = this._fnAndFlush(fn, {onSuccess: removeTimerFn, onError: removeTimerFn}); | ||
let id = this._scheduler.scheduleFunction(cb, delay, args); | ||
this.pendingTimers.push(id); | ||
return id; | ||
} | ||
private _clearTimeout(id: number): void { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); | ||
this._scheduler.removeScheduledFunctionWithId(id); | ||
} | ||
private _setInterval(fn: Function, interval: number, ...args): number { | ||
let id = this._scheduler.nextId; | ||
let completers = {onSuccess: null, onError: this._dequeuePeriodicTimer(id)}; | ||
let cb = this._fnAndFlush(fn, completers); | ||
private _dequeuePeriodicTimer(id: number): Function { | ||
return () => { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); | ||
}; | ||
} | ||
// Use the callback created above to requeue on success. | ||
completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); | ||
private _setTimeout(fn: Function, delay: number, args: any[]): number { | ||
let removeTimerFn = this._dequeueTimer(this._scheduler.nextId); | ||
// Queue the callback and dequeue the timer on success and error. | ||
let cb = this._fnAndFlush(fn, {onSuccess: removeTimerFn, onError: removeTimerFn}); | ||
let id = this._scheduler.scheduleFunction(cb, delay, args); | ||
this.pendingTimers.push(id); | ||
return id; | ||
} | ||
private _clearTimeout(id: number): void { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); | ||
this._scheduler.removeScheduledFunctionWithId(id); | ||
} | ||
private _setInterval(fn: Function, interval: number, ...args): number { | ||
let id = this._scheduler.nextId; | ||
let completers = {onSuccess: null, onError: this._dequeuePeriodicTimer(id)}; | ||
let 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; | ||
} | ||
// Queue the callback and dequeue the periodic timer only on error. | ||
this._scheduler.scheduleFunction(cb, interval, args); | ||
this.pendingPeriodicTimers.push(id); | ||
return id; | ||
} | ||
private _clearInterval(id: number): void { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); | ||
this._scheduler.removeScheduledFunctionWithId(id); | ||
private _clearInterval(id: number): void { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); | ||
this._scheduler.removeScheduledFunctionWithId(id); | ||
} | ||
private _resetLastErrorAndThrow(): void { | ||
let error = this._lastError || this._uncaughtPromiseErrors[0]; | ||
this._uncaughtPromiseErrors.length = 0; | ||
this._lastError = null; | ||
throw error; | ||
} | ||
tick(millis: number = 0): void { | ||
FakeAsyncTestZoneSpec.assertInZone(); | ||
this.flushMicrotasks(); | ||
this._scheduler.tick(millis); | ||
if (this._lastError !== null) { | ||
this._resetLastErrorAndThrow(); | ||
} | ||
} | ||
private _resetLastErrorAndThrow(): void { | ||
let error = this._lastError || this._uncaughtPromiseErrors[0]; | ||
this._uncaughtPromiseErrors.length = 0; | ||
this._lastError = null; | ||
throw error; | ||
} | ||
tick(millis: number = 0): void { | ||
FakeAsyncTestZoneSpec.assertInZone(); | ||
this.flushMicrotasks(); | ||
this._scheduler.tick(millis); | ||
if (this._lastError !== null) { | ||
flushMicrotasks(): void { | ||
FakeAsyncTestZoneSpec.assertInZone(); | ||
const flushErrors = () => { | ||
if (this._lastError !== null || this._uncaughtPromiseErrors.length) { | ||
// If there is an error stop processing the microtask queue and rethrow the error. | ||
this._resetLastErrorAndThrow(); | ||
} | ||
} | ||
flushMicrotasks(): void { | ||
FakeAsyncTestZoneSpec.assertInZone(); | ||
const flushErrors = () => { | ||
if (this._lastError !== null || this._uncaughtPromiseErrors.length) { | ||
// If there is an error stop processing the microtask queue and rethrow the error. | ||
this._resetLastErrorAndThrow(); | ||
} | ||
} | ||
while (this._microtasks.length > 0) { | ||
let microtask = this._microtasks.shift(); | ||
microtask(); | ||
} | ||
flushErrors(); | ||
while (this._microtasks.length > 0) { | ||
let microtask = this._microtasks.shift(); | ||
microtask(); | ||
} | ||
flushErrors(); | ||
} | ||
// ZoneSpec implementation below. | ||
// ZoneSpec implementation below. | ||
name: string; | ||
name: string; | ||
properties: { [key: string]: any } = { 'FakeAsyncTestZoneSpec': this }; | ||
properties: { [key: string]: any } = { 'FakeAsyncTestZoneSpec': this }; | ||
onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): 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; | ||
onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): 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; | ||
} | ||
onCancelTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): any { | ||
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); | ||
} | ||
onCancelTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): any { | ||
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); | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
this._lastError = error; | ||
return false; // Don't propagate error to parent zone. | ||
} | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
this._lastError = error; | ||
return false; // Don't propagate error to parent zone. | ||
} | ||
} | ||
// 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); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; |
@@ -1,146 +0,143 @@ | ||
'use strict'; | ||
(function() { | ||
const NEWLINE = '\n'; | ||
const SEP = ' ------------- '; | ||
const IGNORE_FRAMES = []; | ||
const creationTrace = '__creationTrace__'; | ||
const NEWLINE = '\n'; | ||
const SEP = ' ------------- '; | ||
const IGNORE_FRAMES = []; | ||
const creationTrace = '__creationTrace__'; | ||
class LongStackTrace { | ||
error: Error = getStacktrace(); | ||
timestamp: Date = new Date(); | ||
class LongStackTrace { | ||
error: Error = getStacktrace(); | ||
timestamp: Date = new Date(); | ||
} | ||
} | ||
function getStacktraceWithUncaughtError (): Error { | ||
return new Error('STACKTRACE TRACKING'); | ||
} | ||
function getStacktraceWithUncaughtError (): Error { | ||
return new Error('STACKTRACE TRACKING'); | ||
} | ||
function getStacktraceWithCaughtError(): Error { | ||
try { | ||
throw getStacktraceWithUncaughtError(); | ||
} catch (e) { | ||
return e; | ||
} | ||
function getStacktraceWithCaughtError(): Error { | ||
try { | ||
throw getStacktraceWithUncaughtError(); | ||
} catch (e) { | ||
return e; | ||
} | ||
} | ||
// 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. | ||
const error = getStacktraceWithUncaughtError(); | ||
const coughtError = getStacktraceWithCaughtError(); | ||
const getStacktrace = error.stack | ||
? getStacktraceWithUncaughtError | ||
: (coughtError.stack ? getStacktraceWithCaughtError: 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. | ||
const error = getStacktraceWithUncaughtError(); | ||
const coughtError = getStacktraceWithCaughtError(); | ||
const getStacktrace = error.stack | ||
? getStacktraceWithUncaughtError | ||
: (coughtError.stack ? getStacktraceWithCaughtError: getStacktraceWithUncaughtError); | ||
function getFrames(error: Error): string[] { | ||
return error.stack ? error.stack.split(NEWLINE) : []; | ||
} | ||
function getFrames(error: Error): string[] { | ||
return error.stack ? error.stack.split(NEWLINE) : []; | ||
} | ||
function addErrorStack(lines:string[], error:Error):void { | ||
let trace: string[] = getFrames(error); | ||
for (let i = 0; i < trace.length; i++) { | ||
const 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 addErrorStack(lines:string[], error:Error):void { | ||
let trace: string[] = getFrames(error); | ||
for (let i = 0; i < trace.length; i++) { | ||
const 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: LongStackTrace[], stack: string): string { | ||
const longTrace: string[] = [stack]; | ||
function renderLongStackTrace(frames: LongStackTrace[], stack: string): string { | ||
const longTrace: string[] = [stack]; | ||
if (frames) { | ||
let timestamp = new Date().getTime(); | ||
for (let i = 0; i < frames.length; i++) { | ||
const traceFrames: LongStackTrace = frames[i]; | ||
const lastTime = traceFrames.timestamp; | ||
longTrace.push(`${SEP} Elapsed: ${timestamp - lastTime.getTime()} ms; At: ${lastTime} ${SEP}`); | ||
addErrorStack(longTrace, traceFrames.error); | ||
if (frames) { | ||
let timestamp = new Date().getTime(); | ||
for (let i = 0; i < frames.length; i++) { | ||
const traceFrames: LongStackTrace = frames[i]; | ||
const lastTime = traceFrames.timestamp; | ||
longTrace.push(`${SEP} Elapsed: ${timestamp - lastTime.getTime()} ms; At: ${lastTime} ${SEP}`); | ||
addErrorStack(longTrace, traceFrames.error); | ||
timestamp = lastTime.getTime(); | ||
} | ||
timestamp = lastTime.getTime(); | ||
} | ||
return longTrace.join(NEWLINE); | ||
} | ||
Zone['longStackTraceZoneSpec'] = <ZoneSpec>{ | ||
name: 'long-stack-trace', | ||
longStackTraceLimit: 10, // Max number of task to keep the stack trace for. | ||
return longTrace.join(NEWLINE); | ||
} | ||
onScheduleTask: function(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any | ||
{ | ||
const currentTask = Zone.currentTask; | ||
let 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); | ||
}, | ||
Zone['longStackTraceZoneSpec'] = <ZoneSpec>{ | ||
name: 'long-stack-trace', | ||
longStackTraceLimit: 10, // Max number of task to keep the stack trace for. | ||
onHandleError: function(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): any | ||
{ | ||
const parentTask = Zone.currentTask || error.task; | ||
if (error instanceof Error && parentTask) { | ||
var stackSetSucceded: string|boolean = null; | ||
onScheduleTask: function(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any | ||
{ | ||
const currentTask = Zone.currentTask; | ||
let 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: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): any | ||
{ | ||
const parentTask = Zone.currentTask || error.task; | ||
if (error instanceof Error && parentTask) { | ||
var stackSetSucceded: string|boolean = null; | ||
try { | ||
let descriptor = Object.getOwnPropertyDescriptor(error, 'stack'); | ||
if (descriptor && descriptor.configurable) { | ||
const delegateGet = descriptor.get; | ||
const value = descriptor.value; | ||
descriptor = { | ||
get: function () { | ||
return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], | ||
delegateGet ? delegateGet.apply(this) : value); | ||
} | ||
}; | ||
Object.defineProperty(error, 'stack', descriptor); | ||
stackSetSucceded = true; | ||
} | ||
} catch (e) { } | ||
var longStack: string = stackSetSucceded ? null : renderLongStackTrace( | ||
parentTask.data && parentTask.data[creationTrace], error.stack); | ||
if (!stackSetSucceded) { | ||
try { | ||
let descriptor = Object.getOwnPropertyDescriptor(error, 'stack'); | ||
if (descriptor && descriptor.configurable) { | ||
const delegateGet = descriptor.get; | ||
const value = descriptor.value; | ||
descriptor = { | ||
get: function () { | ||
return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], | ||
delegateGet ? delegateGet.apply(this) : value); | ||
} | ||
}; | ||
Object.defineProperty(error, 'stack', descriptor); | ||
stackSetSucceded = true; | ||
} | ||
stackSetSucceded = error.stack = longStack; | ||
} catch (e) { } | ||
var longStack: string = stackSetSucceded ? null : renderLongStackTrace( | ||
parentTask.data && parentTask.data[creationTrace], error.stack); | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = error.stack = longStack; | ||
} catch (e) { } | ||
} | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = (error as any).longStack = longStack; | ||
} catch (e) { } | ||
} | ||
} | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = (error as any).longStack = longStack; | ||
} catch (e) { } | ||
} | ||
} | ||
}; | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
}; | ||
function captureStackTraces(stackTraces: string[][], count: number): void { | ||
if (count > 0) { | ||
stackTraces.push(getFrames((new LongStackTrace()).error)); | ||
captureStackTraces(stackTraces, count - 1); | ||
} | ||
function captureStackTraces(stackTraces: string[][], count: number): void { | ||
if (count > 0) { | ||
stackTraces.push(getFrames((new LongStackTrace()).error)); | ||
captureStackTraces(stackTraces, count - 1); | ||
} | ||
} | ||
function computeIgnoreFrames() { | ||
const frames: string[][] = []; | ||
captureStackTraces(frames, 2); | ||
const frames1 = frames[0]; | ||
const frames2 = frames[1]; | ||
for (let i = 0; i < frames1.length; i++) { | ||
const frame1 = frames1[i]; | ||
const frame2 = frames2[i]; | ||
if (frame1 === frame2) { | ||
IGNORE_FRAMES.push(frame1); | ||
} else { | ||
break; | ||
} | ||
function computeIgnoreFrames() { | ||
const frames: string[][] = []; | ||
captureStackTraces(frames, 2); | ||
const frames1 = frames[0]; | ||
const frames2 = frames[1]; | ||
for (let i = 0; i < frames1.length; i++) { | ||
const frame1 = frames1[i]; | ||
const frame2 = frames2[i]; | ||
if (frame1 === frame2) { | ||
IGNORE_FRAMES.push(frame1); | ||
} else { | ||
break; | ||
} | ||
} | ||
computeIgnoreFrames(); | ||
})(); | ||
} | ||
computeIgnoreFrames(); |
@@ -1,128 +0,126 @@ | ||
(function () { | ||
class ProxyZoneSpec implements ZoneSpec { | ||
name: string = 'ProxyZone'; | ||
class ProxyZoneSpec implements ZoneSpec { | ||
name: string = 'ProxyZone'; | ||
private _delegateSpec: ZoneSpec; | ||
private _delegateSpec: ZoneSpec; | ||
properties: {[k: string]: any} = {'ProxyZoneSpec': this}; | ||
propertyKeys: string[] = null; | ||
properties: {[k: string]: any} = {'ProxyZoneSpec': this}; | ||
propertyKeys: string[] = null; | ||
static get(): ProxyZoneSpec { | ||
return Zone.current.get('ProxyZoneSpec'); | ||
} | ||
static get(): ProxyZoneSpec { | ||
return Zone.current.get('ProxyZoneSpec'); | ||
} | ||
static isLoaded(): boolean { | ||
return ProxyZoneSpec.get() instanceof ProxyZoneSpec; | ||
} | ||
static isLoaded(): boolean { | ||
return ProxyZoneSpec.get() instanceof ProxyZoneSpec; | ||
} | ||
static assertPresent(): ProxyZoneSpec { | ||
if (!this.isLoaded()) { | ||
throw new Error(`Expected to be running in 'ProxyZone', but it was not found.`); | ||
} | ||
return ProxyZoneSpec.get(); | ||
static assertPresent(): ProxyZoneSpec { | ||
if (!this.isLoaded()) { | ||
throw new Error(`Expected to be running in 'ProxyZone', but it was not found.`); | ||
} | ||
return ProxyZoneSpec.get(); | ||
} | ||
constructor(private defaultSpecDelegate: ZoneSpec = null) { | ||
this.setDelegate(defaultSpecDelegate); | ||
} | ||
constructor(private defaultSpecDelegate: ZoneSpec = null) { | ||
this.setDelegate(defaultSpecDelegate); | ||
} | ||
setDelegate(delegateSpec: ZoneSpec) { | ||
this._delegateSpec = delegateSpec; | ||
this.propertyKeys && this.propertyKeys.forEach((key) => delete this.properties[key]); | ||
this.propertyKeys = null; | ||
if (delegateSpec && delegateSpec.properties) { | ||
this.propertyKeys = Object.keys(delegateSpec.properties); | ||
this.propertyKeys.forEach((k) => this.properties[k] = delegateSpec.properties[k]); | ||
} | ||
setDelegate(delegateSpec: ZoneSpec) { | ||
this._delegateSpec = delegateSpec; | ||
this.propertyKeys && this.propertyKeys.forEach((key) => delete this.properties[key]); | ||
this.propertyKeys = null; | ||
if (delegateSpec && delegateSpec.properties) { | ||
this.propertyKeys = Object.keys(delegateSpec.properties); | ||
this.propertyKeys.forEach((k) => this.properties[k] = delegateSpec.properties[k]); | ||
} | ||
} | ||
getDelegate() { | ||
return this._delegateSpec; | ||
} | ||
getDelegate() { | ||
return this._delegateSpec; | ||
} | ||
resetDelegate() { | ||
this.setDelegate(this.defaultSpecDelegate); | ||
} | ||
resetDelegate() { | ||
this.setDelegate(this.defaultSpecDelegate); | ||
} | ||
onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
zoneSpec: ZoneSpec): Zone { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); | ||
} else { | ||
return parentZoneDelegate.fork(targetZone, zoneSpec); | ||
} | ||
onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
zoneSpec: ZoneSpec): Zone { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); | ||
} else { | ||
return parentZoneDelegate.fork(targetZone, zoneSpec); | ||
} | ||
} | ||
onIntercept(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, source: string): Function { | ||
if (this._delegateSpec && this._delegateSpec.onIntercept) { | ||
return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); | ||
} else { | ||
return parentZoneDelegate.intercept(targetZone, delegate, source); | ||
} | ||
onIntercept(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, source: string): Function { | ||
if (this._delegateSpec && this._delegateSpec.onIntercept) { | ||
return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); | ||
} else { | ||
return parentZoneDelegate.intercept(targetZone, delegate, source); | ||
} | ||
} | ||
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, applyThis: any, applyArgs: any[], source: string): any { | ||
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); | ||
} | ||
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, applyThis: any, applyArgs: any[], source: string): any { | ||
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); | ||
} | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
if (this._delegateSpec && this._delegateSpec.onHandleError) { | ||
return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); | ||
} else { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
if (this._delegateSpec && this._delegateSpec.onHandleError) { | ||
return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); | ||
} else { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
} | ||
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): Task { | ||
if (this._delegateSpec && this._delegateSpec.onScheduleTask) { | ||
return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} else { | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
} | ||
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): Task { | ||
if (this._delegateSpec && this._delegateSpec.onScheduleTask) { | ||
return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} else { | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
} | ||
} | ||
onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task, applyThis: any, applyArgs: any): any { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); | ||
} else { | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
} | ||
onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task, applyThis: any, applyArgs: any): any { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); | ||
} else { | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
} | ||
} | ||
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any { | ||
if (this._delegateSpec && this._delegateSpec.onCancelTask) { | ||
return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} else { | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
} | ||
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any { | ||
if (this._delegateSpec && this._delegateSpec.onCancelTask) { | ||
return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} else { | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
} | ||
} | ||
onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, | ||
hasTaskState: HasTaskState): void { | ||
if (this._delegateSpec && this._delegateSpec.onHasTask) { | ||
this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); | ||
} else { | ||
delegate.hasTask(target, hasTaskState); | ||
} | ||
onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, | ||
hasTaskState: HasTaskState): void { | ||
if (this._delegateSpec && this._delegateSpec.onHasTask) { | ||
this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); | ||
} else { | ||
delegate.hasTask(target, hasTaskState); | ||
} | ||
} | ||
} | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['ProxyZoneSpec'] = ProxyZoneSpec; | ||
})(); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['ProxyZoneSpec'] = ProxyZoneSpec; |
@@ -1,29 +0,27 @@ | ||
(function() { | ||
class SyncTestZoneSpec implements ZoneSpec { | ||
runZone = Zone.current; | ||
class SyncTestZoneSpec implements ZoneSpec { | ||
runZone = Zone.current; | ||
constructor(namePrefix: string) { | ||
this.name = 'syncTestZone for ' + namePrefix; | ||
} | ||
constructor(namePrefix: string) { | ||
this.name = 'syncTestZone for ' + namePrefix; | ||
} | ||
// ZoneSpec implementation below. | ||
// ZoneSpec implementation below. | ||
name: string; | ||
name: string; | ||
onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): 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; | ||
onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): 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; | ||
} | ||
} | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; | ||
})(); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; |
@@ -1,140 +0,138 @@ | ||
(function(global) { | ||
interface Wtf { trace: WtfTrace; } | ||
interface WtfScope {}; | ||
interface WtfRange {}; | ||
interface WtfTrace { | ||
events: WtfEvents; | ||
leaveScope(scope: WtfScope, returnValue?: any): void; | ||
beginTimeRange(rangeType: string, action: string): WtfRange; | ||
endTimeRange(range: WtfRange): void; | ||
} | ||
interface WtfEvents { | ||
createScope(signature: string, flags?: any): WtfScopeFn; | ||
createInstance(signature: string, flags?: any): WtfEventFn; | ||
} | ||
interface Wtf { trace: WtfTrace; } | ||
interface WtfScope {}; | ||
interface WtfRange {}; | ||
interface WtfTrace { | ||
events: WtfEvents; | ||
leaveScope(scope: WtfScope, returnValue?: any): void; | ||
beginTimeRange(rangeType: string, action: string): WtfRange; | ||
endTimeRange(range: WtfRange): void; | ||
} | ||
interface WtfEvents { | ||
createScope(signature: string, flags?: any): WtfScopeFn; | ||
createInstance(signature: string, flags?: any): WtfEventFn; | ||
} | ||
type WtfScopeFn = (...args: any[]) => WtfScope; | ||
type WtfEventFn = (...args: any[]) => any; | ||
type WtfScopeFn = (...args: any[]) => WtfScope; | ||
type WtfEventFn = (...args: any[]) => any; | ||
// Detect and setup WTF. | ||
let wtfTrace: WtfTrace = null; | ||
let wtfEvents: WtfEvents = null; | ||
const wtfEnabled: boolean = (function (): boolean { | ||
const wtf: Wtf = global['wtf']; | ||
if (wtf) { | ||
wtfTrace = wtf.trace; | ||
if (wtfTrace) { | ||
wtfEvents = wtfTrace.events; | ||
return true; | ||
} | ||
// Detect and setup WTF. | ||
let wtfTrace: WtfTrace = null; | ||
let wtfEvents: WtfEvents = null; | ||
const wtfEnabled: boolean = (function (): boolean { | ||
const wtf: Wtf = global['wtf']; | ||
if (wtf) { | ||
wtfTrace = wtf.trace; | ||
if (wtfTrace) { | ||
wtfEvents = wtfTrace.events; | ||
return true; | ||
} | ||
return false; | ||
})(); | ||
} | ||
return false; | ||
})(); | ||
class WtfZoneSpec implements ZoneSpec { | ||
name: string = 'WTF'; | ||
class WtfZoneSpec implements ZoneSpec { | ||
name: string = 'WTF'; | ||
static forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); | ||
static scheduleInstance: {[key: string]: WtfEventFn} = {}; | ||
static cancelInstance: {[key: string]: WtfEventFn} = {}; | ||
static invokeScope: {[key: string]: WtfEventFn} = {}; | ||
static invokeTaskScope: {[key: string]: WtfEventFn} = {}; | ||
static forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); | ||
static scheduleInstance: {[key: string]: WtfEventFn} = {}; | ||
static cancelInstance: {[key: string]: WtfEventFn} = {}; | ||
static invokeScope: {[key: string]: WtfEventFn} = {}; | ||
static invokeTaskScope: {[key: string]: WtfEventFn} = {}; | ||
onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
zoneSpec: ZoneSpec): Zone { | ||
const retValue = parentZoneDelegate.fork(targetZone, zoneSpec); | ||
WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); | ||
return retValue; | ||
} | ||
onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
zoneSpec: ZoneSpec): Zone { | ||
const retValue = parentZoneDelegate.fork(targetZone, zoneSpec); | ||
WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); | ||
return retValue; | ||
} | ||
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, applyThis: any, applyArgs: any[], source: string): any { | ||
let scope = WtfZoneSpec.invokeScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeScope[source] | ||
= wtfEvents.createScope(`Zone:invoke:${source}(ascii zone)`); | ||
} | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), | ||
parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); | ||
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
delegate: Function, applyThis: any, applyArgs: any[], source: string): any { | ||
let scope = WtfZoneSpec.invokeScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeScope[source] | ||
= wtfEvents.createScope(`Zone:invoke:${source}(ascii zone)`); | ||
} | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), | ||
parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
error: any): boolean { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any { | ||
const key = task.type + ':' + task.source; | ||
let instance = WtfZoneSpec.scheduleInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.scheduleInstance[key] | ||
= wtfEvents.createInstance(`Zone:schedule:${key}(ascii zone, any data)`); | ||
} | ||
const retValue = parentZoneDelegate.scheduleTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any { | ||
const key = task.type + ':' + task.source; | ||
let instance = WtfZoneSpec.scheduleInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.scheduleInstance[key] | ||
= wtfEvents.createInstance(`Zone:schedule:${key}(ascii zone, any data)`); | ||
} | ||
const retValue = parentZoneDelegate.scheduleTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
} | ||
onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task, applyThis: any, applyArgs: any[]): any | ||
{ | ||
const source = task.source; | ||
let scope = WtfZoneSpec.invokeTaskScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeTaskScope[source] | ||
= wtfEvents.createScope(`Zone:invokeTask:${source}(ascii zone)`); | ||
} | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), | ||
parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); | ||
onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task, applyThis: any, applyArgs: any[]): any | ||
{ | ||
const source = task.source; | ||
let scope = WtfZoneSpec.invokeTaskScope[source]; | ||
if (!scope) { | ||
scope = WtfZoneSpec.invokeTaskScope[source] | ||
= wtfEvents.createScope(`Zone:invokeTask:${source}(ascii zone)`); | ||
} | ||
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any { | ||
const key = task.source; | ||
let instance = WtfZoneSpec.cancelInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.cancelInstance[key] | ||
= wtfEvents.createInstance(`Zone:cancel:${key}(ascii zone, any options)`); | ||
} | ||
const retValue = parentZoneDelegate.cancelTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
}; | ||
return wtfTrace.leaveScope(scope(zonePathName(targetZone)), | ||
parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); | ||
} | ||
function shallowObj(obj: any, depth: number): any { | ||
if (!depth) return null; | ||
const out = {}; | ||
for(const key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
let value = obj[key]; | ||
switch (typeof value) { | ||
case 'object': | ||
const name = value && value.constructor && (<any>value.constructor).name; | ||
value = name == (<any>Object).name ? shallowObj(value, depth - 1) : name; | ||
break; | ||
case 'function': | ||
value = value.name || undefined; | ||
break; | ||
} | ||
out[key] = value; | ||
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, | ||
task: Task): any { | ||
const key = task.source; | ||
let instance = WtfZoneSpec.cancelInstance[key]; | ||
if (!instance) { | ||
instance = WtfZoneSpec.cancelInstance[key] | ||
= wtfEvents.createInstance(`Zone:cancel:${key}(ascii zone, any options)`); | ||
} | ||
const retValue = parentZoneDelegate.cancelTask(targetZone, task); | ||
instance(zonePathName(targetZone), shallowObj(task.data, 2)); | ||
return retValue; | ||
}; | ||
} | ||
function shallowObj(obj: any, depth: number): any { | ||
if (!depth) return null; | ||
const out = {}; | ||
for(const key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
let value = obj[key]; | ||
switch (typeof value) { | ||
case 'object': | ||
const name = value && value.constructor && (<any>value.constructor).name; | ||
value = name == (<any>Object).name ? shallowObj(value, depth - 1) : name; | ||
break; | ||
case 'function': | ||
value = value.name || undefined; | ||
break; | ||
} | ||
out[key] = value; | ||
} | ||
return out; | ||
} | ||
return out; | ||
} | ||
function zonePathName(zone: Zone) { | ||
let name: string = zone.name; | ||
function zonePathName(zone: Zone) { | ||
let name: string = zone.name; | ||
zone = zone.parent; | ||
while(zone != null) { | ||
name = zone.name + '::' + name; | ||
zone = zone.parent; | ||
while(zone != null) { | ||
name = zone.name + '::' + name; | ||
zone = zone.parent; | ||
} | ||
return name; | ||
} | ||
return name; | ||
} | ||
Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); | ||
})(typeof window === 'object' && window || typeof self === 'object' && self || global); | ||
Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); |
{ | ||
"name": "zone.js", | ||
"version": "0.6.23", | ||
"version": "0.6.24", | ||
"description": "Zones for JavaScript", | ||
@@ -56,3 +56,2 @@ "main": "dist/zone-node.js", | ||
"karma-sourcemap-loader": "^0.3.6", | ||
"karma-webpack": "^1.7.0", | ||
"nodejs-websocket": "^1.2.0", | ||
@@ -59,0 +58,0 @@ "pump": "^1.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25
6486
309349
1