Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zone.js

Package Overview
Dependencies
Maintainers
2
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zone.js - npm Package Compare versions

Comparing version 0.6.25 to 0.6.26

7

dist/async-test.js

@@ -14,2 +14,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var AsyncTestZoneSpec = (function () {

@@ -16,0 +23,0 @@ function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) {

25

dist/fake-async-test.js

@@ -14,2 +14,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
(function (global) {

@@ -31,9 +38,3 @@ var Scheduler = (function () {

// Insert so that scheduler queue remains sorted by end time.
var newEntry = {
endTime: endTime,
id: currentId,
func: cb,
args: args,
delay: delay
};
var newEntry = { endTime: endTime, id: currentId, func: cb, args: args, delay: delay };
var i = 0;

@@ -59,6 +60,6 @@ for (; i < this._schedulerQueue.length; i++) {

if (millis === void 0) { millis = 0; }
this._currentTime += millis;
var finalTime = this._currentTime + millis;
while (this._schedulerQueue.length > 0) {
var current = this._schedulerQueue[0];
if (this._currentTime < current.endTime) {
if (finalTime < current.endTime) {
// Done processing the queue since it's sorted by endTime.

@@ -70,2 +71,3 @@ break;

var current_1 = this._schedulerQueue.shift();
this._currentTime = current_1.endTime;
var retval = current_1.func.apply(global, current_1.args);

@@ -78,2 +80,3 @@ if (!retval) {

}
this._currentTime = finalTime;
};

@@ -118,3 +121,3 @@ return Scheduler;

}
// Return true if there were no errors, false otherwise.
// Return true if there were no errors, false otherwise.
return _this._lastError === null;

@@ -170,3 +173,3 @@ };

var cb = this._fnAndFlush(fn, completers);
// Use the callback created above to requeue on success.
// Use the callback created above to requeue on success.
completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id);

@@ -173,0 +176,0 @@ // Queue the callback and dequeue the periodic timer only on error.

@@ -14,16 +14,27 @@ /**

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 __());
};
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
(function () {
var __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 __());
};
// 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");
throw new Error('Missing: zone.js');
if (typeof jasmine == 'undefined')
throw new Error("Missing: jasmine.js");
throw new Error('Missing: jasmine.js');
if (jasmine['__zone_patch__'])
throw new Error("'jasmine' has already been patched with 'Zone'.");
throw new Error('\'jasmine\' has already been patched with \'Zone\'.');
jasmine['__zone_patch__'] = true;

@@ -33,8 +44,8 @@ var SyncTestZoneSpec = Zone['SyncTestZoneSpec'];

if (!SyncTestZoneSpec)
throw new Error("Missing: SyncTestZoneSpec");
throw new Error('Missing: SyncTestZoneSpec');
if (!ProxyZoneSpec)
throw new Error("Missing: 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
// 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`.

@@ -44,8 +55,8 @@ var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe'));

// It will be a proxy zone, so that the tests function can retroactively install
// different zones.
// 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
// - 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
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add
// fakeAsync behavior to the childZone.

@@ -93,5 +104,7 @@ var testProxyZone = null;

// 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]); };
return (testBody.length == 0) ? function () {
return testProxyZone.run(testBody, this);
} : function (done) {
return testProxyZone.run(testBody, this, [done]);
};
}

@@ -112,3 +125,3 @@ var QueueRunner = jasmine.QueueRunner;

if (Zone.current !== ambientZone)
throw new Error("Unexpected Zone: " + Zone.current.name);
throw new Error('Unexpected Zone: ' + Zone.current.name);
testProxyZone = ambientZone.fork(new ProxyZoneSpec());

@@ -121,3 +134,3 @@ if (!Zone.currentTask) {

// 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); });
Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); });
}

@@ -124,0 +137,0 @@ else {

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";var e=function(e,n){function r(){this.constructor=e}for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)};!function(){function n(e){return function(){return c.run(e,this,arguments)}}function r(e){return 0==e.length?function(){return u.run(e,this)}:function(n){return u.run(e,this,[n])}}if(!Zone)throw new Error("Missing: zone.js");if("undefined"==typeof jasmine)throw new Error("Missing: jasmine.js");if(jasmine.__zone_patch__)throw new Error("'jasmine' has already been patched with 'Zone'.");jasmine.__zone_patch__=!0;var t=Zone.SyncTestZoneSpec,o=Zone.ProxyZoneSpec;if(!t)throw new Error("Missing: SyncTestZoneSpec");if(!o)throw new Error("Missing: ProxyZoneSpec");var i=Zone.current,c=i.fork(new t("jasmine.describe")),u=null,s=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(e){var r=s[e];s[e]=function(e,t){return r.call(this,e,n(t))}}),["it","xit","fit"].forEach(function(e){var n=s[e];s[e]=function(e,t,o){return arguments[1]=r(t),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=s[e];s[e]=function(e,t){return arguments[0]=r(e),n.apply(this,arguments)}});var f=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(e){e.onComplete=function(e){return function(){u=null,i.scheduleMicroTask("jasmine.onComplete",e)}}(e.onComplete),n.call(this,e)}return e(r,n),r.prototype.execute=function(){var e=this;if(Zone.current!==i)throw new Error("Unexpected Zone: "+Zone.current.name);u=i.fork(new o),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return n.prototype.execute.call(e)})},r}(f)}()});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return c.run(e,this,arguments)}}function n(e){return 0==e.length?function(){return u.run(e,this)}:function(n){return u.run(e,this,[n])}}var r=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)};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 r=s[e];s[e]=function(e,t,o){return arguments[1]=n(t),r.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var r=s[e];s[e]=function(e,t){return arguments[0]=n(e),r.apply(this,arguments)}});var f=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){n.onComplete=function(e){return function(){u=null,i.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete),e.call(this,n)}return r(n,e),n.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 f.prototype.execute.call(n)})},n}(f)}()});

@@ -14,2 +14,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var NEWLINE = '\n';

@@ -41,5 +48,5 @@ var SEP = ' ------------- ';

var coughtError = getStacktraceWithCaughtError();
var getStacktrace = error.stack
? getStacktraceWithUncaughtError
: (coughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError);
var getStacktrace = error.stack ?
getStacktraceWithUncaughtError :
(coughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError);
function getFrames(error) {

@@ -105,4 +112,7 @@ return error.stack ? error.stack.split(NEWLINE) : [];

}
catch (e) { }
var longStack = stackSetSucceded ? null : renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
catch (e) {
}
var longStack = stackSetSucceded ?
null :
renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
if (!stackSetSucceded) {

@@ -112,3 +122,4 @@ try {

}
catch (e) { }
catch (e) {
}
}

@@ -119,3 +130,4 @@ if (!stackSetSucceded) {

}
catch (e) { }
catch (e) {
}
}

@@ -122,0 +134,0 @@ }

@@ -14,2 +14,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var ProxyZoneSpec = (function () {

@@ -16,0 +23,0 @@ function ProxyZoneSpec(defaultSpecDelegate) {

@@ -14,2 +14,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var SyncTestZoneSpec = (function () {

@@ -16,0 +23,0 @@ function SyncTestZoneSpec(namePrefix) {

@@ -15,2 +15,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* A `TaskTrackingZoneSpec` allows one to track all outstanding Tasks.

@@ -34,5 +41,8 @@ *

switch (type) {
case 'microTask': return this.microTasks;
case 'macroTask': return this.macroTasks;
case 'eventTask': return this.eventTasks;
case 'microTask':
return this.microTasks;
case 'macroTask':
return this.macroTasks;
case 'eventTask':
return this.eventTasks;
}

@@ -39,0 +49,0 @@ throw new Error('Unknown task format: ' + type);

@@ -14,2 +14,9 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
(function (global) {

@@ -44,4 +51,4 @@

if (!scope) {
scope = WtfZoneSpec.invokeScope[source]
= wtfEvents.createScope("Zone:invoke:" + source + "(ascii zone)");
scope = WtfZoneSpec.invokeScope[source] =
wtfEvents.createScope("Zone:invoke:" + source + "(ascii zone)");
}

@@ -57,4 +64,4 @@ return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source));

if (!instance) {
instance = WtfZoneSpec.scheduleInstance[key]
= wtfEvents.createInstance("Zone:schedule:" + key + "(ascii zone, any data)");
instance = WtfZoneSpec.scheduleInstance[key] =
wtfEvents.createInstance("Zone:schedule:" + key + "(ascii zone, any data)");
}

@@ -69,4 +76,4 @@ var retValue = parentZoneDelegate.scheduleTask(targetZone, task);

if (!scope) {
scope = WtfZoneSpec.invokeTaskScope[source]
= wtfEvents.createScope("Zone:invokeTask:" + source + "(ascii zone)");
scope = WtfZoneSpec.invokeTaskScope[source] =
wtfEvents.createScope("Zone:invokeTask:" + source + "(ascii zone)");
}

@@ -79,4 +86,4 @@ return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs));

if (!instance) {
instance = WtfZoneSpec.cancelInstance[key]
= wtfEvents.createInstance("Zone:cancel:" + key + "(ascii zone, any options)");
instance = WtfZoneSpec.cancelInstance[key] =
wtfEvents.createInstance("Zone:cancel:" + key + "(ascii zone, any options)");
}

@@ -83,0 +90,0 @@ var retValue = parentZoneDelegate.cancelTask(targetZone, task);

@@ -14,2 +14,11 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var Zone$1 = (function (global) {

@@ -25,15 +34,18 @@ if (global.Zone) {

this._properties = zoneSpec && zoneSpec.properties || {};
this._zoneDelegate = new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
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.)");
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; },
get: function () {
return _currentZone;
},
enumerable: true,

@@ -44,3 +56,5 @@ configurable: true

Object.defineProperty(Zone, "currentTask", {
get: function () { return _currentTask; },
get: function () {
return _currentTask;
},
enumerable: true,

@@ -51,3 +65,5 @@ configurable: true

Object.defineProperty(Zone.prototype, "parent", {
get: function () { return this._parent; },
get: function () {
return this._parent;
},
enumerable: true,

@@ -58,3 +74,5 @@ configurable: true

Object.defineProperty(Zone.prototype, "name", {
get: function () { return this._name; },
get: function () {
return this._name;
},
enumerable: true,

@@ -130,4 +148,4 @@ configurable: true

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 + ')');
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;

@@ -181,36 +199,47 @@ _currentTask = task;

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._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._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);
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);
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;
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);
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;
return this._handleErrorZS ?
this._handleErrorZS.onHandleError(this._handleErrorDlgt, this.zone, targetZone, error) :
true;
};

@@ -241,8 +270,9 @@ ZoneDelegate.prototype.scheduleTask = function (targetZone, task) {

try {
return this._invokeTaskZS
? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this.zone, targetZone, task, applyThis, applyArgs)
: task.callback.apply(applyThis, applyArgs);
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)) {
if (targetZone == this.zone && (task.type != 'eventTask') &&
!(task.data && task.data.isPeriodic)) {
this._updateTaskCount(task.type, -1);

@@ -270,3 +300,4 @@ }

ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) {
return this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty);
return this._hasTaskZS &&
this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty);
};

@@ -328,3 +359,3 @@ ZoneDelegate.prototype._updateTaskCount = function (type, count) {

else {
return this.toString();
return Object.prototype.toString.call(this);
}

@@ -334,3 +365,5 @@ };

}());
function __symbol__(name) { return '__zone_symbol__' + name; }
function __symbol__(name) {
return '__zone_symbol__' + name;
}

@@ -390,3 +423,5 @@ var symbolSetTimeout = __symbol__('setTimeout');

try {
uncaughtPromiseError.zone.runGuarded(function () { throw uncaughtPromiseError; });
uncaughtPromiseError.zone.runGuarded(function () {
throw uncaughtPromiseError;
});
}

@@ -407,4 +442,8 @@ catch (e) {

}
function forwardResolution(value) { return value; }
function forwardRejection(rejection) { return ZoneAwarePromise.reject(rejection); }
function forwardResolution(value) {
return value;
}
function forwardRejection(rejection) {
return ZoneAwarePromise.reject(rejection);
}
var symbolState = __symbol__('state');

@@ -442,3 +481,4 @@ var symbolValue = __symbol__('value');

try {
throw new Error("Uncaught (in promise): " + value);
throw new Error('Uncaught (in promise): ' + value +
(value && value.stack ? '\n' + value.stack : ''));
}

@@ -507,5 +547,12 @@ catch (e) {

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)); }
var promise = new this(function (res, rej) {
_a = [res, rej], resolve = _a[0], reject = _a[1];
var _a;
});
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++) {

@@ -523,3 +570,6 @@ var value = values_1[_i];

var reject;
var promise = new this(function (res, rej) { resolve = res; reject = rej; });
var promise = new this(function (res, rej) {
resolve = res;
reject = rej;
});
var count = 0;

@@ -571,4 +621,4 @@ var resolvedValues = [];

var NativePromiseProtototype = NativePromise.prototype;
var NativePromiseThen = NativePromiseProtototype[__symbol__('then')]
= NativePromiseProtototype.then;
var NativePromiseThen = NativePromiseProtototype[__symbol__('then')] =
NativePromiseProtototype.then;
NativePromiseProtototype.then = function (onResolve, onReject) {

@@ -578,3 +628,4 @@ var nativePromise = this;

NativePromiseThen.call(nativePromise, resolve, reject);
}).then(onResolve, onReject);
})
.then(onResolve, onReject);
};

@@ -596,3 +647,4 @@ }

fetchPromise.then(function () { return null; }, function () { return null; });
if (fetchPromise.constructor != NativePromise) {
if (fetchPromise.constructor != NativePromise &&
fetchPromise.constructor != ZoneAwarePromise) {
patchThen(fetchPromise.constructor);

@@ -608,5 +660,7 @@ }

/**
* Suppress closure compiler errors about unknown 'process' variable
* @fileoverview
* @suppress {undefinedVars}
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

@@ -630,6 +684,3 @@ var zoneSymbol = Zone['__symbol__'];

function patchProperty(obj, prop) {
var desc = Object.getOwnPropertyDescriptor(obj, prop) || {
enumerable: true,
configurable: true
};
var desc = Object.getOwnPropertyDescriptor(obj, prop) || { enumerable: true, configurable: true };
// A property descriptor cannot have getter/setter and be writable

@@ -663,3 +714,4 @@ // deleting the writable and value properties avoids this error:

};
// The getter would return undefined for unassigned properties but the default value of an unassigned property is null
// The getter would return undefined for unassigned properties but the default value of an
// unassigned property is null
desc.get = function () {

@@ -683,5 +735,3 @@ return this[_prop] || null;

var data = eventTask.data;
if (data.handler === handler
&& data.useCapturing === capture
&& data.eventName === name) {
if (data.handler === handler && data.useCapturing === capture && data.eventName === name) {
if (remove) {

@@ -739,3 +789,3 @@ eventTasks.splice(i, 1);

// will fail tests prematurely.
validZoneHandler = handler && handler.toString() === "[object FunctionWrapper]";
validZoneHandler = handler && handler.toString() === '[object FunctionWrapper]';
}

@@ -746,3 +796,4 @@ catch (e) {

}
// Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150
// Ignore special listeners of IE11 & Edge dev tools, see
// https://github.com/angular/zone.js/issues/150
if (!delegate || validZoneHandler) {

@@ -796,2 +847,5 @@ return target[addFnSymbol](eventName, handler, useCapturing);

var target = self || _global$1;
if (!target[EVENT_TASKS]) {
return [];
}
return target[EVENT_TASKS]

@@ -822,3 +876,3 @@ .filter(function (task) { return task.data.eventName === eventName; })

var proto = target;
while (proto && !proto.hasOwnProperty(name)) {
while (proto && Object.getOwnPropertyNames(proto).indexOf(name) === -1) {
proto = Object.getPrototypeOf(proto);

@@ -839,57 +893,9 @@ }

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);
}
}; });
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// For EventEmitter

@@ -923,3 +929,4 @@ var EE_ADD_LISTENER = 'addListener';

}
catch (err) { }
catch (err) {
}
if (events && events.EventEmitter) {

@@ -929,2 +936,9 @@ patchEventEmitterMethods(events.EventEmitter.prototype);

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var fs;

@@ -934,44 +948,14 @@ try {

}
catch (err) { }
catch (err) {
}
// TODO(alxhub): Patch `watch` and `unwatchFile`.
var TO_PATCH = [
'access',
'appendFile',
'chmod',
'chown',
'close',
'exists',
'fchmod',
'fchown',
'fdatasync',
'fstat',
'fsync',
'ftruncate',
'futimes',
'lchmod',
'lchown',
'link',
'lstat',
'mkdir',
'mkdtemp',
'open',
'read',
'readdir',
'readFile',
'readlink',
'realpath',
'rename',
'rmdir',
'stat',
'symlink',
'truncate',
'unlink',
'utimes',
'write',
'writeFile',
'access', 'appendFile', 'chmod', 'chown', 'close', 'exists', 'fchmod',
'fchown', 'fdatasync', 'fstat', 'fsync', 'ftruncate', 'futimes', 'lchmod',
'lchown', 'link', 'lstat', 'mkdir', 'mkdtemp', 'open', 'read',
'readdir', 'readFile', 'readlink', 'realpath', 'rename', 'rmdir', 'stat',
'symlink', 'truncate', 'unlink', 'utimes', 'write', 'writeFile',
];
if (fs) {
TO_PATCH
.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; })
.forEach(function (name) {
TO_PATCH.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }).forEach(function (name) {
fs[name] = (function (delegate) {

@@ -985,2 +969,79 @@ return function () {

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function patchTimer(window, setName, cancelName, nameSuffix) {
var setNative = null;
var clearNative = null;
setName += nameSuffix;
cancelName += nameSuffix;
var tasksByHandleId = {};
function scheduleTask(task) {
var data = task.data;
data.args[0] = function () {
task.invoke.apply(this, arguments);
delete tasksByHandleId[data.handleId];
};
data.handleId = setNative.apply(window, data.args);
tasksByHandleId[data.handleId] = task;
return task;
}
function clearTask(task) {
delete tasksByHandleId[task.data.handleId];
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 = typeof args[0] === 'number' ? tasksByHandleId[args[0]] : 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);
}
}; });
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var set = 'set';

@@ -1005,3 +1066,4 @@ var clear = 'clear';

}
catch (err) { }
catch (err) {
}
// TODO(gdi2290): implement a better way to patch these methods

@@ -1043,3 +1105,4 @@ if (crypto) {

}
catch (err) { }
catch (err) {
}
if (httpClient && httpClient.ClientRequest) {

@@ -1046,0 +1109,0 @@ var ClientRequest_1 = httpClient.ClientRequest.bind(httpClient);

@@ -14,2 +14,11 @@ /**

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var Zone$1 = (function (global) {

@@ -25,15 +34,18 @@ if (global.Zone) {

this._properties = zoneSpec && zoneSpec.properties || {};
this._zoneDelegate = new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
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.)");
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; },
get: function () {
return _currentZone;
},
enumerable: true,

@@ -44,3 +56,5 @@ configurable: true

Object.defineProperty(Zone, "currentTask", {
get: function () { return _currentTask; },
get: function () {
return _currentTask;
},
enumerable: true,

@@ -51,3 +65,5 @@ configurable: true

Object.defineProperty(Zone.prototype, "parent", {
get: function () { return this._parent; },
get: function () {
return this._parent;
},
enumerable: true,

@@ -58,3 +74,5 @@ configurable: true

Object.defineProperty(Zone.prototype, "name", {
get: function () { return this._name; },
get: function () {
return this._name;
},
enumerable: true,

@@ -130,4 +148,4 @@ configurable: true

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 + ')');
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;

@@ -181,36 +199,47 @@ _currentTask = task;

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._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._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);
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);
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;
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);
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;
return this._handleErrorZS ?
this._handleErrorZS.onHandleError(this._handleErrorDlgt, this.zone, targetZone, error) :
true;
};

@@ -241,8 +270,9 @@ ZoneDelegate.prototype.scheduleTask = function (targetZone, task) {

try {
return this._invokeTaskZS
? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this.zone, targetZone, task, applyThis, applyArgs)
: task.callback.apply(applyThis, applyArgs);
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)) {
if (targetZone == this.zone && (task.type != 'eventTask') &&
!(task.data && task.data.isPeriodic)) {
this._updateTaskCount(task.type, -1);

@@ -270,3 +300,4 @@ }

ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) {
return this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty);
return this._hasTaskZS &&
this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty);
};

@@ -328,3 +359,3 @@ ZoneDelegate.prototype._updateTaskCount = function (type, count) {

else {
return this.toString();
return Object.prototype.toString.call(this);
}

@@ -334,3 +365,5 @@ };

}());
function __symbol__(name) { return '__zone_symbol__' + name; }
function __symbol__(name) {
return '__zone_symbol__' + name;
}

@@ -390,3 +423,5 @@ var symbolSetTimeout = __symbol__('setTimeout');

try {
uncaughtPromiseError.zone.runGuarded(function () { throw uncaughtPromiseError; });
uncaughtPromiseError.zone.runGuarded(function () {
throw uncaughtPromiseError;
});
}

@@ -407,4 +442,8 @@ catch (e) {

}
function forwardResolution(value) { return value; }
function forwardRejection(rejection) { return ZoneAwarePromise.reject(rejection); }
function forwardResolution(value) {
return value;
}
function forwardRejection(rejection) {
return ZoneAwarePromise.reject(rejection);
}
var symbolState = __symbol__('state');

@@ -442,3 +481,4 @@ var symbolValue = __symbol__('value');

try {
throw new Error("Uncaught (in promise): " + value);
throw new Error('Uncaught (in promise): ' + value +
(value && value.stack ? '\n' + value.stack : ''));
}

@@ -507,5 +547,12 @@ catch (e) {

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)); }
var promise = new this(function (res, rej) {
_a = [res, rej], resolve = _a[0], reject = _a[1];
var _a;
});
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++) {

@@ -523,3 +570,6 @@ var value = values_1[_i];

var reject;
var promise = new this(function (res, rej) { resolve = res; reject = rej; });
var promise = new this(function (res, rej) {
resolve = res;
reject = rej;
});
var count = 0;

@@ -571,4 +621,4 @@ var resolvedValues = [];

var NativePromiseProtototype = NativePromise.prototype;
var NativePromiseThen = NativePromiseProtototype[__symbol__('then')]
= NativePromiseProtototype.then;
var NativePromiseThen = NativePromiseProtototype[__symbol__('then')] =
NativePromiseProtototype.then;
NativePromiseProtototype.then = function (onResolve, onReject) {

@@ -578,3 +628,4 @@ var nativePromise = this;

NativePromiseThen.call(nativePromise, resolve, reject);
}).then(onResolve, onReject);
})
.then(onResolve, onReject);
};

@@ -596,3 +647,4 @@ }

fetchPromise.then(function () { return null; }, function () { return null; });
if (fetchPromise.constructor != NativePromise) {
if (fetchPromise.constructor != NativePromise &&
fetchPromise.constructor != ZoneAwarePromise) {
patchThen(fetchPromise.constructor);

@@ -608,5 +660,7 @@ }

/**
* Suppress closure compiler errors about unknown 'process' variable
* @fileoverview
* @suppress {undefinedVars}
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

@@ -646,6 +700,3 @@ var zoneSymbol = Zone['__symbol__'];

function patchProperty(obj, prop) {
var desc = Object.getOwnPropertyDescriptor(obj, prop) || {
enumerable: true,
configurable: true
};
var desc = Object.getOwnPropertyDescriptor(obj, prop) || { enumerable: true, configurable: true };
// A property descriptor cannot have getter/setter and be writable

@@ -679,3 +730,4 @@ // deleting the writable and value properties avoids this error:

};
// The getter would return undefined for unassigned properties but the default value of an unassigned property is null
// The getter would return undefined for unassigned properties but the default value of an
// unassigned property is null
desc.get = function () {

@@ -714,5 +766,3 @@ return this[_prop] || null;

var data = eventTask.data;
if (data.handler === handler
&& data.useCapturing === capture
&& data.eventName === name) {
if (data.handler === handler && data.useCapturing === capture && data.eventName === name) {
if (remove) {

@@ -770,3 +820,3 @@ eventTasks.splice(i, 1);

// will fail tests prematurely.
validZoneHandler = handler && handler.toString() === "[object FunctionWrapper]";
validZoneHandler = handler && handler.toString() === '[object FunctionWrapper]';
}

@@ -777,3 +827,4 @@ catch (e) {

}
// Ignore special listeners of IE11 & Edge dev tools, see https://github.com/angular/zone.js/issues/150
// Ignore special listeners of IE11 & Edge dev tools, see
// https://github.com/angular/zone.js/issues/150
if (!delegate || validZoneHandler) {

@@ -859,3 +910,4 @@ return target[addFnSymbol](eventName, handler, useCapturing);

break;
default: throw new Error('Arg list too long.');
default:
throw new Error('Arg list too long.');
}

@@ -912,3 +964,3 @@ };

var proto = target;
while (proto && !proto.hasOwnProperty(name)) {
while (proto && Object.getOwnPropertyNames(proto).indexOf(name) === -1) {
proto = Object.getPrototypeOf(proto);

@@ -929,26 +981,79 @@ }

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);
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function patchTimer(window, setName, cancelName, nameSuffix) {
var setNative = null;
var clearNative = null;
setName += nameSuffix;
cancelName += nameSuffix;
var tasksByHandleId = {};
function scheduleTask(task) {
var data = task.data;
data.args[0] = function () {
task.invoke.apply(this, arguments);
delete tasksByHandleId[data.handleId];
};
data.handleId = setNative.apply(window, data.args);
tasksByHandleId[data.handleId] = task;
return task;
}
else if (_global[EVENT_TARGET]) {
apis.push(EVENT_TARGET);
function clearTask(task) {
delete tasksByHandleId[task.data.handleId];
return clearNative(task.data.handleId);
}
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);
}
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 = typeof args[0] === 'number' ? tasksByHandleId[args[0]] : 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);
}
}; });
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/*

@@ -959,3 +1064,4 @@ * This is necessary for Chrome and Chrome mobile, to enable

var _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty;
var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor;
var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] =
Object.getOwnPropertyDescriptor;
var _create = Object.create;

@@ -1022,3 +1128,4 @@ var unconfigurablesKey = zoneSymbol('unconfigurables');

if (desc.configurable) {
// In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's retry with the original flag value
// 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') {

@@ -1050,36 +1157,41 @@ delete desc.configurable;

function registerElementPatch(_global) {
if (!isBrowser || !('registerElement' in _global.document)) {
return;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
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);
}
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]);
};
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);
}
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// we have to patch the instance since the proto is non-configurable

@@ -1118,3 +1230,11 @@ function apply(_global) {

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(' ');
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
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) {

@@ -1153,4 +1273,4 @@ if (isNode) {

function canPatchViaPropertyDescriptor() {
if (isBrowser && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick')
&& typeof Element !== 'undefined') {
if (isBrowser && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') &&
typeof Element !== 'undefined') {
// WebKit https://bugs.webkit.org/show_bug.cgi?id=134364

@@ -1181,3 +1301,3 @@ // IDL interface attributes are not configurable

var onproperty = 'on' + property;
document.addEventListener(property, function (event) {
self.addEventListener(property, function (event) {
var elt = event.target, bound, source;

@@ -1206,57 +1326,45 @@ if (elt) {

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;
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function registerElementPatch(_global) {
if (!isBrowser || !('registerElement' in _global.document)) {
return;
}
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;
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);
}
});
}
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);
}
}; });
return _registerElement.apply(document, [name, opts]);
};
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var set = 'set';

@@ -1312,4 +1420,3 @@ var clear = 'clear';

}
function placeholderCallback() {
}
function placeholderCallback() { }
function clearTask(task) {

@@ -1333,9 +1440,3 @@ var data = task.data;

else {
var options = {
target: self,
isPeriodic: false,
delay: null,
args: args,
aborted: false
};
var options = { target: self, isPeriodic: false, delay: null, args: args, aborted: false };
return zone.scheduleMacroTask('XMLHttpRequest.send', placeholderCallback, options, scheduleTask, clearTask);

@@ -1353,3 +1454,4 @@ }

}
// Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no task to cancel. Do nothing.
// Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no task
// to cancel. Do nothing.
}; });

@@ -1359,8 +1461,5 @@ }

if (_global['navigator'] && _global['navigator'].geolocation) {
patchPrototype(_global['navigator'].geolocation, [
'getCurrentPosition',
'watchPosition'
]);
patchPrototype(_global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']);
}
})));

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";function e(e,t){for(var n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function t(t,n){for(var r=t.constructor.name,o=function(o){var a=n[o],i=t[a];i&&(t[a]=function(t){return function(){return t.apply(this,e(arguments,r+"."+a))}}(i))},a=0;a<n.length;a++)o(a)}function n(e,t){var n=Object.getOwnPropertyDescriptor(e,t)||{enumerable:!0,configurable:!0};delete n.writable,delete n.value;var r=t.substr(2),o="_"+t;n.set=function(e){if(this[o]&&this.removeEventListener(r,this[o]),"function"==typeof e){var t=function(t){var n;n=e.apply(this,arguments),void 0==n||n||t.preventDefault()};this[o]=t,this.addEventListener(r,t,!1)}else this[o]=null},n.get=function(){return this[o]||null},Object.defineProperty(e,t,n)}function r(e,t){var r=[];for(var o in e)"on"==o.substr(0,2)&&r.push(o);for(var a=0;a<r.length;a++)n(e,r[a]);if(t)for(var i=0;i<t.length;i++)n(e,"on"+t[i])}function o(e,t,n,r,o){var a=e[j];if(a)for(var i=0;i<a.length;i++){var s=a[i],u=s.data;if(u.handler===t&&u.useCapturing===r&&u.eventName===n)return o&&a.splice(i,1),s}return null}function a(e,t){var n=e[j];n||(n=e[j]=[]),n.push(t)}function i(e,t,n,r){function i(e){var t=e.data;return a(t.target,e),t.target[u](t.eventName,e.invoke,t.useCapturing)}function s(e){var t=e.data;o(t.target,e.invoke,t.eventName,t.useCapturing,!0),t.target[c](t.eventName,e.invoke,t.useCapturing)}void 0===n&&(n=!0),void 0===r&&(r=!1);var u=E(e),c=E(t),l=!n&&void 0;return function(t,n){var a=n[0],c=n[1],f=n[2]||l,p=t||S,h=null;"function"==typeof c?h=c:c&&c.handleEvent&&(h=function(e){return c.handleEvent(e)});var d=!1;try{d=c&&"[object FunctionWrapper]"===c.toString()}catch(v){return}if(!h||d)return p[u](a,c,f);if(!r){var g=o(p,c,a,f,!1);if(g)return p[u](a,g.invoke,f)}var y=Zone.current,k=p.constructor.name+"."+e+":"+a,b={target:p,eventName:a,name:a,useCapturing:f,handler:c};y.scheduleEventTask(k,h,b,i,s)}}function s(e,t){void 0===t&&(t=!0);var n=E(e),r=!t&&void 0;return function(e,t){var a=t[0],i=t[1],s=t[2]||r,u=e||S,c=o(u,i,a,s,!0);c?c.zone.cancelTask(c):u[n](a,i,s)}}function u(e){return!(!e||!e.addEventListener)&&(f(e,z,function(){return C}),f(e,I,function(){return M}),!0)}function c(t){var n=S[t];if(n){S[t]=function(){var r=e(arguments,t);switch(r.length){case 0:this[L]=new n;break;case 1:this[L]=new n(r[0]);break;case 2:this[L]=new n(r[0],r[1]);break;case 3:this[L]=new n(r[0],r[1],r[2]);break;case 4:this[L]=new n(r[0],r[1],r[2],r[3]);break;default:throw new Error("Arg list too long.")}};var r,o=new n(function(){});for(r in o)"XMLHttpRequest"===t&&"responseBlob"===r||!function(e){"function"==typeof o[e]?S[t].prototype[e]=function(){return this[L][e].apply(this[L],arguments)}:Object.defineProperty(S[t].prototype,e,{set:function(n){"function"==typeof n?this[L][e]=Zone.current.wrap(n,t+"."+e):this[L][e]=n},get:function(){return this[L][e]}})}(r);for(r in n)"prototype"!==r&&n.hasOwnProperty(r)&&(S[t][r]=n[r])}}function l(e,t){try{return Function("f","return function "+e+"(){return f(this, arguments)}")(t)}catch(n){return function(){return t(this,arguments)}}}function f(e,t,n){for(var r=e;r&&!r.hasOwnProperty(t);)r=Object.getPrototypeOf(r);!r&&e[t]&&(r=e);var o,a=E(t);return r&&!(o=r[a])&&(o=r[a]=r[t],r[t]=l(t,n(o,a,t))),o}function p(e){var t=[],n=e.wtf;n?t=F.split(",").map(function(e){return"HTML"+e+"Element"}).concat(H):e[R]?t.push(R):t=H;for(var r=0;r<t.length;r++){var o=e[t[r]];u(o&&o.prototype)}}function h(){Object.defineProperty=function(e,t,n){if(v(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);var r=n.configurable;return"prototype"!==t&&(n=g(e,t,n)),y(e,t,n,r)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=g(e,n,t[n])}),x(e,t)},Object.getOwnPropertyDescriptor=function(e,t){var n=B(e,t);return v(e,t)&&(n.configurable=!1),n}}function d(e,t,n){var r=n.configurable;return n=g(e,t,n),y(e,t,n,r)}function v(e,t){return e&&e[W]&&e[W][t]}function g(e,t,n){return n.configurable=!0,n.configurable||(e[W]||q(e,W,{writable:!0,value:{}}),e[W][t]=!0),n}function y(e,t,n,r){try{return q(e,t,n)}catch(o){if(!n.configurable)throw o;"undefined"==typeof r?delete n.configurable:n.configurable=r;try{return q(e,t,n)}catch(o){var a=null;try{a=JSON.stringify(n)}catch(o){a=a.toString()}console.log("Attempting to configure '"+t+"' with descriptor '"+a+"' on object '"+e+"' and got error, giving up: "+o)}}}function k(e){if(O&&"registerElement"in e.document){var t=document.registerElement,n=["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"];document.registerElement=function(e,r){return r&&r.prototype&&n.forEach(function(e){var t="Document.registerElement::"+e;if(r.prototype.hasOwnProperty(e)){var n=Object.getOwnPropertyDescriptor(r.prototype,e);n&&n.value?(n.value=Zone.current.wrap(n.value,t),d(r.prototype,e,n)):r.prototype[e]=Zone.current.wrap(r.prototype[e],t)}else r.prototype[e]&&(r.prototype[e]=Zone.current.wrap(r.prototype[e],t))}),t.apply(document,[e,r])}}}function b(e){var t=e.WebSocket;e.EventTarget||u(t.prototype),e.WebSocket=function(e,n){var o,a=arguments.length>1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r(o,["close","error","message","open"]),o};for(var n in t)e.WebSocket[n]=t[n]}function m(e){if(!Z){var t="undefined"!=typeof WebSocket;T()?(O&&r(HTMLElement.prototype,X),r(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(r(IDBIndex.prototype,null),r(IDBRequest.prototype,null),r(IDBOpenDBRequest.prototype,null),r(IDBDatabase.prototype,null),r(IDBTransaction.prototype,null),r(IDBCursor.prototype,null)),t&&r(WebSocket.prototype,null)):(w(),c("XMLHttpRequest"),t&&b(e))}}function T(){if(O&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{get:function(){return!0}});var t=new XMLHttpRequest,n=!!t.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{}),n}function w(){for(var e=function(e){var t=X[e],n="on"+t;document.addEventListener(t,function(e){var t,r,o=e.target;for(r=o?o.constructor.name+"."+n:"unknown."+n;o;)o[n]&&!o[n][A]&&(t=Zone.current.wrap(o[n],r),t[A]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t<X.length;t++)e(t)}function _(e,t,n,r){function o(t){var n=t.data;return n.args[0]=t.invoke,n.handleId=i.apply(e,n.args),t}function a(e){return s(e.data.handleId)}var i=null,s=null;t+=r,n+=r,i=f(e,t,function(n){return function(i,s){if("function"==typeof s[0]){var u=Zone.current,c={handleId:null,isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?s[1]||0:null,args:s},l=u.scheduleMacroTask(t,s[0],c,o,a);if(!l)return l;var f=l.data.handleId;return f.ref&&f.unref&&(l.ref=f.ref.bind(f),l.unref=f.unref.bind(f)),l}return n.apply(e,s)}}),s=f(e,n,function(t){return function(n,r){var o=r[0];o&&"string"==typeof o.type?(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&o.zone.cancelTask(o):t.apply(e,r)}})}function D(e){function t(e){var t=e[Q];return t}function n(e){var t=e.data;t.target.addEventListener("readystatechange",function(){t.target.readyState===t.target.DONE&&(t.aborted||e.invoke())});var n=t.target[Q];return n||(t.target[Q]=e),i.apply(t.target,t.args),e}function r(){}function o(e){var t=e.data;return t.aborted=!0,s.apply(t.target,t.args)}var a=f(e.XMLHttpRequest.prototype,"open",function(){return function(e,t){return e[Y]=0==t[2],a.apply(e,t)}}),i=f(e.XMLHttpRequest.prototype,"send",function(){return function(e,t){var a=Zone.current;if(e[Y])return i.apply(e,t);var s={target:e,isPeriodic:!1,delay:null,args:t,aborted:!1};return a.scheduleMacroTask("XMLHttpRequest.send",r,s,n,o)}}),s=f(e.XMLHttpRequest.prototype,"abort",function(e){return function(e,n){var r=t(e);if(r&&"string"==typeof r.type){if(null==r.cancelFn)return;r.zone.cancelTask(r)}}})}var E=(function(e){function t(e){return"__zone_symbol__"+e}function n(){0==E&&0==w.length&&(e[k]?e[k].resolve(0)[b](a):e[y](a,0))}function r(e){n(),w.push(e)}function o(e){var t=e&&e.rejection;t&&console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0),console.error(e)}function a(){if(!_){for(_=!0;w.length;){var e=w;w=[];for(var t=0;t<e.length;t++){var n=e[t];try{n.zone.runTask(n,null,null)}catch(r){o(r)}}}for(;D.length;)for(var a=function(){var e=D.shift();try{e.zone.runGuarded(function(){throw e})}catch(t){o(t)}};D.length;)a();_=!1}}function i(e){return e&&e.then}function s(e){return e}function u(e){return C.reject(e)}function c(e,t){return function(n){l(e,t,n)}}function l(e,t,r){if(e[S]===O)if(r instanceof C&&r[S]!==O)f(r),l(e,r[S],r[P]);else if(i(r))r.then(c(e,t),c(e,!1));else{e[S]=t;var o=e[P];e[P]=r;for(var a=0;a<o.length;)p(e,o[a++],o[a++],o[a++],o[a++]);if(0==o.length&&t==z){e[S]=I;try{throw new Error("Uncaught (in promise): "+r)}catch(s){var u=s;u.rejection=r,u.promise=e,u.zone=d.current,u.task=d.currentTask,D.push(u),n()}}}return e}function f(e){if(e[S]===I){e[S]=z;for(var t=0;t<D.length;t++)if(e===D[t].promise){D.splice(t,1);break}}}function p(e,t,n,r,o){f(e);var a=e[S]?r||s:o||u;t.scheduleMicroTask(Z,function(){try{l(n,!0,t.run(a,null,[e[P]]))}catch(r){l(n,!1,r)}})}function h(e){var n=e.prototype,r=n[t("then")]=n.then;n.then=function(e,t){var n=this;return new C(function(e,t){r.call(n,e,t)}).then(e,t)}}if(e.Zone)throw new Error("Zone already loaded.");var d=function(){function n(e,t){this._properties=null,this._parent=e,this._name=t?t.name||"unnamed":"<root>",this._properties=t&&t.properties||{},this._zoneDelegate=new v(this,this._parent&&this._parent._zoneDelegate,t)}return n.assertZonePatched=function(){if(e.Promise!==C)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(n,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(n,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),n.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},n.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},n.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},n.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},n.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{m=o}},n.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o}},n.prototype.runTask=function(e,t,n){if(e.runCount++,e.zone!=this)throw new Error("A task can only be run in the zone which created it! (Creation: "+e.zone.name+"; Execution: "+this.name+")");var r=T;T=e;var o=m;m=this;try{"macroTask"==e.type&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o,T=r}},n.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new g("microTask",this,e,t,n,r,null))},n.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new g("macroTask",this,e,t,n,r,o))},n.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new g("eventTask",this,e,t,n,r,o))},n.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.runCount=-1,e.cancelFn=null,t},n.__symbol__=t,n}(),v=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new d(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t)},e.prototype.scheduleTask=function(e,t){try{if(this._scheduleTaskZS)return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this.zone,e,t);if(t.scheduleFn)t.scheduleFn(t);else{if("microTask"!=t.type)throw new Error("Task is missing scheduleFn.");r(t)}return t}finally{e==this.zone&&this._updateTaskCount(t.type,1)}},e.prototype.invokeTask=function(e,t,n,r){try{return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this.zone,e,t,n,r):t.callback.apply(n,r)}finally{e!=this.zone||"eventTask"==t.type||t.data&&t.data.isPeriodic||this._updateTaskCount(t.type,-1)}},e.prototype.cancelTask=function(e,t){var n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this.zone,e,t);else{if(!t.cancelFn)throw new Error("Task does not support cancellation, or is already canceled.");n=t.cancelFn(t)}return e==this.zone&&this._updateTaskCount(t.type,-1),n},e.prototype.hasTask=function(e,t){return this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this.zone,e,t)},e.prototype._updateTaskCount=function(e,t){var n=this._taskCounts,r=n[e],o=n[e]=r+t;if(o<0)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),g=function(){function e(e,t,n,r,o,i,s){this.runCount=0,this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=s,this.callback=r;var u=this;this.invoke=function(){E++;try{return t.runTask(u,this,arguments)}finally{1==E&&a(),E--}}}return e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:this.toString()},e}(),y=t("setTimeout"),k=t("Promise"),b=t("then"),m=new d(null,null),T=null,w=[],_=!1,D=[],E=0,S=t("state"),P=t("value"),Z="Promise.then",O=null,j=!0,z=!1,I=0,C=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[S]=O,n[P]=[];try{t&&t(c(n,j),c(n,z))}catch(r){l(n,!1,r)}}return e.resolve=function(e){return l(new this(null),j,e)},e.reject=function(e){return l(new this(null),z,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){r=e,o=t}),s=0,u=e;s<u.length;s++){var c=u[s];i(c)||(c=this.resolve(c)),c.then(t,n)}return a},e.all=function(e){for(var t,n,r=new this(function(e,r){t=e,n=r}),o=0,a=[],s=0,u=e;s<u.length;s++){var c=u[s];i(c)||(c=this.resolve(c)),c.then(function(e){return function(n){a[e]=n,o--,o||t(a)}}(o),n),o++}return o||t(a),r},e.prototype.then=function(e,t){var n=new this.constructor(null),r=d.current;return this[S]==O?this[P].push(r,n,e,t):p(this,r,n,e,t),n},e.prototype["catch"]=function(e){return this.then(null,e)},e}();C.resolve=C.resolve,C.reject=C.reject,C.race=C.race,C.all=C.all;var M=e[t("Promise")]=e.Promise;if(e.Promise=C,M&&(h(M),"undefined"!=typeof e.fetch)){var L=void 0;try{L=e.fetch()}catch(F){L=e.fetch("about:blank")}L.then(function(){return null},function(){return null}),L.constructor!=M&&h(L.constructor)}return Promise[d.__symbol__("uncaughtPromiseErrors")]=D,e.Zone=d}("object"==typeof window&&window||"object"==typeof self&&self||global),Zone.__symbol__),S="object"==typeof window&&window||"object"==typeof self&&self||global,P="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,Z="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),O=!Z&&!P&&!("undefined"==typeof window||!window.HTMLElement),j=E("eventTasks"),z="addEventListener",I="removeEventListener",C=i(z,I),M=s(I),L=E("originalInstance"),F="Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video",H="ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex".split(","),R="EventTarget",q=Object[E("defineProperty")]=Object.defineProperty,B=Object[E("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,x=Object.create,W=E("unconfigurables"),X="copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror".split(" "),A=E("unbound"),N="set",G="clear",U=["alert","prompt","confirm"],K="object"==typeof window&&window||"object"==typeof self&&self||global;_(K,N,G,"Timeout"),_(K,N,G,"Interval"),_(K,N,G,"Immediate"),_(K,"request","cancel","AnimationFrame"),_(K,"mozRequest","mozCancel","AnimationFrame"),_(K,"webkitRequest","webkitCancel","AnimationFrame");for(var V=0;V<U.length;V++){var J=U[V];f(K,J,function(e,t,n){return function(t,r){return Zone.current.run(e,K,r,n)}})}p(K),m(K),c("MutationObserver"),c("WebKitMutationObserver"),c("FileReader"),h(),k(K),D(K);var Q=E("xhrTask"),Y=E("xhrSync");K.navigator&&K.navigator.geolocation&&t(K.navigator.geolocation,["getCurrentPosition","watchPosition"])});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";function e(e,t){for(var n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function t(t,n){for(var r=t.constructor.name,o=function(o){var a=n[o],i=t[a];i&&(t[a]=function(t){return function(){return t.apply(this,e(arguments,r+"."+a))}}(i))},a=0;a<n.length;a++)o(a)}function n(e,t){var n=Object.getOwnPropertyDescriptor(e,t)||{enumerable:!0,configurable:!0};delete n.writable,delete n.value;var r=t.substr(2),o="_"+t;n.set=function(e){if(this[o]&&this.removeEventListener(r,this[o]),"function"==typeof e){var t=function(t){var n;n=e.apply(this,arguments),void 0==n||n||t.preventDefault()};this[o]=t,this.addEventListener(r,t,!1)}else this[o]=null},n.get=function(){return this[o]||null},Object.defineProperty(e,t,n)}function r(e,t){var r=[];for(var o in e)"on"==o.substr(0,2)&&r.push(o);for(var a=0;a<r.length;a++)n(e,r[a]);if(t)for(var i=0;i<t.length;i++)n(e,"on"+t[i])}function o(e,t,n,r,o){var a=e[j];if(a)for(var i=0;i<a.length;i++){var s=a[i],u=s.data;if(u.handler===t&&u.useCapturing===r&&u.eventName===n)return o&&a.splice(i,1),s}return null}function a(e,t){var n=e[j];n||(n=e[j]=[]),n.push(t)}function i(e,t,n,r){function i(e){var t=e.data;return a(t.target,e),t.target[u](t.eventName,e.invoke,t.useCapturing)}function s(e){var t=e.data;o(t.target,e.invoke,t.eventName,t.useCapturing,!0),t.target[c](t.eventName,e.invoke,t.useCapturing)}void 0===n&&(n=!0),void 0===r&&(r=!1);var u=E(e),c=E(t),l=!n&&void 0;return function(t,n){var a=n[0],c=n[1],f=n[2]||l,p=t||S,h=null;"function"==typeof c?h=c:c&&c.handleEvent&&(h=function(e){return c.handleEvent(e)});var d=!1;try{d=c&&"[object FunctionWrapper]"===c.toString()}catch(v){return}if(!h||d)return p[u](a,c,f);if(!r){var g=o(p,c,a,f,!1);if(g)return p[u](a,g.invoke,f)}var y=Zone.current,k=p.constructor.name+"."+e+":"+a,b={target:p,eventName:a,name:a,useCapturing:f,handler:c};y.scheduleEventTask(k,h,b,i,s)}}function s(e,t){void 0===t&&(t=!0);var n=E(e),r=!t&&void 0;return function(e,t){var a=t[0],i=t[1],s=t[2]||r,u=e||S,c=o(u,i,a,s,!0);c?c.zone.cancelTask(c):u[n](a,i,s)}}function u(e){return!(!e||!e.addEventListener)&&(f(e,z,function(){return C}),f(e,I,function(){return M}),!0)}function c(t){var n=S[t];if(n){S[t]=function(){var r=e(arguments,t);switch(r.length){case 0:this[L]=new n;break;case 1:this[L]=new n(r[0]);break;case 2:this[L]=new n(r[0],r[1]);break;case 3:this[L]=new n(r[0],r[1],r[2]);break;case 4:this[L]=new n(r[0],r[1],r[2],r[3]);break;default:throw new Error("Arg list too long.")}};var r,o=new n(function(){});for(r in o)"XMLHttpRequest"===t&&"responseBlob"===r||!function(e){"function"==typeof o[e]?S[t].prototype[e]=function(){return this[L][e].apply(this[L],arguments)}:Object.defineProperty(S[t].prototype,e,{set:function(n){"function"==typeof n?this[L][e]=Zone.current.wrap(n,t+"."+e):this[L][e]=n},get:function(){return this[L][e]}})}(r);for(r in n)"prototype"!==r&&n.hasOwnProperty(r)&&(S[t][r]=n[r])}}function l(e,t){try{return Function("f","return function "+e+"(){return f(this, arguments)}")(t)}catch(n){return function(){return t(this,arguments)}}}function f(e,t,n){for(var r=e;r&&Object.getOwnPropertyNames(r).indexOf(t)===-1;)r=Object.getPrototypeOf(r);!r&&e[t]&&(r=e);var o,a=E(t);return r&&!(o=r[a])&&(o=r[a]=r[t],r[t]=l(t,n(o,a,t))),o}function p(e,t,n,r){function o(t){var n=t.data;return n.args[0]=function(){t.invoke.apply(this,arguments),delete u[n.handleId]},n.handleId=i.apply(e,n.args),u[n.handleId]=t,t}function a(e){return delete u[e.data.handleId],s(e.data.handleId)}var i=null,s=null;t+=r,n+=r;var u={};i=f(e,t,function(n){return function(i,s){if("function"==typeof s[0]){var u=Zone.current,c={handleId:null,isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?s[1]||0:null,args:s},l=u.scheduleMacroTask(t,s[0],c,o,a);if(!l)return l;var f=l.data.handleId;return f.ref&&f.unref&&(l.ref=f.ref.bind(f),l.unref=f.unref.bind(f)),l}return n.apply(e,s)}}),s=f(e,n,function(t){return function(n,r){var o="number"==typeof r[0]?u[r[0]]:r[0];o&&"string"==typeof o.type?(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&o.zone.cancelTask(o):t.apply(e,r)}})}function h(){Object.defineProperty=function(e,t,n){if(v(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);var r=n.configurable;return"prototype"!==t&&(n=g(e,t,n)),y(e,t,n,r)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=g(e,n,t[n])}),R(e,t)},Object.getOwnPropertyDescriptor=function(e,t){var n=H(e,t);return v(e,t)&&(n.configurable=!1),n}}function d(e,t,n){var r=n.configurable;return n=g(e,t,n),y(e,t,n,r)}function v(e,t){return e&&e[q]&&e[q][t]}function g(e,t,n){return n.configurable=!0,n.configurable||(e[q]||F(e,q,{writable:!0,value:{}}),e[q][t]=!0),n}function y(e,t,n,r){try{return F(e,t,n)}catch(o){if(!n.configurable)throw o;"undefined"==typeof r?delete n.configurable:n.configurable=r;try{return F(e,t,n)}catch(o){var a=null;try{a=JSON.stringify(n)}catch(o){a=a.toString()}console.log("Attempting to configure '"+t+"' with descriptor '"+a+"' on object '"+e+"' and got error, giving up: "+o)}}}function k(e){var t=[],n=e.wtf;n?t=B.split(",").map(function(e){return"HTML"+e+"Element"}).concat(x):e[W]?t.push(W):t=x;for(var r=0;r<t.length;r++){var o=e[t[r]];u(o&&o.prototype)}}function b(e){var t=e.WebSocket;e.EventTarget||u(t.prototype),e.WebSocket=function(e,n){var o,a=arguments.length>1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r(o,["close","error","message","open"]),o};for(var n in t)e.WebSocket[n]=t[n]}function m(e){if(!P){var t="undefined"!=typeof WebSocket;T()?(Z&&r(HTMLElement.prototype,X),r(XMLHttpRequest.prototype,null),"undefined"!=typeof IDBIndex&&(r(IDBIndex.prototype,null),r(IDBRequest.prototype,null),r(IDBOpenDBRequest.prototype,null),r(IDBDatabase.prototype,null),r(IDBTransaction.prototype,null),r(IDBCursor.prototype,null)),t&&r(WebSocket.prototype,null)):(w(),c("XMLHttpRequest"),t&&b(e))}}function T(){if(Z&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{get:function(){return!0}});var t=new XMLHttpRequest,n=!!t.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{}),n}function w(){for(var e=function(e){var t=X[e],n="on"+t;self.addEventListener(t,function(e){var t,r,o=e.target;for(r=o?o.constructor.name+"."+n:"unknown."+n;o;)o[n]&&!o[n][A]&&(t=Zone.current.wrap(o[n],r),t[A]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t<X.length;t++)e(t)}function _(e){if(Z&&"registerElement"in e.document){var t=document.registerElement,n=["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"];document.registerElement=function(e,r){return r&&r.prototype&&n.forEach(function(e){var t="Document.registerElement::"+e;if(r.prototype.hasOwnProperty(e)){var n=Object.getOwnPropertyDescriptor(r.prototype,e);n&&n.value?(n.value=Zone.current.wrap(n.value,t),d(r.prototype,e,n)):r.prototype[e]=Zone.current.wrap(r.prototype[e],t)}else r.prototype[e]&&(r.prototype[e]=Zone.current.wrap(r.prototype[e],t))}),t.apply(document,[e,r])}}}function D(e){function t(e){var t=e[Q];return t}function n(e){var t=e.data;t.target.addEventListener("readystatechange",function(){t.target.readyState===t.target.DONE&&(t.aborted||e.invoke())});var n=t.target[Q];return n||(t.target[Q]=e),i.apply(t.target,t.args),e}function r(){}function o(e){var t=e.data;return t.aborted=!0,s.apply(t.target,t.args)}var a=f(e.XMLHttpRequest.prototype,"open",function(){return function(e,t){return e[Y]=0==t[2],a.apply(e,t)}}),i=f(e.XMLHttpRequest.prototype,"send",function(){return function(e,t){var a=Zone.current;if(e[Y])return i.apply(e,t);var s={target:e,isPeriodic:!1,delay:null,args:t,aborted:!1};return a.scheduleMacroTask("XMLHttpRequest.send",r,s,n,o)}}),s=f(e.XMLHttpRequest.prototype,"abort",function(e){return function(e,n){var r=t(e);if(r&&"string"==typeof r.type){if(null==r.cancelFn)return;r.zone.cancelTask(r)}}})}var E=(function(e){function t(e){return"__zone_symbol__"+e}function n(){0==E&&0==w.length&&(e[k]?e[k].resolve(0)[b](a):e[y](a,0))}function r(e){n(),w.push(e)}function o(e){var t=e&&e.rejection;t&&console.error("Unhandled Promise rejection:",t instanceof Error?t.message:t,"; Zone:",e.zone.name,"; Task:",e.task&&e.task.source,"; Value:",t,t instanceof Error?t.stack:void 0),console.error(e)}function a(){if(!_){for(_=!0;w.length;){var e=w;w=[];for(var t=0;t<e.length;t++){var n=e[t];try{n.zone.runTask(n,null,null)}catch(r){o(r)}}}for(;D.length;)for(var a=function(){var e=D.shift();try{e.zone.runGuarded(function(){throw e})}catch(t){o(t)}};D.length;)a();_=!1}}function i(e){return e&&e.then}function s(e){return e}function u(e){return C.reject(e)}function c(e,t){return function(n){l(e,t,n)}}function l(e,t,r){if(e[S]===Z)if(r instanceof C&&r[S]!==Z)f(r),l(e,r[S],r[O]);else if(i(r))r.then(c(e,t),c(e,!1));else{e[S]=t;var o=e[O];e[O]=r;for(var a=0;a<o.length;)p(e,o[a++],o[a++],o[a++],o[a++]);if(0==o.length&&t==z){e[S]=I;try{throw new Error("Uncaught (in promise): "+r+(r&&r.stack?"\n"+r.stack:""))}catch(s){var u=s;u.rejection=r,u.promise=e,u.zone=d.current,u.task=d.currentTask,D.push(u),n()}}}return e}function f(e){if(e[S]===I){e[S]=z;for(var t=0;t<D.length;t++)if(e===D[t].promise){D.splice(t,1);break}}}function p(e,t,n,r,o){f(e);var a=e[S]?r||s:o||u;t.scheduleMicroTask(P,function(){try{l(n,!0,t.run(a,null,[e[O]]))}catch(r){l(n,!1,r)}})}function h(e){var n=e.prototype,r=n[t("then")]=n.then;n.then=function(e,t){var n=this;return new C(function(e,t){r.call(n,e,t)}).then(e,t)}}if(e.Zone)throw new Error("Zone already loaded.");var d=function(){function n(e,t){this._properties=null,this._parent=e,this._name=t?t.name||"unnamed":"<root>",this._properties=t&&t.properties||{},this._zoneDelegate=new v(this,this._parent&&this._parent._zoneDelegate,t)}return n.assertZonePatched=function(){if(e.Promise!==C)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")},Object.defineProperty(n,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(n,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),n.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},n.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},n.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},n.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}},n.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{m=o}},n.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o}},n.prototype.runTask=function(e,t,n){if(e.runCount++,e.zone!=this)throw new Error("A task can only be run in the zone which created it! (Creation: "+e.zone.name+"; Execution: "+this.name+")");var r=T;T=e;var o=m;m=this;try{"macroTask"==e.type&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o,T=r}},n.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new g("microTask",this,e,t,n,r,null))},n.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new g("macroTask",this,e,t,n,r,o))},n.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new g("eventTask",this,e,t,n,r,o))},n.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.runCount=-1,e.cancelFn=null,t},n.__symbol__=t,n}(),v=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new d(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t)},e.prototype.scheduleTask=function(e,t){try{if(this._scheduleTaskZS)return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this.zone,e,t);if(t.scheduleFn)t.scheduleFn(t);else{if("microTask"!=t.type)throw new Error("Task is missing scheduleFn.");r(t)}return t}finally{e==this.zone&&this._updateTaskCount(t.type,1)}},e.prototype.invokeTask=function(e,t,n,r){try{return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this.zone,e,t,n,r):t.callback.apply(n,r)}finally{e!=this.zone||"eventTask"==t.type||t.data&&t.data.isPeriodic||this._updateTaskCount(t.type,-1)}},e.prototype.cancelTask=function(e,t){var n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this.zone,e,t);else{if(!t.cancelFn)throw new Error("Task does not support cancellation, or is already canceled.");n=t.cancelFn(t)}return e==this.zone&&this._updateTaskCount(t.type,-1),n},e.prototype.hasTask=function(e,t){return this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this.zone,e,t)},e.prototype._updateTaskCount=function(e,t){var n=this._taskCounts,r=n[e],o=n[e]=r+t;if(o<0)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),g=function(){function e(e,t,n,r,o,i,s){this.runCount=0,this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=s,this.callback=r;var u=this;this.invoke=function(){E++;try{return t.runTask(u,this,arguments)}finally{1==E&&a(),E--}}}return e.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},e}(),y=t("setTimeout"),k=t("Promise"),b=t("then"),m=new d(null,null),T=null,w=[],_=!1,D=[],E=0,S=t("state"),O=t("value"),P="Promise.then",Z=null,j=!0,z=!1,I=0,C=function(){function e(t){var n=this;if(!(n instanceof e))throw new Error("Must be an instanceof Promise.");n[S]=Z,n[O]=[];try{t&&t(c(n,j),c(n,z))}catch(r){l(n,!1,r)}}return e.resolve=function(e){return l(new this(null),j,e)},e.reject=function(e){return l(new this(null),z,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){n=[e,t],r=n[0],o=n[1];var n}),s=0,u=e;s<u.length;s++){var c=u[s];i(c)||(c=this.resolve(c)),c.then(t,n)}return a},e.all=function(e){for(var t,n,r=new this(function(e,r){t=e,n=r}),o=0,a=[],s=0,u=e;s<u.length;s++){var c=u[s];i(c)||(c=this.resolve(c)),c.then(function(e){return function(n){a[e]=n,o--,o||t(a)}}(o),n),o++}return o||t(a),r},e.prototype.then=function(e,t){var n=new this.constructor(null),r=d.current;return this[S]==Z?this[O].push(r,n,e,t):p(this,r,n,e,t),n},e.prototype["catch"]=function(e){return this.then(null,e)},e}();C.resolve=C.resolve,C.reject=C.reject,C.race=C.race,C.all=C.all;var M=e[t("Promise")]=e.Promise;if(e.Promise=C,M&&(h(M),"undefined"!=typeof e.fetch)){var L=void 0;try{L=e.fetch()}catch(F){L=e.fetch("about:blank")}L.then(function(){return null},function(){return null}),L.constructor!=M&&L.constructor!=C&&h(L.constructor)}return Promise[d.__symbol__("uncaughtPromiseErrors")]=D,e.Zone=d}("object"==typeof window&&window||"object"==typeof self&&self||global),Zone.__symbol__),S="object"==typeof window&&window||"object"==typeof self&&self||global,O="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,P="undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Z=!P&&!O&&!("undefined"==typeof window||!window.HTMLElement),j=E("eventTasks"),z="addEventListener",I="removeEventListener",C=i(z,I),M=s(I),L=E("originalInstance"),F=Object[E("defineProperty")]=Object.defineProperty,H=Object[E("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,R=Object.create,q=E("unconfigurables"),B="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",x="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(","),W="EventTarget",X="copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror".split(" "),A=E("unbound"),N="set",G="clear",U=["alert","prompt","confirm"],K="object"==typeof window&&window||"object"==typeof self&&self||global;p(K,N,G,"Timeout"),p(K,N,G,"Interval"),p(K,N,G,"Immediate"),p(K,"request","cancel","AnimationFrame"),p(K,"mozRequest","mozCancel","AnimationFrame"),p(K,"webkitRequest","webkitCancel","AnimationFrame");for(var V=0;V<U.length;V++){var J=U[V];f(K,J,function(e,t,n){return function(t,r){return Zone.current.run(e,K,r,n)}})}k(K),m(K),c("MutationObserver"),c("WebKitMutationObserver"),c("FileReader"),h(),_(K),D(K);var Q=E("xhrTask"),Y=E("xhrSync");K.navigator&&K.navigator.geolocation&&t(K.navigator.geolocation,["getCurrentPosition","watchPosition"])});

@@ -0,8 +1,18 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import '../zone';
import {patchTimer} from '../common/timers';
import {patchClass, patchMethod, patchPrototype, zoneSymbol} from '../common/utils';
import {propertyPatch} from './define-property';
import {eventTargetPatch} from './event-target';
import {propertyPatch} from './define-property';
import {propertyDescriptorPatch} from './property-descriptor';
import {registerElementPatch} from './register-element';
import {propertyDescriptorPatch} from './property-descriptor';
import {patchTimer} from '../common/timers';
import {patchMethod, patchPrototype, patchClass, zoneSymbol} from "../common/utils";

@@ -24,5 +34,5 @@ const set = 'set';

patchMethod(_global, name, (delegate, symbol, name) => {
return function (s:any, args: any[]) {
return Zone.current.run(delegate, _global, args, name)
}
return function(s: any, args: any[]) {
return Zone.current.run(delegate, _global, args, name);
};
});

@@ -74,4 +84,3 @@ }

function placeholderCallback() {
}
function placeholderCallback() {}

@@ -86,35 +95,36 @@ function clearTask(task: Task) {

var openNative = patchMethod(window.XMLHttpRequest.prototype, 'open', () => function(self: any, args: any[]) {
self[XHR_SYNC] = args[2] == false;
return openNative.apply(self, args);
});
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;
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 sendNative =
patchMethod(window.XMLHttpRequest.prototype, 'send', () => function(self: any, args: any[]) {
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: XHROptions =
{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', (delegate: Function) => function(self: any, args: any[]) {
var task: 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.
});
var abortNative = patchMethod(
window.XMLHttpRequest.prototype, 'abort',
(delegate: Function) => function(self: any, args: any[]) {
var task: 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.
});
}

@@ -124,6 +134,3 @@

if (_global['navigator'] && _global['navigator'].geolocation) {
patchPrototype(_global['navigator'].geolocation, [
'getCurrentPosition',
'watchPosition'
]);
patchPrototype(_global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']);
}

@@ -1,2 +0,10 @@

import {zoneSymbol} from "../common/utils";
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {zoneSymbol} from '../common/utils';
/*

@@ -8,3 +16,4 @@ * This is necessary for Chrome and Chrome mobile, to enable

const _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty;
const _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor;
const _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] =
Object.getOwnPropertyDescriptor;
const _create = Object.create;

@@ -14,3 +23,3 @@ const unconfigurablesKey = zoneSymbol('unconfigurables');

export function propertyPatch() {
Object.defineProperty = function (obj, prop, desc) {
Object.defineProperty = function(obj, prop, desc) {
if (isUnconfigurable(obj, prop)) {

@@ -26,4 +35,4 @@ throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj);

Object.defineProperties = function (obj, props) {
Object.keys(props).forEach(function (prop) {
Object.defineProperties = function(obj, props) {
Object.keys(props).forEach(function(prop) {
Object.defineProperty(obj, prop, props[prop]);

@@ -34,5 +43,5 @@ });

Object.create = <any>function (obj, proto) {
Object.create = <any>function(obj, proto) {
if (typeof proto === 'object' && !Object.isFrozen(proto)) {
Object.keys(proto).forEach(function (prop) {
Object.keys(proto).forEach(function(prop) {
proto[prop] = rewriteDescriptor(obj, prop, proto[prop]);

@@ -44,3 +53,3 @@ });

Object.getOwnPropertyDescriptor = function (obj, prop) {
Object.getOwnPropertyDescriptor = function(obj, prop) {
const desc = _getOwnPropertyDescriptor(obj, prop);

@@ -60,11 +69,11 @@ if (isUnconfigurable(obj, prop)) {

function isUnconfigurable (obj, prop) {
function isUnconfigurable(obj, prop) {
return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop];
}
function rewriteDescriptor (obj, prop, desc) {
function rewriteDescriptor(obj, prop, desc) {
desc.configurable = true;
if (!desc.configurable) {
if (!obj[unconfigurablesKey]) {
_defineProperty(obj, unconfigurablesKey, { writable: true, value: {} });
_defineProperty(obj, unconfigurablesKey, {writable: true, value: {}});
}

@@ -76,9 +85,9 @@ obj[unconfigurablesKey][prop] = true;

function _tryDefineProperty (obj, prop, desc, originalConfigurableFlag) {
function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) {
try {
return _defineProperty(obj, prop, desc);
}
catch(e) {
} 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
// 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') {

@@ -92,5 +101,10 @@ delete desc.configurable;

} 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}`);
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}`);
}

@@ -102,3 +116,1 @@ } else {

}

@@ -0,5 +1,16 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {patchEventTargetMethods} from '../common/utils';
const 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';
const 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(',');
const 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';
const 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(',');
const EVENT_TARGET = 'EventTarget';

@@ -6,0 +17,0 @@

@@ -0,8 +1,19 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {isBrowser, isNode, patchClass, patchOnProperties, zoneSymbol} from '../common/utils';
import * as webSocketPatch from './websocket';
import {zoneSymbol, patchOnProperties, patchClass, isBrowser, isNode} from '../common/utils';
const 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(' ');
const 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(' ');
export function propertyDescriptorPatch(_global) {
if (isNode){
if (isNode) {
return;

@@ -40,4 +51,4 @@ }

function canPatchViaPropertyDescriptor() {
if (isBrowser && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick')
&& typeof Element !== 'undefined') {
if (isBrowser && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') &&
typeof Element !== 'undefined') {
// WebKit https://bugs.webkit.org/show_bug.cgi?id=134364

@@ -50,3 +61,3 @@ // IDL interface attributes are not configurable

Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', {
get: function () {
get: function() {
return true;

@@ -67,6 +78,6 @@ }

function patchViaCapturingAllTheEvents() {
for(let i = 0; i < eventNames.length; i++) {
for (let i = 0; i < eventNames.length; i++) {
const property = eventNames[i];
const onproperty = 'on' + property;
document.addEventListener(property, function (event) {
self.addEventListener(property, function(event) {
let elt = <Node>event.target, bound, source;

@@ -73,0 +84,0 @@ if (elt) {

@@ -1,4 +0,13 @@

import {_redefineProperty} from './define-property';
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {isBrowser} from '../common/utils';
import {_redefineProperty} from './define-property';
export function registerElementPatch(_global: any) {

@@ -10,12 +19,8 @@ if (!isBrowser || !('registerElement' in (<any>_global).document)) {

const _registerElement = (<any>document).registerElement;
const callbacks = [
'createdCallback',
'attachedCallback',
'detachedCallback',
'attributeChangedCallback'
];
const callbacks =
['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback'];
(<any>document).registerElement = function (name, opts) {
(<any>document).registerElement = function(name, opts) {
if (opts && opts.prototype) {
callbacks.forEach(function (callback) {
callbacks.forEach(function(callback) {
const source = 'Document.registerElement::' + callback;

@@ -22,0 +27,0 @@ if (opts.prototype.hasOwnProperty(callback)) {

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {patchEventTargetMethods, patchOnProperties} from '../common/utils';

@@ -33,3 +41,5 @@

};
for (var prop in WS) { _global.WebSocket[prop] = WS[prop]; }
for (var prop in WS) {
_global.WebSocket[prop] = WS[prop];
}
}

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {patchMethod} from './utils';

@@ -8,8 +16,3 @@

export function patchTimer(
window: any,
setName: string,
cancelName: string,
nameSuffix: string) {
export function patchTimer(window: any, setName: string, cancelName: string, nameSuffix: string) {
var setNative = null;

@@ -20,6 +23,12 @@ var clearNative = null;

const tasksByHandleId: {[id: number]: Task} = {};
function scheduleTask(task: Task) {
const data = <TimerOptions>task.data;
data.args[0] = task.invoke;
data.args[0] = function() {
task.invoke.apply(this, arguments);
delete tasksByHandleId[data.handleId];
};
data.handleId = setNative.apply(window, data.args);
tasksByHandleId[data.handleId] = task;
return task;

@@ -29,43 +38,46 @@ }

function clearTask(task: Task) {
delete tasksByHandleId[(<TimerOptions>task.data).handleId];
return clearNative((<TimerOptions>task.data).handleId);
}
setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) {
if (typeof args[0] === 'function') {
var zone = Zone.current;
var options: TimerOptions = {
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 = (<TimerOptions>task.data).handleId;
if ((<any>handle).ref && (<any>handle).unref) {
(<any>task).ref = (<any>handle).ref.bind(handle);
(<any>task).unref = (<any>handle).unref.bind(handle);
}
return task;
} else {
// cause an error by calling it directly.
return delegate.apply(window, args);
}
});
setNative =
patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) {
if (typeof args[0] === 'function') {
var zone = Zone.current;
var options: TimerOptions = {
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 = (<TimerOptions>task.data).handleId;
if ((<any>handle).ref && (<any>handle).unref) {
(<any>task).ref = (<any>handle).ref.bind(handle);
(<any>task).unref = (<any>handle).unref.bind(handle);
}
return task;
} else {
// cause an error by calling it directly.
return delegate.apply(window, args);
}
});
clearNative = patchMethod(window, cancelName, (delegate: Function) => function(self: any, args: any[]) {
var task: 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);
}
});
clearNative =
patchMethod(window, cancelName, (delegate: Function) => function(self: any, args: any[]) {
var task: Task = typeof args[0] === 'number' ? tasksByHandleId[args[0]] : 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);
}
});
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Suppress closure compiler errors about unknown 'process' variable

@@ -40,3 +48,3 @@ * @fileoverview

export const isNode: boolean =
(typeof process !== 'undefined' && {}.toString.call(process) === '[object process]');
(typeof process !== 'undefined' && {}.toString.call(process) === '[object process]');

@@ -48,6 +56,3 @@ export const isBrowser: boolean =

export function patchProperty(obj, prop) {
const desc = Object.getOwnPropertyDescriptor(obj, prop) || {
enumerable: true,
configurable: true
};
const desc = Object.getOwnPropertyDescriptor(obj, prop) || {enumerable: true, configurable: true};

@@ -66,3 +71,3 @@ // A property descriptor cannot have getter/setter and be writable

desc.set = function (fn) {
desc.set = function(fn) {
if (this[_prop]) {

@@ -73,8 +78,7 @@ this.removeEventListener(eventName, this[_prop]);

if (typeof fn === 'function') {
const wrapFn = function (event) {
const wrapFn = function(event) {
let result;
result = fn.apply(this, arguments);
if (result != undefined && !result)
event.preventDefault();
if (result != undefined && !result) event.preventDefault();
};

@@ -89,4 +93,5 @@

// The getter would return undefined for unassigned properties but the default value of an unassigned property is null
desc.get = function () {
// 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;

@@ -105,7 +110,7 @@ };

}
for(let j = 0; j < onProperties.length; j++) {
for (let j = 0; j < onProperties.length; j++) {
patchProperty(obj, onProperties[j]);
}
if (properties) {
for(let i = 0; i < properties.length; i++) {
for (let i = 0; i < properties.length; i++) {
patchProperty(obj, 'on' + properties[i]);

@@ -131,4 +136,4 @@ }

function findExistingRegisteredTask(target: any, handler: any, name: string, capture: boolean,
remove: boolean): Task {
function findExistingRegisteredTask(
target: any, handler: any, name: string, capture: boolean, remove: boolean): Task {
const eventTasks: Task[] = target[EVENT_TASKS];

@@ -139,6 +144,3 @@ if (eventTasks) {

const data = <ListenerTaskMeta>eventTask.data;
if (data.handler === handler
&& data.useCapturing === capture
&& data.eventName === name)
{
if (data.handler === handler && data.useCapturing === capture && data.eventName === name) {
if (remove) {

@@ -163,3 +165,5 @@ eventTasks.splice(i, 1);

export function makeZoneAwareAddListener(addFnName: string, removeFnName: string, useCapturingParam: boolean = true, allowDuplicates: boolean = false) {
export function makeZoneAwareAddListener(
addFnName: string, removeFnName: string, useCapturingParam: boolean = true,
allowDuplicates: boolean = false) {
const addFnSymbol = zoneSymbol(addFnName);

@@ -172,4 +176,3 @@ const removeFnSymbol = zoneSymbol(removeFnName);

attachRegisteredEvent(meta.target, eventTask);
return meta.target[addFnSymbol](meta.eventName, eventTask.invoke,
meta.useCapturing);
return meta.target[addFnSymbol](meta.eventName, eventTask.invoke, meta.useCapturing);
}

@@ -179,6 +182,5 @@

const meta = <ListenerTaskMeta>eventTask.data;
findExistingRegisteredTask(meta.target, eventTask.invoke, meta.eventName,
meta.useCapturing, true);
meta.target[removeFnSymbol](meta.eventName, eventTask.invoke,
meta.useCapturing);
findExistingRegisteredTask(
meta.target, eventTask.invoke, meta.eventName, meta.useCapturing, true);
meta.target[removeFnSymbol](meta.eventName, eventTask.invoke, meta.useCapturing);
}

@@ -205,8 +207,9 @@

// will fail tests prematurely.
validZoneHandler = handler && handler.toString() === "[object FunctionWrapper]";
} catch(e) {
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
// Ignore special listeners of IE11 & Edge dev tools, see
// https://github.com/angular/zone.js/issues/150
if (!delegate || validZoneHandler) {

@@ -217,4 +220,4 @@ return target[addFnSymbol](eventName, handler, useCapturing);

if (!allowDuplicates) {
const eventTask: Task
= findExistingRegisteredTask(target, handler, eventName, useCapturing, false);
const eventTask: Task =
findExistingRegisteredTask(target, handler, eventName, useCapturing, false);
if (eventTask) {

@@ -225,3 +228,3 @@ // we already registered, so this will have noop.

}
const zone: Zone = Zone.current;

@@ -267,9 +270,13 @@ const source = target.constructor['name'] + '.' + addFnName + ':' + eventName;

const target = self || _global;
if (!target[EVENT_TASKS]) {
return [];
}
return target[EVENT_TASKS]
.filter(task => task.data.eventName === eventName)
.map(task => task.data.handler);
}
.filter(task => task.data.eventName === eventName)
.map(task => task.data.handler);
};
}
const zoneAwareAddEventListener = makeZoneAwareAddListener(ADD_EVENT_LISTENER, REMOVE_EVENT_LISTENER);
const zoneAwareAddEventListener =
makeZoneAwareAddListener(ADD_EVENT_LISTENER, REMOVE_EVENT_LISTENER);
const zoneAwareRemoveEventListener = makeZoneAwareRemoveListener(REMOVE_EVENT_LISTENER);

@@ -295,15 +302,26 @@

_global[className] = function () {
_global[className] = function() {
const a = bindArguments(<any>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.');
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.');
}
};
const instance = new OriginalClass(function () {});
const instance = new OriginalClass(function() {});

@@ -314,5 +332,5 @@ let prop;

if (className === 'XMLHttpRequest' && prop === 'responseBlob') continue;
(function (prop) {
(function(prop) {
if (typeof instance[prop] === 'function') {
_global[className].prototype[prop] = function () {
_global[className].prototype[prop] = function() {
return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments);

@@ -322,3 +340,3 @@ };

Object.defineProperty(_global[className].prototype, prop, {
set: function (fn) {
set: function(fn) {
if (typeof fn === 'function') {

@@ -330,3 +348,3 @@ this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop);

},
get: function () {
get: function() {
return this[originalInstanceKey][prop];

@@ -346,11 +364,5 @@ }

export function createNamedFn(
name: string,
delegate: (self: any, args: any[]) => any): Function
{
export function createNamedFn(name: string, delegate: (self: any, args: any[]) => any): Function {
try {
return (Function(
'f',
`return function ${name}(){return f(this, arguments)}`)
)(delegate);
return (Function('f', `return function ${name}(){return f(this, arguments)}`))(delegate);
} catch (e) {

@@ -364,9 +376,7 @@ // if we fail, we must be CSP, just return delegate.

export function patchMethod(target: any, name: string,
patchFn: (delegate: Function,
delegateName: string,
name: string) => (self: any, args: any[]) => any): Function
{
export function patchMethod(
target: any, name: string, patchFn: (delegate: Function, delegateName: string, name: string) =>
(self: any, args: any[]) => any): Function {
let proto = target;
while (proto && !proto.hasOwnProperty(name)) {
while (proto && Object.getOwnPropertyNames(proto).indexOf(name) === -1) {
proto = Object.getPrototypeOf(proto);

@@ -380,3 +390,3 @@ }

let delegate: Function;
if (proto && ! (delegate = proto[delegateName])) {
if (proto && !(delegate = proto[delegateName])) {
delegate = proto[delegateName] = proto[name];

@@ -387,2 +397,1 @@ proto[name] = createNamedFn(name, patchFn(delegate, delegateName, name));

}

@@ -0,8 +1,25 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
'use strict';
(() => {
var __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 __());
};
// 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'.");
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;

@@ -12,8 +29,8 @@

const ProxyZoneSpec: {new (): ZoneSpec} = Zone['ProxyZoneSpec'];
if (!SyncTestZoneSpec) throw new Error("Missing: SyncTestZoneSpec");
if (!ProxyZoneSpec) throw new Error("Missing: ProxyZoneSpec");
if (!SyncTestZoneSpec) throw new Error('Missing: SyncTestZoneSpec');
if (!ProxyZoneSpec) throw new Error('Missing: ProxyZoneSpec');
const 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
// 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`.

@@ -24,8 +41,8 @@ const syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe'));

// It will be a proxy zone, so that the tests function can retroactively install
// different zones.
// 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
// - 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
// - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add
// fakeAsync behavior to the childZone.

@@ -39,11 +56,12 @@ let testProxyZone: Zone = null;

jasmineEnv[methodName] = function(description: string, specDefinitions: Function) {
return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions));
}
return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions));
};
});
['it', 'xit', 'fit'].forEach((methodName) => {
let originalJasmineFn: Function = jasmineEnv[methodName];
jasmineEnv[methodName] = function(description: string, specDefinitions: Function, timeout: number) {
jasmineEnv[methodName] = function(
description: string, specDefinitions: Function, timeout: number) {
arguments[1] = wrapTestInZone(specDefinitions);
return originalJasmineFn.apply(this, arguments);
}
};
});

@@ -55,8 +73,8 @@ ['beforeEach', 'afterEach'].forEach((methodName) => {

return originalJasmineFn.apply(this, arguments);
}
};
});
/**
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a
* synchronous-only zone.
/**
* Gets a function wrapping the body of a Jasmine `describe` block to execute in a
* synchronous-only zone.
*/

@@ -66,8 +84,8 @@ function wrapDescribeInZone(describeBody: Function): Function {

return syncZone.run(describeBody, this, arguments as any as any[]);
}
};
}
/**
* Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to
* execute in a ProxyZone zone.
/**
* 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`

@@ -79,5 +97,7 @@ */

// 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]); };
return (testBody.length == 0) ? function() {
return testProxyZone.run(testBody, this);
} : function(done) {
return testProxyZone.run(testBody, this, [done]);
};
}

@@ -95,8 +115,9 @@ interface QueueRunner {

timeout: {setTimeout: Function, clearTimeout: Function};
fail: ()=> void;
fail: () => void;
}
const QueueRunner = (jasmine as any).QueueRunner as { new(attrs: QueueRunnerAttrs): QueueRunner };
(jasmine as any).QueueRunner = class ZoneQueueRunner extends QueueRunner {
constructor(attrs: QueueRunnerAttrs) {
const QueueRunner = (jasmine as any).QueueRunner as {new (attrs: QueueRunnerAttrs): QueueRunner};
(jasmine as any).QueueRunner = (function(_super) {
__extends(ZoneQueueRunner, _super);
function ZoneQueueRunner(attrs) {
attrs.onComplete = ((fn) => () => {

@@ -107,7 +128,6 @@ // All functions are done, clear the test zone.

})(attrs.onComplete);
super(attrs);
_super.call(this, attrs);
}
execute() {
if(Zone.current !== ambientZone) throw new Error("Unexpected Zone: " + Zone.current.name);
ZoneQueueRunner.prototype.execute = function() {
if (Zone.current !== ambientZone) throw new Error('Unexpected Zone: ' + Zone.current.name);
testProxyZone = ambientZone.fork(new ProxyZoneSpec());

@@ -120,8 +140,10 @@ if (!Zone.currentTask) {

// For this reason we always force a task when running jasmine tests.
Zone.current.scheduleMicroTask('jasmine.execute().forceTask', () => super.execute());
Zone.current.scheduleMicroTask(
'jasmine.execute().forceTask', () => QueueRunner.prototype.execute.call(this));
} else {
super.execute();
_super.prototype.execute.call(this);
}
}
};
};
return ZoneQueueRunner;
}(QueueRunner));
})();

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {makeZoneAwareAddListener, makeZoneAwareListeners, makeZoneAwareRemoveListener, patchMethod} from '../common/utils';

@@ -12,4 +20,6 @@

const zoneAwareAddListener = makeZoneAwareAddListener(EE_ADD_LISTENER, EE_REMOVE_LISTENER, false, true);
const zoneAwarePrependListener = makeZoneAwareAddListener(EE_PREPEND_LISTENER, EE_REMOVE_LISTENER, false, true);
const zoneAwareAddListener =
makeZoneAwareAddListener(EE_ADD_LISTENER, EE_REMOVE_LISTENER, false, true);
const zoneAwarePrependListener =
makeZoneAwareAddListener(EE_PREPEND_LISTENER, EE_REMOVE_LISTENER, false, true);
const zoneAwareRemoveListener = makeZoneAwareRemoveListener(EE_REMOVE_LISTENER, false);

@@ -35,3 +45,4 @@ const zoneAwareListeners = makeZoneAwareListeners(EE_LISTENERS);

events = require('events');
} catch (err) {}
} catch (err) {
}

