From 9b3e77988a54824ee97a3277cc192ab442cdb788 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 21 Mar 2016 11:25:57 -0700 Subject: [PATCH] chore: v0.6.5 --- dist/async-test.js | 134 ++++++++++++++++++++++++++++++ dist/long-stack-trace-zone.js | 4 +- dist/long-stack-trace-zone.min.js | 2 +- dist/zone.js | 40 +++++++-- dist/zone.js.d.ts | 4 + dist/zone.min.js | 2 +- package.json | 2 +- 7 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 dist/async-test.js diff --git a/dist/async-test.js b/dist/async-test.js new file mode 100644 index 000000000..662a6b362 --- /dev/null +++ b/dist/async-test.js @@ -0,0 +1,134 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + (function () { + var AsyncTestZoneSpec = (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this.runZone = Zone.current; + this._finishCallback = finishCallback; + this._failCallback = failCallback; + this.name = 'asyncTestZone for ' + namePrefix; + } + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + // We do this because we would like to catch unhandled rejected promises. + // To do this quickly when there are native promises, we must run using an unwrapped + // promise implementation. + var symbol = Zone.__symbol__; + var NativePromise = window[symbol('Promise')]; + if (NativePromise) { + NativePromise.resolve(true)[symbol('then')](function () { + if (!_this._alreadyErrored) { + _this.runZone.run(_this._finishCallback); + } + }); + } + else { + // For implementations which do not have nativePromise, use setTimeout(0). This is slower, + // but it also works because Zones will handle errors when rejected promises have no + // listeners after one macrotask. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored) { + _this._finishCallback(); + } + }, 0); + }); + } + } + }; + // Note - we need to use onInvoke at the moment to call finish when a test is + // fully synchronous. TODO(juliemr): remove this when the logic for + // onHasTask changes and it calls whenever the task queues are dirty. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + this._finishCallbackIfDone(); + } + }; + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this._failCallback(error.message ? error.message : 'unknown error'); + this._alreadyErrored = true; + } + return false; + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, currentZone, targetZone, task) { + if (task.type == 'macroTask' && task.source == 'setInterval') { + this._failCallback('Cannot use setInterval from within an async zone test.'); + return; + } + return delegate.scheduleTask(targetZone, task); + }; + AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + delegate.hasTask(target, hasTaskState); + if (hasTaskState.change == 'microTask') { + this._pendingMicroTasks = hasTaskState.microTask; + this._finishCallbackIfDone(); + } + else if (hasTaskState.change == 'macroTask') { + this._pendingMacroTasks = hasTaskState.macroTask; + this._finishCallbackIfDone(); + } + }; + return AsyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + })(); + + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/dist/long-stack-trace-zone.js b/dist/long-stack-trace-zone.js index 0365f57bc..4cea0bac0 100644 --- a/dist/long-stack-trace-zone.js +++ b/dist/long-stack-trace-zone.js @@ -127,13 +127,13 @@ var value = descriptor.value; descriptor = { get: function () { - return renderLongStackTrace(parentTask.data[creationTrace], delegateGet ? delegateGet.apply(this) : value); + return renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], delegateGet ? delegateGet.apply(this) : value); } }; Object.defineProperty(error, 'stack', descriptor); } else { - error.stack = renderLongStackTrace(parentTask.data[creationTrace], error.stack); + error.stack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); } } return parentZoneDelegate.handleError(targetZone, error); diff --git a/dist/long-stack-trace-zone.min.js b/dist/long-stack-trace-zone.min.js index 8e0db4d8b..6a4866c60 100644 --- a/dist/long-stack-trace-zone.min.js +++ b/dist/long-stack-trace-zone.min.js @@ -1 +1 @@ -!function(t){function r(n){if(e[n])return e[n].exports;var a=e[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}var e={};return r.m=t,r.c=e,r.p="",r(0)}([function(t,exports){"use strict";!function(){function t(){return new Error("STACKTRACE TRACKING")}function r(){try{throw t()}catch(r){return r}}function e(t){return t.stack?t.stack.split(i):[]}function n(t,r){var n;n=e(r);for(var a=0;a0&&(t.push(e((new l).error)),c(t,r-1))}function o(){var t=[];c(t,2);for(var r=t[0],e=t[1],n=0;nthis.longStackTraceLimit&&(c.length=this.longStackTraceLimit),n.data||(n.data={}),n.data[f]=c,t.scheduleTask(e,n)},onHandleError:function(t,r,e,n){var c=Zone.currentTask;if(n instanceof Error&&c){var o=Object.getOwnPropertyDescriptor(n,"stack");if(o){var i=o.get,s=o.value;o={get:function(){return a(c.data[f],i?i.apply(this):s)}},Object.defineProperty(n,"stack",o)}else n.stack=a(c.data[f],n.stack)}return t.handleError(e,n)}},o()}()}]); \ No newline at end of file +!function(t){function r(n){if(e[n])return e[n].exports;var a=e[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,r),a.loaded=!0,a.exports}var e={};return r.m=t,r.c=e,r.p="",r(0)}([function(t,exports){"use strict";!function(){function t(){return new Error("STACKTRACE TRACKING")}function r(){try{throw t()}catch(r){return r}}function e(t){return t.stack?t.stack.split(i):[]}function n(t,r){var n;n=e(r);for(var a=0;a0&&(t.push(e((new l).error)),c(t,r-1))}function o(){var t=[];c(t,2);for(var r=t[0],e=t[1],n=0;nthis.longStackTraceLimit&&(c.length=this.longStackTraceLimit),n.data||(n.data={}),n.data[f]=c,t.scheduleTask(e,n)},onHandleError:function(t,r,e,n){var c=Zone.currentTask;if(n instanceof Error&&c){var o=Object.getOwnPropertyDescriptor(n,"stack");if(o){var i=o.get,s=o.value;o={get:function(){return a(c.data&&c.data[f],i?i.apply(this):s)}},Object.defineProperty(n,"stack",o)}else n.stack=a(c.data&&c.data[f],n.stack)}return t.handleError(e,n)}},o()}()}]); \ No newline at end of file diff --git a/dist/zone.js b/dist/zone.js index a1bc6d27a..905e36824 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -95,7 +95,7 @@ function clearTask(task) { return clearNative(task.data.handleId); } - var setNative = utils_1.patchMethod(window, setName, function () { return function (self, args) { + var setNative = utils_1.patchMethod(window, setName, function (delegate) { return function (self, args) { if (typeof args[0] === 'function') { var zone = Zone.current; var options = { @@ -108,12 +108,18 @@ } else { // cause an error by calling it directly. - return setNative.apply(window, args); + return delegate.apply(window, args); } }; }); - var clearNative = utils_1.patchMethod(window, cancelName, function () { return function (self, args) { + var clearNative = utils_1.patchMethod(window, cancelName, function (delegate) { return function (self, args) { var task = args[0]; - task.zone.cancelTask(task); + if (task && typeof task.type == 'string') { + task.zone.cancelTask(task); + } + else { + // cause an error by calling it directly. + delegate.apply(window, args); + } }; }); } @@ -645,7 +651,7 @@ "use strict"; var utils_1 = __webpack_require__(3); var WTF_ISSUE_555 = 'Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video'; - var NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload'.split(','); + var NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex'.split(','); var EVENT_TARGET = 'EventTarget'; function eventTargetPatch(_global) { var apis = []; @@ -726,8 +732,14 @@ this.removeEventListener(eventName, this[_prop]); } if (typeof fn === 'function') { - this[_prop] = fn; - this.addEventListener(eventName, fn, false); + var wrapFn = function (event) { + var result; + result = fn.apply(this, arguments); + if (result != undefined && !result) + event.preventDefault(); + }; + this[_prop] = wrapFn; + this.addEventListener(eventName, wrapFn, false); } else { this[_prop] = null; @@ -841,7 +853,7 @@ // - When `addEventListener` is called on the global context in strict mode, `this` is undefined // see https://github.com/angular/zone.js/issues/190 var target = self || _global; - var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, false); + var eventTask = findExistingRegisteredTask(target, handler, eventName, useCapturing, true); if (eventTask) { eventTask.zone.cancelTask(eventTask); } @@ -1084,6 +1096,14 @@ utils_1.patchOnProperties(HTMLElement.prototype, eventNames); } utils_1.patchOnProperties(XMLHttpRequest.prototype, null); + if (typeof IDBIndex !== 'undefined') { + utils_1.patchOnProperties(IDBIndex.prototype, null); + utils_1.patchOnProperties(IDBRequest.prototype, null); + utils_1.patchOnProperties(IDBOpenDBRequest.prototype, null); + utils_1.patchOnProperties(IDBDatabase.prototype, null); + utils_1.patchOnProperties(IDBTransaction.prototype, null); + utils_1.patchOnProperties(IDBCursor.prototype, null); + } if (supportsWebSocket) { utils_1.patchOnProperties(WebSocket.prototype, null); } @@ -1148,7 +1168,7 @@ /* 7 */ /***/ function(module, exports, __webpack_require__) { - "use strict"; + /* WEBPACK VAR INJECTION */(function(global) {"use strict"; var utils_1 = __webpack_require__(3); // we have to patch the instance since the proto is non-configurable function apply(_global) { @@ -1178,9 +1198,11 @@ utils_1.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open']); return proxySocket; }; + global.WebSocket.prototype = Object.create(WS.prototype, { constructor: { value: WebSocket } }); } exports.apply = apply; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) /***/ } /******/ ]); \ No newline at end of file diff --git a/dist/zone.js.d.ts b/dist/zone.js.d.ts index 4570228e5..ebd2d14c4 100644 --- a/dist/zone.js.d.ts +++ b/dist/zone.js.d.ts @@ -438,4 +438,8 @@ interface MacroTask extends Task { } interface EventTask extends Task { } +/** @internal */ +declare type AmbientZone = Zone; +/** @internal */ +declare type AmbientZoneDelegate = ZoneDelegate; declare var Zone: ZoneType; diff --git a/dist/zone.min.js b/dist/zone.min.js index aa3049c66..50bf904d3 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1 +1 @@ -!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,exports,t){(function(e){"use strict";function n(e,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 c(e.data.handleId)}t+=r,n+=r;var i=s.patchMethod(e,t,function(){return function(n,s){if("function"==typeof s[0]){var c=Zone.current,u={handleId:null,isPeriodic:"Interval"==r,delay:"Timeout"==r||"Interval"==r?s[1]||0:null,args:s};return c.scheduleMacroTask(t,s[0],u,o,a)}return i.apply(e,s)}}),c=s.patchMethod(e,n,function(){return function(e,t){var n=t[0];n.zone.cancelTask(n)}})}t(1);var r=t(2),o=t(4),a=t(5),i=t(6),s=t(3),c="set",u="clear",l=["alert","prompt","confirm"],p="undefined"==typeof window?e:window;n(p,c,u,"Timeout"),n(p,c,u,"Interval"),n(p,c,u,"Immediate"),n(p,"request","cancelMacroTask","AnimationFrame"),n(p,"mozRequest","mozCancel","AnimationFrame"),n(p,"webkitRequest","webkitCancel","AnimationFrame");for(var h=0;h",this._properties=t&&t.properties||{},this._zoneDelegate=new d(this,this._parent&&this._parent._zoneDelegate,t)}return Object.defineProperty(e,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(e,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),e.prototype.get=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t._properties[e];t=t._parent}},e.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},e.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var e=this._zoneDelegate.intercept(this,e,t),n=this;return function(){return n.runGuarded(e,this,arguments,t)}},e.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{m=o}},e.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o}},e.prototype.runTask=function(e,t,n){if(e.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{try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o,T=r,"microTask"==e.type}},e.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new v("microTask",this,e,t,n,r,null))},e.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("macroTask",this,e,t,n,r,o))},e.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("eventTask",this,e,t,n,r,o))},e.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.cancelFn=null,t},e.__symbol__=t,e}(),d=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new f(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return this._handleErrorZS?this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t):!0},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(0>o)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),v=function(){function e(e,t,n,r,o,i,s){this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=s,this.callback=r;var c=this;this.invoke=function(){try{return t.runTask(c,this,arguments)}finally{a()}}}return e}(),k=t("setTimeout"),g=t("Promise"),y=t("then"),m=new f(null,null),T=null,_=[],b=!1,w=[],E=!1,S=t("state"),P=t("value"),D="Promise.then",z=null,O=!0,Z=!1,C=0,M=function(){function e(e){var t=this;t[S]=z,t[P]=[];try{e&&e(u(t,O),u(t,Z))}catch(n){l(t,!1,n)}}return e.resolve=function(e){return l(new this(null),O,e)},e.reject=function(e){return l(new this(null),Z,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){r=e,o=t}),s=0,c=e;s=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function n(e,n){for(var r=e.constructor.name,o=0;o1?new t(e,n):new t(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r.patchOnProperties(o,["close","error","message","open"]),o}}var r=t(3);exports.apply=n}]); \ No newline at end of file +!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,exports,t){(function(e){"use strict";function n(e,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 c(e.data.handleId)}t+=r,n+=r;var i=s.patchMethod(e,t,function(n){return function(i,s){if("function"==typeof s[0]){var c=Zone.current,u={handleId:null,isPeriodic:"Interval"==r,delay:"Timeout"==r||"Interval"==r?s[1]||0:null,args:s};return c.scheduleMacroTask(t,s[0],u,o,a)}return n.apply(e,s)}}),c=s.patchMethod(e,n,function(t){return function(n,r){var o=r[0];o&&"string"==typeof o.type?o.zone.cancelTask(o):t.apply(e,r)}})}t(1);var r=t(2),o=t(4),a=t(5),i=t(6),s=t(3),c="set",u="clear",l=["alert","prompt","confirm"],p="undefined"==typeof window?e:window;n(p,c,u,"Timeout"),n(p,c,u,"Interval"),n(p,c,u,"Immediate"),n(p,"request","cancelMacroTask","AnimationFrame"),n(p,"mozRequest","mozCancel","AnimationFrame"),n(p,"webkitRequest","webkitCancel","AnimationFrame");for(var h=0;h",this._properties=t&&t.properties||{},this._zoneDelegate=new d(this,this._parent&&this._parent._zoneDelegate,t)}return Object.defineProperty(e,"current",{get:function(){return m},enumerable:!0,configurable:!0}),Object.defineProperty(e,"currentTask",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),e.prototype.get=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t._properties[e];t=t._parent}},e.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},e.prototype.wrap=function(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);var e=this._zoneDelegate.intercept(this,e,t),n=this;return function(){return n.runGuarded(e,this,arguments,t)}},e.prototype.run=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{m=o}},e.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null);var o=m;m=this;try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o}},e.prototype.runTask=function(e,t,n){if(e.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{try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{m=o,T=r,"microTask"==e.type}},e.prototype.scheduleMicroTask=function(e,t,n,r){return this._zoneDelegate.scheduleTask(this,new v("microTask",this,e,t,n,r,null))},e.prototype.scheduleMacroTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("macroTask",this,e,t,n,r,o))},e.prototype.scheduleEventTask=function(e,t,n,r,o){return this._zoneDelegate.scheduleTask(this,new v("eventTask",this,e,t,n,r,o))},e.prototype.cancelTask=function(e){var t=this._zoneDelegate.cancelTask(this,e);return e.cancelFn=null,t},e.__symbol__=t,e}(),d=function(){function e(e,t,n){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=e,this._parentDelegate=t,this._forkZS=n&&(n&&n.onFork?n:t._forkZS),this._forkDlgt=n&&(n.onFork?t:t._forkDlgt),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._hasTaskZS=n&&(n.onHasTask?n:t._hasTaskZS),this._hasTaskDlgt=n&&(n.onHasTask?t:t._hasTaskDlgt)}return e.prototype.fork=function(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new f(e,t)},e.prototype.intercept=function(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this.zone,e,t,n):t},e.prototype.invoke=function(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this.zone,e,t,n,r,o):t.apply(n,r)},e.prototype.handleError=function(e,t){return this._handleErrorZS?this._handleErrorZS.onHandleError(this._handleErrorDlgt,this.zone,e,t):!0},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(0>o)throw new Error("More tasks executed then were scheduled.");if(0==r||0==o){var a={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};try{this.hasTask(this.zone,a)}finally{this._parentDelegate&&this._parentDelegate._updateTaskCount(e,t)}}},e}(),v=function(){function e(e,t,n,r,o,i,s){this.type=e,this.zone=t,this.source=n,this.data=o,this.scheduleFn=i,this.cancelFn=s,this.callback=r;var c=this;this.invoke=function(){try{return t.runTask(c,this,arguments)}finally{a()}}}return e}(),k=t("setTimeout"),y=t("Promise"),g=t("then"),m=new f(null,null),T=null,b=[],_=!1,w=[],D=!1,S=t("state"),E=t("value"),P="Promise.then",O=null,z=!0,Z=!1,C=0,I=function(){function e(e){var t=this;t[S]=O,t[E]=[];try{e&&e(u(t,z),u(t,Z))}catch(n){l(t,!1,n)}}return e.resolve=function(e){return l(new this(null),z,e)},e.reject=function(e){return l(new this(null),Z,e)},e.race=function(e){function t(e){a&&(a=r(e))}function n(e){a&&(a=o(e))}for(var r,o,a=new this(function(e,t){r=e,o=t}),s=0,c=e;s=0;n--)"function"==typeof e[n]&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function n(e,n){for(var r=e.constructor.name,o=0;o1?new n(e,t):new n(e),i=Object.getOwnPropertyDescriptor(a,"onmessage");return i&&i.configurable===!1?(o=Object.create(a),["addEventListener","removeEventListener","send","close"].forEach(function(e){o[e]=function(){return a[e].apply(a,arguments)}})):o=a,r.patchOnProperties(o,["close","error","message","open"]),o},e.WebSocket.prototype=Object.create(n.prototype,{constructor:{value:WebSocket}})}var r=t(3);exports.apply=n}).call(exports,function(){return this}())}]); \ No newline at end of file diff --git a/package.json b/package.json index a829ae3bb..b4a240d7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zone.js", - "version": "0.6.3", + "version": "0.6.5", "description": "Zones for JavaScript", "main": "dist/zone-node.js", "browser": "dist/zone.js",