Comparing version 0.6.17 to 0.6.18
@@ -1,118 +0,68 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
(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; | ||
} | ||
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; | ||
})(); | ||
/***/ } | ||
/******/ ]); | ||
(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; | ||
} | ||
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; | ||
})(); |
@@ -1,289 +0,238 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
/* WEBPACK VAR INJECTION */(function(global) {(function () { | ||
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; | ||
} | ||
} | ||
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; | ||
} | ||
else { | ||
// Time to run scheduled function. Remove it from the head of queue. | ||
var current_1 = this._schedulerQueue.shift(); | ||
var retval = current_1.func.apply(global, current_1.args); | ||
if (!retval) { | ||
// Uncaught exception in the current scheduled function. Stop processing the queue. | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
return Scheduler; | ||
}()); | ||
var FakeAsyncTestZoneSpec = (function () { | ||
function FakeAsyncTestZoneSpec(namePrefix) { | ||
this._scheduler = new Scheduler(); | ||
this._microtasks = []; | ||
this._lastError = null; | ||
this._uncaughtPromiseErrors = Promise[Zone['__symbol__']('uncaughtPromiseErrors')]; | ||
this.pendingPeriodicTimers = []; | ||
this.pendingTimers = []; | ||
this.properties = { 'FakeAsyncTestZoneSpec': this }; | ||
this.name = 'fakeAsyncTestZone for ' + namePrefix; | ||
} | ||
FakeAsyncTestZoneSpec.assertInZone = function () { | ||
if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { | ||
throw new Error('The code should be running in the fakeAsync zone to call this function'); | ||
} | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { | ||
var _this = this; | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i - 0] = arguments[_i]; | ||
} | ||
fn.apply(global, args); | ||
if (_this._lastError === null) { | ||
if (completers.onSuccess != null) { | ||
completers.onSuccess.apply(global); | ||
} | ||
// Flush microtasks only on success. | ||
_this.flushMicrotasks(); | ||
} | ||
else { | ||
if (completers.onError != null) { | ||
completers.onError.apply(global); | ||
} | ||
} | ||
// Return true if there were no errors, false otherwise. | ||
return _this._lastError === null; | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { | ||
var index = timers.indexOf(id); | ||
if (index > -1) { | ||
timers.splice(index, 1); | ||
} | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { | ||
var _this = this; | ||
return function () { | ||
FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { | ||
var _this = this; | ||
return function () { | ||
// Requeue the timer callback if it's not been canceled. | ||
if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { | ||
_this._scheduler.scheduleFunction(fn, interval, args, id); | ||
} | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { | ||
var _this = this; | ||
return function () { | ||
FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args) { | ||
var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); | ||
// Queue the callback and dequeue the timer on success and error. | ||
var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); | ||
var id = this._scheduler.scheduleFunction(cb, delay, args); | ||
this.pendingTimers.push(id); | ||
return id; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); | ||
this._scheduler.removeScheduledFunctionWithId(id); | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { | ||
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(); | ||
} | ||
}; | ||
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; | ||
})(); | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ } | ||
/******/ ]); | ||
(function () { | ||
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; | ||
} | ||
} | ||
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; | ||
} | ||
else { | ||
// Time to run scheduled function. Remove it from the head of queue. | ||
var current_1 = this._schedulerQueue.shift(); | ||
var retval = current_1.func.apply(global, current_1.args); | ||
if (!retval) { | ||
// Uncaught exception in the current scheduled function. Stop processing the queue. | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
return Scheduler; | ||
}()); | ||
var FakeAsyncTestZoneSpec = (function () { | ||
function FakeAsyncTestZoneSpec(namePrefix) { | ||
this._scheduler = new Scheduler(); | ||
this._microtasks = []; | ||
this._lastError = null; | ||
this._uncaughtPromiseErrors = Promise[Zone['__symbol__']('uncaughtPromiseErrors')]; | ||
this.pendingPeriodicTimers = []; | ||
this.pendingTimers = []; | ||
this.properties = { 'FakeAsyncTestZoneSpec': this }; | ||
this.name = 'fakeAsyncTestZone for ' + namePrefix; | ||
} | ||
FakeAsyncTestZoneSpec.assertInZone = function () { | ||
if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { | ||
throw new Error('The code should be running in the fakeAsync zone to call this function'); | ||
} | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { | ||
var _this = this; | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i - 0] = arguments[_i]; | ||
} | ||
fn.apply(global, args); | ||
if (_this._lastError === null) { | ||
if (completers.onSuccess != null) { | ||
completers.onSuccess.apply(global); | ||
} | ||
// Flush microtasks only on success. | ||
_this.flushMicrotasks(); | ||
} | ||
else { | ||
if (completers.onError != null) { | ||
completers.onError.apply(global); | ||
} | ||
} | ||
// Return true if there were no errors, false otherwise. | ||
return _this._lastError === null; | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { | ||
var index = timers.indexOf(id); | ||
if (index > -1) { | ||
timers.splice(index, 1); | ||
} | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { | ||
var _this = this; | ||
return function () { | ||
FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { | ||
var _this = this; | ||
return function () { | ||
// Requeue the timer callback if it's not been canceled. | ||
if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { | ||
_this._scheduler.scheduleFunction(fn, interval, args, id); | ||
} | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { | ||
var _this = this; | ||
return function () { | ||
FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); | ||
}; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args) { | ||
var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); | ||
// Queue the callback and dequeue the timer on success and error. | ||
var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); | ||
var id = this._scheduler.scheduleFunction(cb, delay, args); | ||
this.pendingTimers.push(id); | ||
return id; | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { | ||
FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); | ||
this._scheduler.removeScheduledFunctionWithId(id); | ||
}; | ||
FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { | ||
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(); | ||
} | ||
}; | ||
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; | ||
})(); |
@@ -1,160 +0,111 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
(function () { | ||
// Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs | ||
// in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) | ||
if (!Zone) | ||
throw new Error("Missing: zone.js"); | ||
if (typeof jasmine == 'undefined') | ||
throw new Error("Missing: jasmine.js"); | ||
if (jasmine['__zone_patch__']) | ||
throw new Error("'jasmine' has already been patched with 'Zone'."); | ||
jasmine['__zone_patch__'] = true; | ||
var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; | ||
var ProxyZoneSpec = Zone['ProxyZoneSpec']; | ||
if (!SyncTestZoneSpec) | ||
throw new Error("Missing: SyncTestZoneSpec"); | ||
if (!ProxyZoneSpec) | ||
throw new Error("Missing: ProxyZoneSpec"); | ||
var ambientZone = Zone.current; | ||
// Create a synchronous-only zone in which to run `describe` blocks in order to raise an | ||
// error if any asynchronous operations are attempted inside of a `describe` but outside of | ||
// a `beforeEach` or `it`. | ||
var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); | ||
// This is the zone which will be used for running individual tests. | ||
// It will be a proxy zone, so that the tests function can retroactively install | ||
// different zones. | ||
// Example: | ||
// - In beforeEach() do childZone = Zone.current.fork(...); | ||
// - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the | ||
// zone outside of fakeAsync it will be able to escope the fakeAsync rules. | ||
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add | ||
// fakeAsync behavior to the childZone. | ||
var testProxyZone = null; | ||
// Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. | ||
var jasmineEnv = jasmine.getEnv(); | ||
['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { | ||
var originalJasmineFn = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function (description, specDefinitions) { | ||
return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); | ||
}; | ||
}); | ||
['it', 'xit', 'fit'].forEach(function (methodName) { | ||
var originalJasmineFn = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function (description, specDefinitions) { | ||
return originalJasmineFn.call(this, description, wrapTestInZone(specDefinitions)); | ||
}; | ||
}); | ||
['beforeEach', 'afterEach'].forEach(function (methodName) { | ||
var originalJasmineFn = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function (specDefinitions) { | ||
return originalJasmineFn.call(this, wrapTestInZone(specDefinitions)); | ||
}; | ||
}); | ||
/** | ||
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a | ||
* synchronous-only zone. | ||
*/ | ||
function wrapDescribeInZone(describeBody) { | ||
return function () { | ||
return syncZone.run(describeBody, this, arguments); | ||
}; | ||
} | ||
/** | ||
* Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to | ||
* execute in a ProxyZone zone. | ||
* This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` | ||
*/ | ||
function wrapTestInZone(testBody) { | ||
// The `done` callback is only passed through if the function expects at least one argument. | ||
// Note we have to make a function with correct number of arguments, otherwise jasmine will | ||
// think that all functions are sync or async. | ||
return (testBody.length == 0) | ||
? function () { return testProxyZone.run(testBody, this); } | ||
: function (done) { return testProxyZone.run(testBody, this, [done]); }; | ||
} | ||
var QueueRunner = jasmine.QueueRunner; | ||
jasmine.QueueRunner = (function (_super) { | ||
__extends(ZoneQueueRunner, _super); | ||
function ZoneQueueRunner(attrs) { | ||
attrs.onComplete = (function (fn) { return function () { | ||
// All functions are done, clear the test zone. | ||
testProxyZone = null; | ||
ambientZone.scheduleMicroTask('jasmine.onComplete', fn); | ||
}; })(attrs.onComplete); | ||
_super.call(this, attrs); | ||
} | ||
ZoneQueueRunner.prototype.execute = function () { | ||
var _this = this; | ||
if (Zone.current !== ambientZone) | ||
throw new Error("Unexpected Zone: " + Zone.current.name); | ||
testProxyZone = ambientZone.fork(new ProxyZoneSpec()); | ||
if (!Zone.currentTask) { | ||
// if we are not running in a task then if someone would register a | ||
// element.addEventListener and then calling element.click() the | ||
// addEventListener callback would think that it is the top most task and would | ||
// drain the microtask queue on element.click() which would be incorrect. | ||
// For this reason we always force a task when running jasmine tests. | ||
Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return _super.prototype.execute.call(_this); }); | ||
} | ||
else { | ||
_super.prototype.execute.call(this); | ||
} | ||
}; | ||
return ZoneQueueRunner; | ||
}(QueueRunner)); | ||
})(); | ||
/***/ } | ||
/******/ ]); | ||
var __extends = (undefined && undefined.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
(function () { | ||
// Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs | ||
// in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) | ||
if (!Zone) | ||
throw new Error("Missing: zone.js"); | ||
if (typeof jasmine == 'undefined') | ||
throw new Error("Missing: jasmine.js"); | ||
if (jasmine['__zone_patch__']) | ||
throw new Error("'jasmine' has already been patched with 'Zone'."); | ||
jasmine['__zone_patch__'] = true; | ||
var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; | ||
var ProxyZoneSpec = Zone['ProxyZoneSpec']; | ||
if (!SyncTestZoneSpec) | ||
throw new Error("Missing: SyncTestZoneSpec"); | ||
if (!ProxyZoneSpec) | ||
throw new Error("Missing: ProxyZoneSpec"); | ||
var ambientZone = Zone.current; | ||
// Create a synchronous-only zone in which to run `describe` blocks in order to raise an | ||
// error if any asynchronous operations are attempted inside of a `describe` but outside of | ||
// a `beforeEach` or `it`. | ||
var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); | ||
// This is the zone which will be used for running individual tests. | ||
// It will be a proxy zone, so that the tests function can retroactively install | ||
// different zones. | ||
// Example: | ||
// - In beforeEach() do childZone = Zone.current.fork(...); | ||
// - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the | ||
// zone outside of fakeAsync it will be able to escope the fakeAsync rules. | ||
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add | ||
// fakeAsync behavior to the childZone. | ||
var testProxyZone = null; | ||
// Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. | ||
var jasmineEnv = jasmine.getEnv(); | ||
['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { | ||
var originalJasmineFn = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function (description, specDefinitions) { | ||
return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); | ||
}; | ||
}); | ||
['it', 'xit', 'fit'].forEach(function (methodName) { | ||
var originalJasmineFn = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function (description, specDefinitions, timeout) { | ||
arguments[1] = wrapTestInZone(specDefinitions); | ||
return originalJasmineFn.apply(this, arguments); | ||
}; | ||
}); | ||
['beforeEach', 'afterEach'].forEach(function (methodName) { | ||
var originalJasmineFn = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function (specDefinitions, timeout) { | ||
arguments[0] = wrapTestInZone(specDefinitions); | ||
return originalJasmineFn.apply(this, arguments); | ||
}; | ||
}); | ||
/** | ||
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a | ||
* synchronous-only zone. | ||
*/ | ||
function wrapDescribeInZone(describeBody) { | ||
return function () { | ||
return syncZone.run(describeBody, this, arguments); | ||
}; | ||
} | ||
/** | ||
* Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to | ||
* execute in a ProxyZone zone. | ||
* This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` | ||
*/ | ||
function wrapTestInZone(testBody) { | ||
// The `done` callback is only passed through if the function expects at least one argument. | ||
// Note we have to make a function with correct number of arguments, otherwise jasmine will | ||
// think that all functions are sync or async. | ||
return (testBody.length == 0) | ||
? function () { return testProxyZone.run(testBody, this); } | ||
: function (done) { return testProxyZone.run(testBody, this, [done]); }; | ||
} | ||
var QueueRunner = jasmine.QueueRunner; | ||
jasmine.QueueRunner = (function (_super) { | ||
__extends(ZoneQueueRunner, _super); | ||
function ZoneQueueRunner(attrs) { | ||
attrs.onComplete = (function (fn) { return function () { | ||
// All functions are done, clear the test zone. | ||
testProxyZone = null; | ||
ambientZone.scheduleMicroTask('jasmine.onComplete', fn); | ||
}; })(attrs.onComplete); | ||
_super.call(this, attrs); | ||
} | ||
ZoneQueueRunner.prototype.execute = function () { | ||
var _this = this; | ||
if (Zone.current !== ambientZone) | ||
throw new Error("Unexpected Zone: " + Zone.current.name); | ||
testProxyZone = ambientZone.fork(new ProxyZoneSpec()); | ||
if (!Zone.currentTask) { | ||
// if we are not running in a task then if someone would register a | ||
// element.addEventListener and then calling element.click() the | ||
// addEventListener callback would think that it is the top most task and would | ||
// drain the microtask queue on element.click() which would be incorrect. | ||
// For this reason we always force a task when running jasmine tests. | ||
Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return _super.prototype.execute.call(_this); }); | ||
} | ||
else { | ||
_super.prototype.execute.call(this); | ||
} | ||
}; | ||
return ZoneQueueRunner; | ||
}(QueueRunner)); | ||
})(); |
@@ -1,1 +0,1 @@ | ||
!function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,exports){"use strict";var n=this&&this.__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 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(n){var r=s[n];s[n]=function(n,t){return r.call(this,n,e(t))}}),["it","xit","fit"].forEach(function(e){var n=s[e];s[e]=function(e,t){return n.call(this,e,r(t))}}),["beforeEach","afterEach"].forEach(function(e){var n=s[e];s[e]=function(e){return n.call(this,r(e))}});var a=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function r(n){n.onComplete=function(e){return function(){u=null,i.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete),e.call(this,n)}return n(r,e),r.prototype.execute=function(){var n=this;if(Zone.current!==i)throw new Error("Unexpected Zone: "+Zone.current.name);u=i.fork(new o),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return e.prototype.execute.call(n)})},r}(a)}()}]); | ||
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)}(); |
@@ -1,168 +0,132 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
'use strict'; | ||
(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'); | ||
} | ||
function getStacktraceWithCaughtError() { | ||
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. | ||
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(); | ||
} | ||
} | ||
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 descriptor = Object.getOwnPropertyDescriptor(error, 'stack'); | ||
if (descriptor) { | ||
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); | ||
} | ||
else { | ||
error.stack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); | ||
} | ||
} | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
}; | ||
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(); | ||
})(); | ||
/***/ } | ||
/******/ ]); | ||
(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'); | ||
} | ||
function getStacktraceWithCaughtError() { | ||
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. | ||
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(); | ||
} | ||
} | ||
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; | ||
} | ||
} | ||
catch (e) { } | ||
var longStack = stackSetSucceded ? null : renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = error.stack = longStack; | ||
} | ||
catch (e) { } | ||
} | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = error.longStack = longStack; | ||
} | ||
catch (e) { } | ||
} | ||
} | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
}; | ||
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(); | ||
})(); |
@@ -1,1 +0,1 @@ | ||
!function(t){function r(n){if(e[n])return e[n].exports;var a=e[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}var e={};return r.m=t,r.c=e,r.p="",r(0)}([function(t,exports){"use strict";!function(){function t(){return new Error("STACKTRACE TRACKING")}function r(){try{throw t()}catch(r){return r}}function e(t){return t.stack?t.stack.split(i):[]}function n(t,r){for(var n=e(r),a=0;a<n.length;a++){var c=n[a];a<u.length&&u[a]===c||t.push(n[a])}}function a(t,r){var e=[r];if(t)for(var a=(new Date).getTime(),c=0;c<t.length;c++){var o=t[c],u=o.timestamp;e.push(s+" Elapsed: "+(a-u.getTime())+" ms; At: "+u+" "+s),n(e,o.error),a=u.getTime()}return e.join(i)}function c(t,r){r>0&&(t.push(e((new l).error)),c(t,r-1))}function o(){var t=[];c(t,2);for(var r=t[0],e=t[1],n=0;n<r.length;n++){var a=r[n],o=e[n];if(a!==o)break;u.push(a)}}var i="\n",s=" ------------- ",u=[],f="__creationTrace__",l=function(){function t(){this.error=p(),this.timestamp=new Date}return t}(),d=t(),h=r(),p=d.stack?t:h.stack?r:t;Zone.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,onScheduleTask:function(t,r,e,n){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),n.data||(n.data={}),n.data[f]=c,t.scheduleTask(e,n)},onHandleError:function(t,r,e,n){var c=Zone.currentTask||n.task;if(n instanceof Error&&c){var o=Object.getOwnPropertyDescriptor(n,"stack");if(o){var i=o.get,s=o.value;o={get:function(){return a(c.data&&c.data[f],i?i.apply(this):s)}},Object.defineProperty(n,"stack",o)}else n.stack=a(c.data&&c.data[f],n.stack)}return t.handleError(e,n)}},o()}()}]); | ||
!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()}(); |
@@ -1,158 +0,108 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
(function () { | ||
var ProxyZoneSpec = (function () { | ||
function ProxyZoneSpec(defaultSpecDelegate) { | ||
if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } | ||
this.defaultSpecDelegate = defaultSpecDelegate; | ||
this.name = 'ProxyZone'; | ||
this.properties = { 'ProxyZoneSpec': this }; | ||
this.propertyKeys = null; | ||
this.setDelegate(defaultSpecDelegate); | ||
} | ||
ProxyZoneSpec.get = function () { | ||
return Zone.current.get('ProxyZoneSpec'); | ||
}; | ||
ProxyZoneSpec.isLoaded = function () { | ||
return ProxyZoneSpec.get() instanceof ProxyZoneSpec; | ||
}; | ||
ProxyZoneSpec.assertPresent = function () { | ||
if (!this.isLoaded()) { | ||
throw new Error("Expected to be running in 'ProxyZone', but it was not found."); | ||
} | ||
return ProxyZoneSpec.get(); | ||
}; | ||
ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { | ||
var _this = this; | ||
this._delegateSpec = delegateSpec; | ||
this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); | ||
this.propertyKeys = null; | ||
if (delegateSpec && delegateSpec.properties) { | ||
this.propertyKeys = Object.keys(delegateSpec.properties); | ||
this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.getDelegate = function () { | ||
return this._delegateSpec; | ||
}; | ||
ProxyZoneSpec.prototype.resetDelegate = function () { | ||
this.setDelegate(this.defaultSpecDelegate); | ||
}; | ||
ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); | ||
} | ||
else { | ||
return parentZoneDelegate.fork(targetZone, zoneSpec); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { | ||
if (this._delegateSpec && this._delegateSpec.onIntercept) { | ||
return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); | ||
} | ||
else { | ||
return parentZoneDelegate.intercept(targetZone, delegate, source); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { | ||
if (this._delegateSpec && this._delegateSpec.onInvoke) { | ||
return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); | ||
} | ||
else { | ||
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { | ||
if (this._delegateSpec && this._delegateSpec.onHandleError) { | ||
return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); | ||
} | ||
else { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
if (this._delegateSpec && this._delegateSpec.onScheduleTask) { | ||
return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} | ||
else { | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); | ||
} | ||
else { | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
if (this._delegateSpec && this._delegateSpec.onCancelTask) { | ||
return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} | ||
else { | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { | ||
if (this._delegateSpec && this._delegateSpec.onHasTask) { | ||
this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); | ||
} | ||
else { | ||
delegate.hasTask(target, hasTaskState); | ||
} | ||
}; | ||
return ProxyZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['ProxyZoneSpec'] = ProxyZoneSpec; | ||
})(); | ||
/***/ } | ||
/******/ ]); | ||
(function () { | ||
var ProxyZoneSpec = (function () { | ||
function ProxyZoneSpec(defaultSpecDelegate) { | ||
if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } | ||
this.defaultSpecDelegate = defaultSpecDelegate; | ||
this.name = 'ProxyZone'; | ||
this.properties = { 'ProxyZoneSpec': this }; | ||
this.propertyKeys = null; | ||
this.setDelegate(defaultSpecDelegate); | ||
} | ||
ProxyZoneSpec.get = function () { | ||
return Zone.current.get('ProxyZoneSpec'); | ||
}; | ||
ProxyZoneSpec.isLoaded = function () { | ||
return ProxyZoneSpec.get() instanceof ProxyZoneSpec; | ||
}; | ||
ProxyZoneSpec.assertPresent = function () { | ||
if (!this.isLoaded()) { | ||
throw new Error("Expected to be running in 'ProxyZone', but it was not found."); | ||
} | ||
return ProxyZoneSpec.get(); | ||
}; | ||
ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { | ||
var _this = this; | ||
this._delegateSpec = delegateSpec; | ||
this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); | ||
this.propertyKeys = null; | ||
if (delegateSpec && delegateSpec.properties) { | ||
this.propertyKeys = Object.keys(delegateSpec.properties); | ||
this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.getDelegate = function () { | ||
return this._delegateSpec; | ||
}; | ||
ProxyZoneSpec.prototype.resetDelegate = function () { | ||
this.setDelegate(this.defaultSpecDelegate); | ||
}; | ||
ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); | ||
} | ||
else { | ||
return parentZoneDelegate.fork(targetZone, zoneSpec); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { | ||
if (this._delegateSpec && this._delegateSpec.onIntercept) { | ||
return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); | ||
} | ||
else { | ||
return parentZoneDelegate.intercept(targetZone, delegate, source); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { | ||
if (this._delegateSpec && this._delegateSpec.onInvoke) { | ||
return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); | ||
} | ||
else { | ||
return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { | ||
if (this._delegateSpec && this._delegateSpec.onHandleError) { | ||
return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); | ||
} | ||
else { | ||
return parentZoneDelegate.handleError(targetZone, error); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
if (this._delegateSpec && this._delegateSpec.onScheduleTask) { | ||
return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} | ||
else { | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { | ||
if (this._delegateSpec && this._delegateSpec.onFork) { | ||
return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); | ||
} | ||
else { | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
if (this._delegateSpec && this._delegateSpec.onCancelTask) { | ||
return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); | ||
} | ||
else { | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
} | ||
}; | ||
ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { | ||
if (this._delegateSpec && this._delegateSpec.onHasTask) { | ||
this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); | ||
} | ||
else { | ||
delegate.hasTask(target, hasTaskState); | ||
} | ||
}; | ||
return ProxyZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['ProxyZoneSpec'] = ProxyZoneSpec; | ||
})(); |
@@ -1,1 +0,1 @@ | ||
!function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,exports){!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(){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,73 +0,23 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
(function () { | ||
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; | ||
} | ||
return task; | ||
}; | ||
return SyncTestZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; | ||
})(); | ||
/***/ } | ||
/******/ ]); | ||
(function () { | ||
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; | ||
} | ||
return task; | ||
}; | ||
return SyncTestZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; | ||
})(); |
@@ -1,113 +0,63 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
/** | ||
* A `TaskTrackingZoneSpec` allows one to track all outstanding Tasks. | ||
* | ||
* This is useful in tests. For example to see which tasks are preventing a test from completing | ||
* or an automated way of releasing all of the event listeners at the end of the test. | ||
*/ | ||
var TaskTrackingZoneSpec = (function () { | ||
function TaskTrackingZoneSpec() { | ||
this.name = 'TaskTrackingZone'; | ||
this.microTasks = []; | ||
this.macroTasks = []; | ||
this.eventTasks = []; | ||
this.properties = { 'TaskTrackingZone': this }; | ||
} | ||
TaskTrackingZoneSpec.get = function () { | ||
return Zone.current.get('TaskTrackingZone'); | ||
}; | ||
TaskTrackingZoneSpec.prototype.getTasksFor = function (type) { | ||
switch (type) { | ||
case 'microTask': return this.microTasks; | ||
case 'macroTask': return this.macroTasks; | ||
case 'eventTask': return this.eventTasks; | ||
} | ||
throw new Error('Unknown task format: ' + type); | ||
}; | ||
TaskTrackingZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
task['creationLocation'] = new Error("Task '" + task.type + "' from '" + task.source + "'."); | ||
var tasks = this.getTasksFor(task.type); | ||
tasks.push(task); | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
}; | ||
TaskTrackingZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
var tasks = this.getTasksFor(task.type); | ||
for (var i = 0; i < tasks.length; i++) { | ||
if (tasks[i] == task) { | ||
tasks.splice(i, 1); | ||
break; | ||
} | ||
} | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
}; | ||
TaskTrackingZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { | ||
if (task.type === 'eventTask') | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
var tasks = this.getTasksFor(task.type); | ||
for (var i = 0; i < tasks.length; i++) { | ||
if (tasks[i] == task) { | ||
tasks.splice(i, 1); | ||
break; | ||
} | ||
} | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
}; | ||
TaskTrackingZoneSpec.prototype.clearEvents = function () { | ||
while (this.eventTasks.length) { | ||
Zone.current.cancelTask(this.eventTasks[0]); | ||
} | ||
}; | ||
return TaskTrackingZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec; | ||
/***/ } | ||
/******/ ]); | ||
/** | ||
* A `TaskTrackingZoneSpec` allows one to track all outstanding Tasks. | ||
* | ||
* This is useful in tests. For example to see which tasks are preventing a test from completing | ||
* or an automated way of releasing all of the event listeners at the end of the test. | ||
*/ | ||
var TaskTrackingZoneSpec = (function () { | ||
function TaskTrackingZoneSpec() { | ||
this.name = 'TaskTrackingZone'; | ||
this.microTasks = []; | ||
this.macroTasks = []; | ||
this.eventTasks = []; | ||
this.properties = { 'TaskTrackingZone': this }; | ||
} | ||
TaskTrackingZoneSpec.get = function () { | ||
return Zone.current.get('TaskTrackingZone'); | ||
}; | ||
TaskTrackingZoneSpec.prototype.getTasksFor = function (type) { | ||
switch (type) { | ||
case 'microTask': return this.microTasks; | ||
case 'macroTask': return this.macroTasks; | ||
case 'eventTask': return this.eventTasks; | ||
} | ||
throw new Error('Unknown task format: ' + type); | ||
}; | ||
TaskTrackingZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
task['creationLocation'] = new Error("Task '" + task.type + "' from '" + task.source + "'."); | ||
var tasks = this.getTasksFor(task.type); | ||
tasks.push(task); | ||
return parentZoneDelegate.scheduleTask(targetZone, task); | ||
}; | ||
TaskTrackingZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { | ||
var tasks = this.getTasksFor(task.type); | ||
for (var i = 0; i < tasks.length; i++) { | ||
if (tasks[i] == task) { | ||
tasks.splice(i, 1); | ||
break; | ||
} | ||
} | ||
return parentZoneDelegate.cancelTask(targetZone, task); | ||
}; | ||
TaskTrackingZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { | ||
if (task.type === 'eventTask') | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
var tasks = this.getTasksFor(task.type); | ||
for (var i = 0; i < tasks.length; i++) { | ||
if (tasks[i] == task) { | ||
tasks.splice(i, 1); | ||
break; | ||
} | ||
} | ||
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | ||
}; | ||
TaskTrackingZoneSpec.prototype.clearEvents = function () { | ||
while (this.eventTasks.length) { | ||
Zone.current.cancelTask(this.eventTasks[0]); | ||
} | ||
}; | ||
return TaskTrackingZoneSpec; | ||
}()); | ||
// Export the class so that new instances can be created with proper | ||
// constructor params. | ||
Zone['TaskTrackingZoneSpec'] = TaskTrackingZoneSpec; |
@@ -1,1 +0,1 @@ | ||
!function(e){function t(n){if(r[n])return r[n].exports;var s=r[n]={exports:{},id:n,loaded:!1};return e[n].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,exports){var t=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,r,n){n.creationLocation=new Error("Task '"+n.type+"' from '"+n.source+"'.");var s=this.getTasksFor(n.type);return s.push(n),e.scheduleTask(r,n)},e.prototype.onCancelTask=function(e,t,r,n){for(var s=this.getTasksFor(n.type),o=0;o<s.length;o++)if(s[o]==n){s.splice(o,1);break}return e.cancelTask(r,n)},e.prototype.onInvokeTask=function(e,t,r,n,s,o){if("eventTask"===n.type)return e.invokeTask(r,n,s,o);for(var a=this.getTasksFor(n.type),i=0;i<a.length;i++)if(a[i]==n){a.splice(i,1);break}return e.invokeTask(r,n,s,o)},e.prototype.clearEvents=function(){for(;this.eventTasks.length;)Zone.current.cancelTask(this.eventTasks[0])},e}();Zone.TaskTrackingZoneSpec=t}]); | ||
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; |
267
dist/wtf.js
@@ -1,159 +0,108 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports) { | ||
/* WEBPACK VAR INJECTION */(function(global) {(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; | ||
} | ||
} | ||
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)"); | ||
} | ||
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; | ||
} | ||
} | ||
return out; | ||
} | ||
function zonePathName(zone) { | ||
var name = zone.name; | ||
zone = zone.parent; | ||
while (zone != null) { | ||
name = zone.name + '::' + name; | ||
zone = zone.parent; | ||
} | ||
return name; | ||
} | ||
Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); | ||
})(typeof window == 'undefined' ? global : window); | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ } | ||
/******/ ]); | ||
(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; | ||
} | ||
} | ||
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)"); | ||
} | ||
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; | ||
} | ||
} | ||
return out; | ||
} | ||
function zonePathName(zone) { | ||
var name = zone.name; | ||
zone = zone.parent; | ||
while (zone != null) { | ||
name = zone.name + '::' + name; | ||
zone = zone.parent; | ||
} | ||
return name; | ||
} | ||
Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); | ||
})(typeof window == 'undefined' ? global : window); |
@@ -1,1 +0,1 @@ | ||
!function(n){function e(t){if(o[t])return o[t].exports;var r=o[t]={exports:{},id:t,loaded:!1};return n[t].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=n,e.c=o,e.p="",e(0)}([function(n,exports){(function(n){!function(n){function e(n,o){if(!o)return null;var t={};for(var r in n)if(n.hasOwnProperty(r)){var a=n[r];switch(typeof a){case"object":var c=a&&a.constructor&&a.constructor.name;a=c==Object.name?e(a,o-1):c;break;case"function":a=a.name||void 0}t[r]=a}return t}function o(n){var e=n.name;for(n=n.parent;null!=n;)e=n.name+"::"+e,n=n.parent;return e}var t=null,r=null,a=function(){var e=n.wtf;return!(!e||!(t=e.trace))&&(r=t.events,!0)}(),c=function(){function n(){this.name="WTF"}return n.prototype.onFork=function(e,t,r,a){var c=e.fork(r,a);return n.forkInstance(o(r),c.name),c},n.prototype.onInvoke=function(e,a,c,i,s,u,p){var f=n.invokeScope[p];return f||(f=n.invokeScope[p]=r.createScope("Zone:invoke:"+p+"(ascii zone)")),t.leaveScope(f(o(c)),e.invoke(c,i,s,u,p))},n.prototype.onHandleError=function(n,e,o,t){return n.handleError(o,t)},n.prototype.onScheduleTask=function(t,a,c,i){var s=i.type+":"+i.source,u=n.scheduleInstance[s];u||(u=n.scheduleInstance[s]=r.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var p=t.scheduleTask(c,i);return u(o(c),e(i.data,2)),p},n.prototype.onInvokeTask=function(e,a,c,i,s,u){var p=i.source,f=n.invokeTaskScope[p];return f||(f=n.invokeTaskScope[p]=r.createScope("Zone:invokeTask:"+p+"(ascii zone)")),t.leaveScope(f(o(c)),e.invokeTask(c,i,s,u))},n.prototype.onCancelTask=function(t,a,c,i){var s=i.source,u=n.cancelInstance[s];u||(u=n.cancelInstance[s]=r.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var p=t.cancelTask(c,i);return u(o(c),e(i.data,2)),p},n.forkInstance=a&&r.createInstance("Zone:fork(ascii zone, ascii newZone)"),n.scheduleInstance={},n.cancelInstance={},n.invokeScope={},n.invokeTaskScope={},n}();Zone.wtfZoneSpec=a?new c:null}("undefined"==typeof window?n:window)}).call(exports,function(){return this}())}]); | ||
!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,i,s,u,p){var v=e.invokeScope[p];return v||(v=e.invokeScope[p]=c.createScope("Zone:invoke:"+p+"(ascii zone)")),a.leaveScope(v(o(r)),n.invoke(r,i,s,u,p))},e.prototype.onHandleError=function(e,n,o,a){return e.handleError(o,a)},e.prototype.onScheduleTask=function(a,t,r,i){var s=i.type+":"+i.source,u=e.scheduleInstance[s];u||(u=e.scheduleInstance[s]=c.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var p=a.scheduleTask(r,i);return u(o(r),n(i.data,2)),p},e.prototype.onInvokeTask=function(n,t,r,i,s,u){var p=i.source,v=e.invokeTaskScope[p];return v||(v=e.invokeTaskScope[p]=c.createScope("Zone:invokeTask:"+p+"(ascii zone)")),a.leaveScope(v(o(r)),n.invokeTask(r,i,s,u))},e.prototype.onCancelTask=function(a,t,r,i){var s=i.source,u=e.cancelInstance[s];u||(u=e.cancelInstance[s]=c.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var p=a.cancelTask(r,i);return u(o(r),n(i.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}("undefined"==typeof window?global:window); |
2646
dist/zone.js
@@ -1,1376 +0,1286 @@ | ||
/******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
; | ||
; | ||
var Zone$1 = (function (global) { | ||
if (global.Zone) { | ||
throw new Error('Zone already loaded.'); | ||
} | ||
var Zone = (function () { | ||
function Zone(parent, zoneSpec) { | ||
this._properties = null; | ||
this._parent = parent; | ||
this._name = zoneSpec ? zoneSpec.name || 'unnamed' : '<root>'; | ||
this._properties = zoneSpec && zoneSpec.properties || {}; | ||
this._zoneDelegate = new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); | ||
} | ||
Zone.assertZonePatched = function () { | ||
if (global.Promise !== ZoneAwarePromise) { | ||
throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` " + | ||
"has been overwritten.\n" + | ||
"Most 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(Zone, "current", { | ||
get: function () { return _currentZone; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Object.defineProperty(Zone, "currentTask", { | ||
get: function () { return _currentTask; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "parent", { | ||
get: function () { return this._parent; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "name", { | ||
get: function () { return this._name; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Zone.prototype.get = function (key) { | ||
var zone = this.getZoneWith(key); | ||
if (zone) | ||
return zone._properties[key]; | ||
}; | ||
Zone.prototype.getZoneWith = function (key) { | ||
var current = this; | ||
while (current) { | ||
if (current._properties.hasOwnProperty(key)) { | ||
return current; | ||
} | ||
current = current._parent; | ||
} | ||
return null; | ||
}; | ||
Zone.prototype.fork = function (zoneSpec) { | ||
if (!zoneSpec) | ||
throw new Error('ZoneSpec required!'); | ||
return this._zoneDelegate.fork(this, zoneSpec); | ||
}; | ||
Zone.prototype.wrap = function (callback, source) { | ||
if (typeof callback !== 'function') { | ||
throw new Error('Expecting function got: ' + callback); | ||
} | ||
var _callback = this._zoneDelegate.intercept(this, callback, source); | ||
var zone = this; | ||
return function () { | ||
return zone.runGuarded(_callback, this, arguments, source); | ||
}; | ||
}; | ||
Zone.prototype.run = function (callback, applyThis, applyArgs, source) { | ||
if (applyThis === void 0) { applyThis = null; } | ||
if (applyArgs === void 0) { applyArgs = null; } | ||
if (source === void 0) { source = null; } | ||
var oldZone = _currentZone; | ||
_currentZone = this; | ||
try { | ||
return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); | ||
} | ||
finally { | ||
_currentZone = oldZone; | ||
} | ||
}; | ||
Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { | ||
if (applyThis === void 0) { applyThis = null; } | ||
if (applyArgs === void 0) { applyArgs = null; } | ||
if (source === void 0) { source = null; } | ||
var oldZone = _currentZone; | ||
_currentZone = this; | ||
try { | ||
try { | ||
return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); | ||
} | ||
catch (error) { | ||
if (this._zoneDelegate.handleError(this, error)) { | ||
throw error; | ||
} | ||
} | ||
} | ||
finally { | ||
_currentZone = oldZone; | ||
} | ||
}; | ||
Zone.prototype.runTask = function (task, applyThis, applyArgs) { | ||
task.runCount++; | ||
if (task.zone != this) | ||
throw new Error('A task can only be run in the zone which created it! (Creation: ' + | ||
task.zone.name + '; Execution: ' + this.name + ')'); | ||
var previousTask = _currentTask; | ||
_currentTask = task; | ||
var oldZone = _currentZone; | ||
_currentZone = this; | ||
try { | ||
if (task.type == 'macroTask' && task.data && !task.data.isPeriodic) { | ||
task.cancelFn = null; | ||
} | ||
try { | ||
return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); | ||
} | ||
catch (error) { | ||
if (this._zoneDelegate.handleError(this, error)) { | ||
throw error; | ||
} | ||
} | ||
} | ||
finally { | ||
_currentZone = oldZone; | ||
_currentTask = previousTask; | ||
} | ||
}; | ||
Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { | ||
return this._zoneDelegate.scheduleTask(this, new ZoneTask('microTask', this, source, callback, data, customSchedule, null)); | ||
}; | ||
Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { | ||
return this._zoneDelegate.scheduleTask(this, new ZoneTask('macroTask', this, source, callback, data, customSchedule, customCancel)); | ||
}; | ||
Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { | ||
return this._zoneDelegate.scheduleTask(this, new ZoneTask('eventTask', this, source, callback, data, customSchedule, customCancel)); | ||
}; | ||
Zone.prototype.cancelTask = function (task) { | ||
var value = this._zoneDelegate.cancelTask(this, task); | ||
task.runCount = -1; | ||
task.cancelFn = null; | ||
return value; | ||
}; | ||
Zone.__symbol__ = __symbol__; | ||
return Zone; | ||
}()); | ||
; | ||
var ZoneDelegate = (function () { | ||
function ZoneDelegate(zone, parentDelegate, zoneSpec) { | ||
this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 }; | ||
this.zone = zone; | ||
this._parentDelegate = parentDelegate; | ||
this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); | ||
this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); | ||
this._interceptZS = zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); | ||
this._interceptDlgt = zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); | ||
this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); | ||
this._invokeDlgt = zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); | ||
this._handleErrorZS = zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); | ||
this._handleErrorDlgt = zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); | ||
this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); | ||
this._scheduleTaskDlgt = zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); | ||
this._invokeTaskZS = zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); | ||
this._invokeTaskDlgt = zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); | ||
this._cancelTaskZS = zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); | ||
this._cancelTaskDlgt = zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); | ||
this._hasTaskZS = zoneSpec && (zoneSpec.onHasTask ? zoneSpec : parentDelegate._hasTaskZS); | ||
this._hasTaskDlgt = zoneSpec && (zoneSpec.onHasTask ? parentDelegate : parentDelegate._hasTaskDlgt); | ||
} | ||
ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { | ||
return this._forkZS | ||
? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) | ||
: new Zone(targetZone, zoneSpec); | ||
}; | ||
ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { | ||
return this._interceptZS | ||
? this._interceptZS.onIntercept(this._interceptDlgt, this.zone, targetZone, callback, source) | ||
: callback; | ||
}; | ||
ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { | ||
return this._invokeZS | ||
? this._invokeZS.onInvoke(this._invokeDlgt, this.zone, targetZone, callback, applyThis, applyArgs, source) | ||
: callback.apply(applyThis, applyArgs); | ||
}; | ||
ZoneDelegate.prototype.handleError = function (targetZone, error) { | ||
return this._handleErrorZS | ||
? this._handleErrorZS.onHandleError(this._handleErrorDlgt, this.zone, targetZone, error) | ||
: true; | ||
}; | ||
ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { | ||
try { | ||
if (this._scheduleTaskZS) { | ||
return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this.zone, targetZone, task); | ||
} | ||
else if (task.scheduleFn) { | ||
task.scheduleFn(task); | ||
} | ||
else if (task.type == 'microTask') { | ||
scheduleMicroTask(task); | ||
} | ||
else { | ||
throw new Error('Task is missing scheduleFn.'); | ||
} | ||
return task; | ||
} | ||
finally { | ||
if (targetZone == this.zone) { | ||
this._updateTaskCount(task.type, 1); | ||
} | ||
} | ||
}; | ||
ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { | ||
try { | ||
return this._invokeTaskZS | ||
? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this.zone, targetZone, task, applyThis, applyArgs) | ||
: task.callback.apply(applyThis, applyArgs); | ||
} | ||
finally { | ||
if (targetZone == this.zone && (task.type != 'eventTask') && !(task.data && task.data.isPeriodic)) { | ||
this._updateTaskCount(task.type, -1); | ||
} | ||
} | ||
}; | ||
ZoneDelegate.prototype.cancelTask = function (targetZone, task) { | ||
var value; | ||
if (this._cancelTaskZS) { | ||
value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this.zone, targetZone, task); | ||
} | ||
else if (!task.cancelFn) { | ||
throw new Error('Task does not support cancellation, or is already canceled.'); | ||
} | ||
else { | ||
value = task.cancelFn(task); | ||
} | ||
if (targetZone == this.zone) { | ||
// this should not be in the finally block, because exceptions assume not canceled. | ||
this._updateTaskCount(task.type, -1); | ||
} | ||
return value; | ||
}; | ||
ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { | ||
return this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty); | ||
}; | ||
ZoneDelegate.prototype._updateTaskCount = function (type, count) { | ||
var counts = this._taskCounts; | ||
var prev = counts[type]; | ||
var next = counts[type] = prev + count; | ||
if (next < 0) { | ||
throw new Error('More tasks executed then were scheduled.'); | ||
} | ||
if (prev == 0 || next == 0) { | ||
var isEmpty = { | ||
microTask: counts.microTask > 0, | ||
macroTask: counts.macroTask > 0, | ||
eventTask: counts.eventTask > 0, | ||
change: type | ||
}; | ||
try { | ||
this.hasTask(this.zone, isEmpty); | ||
} | ||
finally { | ||
if (this._parentDelegate) { | ||
this._parentDelegate._updateTaskCount(type, count); | ||
} | ||
} | ||
} | ||
}; | ||
return ZoneDelegate; | ||
}()); | ||
var ZoneTask = (function () { | ||
function ZoneTask(type, zone, source, callback, options, scheduleFn, cancelFn) { | ||
this.runCount = 0; | ||
this.type = type; | ||
this.zone = zone; | ||
this.source = source; | ||
this.data = options; | ||
this.scheduleFn = scheduleFn; | ||
this.cancelFn = cancelFn; | ||
this.callback = callback; | ||
var self = this; | ||
this.invoke = function () { | ||
_numberOfNestedTaskFrames++; | ||
try { | ||
return zone.runTask(self, this, arguments); | ||
} | ||
finally { | ||
if (_numberOfNestedTaskFrames == 1) { | ||
drainMicroTaskQueue(); | ||
} | ||
_numberOfNestedTaskFrames--; | ||
} | ||
}; | ||
} | ||
ZoneTask.prototype.toString = function () { | ||
if (this.data && typeof this.data.handleId !== 'undefined') { | ||
return this.data.handleId; | ||
} | ||
else { | ||
return this.toString(); | ||
} | ||
}; | ||
return ZoneTask; | ||
}()); | ||
function __symbol__(name) { return '__zone_symbol__' + name; } | ||
; | ||
var symbolSetTimeout = __symbol__('setTimeout'); | ||
var symbolPromise = __symbol__('Promise'); | ||
var symbolThen = __symbol__('then'); | ||
var _currentZone = new Zone(null, null); | ||
var _currentTask = null; | ||
var _microTaskQueue = []; | ||
var _isDrainingMicrotaskQueue = false; | ||
var _uncaughtPromiseErrors = []; | ||
var _numberOfNestedTaskFrames = 0; | ||
function scheduleQueueDrain() { | ||
// if we are not running in any task, and there has not been anything scheduled | ||
// we must bootstrap the initial task creation by manually scheduling the drain | ||
if (_numberOfNestedTaskFrames == 0 && _microTaskQueue.length == 0) { | ||
// We are not running in Task, so we need to kickstart the microtask queue. | ||
if (global[symbolPromise]) { | ||
global[symbolPromise].resolve(0)[symbolThen](drainMicroTaskQueue); | ||
} | ||
else { | ||
global[symbolSetTimeout](drainMicroTaskQueue, 0); | ||
} | ||
} | ||
} | ||
function scheduleMicroTask(task) { | ||
scheduleQueueDrain(); | ||
_microTaskQueue.push(task); | ||
} | ||
function consoleError(e) { | ||
var rejection = e && e.rejection; | ||
if (rejection) { | ||
console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); | ||
} | ||
console.error(e); | ||
} | ||
function drainMicroTaskQueue() { | ||
if (!_isDrainingMicrotaskQueue) { | ||
_isDrainingMicrotaskQueue = true; | ||
while (_microTaskQueue.length) { | ||
var queue = _microTaskQueue; | ||
_microTaskQueue = []; | ||
for (var i = 0; i < queue.length; i++) { | ||
var task = queue[i]; | ||
try { | ||
task.zone.runTask(task, null, null); | ||
} | ||
catch (e) { | ||
consoleError(e); | ||
} | ||
} | ||
} | ||
while (_uncaughtPromiseErrors.length) { | ||
var _loop_1 = function() { | ||
var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); | ||
try { | ||
uncaughtPromiseError.zone.runGuarded(function () { throw uncaughtPromiseError; }); | ||
} | ||
catch (e) { | ||
consoleError(e); | ||
} | ||
}; | ||
while (_uncaughtPromiseErrors.length) { | ||
_loop_1(); | ||
} | ||
} | ||
_isDrainingMicrotaskQueue = false; | ||
} | ||
} | ||
function isThenable(value) { | ||
return value && value.then; | ||
} | ||
function forwardResolution(value) { return value; } | ||
function forwardRejection(rejection) { return ZoneAwarePromise.reject(rejection); } | ||
var symbolState = __symbol__('state'); | ||
var symbolValue = __symbol__('value'); | ||
var source = 'Promise.then'; | ||
var UNRESOLVED = null; | ||
var RESOLVED = true; | ||
var REJECTED = false; | ||
var REJECTED_NO_CATCH = 0; | ||
function makeResolver(promise, state) { | ||
return function (v) { | ||
resolvePromise(promise, state, v); | ||
// Do not return value or you will break the Promise spec. | ||
}; | ||
} | ||
function resolvePromise(promise, state, value) { | ||
if (promise[symbolState] === UNRESOLVED) { | ||
if (value instanceof ZoneAwarePromise && value[symbolState] !== UNRESOLVED) { | ||
clearRejectedNoCatch(value); | ||
resolvePromise(promise, value[symbolState], value[symbolValue]); | ||
} | ||
else if (isThenable(value)) { | ||
value.then(makeResolver(promise, state), makeResolver(promise, false)); | ||
} | ||
else { | ||
promise[symbolState] = state; | ||
var queue = promise[symbolValue]; | ||
promise[symbolValue] = value; | ||
for (var i = 0; i < queue.length;) { | ||
scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); | ||
} | ||
if (queue.length == 0 && state == REJECTED) { | ||
promise[symbolState] = REJECTED_NO_CATCH; | ||
try { | ||
throw new Error("Uncaught (in promise): " + value); | ||
} | ||
catch (e) { | ||
var error = e; | ||
error.rejection = value; | ||
error.promise = promise; | ||
error.zone = Zone.current; | ||
error.task = Zone.currentTask; | ||
_uncaughtPromiseErrors.push(error); | ||
scheduleQueueDrain(); | ||
} | ||
} | ||
} | ||
} | ||
// Resolving an already resolved promise is a noop. | ||
return promise; | ||
} | ||
function clearRejectedNoCatch(promise) { | ||
if (promise[symbolState] === REJECTED_NO_CATCH) { | ||
promise[symbolState] = REJECTED; | ||
for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { | ||
if (promise === _uncaughtPromiseErrors[i].promise) { | ||
_uncaughtPromiseErrors.splice(i, 1); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { | ||
clearRejectedNoCatch(promise); | ||
var delegate = promise[symbolState] ? onFulfilled || forwardResolution : onRejected || forwardRejection; | ||
zone.scheduleMicroTask(source, function () { | ||
try { | ||
resolvePromise(chainPromise, true, zone.run(delegate, null, [promise[symbolValue]])); | ||
} | ||
catch (error) { | ||
resolvePromise(chainPromise, false, error); | ||
} | ||
}); | ||
} | ||
var ZoneAwarePromise = (function () { | ||
function ZoneAwarePromise(executor) { | ||
var promise = this; | ||
if (!(promise instanceof ZoneAwarePromise)) { | ||
throw new Error('Must be an instanceof Promise.'); | ||
} | ||
promise[symbolState] = UNRESOLVED; | ||
promise[symbolValue] = []; // queue; | ||
try { | ||
executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); | ||
} | ||
catch (e) { | ||
resolvePromise(promise, false, e); | ||
} | ||
} | ||
ZoneAwarePromise.resolve = function (value) { | ||
return resolvePromise(new this(null), RESOLVED, value); | ||
}; | ||
ZoneAwarePromise.reject = function (error) { | ||
return resolvePromise(new this(null), REJECTED, error); | ||
}; | ||
ZoneAwarePromise.race = function (values) { | ||
var resolve; | ||
var reject; | ||
var promise = new this(function (res, rej) { resolve = res; reject = rej; }); | ||
function onResolve(value) { promise && (promise = null || resolve(value)); } | ||
function onReject(error) { promise && (promise = null || reject(error)); } | ||
for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { | ||
var value = values_1[_i]; | ||
if (!isThenable(value)) { | ||
value = this.resolve(value); | ||
} | ||
value.then(onResolve, onReject); | ||
} | ||
return promise; | ||
}; | ||
ZoneAwarePromise.all = function (values) { | ||
var resolve; | ||
var reject; | ||
var promise = new this(function (res, rej) { resolve = res; reject = rej; }); | ||
var count = 0; | ||
var resolvedValues = []; | ||
for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { | ||
var value = values_2[_i]; | ||
if (!isThenable(value)) { | ||
value = this.resolve(value); | ||
} | ||
value.then((function (index) { return function (value) { | ||
resolvedValues[index] = value; | ||
count--; | ||
if (!count) { | ||
resolve(resolvedValues); | ||
} | ||
}; })(count), reject); | ||
count++; | ||
} | ||
if (!count) | ||
resolve(resolvedValues); | ||
return promise; | ||
}; | ||
ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { | ||
var chainPromise = new this.constructor(null); | ||
var zone = Zone.current; | ||
if (this[symbolState] == UNRESOLVED) { | ||
this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); | ||
} | ||
else { | ||
scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); | ||
} | ||
return chainPromise; | ||
}; | ||
ZoneAwarePromise.prototype.catch = function (onRejected) { | ||
return this.then(null, onRejected); | ||
}; | ||
return ZoneAwarePromise; | ||
}()); | ||
var NativePromise = global[__symbol__('Promise')] = global.Promise; | ||
global.Promise = ZoneAwarePromise; | ||
function patchThen(NativePromise) { | ||
var NativePromiseProtototype = NativePromise.prototype; | ||
var NativePromiseThen = NativePromiseProtototype[__symbol__('then')] | ||
= NativePromiseProtototype.then; | ||
NativePromiseProtototype.then = function (onResolve, onReject) { | ||
var nativePromise = this; | ||
return new ZoneAwarePromise(function (resolve, reject) { | ||
NativePromiseThen.call(nativePromise, resolve, reject); | ||
}).then(onResolve, onReject); | ||
}; | ||
} | ||
if (NativePromise) { | ||
patchThen(NativePromise); | ||
if (typeof global['fetch'] !== 'undefined') { | ||
var fetchPromise = global['fetch'](); | ||
// ignore output to prevent error; | ||
fetchPromise.then(function () { return null; }, function () { return null; }); | ||
if (fetchPromise.constructor != NativePromise) { | ||
patchThen(fetchPromise.constructor); | ||
} | ||
} | ||
} | ||
// This is not part of public API, but it is usefull for tests, so we expose it. | ||
Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; | ||
return global.Zone = Zone; | ||
})(typeof window === 'undefined' ? global : window); | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/** | ||
* Suppress closure compiler errors about unknown 'process' variable | ||
* @fileoverview | ||
* @suppress {undefinedVars} | ||
*/ | ||
var zoneSymbol = Zone['__symbol__']; | ||
var _global$1 = typeof window == 'undefined' ? global : window; | ||
function bindArguments(args, source) { | ||
for (var i = args.length - 1; i >= 0; i--) { | ||
if (typeof args[i] === 'function') { | ||
args[i] = Zone.current.wrap(args[i], source + '_' + i); | ||
} | ||
} | ||
return args; | ||
} | ||
; | ||
function patchPrototype(prototype, fnNames) { | ||
var source = prototype.constructor['name']; | ||
var _loop_1 = function(i) { | ||
var name_1 = fnNames[i]; | ||
var delegate = prototype[name_1]; | ||
if (delegate) { | ||
prototype[name_1] = (function (delegate) { | ||
return function () { | ||
return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); | ||
}; | ||
})(delegate); | ||
} | ||
}; | ||
for (var i = 0; i < fnNames.length; i++) { | ||
_loop_1(i); | ||
} | ||
} | ||
; | ||
var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); | ||
var isNode = (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'); | ||
var isBrowser = !isNode && !isWebWorker && !!(typeof window !== 'undefined' && window['HTMLElement']); | ||
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); | ||
} | ||
; | ||
function patchOnProperties(obj, properties) { | ||
var onProperties = []; | ||
for (var prop in obj) { | ||
if (prop.substr(0, 2) == 'on') { | ||
onProperties.push(prop); | ||
} | ||
} | ||
for (var j = 0; j < onProperties.length; j++) { | ||
patchProperty(obj, onProperties[j]); | ||
} | ||
if (properties) { | ||
for (var i = 0; i < properties.length; i++) { | ||
patchProperty(obj, 'on' + properties[i]); | ||
} | ||
} | ||
} | ||
; | ||
var EVENT_TASKS = zoneSymbol('eventTasks'); | ||
var ADD_EVENT_LISTENER = 'addEventListener'; | ||
var REMOVE_EVENT_LISTENER = 'removeEventListener'; | ||
var SYMBOL_ADD_EVENT_LISTENER = zoneSymbol(ADD_EVENT_LISTENER); | ||
var SYMBOL_REMOVE_EVENT_LISTENER = zoneSymbol(REMOVE_EVENT_LISTENER); | ||
function findExistingRegisteredTask(target, handler, name, capture, remove) { | ||
var eventTasks = target[EVENT_TASKS]; | ||
if (eventTasks) { | ||
for (var i = 0; i < eventTasks.length; i++) { | ||
var eventTask = eventTasks[i]; | ||
var data = eventTask.data; | ||
if (data.handler === handler | ||
&& data.useCapturing === capture | ||
&& data.eventName === name) { | ||
if (remove) { | ||
eventTasks.splice(i, 1); | ||
} | ||
return eventTask; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
function attachRegisteredEvent(target, eventTask) { | ||
var eventTasks = target[EVENT_TASKS]; | ||
if (!eventTasks) { | ||
eventTasks = target[EVENT_TASKS] = []; | ||
} | ||
eventTasks.push(eventTask); | ||
} | ||
function scheduleEventListener(eventTask) { | ||
var meta = eventTask.data; | ||
attachRegisteredEvent(meta.target, eventTask); | ||
return meta.target[SYMBOL_ADD_EVENT_LISTENER](meta.eventName, eventTask.invoke, meta.useCapturing); | ||
} | ||
function cancelEventListener(eventTask) { | ||
var meta = eventTask.data; | ||
findExistingRegisteredTask(meta.target, eventTask.invoke, meta.eventName, meta.useCapturing, true); | ||
meta.target[SYMBOL_REMOVE_EVENT_LISTENER](meta.eventName, eventTask.invoke, meta.useCapturing); | ||
} | ||
function zoneAwareAddEventListener(self, args) { | ||
var eventName = args[0]; | ||
var handler = args[1]; | ||
var useCapturing = args[2] || false; | ||
// - Inside a Web Worker, `this` is undefined, the context is `global` | ||
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined | ||
// see https://github.com/angular/zone.js/issues/190 | ||
var target = self || _global$1; | ||
var delegate = null; | ||
if (typeof handler == 'function') { | ||
delegate = handler; | ||
} | ||
else if (handler && handler.handleEvent) { | ||
delegate = function (event) { return handler.handleEvent(event); }; | ||
} | ||
var validZoneHandler = false; | ||
try { | ||
// In cross site contexts (such as WebDriver frameworks like Selenium), | ||
// accessing the handler object here will cause an exception to be thrown which | ||
// will fail tests prematurely. | ||
validZoneHandler = handler && handler.toString() === "[object FunctionWrapper]"; | ||
} | ||
catch (e) { | ||
// Returning nothing here is fine, because objects in a cross-site context are unusable | ||
return; | ||
} | ||
// Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150 | ||
if (!delegate || validZoneHandler) { | ||
return target[SYMBOL_ADD_EVENT_LISTENER](eventName, handler, useCapturing); | ||
} | ||
var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, false); | ||
if (eventTask) { | ||
// we already registered, so this will have noop. | ||
return target[SYMBOL_ADD_EVENT_LISTENER](eventName, eventTask.invoke, useCapturing); | ||
} | ||
var zone = Zone.current; | ||
var source = target.constructor['name'] + '.addEventListener:' + eventName; | ||
var data = { | ||
target: target, | ||
eventName: eventName, | ||
name: eventName, | ||
useCapturing: useCapturing, | ||
handler: handler | ||
}; | ||
zone.scheduleEventTask(source, delegate, data, scheduleEventListener, cancelEventListener); | ||
} | ||
function zoneAwareRemoveEventListener(self, args) { | ||
var eventName = args[0]; | ||
var handler = args[1]; | ||
var useCapturing = args[2] || false; | ||
// - Inside a Web Worker, `this` is undefined, the context is `global` | ||
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined | ||
// see https://github.com/angular/zone.js/issues/190 | ||
var target = self || _global$1; | ||
var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, true); | ||
if (eventTask) { | ||
eventTask.zone.cancelTask(eventTask); | ||
} | ||
else { | ||
target[SYMBOL_REMOVE_EVENT_LISTENER](eventName, handler, useCapturing); | ||
} | ||
} | ||
function patchEventTargetMethods(obj) { | ||
if (obj && obj.addEventListener) { | ||
patchMethod(obj, ADD_EVENT_LISTENER, function () { return zoneAwareAddEventListener; }); | ||
patchMethod(obj, REMOVE_EVENT_LISTENER, function () { return zoneAwareRemoveEventListener; }); | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
; | ||
var originalInstanceKey = zoneSymbol('originalInstance'); | ||
// wrap some native API on `window` | ||
function patchClass(className) { | ||
var OriginalClass = _global$1[className]; | ||
if (!OriginalClass) | ||
return; | ||
_global$1[className] = function () { | ||
var a = bindArguments(arguments, className); | ||
switch (a.length) { | ||
case 0: | ||
this[originalInstanceKey] = new OriginalClass(); | ||
break; | ||
case 1: | ||
this[originalInstanceKey] = new OriginalClass(a[0]); | ||
break; | ||
case 2: | ||
this[originalInstanceKey] = new OriginalClass(a[0], a[1]); | ||
break; | ||
case 3: | ||
this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); | ||
break; | ||
case 4: | ||
this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); | ||
break; | ||
default: throw new Error('Arg list too long.'); | ||
} | ||
}; | ||
var instance = new OriginalClass(function () { }); | ||
var prop; | ||
for (prop in instance) { | ||
// https://bugs.webkit.org/show_bug.cgi?id=44721 | ||
if (className === 'XMLHttpRequest' && prop === 'responseBlob') | ||
continue; | ||
(function (prop) { | ||
if (typeof instance[prop] === 'function') { | ||
_global$1[className].prototype[prop] = function () { | ||
return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); | ||
}; | ||
} | ||
else { | ||
Object.defineProperty(_global$1[className].prototype, prop, { | ||
set: function (fn) { | ||
if (typeof fn === 'function') { | ||
this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); | ||
} | ||
else { | ||
this[originalInstanceKey][prop] = fn; | ||
} | ||
}, | ||
get: function () { | ||
return this[originalInstanceKey][prop]; | ||
} | ||
}); | ||
} | ||
}(prop)); | ||
} | ||
for (prop in OriginalClass) { | ||
if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { | ||
_global$1[className][prop] = OriginalClass[prop]; | ||
} | ||
} | ||
} | ||
; | ||
function createNamedFn(name, delegate) { | ||
try { | ||
return (Function('f', "return function " + name + "(){return f(this, arguments)}"))(delegate); | ||
} | ||
catch (e) { | ||
// if we fail, we must be CSP, just return delegate. | ||
return function () { | ||
return delegate(this, arguments); | ||
}; | ||
} | ||
} | ||
function patchMethod(target, name, patchFn) { | ||
var proto = target; | ||
while (proto && !proto.hasOwnProperty(name)) { | ||
proto = Object.getPrototypeOf(proto); | ||
} | ||
if (!proto && target[name]) { | ||
// somehow we did not find it, but we can see it. This happens on IE for Window properties. | ||
proto = target; | ||
} | ||
var delegateName = zoneSymbol(name); | ||
var delegate; | ||
if (proto && !(delegate = proto[delegateName])) { | ||
delegate = proto[delegateName] = proto[name]; | ||
proto[name] = createNamedFn(name, patchFn(delegate, delegateName, name)); | ||
} | ||
return delegate; | ||
} | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
var 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'; | ||
var 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(','); | ||
var EVENT_TARGET = 'EventTarget'; | ||
function eventTargetPatch(_global) { | ||
var apis = []; | ||
var isWtf = _global['wtf']; | ||
if (isWtf) { | ||
// Workaround for: https://github.com/google/tracing-framework/issues/555 | ||
apis = WTF_ISSUE_555.split(',').map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); | ||
} | ||
else if (_global[EVENT_TARGET]) { | ||
apis.push(EVENT_TARGET); | ||
} | ||
else { | ||
// Note: EventTarget is not available in all browsers, | ||
// if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget | ||
apis = NO_EVENT_TARGET; | ||
} | ||
for (var i = 0; i < apis.length; i++) { | ||
var type = _global[apis[i]]; | ||
patchEventTargetMethods(type && type.prototype); | ||
} | ||
} | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/* | ||
* This is necessary for Chrome and Chrome mobile, to enable | ||
* things like redefining `createdCallback` on an element. | ||
*/ | ||
var _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty; | ||
var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; | ||
var _create = Object.create; | ||
var unconfigurablesKey = zoneSymbol('unconfigurables'); | ||
function propertyPatch() { | ||
Object.defineProperty = function (obj, prop, desc) { | ||
if (isUnconfigurable(obj, prop)) { | ||
throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); | ||
} | ||
var originalConfigurableFlag = desc.configurable; | ||
if (prop !== 'prototype') { | ||
desc = rewriteDescriptor(obj, prop, desc); | ||
} | ||
return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); | ||
}; | ||
Object.defineProperties = function (obj, props) { | ||
Object.keys(props).forEach(function (prop) { | ||
Object.defineProperty(obj, prop, props[prop]); | ||
}); | ||
return obj; | ||
}; | ||
Object.create = function (obj, proto) { | ||
if (typeof proto === 'object' && !Object.isFrozen(proto)) { | ||
Object.keys(proto).forEach(function (prop) { | ||
proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); | ||
}); | ||
} | ||
return _create(obj, proto); | ||
}; | ||
Object.getOwnPropertyDescriptor = function (obj, prop) { | ||
var desc = _getOwnPropertyDescriptor(obj, prop); | ||
if (isUnconfigurable(obj, prop)) { | ||
desc.configurable = false; | ||
} | ||
return desc; | ||
}; | ||
} | ||
; | ||
function _redefineProperty(obj, prop, desc) { | ||
var originalConfigurableFlag = desc.configurable; | ||
desc = rewriteDescriptor(obj, prop, desc); | ||
return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); | ||
} | ||
; | ||
function isUnconfigurable(obj, prop) { | ||
return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; | ||
} | ||
function rewriteDescriptor(obj, prop, desc) { | ||
desc.configurable = true; | ||
if (!desc.configurable) { | ||
if (!obj[unconfigurablesKey]) { | ||
_defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); | ||
} | ||
obj[unconfigurablesKey][prop] = true; | ||
} | ||
return desc; | ||
} | ||
function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { | ||
try { | ||
return _defineProperty(obj, prop, desc); | ||
} | ||
catch (e) { | ||
if (desc.configurable) { | ||
// In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's retry with the original flag value | ||
if (typeof originalConfigurableFlag == 'undefined') { | ||
delete desc.configurable; | ||
} | ||
else { | ||
desc.configurable = originalConfigurableFlag; | ||
} | ||
try { | ||
return _defineProperty(obj, prop, desc); | ||
} | ||
catch (e) { | ||
var descJson = null; | ||
try { | ||
descJson = JSON.stringify(desc); | ||
} | ||
catch (e) { | ||
descJson = descJson.toString(); | ||
} | ||
console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + e); | ||
} | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
} | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
function registerElementPatch(_global) { | ||
if (!isBrowser || !('registerElement' in _global.document)) { | ||
return; | ||
} | ||
var _registerElement = document.registerElement; | ||
var callbacks = [ | ||
'createdCallback', | ||
'attachedCallback', | ||
'detachedCallback', | ||
'attributeChangedCallback' | ||
]; | ||
document.registerElement = function (name, opts) { | ||
if (opts && opts.prototype) { | ||
callbacks.forEach(function (callback) { | ||
var source = 'Document.registerElement::' + callback; | ||
if (opts.prototype.hasOwnProperty(callback)) { | ||
var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback); | ||
if (descriptor && descriptor.value) { | ||
descriptor.value = Zone.current.wrap(descriptor.value, source); | ||
_redefineProperty(opts.prototype, callback, descriptor); | ||
} | ||
else { | ||
opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); | ||
} | ||
} | ||
else if (opts.prototype[callback]) { | ||
opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); | ||
} | ||
}); | ||
} | ||
return _registerElement.apply(document, [name, opts]); | ||
}; | ||
} | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
// we have to patch the instance since the proto is non-configurable | ||
function apply(_global) { | ||
var WS = _global.WebSocket; | ||
// On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener | ||
// On older Chrome, no need since EventTarget was already patched | ||
if (!_global.EventTarget) { | ||
patchEventTargetMethods(WS.prototype); | ||
} | ||
_global.WebSocket = function (a, b) { | ||
var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); | ||
var proxySocket; | ||
// Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance | ||
var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); | ||
if (onmessageDesc && onmessageDesc.configurable === false) { | ||
proxySocket = Object.create(socket); | ||
['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function (propName) { | ||
proxySocket[propName] = function () { | ||
return socket[propName].apply(socket, arguments); | ||
}; | ||
}); | ||
} | ||
else { | ||
// we can patch the real socket | ||
proxySocket = socket; | ||
} | ||
patchOnProperties(proxySocket, ['close', 'error', 'message', 'open']); | ||
return proxySocket; | ||
}; | ||
for (var prop in WS) { | ||
_global.WebSocket[prop] = WS[prop]; | ||
} | ||
} | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
var 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(' '); | ||
function propertyDescriptorPatch(_global) { | ||
if (isNode) { | ||
return; | ||
} | ||
var supportsWebSocket = typeof WebSocket !== 'undefined'; | ||
if (canPatchViaPropertyDescriptor()) { | ||
// for browsers that we can patch the descriptor: Chrome & Firefox | ||
if (isBrowser) { | ||
patchOnProperties(HTMLElement.prototype, eventNames); | ||
} | ||
patchOnProperties(XMLHttpRequest.prototype, null); | ||
if (typeof IDBIndex !== 'undefined') { | ||
patchOnProperties(IDBIndex.prototype, null); | ||
patchOnProperties(IDBRequest.prototype, null); | ||
patchOnProperties(IDBOpenDBRequest.prototype, null); | ||
patchOnProperties(IDBDatabase.prototype, null); | ||
patchOnProperties(IDBTransaction.prototype, null); | ||
patchOnProperties(IDBCursor.prototype, null); | ||
} | ||
if (supportsWebSocket) { | ||
patchOnProperties(WebSocket.prototype, null); | ||
} | ||
} | ||
else { | ||
// Safari, Android browsers (Jelly Bean) | ||
patchViaCapturingAllTheEvents(); | ||
patchClass('XMLHttpRequest'); | ||
if (supportsWebSocket) { | ||
apply(_global); | ||
} | ||
} | ||
} | ||
function canPatchViaPropertyDescriptor() { | ||
if (isBrowser && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') | ||
&& typeof Element !== 'undefined') { | ||
// WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 | ||
// IDL interface attributes are not configurable | ||
var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); | ||
if (desc && !desc.configurable) | ||
return false; | ||
} | ||
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { | ||
get: function () { | ||
return true; | ||
} | ||
}); | ||
var req = new XMLHttpRequest(); | ||
var result = !!req.onreadystatechange; | ||
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', {}); | ||
return result; | ||
} | ||
; | ||
var unboundKey = zoneSymbol('unbound'); | ||
// Whenever any eventListener fires, we check the eventListener target and all parents | ||
// for `onwhatever` properties and replace them with zone-bound functions | ||
// - Chrome (for now) | ||
function patchViaCapturingAllTheEvents() { | ||
var _loop_1 = function(i) { | ||
var property = eventNames[i]; | ||
var onproperty = 'on' + property; | ||
document.addEventListener(property, function (event) { | ||
var elt = event.target, bound, source; | ||
if (elt) { | ||
source = elt.constructor['name'] + '.' + onproperty; | ||
} | ||
else { | ||
source = 'unknown.' + onproperty; | ||
} | ||
while (elt) { | ||
if (elt[onproperty] && !elt[onproperty][unboundKey]) { | ||
bound = Zone.current.wrap(elt[onproperty], source); | ||
bound[unboundKey] = elt[onproperty]; | ||
elt[onproperty] = bound; | ||
} | ||
elt = elt.parentElement; | ||
} | ||
}, true); | ||
}; | ||
for (var i = 0; i < eventNames.length; i++) { | ||
_loop_1(i); | ||
} | ||
; | ||
} | ||
; | ||
function patchTimer(window, setName, cancelName, nameSuffix) { | ||
var setNative = null; | ||
var clearNative = null; | ||
setName += nameSuffix; | ||
cancelName += nameSuffix; | ||
function scheduleTask(task) { | ||
var data = task.data; | ||
data.args[0] = task.invoke; | ||
data.handleId = setNative.apply(window, data.args); | ||
return task; | ||
} | ||
function clearTask(task) { | ||
return clearNative(task.data.handleId); | ||
} | ||
setNative = patchMethod(window, setName, function (delegate) { return function (self, args) { | ||
if (typeof args[0] === 'function') { | ||
var zone = Zone.current; | ||
var options = { | ||
handleId: null, | ||
isPeriodic: nameSuffix === 'Interval', | ||
delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, | ||
args: args | ||
}; | ||
var task = zone.scheduleMacroTask(setName, args[0], options, scheduleTask, clearTask); | ||
if (!task) { | ||
return task; | ||
} | ||
// Node.js must additionally support the ref and unref functions. | ||
var handle = task.data.handleId; | ||
if (handle.ref && handle.unref) { | ||
task.ref = handle.ref.bind(handle); | ||
task.unref = handle.unref.bind(handle); | ||
} | ||
return task; | ||
} | ||
else { | ||
// cause an error by calling it directly. | ||
return delegate.apply(window, args); | ||
} | ||
}; }); | ||
clearNative = patchMethod(window, cancelName, function (delegate) { return function (self, args) { | ||
var task = args[0]; | ||
if (task && typeof task.type === 'string') { | ||
if (task.cancelFn && task.data.isPeriodic || task.runCount === 0) { | ||
// Do not cancel already canceled functions | ||
task.zone.cancelTask(task); | ||
} | ||
} | ||
else { | ||
// cause an error by calling it directly. | ||
delegate.apply(window, args); | ||
} | ||
}; }); | ||
} | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {"use strict"; | ||
__webpack_require__(1); | ||
var event_target_1 = __webpack_require__(2); | ||
var define_property_1 = __webpack_require__(4); | ||
var register_element_1 = __webpack_require__(5); | ||
var property_descriptor_1 = __webpack_require__(6); | ||
var timers_1 = __webpack_require__(8); | ||
var utils_1 = __webpack_require__(3); | ||
var set = 'set'; | ||
var clear = 'clear'; | ||
var blockingMethods = ['alert', 'prompt', 'confirm']; | ||
var _global = typeof window == 'undefined' ? global : window; | ||
timers_1.patchTimer(_global, set, clear, 'Timeout'); | ||
timers_1.patchTimer(_global, set, clear, 'Interval'); | ||
timers_1.patchTimer(_global, set, clear, 'Immediate'); | ||
timers_1.patchTimer(_global, 'request', 'cancel', 'AnimationFrame'); | ||
timers_1.patchTimer(_global, 'mozRequest', 'mozCancel', 'AnimationFrame'); | ||
timers_1.patchTimer(_global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); | ||
for (var i = 0; i < blockingMethods.length; i++) { | ||
var name = blockingMethods[i]; | ||
utils_1.patchMethod(_global, name, function (delegate, symbol, name) { | ||
return function (s, args) { | ||
return Zone.current.run(delegate, _global, args, name); | ||
}; | ||
}); | ||
} | ||
event_target_1.eventTargetPatch(_global); | ||
property_descriptor_1.propertyDescriptorPatch(_global); | ||
utils_1.patchClass('MutationObserver'); | ||
utils_1.patchClass('WebKitMutationObserver'); | ||
utils_1.patchClass('FileReader'); | ||
define_property_1.propertyPatch(); | ||
register_element_1.registerElementPatch(_global); | ||
// Treat XMLHTTPRequest as a macrotask. | ||
patchXHR(_global); | ||
var XHR_TASK = utils_1.zoneSymbol('xhrTask'); | ||
function patchXHR(window) { | ||
function findPendingTask(target) { | ||
var pendingTask = target[XHR_TASK]; | ||
return pendingTask; | ||
} | ||
function scheduleTask(task) { | ||
var data = task.data; | ||
data.target.addEventListener('readystatechange', function () { | ||
if (data.target.readyState === data.target.DONE) { | ||
if (!data.aborted) { | ||
task.invoke(); | ||
} | ||
} | ||
}); | ||
var storedTask = data.target[XHR_TASK]; | ||
if (!storedTask) { | ||
data.target[XHR_TASK] = task; | ||
} | ||
setNative.apply(data.target, data.args); | ||
return task; | ||
} | ||
function placeholderCallback() { | ||
} | ||
function clearTask(task) { | ||
var data = task.data; | ||
// Note - ideally, we would call data.target.removeEventListener here, but it's too late | ||
// to prevent it from firing. So instead, we store info for the event listener. | ||
data.aborted = true; | ||
return clearNative.apply(data.target, data.args); | ||
} | ||
var setNative = utils_1.patchMethod(window.XMLHttpRequest.prototype, 'send', function () { return function (self, args) { | ||
var zone = Zone.current; | ||
var options = { | ||
target: self, | ||
isPeriodic: false, | ||
delay: null, | ||
args: args, | ||
aborted: false | ||
}; | ||
return zone.scheduleMacroTask('XMLHttpRequest.send', placeholderCallback, options, scheduleTask, clearTask); | ||
}; }); | ||
var clearNative = utils_1.patchMethod(window.XMLHttpRequest.prototype, 'abort', function (delegate) { return function (self, args) { | ||
var task = findPendingTask(self); | ||
if (task && typeof task.type == 'string') { | ||
// If the XHR has already completed, do nothing. | ||
if (task.cancelFn == null) { | ||
return; | ||
} | ||
task.zone.cancelTask(task); | ||
} | ||
// Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no task to cancel. Do nothing. | ||
}; }); | ||
} | ||
/// GEO_LOCATION | ||
if (_global['navigator'] && _global['navigator'].geolocation) { | ||
utils_1.patchPrototype(_global['navigator'].geolocation, [ | ||
'getCurrentPosition', | ||
'watchPosition' | ||
]); | ||
} | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 1 */ | ||
/***/ function(module, exports) { | ||
/* WEBPACK VAR INJECTION */(function(global) {; | ||
; | ||
var Zone = (function (global) { | ||
if (global.Zone) { | ||
throw new Error('Zone already loaded.'); | ||
} | ||
var Zone = (function () { | ||
function Zone(parent, zoneSpec) { | ||
this._properties = null; | ||
this._parent = parent; | ||
this._name = zoneSpec ? zoneSpec.name || 'unnamed' : '<root>'; | ||
this._properties = zoneSpec && zoneSpec.properties || {}; | ||
this._zoneDelegate = new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); | ||
} | ||
Object.defineProperty(Zone, "current", { | ||
get: function () { return _currentZone; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Object.defineProperty(Zone, "currentTask", { | ||
get: function () { return _currentTask; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "parent", { | ||
get: function () { return this._parent; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Object.defineProperty(Zone.prototype, "name", { | ||
get: function () { return this._name; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
; | ||
Zone.prototype.get = function (key) { | ||
var zone = this.getZoneWith(key); | ||
if (zone) | ||
return zone._properties[key]; | ||
}; | ||
Zone.prototype.getZoneWith = function (key) { | ||
var current = this; | ||
while (current) { | ||
if (current._properties.hasOwnProperty(key)) { | ||
return current; | ||
} | ||
current = current._parent; | ||
} | ||
return null; | ||
}; | ||
Zone.prototype.fork = function (zoneSpec) { | ||
if (!zoneSpec) | ||
throw new Error('ZoneSpec required!'); | ||
return this._zoneDelegate.fork(this, zoneSpec); | ||
}; | ||
Zone.prototype.wrap = function (callback, source) { | ||
if (typeof callback !== 'function') { | ||
throw new Error('Expecting function got: ' + callback); | ||
} | ||
var _callback = this._zoneDelegate.intercept(this, callback, source); | ||
var zone = this; | ||
return function () { | ||
return zone.runGuarded(_callback, this, arguments, source); | ||
}; | ||
}; | ||
Zone.prototype.run = function (callback, applyThis, applyArgs, source) { | ||
if (applyThis === void 0) { applyThis = null; } | ||
if (applyArgs === void 0) { applyArgs = null; } | ||
if (source === void 0) { source = null; } | ||
var oldZone = _currentZone; | ||
_currentZone = this; | ||
try { | ||
return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); | ||
} | ||
finally { | ||
_currentZone = oldZone; | ||
} | ||
}; | ||
Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { | ||
if (applyThis === void 0) { applyThis = null; } | ||
if (applyArgs === void 0) { applyArgs = null; } | ||
if (source === void 0) { source = null; } | ||
var oldZone = _currentZone; | ||
_currentZone = this; | ||
try { | ||
try { | ||
return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); | ||
} | ||
catch (error) { | ||
if (this._zoneDelegate.handleError(this, error)) { | ||
throw error; | ||
} | ||
} | ||
} | ||
finally { | ||
_currentZone = oldZone; | ||
} | ||
}; | ||
Zone.prototype.runTask = function (task, applyThis, applyArgs) { | ||
task.runCount++; | ||
if (task.zone != this) | ||
throw new Error('A task can only be run in the zone which created it! (Creation: ' + | ||
task.zone.name + '; Execution: ' + this.name + ')'); | ||
var previousTask = _currentTask; | ||
_currentTask = task; | ||
var oldZone = _currentZone; | ||
_currentZone = this; | ||
try { | ||
if (task.type == 'macroTask' && task.data && !task.data.isPeriodic) { | ||
task.cancelFn = null; | ||
} | ||
try { | ||
return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); | ||
} | ||
catch (error) { | ||
if (this._zoneDelegate.handleError(this, error)) { | ||
throw error; | ||
} | ||
} | ||
} | ||
finally { | ||
_currentZone = oldZone; | ||
_currentTask = previousTask; | ||
} | ||
}; | ||
Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { | ||
return this._zoneDelegate.scheduleTask(this, new ZoneTask('microTask', this, source, callback, data, customSchedule, null)); | ||
}; | ||
Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { | ||
return this._zoneDelegate.scheduleTask(this, new ZoneTask('macroTask', this, source, callback, data, customSchedule, customCancel)); | ||
}; | ||
Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { | ||
return this._zoneDelegate.scheduleTask(this, new ZoneTask('eventTask', this, source, callback, data, customSchedule, customCancel)); | ||
}; | ||
Zone.prototype.cancelTask = function (task) { | ||
var value = this._zoneDelegate.cancelTask(this, task); | ||
task.runCount = -1; | ||
task.cancelFn = null; | ||
return value; | ||
}; | ||
Zone.__symbol__ = __symbol__; | ||
return Zone; | ||
}()); | ||
; | ||
var ZoneDelegate = (function () { | ||
function ZoneDelegate(zone, parentDelegate, zoneSpec) { | ||
this._taskCounts = { microTask: 0, macroTask: 0, eventTask: 0 }; | ||
this.zone = zone; | ||
this._parentDelegate = parentDelegate; | ||
this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); | ||
this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); | ||
this._interceptZS = zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); | ||
this._interceptDlgt = zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); | ||
this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); | ||
this._invokeDlgt = zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); | ||
this._handleErrorZS = zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); | ||
this._handleErrorDlgt = zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); | ||
this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); | ||
this._scheduleTaskDlgt = zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); | ||
this._invokeTaskZS = zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); | ||
this._invokeTaskDlgt = zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); | ||
this._cancelTaskZS = zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); | ||
this._cancelTaskDlgt = zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); | ||
this._hasTaskZS = zoneSpec && (zoneSpec.onHasTask ? zoneSpec : parentDelegate._hasTaskZS); | ||
this._hasTaskDlgt = zoneSpec && (zoneSpec.onHasTask ? parentDelegate : parentDelegate._hasTaskDlgt); | ||
} | ||
ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { | ||
return this._forkZS | ||
? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) | ||
: new Zone(targetZone, zoneSpec); | ||
}; | ||
ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { | ||
return this._interceptZS | ||
? this._interceptZS.onIntercept(this._interceptDlgt, this.zone, targetZone, callback, source) | ||
: callback; | ||
}; | ||
ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { | ||
return this._invokeZS | ||
? this._invokeZS.onInvoke(this._invokeDlgt, this.zone, targetZone, callback, applyThis, applyArgs, source) | ||
: callback.apply(applyThis, applyArgs); | ||
}; | ||
ZoneDelegate.prototype.handleError = function (targetZone, error) { | ||
return this._handleErrorZS | ||
? this._handleErrorZS.onHandleError(this._handleErrorDlgt, this.zone, targetZone, error) | ||
: true; | ||
}; | ||
ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { | ||
try { | ||
if (this._scheduleTaskZS) { | ||
return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this.zone, targetZone, task); | ||
} | ||
else if (task.scheduleFn) { | ||
task.scheduleFn(task); | ||
} | ||
else if (task.type == 'microTask') { | ||
scheduleMicroTask(task); | ||
} | ||
else { | ||
throw new Error('Task is missing scheduleFn.'); | ||
} | ||
return task; | ||
} | ||
finally { | ||
if (targetZone == this.zone) { | ||
this._updateTaskCount(task.type, 1); | ||
} | ||
} | ||
}; | ||
ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { | ||
try { | ||
return this._invokeTaskZS | ||
? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this.zone, targetZone, task, applyThis, applyArgs) | ||
: task.callback.apply(applyThis, applyArgs); | ||
} | ||
finally { | ||
if (targetZone == this.zone && (task.type != 'eventTask') && !(task.data && task.data.isPeriodic)) { | ||
this._updateTaskCount(task.type, -1); | ||
} | ||
} | ||
}; | ||
ZoneDelegate.prototype.cancelTask = function (targetZone, task) { | ||
var value; | ||
if (this._cancelTaskZS) { | ||
value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this.zone, targetZone, task); | ||
} | ||
else if (!task.cancelFn) { | ||
throw new Error('Task does not support cancellation, or is already canceled.'); | ||
} | ||
else { | ||
value = task.cancelFn(task); | ||
} | ||
if (targetZone == this.zone) { | ||
// this should not be in the finally block, because exceptions assume not canceled. | ||
this._updateTaskCount(task.type, -1); | ||
} | ||
return value; | ||
}; | ||
ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { | ||
return this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty); | ||
}; | ||
ZoneDelegate.prototype._updateTaskCount = function (type, count) { | ||
var counts = this._taskCounts; | ||
var prev = counts[type]; | ||
var next = counts[type] = prev + count; | ||
if (next < 0) { | ||
throw new Error('More tasks executed then were scheduled.'); | ||
} | ||
if (prev == 0 || next == 0) { | ||
var isEmpty = { | ||
microTask: counts.microTask > 0, | ||
macroTask: counts.macroTask > 0, | ||
eventTask: counts.eventTask > 0, | ||
change: type | ||
}; | ||
try { | ||
this.hasTask(this.zone, isEmpty); | ||
} | ||
finally { | ||
if (this._parentDelegate) { | ||
this._parentDelegate._updateTaskCount(type, count); | ||
} | ||
} | ||
} | ||
}; | ||
return ZoneDelegate; | ||
}()); | ||
var ZoneTask = (function () { | ||
function ZoneTask(type, zone, source, callback, options, scheduleFn, cancelFn) { | ||
this.runCount = 0; | ||
this.type = type; | ||
this.zone = zone; | ||
this.source = source; | ||
this.data = options; | ||
this.scheduleFn = scheduleFn; | ||
this.cancelFn = cancelFn; | ||
this.callback = callback; | ||
var self = this; | ||
this.invoke = function () { | ||
_numberOfNestedTaskFrames++; | ||
try { | ||
return zone.runTask(self, this, arguments); | ||
} | ||
finally { | ||
if (_numberOfNestedTaskFrames == 1) { | ||
drainMicroTaskQueue(); | ||
} | ||
_numberOfNestedTaskFrames--; | ||
} | ||
}; | ||
} | ||
ZoneTask.prototype.toString = function () { | ||
if (this.data && typeof this.data.handleId !== 'undefined') { | ||
return this.data.handleId; | ||
} | ||
else { | ||
return this.toString(); | ||
} | ||
}; | ||
return ZoneTask; | ||
}()); | ||
function __symbol__(name) { return '__zone_symbol__' + name; } | ||
; | ||
var symbolSetTimeout = __symbol__('setTimeout'); | ||
var symbolPromise = __symbol__('Promise'); | ||
var symbolThen = __symbol__('then'); | ||
var _currentZone = new Zone(null, null); | ||
var _currentTask = null; | ||
var _microTaskQueue = []; | ||
var _isDrainingMicrotaskQueue = false; | ||
var _uncaughtPromiseErrors = []; | ||
var _numberOfNestedTaskFrames = 0; | ||
function scheduleQueueDrain() { | ||
// if we are not running in any task, and there has not been anything scheduled | ||
// we must bootstrap the initial task creation by manually scheduling the drain | ||
if (_numberOfNestedTaskFrames == 0 && _microTaskQueue.length == 0) { | ||
// We are not running in Task, so we need to kickstart the microtask queue. | ||
if (global[symbolPromise]) { | ||
global[symbolPromise].resolve(0)[symbolThen](drainMicroTaskQueue); | ||
} | ||
else { | ||
global[symbolSetTimeout](drainMicroTaskQueue, 0); | ||
} | ||
} | ||
} | ||
function scheduleMicroTask(task) { | ||
scheduleQueueDrain(); | ||
_microTaskQueue.push(task); | ||
} | ||
function consoleError(e) { | ||
var rejection = e && e.rejection; | ||
if (rejection) { | ||
console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); | ||
} | ||
console.error(e); | ||
} | ||
function drainMicroTaskQueue() { | ||
if (!_isDrainingMicrotaskQueue) { | ||
_isDrainingMicrotaskQueue = true; | ||
while (_microTaskQueue.length) { | ||
var queue = _microTaskQueue; | ||
_microTaskQueue = []; | ||
for (var i = 0; i < queue.length; i++) { | ||
var task = queue[i]; | ||
try { | ||
task.zone.runTask(task, null, null); | ||
} | ||
catch (e) { | ||
consoleError(e); | ||
} | ||
} | ||
} | ||
while (_uncaughtPromiseErrors.length) { | ||
var _loop_1 = function() { | ||
var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); | ||
try { | ||
uncaughtPromiseError.zone.runGuarded(function () { throw uncaughtPromiseError; }); | ||
} | ||
catch (e) { | ||
consoleError(e); | ||
} | ||
}; | ||
while (_uncaughtPromiseErrors.length) { | ||
_loop_1(); | ||
} | ||
} | ||
_isDrainingMicrotaskQueue = false; | ||
} | ||
} | ||
function isThenable(value) { | ||
return value && value.then; | ||
} | ||
function forwardResolution(value) { return value; } | ||
function forwardRejection(rejection) { return ZoneAwarePromise.reject(rejection); } | ||
var symbolState = __symbol__('state'); | ||
var symbolValue = __symbol__('value'); | ||
var source = 'Promise.then'; | ||
var UNRESOLVED = null; | ||
var RESOLVED = true; | ||
var REJECTED = false; | ||
var REJECTED_NO_CATCH = 0; | ||
function makeResolver(promise, state) { | ||
return function (v) { | ||
resolvePromise(promise, state, v); | ||
// Do not return value or you will break the Promise spec. | ||
}; | ||
} | ||
function resolvePromise(promise, state, value) { | ||
if (promise[symbolState] === UNRESOLVED) { | ||
if (value instanceof ZoneAwarePromise && value[symbolState] !== UNRESOLVED) { | ||
clearRejectedNoCatch(value); | ||
resolvePromise(promise, value[symbolState], value[symbolValue]); | ||
} | ||
else if (isThenable(value)) { | ||
value.then(makeResolver(promise, state), makeResolver(promise, false)); | ||
} | ||
else { | ||
promise[symbolState] = state; | ||
var queue = promise[symbolValue]; | ||
promise[symbolValue] = value; | ||
for (var i = 0; i < queue.length;) { | ||
scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); | ||
} | ||
if (queue.length == 0 && state == REJECTED) { | ||
promise[symbolState] = REJECTED_NO_CATCH; | ||
try { | ||
throw new Error("Uncaught (in promise): " + value); | ||
} | ||
catch (e) { | ||
var error = e; | ||
error.rejection = value; | ||
error.promise = promise; | ||
error.zone = Zone.current; | ||
error.task = Zone.currentTask; | ||
_uncaughtPromiseErrors.push(error); | ||
scheduleQueueDrain(); | ||
} | ||
} | ||
} | ||
} | ||
// Resolving an already resolved promise is a noop. | ||
return promise; | ||
} | ||
function clearRejectedNoCatch(promise) { | ||
if (promise[symbolState] === REJECTED_NO_CATCH) { | ||
promise[symbolState] = REJECTED; | ||
for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { | ||
if (promise === _uncaughtPromiseErrors[i].promise) { | ||
_uncaughtPromiseErrors.splice(i, 1); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { | ||
clearRejectedNoCatch(promise); | ||
var delegate = promise[symbolState] ? onFulfilled || forwardResolution : onRejected || forwardRejection; | ||
zone.scheduleMicroTask(source, function () { | ||
try { | ||
resolvePromise(chainPromise, true, zone.run(delegate, null, [promise[symbolValue]])); | ||
} | ||
catch (error) { | ||
resolvePromise(chainPromise, false, error); | ||
} | ||
}); | ||
} | ||
var ZoneAwarePromise = (function () { | ||
function ZoneAwarePromise(executor) { | ||
var promise = this; | ||
if (!(promise instanceof ZoneAwarePromise)) { | ||
throw new Error('Must be an instanceof Promise.'); | ||
} | ||
promise[symbolState] = UNRESOLVED; | ||
promise[symbolValue] = []; // queue; | ||
try { | ||
executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); | ||
} | ||
catch (e) { | ||
resolvePromise(promise, false, e); | ||
} | ||
} | ||
ZoneAwarePromise.resolve = function (value) { | ||
return resolvePromise(new this(null), RESOLVED, value); | ||
}; | ||
ZoneAwarePromise.reject = function (error) { | ||
return resolvePromise(new this(null), REJECTED, error); | ||
}; | ||
ZoneAwarePromise.race = function (values) { | ||
var resolve; | ||
var reject; | ||
var promise = new this(function (res, rej) { resolve = res; reject = rej; }); | ||
function onResolve(value) { promise && (promise = null || resolve(value)); } | ||
function onReject(error) { promise && (promise = null || reject(error)); } | ||
for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { | ||
var value = values_1[_i]; | ||
if (!isThenable(value)) { | ||
value = this.resolve(value); | ||
} | ||
value.then(onResolve, onReject); | ||
} | ||
return promise; | ||
}; | ||
ZoneAwarePromise.all = function (values) { | ||
var resolve; | ||
var reject; | ||
var promise = new this(function (res, rej) { resolve = res; reject = rej; }); | ||
var count = 0; | ||
var resolvedValues = []; | ||
function onReject(error) { promise && reject(error); promise = null; } | ||
for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { | ||
var value = values_2[_i]; | ||
if (!isThenable(value)) { | ||
value = this.resolve(value); | ||
} | ||
value.then((function (index) { return function (value) { | ||
resolvedValues[index] = value; | ||
count--; | ||
if (promise && !count) { | ||
resolve(resolvedValues); | ||
} | ||
promise == null; | ||
}; })(count), onReject); | ||
count++; | ||
} | ||
if (!count) | ||
resolve(resolvedValues); | ||
return promise; | ||
}; | ||
ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { | ||
var chainPromise = new this.constructor(null); | ||
var zone = Zone.current; | ||
if (this[symbolState] == UNRESOLVED) { | ||
this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); | ||
} | ||
else { | ||
scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); | ||
} | ||
return chainPromise; | ||
}; | ||
ZoneAwarePromise.prototype.catch = function (onRejected) { | ||
return this.then(null, onRejected); | ||
}; | ||
return ZoneAwarePromise; | ||
}()); | ||
var NativePromise = global[__symbol__('Promise')] = global.Promise; | ||
global.Promise = ZoneAwarePromise; | ||
if (NativePromise) { | ||
var NativePromiseProtototype = NativePromise.prototype; | ||
var NativePromiseThen_1 = NativePromiseProtototype[__symbol__('then')] | ||
= NativePromiseProtototype.then; | ||
NativePromiseProtototype.then = function (onResolve, onReject) { | ||
var nativePromise = this; | ||
return new ZoneAwarePromise(function (resolve, reject) { | ||
NativePromiseThen_1.call(nativePromise, resolve, reject); | ||
}).then(onResolve, onReject); | ||
}; | ||
} | ||
// This is not part of public API, but it is usefull for tests, so we expose it. | ||
Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; | ||
return global.Zone = Zone; | ||
})(typeof window === 'undefined' ? global : window); | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 2 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var utils_1 = __webpack_require__(3); | ||
var 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'; | ||
var 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(','); | ||
var EVENT_TARGET = 'EventTarget'; | ||
function eventTargetPatch(_global) { | ||
var apis = []; | ||
var isWtf = _global['wtf']; | ||
if (isWtf) { | ||
// Workaround for: https://github.com/google/tracing-framework/issues/555 | ||
apis = WTF_ISSUE_555.split(',').map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); | ||
} | ||
else if (_global[EVENT_TARGET]) { | ||
apis.push(EVENT_TARGET); | ||
} | ||
else { | ||
// Note: EventTarget is not available in all browsers, | ||
// if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget | ||
apis = NO_EVENT_TARGET; | ||
} | ||
for (var i = 0; i < apis.length; i++) { | ||
var type = _global[apis[i]]; | ||
utils_1.patchEventTargetMethods(type && type.prototype); | ||
} | ||
} | ||
exports.eventTargetPatch = eventTargetPatch; | ||
/***/ }, | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
/* WEBPACK VAR INJECTION */(function(global) {/** | ||
* Suppress closure compiler errors about unknown 'process' variable | ||
* @fileoverview | ||
* @suppress {undefinedVars} | ||
*/ | ||
"use strict"; | ||
exports.zoneSymbol = Zone['__symbol__']; | ||
var _global = typeof window == 'undefined' ? global : window; | ||
function bindArguments(args, source) { | ||
for (var i = args.length - 1; i >= 0; i--) { | ||
if (typeof args[i] === 'function') { | ||
args[i] = Zone.current.wrap(args[i], source + '_' + i); | ||
} | ||
} | ||
return args; | ||
} | ||
exports.bindArguments = bindArguments; | ||
; | ||
function patchPrototype(prototype, fnNames) { | ||
var source = prototype.constructor['name']; | ||
var _loop_1 = function(i) { | ||
var name_1 = fnNames[i]; | ||
var delegate = prototype[name_1]; | ||
if (delegate) { | ||
prototype[name_1] = (function (delegate) { | ||
return function () { | ||
return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); | ||
}; | ||
})(delegate); | ||
} | ||
}; | ||
for (var i = 0; i < fnNames.length; i++) { | ||
_loop_1(i); | ||
} | ||
} | ||
exports.patchPrototype = patchPrototype; | ||
; | ||
exports.isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); | ||
exports.isNode = (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]'); | ||
exports.isBrowser = !exports.isNode && !exports.isWebWorker && !!(typeof window !== 'undefined' && window['HTMLElement']); | ||
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); | ||
} | ||
exports.patchProperty = patchProperty; | ||
; | ||
function patchOnProperties(obj, properties) { | ||
var onProperties = []; | ||
for (var prop in obj) { | ||
if (prop.substr(0, 2) == 'on') { | ||
onProperties.push(prop); | ||
} | ||
} | ||
for (var j = 0; j < onProperties.length; j++) { | ||
patchProperty(obj, onProperties[j]); | ||
} | ||
if (properties) { | ||
for (var i = 0; i < properties.length; i++) { | ||
patchProperty(obj, 'on' + properties[i]); | ||
} | ||
} | ||
} | ||
exports.patchOnProperties = patchOnProperties; | ||
; | ||
var EVENT_TASKS = exports.zoneSymbol('eventTasks'); | ||
var ADD_EVENT_LISTENER = 'addEventListener'; | ||
var REMOVE_EVENT_LISTENER = 'removeEventListener'; | ||
var SYMBOL_ADD_EVENT_LISTENER = exports.zoneSymbol(ADD_EVENT_LISTENER); | ||
var SYMBOL_REMOVE_EVENT_LISTENER = exports.zoneSymbol(REMOVE_EVENT_LISTENER); | ||
function findExistingRegisteredTask(target, handler, name, capture, remove) { | ||
var eventTasks = target[EVENT_TASKS]; | ||
if (eventTasks) { | ||
for (var i = 0; i < eventTasks.length; i++) { | ||
var eventTask = eventTasks[i]; | ||
var data = eventTask.data; | ||
if (data.handler === handler | ||
&& data.useCapturing === capture | ||
&& data.eventName === name) { | ||
if (remove) { | ||
eventTasks.splice(i, 1); | ||
} | ||
return eventTask; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
function attachRegisteredEvent(target, eventTask) { | ||
var eventTasks = target[EVENT_TASKS]; | ||
if (!eventTasks) { | ||
eventTasks = target[EVENT_TASKS] = []; | ||
} | ||
eventTasks.push(eventTask); | ||
} | ||
function scheduleEventListener(eventTask) { | ||
var meta = eventTask.data; | ||
attachRegisteredEvent(meta.target, eventTask); | ||
return meta.target[SYMBOL_ADD_EVENT_LISTENER](meta.eventName, eventTask.invoke, meta.useCapturing); | ||
} | ||
function cancelEventListener(eventTask) { | ||
var meta = eventTask.data; | ||
findExistingRegisteredTask(meta.target, eventTask.invoke, meta.eventName, meta.useCapturing, true); | ||
meta.target[SYMBOL_REMOVE_EVENT_LISTENER](meta.eventName, eventTask.invoke, meta.useCapturing); | ||
} | ||
function zoneAwareAddEventListener(self, args) { | ||
var eventName = args[0]; | ||
var handler = args[1]; | ||
var useCapturing = args[2] || false; | ||
// - Inside a Web Worker, `this` is undefined, the context is `global` | ||
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined | ||
// see https://github.com/angular/zone.js/issues/190 | ||
var target = self || _global; | ||
var delegate = null; | ||
if (typeof handler == 'function') { | ||
delegate = handler; | ||
} | ||
else if (handler && handler.handleEvent) { | ||
delegate = function (event) { return handler.handleEvent(event); }; | ||
} | ||
var validZoneHandler = false; | ||
try { | ||
// In cross site contexts (such as WebDriver frameworks like Selenium), | ||
// accessing the handler object here will cause an exception to be thrown which | ||
// will fail tests prematurely. | ||
validZoneHandler = handler && handler.toString() === "[object FunctionWrapper]"; | ||
} | ||
catch (e) { | ||
// Returning nothing here is fine, because objects in a cross-site context are unusable | ||
return; | ||
} | ||
// Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150 | ||
if (!delegate || validZoneHandler) { | ||
return target[SYMBOL_ADD_EVENT_LISTENER](eventName, handler, useCapturing); | ||
} | ||
var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, false); | ||
if (eventTask) { | ||
// we already registered, so this will have noop. | ||
return target[SYMBOL_ADD_EVENT_LISTENER](eventName, eventTask.invoke, useCapturing); | ||
} | ||
var zone = Zone.current; | ||
var source = target.constructor['name'] + '.addEventListener:' + eventName; | ||
var data = { | ||
target: target, | ||
eventName: eventName, | ||
name: eventName, | ||
useCapturing: useCapturing, | ||
handler: handler | ||
}; | ||
zone.scheduleEventTask(source, delegate, data, scheduleEventListener, cancelEventListener); | ||
} | ||
function zoneAwareRemoveEventListener(self, args) { | ||
var eventName = args[0]; | ||
var handler = args[1]; | ||
var useCapturing = args[2] || false; | ||
// - Inside a Web Worker, `this` is undefined, the context is `global` | ||
// - When `addEventListener` is called on the global context in strict mode, `this` is undefined | ||
// see https://github.com/angular/zone.js/issues/190 | ||
var target = self || _global; | ||
var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, true); | ||
if (eventTask) { | ||
eventTask.zone.cancelTask(eventTask); | ||
} | ||
else { | ||
target[SYMBOL_REMOVE_EVENT_LISTENER](eventName, handler, useCapturing); | ||
} | ||
} | ||
function patchEventTargetMethods(obj) { | ||
if (obj && obj.addEventListener) { | ||
patchMethod(obj, ADD_EVENT_LISTENER, function () { return zoneAwareAddEventListener; }); | ||
patchMethod(obj, REMOVE_EVENT_LISTENER, function () { return zoneAwareRemoveEventListener; }); | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
} | ||
exports.patchEventTargetMethods = patchEventTargetMethods; | ||
; | ||
var originalInstanceKey = exports.zoneSymbol('originalInstance'); | ||
// wrap some native API on `window` | ||
function patchClass(className) { | ||
var OriginalClass = _global[className]; | ||
if (!OriginalClass) | ||
return; | ||
_global[className] = function () { | ||
var a = bindArguments(arguments, className); | ||
switch (a.length) { | ||
case 0: | ||
this[originalInstanceKey] = new OriginalClass(); | ||
break; | ||
case 1: | ||
this[originalInstanceKey] = new OriginalClass(a[0]); | ||
break; | ||
case 2: | ||
this[originalInstanceKey] = new OriginalClass(a[0], a[1]); | ||
break; | ||
case 3: | ||
this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); | ||
break; | ||
case 4: | ||
this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); | ||
break; | ||
default: throw new Error('Arg list too long.'); | ||
} | ||
}; | ||
var instance = new OriginalClass(function () { }); | ||
var prop; | ||
for (prop in instance) { | ||
// https://bugs.webkit.org/show_bug.cgi?id=44721 | ||
if (className === 'XMLHttpRequest' && prop === 'responseBlob') | ||
continue; | ||
(function (prop) { | ||
if (typeof instance[prop] === 'function') { | ||
_global[className].prototype[prop] = function () { | ||
return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); | ||
}; | ||
} | ||
else { | ||
Object.defineProperty(_global[className].prototype, prop, { | ||
set: function (fn) { | ||
if (typeof fn === 'function') { | ||
this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); | ||
} | ||
else { | ||
this[originalInstanceKey][prop] = fn; | ||
} | ||
}, | ||
get: function () { | ||
return this[originalInstanceKey][prop]; | ||
} | ||
}); | ||
} | ||
}(prop)); | ||
} | ||
for (prop in OriginalClass) { | ||
if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { | ||
_global[className][prop] = OriginalClass[prop]; | ||
} | ||
} | ||
} | ||
exports.patchClass = patchClass; | ||
; | ||
function createNamedFn(name, delegate) { | ||
try { | ||
return (Function('f', "return function " + name + "(){return f(this, arguments)}"))(delegate); | ||
} | ||
catch (e) { | ||
// if we fail, we must be CSP, just return delegate. | ||
return function () { | ||
return delegate(this, arguments); | ||
}; | ||
} | ||
} | ||
exports.createNamedFn = createNamedFn; | ||
function patchMethod(target, name, patchFn) { | ||
var proto = target; | ||
while (proto && !proto.hasOwnProperty(name)) { | ||
proto = Object.getPrototypeOf(proto); | ||
} | ||
if (!proto && target[name]) { | ||
// somehow we did not find it, but we can see it. This happens on IE for Window properties. | ||
proto = target; | ||
} | ||
var delegateName = exports.zoneSymbol(name); | ||
var delegate; | ||
if (proto && !(delegate = proto[delegateName])) { | ||
delegate = proto[delegateName] = proto[name]; | ||
proto[name] = createNamedFn(name, patchFn(delegate, delegateName, name)); | ||
} | ||
return delegate; | ||
} | ||
exports.patchMethod = patchMethod; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var utils_1 = __webpack_require__(3); | ||
/* | ||
* This is necessary for Chrome and Chrome mobile, to enable | ||
* things like redefining `createdCallback` on an element. | ||
*/ | ||
var _defineProperty = Object.defineProperty; | ||
var _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
var _create = Object.create; | ||
var unconfigurablesKey = utils_1.zoneSymbol('unconfigurables'); | ||
function propertyPatch() { | ||
Object.defineProperty = function (obj, prop, desc) { | ||
if (isUnconfigurable(obj, prop)) { | ||
throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); | ||
} | ||
var originalConfigurableFlag = desc.configurable; | ||
if (prop !== 'prototype') { | ||
desc = rewriteDescriptor(obj, prop, desc); | ||
} | ||
return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); | ||
}; | ||
Object.defineProperties = function (obj, props) { | ||
Object.keys(props).forEach(function (prop) { | ||
Object.defineProperty(obj, prop, props[prop]); | ||
}); | ||
return obj; | ||
}; | ||
Object.create = function (obj, proto) { | ||
if (typeof proto === 'object' && !Object.isFrozen(proto)) { | ||
Object.keys(proto).forEach(function (prop) { | ||
proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); | ||
}); | ||
} | ||
return _create(obj, proto); | ||
}; | ||
Object.getOwnPropertyDescriptor = function (obj, prop) { | ||
var desc = _getOwnPropertyDescriptor(obj, prop); | ||
if (isUnconfigurable(obj, prop)) { | ||
desc.configurable = false; | ||
} | ||
return desc; | ||
}; | ||
} | ||
exports.propertyPatch = propertyPatch; | ||
; | ||
function _redefineProperty(obj, prop, desc) { | ||
var originalConfigurableFlag = desc.configurable; | ||
desc = rewriteDescriptor(obj, prop, desc); | ||
return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); | ||
} | ||
exports._redefineProperty = _redefineProperty; | ||
; | ||
function isUnconfigurable(obj, prop) { | ||
return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; | ||
} | ||
function rewriteDescriptor(obj, prop, desc) { | ||
desc.configurable = true; | ||
if (!desc.configurable) { | ||
if (!obj[unconfigurablesKey]) { | ||
_defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); | ||
} | ||
obj[unconfigurablesKey][prop] = true; | ||
} | ||
return desc; | ||
} | ||
function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { | ||
try { | ||
return _defineProperty(obj, prop, desc); | ||
} | ||
catch (e) { | ||
if (desc.configurable) { | ||
// In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's retry with the original flag value | ||
if (typeof originalConfigurableFlag == 'undefined') { | ||
delete desc.configurable; | ||
} | ||
else { | ||
desc.configurable = originalConfigurableFlag; | ||
} | ||
return _defineProperty(obj, prop, desc); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
} | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var define_property_1 = __webpack_require__(4); | ||
var utils_1 = __webpack_require__(3); | ||
function registerElementPatch(_global) { | ||
if (!utils_1.isBrowser || !('registerElement' in _global.document)) { | ||
return; | ||
} | ||
var _registerElement = document.registerElement; | ||
var callbacks = [ | ||
'createdCallback', | ||
'attachedCallback', | ||
'detachedCallback', | ||
'attributeChangedCallback' | ||
]; | ||
document.registerElement = function (name, opts) { | ||
if (opts && opts.prototype) { | ||
callbacks.forEach(function (callback) { | ||
var source = 'Document.registerElement::' + callback; | ||
if (opts.prototype.hasOwnProperty(callback)) { | ||
var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback); | ||
if (descriptor && descriptor.value) { | ||
descriptor.value = Zone.current.wrap(descriptor.value, source); | ||
define_property_1._redefineProperty(opts.prototype, callback, descriptor); | ||
} | ||
else { | ||
opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); | ||
} | ||
} | ||
else if (opts.prototype[callback]) { | ||
opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); | ||
} | ||
}); | ||
} | ||
return _registerElement.apply(document, [name, opts]); | ||
}; | ||
} | ||
exports.registerElementPatch = registerElementPatch; | ||
/***/ }, | ||
/* 6 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var webSocketPatch = __webpack_require__(7); | ||
var utils_1 = __webpack_require__(3); | ||
var 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(' '); | ||
function propertyDescriptorPatch(_global) { | ||
if (utils_1.isNode) { | ||
return; | ||
} | ||
var supportsWebSocket = typeof WebSocket !== 'undefined'; | ||
if (canPatchViaPropertyDescriptor()) { | ||
// for browsers that we can patch the descriptor: Chrome & Firefox | ||
if (utils_1.isBrowser) { | ||
utils_1.patchOnProperties(HTMLElement.prototype, eventNames); | ||
} | ||
utils_1.patchOnProperties(XMLHttpRequest.prototype, null); | ||
if (typeof IDBIndex !== 'undefined') { | ||
utils_1.patchOnProperties(IDBIndex.prototype, null); | ||
utils_1.patchOnProperties(IDBRequest.prototype, null); | ||
utils_1.patchOnProperties(IDBOpenDBRequest.prototype, null); | ||
utils_1.patchOnProperties(IDBDatabase.prototype, null); | ||
utils_1.patchOnProperties(IDBTransaction.prototype, null); | ||
utils_1.patchOnProperties(IDBCursor.prototype, null); | ||
} | ||
if (supportsWebSocket) { | ||
utils_1.patchOnProperties(WebSocket.prototype, null); | ||
} | ||
} | ||
else { | ||
// Safari, Android browsers (Jelly Bean) | ||
patchViaCapturingAllTheEvents(); | ||
utils_1.patchClass('XMLHttpRequest'); | ||
if (supportsWebSocket) { | ||
webSocketPatch.apply(_global); | ||
} | ||
} | ||
} | ||
exports.propertyDescriptorPatch = propertyDescriptorPatch; | ||
function canPatchViaPropertyDescriptor() { | ||
if (utils_1.isBrowser && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') | ||
&& typeof Element !== 'undefined') { | ||
// WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 | ||
// IDL interface attributes are not configurable | ||
var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); | ||
if (desc && !desc.configurable) | ||
return false; | ||
} | ||
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { | ||
get: function () { | ||
return true; | ||
} | ||
}); | ||
var req = new XMLHttpRequest(); | ||
var result = !!req.onreadystatechange; | ||
Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', {}); | ||
return result; | ||
} | ||
; | ||
var unboundKey = utils_1.zoneSymbol('unbound'); | ||
// Whenever any eventListener fires, we check the eventListener target and all parents | ||
// for `onwhatever` properties and replace them with zone-bound functions | ||
// - Chrome (for now) | ||
function patchViaCapturingAllTheEvents() { | ||
var _loop_1 = function(i) { | ||
var property = eventNames[i]; | ||
var onproperty = 'on' + property; | ||
document.addEventListener(property, function (event) { | ||
var elt = event.target, bound, source; | ||
if (elt) { | ||
source = elt.constructor['name'] + '.' + onproperty; | ||
} | ||
else { | ||
source = 'unknown.' + onproperty; | ||
} | ||
while (elt) { | ||
if (elt[onproperty] && !elt[onproperty][unboundKey]) { | ||
bound = Zone.current.wrap(elt[onproperty], source); | ||
bound[unboundKey] = elt[onproperty]; | ||
elt[onproperty] = bound; | ||
} | ||
elt = elt.parentElement; | ||
} | ||
}, true); | ||
}; | ||
for (var i = 0; i < eventNames.length; i++) { | ||
_loop_1(i); | ||
} | ||
; | ||
} | ||
; | ||
/***/ }, | ||
/* 7 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var utils_1 = __webpack_require__(3); | ||
// we have to patch the instance since the proto is non-configurable | ||
function apply(_global) { | ||
var WS = _global.WebSocket; | ||
// On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener | ||
// On older Chrome, no need since EventTarget was already patched | ||
if (!_global.EventTarget) { | ||
utils_1.patchEventTargetMethods(WS.prototype); | ||
} | ||
_global.WebSocket = function (a, b) { | ||
var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); | ||
var proxySocket; | ||
// Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance | ||
var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); | ||
if (onmessageDesc && onmessageDesc.configurable === false) { | ||
proxySocket = Object.create(socket); | ||
['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function (propName) { | ||
proxySocket[propName] = function () { | ||
return socket[propName].apply(socket, arguments); | ||
}; | ||
}); | ||
} | ||
else { | ||
// we can patch the real socket | ||
proxySocket = socket; | ||
} | ||
utils_1.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open']); | ||
return proxySocket; | ||
}; | ||
for (var prop in WS) { | ||
_global.WebSocket[prop] = WS[prop]; | ||
} | ||
} | ||
exports.apply = apply; | ||
/***/ }, | ||
/* 8 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var utils_1 = __webpack_require__(3); | ||
function patchTimer(window, setName, cancelName, nameSuffix) { | ||
var setNative = null; | ||
var clearNative = null; | ||
setName += nameSuffix; | ||
cancelName += nameSuffix; | ||
function scheduleTask(task) { | ||
var data = task.data; | ||
data.args[0] = task.invoke; | ||
data.handleId = setNative.apply(window, data.args); | ||
return task; | ||
} | ||
function clearTask(task) { | ||
return clearNative(task.data.handleId); | ||
} | ||
setNative = utils_1.patchMethod(window, setName, function (delegate) { return function (self, args) { | ||
if (typeof args[0] === 'function') { | ||
var zone = Zone.current; | ||
var options = { | ||
handleId: null, | ||
isPeriodic: nameSuffix === 'Interval', | ||
delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, | ||
args: args | ||
}; | ||
var task = zone.scheduleMacroTask(setName, args[0], options, scheduleTask, clearTask); | ||
if (!task) { | ||
return task; | ||
} | ||
// Node.js must additionally support the ref and unref functions. | ||
var handle = task.data.handleId; | ||
if (handle.ref && handle.unref) { | ||
task.ref = handle.ref.bind(handle); | ||
task.unref = handle.unref.bind(handle); | ||
} | ||
return task; | ||
} | ||
else { | ||
// cause an error by calling it directly. | ||
return delegate.apply(window, args); | ||
} | ||
}; }); | ||
clearNative = utils_1.patchMethod(window, cancelName, function (delegate) { return function (self, args) { | ||
var task = args[0]; | ||
if (task && typeof task.type === 'string') { | ||
if (task.cancelFn && task.data.isPeriodic || task.runCount === 0) { | ||
// Do not cancel already canceled functions | ||
task.zone.cancelTask(task); | ||
} | ||
} | ||
else { | ||
// cause an error by calling it directly. | ||
delegate.apply(window, args); | ||
} | ||
}; }); | ||
} | ||
exports.patchTimer = patchTimer; | ||
/***/ } | ||
/******/ ]); | ||
var set = 'set'; | ||
var clear = 'clear'; | ||
var blockingMethods = ['alert', 'prompt', 'confirm']; | ||
var _global = typeof window == 'undefined' ? global : window; | ||
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 (delegate, symbol, name) { | ||
return function (s, args) { | ||
return Zone.current.run(delegate, _global, args, name); | ||
}; | ||
}); | ||
} | ||
eventTargetPatch(_global); | ||
propertyDescriptorPatch(_global); | ||
patchClass('MutationObserver'); | ||
patchClass('WebKitMutationObserver'); | ||
patchClass('FileReader'); | ||
propertyPatch(); | ||
registerElementPatch(_global); | ||
// Treat XMLHTTPRequest as a macrotask. | ||
patchXHR(_global); | ||
var XHR_TASK = zoneSymbol('xhrTask'); | ||
var XHR_SYNC = zoneSymbol('xhrSync'); | ||
function patchXHR(window) { | ||
function findPendingTask(target) { | ||
var pendingTask = target[XHR_TASK]; | ||
return pendingTask; | ||
} | ||
function scheduleTask(task) { | ||
var data = task.data; | ||
data.target.addEventListener('readystatechange', function () { | ||
if (data.target.readyState === data.target.DONE) { | ||
if (!data.aborted) { | ||
task.invoke(); | ||
} | ||
} | ||
}); | ||
var storedTask = data.target[XHR_TASK]; | ||
if (!storedTask) { | ||
data.target[XHR_TASK] = task; | ||
} | ||
sendNative.apply(data.target, data.args); | ||
return task; | ||
} | ||
function placeholderCallback() { | ||
} | ||
function clearTask(task) { | ||
var data = task.data; | ||
// Note - ideally, we would call data.target.removeEventListener here, but it's too late | ||
// to prevent it from firing. So instead, we store info for the event listener. | ||
data.aborted = true; | ||
return abortNative.apply(data.target, data.args); | ||
} | ||
var openNative = patchMethod(window.XMLHttpRequest.prototype, 'open', function () { return function (self, args) { | ||
self[XHR_SYNC] = args[2] == false; | ||
return openNative.apply(self, args); | ||
}; }); | ||
var sendNative = patchMethod(window.XMLHttpRequest.prototype, 'send', function () { return function (self, args) { | ||
var zone = Zone.current; | ||
if (self[XHR_SYNC]) { | ||
// if the XHR is sync there is no task to schedule, just execute the code. | ||
return sendNative.apply(self, args); | ||
} | ||
else { | ||
var options = { | ||
target: self, | ||
isPeriodic: false, | ||
delay: null, | ||
args: args, | ||
aborted: false | ||
}; | ||
return zone.scheduleMacroTask('XMLHttpRequest.send', placeholderCallback, options, scheduleTask, clearTask); | ||
} | ||
}; }); | ||
var abortNative = patchMethod(window.XMLHttpRequest.prototype, 'abort', function (delegate) { return function (self, args) { | ||
var task = findPendingTask(self); | ||
if (task && typeof task.type == 'string') { | ||
// If the XHR has already completed, do nothing. | ||
if (task.cancelFn == null) { | ||
return; | ||
} | ||
task.zone.cancelTask(task); | ||
} | ||
// Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no task to cancel. Do nothing. | ||
}; }); | ||
} | ||
/// GEO_LOCATION | ||
if (_global['navigator'] && _global['navigator'].geolocation) { | ||
patchPrototype(_global['navigator'].geolocation, [ | ||
'getCurrentPosition', | ||
'watchPosition' | ||
]); | ||
} |
@@ -233,2 +233,6 @@ /** | ||
currentTask: Task; | ||
/** | ||
* Verify that Zone has been correctly patched. Specifically that Promise is zone aware. | ||
*/ | ||
assertZonePatched(): any; | ||
} | ||
@@ -235,0 +239,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,exports,t){(function(e){"use strict";function n(e){function t(e){var t=e[v];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[v];return n||(t.target[v]=e),a.apply(t.target,t.args),e}function r(){}function o(e){var t=e.data;return t.aborted=!0,i.apply(t.target,t.args)}var a=c.patchMethod(e.XMLHttpRequest.prototype,"send",function(){return function(e,t){var a=Zone.current,i={target:e,isPeriodic:!1,delay:null,args:t,aborted:!1};return a.scheduleMacroTask("XMLHttpRequest.send",r,i,n,o)}}),i=c.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)}}})}t(1);var r=t(2),o=t(4),a=t(5),i=t(6),s=t(8),c=t(3),u="set",l="clear",p=["alert","prompt","confirm"],h="undefined"==typeof window?e:window;s.patchTimer(h,u,l,"Timeout"),s.patchTimer(h,u,l,"Interval"),s.patchTimer(h,u,l,"Immediate"),s.patchTimer(h,"request","cancel","AnimationFrame"),s.patchTimer(h,"mozRequest","mozCancel","AnimationFrame"),s.patchTimer(h,"webkitRequest","webkitCancel","AnimationFrame");for(var f=0;f<p.length;f++){var d=p[f];c.patchMethod(h,d,function(e,t,n){return function(t,r){return Zone.current.run(e,h,r,n)}})}r.eventTargetPatch(h),i.propertyDescriptorPatch(h),c.patchClass("MutationObserver"),c.patchClass("WebKitMutationObserver"),c.patchClass("FileReader"),o.propertyPatch(),a.registerElementPatch(h),n(h);var v=c.zoneSymbol("xhrTask");h.navigator&&h.navigator.geolocation&&c.patchPrototype(h.navigator.geolocation,["getCurrentPosition","watchPosition"])}).call(exports,function(){return this}())},function(e,exports){(function(e){(function(e){function t(e){return"__zone_symbol__"+e}function n(){0==D&&0==b.length&&(e[g]?e[g].resolve(0)[k](a):e[y](a,0))}function r(e){n(),b.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;b.length;){var e=b;b=[];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();_=!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[E]===O)if(r instanceof M&&r[E]!==O)p(r),l(e,r[E],r[P]);else if(i(r))r.then(u(e,t),u(e,!1));else{e[E]=t;var o=e[P];e[P]=r;for(var a=0;a<o.length;)h(e,o[a++],o[a++],o[a++],o[a++]);if(0==o.length&&t==Z){e[E]=C;try{throw new Error("Uncaught (in promise): "+r)}catch(s){var c=s;c.rejection=r,c.promise=e,c.zone=f.current,c.task=f.currentTask,w.push(c),n()}}}return e}function p(e){if(e[E]===C){e[E]=Z;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[E]?r||s:o||c;t.scheduleMicroTask(S,function(){try{l(n,!0,t.run(a,null,[e[P]]))}catch(r){l(n,!1,r)}})}if(e.Zone)throw new Error("Zone already loaded.");var f=function(){function e(e,t){this._properties=null,this._parent=e,this._name=t?t.name||"unnamed":"<root>",this._properties=t&&t.properties||{},this._zoneDelegate=new d(this,this._parent&&this._parent._zoneDelegate,t)}return Object.defineProperty(e,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(e,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},e.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},e.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},e.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)}},e.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}},e.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}},e.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}},e.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new v("microTask",this,e,t,n,r,null))},e.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("macroTask",this,e,t,n,r,o))},e.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("eventTask",this,e,t,n,r,o))},e.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.runCount=-1,e.cancelFn=null,t},e.__symbol__=t,e}(),d=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 f(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}(),v=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(){D++;try{return t.runTask(c,this,arguments)}finally{1==D&&a(),D--}}}return e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:this.toString()},e}(),y=t("setTimeout"),g=t("Promise"),k=t("then"),m=new f(null,null),T=null,b=[],_=!1,w=[],D=0,E=t("state"),P=t("value"),S="Promise.then",O=null,z=!0,Z=!1,C=0,M=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[E]=O,n[P]=[];try{t&&t(u(n,z),u(n,Z))}catch(r){l(n,!1,r)}}return e.resolve=function(e){return l(new this(null),z,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,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){function t(e){o&&r(e),o=null}for(var n,r,o=new this(function(e,t){n=e,r=t}),a=0,s=[],c=0,u=e;c<u.length;c++){var l=u[c];i(l)||(l=this.resolve(l)),l.then(function(e){return function(t){s[e]=t,a--,o&&!a&&n(s)}}(a),t),a++}return a||n(s),o},e.prototype.then=function(e,t){var n=new this.constructor(null),r=f.current;return this[E]==O?this[P].push(r,n,e,t):h(this,r,n,e,t),n},e.prototype["catch"]=function(e){return this.then(null,e)},e}(),I=e[t("Promise")]=e.Promise;if(e.Promise=M,I){var j=I.prototype,L=j[t("then")]=j.then;j.then=function(e,t){var n=this;return new M(function(e,t){L.call(n,e,t)}).then(e,t)}}return Promise[f.__symbol__("uncaughtPromiseErrors")]=w,e.Zone=f})("undefined"==typeof window?e:window)}).call(exports,function(){return this}())},function(e,exports,t){"use strict";function n(e){var t=[],n=e.wtf;n?t=o.split(",").map(function(e){return"HTML"+e+"Element"}).concat(a):e[i]?t.push(i):t=a;for(var s=0;s<t.length;s++){var c=e[t[s]];r.patchEventTargetMethods(c&&c.prototype)}}var r=t(3),o="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",a="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(","),i="EventTarget";exports.eventTargetPatch=n},function(e,exports){(function(e){"use strict";function t(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 n(e,n){for(var r=e.constructor.name,o=function(o){var a=n[o],i=e[a];i&&(e[a]=function(e){return function(){return e.apply(this,t(arguments,r+"."+a))}}(i))},a=0;a<n.length;a++)o(a)}function r(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 o(e,t){var n=[];for(var o in e)"on"==o.substr(0,2)&&n.push(o);for(var a=0;a<n.length;a++)r(e,n[a]);if(t)for(var i=0;i<t.length;i++)r(e,"on"+t[i])}function a(e,t,n,r,o){var a=e[y];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 i(e,t){var n=e[y];n||(n=e[y]=[]),n.push(t)}function s(e){var t=e.data;return i(t.target,e),t.target[m](t.eventName,e.invoke,t.useCapturing)}function c(e){var t=e.data;a(t.target,e.invoke,t.eventName,t.useCapturing,!0),t.target[T](t.eventName,e.invoke,t.useCapturing)}function u(e,t){var n=t[0],r=t[1],o=t[2]||!1,i=e||v,u=null;"function"==typeof r?u=r:r&&r.handleEvent&&(u=function(e){return r.handleEvent(e)});var l=!1;try{l=r&&"[object FunctionWrapper]"===r.toString()}catch(p){return}if(!u||l)return i[m](n,r,o);var h=a(i,r,n,o,!1);if(h)return i[m](n,h.invoke,o);var f=Zone.current,d=i.constructor.name+".addEventListener:"+n,y={target:i,eventName:n,name:n,useCapturing:o,handler:r};f.scheduleEventTask(d,u,y,s,c)}function l(e,t){var n=t[0],r=t[1],o=t[2]||!1,i=e||v,s=a(i,r,n,o,!0);s?s.zone.cancelTask(s):i[T](n,r,o)}function p(e){return!(!e||!e.addEventListener)&&(d(e,g,function(){return u}),d(e,k,function(){return l}),!0)}function h(e){var n=v[e];if(n){v[e]=function(){var r=t(arguments,e);switch(r.length){case 0:this[b]=new n;break;case 1:this[b]=new n(r[0]);break;case 2:this[b]=new n(r[0],r[1]);break;case 3:this[b]=new n(r[0],r[1],r[2]);break;case 4:this[b]=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"===e&&"responseBlob"===r||!function(t){"function"==typeof o[t]?v[e].prototype[t]=function(){return this[b][t].apply(this[b],arguments)}:Object.defineProperty(v[e].prototype,t,{set:function(n){"function"==typeof n?this[b][t]=Zone.current.wrap(n,e+"."+t):this[b][t]=n},get:function(){return this[b][t]}})}(r);for(r in n)"prototype"!==r&&n.hasOwnProperty(r)&&(v[e][r]=n[r])}}function f(e,t){try{return Function("f","return function "+e+"(){return f(this, arguments)}")(t)}catch(n){return function(){return t(this,arguments)}}}function d(e,t,n){for(var r=e;r&&!r.hasOwnProperty(t);)r=Object.getPrototypeOf(r);!r&&e[t]&&(r=e);var o,a=exports.zoneSymbol(t);return r&&!(o=r[a])&&(o=r[a]=r[t],r[t]=f(t,n(o,a,t))),o}exports.zoneSymbol=Zone.__symbol__;var v="undefined"==typeof window?e:window;exports.bindArguments=t,exports.patchPrototype=n,exports.isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,exports.isNode="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),exports.isBrowser=!exports.isNode&&!exports.isWebWorker&&!("undefined"==typeof window||!window.HTMLElement),exports.patchProperty=r,exports.patchOnProperties=o;var y=exports.zoneSymbol("eventTasks"),g="addEventListener",k="removeEventListener",m=exports.zoneSymbol(g),T=exports.zoneSymbol(k);exports.patchEventTargetMethods=p;var b=exports.zoneSymbol("originalInstance");exports.patchClass=h,exports.createNamedFn=f,exports.patchMethod=d}).call(exports,function(){return this}())},function(e,exports,t){"use strict";function n(){Object.defineProperty=function(e,t,n){if(o(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);var r=n.configurable;return"prototype"!==t&&(n=a(e,t,n)),i(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]=a(e,n,t[n])}),l(e,t)},Object.getOwnPropertyDescriptor=function(e,t){var n=u(e,t);return o(e,t)&&(n.configurable=!1),n}}function r(e,t,n){var r=n.configurable;return n=a(e,t,n),i(e,t,n,r)}function o(e,t){return e&&e[p]&&e[p][t]}function a(e,t,n){return n.configurable=!0,n.configurable||(e[p]||c(e,p,{writable:!0,value:{}}),e[p][t]=!0),n}function i(e,t,n,r){try{return c(e,t,n)}catch(o){if(n.configurable)return"undefined"==typeof r?delete n.configurable:n.configurable=r,c(e,t,n);throw o}}var s=t(3),c=Object.defineProperty,u=Object.getOwnPropertyDescriptor,l=Object.create,p=s.zoneSymbol("unconfigurables");exports.propertyPatch=n,exports._redefineProperty=r},function(e,exports,t){"use strict";function n(e){if(o.isBrowser&&"registerElement"in e.document){var t=document.registerElement,n=["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"];document.registerElement=function(e,o){return o&&o.prototype&&n.forEach(function(e){var t="Document.registerElement::"+e;if(o.prototype.hasOwnProperty(e)){var n=Object.getOwnPropertyDescriptor(o.prototype,e);n&&n.value?(n.value=Zone.current.wrap(n.value,t),r._redefineProperty(o.prototype,e,n)):o.prototype[e]=Zone.current.wrap(o.prototype[e],t)}else o.prototype[e]&&(o.prototype[e]=Zone.current.wrap(o.prototype[e],t))}),t.apply(document,[e,o])}}}var r=t(4),o=t(3);exports.registerElementPatch=n},function(e,exports,t){"use strict";function n(e){if(!i.isNode){var t="undefined"!=typeof WebSocket;r()?(i.isBrowser&&i.patchOnProperties(HTMLElement.prototype,s),i.patchOnProperties(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(i.patchOnProperties(IDBIndex.prototype,null),i.patchOnProperties(IDBRequest.prototype,null),i.patchOnProperties(IDBOpenDBRequest.prototype,null),i.patchOnProperties(IDBDatabase.prototype,null),i.patchOnProperties(IDBTransaction.prototype,null),i.patchOnProperties(IDBCursor.prototype,null)),t&&i.patchOnProperties(WebSocket.prototype,null)):(o(),i.patchClass("XMLHttpRequest"),t&&a.apply(e))}}function r(){if(i.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 o(){for(var e=function(e){var t=s[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][c]&&(t=Zone.current.wrap(o[n],r),t[c]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t<s.length;t++)e(t)}var a=t(7),i=t(3),s="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(" ");exports.propertyDescriptorPatch=n;var c=i.zoneSymbol("unbound")},function(e,exports,t){"use strict";function n(e){var t=e.WebSocket;e.EventTarget||r.patchEventTargetMethods(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.patchOnProperties(o,["close","error","message","open"]),o};for(var n in t)e.WebSocket[n]=t[n]}var r=t(3);exports.apply=n},function(e,exports,t){"use strict";function n(e,t,n,o){function a(t){var n=t.data;return n.args[0]=t.invoke,n.handleId=s.apply(e,n.args),t}function i(e){return c(e.data.handleId)}var s=null,c=null;t+=o,n+=o,s=r.patchMethod(e,t,function(n){return function(r,s){if("function"==typeof s[0]){var c=Zone.current,u={handleId:null,isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:null,args:s},l=c.scheduleMacroTask(t,s[0],u,a,i);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)}}),c=r.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)}})}var r=t(3);exports.patchTimer=n}]); | ||
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 scheduleEventListener(e){var t=e.data;return attachRegisteredEvent(t.target,e),t.target[SYMBOL_ADD_EVENT_LISTENER](t.eventName,e.invoke,t.useCapturing)}function cancelEventListener(e){var t=e.data;findExistingRegisteredTask(t.target,e.invoke,t.eventName,t.useCapturing,!0),t.target[SYMBOL_REMOVE_EVENT_LISTENER](t.eventName,e.invoke,t.useCapturing)}function zoneAwareAddEventListener(e,t){var n=t[0],r=t[1],o=t[2]||!1,a=e||_global$1,i=null;"function"==typeof r?i=r:r&&r.handleEvent&&(i=function(e){return r.handleEvent(e)});var s=!1;try{s=r&&"[object FunctionWrapper]"===r.toString()}catch(c){return}if(!i||s)return a[SYMBOL_ADD_EVENT_LISTENER](n,r,o);var u=findExistingRegisteredTask(a,r,n,o,!1);if(u)return a[SYMBOL_ADD_EVENT_LISTENER](n,u.invoke,o);var l=Zone.current,p=a.constructor.name+".addEventListener:"+n,h={target:a,eventName:n,name:n,useCapturing:o,handler:r};l.scheduleEventTask(p,i,h,scheduleEventListener,cancelEventListener)}function zoneAwareRemoveEventListener(e,t){var n=t[0],r=t[1],o=t[2]||!1,a=e||_global$1,i=findExistingRegisteredTask(a,r,n,o,!0);i?i.zone.cancelTask(i):a[SYMBOL_REMOVE_EVENT_LISTENER](n,r,o)}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==E.length&&(e[_]?e[_].resolve(0)[k](a):e[v](a,0))}function r(e){n(),E.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(!m){for(m=!0;E.length;){var e=E;E=[];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();m=!1}}function i(e){return e&&e.then}function s(e){return e}function c(e){return L.reject(e)}function u(e,t){return function(n){l(e,t,n)}}function l(e,t,r){if(e[D]===I)if(r instanceof L&&r[D]!==I)p(r),l(e,r[D],r[P]);else if(i(r))r.then(u(e,t),u(e,!1));else{e[D]=t;var o=e[P];e[P]=r;for(var a=0;a<o.length;)h(e,o[a++],o[a++],o[a++],o[a++]);if(0==o.length&&t==M){e[D]=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[D]===z){e[D]=M;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[D]?r||s:o||c;t.scheduleMicroTask(O,function(){try{l(n,!0,t.run(a,null,[e[P]]))}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 L(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!==L)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 T},enumerable:!0,configurable:!0}),Object.defineProperty(n,"currentTask",{get:function(){return b},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=T;T=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{T=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=T;T=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{T=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=b;b=e;var o=T;T=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{T=o,b=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"),_=t("Promise"),k=t("then"),T=new d(null,null),b=null,E=[],m=!1,w=[],S=0,D=t("state"),P=t("value"),O="Promise.then",I=null,R=!0,M=!1,z=0,L=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[D]=I,n[P]=[];try{t&&t(u(n,R),u(n,M))}catch(r){l(n,!1,r)}}return e.resolve=function(e){return l(new this(null),R,e)},e.reject=function(e){return l(new this(null),M,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[D]==I?this[P].push(r,n,e,t):h(this,r,n,e,t),n},e.prototype["catch"]=function(e){return this.then(null,e)},e}(),N=e[t("Promise")]=e.Promise;if(e.Promise=L,N&&(f(N),"undefined"!=typeof e.fetch)){var Z=e.fetch();Z.then(function(){return null},function(){return null}),Z.constructor!=N&&f(Z.constructor)}return Promise[d.__symbol__("uncaughtPromiseErrors")]=w,e.Zone=d}("undefined"==typeof window?global:window),zoneSymbol=Zone.__symbol__,_global$1="undefined"==typeof window?global:window,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",SYMBOL_ADD_EVENT_LISTENER=zoneSymbol(ADD_EVENT_LISTENER),SYMBOL_REMOVE_EVENT_LISTENER=zoneSymbol(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="undefined"==typeof window?global:window;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"]); |
@@ -42,2 +42,3 @@ import '../zone'; | ||
const XHR_TASK = zoneSymbol('xhrTask'); | ||
const XHR_SYNC = zoneSymbol('xhrSync'); | ||
@@ -69,3 +70,3 @@ interface XHROptions extends TaskData { | ||
} | ||
setNative.apply(data.target, data.args); | ||
sendNative.apply(data.target, data.args); | ||
return task; | ||
@@ -82,19 +83,28 @@ } | ||
data.aborted = true; | ||
return clearNative.apply(data.target, data.args); | ||
return abortNative.apply(data.target, data.args); | ||
} | ||
var setNative = patchMethod(window.XMLHttpRequest.prototype, 'send', () => function(self: any, args: any[]) { | ||
var openNative = patchMethod(window.XMLHttpRequest.prototype, 'open', () => function(self: any, args: any[]) { | ||
self[XHR_SYNC] = args[2] == false; | ||
return openNative.apply(self, args); | ||
}); | ||
var sendNative = patchMethod(window.XMLHttpRequest.prototype, 'send', () => function(self: any, args: any[]) { | ||
var zone = Zone.current; | ||
var options: XHROptions = { | ||
target: self, | ||
isPeriodic: false, | ||
delay: null, | ||
args: args, | ||
aborted: false | ||
}; | ||
return zone.scheduleMacroTask('XMLHttpRequest.send', placeholderCallback, options, scheduleTask, clearTask); | ||
if (self[XHR_SYNC]) { | ||
// if the XHR is sync there is no task to schedule, just execute the code. | ||
return sendNative.apply(self, args); | ||
} else { | ||
var options: XHROptions = { | ||
target: self, | ||
isPeriodic: false, | ||
delay: null, | ||
args: args, | ||
aborted: false | ||
}; | ||
return zone.scheduleMacroTask('XMLHttpRequest.send', placeholderCallback, options, scheduleTask, clearTask); | ||
} | ||
}); | ||
var clearNative = patchMethod(window.XMLHttpRequest.prototype, 'abort', (delegate: Function) => function(self: any, args: any[]) { | ||
var abortNative = patchMethod(window.XMLHttpRequest.prototype, 'abort', (delegate: Function) => function(self: any, args: any[]) { | ||
var task: Task = findPendingTask(self); | ||
@@ -101,0 +111,0 @@ if (task && typeof task.type == 'string') { |
@@ -7,4 +7,4 @@ import {zoneSymbol} from "../common/utils"; | ||
const _defineProperty = Object.defineProperty; | ||
const _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
const _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty; | ||
const _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; | ||
const _create = Object.create; | ||
@@ -32,3 +32,3 @@ const unconfigurablesKey = zoneSymbol('unconfigurables'); | ||
Object.create = function (obj, proto) { | ||
Object.create = <any>function (obj, proto) { | ||
if (typeof proto === 'object' && !Object.isFrozen(proto)) { | ||
@@ -84,3 +84,9 @@ Object.keys(proto).forEach(function (prop) { | ||
} | ||
return _defineProperty(obj, prop, desc); | ||
try { | ||
return _defineProperty(obj, prop, desc); | ||
} catch (e) { | ||
var descJson: string = null; | ||
try { descJson = JSON.stringify(desc); } catch (e) { descJson = descJson.toString(); } | ||
console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${obj}' and got error, giving up: ${e}`); | ||
} | ||
} else { | ||
@@ -87,0 +93,0 @@ throw e; |
@@ -42,4 +42,5 @@ 'use strict'; | ||
let originalJasmineFn: Function = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function(description: string, specDefinitions: Function) { | ||
return originalJasmineFn.call(this, description, wrapTestInZone(specDefinitions)); | ||
jasmineEnv[methodName] = function(description: string, specDefinitions: Function, timeout: number) { | ||
arguments[1] = wrapTestInZone(specDefinitions); | ||
return originalJasmineFn.apply(this, arguments); | ||
} | ||
@@ -49,4 +50,5 @@ }); | ||
let originalJasmineFn: Function = jasmineEnv[methodName]; | ||
jasmineEnv[methodName] = function(specDefinitions: Function) { | ||
return originalJasmineFn.call(this, wrapTestInZone(specDefinitions)); | ||
jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { | ||
arguments[0] = wrapTestInZone(specDefinitions); | ||
return originalJasmineFn.apply(this, arguments); | ||
} | ||
@@ -53,0 +55,0 @@ }); |
@@ -43,3 +43,3 @@ import '../zone'; | ||
let nativePbkdf2 = crypto.pbkdf2; | ||
crypto.pbkdf2 = function pbkdf2Zone(...args) { | ||
crypto.pbkdf2 = function pbkdf2Zone(...args: any[]) { | ||
let fn = args[args.length - 1]; | ||
@@ -46,0 +46,0 @@ if (typeof fn === 'function') { |
@@ -90,17 +90,30 @@ 'use strict'; | ||
if (error instanceof Error && parentTask) { | ||
let descriptor = Object.getOwnPropertyDescriptor(error, 'stack'); | ||
if (descriptor) { | ||
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); | ||
} else { | ||
error.stack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], | ||
error.stack); | ||
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 { | ||
stackSetSucceded = error.stack = longStack; | ||
} catch (e) { } | ||
} | ||
if (!stackSetSucceded) { | ||
try { | ||
stackSetSucceded = (error as any).longStack = longStack; | ||
} catch (e) { } | ||
} | ||
} | ||
@@ -107,0 +120,0 @@ return parentZoneDelegate.handleError(targetZone, error); |
@@ -235,2 +235,7 @@ /** | ||
currentTask: Task; | ||
/** | ||
* Verify that Zone has been correctly patched. Specifically that Promise is zone aware. | ||
*/ | ||
assertZonePatched(); | ||
} | ||
@@ -512,3 +517,13 @@ | ||
static assertZonePatched() { | ||
if (global.Promise !== ZoneAwarePromise) { | ||
throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` " + | ||
"has been overwritten.\n" + | ||
"Most 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.)"); | ||
} | ||
} | ||
static get current(): AmbientZone { return _currentZone; }; | ||
@@ -1040,3 +1055,3 @@ static get currentTask(): Task { return _currentTask; }; | ||
static race<R>(values: Thenable<any>[]): Promise<R> { | ||
static race<R>(values: PromiseLike<any>[]): Promise<R> { | ||
let resolve: (v: any) => void; | ||
@@ -1063,4 +1078,2 @@ let reject: (v: any) => void; | ||
const resolvedValues = []; | ||
function onReject(error) { promise && reject(error); promise = null; } | ||
for(let value of values) { | ||
@@ -1073,7 +1086,6 @@ if (!isThenable(value)) { | ||
count--; | ||
if (promise && !count) { | ||
if (!count) { | ||
resolve(resolvedValues); | ||
} | ||
promise == null; | ||
})(count), onReject); | ||
})(count), reject); | ||
count++; | ||
@@ -1085,3 +1097,3 @@ } | ||
constructor(executor: (resolve : (value?: R | Thenable<R>) => void, | ||
constructor(executor: (resolve : (value?: R | PromiseLike<R>) => void, | ||
reject: (error?: any) => void) => void) { | ||
@@ -1101,4 +1113,4 @@ const promise: ZoneAwarePromise<R> = this; | ||
then<R, U>(onFulfilled?: (value: R) => U | Thenable<U>, | ||
onRejected?: (error: any) => U | Thenable<U>): Promise<R> | ||
then<R, U>(onFulfilled?: (value: R) => U | PromiseLike<U>, | ||
onRejected?: (error: any) => U | PromiseLike<U>): Promise<R> | ||
{ | ||
@@ -1115,3 +1127,3 @@ const chainPromise: Promise<R> = new (this.constructor as typeof ZoneAwarePromise)(null); | ||
catch<U>(onRejected?: (error: any) => U | Thenable<U>): Promise<R> { | ||
catch<U>(onRejected?: (error: any) => U | PromiseLike<U>): Promise<R> { | ||
return this.then(null, onRejected); | ||
@@ -1123,3 +1135,3 @@ } | ||
global.Promise = ZoneAwarePromise; | ||
if (NativePromise) { | ||
function patchThen(NativePromise) { | ||
const NativePromiseProtototype = NativePromise.prototype; | ||
@@ -1133,2 +1145,14 @@ const NativePromiseThen = NativePromiseProtototype[__symbol__('then')] | ||
}).then(onResolve, onReject); | ||
}; | ||
} | ||
if (NativePromise) { | ||
patchThen(NativePromise); | ||
if (typeof global['fetch'] !== 'undefined') { | ||
const fetchPromise = global['fetch'](); | ||
// ignore output to prevent error; | ||
fetchPromise.then(() => null, () => null); | ||
if (fetchPromise.constructor != NativePromise) { | ||
patchThen(fetchPromise.constructor); | ||
} | ||
} | ||
@@ -1135,0 +1159,0 @@ } |
{ | ||
"name": "zone.js", | ||
"version": "0.6.17", | ||
"version": "0.6.18", | ||
"description": "Zones for JavaScript", | ||
@@ -17,8 +17,7 @@ "main": "dist/zone-node.js", | ||
"scripts": { | ||
"prepublish": "./node_modules/.bin/typings install && ./node_modules/.bin/tsc && gulp build", | ||
"typings": "./node_modules/.bin/typings install", | ||
"prepublish": "./node_modules/.bin/tsc && gulp build", | ||
"ws-server": "node ./test/ws-server.js", | ||
"tsc": "./node_modules/.bin/tsc", | ||
"tsc:w": "./node_modules/.bin/tsc -w", | ||
"test": "karma start karma.conf.js", | ||
"test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma.conf.js\"", | ||
"test-node": "./node_modules/.bin/gulp test/node", | ||
@@ -38,5 +37,10 @@ "serve": "python -m SimpleHTTPServer 8000" | ||
"devDependencies": { | ||
"@types/jasmine": "^2.2.33", | ||
"@types/node": "^6.0.38", | ||
"@types/systemjs": "^0.19.30", | ||
"concurrently": "^2.2.0", | ||
"es6-promise": "^3.0.2", | ||
"gulp": "^3.8.11", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-rollup": "^2.3.0", | ||
"gulp-tsc": "^1.1.4", | ||
@@ -56,7 +60,7 @@ "gulp-uglify": "^1.2.0", | ||
"nodejs-websocket": "^1.2.0", | ||
"pump": "^1.0.1", | ||
"systemjs": "^0.19.37", | ||
"ts-loader": "^0.6.0", | ||
"typescript": "^1.8.0", | ||
"typings": "^0.7.12", | ||
"webpack": "^1.12.2" | ||
"typescript": "^2.0.2" | ||
} | ||
} |
@@ -7,4 +7,4 @@ # Zone.js | ||
> If you're using zone.js via npmcdn please provide a query param `?main=browser` | ||
`https://npmcdn.com/zone.js?main=browser` | ||
> If you're using zone.js via unpkg please provide a query param `?main=browser` | ||
`https://unpkg.com/zone.js?main=browser` | ||
@@ -11,0 +11,0 @@ # NEW Zone.js POST-v0.6.0 |
Sorry, the diff of this file is too big to display
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
293978
26
5948
1