@@ -38,0 +49,0 @@ if (events && events.EventEmitter) {

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {bindArguments} from '../common/utils';

@@ -6,52 +14,22 @@

fs = require('fs');
} catch (err) {}
} catch (err) {
}
// TODO(alxhub): Patch `watch` and `unwatchFile`.
const TO_PATCH = [
'access',
'appendFile',
'chmod',
'chown',
'close',
'exists',
'fchmod',
'fchown',
'fdatasync',
'fstat',
'fsync',
'ftruncate',
'futimes',
'lchmod',
'lchown',
'link',
'lstat',
'mkdir',
'mkdtemp',
'open',
'read',
'readdir',
'readFile',
'readlink',
'realpath',
'rename',
'rmdir',
'stat',
'symlink',
'truncate',
'unlink',
'utimes',
'write',
'writeFile',
'access', 'appendFile', 'chmod', 'chown', 'close', 'exists', 'fchmod',
'fchown', 'fdatasync', 'fstat', 'fsync', 'ftruncate', 'futimes', 'lchmod',
'lchown', 'link', 'lstat', 'mkdir', 'mkdtemp', 'open', 'read',
'readdir', 'readFile', 'readlink', 'realpath', 'rename', 'rmdir', 'stat',
'symlink', 'truncate', 'unlink', 'utimes', 'write', 'writeFile',
];
if (fs) {
TO_PATCH
.filter(name => !!fs[name] && typeof fs[name] === 'function')
.forEach(name => {
fs[name] = ((delegate: Function) => {
return function() {
return delegate.apply(this, bindArguments(<any>arguments, 'fs.' + name));
};
})(fs[name]);
});
TO_PATCH.filter(name => !!fs[name] && typeof fs[name] === 'function').forEach(name => {
fs[name] = ((delegate: Function) => {
return function() {
return delegate.apply(this, bindArguments(<any>arguments, 'fs.' + name));
};
})(fs[name]);
});
}

@@ -0,7 +1,15 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import '../zone';
import {patchTimer} from '../common/timers';
import './events';
import './fs';
import {patchTimer} from '../common/timers';
const set = 'set';

@@ -30,3 +38,4 @@ const clear = 'clear';

crypto = require('crypto');
} catch (err) {}
} catch (err) {
}

@@ -64,3 +73,4 @@ // TODO(gdi2290): implement a better way to patch these methods

httpClient = require('_http_client');
} catch (err) {}
} catch (err) {
}

@@ -76,3 +86,3 @@ if (httpClient && httpClient.ClientRequest) {

}
}
};
}

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
class AsyncTestZoneSpec implements ZoneSpec {

@@ -35,4 +43,5 @@ _finishCallback: Function;

// onHasTask changes and it calls whenever the task queues are dirty.
onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
delegate: Function, applyThis: any, applyArgs: any[], source: string): any {
onInvoke(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function,
applyThis: any, applyArgs: any[], source: string): any {
try {

@@ -45,4 +54,4 @@ return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);

onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean {
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any):
boolean {
// Let the parent try to handle the error.

@@ -49,0 +58,0 @@ const result = parentZoneDelegate.handleError(targetZone, error);

@@ -0,5 +1,13 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
(function(global: any) {
interface ScheduledFunction {
endTime: number;
id: number,
id: number;
func: Function;

@@ -9,7 +17,7 @@ args: any[];

}
class Scheduler {
// Next scheduler id.
public nextId: number = 0;
// Scheduler queue with the tuple of end time and callback function - sorted by end time.

@@ -19,17 +27,12 @@ private _schedulerQueue: ScheduledFunction[] = [];

private _currentTime: number = 0;
constructor() {}
scheduleFunction(cb: Function, delay: number, args: any[] = [], id: number = -1) : number {
scheduleFunction(cb: Function, delay: number, args: any[] = [], id: number = -1): number {
let currentId: number = id < 0 ? this.nextId++ : id;
let endTime = this._currentTime + delay;
// Insert so that scheduler queue remains sorted by end time.
let newEntry: ScheduledFunction = {
endTime: endTime,
id: currentId,
func: cb,
args: args,
delay: delay
}
let newEntry:
ScheduledFunction = {endTime: endTime, id: currentId, func: cb, args: args, delay: delay};
let i = 0;

@@ -45,3 +48,3 @@ for (; i < this._schedulerQueue.length; i++) {

}
removeScheduledFunctionWithId(id: number): void {

@@ -55,8 +58,8 @@ for (let i = 0; i < this._schedulerQueue.length; i++) {

}
tick(millis: number = 0): void {
this._currentTime += millis;
while (this._schedulerQueue.length > 0) {
let current = this._schedulerQueue[0];
if (this._currentTime < current.endTime) {
let finalTime = this._currentTime + millis;
while (this._schedulerQueue.length > 0) {
let current = this._schedulerQueue[0];
if (finalTime < current.endTime) {
// Done processing the queue since it's sorted by endTime.

@@ -67,2 +70,3 @@ break;

let current = this._schedulerQueue.shift();
this._currentTime = current.endTime;
let retval = current.func.apply(global, current.args);

@@ -75,5 +79,6 @@ if (!retval) {

}
this._currentTime = finalTime;
}
}
class FakeAsyncTestZoneSpec implements ZoneSpec {

@@ -85,8 +90,9 @@ static assertInZone(): void {

}
private _scheduler: Scheduler = new Scheduler();
private _microtasks: Function[] = [];
private _lastError: Error = null;
private _uncaughtPromiseErrors: {rejection: any}[] = Promise[Zone['__symbol__']('uncaughtPromiseErrors')];
private _uncaughtPromiseErrors: {rejection: any}[] =
Promise[Zone['__symbol__']('uncaughtPromiseErrors')];
pendingPeriodicTimers: number[] = [];

@@ -99,8 +105,8 @@ pendingTimers: number[] = [];

private _fnAndFlush(fn: Function,
completers: {onSuccess?: Function, onError?: Function}): Function {
private _fnAndFlush(fn: Function, completers: {onSuccess?: Function, onError?: Function}):
Function {
return (...args): boolean => {
fn.apply(global, args);
if (this._lastError === null) { // Success
if (this._lastError === null) { // Success
if (completers.onSuccess != null) {

@@ -111,19 +117,19 @@ completers.onSuccess.apply(global);

this.flushMicrotasks();
} else { // Failure
if (completers.onError != null) {
} else { // Failure
if (completers.onError != null) {
completers.onError.apply(global);
}
}
// Return true if there were no errors, false otherwise.
// Return true if there were no errors, false otherwise.
return this._lastError === null;
}
};
}
private static _removeTimer(timers: number[], id:number): void {
private static _removeTimer(timers: number[], id: number): void {
let index = timers.indexOf(id);
if (index > -1) {
timers.splice(index, 1);
}
if (index > -1) {
timers.splice(index, 1);
}
}
private _dequeueTimer(id: number): Function {

@@ -134,5 +140,5 @@ return () => {

}
private _requeuePeriodicTimer(
fn: Function, interval: number, args: any[], id: number): Function {
private _requeuePeriodicTimer(fn: Function, interval: number, args: any[], id: number):
Function {
return () => {

@@ -143,5 +149,5 @@ // Requeue the timer callback if it's not been canceled.

}
}
};
}
private _dequeuePeriodicTimer(id: number): Function {

@@ -152,3 +158,3 @@ return () => {

}
private _setTimeout(fn: Function, delay: number, args: any[]): number {

@@ -162,3 +168,3 @@ let removeTimerFn = this._dequeueTimer(this._scheduler.nextId);

}
private _clearTimeout(id: number): void {

@@ -168,3 +174,3 @@ FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id);

}
private _setInterval(fn: Function, interval: number, ...args): number {

@@ -174,6 +180,6 @@ let id = this._scheduler.nextId;

let cb = this._fnAndFlush(fn, completers);
// Use the callback created above to requeue on success.
// 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.

@@ -196,3 +202,3 @@ this._scheduler.scheduleFunction(cb, interval, args);

}
tick(millis: number = 0): void {

@@ -214,3 +220,3 @@ FakeAsyncTestZoneSpec.assertInZone();

}
}
};
while (this._microtasks.length > 0) {

@@ -227,3 +233,3 @@ let microtask = this._microtasks.shift();

properties: { [key: string]: any } = { 'FakeAsyncTestZoneSpec': this };
properties: {[key: string]: any} = {'FakeAsyncTestZoneSpec': this};

@@ -239,7 +245,7 @@ onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task {

task.data['handleId'] =
this._setTimeout(task.invoke, task.data['delay'], task.data['args']);
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']);
this._setInterval(task.invoke, task.data['delay'], task.data['args']);
break;

@@ -269,7 +275,8 @@ case 'XMLHttpRequest.send':

}
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
onHandleError(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean {
this._lastError = error;
return false; // Don't propagate error to parent zone.
this._lastError = error;
return false; // Don't propagate error to parent zone.
}

@@ -276,0 +283,0 @@ }

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const NEWLINE = '\n';

@@ -9,6 +17,5 @@ const SEP = ' ------------- ';

timestamp: Date = new Date();
}
function getStacktraceWithUncaughtError (): Error {
function getStacktraceWithUncaughtError(): Error {
return new Error('STACKTRACE TRACKING');

@@ -29,5 +36,5 @@ }

const coughtError = getStacktraceWithCaughtError();
const getStacktrace = error.stack
? getStacktraceWithUncaughtError
: (coughtError.stack ? getStacktraceWithCaughtError: getStacktraceWithUncaughtError);
const getStacktrace = error.stack ?
getStacktraceWithUncaughtError :
(coughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError);

@@ -38,3 +45,3 @@ function getFrames(error: Error): string[] {

function addErrorStack(lines:string[], error:Error):void {
function addErrorStack(lines: string[], error: Error): void {
let trace: string[] = getFrames(error);

@@ -44,3 +51,3 @@ for (let i = 0; i < trace.length; i++) {

// Filter out the Frames which are part of stack capturing.
if (! (i < IGNORE_FRAMES.length && IGNORE_FRAMES[i] === frame)) {
if (!(i < IGNORE_FRAMES.length && IGNORE_FRAMES[i] === frame)) {
lines.push(trace[i]);

@@ -59,3 +66,4 @@ }

const lastTime = traceFrames.timestamp;
longTrace.push(`${SEP} Elapsed: ${timestamp - lastTime.getTime()} ms; At: ${lastTime} ${SEP}`);
longTrace.push(
`${SEP} Elapsed: ${timestamp - lastTime.getTime()} ms; At: ${lastTime} ${SEP}`);
addErrorStack(longTrace, traceFrames.error);

@@ -72,7 +80,6 @@

name: 'long-stack-trace',
longStackTraceLimit: 10, // Max number of task to keep the stack trace for.
longStackTraceLimit: 10, // Max number of task to keep the stack trace for.
onScheduleTask: function(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task): any
{
onScheduleTask: function(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any {
const currentTask = Zone.currentTask;

@@ -89,5 +96,4 @@ let trace = currentTask && currentTask.data && currentTask.data[creationTrace] || [];

onHandleError: function(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): any
{
onHandleError: function(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): any {
const parentTask = Zone.currentTask || error.task;

@@ -102,4 +108,5 @@ if (error instanceof Error && parentTask) {

descriptor = {
get: function () {
return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace],
get: function() {
return renderLongStackTrace(
parentTask.data && parentTask.data[creationTrace],
delegateGet ? delegateGet.apply(this) : value);

@@ -111,9 +118,12 @@ }

}
} catch (e) { }
var longStack: string = stackSetSucceded ? null : renderLongStackTrace(
parentTask.data && parentTask.data[creationTrace], error.stack);
} catch (e) {
}
var longStack: string = stackSetSucceded ?
null :
renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack);
if (!stackSetSucceded) {
try {
stackSetSucceded = error.stack = longStack;
} catch (e) { }
} catch (e) {
}
}

@@ -123,3 +133,4 @@ if (!stackSetSucceded) {

stackSetSucceded = (error as any).longStack = longStack;
} catch (e) { }
} catch (e) {
}
}

@@ -126,0 +137,0 @@ }

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
class ProxyZoneSpec implements ZoneSpec {

@@ -14,3 +22,3 @@ name: string = 'ProxyZone';

static isLoaded(): boolean {
return ProxyZoneSpec.get() instanceof ProxyZoneSpec;
return ProxyZoneSpec.get() instanceof ProxyZoneSpec;
}

@@ -50,4 +58,4 @@

onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
zoneSpec: ZoneSpec): Zone {
onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, zoneSpec: ZoneSpec):
Zone {
if (this._delegateSpec && this._delegateSpec.onFork) {

@@ -61,6 +69,8 @@ return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec);

onIntercept(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
delegate: Function, source: string): Function {
onIntercept(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function,
source: string): Function {
if (this._delegateSpec && this._delegateSpec.onIntercept) {
return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source);
return this._delegateSpec.onIntercept(
parentZoneDelegate, currentZone, targetZone, delegate, source);
} else {

@@ -72,6 +82,8 @@ return parentZoneDelegate.intercept(targetZone, delegate, source);

onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
delegate: Function, applyThis: any, applyArgs: any[], source: string): any {
onInvoke(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function,
applyThis: any, applyArgs: any[], source: string): any {
if (this._delegateSpec && this._delegateSpec.onInvoke) {
return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source);
return this._delegateSpec.onInvoke(
parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source);
} else {

@@ -82,4 +94,4 @@ return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source);

onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean {
onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any):
boolean {
if (this._delegateSpec && this._delegateSpec.onHandleError) {

@@ -92,4 +104,4 @@ return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error);

onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task): Task {
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
Task {
if (this._delegateSpec && this._delegateSpec.onScheduleTask) {

@@ -102,6 +114,8 @@ return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task);

onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task, applyThis: any, applyArgs: any): any {
onInvokeTask(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task,
applyThis: any, applyArgs: any): any {
if (this._delegateSpec && this._delegateSpec.onFork) {
return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs);
return this._delegateSpec.onInvokeTask(
parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs);
} else {

@@ -112,4 +126,4 @@ return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs);

onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task): any {
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
any {
if (this._delegateSpec && this._delegateSpec.onCancelTask) {

@@ -122,4 +136,3 @@ return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task);

onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone,
hasTaskState: HasTaskState): void {
onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState): void {
if (this._delegateSpec && this._delegateSpec.onHasTask) {

@@ -126,0 +139,0 @@ this._delegateSpec.onHasTask(delegate, current, target, hasTaskState);

@@ -0,1 +1,9 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
class SyncTestZoneSpec implements ZoneSpec {

@@ -2,0 +10,0 @@ runZone = Zone.current;

/**
* A `TaskTrackingZoneSpec` allows one to track all outstanding Tasks.
*
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* 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

@@ -9,6 +17,6 @@ * or an automated way of releasing all of the event listeners at the end of the test.

name = 'TaskTrackingZone';
microTasks: Task[] = [];
macroTasks: Task[] = [];
microTasks: Task[] = [];
macroTasks: Task[] = [];
eventTasks: Task[] = [];
properties: {[key: string]: any} = {'TaskTrackingZone': this};
properties: {[key: string]: any} = {'TaskTrackingZone': this};

@@ -19,7 +27,10 @@ static get() {

private getTasksFor(type: string): Task [] {
private getTasksFor(type: string): Task[] {
switch (type) {
case 'microTask': return this.microTasks;
case 'macroTask': return this.macroTasks;
case 'eventTask': return this.eventTasks;
case 'microTask':
return this.microTasks;
case 'macroTask':
return this.macroTasks;
case 'eventTask':
return this.eventTasks;
}

@@ -29,3 +40,4 @@ throw new Error('Unknown task format: ' + type);

onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): Task {
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
Task {
task['creationLocation'] = new Error(`Task '${task.type}' from '${task.source}'.`);

@@ -37,5 +49,6 @@ const tasks = this.getTasksFor(task.type);

onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any {
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
any {
const tasks = this.getTasksFor(task.type);
for(var i = 0; i < tasks.length; i++) {
for (var i = 0; i < tasks.length; i++) {
if (tasks[i] == task) {

@@ -49,8 +62,9 @@ tasks.splice(i, 1);

onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task, applyThis: any, applyArgs: any): any
{
if (task.type === 'eventTask') return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs);
onInvokeTask(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task,
applyThis: any, applyArgs: any): any {
if (task.type === 'eventTask')
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs);
const tasks = this.getTasksFor(task.type);
for(var i = 0; i < tasks.length; i++) {
for (var i = 0; i < tasks.length; i++) {
if (tasks[i] == task) {

@@ -57,0 +71,0 @@ tasks.splice(i, 1);

@@ -0,5 +1,17 @@

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
(function(global) {
interface Wtf { trace: WtfTrace; }
interface WtfScope {};
interface WtfRange {};
interface Wtf {
trace: WtfTrace;
}
interface WtfScope {}
;
interface WtfRange {}
;
interface WtfTrace {

@@ -22,3 +34,3 @@ events: WtfEvents;

let wtfEvents: WtfEvents = null;
const wtfEnabled: boolean = (function (): boolean {
const wtfEnabled: boolean = (function(): boolean {
const wtf: Wtf = global['wtf'];

@@ -38,3 +50,4 @@ if (wtf) {

static forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)');
static forkInstance =
wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)');
static scheduleInstance: {[key: string]: WtfEventFn} = {};

@@ -45,4 +58,5 @@ static cancelInstance: {[key: string]: WtfEventFn} = {};

onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
zoneSpec: ZoneSpec): Zone {
onFork(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
zoneSpec: ZoneSpec): Zone {
const retValue = parentZoneDelegate.fork(targetZone, zoneSpec);

@@ -53,10 +67,12 @@ WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name);

onInvoke(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
delegate: Function, applyThis: any, applyArgs: any[], source: string): any {
onInvoke(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function,
applyThis: any, applyArgs: any[], source: string): any {
let scope = WtfZoneSpec.invokeScope[source];
if (!scope) {
scope = WtfZoneSpec.invokeScope[source]
= wtfEvents.createScope(`Zone:invoke:${source}(ascii zone)`);
scope = WtfZoneSpec.invokeScope[source] =
wtfEvents.createScope(`Zone:invoke:${source}(ascii zone)`);
}
return wtfTrace.leaveScope(scope(zonePathName(targetZone)),
return wtfTrace.leaveScope(
scope(zonePathName(targetZone)),
parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source));

@@ -66,14 +82,15 @@ }

onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean {
onHandleError(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any): boolean {
return parentZoneDelegate.handleError(targetZone, error);
}
onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task): any {
onScheduleTask(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any {
const key = task.type + ':' + task.source;
let instance = WtfZoneSpec.scheduleInstance[key];
if (!instance) {
instance = WtfZoneSpec.scheduleInstance[key]
= wtfEvents.createInstance(`Zone:schedule:${key}(ascii zone, any data)`);
instance = WtfZoneSpec.scheduleInstance[key] =
wtfEvents.createInstance(`Zone:schedule:${key}(ascii zone, any data)`);
}

@@ -86,22 +103,23 @@ const retValue = parentZoneDelegate.scheduleTask(targetZone, task);

onInvokeTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task, applyThis: any, applyArgs: any[]): any
{
onInvokeTask(
parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task,
applyThis: any, applyArgs: any[]): any {
const source = task.source;
let scope = WtfZoneSpec.invokeTaskScope[source];
if (!scope) {
scope = WtfZoneSpec.invokeTaskScope[source]
= wtfEvents.createScope(`Zone:invokeTask:${source}(ascii zone)`);
scope = WtfZoneSpec.invokeTaskScope[source] =
wtfEvents.createScope(`Zone:invokeTask:${source}(ascii zone)`);
}
return wtfTrace.leaveScope(scope(zonePathName(targetZone)),
return wtfTrace.leaveScope(
scope(zonePathName(targetZone)),
parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs));
}
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task): any {
onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task):
any {
const key = task.source;
let instance = WtfZoneSpec.cancelInstance[key];
if (!instance) {
instance = WtfZoneSpec.cancelInstance[key]
= wtfEvents.createInstance(`Zone:cancel:${key}(ascii zone, any options)`);
instance = WtfZoneSpec.cancelInstance[key] =
wtfEvents.createInstance(`Zone:cancel:${key}(ascii zone, any options)`);
}

@@ -117,3 +135,3 @@ const retValue = parentZoneDelegate.cancelTask(targetZone, task);

const out = {};
for(const key in obj) {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {

@@ -139,3 +157,3 @@ let value = obj[key];

zone = zone.parent;
while(zone != null) {
while (zone != null) {
name = zone.name + '::' + name;

@@ -142,0 +160,0 @@ zone = zone.parent;

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* Zone is a mechanism for intercepting and keeping track of asynchronous work.

@@ -209,5 +217,11 @@ *

runTask(task: Task, applyThis?: any, applyArgs?: any): any;
scheduleMicroTask(source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void): MicroTask;
scheduleMacroTask(source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, customCancel: (task: Task) => void): MacroTask;
scheduleEventTask(source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, customCancel: (task: Task) => void): EventTask;
scheduleMicroTask(
source: string, callback: Function, data?: TaskData,
customSchedule?: (task: Task) => void): MicroTask;
scheduleMacroTask(
source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void,
customCancel: (task: Task) => void): MacroTask;
scheduleEventTask(
source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void,
customCancel: (task: Task) => void): EventTask;
/**

@@ -269,4 +283,5 @@ * Allows the zone to intercept canceling of scheduled Task.

*/
onFork?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
zoneSpec: ZoneSpec) => Zone;
onFork?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
zoneSpec: ZoneSpec) => Zone;

@@ -282,4 +297,5 @@ /**

*/
onIntercept?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
delegate: Function, source: string) => Function;
onIntercept?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function,
source: string) => Function;

@@ -297,4 +313,5 @@ /**

*/
onInvoke?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
delegate: Function, applyThis: any, applyArgs: any[], source: string) => any;
onInvoke?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function,
applyThis: any, applyArgs: any[], source: string) => any;

@@ -309,4 +326,5 @@ /**

*/
onHandleError?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any) => boolean;
onHandleError?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
error: any) => boolean;

@@ -321,7 +339,8 @@ /**

*/
onScheduleTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task) => Task;
onScheduleTask?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task) => Task;
onInvokeTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task, applyThis: any, applyArgs: any) => any;
onInvokeTask?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task,
applyThis: any, applyArgs: any) => any;

@@ -336,4 +355,4 @@ /**

*/
onCancelTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone,
task: Task) => any;
onCancelTask?:
(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task) => any;

@@ -348,5 +367,6 @@ /**

*/
onHasTask?: (delegate: ZoneDelegate, current: Zone, target: Zone,
hasTaskState: HasTaskState) => void;
};
onHasTask?:
(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState) => void;
}
;

@@ -388,3 +408,4 @@ /**

intercept(targetZone: Zone, callback: Function, source: string): Function;
invoke(targetZone: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string): any;
invoke(targetZone: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string):
any;
handleError(targetZone: Zone, error: any): boolean;

@@ -398,6 +419,3 @@ scheduleTask(targetZone: Zone, task: Task): Task;

type HasTaskState = {
microTask: boolean;
macroTask: boolean;
eventTask: boolean;
change: TaskType;
microTask: boolean; macroTask: boolean; eventTask: boolean; change: TaskType;
};

@@ -408,3 +426,4 @@

*/
type TaskType = string; /* TS v1.8 => "microTask" | "macroTask" | "eventTask" */;
type TaskType = string; /* TS v1.8 => "microTask" | "macroTask" | "eventTask" */
;

@@ -529,7 +548,8 @@ /**

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.)");
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.)');
}

@@ -539,7 +559,15 @@ }

static get current(): AmbientZone { return _currentZone; };
static get currentTask(): Task { return _currentTask; };
static get current(): AmbientZone {
return _currentZone;
};
static get currentTask(): Task {
return _currentTask;
};
public get parent(): AmbientZone { return this._parent; };
public get name(): string { return this._name; };
public get parent(): AmbientZone {
return this._parent;
};
public get name(): string {
return this._name;
};

@@ -552,8 +580,8 @@

constructor(parent: Zone, zoneSpec: ZoneSpec)
{
constructor(parent: Zone, zoneSpec: ZoneSpec) {
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);
this._zoneDelegate =
new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec);
}

@@ -582,4 +610,3 @@

public wrap(callback: Function, source: string): Function
{
public wrap(callback: Function, source: string): Function {
if (typeof callback !== 'function') {

@@ -592,8 +619,7 @@ throw new Error('Expecting function got: ' + callback);

return zone.runGuarded(_callback, this, <any>arguments, source);
}
};
}
public run(callback: Function, applyThis: any = null, applyArgs: any[] = null,
source: string = null)
{
public run(
callback: Function, applyThis: any = null, applyArgs: any[] = null, source: string = null) {
const oldZone = _currentZone;

@@ -608,5 +634,4 @@ _currentZone = this;

public runGuarded(callback: Function, applyThis: any = null, applyArgs: any[] = null,
source: string = null)
{
public runGuarded(
callback: Function, applyThis: any = null, applyArgs: any[] = null, source: string = null) {
const oldZone = _currentZone;

@@ -631,4 +656,5 @@ _currentZone = this;

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 + ')');
throw new Error(
'A task can only be run in the zone which created it! (Creation: ' + task.zone.name +
'; Execution: ' + this.name + ')');
const previousTask = _currentTask;

@@ -656,19 +682,22 @@ _currentTask = task;

scheduleMicroTask(source: string, callback: Function, data?: TaskData,
customSchedule?: (task: Task) => void): MicroTask {
return <MicroTask>this._zoneDelegate.scheduleTask(this,
new ZoneTask('microTask', this, source, callback, data, customSchedule, null));
scheduleMicroTask(
source: string, callback: Function, data?: TaskData,
customSchedule?: (task: Task) => void): MicroTask {
return <MicroTask>this._zoneDelegate.scheduleTask(
this, new ZoneTask('microTask', this, source, callback, data, customSchedule, null));
}
scheduleMacroTask(source: string, callback: Function, data: TaskData,
customSchedule: (task: Task) => void,
customCancel: (task: Task) => void): MacroTask {
return <MacroTask>this._zoneDelegate.scheduleTask(this,
scheduleMacroTask(
source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void,
customCancel: (task: Task) => void): MacroTask {
return <MacroTask>this._zoneDelegate.scheduleTask(
this,
new ZoneTask('macroTask', this, source, callback, data, customSchedule, customCancel));
}
scheduleEventTask(source: string, callback: Function, data: TaskData,
customSchedule: (task: Task) => void,
customCancel: (task: Task) => void): EventTask {
return <EventTask>this._zoneDelegate.scheduleTask(this,
scheduleEventTask(
source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void,
customCancel: (task: Task) => void): EventTask {
return <EventTask>this._zoneDelegate.scheduleTask(
this,
new ZoneTask('eventTask', this, source, callback, data, customSchedule, customCancel));

@@ -688,4 +717,5 @@ }

private _taskCounts: {microTask: number, macroTask: number, eventTask: number}
= {microTask: 0, macroTask: 0, eventTask: 0};
private _taskCounts: {microTask: number,
macroTask: number,
eventTask: number} = {microTask: 0, macroTask: 0, eventTask: 0};

@@ -718,3 +748,3 @@ private _parentDelegate: ZoneDelegate;

constructor(zone: Zone, parentDelegate: ZoneDelegate, zoneSpec:ZoneSpec) {
constructor(zone: Zone, parentDelegate: ZoneDelegate, zoneSpec: ZoneSpec) {
this.zone = zone;

@@ -726,48 +756,60 @@ this._parentDelegate = parentDelegate;

this._interceptZS = zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS);
this._interceptDlgt = zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt);
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._invokeDlgt =
zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt);
this._handleErrorZS = zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS);
this._handleErrorDlgt = zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt);
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._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._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._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);
this._hasTaskDlgt =
zoneSpec && (zoneSpec.onHasTask ? parentDelegate : parentDelegate._hasTaskDlgt);
}
fork(targetZone: Zone, zoneSpec: ZoneSpec): AmbientZone {
return this._forkZS
? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec)
: new Zone(targetZone, zoneSpec);
return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) :
new Zone(targetZone, zoneSpec);
}
intercept(targetZone: Zone, callback: Function, source: string): Function {
return this._interceptZS
? this._interceptZS.onIntercept(this._interceptDlgt, this.zone, targetZone, callback, source)
: callback;
return this._interceptZS ?
this._interceptZS.onIntercept(
this._interceptDlgt, this.zone, targetZone, callback, source) :
callback;
}
invoke(targetZone: Zone, callback: Function, applyThis: any, applyArgs: any[],
source: string): any
{
return this._invokeZS
? this._invokeZS.onInvoke(this._invokeDlgt, this.zone, targetZone, callback, applyThis, applyArgs, source)
: callback.apply(applyThis, applyArgs);
invoke(targetZone: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string):
any {
return this._invokeZS ?
this._invokeZS.onInvoke(
this._invokeDlgt, this.zone, targetZone, callback, applyThis, applyArgs, source) :
callback.apply(applyThis, applyArgs);
}
handleError(targetZone: Zone, error: any): boolean {
return this._handleErrorZS
? this._handleErrorZS.onHandleError(this._handleErrorDlgt, this.zone, targetZone, error)
: true;
return this._handleErrorZS ?
this._handleErrorZS.onHandleError(this._handleErrorDlgt, this.zone, targetZone, error) :
true;
}

@@ -778,5 +820,6 @@

if (this._scheduleTaskZS) {
return this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this.zone, targetZone, task);
return this._scheduleTaskZS.onScheduleTask(
this._scheduleTaskDlgt, this.zone, targetZone, task);
} else if (task.scheduleFn) {
task.scheduleFn(task)
task.scheduleFn(task);
} else if (task.type == 'microTask') {

@@ -797,7 +840,9 @@ scheduleMicroTask(<MicroTask>task);

try {
return this._invokeTaskZS
? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this.zone, targetZone, task, applyThis, applyArgs)
: task.callback.apply(applyThis, applyArgs);
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)) {
if (targetZone == this.zone && (task.type != 'eventTask') &&
!(task.data && task.data.isPeriodic)) {
this._updateTaskCount(task.type, -1);

@@ -811,7 +856,7 @@ }

if (this._cancelTaskZS) {
value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this.zone, targetZone, task);
} else if (!task.cancelFn) {
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)
value = task.cancelFn(task);
}

@@ -826,4 +871,4 @@ if (targetZone == this.zone) {

hasTask(targetZone: Zone, isEmpty: HasTaskState) {
return this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone,
isEmpty);
return this._hasTaskZS &&
this._hasTaskZS.onHasTask(this._hasTaskDlgt, this.zone, targetZone, isEmpty);
}

@@ -847,3 +892,3 @@

this.hasTask(this.zone, isEmpty);
} finally {
} finally {
if (this._parentDelegate) {

@@ -869,5 +914,5 @@ this._parentDelegate._updateTaskCount(type, count);

constructor(type: TaskType, zone: Zone, source: string, callback: Function, options: TaskData,
scheduleFn: (task: Task) => void, cancelFn:(task: Task) => void)
{
constructor(
type: TaskType, zone: Zone, source: string, callback: Function, options: TaskData,
scheduleFn: (task: Task) => void, cancelFn: (task: Task) => void) {
this.type = type;

@@ -881,3 +926,3 @@ this.zone = zone;

const self = this;
this.invoke = function () {
this.invoke = function() {
_numberOfNestedTaskFrames++;

@@ -895,7 +940,7 @@ try {

public toString() {
public toString() {
if (this.data && typeof this.data.handleId !== 'undefined') {
return this.data.handleId;
} else {
return this.toString();
return Object.prototype.toString.call(this);
}

@@ -912,3 +957,5 @@ }

function __symbol__(name: string) { return '__zone_symbol__' + name; };
function __symbol__(name: string) {
return '__zone_symbol__' + name;
};
const symbolSetTimeout = __symbol__('setTimeout');

@@ -943,12 +990,10 @@ const symbolPromise = __symbol__('Promise');

function consoleError(e:any) {
function consoleError(e: any) {
const rejection = e && e.rejection;
if (rejection) {
console.error(
'Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection,
'; Zone:', (<Zone>e.zone).name,
'; Task:', e.task && (<Task>e.task).source,
'; Value:', rejection,
rejection instanceof Error ? rejection.stack : undefined
);
'Unhandled Promise rejection:',
rejection instanceof Error ? rejection.message : rejection, '; Zone:',
(<Zone>e.zone).name, '; Task:', e.task && (<Task>e.task).source, '; Value:', rejection,
rejection instanceof Error ? rejection.stack : undefined);
}

@@ -961,3 +1006,3 @@ console.error(e);

_isDrainingMicrotaskQueue = true;
while(_microTaskQueue.length) {
while (_microTaskQueue.length) {
const queue = _microTaskQueue;

@@ -974,7 +1019,9 @@ _microTaskQueue = [];

}
while(_uncaughtPromiseErrors.length) {
while(_uncaughtPromiseErrors.length) {
while (_uncaughtPromiseErrors.length) {
while (_uncaughtPromiseErrors.length) {
const uncaughtPromiseError: UncaughtPromiseError = _uncaughtPromiseErrors.shift();
try {
uncaughtPromiseError.zone.runGuarded(() => { throw uncaughtPromiseError; });
uncaughtPromiseError.zone.runGuarded(() => {
throw uncaughtPromiseError;
});
} catch (e) {

@@ -994,5 +1041,9 @@ consoleError(e);

function forwardResolution(value: any): any { return value; }
function forwardResolution(value: any): any {
return value;
}
function forwardRejection(rejection: any): any { return ZoneAwarePromise.reject(rejection); }
function forwardRejection(rejection: any): any {
return ZoneAwarePromise.reject(rejection);
}

@@ -1011,6 +1062,7 @@ const symbolState: string = __symbol__('state');

// Do not return value or you will break the Promise spec.
}
};
}
function resolvePromise(promise: ZoneAwarePromise<any>, state: boolean, value: any): ZoneAwarePromise<any> {
function resolvePromise(
promise: ZoneAwarePromise<any>, state: boolean, value: any): ZoneAwarePromise<any> {
if (promise[symbolState] === UNRESOLVED) {

@@ -1033,3 +1085,5 @@ if (value instanceof ZoneAwarePromise && value[symbolState] !== UNRESOLVED) {

try {
throw new Error("Uncaught (in promise): " + value);
throw new Error(
'Uncaught (in promise): ' + value +
(value && value.stack ? '\n' + value.stack : ''));
} catch (e) {

@@ -1064,10 +1118,8 @@ const error: UncaughtPromiseError = e;

function scheduleResolveOrReject<R, U>(promise: ZoneAwarePromise<any>,
zone: AmbientZone,
chainPromise: ZoneAwarePromise<any>,
onFulfilled?: (value: R) => U,
onRejected?: (error: any) => U): void
{
function scheduleResolveOrReject<R, U>(
promise: ZoneAwarePromise<any>, zone: AmbientZone, chainPromise: ZoneAwarePromise<any>,
onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): void {
clearRejectedNoCatch(promise);
const delegate = promise[symbolState] ? onFulfilled || forwardResolution: onRejected || forwardRejection;
const delegate =
promise[symbolState] ? onFulfilled || forwardResolution : onRejected || forwardRejection;
zone.scheduleMicroTask(source, () => {

@@ -1083,7 +1135,7 @@ try {

class ZoneAwarePromise<R> implements Promise<R> {
static resolve<R>(value:R): Promise<R> {
static resolve<R>(value: R): Promise<R> {
return resolvePromise(<ZoneAwarePromise<R>>new this(null), RESOLVED, value);
}
static reject<U>(error:U): Promise<U> {
static reject<U>(error: U): Promise<U> {
return resolvePromise(<ZoneAwarePromise<U>>new this(null), REJECTED, error);

@@ -1095,7 +1147,13 @@ }

let reject: (v: any) => void;
let promise: any = new this((res, rej) => {resolve = res; reject = rej});
function onResolve(value) { promise && (promise = null || resolve(value)) }
function onReject(error) { promise && (promise = null || reject(error)) }
let promise: any = new this((res, rej) => {
[resolve, reject] = [res, rej];
});
function onResolve(value) {
promise && (promise = null || resolve(value));
}
function onReject(error) {
promise && (promise = null || reject(error));
}
for(let value of values) {
for (let value of values) {
if (!isThenable(value)) {

@@ -1112,16 +1170,21 @@ value = this.resolve(value);

let reject: (v: any) => void;
let promise = new this((res, rej) => {resolve = res; reject = rej;});
let promise = new this((res, rej) => {
resolve = res;
reject = rej;
});
let count = 0;
const resolvedValues = [];
for(let value of values) {
for (let value of values) {
if (!isThenable(value)) {
value = this.resolve(value);
}
value.then(((index) => (value) => {
resolvedValues[index] = value;
count--;
if (!count) {
resolve(resolvedValues);
}
})(count), reject);
value.then(
((index) => (value) => {
resolvedValues[index] = value;
count--;
if (!count) {
resolve(resolvedValues);
}
})(count),
reject);
count++;

@@ -1133,4 +1196,5 @@ }

constructor(executor: (resolve : (value?: R | PromiseLike<R>) => void,
reject: (error?: any) => void) => void) {
constructor(
executor:
(resolve: (value?: R|PromiseLike<R>) => void, reject: (error?: any) => void) => void) {
const promise: ZoneAwarePromise<R> = this;

@@ -1141,3 +1205,3 @@ if (!(promise instanceof ZoneAwarePromise)) {

promise[symbolState] = UNRESOLVED;
promise[symbolValue] = []; // queue;
promise[symbolValue] = []; // queue;
try {

@@ -1150,8 +1214,8 @@ executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED));

then<R, U>(onFulfilled?: (value: R) => U | PromiseLike<U>,
onRejected?: (error: any) => U | PromiseLike<U>): Promise<R>
{
then<R, U>(
onFulfilled?: (value: R) => U | PromiseLike<U>,
onRejected?: (error: any) => U | PromiseLike<U>): Promise<R> {
const chainPromise: Promise<R> = new (this.constructor as typeof ZoneAwarePromise)(null);
const zone = Zone.current;
if (this[symbolState] == UNRESOLVED ) {
if (this[symbolState] == UNRESOLVED) {
(<any[]>this[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected);

@@ -1179,9 +1243,10 @@ } else {

const NativePromiseProtototype = NativePromise.prototype;
const NativePromiseThen = NativePromiseProtototype[__symbol__('then')]
= NativePromiseProtototype.then;
const NativePromiseThen = NativePromiseProtototype[__symbol__('then')] =
NativePromiseProtototype.then;
NativePromiseProtototype.then = function(onResolve, onReject) {
const nativePromise = this;
return new ZoneAwarePromise((resolve, reject) => {
NativePromiseThen.call(nativePromise, resolve, reject);
}).then(onResolve, onReject);
NativePromiseThen.call(nativePromise, resolve, reject);
})
.then(onResolve, onReject);
};

@@ -1203,3 +1268,4 @@ }

fetchPromise.then(() => null, () => null);
if (fetchPromise.constructor != NativePromise) {
if (fetchPromise.constructor != NativePromise &&
fetchPromise.constructor != ZoneAwarePromise) {
patchThen(fetchPromise.constructor);

@@ -1206,0 +1272,0 @@ }

{
"name": "zone.js",
"version": "0.6.25",
"version": "0.6.26",
"description": "Zones for JavaScript",

@@ -17,8 +17,8 @@ "main": "dist/zone-node.js",

"scripts": {
"prepublish": "./node_modules/.bin/tsc && gulp build",
"prepublish": "tsc && gulp build",
"ws-server": "node ./test/ws-server.js",
"tsc": "./node_modules/.bin/tsc",
"tsc:w": "./node_modules/.bin/tsc -w",
"tsc": "tsc",
"tsc:w": "tsc -w",
"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",
"test-node": "gulp test/node",
"serve": "python -m SimpleHTTPServer 8000"

@@ -43,5 +43,7 @@ },

"gulp": "^3.8.11",
"gulp-clang-format": "^1.0.23",
"gulp-rename": "^1.2.2",
"gulp-rollup": "^2.3.0",
"gulp-tsc": "^1.1.4",
"gulp-tslint": "^6.1.2",
"gulp-uglify": "^1.2.0",

@@ -62,4 +64,6 @@ "gulp-util": "^3.0.7",

"ts-loader": "^0.6.0",
"typescript": "^2.0.2"
"tslint": "^3.15.1",
"typescript": "^2.0.2",
"whatwg-fetch": "^1.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc