From 73b0061a026780143bda312b7a99e2a16c7bafcb Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sun, 7 Jan 2018 00:36:11 +0900 Subject: [PATCH 001/106] fix(core): fix #989, remove unuse code, use shorter name to reduce bundle size --- gulpfile.js | 10 ++ lib/browser/browser.ts | 105 +++++++------- lib/browser/define-property.ts | 11 +- lib/browser/event-target.ts | 22 +-- lib/browser/property-descriptor.ts | 40 +++--- lib/browser/register-element.ts | 15 +- lib/browser/shadydom.ts | 4 +- lib/browser/webapis-media-query.ts | 7 +- lib/browser/webapis-notification.ts | 4 +- lib/browser/webapis-rtc-peer-connection.ts | 4 +- lib/browser/webapis-user-media.ts | 20 +++ lib/browser/websocket.ts | 18 +-- lib/common/events.ts | 154 ++++++++++----------- lib/common/promise.ts | 51 +++---- lib/common/timers.ts | 38 +++-- lib/common/to-string.ts | 9 +- lib/common/utils.ts | 100 +++++++------ lib/extra/bluebird.ts | 6 +- lib/extra/cordova.ts | 10 +- lib/extra/electron.ts | 16 ++- lib/node/events.ts | 22 +-- lib/node/fs.ts | 6 +- lib/node/node.ts | 26 ++-- lib/rxjs/rxjs.ts | 8 +- lib/zone-spec/fake-async-test.ts | 2 +- lib/zone.ts | 27 +++- test/browser-zone-setup.ts | 3 +- test/browser_entry_point.ts | 1 - test/common/util.spec.ts | 28 +--- test/common_tests.ts | 4 +- test/zone-spec/fake-async-test.spec.ts | 6 +- 31 files changed, 388 insertions(+), 389 deletions(-) create mode 100644 lib/browser/webapis-user-media.ts diff --git a/gulpfile.js b/gulpfile.js index 0bb8c47fb..71a099320 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -184,6 +184,14 @@ gulp.task('build/zone-patch-electron.min.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.min.js', true, cb); }); +gulp.task('build/zone-patch-user-media.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.js', false, cb); +}); + +gulp.task('build/zone-patch-user-media.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb); +}); + gulp.task('build/bluebird.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb); }); @@ -287,6 +295,8 @@ gulp.task('build', [ 'build/zone-patch-cordova.min.js', 'build/zone-patch-electron.js', 'build/zone-patch-electron.min.js', + 'build/zone-patch-user-media.js', + 'build/zone-patch-user-media.min.js', 'build/zone-mix.js', 'build/bluebird.js', 'build/bluebird.min.js', diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index ce9a77c22..03f3b00db 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -12,20 +12,20 @@ import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {patchArguments, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, wrapFunctionArgs, zoneSymbol} from '../common/utils'; +import {bindArguments, i, j, o, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, r, zoneSymbol} from '../common/utils'; import {propertyPatch} from './define-property'; import {eventTargetPatch, patchEvent} from './event-target'; import {propertyDescriptorPatch} from './property-descriptor'; import {registerElementPatch} from './register-element'; -Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('timers', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('timers', (global: any) => { const set = 'set'; const clear = 'clear'; patchTimer(global, set, clear, 'Timeout'); @@ -33,27 +33,27 @@ Zone.__load_patch('timers', (global: any, Zone: ZoneType, api: _ZonePrivate) => patchTimer(global, set, clear, 'Immediate'); }); -Zone.__load_patch('requestAnimationFrame', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('requestAnimationFrame', (global: any) => { patchTimer(global, 'request', 'cancel', 'AnimationFrame'); patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); }); -Zone.__load_patch('blocking', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('blocking', (global: any, Zone: ZoneType) => { const blockingMethods = ['alert', 'prompt', 'confirm']; for (let i = 0; i < blockingMethods.length; i++) { const name = blockingMethods[i]; patchMethod(global, name, (delegate, symbol, name) => { return function(s: any, args: any[]) { - return Zone.current.run(delegate, global, args, name); + return (Zone as any).c.r(delegate, global, args, name); }; }); } }); -Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // load blackListEvents from global - const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + const SYMBOL_BLACK_LISTED_EVENTS = (Zone as any).s('BLACK_LISTED_EVENTS'); if (global[SYMBOL_BLACK_LISTED_EVENTS]) { (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; } @@ -71,23 +71,23 @@ Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate patchClass('FileReader'); }); -Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => { propertyDescriptorPatch(api, global); propertyPatch(); registerElementPatch(global); }); -Zone.__load_patch('canvas', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('canvas', (global: any) => { const HTMLCanvasElement = global['HTMLCanvasElement']; - if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && + if (typeof HTMLCanvasElement !== o && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.toBlob) { patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', (self: any, args: any[]) => { - return {name: 'HTMLCanvasElement.toBlob', target: self, callbackIndex: 0, args: args}; + return {name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args}; }); } }); -Zone.__load_patch('XHR', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('XHR', (global: any, Zone: ZoneType) => { // Treat XMLHTTPRequest as a macrotask. patchXHR(global); @@ -105,21 +105,21 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType, api: _ZonePrivate) => { } function patchXHR(window: any) { + const XMLHttpRequestPrototype: any = XMLHttpRequest.prototype; + function findPendingTask(target: any) { const pendingTask: Task = target[XHR_TASK]; return pendingTask; } - const SYMBOL_ADDEVENTLISTENER = zoneSymbol('addEventListener'); - const SYMBOL_REMOVEEVENTLISTENER = zoneSymbol('removeEventListener'); - - let oriAddListener = (XMLHttpRequest.prototype as any)[SYMBOL_ADDEVENTLISTENER]; - let oriRemoveListener = (XMLHttpRequest.prototype as any)[SYMBOL_REMOVEEVENTLISTENER]; + let oriAddListener = XMLHttpRequestPrototype[i]; + let oriRemoveListener = XMLHttpRequestPrototype[j]; if (!oriAddListener) { const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { - oriAddListener = XMLHttpRequestEventTarget.prototype[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = XMLHttpRequestEventTarget.prototype[SYMBOL_REMOVEEVENTLISTENER]; + const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[i]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[j]; } } @@ -133,8 +133,8 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // remove existing event listener const listener = target[XHR_LISTENER]; if (!oriAddListener) { - oriAddListener = target[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = target[SYMBOL_REMOVEEVENTLISTENER]; + oriAddListener = target[i]; + oriRemoveListener = target[j]; } if (listener) { @@ -170,17 +170,17 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType, api: _ZonePrivate) => { return abortNative.apply(data.target, data.args); } - const openNative: Function = patchMethod( - window.XMLHttpRequest.prototype, 'open', () => function(self: any, args: any[]) { + const openNative: Function = + patchMethod(XMLHttpRequestPrototype, 'open', () => function(self: any, args: any[]) { self[XHR_SYNC] = args[2] == false; self[XHR_URL] = args[1]; return openNative.apply(self, args); }); const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - const sendNative: Function = patchMethod( - window.XMLHttpRequest.prototype, 'send', () => function(self: any, args: any[]) { - const zone = Zone.current; + const sendNative: Function = + patchMethod(XMLHttpRequestPrototype, 'send', () => function(self: any, args: any[]) { + const zone = (Zone as any).c; if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); @@ -193,49 +193,38 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType, api: _ZonePrivate) => { args: args, aborted: false }; - return zone.scheduleMacroTask( + return zone.sc( XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } }); - const STRING_TYPE = 'string'; - - const abortNative = patchMethod( - window.XMLHttpRequest.prototype, 'abort', - (delegate: Function) => function(self: any, args: any[]) { - const task: Task = findPendingTask(self); - if (task && typeof task.type == STRING_TYPE) { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && (task.data).aborted)) { - 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. - }); + const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function(self: any) { + const task: Task = findPendingTask(self); + if (task && typeof task.type == r) { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && (task.data).aborted)) { + return; + } + (task.zone as any).ct(task); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }); } }); -Zone.__load_patch('geolocation', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('geolocation', (global: any) => { /// GEO_LOCATION if (global['navigator'] && global['navigator'].geolocation) { patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); } }); -Zone.__load_patch('getUserMedia', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - let navigator = global['navigator']; - if (navigator && navigator.getUserMedia) { - navigator.getUserMedia = wrapFunctionArgs(navigator.getUserMedia); - } -}); - -Zone.__load_patch('PromiseRejectionEvent', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('PromiseRejectionEvent', (global: any, Zone: ZoneType) => { // handle unhandled promise rejection function findPromiseRejectionHandler(evtName: string) { return function(e: any) { diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index 2a2f0e18f..ae966c86e 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {zoneSymbol} from '../common/utils'; +import {o, p, zoneSymbol} from '../common/utils'; /* * This is necessary for Chrome and Chrome mobile, to enable * things like redefining `createdCallback` on an element. @@ -17,9 +17,6 @@ const _getOwnPropertyDescriptor = (Object as any)[zoneSymbol('getOwnPropertyDesc Object.getOwnPropertyDescriptor; const _create = Object.create; const unconfigurablesKey = zoneSymbol('unconfigurables'); -const PROTOTYPE = 'prototype'; -const OBJECT = 'object'; -const UNDEFINED = 'undefined'; export function propertyPatch() { Object.defineProperty = function(obj, prop, desc) { @@ -27,7 +24,7 @@ export function propertyPatch() { throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); } const originalConfigurableFlag = desc.configurable; - if (prop !== PROTOTYPE) { + if (prop !== 'prototype') { desc = rewriteDescriptor(obj, prop, desc); } return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); @@ -41,7 +38,7 @@ export function propertyPatch() { }; Object.create = function(obj: any, proto: any) { - if (typeof proto === OBJECT && !Object.isFrozen(proto)) { + if (typeof proto === p && !Object.isFrozen(proto)) { Object.keys(proto).forEach(function(prop) { proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); }); @@ -92,7 +89,7 @@ function _tryDefineProperty(obj: any, prop: string, desc: any, originalConfigura if (desc.configurable) { // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's // retry with the original flag value - if (typeof originalConfigurableFlag == UNDEFINED) { + if (typeof originalConfigurableFlag == o) { delete desc.configurable; } else { desc.configurable = originalConfigurableFlag; diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index 2972cfbd6..d0bb6a897 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {FALSE_STR, globalSources, patchEventPrototype, patchEventTarget, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbolEventNames} from '../common/events'; -import {attachOriginToPatched, isIEOrEdge, zoneSymbol} from '../common/utils'; +import {ens, gs, patchEventPrototype, patchEventTarget} from '../common/events'; +import {isIEOrEdge, k, l, m} from '../common/utils'; import {eventNames} from './property-descriptor'; @@ -45,19 +45,19 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { // predefine all __zone_symbol__ + eventName + true/false string for (let i = 0; i < eventNames.length; i++) { const eventName = eventNames[i]; - const falseEventName = eventName + FALSE_STR; - const trueEventName = eventName + TRUE_STR; - const symbol = ZONE_SYMBOL_PREFIX + falseEventName; - const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + const falseEventName = eventName + l; + const trueEventName = eventName + k; + const symbol = m + falseEventName; + const symbolCapture = m + trueEventName; + ens[eventName] = {}; + ens[eventName][l] = symbol; + ens[eventName][k] = symbolCapture; } // predefine all task.source string for (let i = 0; i < WTF_ISSUE_555.length; i++) { const target: any = WTF_ISSUE_555_ARRAY[i]; - const targets: any = globalSources[target] = {}; + const targets: any = gs[target] = {}; for (let j = 0; j < eventNames.length; j++) { const eventName = eventNames[j]; targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; @@ -101,7 +101,7 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { const type = _global[apis[i]]; apiTypes.push(type && type.prototype); } - patchEventTarget(_global, apiTypes, {validateHandler: checkIEAndCrossContext}); + patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); api.patchEventTarget = patchEventTarget; return true; diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 55c2df789..f8945947e 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -10,7 +10,7 @@ * @suppress {globalThis} */ -import {isBrowser, isMix, isNode, patchClass, patchOnProperties, zoneSymbol} from '../common/utils'; +import {a, b, d, isBrowser, isMix, isNode, o, patchClass, patchOnProperties, zoneSymbol} from '../common/utils'; import * as webSocketPatch from './websocket'; @@ -265,21 +265,19 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { return; } - const supportsWebSocket = typeof WebSocket !== 'undefined'; + const supportsWebSocket = typeof WebSocket !== o; if (canPatchViaPropertyDescriptor()) { const ignoreProperties: IgnoreProperty[] = _global.__Zone_ignore_on_properties; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { + const w: any = window; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties( - window, eventNames.concat(['messageerror']), ignoreProperties, - Object.getPrototypeOf(window)); + patchFilteredProperties(w, eventNames.concat(['messageerror']), ignoreProperties, d(w)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof(window)['SVGElement'] !== 'undefined') { - patchFilteredProperties( - (window)['SVGElement'].prototype, eventNames, ignoreProperties); + if (typeof w['SVGElement'] !== o) { + patchFilteredProperties(w['SVGElement'].prototype, eventNames, ignoreProperties); } patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); @@ -292,11 +290,11 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - const HTMLMarqueeElement = (window as any)['HTMLMarqueeElement']; + const HTMLMarqueeElement = w['HTMLMarqueeElement']; if (HTMLMarqueeElement) { patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); } - const Worker = (window as any)['Worker']; + const Worker = w['Worker']; if (Worker) { patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); } @@ -308,7 +306,7 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); } - if (typeof IDBIndex !== 'undefined') { + if (typeof IDBIndex !== o) { patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); @@ -330,15 +328,17 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { } function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { + if ((isBrowser || isMix) && !a(HTMLElement.prototype, 'onclick') && typeof Element !== o) { // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 // IDL interface attributes are not configurable - const desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); + const desc = a(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; } - const xhrDesc = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'onreadystatechange'); + const ON_READY_STATE_CHANGE = 'onreadystatechange'; + const XMLHttpRequestPrototype = XMLHttpRequest.prototype; + + const xhrDesc = a(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera // by default XMLHttpRequest.prototype.onreadystatechange is undefined @@ -347,7 +347,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function() { @@ -357,11 +357,11 @@ function canPatchViaPropertyDescriptor() { const req = new XMLHttpRequest(); const result = !!req.onreadystatechange; // restore original desc - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', xhrDesc || {}); + b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } else { - const SYMBOL_FAKE_ONREADYSTATECHANGE = zoneSymbol('fakeonreadystatechange'); - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + const SYMBOL_FAKE_ONREADYSTATECHANGE = zoneSymbol('fake'); + b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function() { @@ -398,7 +398,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = Zone.current.wrap(elt[onproperty], source); + bound = (Zone as any).c.w(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index 0f6f9a49a..74e1ccd05 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {attachOriginToPatched, isBrowser, isMix} from '../common/utils'; +import {a, attachOriginToPatched, isBrowser, isMix} from '../common/utils'; import {_redefineProperty} from './define-property'; @@ -23,16 +23,17 @@ export function registerElementPatch(_global: any) { if (opts && opts.prototype) { callbacks.forEach(function(callback) { const source = 'Document.registerElement::' + callback; - if (opts.prototype.hasOwnProperty(callback)) { - const descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback); + const p = opts.prototype; + if (p.hasOwnProperty(callback)) { + const descriptor = a(p, callback); if (descriptor && descriptor.value) { - descriptor.value = Zone.current.wrap(descriptor.value, source); + descriptor.value = (Zone as any).c.w(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } else { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + p[callback] = (Zone as any).c.w(p[callback], source); } - } else if (opts.prototype[callback]) { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + } else if (p[callback]) { + p[callback] = (Zone as any).c.w(p[callback], source); } }); } diff --git a/lib/browser/shadydom.ts b/lib/browser/shadydom.ts index 2a0173a84..d02590204 100644 --- a/lib/browser/shadydom.ts +++ b/lib/browser/shadydom.ts @@ -5,7 +5,7 @@ * 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.__load_patch('shadydom', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('shadydom', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // https://github.com/angular/zone.js/issues/782 // in web components, shadydom will patch addEventListener/removeEventListener of // Node.prototype and WindowPrototype, this will have conflict with zone.js @@ -21,4 +21,4 @@ Zone.__load_patch('shadydom', (global: any, Zone: ZoneType, api: _ZonePrivate) = (Node.prototype as any)[Zone.__symbol__('removeEventListener')] = null; api.patchEventTarget(global, [Node.prototype]); } -}); \ No newline at end of file +}); diff --git a/lib/browser/webapis-media-query.ts b/lib/browser/webapis-media-query.ts index d1fcd53d8..b26831327 100644 --- a/lib/browser/webapis-media-query.ts +++ b/lib/browser/webapis-media-query.ts @@ -5,11 +5,10 @@ * 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.__load_patch('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate) => { if (!global['MediaQueryList']) { return; } api.patchEventTarget( - global, [global['MediaQueryList'].prototype], - {addEventListenerFnName: 'addListener', removeEventListenerFnName: 'removeListener'}); -}); \ No newline at end of file + global, [global['MediaQueryList'].prototype], {add: 'addListener', rm: 'removeListener'}); +}); diff --git a/lib/browser/webapis-notification.ts b/lib/browser/webapis-notification.ts index 1bccaa9c9..b714b3830 100644 --- a/lib/browser/webapis-notification.ts +++ b/lib/browser/webapis-notification.ts @@ -5,7 +5,7 @@ * 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.__load_patch('notification', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('notification', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const Notification = global['Notification']; if (!Notification || !Notification.prototype) { return; @@ -15,4 +15,4 @@ Zone.__load_patch('notification', (global: any, Zone: ZoneType, api: _ZonePrivat return; } api.patchOnProperties(Notification.prototype, null); -}); \ No newline at end of file +}); diff --git a/lib/browser/webapis-rtc-peer-connection.ts b/lib/browser/webapis-rtc-peer-connection.ts index 2551ae234..666b4482d 100644 --- a/lib/browser/webapis-rtc-peer-connection.ts +++ b/lib/browser/webapis-rtc-peer-connection.ts @@ -5,7 +5,7 @@ * 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.__load_patch('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const RTCPeerConnection = global['RTCPeerConnection']; if (!RTCPeerConnection) { return; @@ -22,5 +22,5 @@ Zone.__load_patch('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZoneP RTCPeerConnection.prototype[addSymbol] = null; RTCPeerConnection.prototype[removeSymbol] = null; - api.patchEventTarget(global, [RTCPeerConnection.prototype], {useGlobalCallback: false}); + api.patchEventTarget(global, [RTCPeerConnection.prototype], {useG: false}); }); diff --git a/lib/browser/webapis-user-media.ts b/lib/browser/webapis-user-media.ts new file mode 100644 index 000000000..f93085a83 --- /dev/null +++ b/lib/browser/webapis-user-media.ts @@ -0,0 +1,20 @@ +/** + * @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 as any).l('getUserMedia', (global: any, Zone: any, api: _ZonePrivate) => { + function wrapFunctionArgs(func: Function, source?: string): Function { + return function() { + const args = Array.prototype.slice.call(arguments); + const wrappedArgs = api.bindArguments(args, source ? source : (func as any).name); + return func.apply(this, wrappedArgs); + }; + } + let navigator = global['navigator']; + if (navigator && navigator.getUserMedia) { + navigator.getUserMedia = wrapFunctionArgs(navigator.getUserMedia); + } +}); diff --git a/lib/browser/websocket.ts b/lib/browser/websocket.ts index d9f3354c9..5714b6c77 100644 --- a/lib/browser/websocket.ts +++ b/lib/browser/websocket.ts @@ -7,7 +7,7 @@ */ import {patchEventTarget} from '../common/events'; -import {patchOnProperties} from '../common/utils'; +import {a, e, f, g, h, patchOnProperties} from '../common/utils'; // we have to patch the instance since the proto is non-configurable export function apply(api: _ZonePrivate, _global: any) { @@ -17,27 +17,27 @@ export function apply(api: _ZonePrivate, _global: any) { if (!(_global).EventTarget) { patchEventTarget(_global, [WS.prototype]); } - (_global).WebSocket = function(a: any, b: any) { - const socket = arguments.length > 1 ? new WS(a, b) : new WS(a); + (_global).WebSocket = function(x: any, y: any) { + const socket = arguments.length > 1 ? new WS(x, y) : new WS(x); let proxySocket: any; let proxySocketProto: any; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - const onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); + const onmessageDesc = a(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = Object.create(socket); + proxySocket = e(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method proxySocketProto = socket; - ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function(propName) { + [g, h, 'send', 'close'].forEach(function(propName) { proxySocket[propName] = function() { - const args = Array.prototype.slice.call(arguments); - if (propName === 'addEventListener' || propName === 'removeEventListener') { + const args = f.call(arguments); + if (propName === g || propName === h) { const eventName = args.length > 0 ? args[0] : undefined; if (eventName) { - const propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + const propertySymbol = (Zone as any).s('ON_PROPERTY' + eventName); socket[propertySymbol] = proxySocket[propertySymbol]; } } diff --git a/lib/common/events.ts b/lib/common/events.ts index c5424a782..5b349ab75 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -10,56 +10,56 @@ * @suppress {missingRequire} */ -import {attachOriginToPatched, zoneSymbol} from './utils'; +import {attachOriginToPatched, d, g, h, k, l, m, n, p, zoneSymbol} from './utils'; -export const TRUE_STR = 'true'; -export const FALSE_STR = 'false'; - -export interface EventTaskData extends TaskData { readonly isUsingGlobalCallback?: boolean; } +/** @internal **/ +interface EventTaskData extends TaskData { + // use global callback or not + readonly useG?: boolean; +} // an identifier to tell ZoneTask do not create a new invoke closure -export const OPTIMIZED_ZONE_EVENT_TASK_DATA: EventTaskData = { - isUsingGlobalCallback: true +const OPTIMIZED_ZONE_EVENT_TASK_DATA: EventTaskData = { + useG: true }; -export const zoneSymbolEventNames: any = {}; -export const globalSources: any = {}; - -export const CONSTRUCTOR_NAME = 'name'; - -export const FUNCTION_TYPE = 'function'; -export const OBJECT_TYPE = 'object'; - -export const ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +export const ens: any = {}; +export const gs: any = {}; const EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; - const IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); export interface PatchEventTargetOptions { - validateHandler?: (nativeDelegate: any, delegate: any, target: any, args: any) => boolean; - addEventListenerFnName?: string; - removeEventListenerFnName?: string; - prependEventListenerFnName?: string; - listenersFnName?: string; - removeAllFnName?: string; - useGlobalCallback?: boolean; - checkDuplicate?: boolean; - returnTarget?: boolean; - compareTaskCallbackVsDelegate?: (task: any, delegate: any) => boolean; + // validateHandler + vh?: (nativeDelegate: any, delegate: any, target: any, args: any) => boolean; + // addEventListener function name + add?: string; + // removeEventListener function name + rm?: string; + // prependEventListener function name + prepend?: string; + // listeners function name + listeners?: string; + // removeAllListeners function name + rmAll?: string; + // useGlobalCallback flag + useG?: boolean; + // check duplicate flag when addEventListener + chkDup?: boolean; + // return target flag when addEventListener + rt?: boolean; + // event compare handler + diff?: (task: any, delegate: any) => boolean; } export function patchEventTarget( _global: any, apis: any[], patchOptions?: PatchEventTargetOptions) { - const ADD_EVENT_LISTENER = - (patchOptions && patchOptions.addEventListenerFnName) || 'addEventListener'; - const REMOVE_EVENT_LISTENER = - (patchOptions && patchOptions.removeEventListenerFnName) || 'removeEventListener'; + const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || g; + const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || h; - const LISTENERS_EVENT_LISTENER = - (patchOptions && patchOptions.listenersFnName) || 'eventListeners'; + const LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; const REMOVE_ALL_LISTENERS_EVENT_LISTENER = - (patchOptions && patchOptions.removeAllFnName) || 'removeAllListeners'; + (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); @@ -75,7 +75,7 @@ export function patchEventTarget( return; } const delegate = task.callback; - if (typeof delegate === OBJECT_TYPE && delegate.handleEvent) { + if (typeof delegate === p && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = (event: Event) => delegate.handleEvent(event); task.originalDelegate = delegate; @@ -83,7 +83,7 @@ export function patchEventTarget( // invoke static task.invoke task.invoke(task, target, [event]); const options = task.options; - if (options && typeof options === 'object' && options.once) { + if (options && typeof options === p && options.once) { // if options.once is true, after invoke once remove listener here // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once @@ -103,7 +103,7 @@ export function patchEventTarget( // event.target is needed for Samusung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 const target: any = this || event.target || _global; - const tasks = target[zoneSymbolEventNames[event.type][FALSE_STR]]; + const tasks = target[ens[event.type][l]]; if (tasks) { // invoke all tasks which attached to current target with given event.type and capture = false // for performance concern, if task.length === 1, just invoke @@ -135,7 +135,7 @@ export function patchEventTarget( // event.target is needed for Samusung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 const target: any = this || event.target || _global; - const tasks = target[zoneSymbolEventNames[event.type][TRUE_STR]]; + const tasks = target[ens[event.type][k]]; if (tasks) { // invoke all tasks which attached to current target with given event.type and capture = false // for performance concern, if task.length === 1, just invoke @@ -162,24 +162,24 @@ export function patchEventTarget( } let useGlobalCallback = true; - if (patchOptions && patchOptions.useGlobalCallback !== undefined) { - useGlobalCallback = patchOptions.useGlobalCallback; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; } - const validateHandler = patchOptions && patchOptions.validateHandler; + const validateHandler = patchOptions && patchOptions.vh; let checkDuplicate = true; - if (patchOptions && patchOptions.checkDuplicate !== undefined) { - checkDuplicate = patchOptions.checkDuplicate; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; } let returnTarget = false; - if (patchOptions && patchOptions.returnTarget !== undefined) { - returnTarget = patchOptions.returnTarget; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; } let proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = Object.getPrototypeOf(proto); + proto = d(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -207,9 +207,9 @@ export function patchEventTarget( proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; let nativePrependEventListener: any; - if (patchOptions && patchOptions.prependEventListenerFnName) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prependEventListenerFnName)] = - proto[patchOptions.prependEventListenerFnName]; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; } const customScheduleGlobal = function(task: Task) { @@ -230,10 +230,10 @@ export function patchEventTarget( // from Zone.prototype.cancelTask, we should remove the task // from tasksList of target first if (!task.isRemoved) { - const symbolEventNames = zoneSymbolEventNames[task.eventName]; + const symbolEventNames = ens[task.eventName]; let symbolEventName; if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + symbolEventName = symbolEventNames[task.capture ? k : l]; } const existingTasks = symbolEventName && task.target[symbolEventName]; if (existingTasks) { @@ -286,26 +286,24 @@ export function patchEventTarget( const compareTaskCallbackVsDelegate = function(task: any, delegate: any) { const typeOfDelegate = typeof delegate; - if ((typeOfDelegate === FUNCTION_TYPE && task.callback === delegate) || - (typeOfDelegate === OBJECT_TYPE && task.originalDelegate === delegate)) { + if ((typeOfDelegate === n && task.callback === delegate) || + (typeOfDelegate === p && task.originalDelegate === delegate)) { // same callback, same capture, same event name, just return return true; } return false; }; - const compare = (patchOptions && patchOptions.compareTaskCallbackVsDelegate) ? - patchOptions.compareTaskCallbackVsDelegate : - compareTaskCallbackVsDelegate; + const compare = + (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - const blackListedEvents: string[] = (Zone as any)[Zone.__symbol__('BLACK_LISTED_EVENTS')]; + const blackListedEvents: string[] = (Zone as any)[(Zone as any).s('BLACK_LISTED_EVENTS')]; const makeAddListener = function( nativeListener: any, addSource: string, customScheduleFn: any, customCancelFn: any, returnTarget = false, prepend = false) { return function() { const target = this || _global; - const targetZone = Zone.current; let delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); @@ -315,7 +313,7 @@ export function patchEventTarget( // case here to improve addEventListener performance // we will create the bind delegate when invoke let isHandleEvent = false; - if (typeof delegate !== FUNCTION_TYPE) { + if (typeof delegate !== n) { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -351,21 +349,21 @@ export function patchEventTarget( once = options ? !!options.once : false; } - const zone = Zone.current; - const symbolEventNames = zoneSymbolEventNames[eventName]; + const zone = (Zone as any).c; + const symbolEventNames = ens[eventName]; let symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - const falseEventName = eventName + FALSE_STR; - const trueEventName = eventName + TRUE_STR; - const symbol = ZONE_SYMBOL_PREFIX + falseEventName; - const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + const falseEventName = eventName + l; + const trueEventName = eventName + k; + const symbol = m + falseEventName; + const symbolCapture = m + trueEventName; + ens[eventName] = {}; + ens[eventName][l] = symbol; + ens[eventName][k] = symbolCapture; symbolEventName = capture ? symbolCapture : symbol; } else { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + symbolEventName = symbolEventNames[capture ? k : l]; } let existingTasks = target[symbolEventName]; let isExisting = false; @@ -384,8 +382,8 @@ export function patchEventTarget( existingTasks = target[symbolEventName] = []; } let source; - const constructorName = target.constructor[CONSTRUCTOR_NAME]; - const targetSource = globalSources[constructorName]; + const constructorName = target.constructor['name']; + const targetSource = gs[constructorName]; if (targetSource) { source = targetSource[eventName]; } @@ -414,7 +412,7 @@ export function patchEventTarget( } const task: any = - zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + (zone as any).se(source, delegate, data, customScheduleFn, customCancelFn); // should clear taskData.target to avoid memory leak // issue, https://github.com/angular/angular/issues/20442 @@ -485,10 +483,10 @@ export function patchEventTarget( return; } - const symbolEventNames = zoneSymbolEventNames[eventName]; + const symbolEventNames = ens[eventName]; let symbolEventName; if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + symbolEventName = symbolEventNames[capture ? k : l]; } const existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { @@ -505,7 +503,7 @@ export function patchEventTarget( (existingTask as any).allRemoved = true; target[symbolEventName] = null; } - existingTask.zone.cancelTask(existingTask); + (existingTask.zone as any).ct(existingTask); return; } } @@ -553,10 +551,10 @@ export function patchEventTarget( // remove removeListener listener finally this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); } else { - const symbolEventNames = zoneSymbolEventNames[eventName]; + const symbolEventNames = ens[eventName]; if (symbolEventNames) { - const symbolEventName = symbolEventNames[FALSE_STR]; - const symbolCaptureEventName = symbolEventNames[TRUE_STR]; + const symbolEventName = symbolEventNames[l]; + const symbolCaptureEventName = symbolEventNames[k]; const tasks = target[symbolEventName]; const captureTasks = target[symbolCaptureEventName]; diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 7d0484f4a..c9a7a0ddf 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -5,7 +5,12 @@ * 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.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const a = Object.getOwnPropertyDescriptor; + const b = Object.defineProperty; + const n = 'function'; + const p = 'object'; + function readableObjectToString(obj: any) { if (obj && obj.toString === Object.prototype.toString) { const className = obj.constructor && obj.constructor.name; @@ -48,7 +53,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr while (_uncaughtPromiseErrors.length) { const uncaughtPromiseError: UncaughtPromiseError = _uncaughtPromiseErrors.shift(); try { - uncaughtPromiseError.zone.runGuarded(() => { + (uncaughtPromiseError.zone as any).rg(() => { throw uncaughtPromiseError; }); } catch (error) { @@ -64,7 +69,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr api.onUnhandledError(e); try { const handler = (Zone as any)[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { + if (handler && typeof handler === n) { handler.apply(this, [e]); } } catch (err) { @@ -117,8 +122,6 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr }; const TYPE_ERROR = 'Promise resolved with itself'; - const OBJECT = 'object'; - const FUNCTION = 'function'; const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution @@ -132,7 +135,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr // should only get value.then once based on promise spec. let then: any = null; try { - if (typeof value === OBJECT || typeof value === FUNCTION) { + if (typeof value === p || typeof value === n) { then = value && value.then; } } catch (err) { @@ -147,7 +150,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr (value as any)[symbolState] !== UNRESOLVED) { clearRejectedNoCatch(>value); resolvePromise(promise, (value as any)[symbolState], (value as any)[symbolValue]); - } else if (state !== REJECTED && typeof then === FUNCTION) { + } else if (state !== REJECTED && typeof then === n) { try { then.apply(value, [ onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)) @@ -170,9 +173,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr (Zone.currentTask.data as any)[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone - Object.defineProperty( - value, CURRENT_TASK_TRACE_SYMBOL, - {configurable: true, enumerable: false, writable: true, value: trace}); + b(value, CURRENT_TASK_TRACE_SYMBOL, + {configurable: true, enumerable: false, writable: true, value: trace}); } } @@ -190,7 +192,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr const error: UncaughtPromiseError = err; error.rejection = value; error.promise = promise; - error.zone = Zone.current; + error.zone = (Zone as any).c; error.task = Zone.currentTask; _uncaughtPromiseErrors.push(error); api.scheduleMicroTask(); // to make sure that it is running @@ -212,7 +214,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr // eventHandler try { const handler = (Zone as any)[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === FUNCTION) { + if (handler && typeof handler === n) { handler.apply(this, [{rejection: (promise as any)[symbolValue], promise: promise}]); } } catch (err) { @@ -231,12 +233,13 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr onFulfilled?: (value: R) => U1, onRejected?: (error: any) => U2): void { clearRejectedNoCatch(promise); const delegate = (promise as any)[symbolState] ? - (typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution : - (typeof onRejected === FUNCTION) ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, () => { + (typeof onFulfilled === n) ? onFulfilled : forwardResolution : + (typeof onRejected === n) ? onRejected : forwardRejection; + (zone as any).si(source, () => { try { resolvePromise( - chainPromise, true, zone.run(delegate, undefined, [(promise as any)[symbolValue]])); + chainPromise, true, + (zone as any).r(delegate, undefined, [(promise as any)[symbolValue]])); } catch (error) { resolvePromise(chainPromise, false, error); } @@ -331,7 +334,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr null): Promise { const chainPromise: Promise = new (this.constructor as typeof ZoneAwarePromise)(null); - const zone = Zone.current; + const zone = (Zone as any).c; if ((this as any)[symbolState] == UNRESOLVED) { ((this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected); } else { @@ -353,9 +356,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr ZoneAwarePromise['all'] = ZoneAwarePromise.all; const NativePromise = global[symbolPromise] = global['Promise']; - const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + const ZONE_AWARE_PROMISE = (Zone as any).s('ZoneAwarePromise'); - let desc = Object.getOwnPropertyDescriptor(global, 'Promise'); + let desc = a(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; desc && delete desc.value; @@ -388,7 +391,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr } }; - Object.defineProperty(global, 'Promise', desc); + b(global, 'Promise', desc); } global['Promise'] = ZoneAwarePromise; @@ -403,9 +406,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr // check Ctor.prototype.then propertyDescritor is writable or not // in meteor env, writable is false, we have to make it to be true. - const prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then'); + const prop = a(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { - Object.defineProperty(Ctor.prototype, 'then', {writable: true}); + b(Ctor.prototype, 'then', {writable: true}); } Ctor.prototype.then = function(onResolve: any, onReject: any) { @@ -435,12 +438,12 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr patchThen(NativePromise); let fetch = global['fetch']; - if (typeof fetch == FUNCTION) { + if (typeof fetch == n) { global['fetch'] = zoneify(fetch); } } // This is not part of public API, but it is useful for tests, so we expose it. - (Promise as any)[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + (Promise as any)[(Zone as any).s('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; return ZoneAwarePromise; }); diff --git a/lib/common/timers.ts b/lib/common/timers.ts index 5f8d9aa1e..82266f0ad 100644 --- a/lib/common/timers.ts +++ b/lib/common/timers.ts @@ -10,7 +10,7 @@ * @suppress {missingRequire} */ -import {patchMethod, zoneSymbol} from './utils'; +import {n, patchMethod, q, r, zoneSymbol} from './utils'; const taskSymbol = zoneSymbol('zoneTask'); @@ -26,12 +26,6 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam cancelName += nameSuffix; const tasksByHandleId: {[id: number]: Task} = {}; - const NUMBER = 'number'; - const STRING = 'string'; - const FUNCTION = 'function'; - const INTERVAL = 'Interval'; - const TIMEOUT = 'Timeout'; - const NOT_SCHEDULED = 'notScheduled'; function scheduleTask(task: Task) { const data = task.data; @@ -45,7 +39,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam // setInterval return; } - if (typeof data.handleId === NUMBER) { + if (typeof data.handleId === q) { // in non-nodejs env, we remove timerId // from local cache delete tasksByHandleId[data.handleId]; @@ -67,21 +61,21 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) { - if (typeof args[0] === FUNCTION) { - const zone = Zone.current; + if (typeof args[0] === n) { + const zone = (Zone as any).c; const options: TimerOptions = { handleId: null, - isPeriodic: nameSuffix === INTERVAL, - delay: (nameSuffix === TIMEOUT || nameSuffix === INTERVAL) ? args[1] || 0 : null, + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, args: args }; - const task = zone.scheduleMacroTask(setName, args[0], options, scheduleTask, clearTask); + const task = (zone as any).sc(setName, args[0], options, scheduleTask, clearTask); if (!task) { return task; } // Node.js must additionally support the ref and unref functions. const handle: any = (task.data).handleId; - if (typeof handle === NUMBER) { + if (typeof handle === q) { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -93,12 +87,12 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === FUNCTION && - typeof handle.unref === FUNCTION) { + if (handle && handle.ref && handle.unref && typeof handle.ref === n && + typeof handle.unref === n) { (task).ref = (handle).ref.bind(handle); (task).unref = (handle).unref.bind(handle); } - if (typeof handle === NUMBER || handle) { + if (typeof handle === q || handle) { return handle; } return task; @@ -112,7 +106,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam patchMethod(window, cancelName, (delegate: Function) => function(self: any, args: any[]) { const id = args[0]; let task: Task; - if (typeof id === NUMBER) { + if (typeof id === q) { // non nodejs env. task = tasksByHandleId[id]; } else { @@ -123,16 +117,16 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam task = id; } } - if (task && typeof task.type === STRING) { - if (task.state !== NOT_SCHEDULED && + if (task && typeof task.type === r) { + if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === NUMBER) { + if (typeof id === q) { delete tasksByHandleId[id]; } else if (id) { id[taskSymbol] = null; } // Do not cancel already canceled functions - task.zone.cancelTask(task); + (task.zone as any).ct(task); } } else { // cause an error by calling it directly. diff --git a/lib/common/to-string.ts b/lib/common/to-string.ts index 9e7d7fe71..0499f6016 100644 --- a/lib/common/to-string.ts +++ b/lib/common/to-string.ts @@ -5,24 +5,23 @@ * 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 './utils'; +import {n, zoneSymbol} from './utils'; // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('toString', (global: any, Zone: ZoneType) => { // patch Func.prototype.toString to let them look like native const originalFunctionToString = (Zone as any)['__zone_symbol__originalToString'] = Function.prototype.toString; - const FUNCTION = 'function'; const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); const PROMISE_SYMBOL = zoneSymbol('Promise'); const ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function() { - if (typeof this === FUNCTION) { + if (typeof this === n) { const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === FUNCTION) { + if (typeof originalDelegate === n) { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { return Object.prototype.toString.call(originalDelegate); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 938935f77..b792439a1 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -11,50 +11,51 @@ * @suppress {undefinedVars,globalThis,missingRequire} */ +// issue #989, to reduce bundle size, use short name +export const a = Object.getOwnPropertyDescriptor; +export const b = Object.defineProperty; +export const c = Object.defineProperties; +export const d = Object.getPrototypeOf; +export const e = Object.create; +export const f = Array.prototype.slice; +export const g = 'addEventListener'; +export const h = 'removeEventListener'; +export const i = (Zone as any).s(g); +export const j = (Zone as any).s(h); +export const k = 'true'; +export const l = 'false'; +export const m = '__zone_symbol__'; +export const n = 'function'; +export const o = 'undefined'; +export const p = 'object'; +export const q = 'number'; +export const r = 'string'; + // Hack since TypeScript isn't compiling this for a worker. declare const WorkerGlobalScope: any; export const zoneSymbol = Zone.__symbol__; -const _global: any = - typeof window === 'object' && window || typeof self === 'object' && self || global; +const _global: any = typeof window === p && window || typeof self === p && self || global; -const FUNCTION = 'function'; -const UNDEFINED = 'undefined'; const REMOVE_ATTRIBUTE = 'removeAttribute'; const NULL_ON_PROP_VALUE: any[] = [null]; export function bindArguments(args: any[], source: string): any[] { for (let i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === FUNCTION) { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + if (typeof args[i] === n) { + args[i] = (Zone as any).c.w(args[i], source + '_' + i); } } return args; } -export function wrapFunctionArgs(func: Function, source?: string): Function { - return function() { - const args = Array.prototype.slice.call(arguments); - const wrappedArgs = bindArguments(args, source ? source : (func as any).name); - return func.apply(this, wrappedArgs); - }; -} - -export function patchArguments(target: any, name: string, source: string): Function { - return patchMethod( - target, name, - (delegate: Function, delegateName: string, name: string) => (self: any, args: any[]) => { - return delegate && delegate.apply(self, bindArguments(args, source)); - }); -} - export function patchPrototype(prototype: any, fnNames: string[]) { const source = prototype.constructor['name']; for (let i = 0; i < fnNames.length; i++) { const name = fnNames[i]; const delegate = prototype[name]; if (delegate) { - const prototypeDesc = Object.getOwnPropertyDescriptor(prototype, name); + const prototypeDesc = a(prototype, name); if (!isPropertyWritable(prototypeDesc)) { continue; } @@ -78,7 +79,7 @@ export function isPropertyWritable(propertyDesc: any) { return false; } - if (typeof propertyDesc.get === FUNCTION && typeof propertyDesc.set === UNDEFINED) { + if (typeof propertyDesc.get === n && typeof propertyDesc.set === o) { return false; } @@ -86,23 +87,23 @@ export function isPropertyWritable(propertyDesc: any) { } export const isWebWorker: boolean = - (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + (typeof WorkerGlobalScope !== o && self instanceof WorkerGlobalScope); // Make sure to access `process` through `_global` so that WebPack does not accidently browserify // this code. export const isNode: boolean = - (!('nw' in _global) && typeof _global.process !== 'undefined' && + (!('nw' in _global) && typeof _global.process !== o && {}.toString.call(_global.process) === '[object process]'); export const isBrowser: boolean = - !isNode && !isWebWorker && !!(typeof window !== 'undefined' && (window as any)['HTMLElement']); + !isNode && !isWebWorker && !!(typeof window !== o && (window as any)['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs // Make sure to access `process` through `_global` so that WebPack does not accidently browserify // this code. -export const isMix: boolean = typeof _global.process !== 'undefined' && +export const isMix: boolean = typeof _global.process !== o && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== 'undefined' && (window as any)['HTMLElement']); + !!(typeof window !== o && (window as any)['HTMLElement']); const zoneSymbolEventNames: {[eventName: string]: string} = {}; @@ -128,10 +129,10 @@ const wrapFn = function(event: Event) { }; export function patchProperty(obj: any, prop: string, prototype?: any) { - let desc = Object.getOwnPropertyDescriptor(obj, prop); + let desc = a(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - const prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); + const prototypeDesc = a(prototype, prop); if (prototypeDesc) { desc = {enumerable: true, configurable: true}; } @@ -181,7 +182,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { originalDescSet.apply(target, NULL_ON_PROP_VALUE); } - if (typeof newValue === 'function') { + if (typeof newValue === n) { target[eventNameSymbol] = newValue; target.addEventListener(eventName, wrapFn, false); } else { @@ -214,7 +215,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { let value = originalDescGet && originalDescGet.apply(this); if (value) { desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === FUNCTION) { + if (typeof target[REMOVE_ATTRIBUTE] === n) { target.removeAttribute(prop); } return value; @@ -223,7 +224,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { return null; }; - Object.defineProperty(obj, prop, desc); + b(obj, prop, desc); } export function patchOnProperties(obj: any, properties: string[], prototype?: any) { @@ -286,15 +287,15 @@ export function patchClass(className: string) { // https://bugs.webkit.org/show_bug.cgi?id=44721 if (className === 'XMLHttpRequest' && prop === 'responseBlob') continue; (function(prop) { - if (typeof instance[prop] === 'function') { + if (typeof instance[prop] === n) { _global[className].prototype[prop] = function() { return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); }; } else { - Object.defineProperty(_global[className].prototype, prop, { + b(_global[className].prototype, prop, { set: function(fn) { - if (typeof fn === 'function') { - this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); + if (typeof fn === n) { + this[originalInstanceKey][prop] = (Zone as any).c.w(fn, className + '.' + prop); // keep callback in wrapped function so we can // use it in Function.prototype.toString to return // the native one. @@ -324,7 +325,7 @@ export function patchMethod( any): Function { let proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = Object.getPrototypeOf(proto); + proto = d(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -337,7 +338,7 @@ export function patchMethod( delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - const desc = proto && Object.getOwnPropertyDescriptor(proto, name); + const desc = proto && a(proto, name); if (isPropertyWritable(desc)) { const patchDelegate = patchFn(delegate, delegateName, name); proto[name] = function() { @@ -352,7 +353,7 @@ export function patchMethod( export interface MacroTaskMeta extends TaskData { name: string; target: any; - callbackIndex: number; + cbIdx: number; args: any[]; } @@ -363,7 +364,7 @@ export function patchMacroTask( function scheduleTask(task: Task) { const data = task.data; - data.args[data.callbackIndex] = function() { + data.args[data.cbIdx] = function() { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -372,9 +373,8 @@ export function patchMacroTask( setNative = patchMethod(obj, funcName, (delegate: Function) => function(self: any, args: any[]) { const meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - const task = Zone.current.scheduleMacroTask( - meta.name, args[meta.callbackIndex], meta, scheduleTask, null); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === n) { + const task = (Zone as any).c.sc(meta.name, args[meta.cbIdx], meta, scheduleTask, null); return task; } else { // cause an error by calling it directly. @@ -386,7 +386,7 @@ export function patchMacroTask( export interface MicroTaskMeta extends TaskData { name: string; target: any; - callbackIndex: number; + cbIdx: number; args: any[]; } @@ -396,7 +396,7 @@ export function patchMicroTask( function scheduleTask(task: Task) { const data = task.data; - data.args[data.callbackIndex] = function() { + data.args[data.cbIdx] = function() { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -405,9 +405,8 @@ export function patchMicroTask( setNative = patchMethod(obj, funcName, (delegate: Function) => function(self: any, args: any[]) { const meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - const task = - Zone.current.scheduleMicroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === n) { + const task = (Zone as any).c.si(meta.name, args[meta.cbIdx], meta, scheduleTask); return task; } else { // cause an error by calling it directly. @@ -432,7 +431,6 @@ export function isIEOrEdge() { try { const ua = window.navigator.userAgent; - const msie = ua.indexOf('MSIE '); if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } diff --git a/lib/extra/bluebird.ts b/lib/extra/bluebird.ts index 0a70f5cbf..d3f9b9cca 100644 --- a/lib/extra/bluebird.ts +++ b/lib/extra/bluebird.ts @@ -5,7 +5,7 @@ * 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.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // TODO: @JiaLiPassion, we can automatically patch bluebird // if global.Promise = Bluebird, but sometimes in nodejs, // global.Promise is not Bluebird, and Bluebird is just be @@ -14,7 +14,7 @@ Zone.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) = const BLUEBIRD = 'bluebird'; (Zone as any)[Zone.__symbol__(BLUEBIRD)] = function patchBluebird(Bluebird: any) { Bluebird.setScheduler((fn: Function) => { - Zone.current.scheduleMicroTask(BLUEBIRD, fn); + (Zone as any).c.si(BLUEBIRD, fn); }); }; -}); \ No newline at end of file +}); diff --git a/lib/extra/cordova.ts b/lib/extra/cordova.ts index 5f8518ce5..4d32a46a0 100644 --- a/lib/extra/cordova.ts +++ b/lib/extra/cordova.ts @@ -5,7 +5,7 @@ * 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.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => { if (global.cordova) { const SUCCESS_SOURCE = 'cordova.exec.success'; const ERROR_SOURCE = 'cordova.exec.error'; @@ -13,17 +13,17 @@ Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => const nativeExec: Function = api.patchMethod( global.cordova, 'exec', (delegate: Function) => function(self: any, args: any[]) { if (args.length > 0 && typeof args[0] === FUNCTION) { - args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE); + args[0] = (Zone as any).c.w(args[0], SUCCESS_SOURCE); } if (args.length > 1 && typeof args[1] === FUNCTION) { - args[1] = Zone.current.wrap(args[1], ERROR_SOURCE); + args[1] = (Zone as any).c.w(args[1], ERROR_SOURCE); } return nativeExec.apply(self, args); }); } }); -Zone.__load_patch('cordova.FileReader', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('cordova.FileReader', (global: any, Zone: ZoneType, api: _ZonePrivate) => { if (global.cordova && typeof global['FileReader'] !== 'undefined') { document.addEventListener('deviceReady', () => { const FileReader = global['FileReader']; @@ -38,4 +38,4 @@ Zone.__load_patch('cordova.FileReader', (global: any, Zone: ZoneType, api: _Zone }); }); } -}); \ No newline at end of file +}); diff --git a/lib/extra/electron.ts b/lib/extra/electron.ts index 7f618f48c..9ed842b21 100644 --- a/lib/extra/electron.ts +++ b/lib/extra/electron.ts @@ -5,17 +5,21 @@ * 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.__load_patch('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - const FUNCTION = 'function'; +(Zone as any).l('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + function patchArguments(target: any, name: string, source: string): Function { + return api.patchMethod(target, name, (delegate: Function) => (self: any, args: any[]) => { + return delegate && delegate.apply(self, api.bindArguments(args, source)); + }); + } const {desktopCapturer, shell, CallbackRegistry} = require('electron'); // patch api in renderer process directly // desktopCapturer if (desktopCapturer) { - api.patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources'); + patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources'); } // shell if (shell) { - api.patchArguments(shell, 'openExternal', 'electron.shell.openExternal'); + patchArguments(shell, 'openExternal', 'electron.shell.openExternal'); } // patch api in main process through CallbackRegistry @@ -23,5 +27,5 @@ Zone.__load_patch('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) = return; } - api.patchArguments(CallbackRegistry.prototype, 'add', 'CallbackRegistry.add'); -}); \ No newline at end of file + patchArguments(CallbackRegistry.prototype, 'add', 'CallbackRegistry.add'); +}); diff --git a/lib/node/events.ts b/lib/node/events.ts index 3130b93ad..223721f1d 100644 --- a/lib/node/events.ts +++ b/lib/node/events.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {globalSources, patchEventTarget, zoneSymbolEventNames} from '../common/events'; +import {ens, gs, patchEventTarget} from '../common/events'; -Zone.__load_patch('EventEmitter', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('EventEmitter', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const callAndReturnFirstParam = (fn: (self: any, args: any[]) => any) => { return (self: any, args: any[]) => { fn(self, args); @@ -34,15 +34,15 @@ Zone.__load_patch('EventEmitter', (global: any, Zone: ZoneType, api: _ZonePrivat function patchEventEmitterMethods(obj: any) { const result = patchEventTarget(global, [obj], { - useGlobalCallback: false, - addEventListenerFnName: EE_ADD_LISTENER, - removeEventListenerFnName: EE_REMOVE_LISTENER, - prependEventListenerFnName: EE_PREPEND_LISTENER, - removeAllFnName: EE_REMOVE_ALL_LISTENER, - listenersFnName: EE_LISTENERS, - checkDuplicate: false, - returnTarget: true, - compareTaskCallbackVsDelegate: compareTaskCallbackVsDelegate + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; diff --git a/lib/node/fs.ts b/lib/node/fs.ts index 79de87a30..11c115436 100644 --- a/lib/node/fs.ts +++ b/lib/node/fs.ts @@ -8,7 +8,7 @@ import {patchMacroTask} from '../common/utils'; -Zone.__load_patch('fs', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('fs', (global: any, Zone: ZoneType, api: _ZonePrivate) => { let fs: any; try { fs = require('fs'); @@ -32,10 +32,10 @@ Zone.__load_patch('fs', (global: any, Zone: ZoneType, api: _ZonePrivate) => { return { name: 'fs.' + name, args: args, - callbackIndex: args.length > 0 ? args.length - 1 : -1, + cbIdx: args.length > 0 ? args.length - 1 : -1, target: self }; }); }); } -}); \ No newline at end of file +}); diff --git a/lib/node/node.ts b/lib/node/node.ts index 78111dc79..388d00195 100644 --- a/lib/node/node.ts +++ b/lib/node/node.ts @@ -11,18 +11,18 @@ import './fs'; import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {isMix, patchArguments, patchMacroTask, patchMethod, patchMicroTask, patchOnProperties} from '../common/utils'; +import {bindArguments, f, isMix, patchMacroTask, patchMethod, patchMicroTask, patchOnProperties} from '../common/utils'; const set = 'set'; const clear = 'clear'; -Zone.__load_patch('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('node_timers', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('node_timers', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // Timers let globalUseTimeoutFromTimer = false; try { @@ -76,20 +76,20 @@ Zone.__load_patch('node_timers', (global: any, Zone: ZoneType, api: _ZonePrivate }); // patch process related methods -Zone.__load_patch('nextTick', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('nextTick', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // patch nextTick as microTask patchMicroTask(process, 'nextTick', (self: any, args: any[]) => { return { name: 'process.nextTick', args: args, - callbackIndex: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, target: process }; }); }); -Zone.__load_patch( - 'handleUnhandledPromiseRejection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any) + .l('handleUnhandledPromiseRejection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { (Zone as any)[api.symbol('unhandledPromiseRejectionHandler')] = findProcessPromiseRejectionHandler('unhandledRejection'); @@ -116,7 +116,7 @@ Zone.__load_patch( // Crypto -Zone.__load_patch('crypto', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('crypto', (global: any, Zone: ZoneType, api: _ZonePrivate) => { let crypto: any; try { crypto = require('crypto'); @@ -131,7 +131,7 @@ Zone.__load_patch('crypto', (global: any, Zone: ZoneType, api: _ZonePrivate) => return { name: 'crypto.' + name, args: args, - callbackIndex: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? args.length - 1 : -1, target: crypto @@ -141,15 +141,15 @@ Zone.__load_patch('crypto', (global: any, Zone: ZoneType, api: _ZonePrivate) => } }); -Zone.__load_patch('console', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +(Zone as any).l('console', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; consoleMethods.forEach((m: string) => { const originalMethod = (console as any)[Zone.__symbol__(m)] = (console as any)[m]; if (originalMethod) { (console as any)[m] = function() { - const args = Array.prototype.slice.call(arguments); - if (Zone.current === Zone.root) { + const args = f.call(arguments); + if ((Zone as any).c === Zone.root) { return originalMethod.apply(this, args); } else { return Zone.root.run(originalMethod, this, args); diff --git a/lib/rxjs/rxjs.ts b/lib/rxjs/rxjs.ts index 23d5287a9..11c116b8a 100644 --- a/lib/rxjs/rxjs.ts +++ b/lib/rxjs/rxjs.ts @@ -19,14 +19,11 @@ import {Subscriber} from 'rxjs/Subscriber'; import {Subscription} from 'rxjs/Subscription'; import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; -(Zone as any).__load_patch('rxjs', (global: any, Zone: ZoneType, api: any) => { +(Zone as any).__load_patch('rxjs', (global: any, Zone: ZoneType) => { const symbol: (symbolString: string) => string = (Zone as any).__symbol__; - const subscribeSource = 'rxjs.subscribe'; const nextSource = 'rxjs.Subscriber.next'; const errorSource = 'rxjs.Subscriber.error'; const completeSource = 'rxjs.Subscriber.complete'; - const unsubscribeSource = 'rxjs.Subscriber.unsubscribe'; - const teardownSource = 'rxjs.Subscriber.teardownLogic'; const empty = { closed: true, @@ -321,7 +318,6 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; } const scheduleSymbol = symbol('scheduleSymbol'); - const flushSymbol = symbol('flushSymbol'); const zoneSymbol = symbol('zone'); if (asap[scheduleSymbol]) { return; @@ -359,4 +355,4 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; patchObservableFactoryArgs(Observable, 'fromEventPattern'); patchMulticast(); patchImmediate(asap); -}); \ No newline at end of file +}); diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 5123743a5..31f1fae35 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -330,7 +330,7 @@ // arguments let addtionalArgs: any[]; if (args) { - let callbackIndex = (task.data as any).callbackIndex; + let callbackIndex = (task.data as any).cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { addtionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } diff --git a/lib/zone.ts b/lib/zone.ts index 038a88e74..d65149400 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -327,7 +327,7 @@ interface _ZonePrivate { (target: any, name: string, patchFn: (delegate: Function, delegateName: string, name: string) => (self: any, args: any[]) => any) => Function; - patchArguments: (target: any, name: string, source: string) => Function; + bindArguments: (args: any[], source: string) => any[]; } /** @internal */ @@ -656,7 +656,7 @@ const Zone: ZoneType = (function(global: any) { } static get root(): AmbientZone { - let zone = Zone.current; + let zone = Zone.c; while (zone.parent) { zone = zone.parent; } @@ -667,6 +667,10 @@ const Zone: ZoneType = (function(global: any) { return _currentZoneFrame.zone; } + static get c(): AmbientZone { + return _currentZoneFrame.zone; + } + static get currentTask(): Task { return _currentTask; } @@ -1167,7 +1171,8 @@ const Zone: ZoneType = (function(global: any) { this.cancelFn = cancelFn; this.callback = callback; const self = this; - if (type === eventTask && options && (options as any).isUsingGlobalCallback) { + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && (options as any).useG) { this.invoke = ZoneTask.invokeTask; } else { this.invoke = function() { @@ -1318,7 +1323,7 @@ const Zone: ZoneType = (function(global: any) { patchEventTarget: () => [], patchOnProperties: noop, patchMethod: () => noop, - patchArguments: () => noop, + bindArguments: () => null, setNativePromise: (NativePromise: any) => { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -1338,7 +1343,19 @@ const Zone: ZoneType = (function(global: any) { return '__zone_symbol__' + name; } - performanceMeasure('Zone', 'Zone'); + const z: any = Zone.prototype; + z.w = z.wrap; + z.f = z.fork; + z.r = z.run; + z.rg = z.runGuarded; + z.rt = z.runTask; + z.st = z.scheduleTask; + z.sc = z.scheduleMacroTask; + z.si = z.scheduleMicroTask; + z.se = z.scheduleEventTask; + z.ct = z.cancelTask; + (Zone as any).l = Zone.__load_patch; + (Zone as any).s = Zone.__symbol__; return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 1c16e96a8..bdefeff31 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -10,6 +10,7 @@ if (typeof window !== 'undefined') { } import '../lib/common/to-string'; import '../lib/browser/browser'; +import '../lib/browser/webapis-user-media'; import '../lib/zone-spec/async-test'; import '../lib/zone-spec/fake-async-test'; import '../lib/zone-spec/long-stack-trace'; @@ -17,4 +18,4 @@ import '../lib/zone-spec/proxy'; import '../lib/zone-spec/sync-test'; import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; -import '../lib/extra/cordova'; \ No newline at end of file +import '../lib/extra/cordova'; diff --git a/test/browser_entry_point.ts b/test/browser_entry_point.ts index 0d49c69af..4ec6e5776 100644 --- a/test/browser_entry_point.ts +++ b/test/browser_entry_point.ts @@ -25,4 +25,3 @@ import './browser/Worker.spec'; import './mocha-patch.spec'; import './jasmine-patch.spec'; import './extra/cordova.spec'; -import './rxjs/rxjs.spec'; \ No newline at end of file diff --git a/test/common/util.spec.ts b/test/common/util.spec.ts index 9d450cab1..b6b122d10 100644 --- a/test/common/util.spec.ts +++ b/test/common/util.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {patchMethod, patchProperty, patchPrototype, wrapFunctionArgs, zoneSymbol} from '../../lib/common/utils'; +import {patchMethod, patchProperty, patchPrototype, zoneSymbol} from '../../lib/common/utils'; describe('utils', function() { @@ -329,30 +329,4 @@ describe('utils', function() { expect(log).toEqual(['property2']); }); }); - - describe('wrapFunctionArgs', () => { - it('wrapFunctionArgs should make function arguments in zone', () => { - const func = function(arg1: string, arg2: Function, arg3: Function) { - arg2(arg1); - arg3(arg1); - }; - - const zone = Zone.current.fork({name: 'wrap'}); - - wrapFunctionArgs(func); - - zone.run(() => { - func( - 'test', - function(arg: string) { - expect(arg).toEqual('test'); - expect(Zone.current.name).toEqual(zone.name); - }, - function(arg: string) { - expect(arg).toEqual('test'); - expect(Zone.current.name).toEqual(zone.name); - }); - }); - }); - }); }); diff --git a/test/common_tests.ts b/test/common_tests.ts index 186274955..bb507dec6 100644 --- a/test/common_tests.ts +++ b/test/common_tests.ts @@ -21,6 +21,6 @@ import './zone-spec/sync-test.spec'; import './zone-spec/fake-async-test.spec'; import './zone-spec/proxy.spec'; import './zone-spec/task-tracking.spec'; -import './rxjs/rxjs.spec'; +// import './rxjs/rxjs.spec'; -Error.stackTraceLimit = Number.POSITIVE_INFINITY; \ No newline at end of file +Error.stackTraceLimit = Number.POSITIVE_INFINITY; diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 8c53da96b..7e2dfe5c8 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -732,7 +732,7 @@ describe('FakeAsyncTestZoneSpec', () => { patchMacroTask( TestClass.prototype, 'myTimeout', (self: any, args: any[]) => - ({name: 'TestClass.myTimeout', target: self, callbackIndex: 0, args: args})); + ({name: 'TestClass.myTimeout', target: self, cbIdx: 0, args: args})); const testClass = new TestClass(); testClass.myTimeout(function(callbackArgs: any) { @@ -758,7 +758,7 @@ describe('FakeAsyncTestZoneSpec', () => { patchMacroTask( TestClass.prototype, 'myTimeout', (self: any, args: any[]) => - ({name: 'TestClass.myTimeout', target: self, callbackIndex: 0, args: args})); + ({name: 'TestClass.myTimeout', target: self, cbIdx: 0, args: args})); const testClass = new TestClass(); testClass.myTimeout(() => { @@ -787,7 +787,7 @@ describe('FakeAsyncTestZoneSpec', () => { patchMacroTask( TestClass.prototype, 'myInterval', (self: any, args: any[]) => - ({name: 'TestClass.myInterval', target: self, callbackIndex: 0, args: args})); + ({name: 'TestClass.myInterval', target: self, cbIdx: 0, args: args})); const testClass = new TestClass(); const id = testClass.myInterval(() => { From 00a4e31632764d22eec621e510512b761da341c4 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sun, 7 Jan 2018 17:40:12 +0900 Subject: [PATCH 002/106] fix(core): fix shorter name closure conflict --- karma-dist.conf.js | 1 + lib/common/utils.ts | 12 +++++++----- test/browser/browser.spec.ts | 1 - test/closure/zone.closure.ts | 8 +++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/karma-dist.conf.js b/karma-dist.conf.js index f6788e1ab..517088ac8 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -12,6 +12,7 @@ module.exports = function (config) { config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); config.files.push('dist/zone.js'); + config.files.push('dist/zone-patch-user-media.js'); config.files.push('dist/async-test.js'); config.files.push('dist/fake-async-test.js'); config.files.push('dist/long-stack-trace-zone.js'); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index b792439a1..0d95b4596 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -31,11 +31,14 @@ export const p = 'object'; export const q = 'number'; export const r = 'string'; + // Hack since TypeScript isn't compiling this for a worker. declare const WorkerGlobalScope: any; export const zoneSymbol = Zone.__symbol__; -const _global: any = typeof window === p && window || typeof self === p && self || global; +const iw = typeof window !== o; +const w: any = iw ? window : undefined; +const _global: any = iw && w || typeof self === p && self || global; const REMOVE_ATTRIBUTE = 'removeAttribute'; const NULL_ON_PROP_VALUE: any[] = [null]; @@ -95,15 +98,14 @@ export const isNode: boolean = (!('nw' in _global) && typeof _global.process !== o && {}.toString.call(_global.process) === '[object process]'); -export const isBrowser: boolean = - !isNode && !isWebWorker && !!(typeof window !== o && (window as any)['HTMLElement']); +export const isBrowser: boolean = !isNode && !isWebWorker && !!(iw && w['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs // Make sure to access `process` through `_global` so that WebPack does not accidently browserify // this code. export const isMix: boolean = typeof _global.process !== o && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== o && (window as any)['HTMLElement']); + !!(iw && w['HTMLElement']); const zoneSymbolEventNames: {[eventName: string]: string} = {}; @@ -430,7 +432,7 @@ export function isIEOrEdge() { isDetectedIEOrEdge = true; try { - const ua = window.navigator.userAgent; + const ua = w.navigator.userAgent; if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 5365aeb21..6276d1e8e 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -2504,7 +2504,6 @@ describe('Zone', function() { const zone = Zone.current.fork({name: 'media'}); zone.run(() => { const constraints = {audio: true, video: {width: 1280, height: 720}}; - navigator.getUserMedia( constraints, () => { diff --git a/test/closure/zone.closure.ts b/test/closure/zone.closure.ts index e9ad5389d..3e5cc3470 100644 --- a/test/closure/zone.closure.ts +++ b/test/closure/zone.closure.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import '../../dist/zone-node'; - +const shortKeys = ['w', 'f', 'r', 'rg', 'rt', 'st', 'sc', 'si', 'se', 'ct']; const testClosureFunction = () => { const logs: string[] = []; // call all Zone exposed functions @@ -69,7 +69,9 @@ const testClosureFunction = () => { logs.push('get' + keyZone.get('key')); logs.push('root' + Zone.root.name); Object.keys((Zone as any).prototype).forEach(key => { - logs.push(key); + if (shortKeys.indexOf(key) === -1) { + logs.push(key); + } }); Object.keys(testZoneSpec).forEach(key => { logs.push(key); @@ -139,4 +141,4 @@ process['on']('uncaughtException', (err: any) => { process['exit'](1); }); -testClosureFunction(); \ No newline at end of file +testClosureFunction(); From 67e8178744e0652091691b4c86e0e5871ebfde6d Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sun, 7 Jan 2018 22:17:58 +0900 Subject: [PATCH 003/106] fix(core): add comment for shorter var/function name --- lib/browser/browser.ts | 9 +++++++++ lib/browser/define-property.ts | 2 ++ lib/browser/event-target.ts | 10 ++++++++++ lib/browser/property-descriptor.ts | 5 +++++ lib/browser/register-element.ts | 1 + lib/browser/websocket.ts | 3 +++ lib/common/events.ts | 15 +++++++++++++++ lib/common/promise.ts | 17 +++++++++++++++++ lib/common/timers.ts | 11 +++++++++++ lib/common/to-string.ts | 1 + lib/common/utils.ts | 20 +++++++++++++++++++- lib/zone.ts | 12 ++++++++++++ 12 files changed, 105 insertions(+), 1 deletion(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 03f3b00db..39981ba64 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -45,6 +45,7 @@ import {registerElementPatch} from './register-element'; const name = blockingMethods[i]; patchMethod(global, name, (delegate, symbol, name) => { return function(s: any, args: any[]) { + // Zone.current.run return (Zone as any).c.r(delegate, global, args, name); }; }); @@ -53,6 +54,7 @@ import {registerElementPatch} from './register-element'; (Zone as any).l('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // load blackListEvents from global + // Zone.__symbol__ const SYMBOL_BLACK_LISTED_EVENTS = (Zone as any).s('BLACK_LISTED_EVENTS'); if (global[SYMBOL_BLACK_LISTED_EVENTS]) { (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; @@ -79,6 +81,7 @@ import {registerElementPatch} from './register-element'; (Zone as any).l('canvas', (global: any) => { const HTMLCanvasElement = global['HTMLCanvasElement']; + // o is 'undefined' if (typeof HTMLCanvasElement !== o && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.toBlob) { patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', (self: any, args: any[]) => { @@ -133,6 +136,8 @@ import {registerElementPatch} from './register-element'; // remove existing event listener const listener = target[XHR_LISTENER]; if (!oriAddListener) { + // i is addEventListener zoneSymbol + // j is removeEventListener zoneSymbol oriAddListener = target[i]; oriRemoveListener = target[j]; } @@ -180,6 +185,7 @@ import {registerElementPatch} from './register-element'; const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; const sendNative: Function = patchMethod(XMLHttpRequestPrototype, 'send', () => function(self: any, args: any[]) { + // Zone.current const zone = (Zone as any).c; if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. @@ -193,6 +199,7 @@ import {registerElementPatch} from './register-element'; args: args, aborted: false }; + // Zone.scheduleMacroTask return zone.sc( XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } @@ -200,6 +207,7 @@ import {registerElementPatch} from './register-element'; const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function(self: any) { const task: Task = findPendingTask(self); + // r is 'string' if (task && typeof task.type == r) { // If the XHR has already completed, do nothing. // If the XHR has already been aborted, do nothing. @@ -208,6 +216,7 @@ import {registerElementPatch} from './register-element'; if (task.cancelFn == null || (task.data && (task.data).aborted)) { return; } + // Zone.cancelTask (task.zone as any).ct(task); } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index ae966c86e..c727bba63 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -38,6 +38,7 @@ export function propertyPatch() { }; Object.create = function(obj: any, proto: any) { + // o is 'object' string if (typeof proto === p && !Object.isFrozen(proto)) { Object.keys(proto).forEach(function(prop) { proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); @@ -89,6 +90,7 @@ function _tryDefineProperty(obj: any, prop: string, desc: any, originalConfigura if (desc.configurable) { // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's // retry with the original flag value + // o is 'undefined' string if (typeof originalConfigurableFlag == o) { delete desc.configurable; } else { diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index d0bb6a897..cf957239b 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -45,18 +45,26 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { // predefine all __zone_symbol__ + eventName + true/false string for (let i = 0; i < eventNames.length; i++) { const eventName = eventNames[i]; + // l is 'false' string const falseEventName = eventName + l; + // k is 'true' string const trueEventName = eventName + k; + // m is '__zone_symbol__' string const symbol = m + falseEventName; + // m is '__zone_symbol__' string const symbolCapture = m + trueEventName; + // ens is globalEventNames cache ens[eventName] = {}; + // l is 'false' string ens[eventName][l] = symbol; + // k is 'true' string ens[eventName][k] = symbolCapture; } // predefine all task.source string for (let i = 0; i < WTF_ISSUE_555.length; i++) { const target: any = WTF_ISSUE_555_ARRAY[i]; + // gs is global source cache const targets: any = gs[target] = {}; for (let j = 0; j < eventNames.length; j++) { const eventName = eventNames[j]; @@ -101,6 +109,8 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { const type = _global[apis[i]]; apiTypes.push(type && type.prototype); } + // vh is validateHandler to check event handler + // is valid or not(for security check) patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); api.patchEventTarget = patchEventTarget; diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index f8945947e..070e3a6fe 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -265,6 +265,7 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { return; } + // o is 'undefined' string const supportsWebSocket = typeof WebSocket !== o; if (canPatchViaPropertyDescriptor()) { const ignoreProperties: IgnoreProperty[] = _global.__Zone_ignore_on_properties; @@ -306,6 +307,7 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); } + // o is 'undefined' string if (typeof IDBIndex !== o) { patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); @@ -338,6 +340,7 @@ function canPatchViaPropertyDescriptor() { const ON_READY_STATE_CHANGE = 'onreadystatechange'; const XMLHttpRequestPrototype = XMLHttpRequest.prototype; + // a is Object.getOwnPropertyDescriptor const xhrDesc = a(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera @@ -347,6 +350,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { + // b is Object.defineProperty b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, @@ -398,6 +402,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { + // Zone.current.wrap bound = (Zone as any).c.w(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index 74e1ccd05..ad877c52d 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -25,6 +25,7 @@ export function registerElementPatch(_global: any) { const source = 'Document.registerElement::' + callback; const p = opts.prototype; if (p.hasOwnProperty(callback)) { + // a is Object.getOwnPropertyDescriptor const descriptor = a(p, callback); if (descriptor && descriptor.value) { descriptor.value = (Zone as any).c.w(descriptor.value, source); diff --git a/lib/browser/websocket.ts b/lib/browser/websocket.ts index 5714b6c77..7ecc54232 100644 --- a/lib/browser/websocket.ts +++ b/lib/browser/websocket.ts @@ -24,13 +24,16 @@ export function apply(api: _ZonePrivate, _global: any) { let proxySocketProto: any; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + // a is Object.getOwnPropertyDescriptor const onmessageDesc = a(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { + // e is Object.create proxySocket = e(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method proxySocketProto = socket; + // g is `addEventListener`, h is `removeEventListener` string [g, h, 'send', 'close'].forEach(function(propName) { proxySocket[propName] = function() { const args = f.call(arguments); diff --git a/lib/common/events.ts b/lib/common/events.ts index 5b349ab75..bb5666332 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -75,6 +75,7 @@ export function patchEventTarget( return; } const delegate = task.callback; + // p is 'object' string if (typeof delegate === p && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = (event: Event) => delegate.handleEvent(event); @@ -83,6 +84,7 @@ export function patchEventTarget( // invoke static task.invoke task.invoke(task, target, [event]); const options = task.options; + // p is 'object' string if (options && typeof options === p && options.once) { // if options.once is true, after invoke once remove listener here // only browser need to do this, nodejs eventEmitter will cal removeListener @@ -103,6 +105,7 @@ export function patchEventTarget( // event.target is needed for Samusung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 const target: any = this || event.target || _global; + // l is 'false' string const tasks = target[ens[event.type][l]]; if (tasks) { // invoke all tasks which attached to current target with given event.type and capture = false @@ -135,6 +138,7 @@ export function patchEventTarget( // event.target is needed for Samusung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 const target: any = this || event.target || _global; + // k is 'true' string const tasks = target[ens[event.type][k]]; if (tasks) { // invoke all tasks which attached to current target with given event.type and capture = false @@ -179,6 +183,7 @@ export function patchEventTarget( let proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + // d is Object.getPrototypeOf proto = d(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { @@ -230,9 +235,11 @@ export function patchEventTarget( // from Zone.prototype.cancelTask, we should remove the task // from tasksList of target first if (!task.isRemoved) { + // ens is event names cache const symbolEventNames = ens[task.eventName]; let symbolEventName; if (symbolEventNames) { + // k is 'true' string, l is 'false' string symbolEventName = symbolEventNames[task.capture ? k : l]; } const existingTasks = symbolEventName && task.target[symbolEventName]; @@ -286,6 +293,7 @@ export function patchEventTarget( const compareTaskCallbackVsDelegate = function(task: any, delegate: any) { const typeOfDelegate = typeof delegate; + // n is 'function' string, p is 'object' string if ((typeOfDelegate === n && task.callback === delegate) || (typeOfDelegate === p && task.originalDelegate === delegate)) { // same callback, same capture, same event name, just return @@ -313,6 +321,7 @@ export function patchEventTarget( // case here to improve addEventListener performance // we will create the bind delegate when invoke let isHandleEvent = false; + // n is 'function' string if (typeof delegate !== n) { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); @@ -349,16 +358,20 @@ export function patchEventTarget( once = options ? !!options.once : false; } + // Zone.current const zone = (Zone as any).c; const symbolEventNames = ens[eventName]; let symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance + // l is 'false' string, k is 'true' string const falseEventName = eventName + l; const trueEventName = eventName + k; + // m is '__zone_symbol__' string const symbol = m + falseEventName; const symbolCapture = m + trueEventName; ens[eventName] = {}; + // l is 'false' string, k is 'true' string ens[eventName][l] = symbol; ens[eventName][k] = symbolCapture; symbolEventName = capture ? symbolCapture : symbol; @@ -411,6 +424,7 @@ export function patchEventTarget( (data as any).taskData = taskData; } + // Zone.scehduleEventTask const task: any = (zone as any).se(source, delegate, data, customScheduleFn, customCancelFn); @@ -553,6 +567,7 @@ export function patchEventTarget( } else { const symbolEventNames = ens[eventName]; if (symbolEventNames) { + // l is 'false' string, k is 'true' string const symbolEventName = symbolEventNames[l]; const symbolCaptureEventName = symbolEventNames[k]; diff --git a/lib/common/promise.ts b/lib/common/promise.ts index c9a7a0ddf..26c470089 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -53,6 +53,7 @@ while (_uncaughtPromiseErrors.length) { const uncaughtPromiseError: UncaughtPromiseError = _uncaughtPromiseErrors.shift(); try { + // zone.runGuarded (uncaughtPromiseError.zone as any).rg(() => { throw uncaughtPromiseError; }); @@ -69,6 +70,7 @@ api.onUnhandledError(e); try { const handler = (Zone as any)[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + // n is 'function' if (handler && typeof handler === n) { handler.apply(this, [e]); } @@ -135,6 +137,7 @@ // should only get value.then once based on promise spec. let then: any = null; try { + // p is 'object', n is 'function' string if (typeof value === p || typeof value === n) { then = value && value.then; } @@ -150,6 +153,7 @@ (value as any)[symbolState] !== UNRESOLVED) { clearRejectedNoCatch(>value); resolvePromise(promise, (value as any)[symbolState], (value as any)[symbolValue]); + // n is 'function' string } else if (state !== REJECTED && typeof then === n) { try { then.apply(value, [ @@ -173,6 +177,7 @@ (Zone.currentTask.data as any)[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone + // b is Object.defineProperty b(value, CURRENT_TASK_TRACE_SYMBOL, {configurable: true, enumerable: false, writable: true, value: trace}); } @@ -192,6 +197,7 @@ const error: UncaughtPromiseError = err; error.rejection = value; error.promise = promise; + // Zone.current error.zone = (Zone as any).c; error.task = Zone.currentTask; _uncaughtPromiseErrors.push(error); @@ -214,6 +220,7 @@ // eventHandler try { const handler = (Zone as any)[REJECTION_HANDLED_HANDLER]; + // n is 'function' string if (handler && typeof handler === n) { handler.apply(this, [{rejection: (promise as any)[symbolValue], promise: promise}]); } @@ -233,10 +240,12 @@ onFulfilled?: (value: R) => U1, onRejected?: (error: any) => U2): void { clearRejectedNoCatch(promise); const delegate = (promise as any)[symbolState] ? + // n is 'function' string (typeof onFulfilled === n) ? onFulfilled : forwardResolution : (typeof onRejected === n) ? onRejected : forwardRejection; (zone as any).si(source, () => { try { + // zone.run resolvePromise( chainPromise, true, (zone as any).r(delegate, undefined, [(promise as any)[symbolValue]])); @@ -334,6 +343,7 @@ null): Promise { const chainPromise: Promise = new (this.constructor as typeof ZoneAwarePromise)(null); + // Zone.current const zone = (Zone as any).c; if ((this as any)[symbolState] == UNRESOLVED) { ((this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected); @@ -356,8 +366,10 @@ ZoneAwarePromise['all'] = ZoneAwarePromise.all; const NativePromise = global[symbolPromise] = global['Promise']; + // Zone.__symbol__ const ZONE_AWARE_PROMISE = (Zone as any).s('ZoneAwarePromise'); + // a is Object.getOwnPropertyDescriptor let desc = a(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; @@ -391,6 +403,7 @@ } }; + // b is Object.defineProperty b(global, 'Promise', desc); } @@ -406,8 +419,10 @@ // check Ctor.prototype.then propertyDescritor is writable or not // in meteor env, writable is false, we have to make it to be true. + // a is Object.getOwnPropertyDescritor const prop = a(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { + // b is Object.defineProperty b(Ctor.prototype, 'then', {writable: true}); } @@ -438,12 +453,14 @@ patchThen(NativePromise); let fetch = global['fetch']; + // n is 'function' if (typeof fetch == n) { global['fetch'] = zoneify(fetch); } } // This is not part of public API, but it is useful for tests, so we expose it. + // s is '__symbol__' (Promise as any)[(Zone as any).s('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; return ZoneAwarePromise; }); diff --git a/lib/common/timers.ts b/lib/common/timers.ts index 82266f0ad..f7d8b7825 100644 --- a/lib/common/timers.ts +++ b/lib/common/timers.ts @@ -39,6 +39,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam // setInterval return; } + // q is 'number' string if (typeof data.handleId === q) { // in non-nodejs env, we remove timerId // from local cache @@ -61,7 +62,9 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) { + // n is 'function' string if (typeof args[0] === n) { + // Zone.current const zone = (Zone as any).c; const options: TimerOptions = { handleId: null, @@ -69,12 +72,14 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, args: args }; + // Zone.scheduleMacroTask const task = (zone as any).sc(setName, args[0], options, scheduleTask, clearTask); if (!task) { return task; } // Node.js must additionally support the ref and unref functions. const handle: any = (task.data).handleId; + // q is 'number' string if (typeof handle === q) { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout @@ -87,11 +92,13 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + // n is 'function' string if (handle && handle.ref && handle.unref && typeof handle.ref === n && typeof handle.unref === n) { (task).ref = (handle).ref.bind(handle); (task).unref = (handle).unref.bind(handle); } + // q is 'number' string if (typeof handle === q || handle) { return handle; } @@ -106,6 +113,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam patchMethod(window, cancelName, (delegate: Function) => function(self: any, args: any[]) { const id = args[0]; let task: Task; + // q is 'number' string if (typeof id === q) { // non nodejs env. task = tasksByHandleId[id]; @@ -117,15 +125,18 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam task = id; } } + // r is 'string' if (task && typeof task.type === r) { if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + // q is 'number' string if (typeof id === q) { delete tasksByHandleId[id]; } else if (id) { id[taskSymbol] = null; } // Do not cancel already canceled functions + // zone.cancelTask (task.zone as any).ct(task); } } else { diff --git a/lib/common/to-string.ts b/lib/common/to-string.ts index 0499f6016..c2f7a8c9a 100644 --- a/lib/common/to-string.ts +++ b/lib/common/to-string.ts @@ -18,6 +18,7 @@ import {n, zoneSymbol} from './utils'; const PROMISE_SYMBOL = zoneSymbol('Promise'); const ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function() { + // n is 'function' string if (typeof this === n) { const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 0d95b4596..8ef229442 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -12,26 +12,44 @@ */ // issue #989, to reduce bundle size, use short name + +/** Object.getOwnPropertyDescriptor */ export const a = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ export const b = Object.defineProperty; +/** Object.defineProperties */ export const c = Object.defineProperties; +/** Object.getPrototypeOf */ export const d = Object.getPrototypeOf; +/** Object.create */ export const e = Object.create; +/** Array.prototype.slice */ export const f = Array.prototype.slice; +/** addEventListener string const */ export const g = 'addEventListener'; +/** removeEventListener string const */ export const h = 'removeEventListener'; +/** zoneSymbol addEventListener */ export const i = (Zone as any).s(g); +/** zoneSymbol removeEventListener */ export const j = (Zone as any).s(h); +/** true string const */ export const k = 'true'; +/** false string const */ export const l = 'false'; +/** __zone_symbol__ string const */ export const m = '__zone_symbol__'; +/** function type string const */ export const n = 'function'; +/** undefined type string const */ export const o = 'undefined'; +/** object type string const */ export const p = 'object'; +/** number type string const */ export const q = 'number'; +/** string type string const */ export const r = 'string'; - // Hack since TypeScript isn't compiling this for a worker. declare const WorkerGlobalScope: any; diff --git a/lib/zone.ts b/lib/zone.ts index d65149400..43df0a7a5 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -1345,17 +1345,29 @@ const Zone: ZoneType = (function(global: any) { performanceMeasure('Zone', 'Zone'); const z: any = Zone.prototype; + /** shorter for Zone.prototype.wrap */ z.w = z.wrap; + /** shorter for Zone.prototype.fork */ z.f = z.fork; + /** shorter for Zone.prototype.run */ z.r = z.run; + /** shorter for Zone.prototype.runGuarded */ z.rg = z.runGuarded; + /** shorter for Zone.prototype.runTask */ z.rt = z.runTask; + /** shorter for Zone.prototype.scheduleTask */ z.st = z.scheduleTask; + /** shorter for Zone.prototype.scheduleMacroTask */ z.sc = z.scheduleMacroTask; + /** shorter for Zone.prototype.scheduleMicroTask */ z.si = z.scheduleMicroTask; + /** shorter for Zone.prototype.scheduleEventTask */ z.se = z.scheduleEventTask; + /** shorter for Zone.prototype.cancelTask */ z.ct = z.cancelTask; + /** shorter for Zone.__load_patch */ (Zone as any).l = Zone.__load_patch; + /** shorter for Zone.__symbol__ */ (Zone as any).s = Zone.__symbol__; return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); From 615a6c1f51c8c4b79a3a94593463da4d7fdd08cf Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Mon, 8 Jan 2018 11:36:44 +0900 Subject: [PATCH 004/106] fix(core): add file check script in travis build --- check-file-size.js | 27 +++++++++++++++++++++++++++ file-size-limit.json | 9 +++++++++ gulpfile.js | 11 +++++++++++ 3 files changed, 47 insertions(+) create mode 100644 check-file-size.js create mode 100644 file-size-limit.json diff --git a/check-file-size.js b/check-file-size.js new file mode 100644 index 000000000..6c109a445 --- /dev/null +++ b/check-file-size.js @@ -0,0 +1,27 @@ +/** + * @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 fs = require('fs'); + +module.exports = function(config) { + let chkResult = true; + config.targets.forEach(target => { + if (target.checkTarget) { + try { + const stats = fs.statSync(target.path); + if (stats.size > target.limit) { + console.error(`file ${target.path} size over limit, limit is ${target.limit}, actual is ${stats.size}`); + chkResult = false; + } + } catch (err) { + console.error(`failed to get filesize: ${target.path}`); + chkResult = false; + } + } + }); + return chkResult; +}; diff --git a/file-size-limit.json b/file-size-limit.json new file mode 100644 index 000000000..2c03611e5 --- /dev/null +++ b/file-size-limit.json @@ -0,0 +1,9 @@ +{ + "targets": [ + { + "path": "dist/zone.min.js", + "checkTarget": true, + "limit": 40000 + } + ] +} diff --git a/gulpfile.js b/gulpfile.js index 71a099320..b524bf3ca 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -410,3 +410,14 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => { } }); }); + +// check dist file size limitation +gulp.task('filesize', ['build'], (cb) => { + const checker = require('./check-file-size'); + const result = checker(require('./file-size-limit.json')); + if (result) { + cb(); + } else { + cb('check file size failed'); + } +}); From 31832a7a663d31af667e2a910d2f455f870f8421 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Mon, 8 Jan 2018 17:39:33 +0900 Subject: [PATCH 005/106] fix(core): add rxjs test --- .travis.yml | 3 ++- test/common_tests.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee2d8bdd7..fc734678d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ script: - node_modules/.bin/gulp lint - node_modules/.bin/gulp format:enforce - node_modules/.bin/gulp build + - node_modules/.bin/gulp filesize - scripts/closure/closure_compiler.sh - node_modules/.bin/gulp promisetest - npm run test:phantomjs-single @@ -35,4 +36,4 @@ script: - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node - node simple-server.js 2>&1> server.log& - - node ./test/webdriver/test.sauce.js \ No newline at end of file + - node ./test/webdriver/test.sauce.js diff --git a/test/common_tests.ts b/test/common_tests.ts index bb507dec6..2fbb7ecfd 100644 --- a/test/common_tests.ts +++ b/test/common_tests.ts @@ -21,6 +21,6 @@ import './zone-spec/sync-test.spec'; import './zone-spec/fake-async-test.spec'; import './zone-spec/proxy.spec'; import './zone-spec/task-tracking.spec'; -// import './rxjs/rxjs.spec'; +import './rxjs/rxjs.spec'; Error.stackTraceLimit = Number.POSITIVE_INFINITY; From 957351e37024e472022cc9695ce3d6382f5b6ef9 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Tue, 9 Jan 2018 15:17:01 +0900 Subject: [PATCH 006/106] fix(core): remove unreadable short names --- lib/browser/browser.ts | 66 +++++----- lib/browser/define-property.ts | 8 +- lib/browser/event-target.ts | 28 ++--- lib/browser/property-descriptor.ts | 41 +++---- lib/browser/register-element.ts | 19 ++- lib/browser/shadydom.ts | 2 +- lib/browser/webapis-media-query.ts | 2 +- lib/browser/webapis-notification.ts | 2 +- lib/browser/webapis-rtc-peer-connection.ts | 4 +- lib/browser/webapis-user-media.ts | 2 +- lib/browser/websocket.ts | 18 ++- lib/closure/zone_externs.js | 24 ++-- lib/common/error-rewrite.ts | 7 +- lib/common/events.ts | 134 +++++++++------------ lib/common/promise.ts | 79 +++++------- lib/common/timers.ts | 61 ++++------ lib/common/to-string.ts | 9 +- lib/common/utils.ts | 107 +++++++--------- lib/extra/bluebird.ts | 4 +- lib/extra/cordova.ts | 12 +- lib/extra/electron.ts | 8 +- lib/node/events.ts | 18 +-- lib/node/fs.ts | 2 +- lib/node/node.ts | 24 ++-- lib/rxjs/rxjs.ts | 8 +- lib/zone-spec/fake-async-test.ts | 10 +- lib/zone.ts | 34 +----- test/closure/zone.closure.ts | 5 +- 28 files changed, 301 insertions(+), 437 deletions(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 39981ba64..78f51ebcc 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -12,20 +12,20 @@ import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {bindArguments, i, j, o, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, r, zoneSymbol} from '../common/utils'; +import {bindArguments, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, ZONE_SYMBOL_ADD_EVENT_LISTENER, ZONE_SYMBOL_REMOVE_EVENT_LISTENER, zoneSymbol} from '../common/utils'; import {propertyPatch} from './define-property'; import {eventTargetPatch, patchEvent} from './event-target'; import {propertyDescriptorPatch} from './property-descriptor'; import {registerElementPatch} from './register-element'; -(Zone as any).l('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; api.bindArguments = bindArguments; }); -(Zone as any).l('timers', (global: any) => { +Zone.__load_patch('timers', (global: any) => { const set = 'set'; const clear = 'clear'; patchTimer(global, set, clear, 'Timeout'); @@ -33,29 +33,27 @@ import {registerElementPatch} from './register-element'; patchTimer(global, set, clear, 'Immediate'); }); -(Zone as any).l('requestAnimationFrame', (global: any) => { +Zone.__load_patch('requestAnimationFrame', (global: any) => { patchTimer(global, 'request', 'cancel', 'AnimationFrame'); patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); }); -(Zone as any).l('blocking', (global: any, Zone: ZoneType) => { +Zone.__load_patch('blocking', (global: any, Zone: ZoneType) => { const blockingMethods = ['alert', 'prompt', 'confirm']; for (let i = 0; i < blockingMethods.length; i++) { const name = blockingMethods[i]; patchMethod(global, name, (delegate, symbol, name) => { return function(s: any, args: any[]) { - // Zone.current.run - return (Zone as any).c.r(delegate, global, args, name); + return Zone.current.run(delegate, global, args, name); }; }); } }); -(Zone as any).l('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // load blackListEvents from global - // Zone.__symbol__ - const SYMBOL_BLACK_LISTED_EVENTS = (Zone as any).s('BLACK_LISTED_EVENTS'); + const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); if (global[SYMBOL_BLACK_LISTED_EVENTS]) { (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; } @@ -73,16 +71,15 @@ import {registerElementPatch} from './register-element'; patchClass('FileReader'); }); -(Zone as any).l('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => { propertyDescriptorPatch(api, global); propertyPatch(); registerElementPatch(global); }); -(Zone as any).l('canvas', (global: any) => { +Zone.__load_patch('canvas', (global: any) => { const HTMLCanvasElement = global['HTMLCanvasElement']; - // o is 'undefined' - if (typeof HTMLCanvasElement !== o && HTMLCanvasElement.prototype && + if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.toBlob) { patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', (self: any, args: any[]) => { return {name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args}; @@ -90,8 +87,8 @@ import {registerElementPatch} from './register-element'; } }); -(Zone as any).l('XHR', (global: any, Zone: ZoneType) => { - // Treat XMLHTTPRequest as a macrotask. +Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { + // Treat XMLHttpRequest as a macrotask. patchXHR(global); const XHR_TASK = zoneSymbol('xhrTask'); @@ -111,18 +108,17 @@ import {registerElementPatch} from './register-element'; const XMLHttpRequestPrototype: any = XMLHttpRequest.prototype; function findPendingTask(target: any) { - const pendingTask: Task = target[XHR_TASK]; - return pendingTask; + return target[XHR_TASK]; } - let oriAddListener = XMLHttpRequestPrototype[i]; - let oriRemoveListener = XMLHttpRequestPrototype[j]; + let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; - oriAddListener = XMLHttpRequestEventTargetPrototype[i]; - oriRemoveListener = XMLHttpRequestEventTargetPrototype[j]; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } } @@ -136,14 +132,12 @@ import {registerElementPatch} from './register-element'; // remove existing event listener const listener = target[XHR_LISTENER]; if (!oriAddListener) { - // i is addEventListener zoneSymbol - // j is removeEventListener zoneSymbol - oriAddListener = target[i]; - oriRemoveListener = target[j]; + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } if (listener) { - oriRemoveListener.apply(target, [READY_STATE_CHANGE, listener]); + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); } const newListener = target[XHR_LISTENER] = () => { if (target.readyState === target.DONE) { @@ -154,7 +148,7 @@ import {registerElementPatch} from './register-element'; } } }; - oriAddListener.apply(target, [READY_STATE_CHANGE, newListener]); + oriAddListener.call(target, READY_STATE_CHANGE, newListener); const storedTask: Task = target[XHR_TASK]; if (!storedTask) { @@ -185,8 +179,7 @@ import {registerElementPatch} from './register-element'; const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; const sendNative: Function = patchMethod(XMLHttpRequestPrototype, 'send', () => function(self: any, args: any[]) { - // Zone.current - const zone = (Zone as any).c; + const 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); @@ -199,16 +192,14 @@ import {registerElementPatch} from './register-element'; args: args, aborted: false }; - // Zone.scheduleMacroTask - return zone.sc( + return zone.scheduleMacroTask( XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } }); const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function(self: any) { const task: Task = findPendingTask(self); - // r is 'string' - if (task && typeof task.type == r) { + if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. // If the XHR has already been aborted, do nothing. // Fix #569, call abort multiple times before done will cause @@ -216,8 +207,7 @@ import {registerElementPatch} from './register-element'; if (task.cancelFn == null || (task.data && (task.data).aborted)) { return; } - // Zone.cancelTask - (task.zone as any).ct(task); + task.zone.cancelTask(task); } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no // task @@ -226,14 +216,14 @@ import {registerElementPatch} from './register-element'; } }); -(Zone as any).l('geolocation', (global: any) => { +Zone.__load_patch('geolocation', (global: any) => { /// GEO_LOCATION if (global['navigator'] && global['navigator'].geolocation) { patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); } }); -(Zone as any).l('PromiseRejectionEvent', (global: any, Zone: ZoneType) => { +Zone.__load_patch('PromiseRejectionEvent', (global: any, Zone: ZoneType) => { // handle unhandled promise rejection function findPromiseRejectionHandler(evtName: string) { return function(e: any) { diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index c727bba63..00193832e 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {o, p, zoneSymbol} from '../common/utils'; +import {zoneSymbol} from '../common/utils'; /* * This is necessary for Chrome and Chrome mobile, to enable * things like redefining `createdCallback` on an element. @@ -38,8 +38,7 @@ export function propertyPatch() { }; Object.create = function(obj: any, proto: any) { - // o is 'object' string - if (typeof proto === p && !Object.isFrozen(proto)) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { Object.keys(proto).forEach(function(prop) { proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); }); @@ -90,8 +89,7 @@ function _tryDefineProperty(obj: any, prop: string, desc: any, originalConfigura if (desc.configurable) { // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's // retry with the original flag value - // o is 'undefined' string - if (typeof originalConfigurableFlag == o) { + if (typeof originalConfigurableFlag == 'undefined') { delete desc.configurable; } else { desc.configurable = originalConfigurableFlag; diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index cf957239b..4a67d7567 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {ens, gs, patchEventPrototype, patchEventTarget} from '../common/events'; -import {isIEOrEdge, k, l, m} from '../common/utils'; +import {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNames} from '../common/events'; +import {FALSE_STR, isIEOrEdge, TRUE_STR, ZONE_SYMBOL_PREFIX} from '../common/utils'; import {eventNames} from './property-descriptor'; @@ -45,27 +45,19 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { // predefine all __zone_symbol__ + eventName + true/false string for (let i = 0; i < eventNames.length; i++) { const eventName = eventNames[i]; - // l is 'false' string - const falseEventName = eventName + l; - // k is 'true' string - const trueEventName = eventName + k; - // m is '__zone_symbol__' string - const symbol = m + falseEventName; - // m is '__zone_symbol__' string - const symbolCapture = m + trueEventName; - // ens is globalEventNames cache - ens[eventName] = {}; - // l is 'false' string - ens[eventName][l] = symbol; - // k is 'true' string - ens[eventName][k] = symbolCapture; + const falseEventName = eventName + FALSE_STR; + const trueEventName = eventName + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; } // predefine all task.source string for (let i = 0; i < WTF_ISSUE_555.length; i++) { const target: any = WTF_ISSUE_555_ARRAY[i]; - // gs is global source cache - const targets: any = gs[target] = {}; + const targets: any = globalSources[target] = {}; for (let j = 0; j < eventNames.length; j++) { const eventName = eventNames[j]; targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 070e3a6fe..00ac86b1c 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -10,7 +10,7 @@ * @suppress {globalThis} */ -import {a, b, d, isBrowser, isMix, isNode, o, patchClass, patchOnProperties, zoneSymbol} from '../common/utils'; +import {isBrowser, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, patchClass, patchOnProperties, zoneSymbol} from '../common/utils'; import * as webSocketPatch from './websocket'; @@ -265,20 +265,22 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { return; } - // o is 'undefined' string - const supportsWebSocket = typeof WebSocket !== o; + const supportsWebSocket = typeof WebSocket !== 'undefined'; if (canPatchViaPropertyDescriptor()) { const ignoreProperties: IgnoreProperty[] = _global.__Zone_ignore_on_properties; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { - const w: any = window; + const internalWindow: any = window; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(w, eventNames.concat(['messageerror']), ignoreProperties, d(w)); + patchFilteredProperties( + internalWindow, eventNames.concat(['messageerror']), ignoreProperties, + ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof w['SVGElement'] !== o) { - patchFilteredProperties(w['SVGElement'].prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties( + internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); } patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); @@ -291,11 +293,11 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - const HTMLMarqueeElement = w['HTMLMarqueeElement']; + const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; if (HTMLMarqueeElement) { patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); } - const Worker = w['Worker']; + const Worker = internalWindow['Worker']; if (Worker) { patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); } @@ -307,8 +309,7 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); } - // o is 'undefined' string - if (typeof IDBIndex !== o) { + if (typeof IDBIndex !== 'undefined') { patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); @@ -330,18 +331,18 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { } function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !a(HTMLElement.prototype, 'onclick') && typeof Element !== o) { + if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 // IDL interface attributes are not configurable - const desc = a(Element.prototype, 'onclick'); + const desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; } const ON_READY_STATE_CHANGE = 'onreadystatechange'; const XMLHttpRequestPrototype = XMLHttpRequest.prototype; - // a is Object.getOwnPropertyDescriptor - const xhrDesc = a(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + const xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera // by default XMLHttpRequest.prototype.onreadystatechange is undefined @@ -350,8 +351,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { - // b is Object.defineProperty - b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function() { @@ -361,11 +361,11 @@ function canPatchViaPropertyDescriptor() { const req = new XMLHttpRequest(); const result = !!req.onreadystatechange; // restore original desc - b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } else { const SYMBOL_FAKE_ONREADYSTATECHANGE = zoneSymbol('fake'); - b(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function() { @@ -402,8 +402,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - // Zone.current.wrap - bound = (Zone as any).c.w(elt[onproperty], source); + bound = Zone.current.wrap(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index ad877c52d..d558e2dd1 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {a, attachOriginToPatched, isBrowser, isMix} from '../common/utils'; +import {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor} from '../common/utils'; import {_redefineProperty} from './define-property'; @@ -23,23 +23,22 @@ export function registerElementPatch(_global: any) { if (opts && opts.prototype) { callbacks.forEach(function(callback) { const source = 'Document.registerElement::' + callback; - const p = opts.prototype; - if (p.hasOwnProperty(callback)) { - // a is Object.getOwnPropertyDescriptor - const descriptor = a(p, callback); + const prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + const descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); if (descriptor && descriptor.value) { - descriptor.value = (Zone as any).c.w(descriptor.value, source); + descriptor.value = Zone.current.wrap(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } else { - p[callback] = (Zone as any).c.w(p[callback], source); + prototype[callback] = Zone.current.wrap(prototype[callback], source); } - } else if (p[callback]) { - p[callback] = (Zone as any).c.w(p[callback], source); + } else if (prototype[callback]) { + prototype[callback] = Zone.current.wrap(prototype[callback], source); } }); } - return _registerElement.apply(document, [name, opts]); + return _registerElement.call(document, name, opts); }; attachOriginToPatched((document).registerElement, _registerElement); diff --git a/lib/browser/shadydom.ts b/lib/browser/shadydom.ts index d02590204..f308308cd 100644 --- a/lib/browser/shadydom.ts +++ b/lib/browser/shadydom.ts @@ -5,7 +5,7 @@ * 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 as any).l('shadydom', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('shadydom', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // https://github.com/angular/zone.js/issues/782 // in web components, shadydom will patch addEventListener/removeEventListener of // Node.prototype and WindowPrototype, this will have conflict with zone.js diff --git a/lib/browser/webapis-media-query.ts b/lib/browser/webapis-media-query.ts index b26831327..0bb841826 100644 --- a/lib/browser/webapis-media-query.ts +++ b/lib/browser/webapis-media-query.ts @@ -5,7 +5,7 @@ * 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 as any).l('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate) => { if (!global['MediaQueryList']) { return; } diff --git a/lib/browser/webapis-notification.ts b/lib/browser/webapis-notification.ts index b714b3830..2d663e73c 100644 --- a/lib/browser/webapis-notification.ts +++ b/lib/browser/webapis-notification.ts @@ -5,7 +5,7 @@ * 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 as any).l('notification', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('notification', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const Notification = global['Notification']; if (!Notification || !Notification.prototype) { return; diff --git a/lib/browser/webapis-rtc-peer-connection.ts b/lib/browser/webapis-rtc-peer-connection.ts index 666b4482d..5930445ef 100644 --- a/lib/browser/webapis-rtc-peer-connection.ts +++ b/lib/browser/webapis-rtc-peer-connection.ts @@ -5,7 +5,7 @@ * 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 as any).l('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('RTCPeerConnection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const RTCPeerConnection = global['RTCPeerConnection']; if (!RTCPeerConnection) { return; @@ -18,7 +18,7 @@ RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol]; // RTCPeerConnection extends EventTarget, so we must clear the symbol - // to allow pathc RTCPeerConnection.prototype.addEventListener again + // to allow patch RTCPeerConnection.prototype.addEventListener again RTCPeerConnection.prototype[addSymbol] = null; RTCPeerConnection.prototype[removeSymbol] = null; diff --git a/lib/browser/webapis-user-media.ts b/lib/browser/webapis-user-media.ts index f93085a83..6d2cf5b98 100644 --- a/lib/browser/webapis-user-media.ts +++ b/lib/browser/webapis-user-media.ts @@ -5,7 +5,7 @@ * 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 as any).l('getUserMedia', (global: any, Zone: any, api: _ZonePrivate) => { +Zone.__load_patch('getUserMedia', (global: any, Zone: any, api: _ZonePrivate) => { function wrapFunctionArgs(func: Function, source?: string): Function { return function() { const args = Array.prototype.slice.call(arguments); diff --git a/lib/browser/websocket.ts b/lib/browser/websocket.ts index 7ecc54232..ab3cc0d41 100644 --- a/lib/browser/websocket.ts +++ b/lib/browser/websocket.ts @@ -7,7 +7,7 @@ */ import {patchEventTarget} from '../common/events'; -import {a, e, f, g, h, patchOnProperties} from '../common/utils'; +import {ADD_EVENT_LISTENER_STR, ArraySlice, ObjectCreate, ObjectGetOwnPropertyDescriptor, patchOnProperties, REMOVE_EVENT_LISTENER_STR} from '../common/utils'; // we have to patch the instance since the proto is non-configurable export function apply(api: _ZonePrivate, _global: any) { @@ -24,23 +24,21 @@ export function apply(api: _ZonePrivate, _global: any) { let proxySocketProto: any; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - // a is Object.getOwnPropertyDescriptor - const onmessageDesc = a(socket, 'onmessage'); + const onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { - // e is Object.create - proxySocket = e(socket); + proxySocket = ObjectCreate(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method proxySocketProto = socket; - // g is `addEventListener`, h is `removeEventListener` string - [g, h, 'send', 'close'].forEach(function(propName) { + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function( + propName) { proxySocket[propName] = function() { - const args = f.call(arguments); - if (propName === g || propName === h) { + const args = ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { const eventName = args.length > 0 ? args[0] : undefined; if (eventName) { - const propertySymbol = (Zone as any).s('ON_PROPERTY' + eventName); + const propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); socket[propertySymbol] = proxySocket[propertySymbol]; } } diff --git a/lib/closure/zone_externs.js b/lib/closure/zone_externs.js index 1fdf456b8..08a4c68c7 100644 --- a/lib/closure/zone_externs.js +++ b/lib/closure/zone_externs.js @@ -48,7 +48,7 @@ Zone.root; * Returns a value associated with the `key`. * * If the current zone does not have a key, the request is delegated to the parent zone. Use - * [ZoneSpec.properties] to configure the set of properties asseciated with the current zone. + * [ZoneSpec.properties] to configure the set of properties associated with the current zone. * * @param {!string} key The key to retrieve. * @returns {?} The value for the key, or `undefined` if not found. @@ -206,18 +206,18 @@ ZoneSpec.prototype.onIntercept; /** * Allows interception of the callback invocation. - * + * * @type { - * undefined|?function(ZoneDelegate, Zone, Zone, Function, Object, Array, string): * + * undefined|?function(ZoneDelegate, Zone, Zone, Function, Object, Array, string): * * } */ -ZoneSpec.prototype.onInvoke; +ZoneSpec.prototype.onInvoke; /** * Allows interception of the error handling. * * @type { - * undefined|?function(ZoneDelegate, Zone, Zone, Object): boolean + * undefined|?function(ZoneDelegate, Zone, Zone, Object): boolean * } */ ZoneSpec.prototype.onHandleError; @@ -226,7 +226,7 @@ ZoneSpec.prototype.onHandleError; * Allows interception of task scheduling. * * @type { - * undefined|?function(ZoneDelegate, Zone, Zone, Task): Task + * undefined|?function(ZoneDelegate, Zone, Zone, Task): Task * } */ ZoneSpec.prototype.onScheduleTask; @@ -238,16 +238,16 @@ ZoneSpec.prototype.onScheduleTask; * undefined|?function(ZoneDelegate, Zone, Zone, Task, Object, Array): * * } */ -ZoneSpec.prototype.onInvokeTask; +ZoneSpec.prototype.onInvokeTask; /** * Allows interception of task cancelation. * * @type { - * undefined|?function(ZoneDelegate, Zone, Zone, Task): * + * undefined|?function(ZoneDelegate, Zone, Zone, Task): * * } */ -ZoneSpec.prototype.onCancelTask; +ZoneSpec.prototype.onCancelTask; /** * Notifies of changes to the task queue empty status. * @@ -275,7 +275,7 @@ ZoneDelegate.prototype.fork = function(targetZone, zoneSpec) {}; * @param {!Zone} targetZone the [Zone] which originally received the request. * @param {!Function} callback the callback function passed into `wrap` function * @param {string=} source the argument passed into the `wrap` method. - * @returns {!Function} + * @returns {!Function} */ ZoneDelegate.prototype.intercept = function(targetZone, callback, source) {}; @@ -316,7 +316,7 @@ ZoneDelegate.prototype.invokeTask = function(targetZone, task, applyThis, applyA ZoneDelegate.prototype.cancelTask = function(targetZone, task) {}; /** * @param {!Zone} targetZone The [Zone] which originally received the request. - * @param {!HasTaskState} hasTaskState + * @param {!HasTaskState} hasTaskState */ ZoneDelegate.prototype.hasTask = function(targetZone, hasTaskState) {}; @@ -439,4 +439,4 @@ Error.prototype.zoneAwareStack; /** * @type {?string} */ -Error.prototype.originalStack; \ No newline at end of file +Error.prototype.originalStack; diff --git a/lib/common/error-rewrite.ts b/lib/common/error-rewrite.ts index e9ea0639d..dcd5b3970 100644 --- a/lib/common/error-rewrite.ts +++ b/lib/common/error-rewrite.ts @@ -189,7 +189,7 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { } } } - return value.apply(this, [error, structuredStackTrace]); + return value.call(this, error, structuredStackTrace); }; } }); @@ -218,7 +218,7 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { let frame = frames.shift(); // On safari it is possible to have stack frame with no line number. // This check makes sure that we don't filter frames on name only (must have - // linenumber) + // line number) if (/:\d+:\d+/.test(frame)) { // Get rid of the path so that we don't accidentally find function name in path. // In chrome the separator is `(` and `@` in FF and safari @@ -283,8 +283,7 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // all kinds of tasks with one error thrown. childDetectZone.run(() => { childDetectZone.runGuarded(() => { - const fakeTransitionTo = - (toState: TaskState, fromState1: TaskState, fromState2: TaskState) => {}; + const fakeTransitionTo = () => {}; childDetectZone.scheduleEventTask( blacklistedStackFramesSymbol, () => { diff --git a/lib/common/events.ts b/lib/common/events.ts index bb5666332..49bc6fe16 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -10,7 +10,7 @@ * @suppress {missingRequire} */ -import {attachOriginToPatched, d, g, h, k, l, m, n, p, zoneSymbol} from './utils'; +import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils'; /** @internal **/ interface EventTaskData extends TaskData { @@ -23,8 +23,8 @@ const OPTIMIZED_ZONE_EVENT_TASK_DATA: EventTaskData = { useG: true }; -export const ens: any = {}; -export const gs: any = {}; +export const zoneSymbolEventNames: any = {}; +export const globalSources: any = {}; const EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; const IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); @@ -54,8 +54,8 @@ export interface PatchEventTargetOptions { export function patchEventTarget( _global: any, apis: any[], patchOptions?: PatchEventTargetOptions) { - const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || g; - const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || h; + const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; const LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; const REMOVE_ALL_LISTENERS_EVENT_LISTENER = @@ -75,8 +75,7 @@ export function patchEventTarget( return; } const delegate = task.callback; - // p is 'object' string - if (typeof delegate === p && delegate.handleEvent) { + if (typeof delegate === 'object' && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = (event: Event) => delegate.handleEvent(event); task.originalDelegate = delegate; @@ -84,13 +83,12 @@ export function patchEventTarget( // invoke static task.invoke task.invoke(task, target, [event]); const options = task.options; - // p is 'object' string - if (options && typeof options === p && options.once) { + if (options && typeof options === 'object' && options.once) { // if options.once is true, after invoke once remove listener here // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once const delegate = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].apply(target, [event.type, delegate, options]); + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options); } }; @@ -102,11 +100,10 @@ export function patchEventTarget( if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 const target: any = this || event.target || _global; - // l is 'false' string - const tasks = target[ens[event.type][l]]; + const tasks = target[zoneSymbolEventNames[event.type][FALSE_STR]]; if (tasks) { // invoke all tasks which attached to current target with given event.type and capture = false // for performance concern, if task.length === 1, just invoke @@ -135,11 +132,10 @@ export function patchEventTarget( if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 const target: any = this || event.target || _global; - // k is 'true' string - const tasks = target[ens[event.type][k]]; + const tasks = target[zoneSymbolEventNames[event.type][TRUE_STR]]; if (tasks) { // invoke all tasks which attached to current target with given event.type and capture = false // for performance concern, if task.length === 1, just invoke @@ -183,8 +179,7 @@ export function patchEventTarget( let proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - // d is Object.getPrototypeOf - proto = d(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -217,17 +212,16 @@ export function patchEventTarget( proto[patchOptions.prepend]; } - const customScheduleGlobal = function(task: Task) { + const customScheduleGlobal = function() { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } - return nativeAddEventListener.apply(taskData.target, [ - taskData.eventName, - taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - taskData.options - ]); + return nativeAddEventListener.call( + taskData.target, taskData.eventName, + taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, + taskData.options); }; const customCancelGlobal = function(task: any) { @@ -235,12 +229,10 @@ export function patchEventTarget( // from Zone.prototype.cancelTask, we should remove the task // from tasksList of target first if (!task.isRemoved) { - // ens is event names cache - const symbolEventNames = ens[task.eventName]; + const symbolEventNames = zoneSymbolEventNames[task.eventName]; let symbolEventName; if (symbolEventNames) { - // k is 'true' string, l is 'false' string - symbolEventName = symbolEventNames[task.capture ? k : l]; + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; } const existingTasks = symbolEventName && task.target[symbolEventName]; if (existingTasks) { @@ -267,25 +259,23 @@ export function patchEventTarget( if (!task.allRemoved) { return; } - return nativeRemoveEventListener.apply(task.target, [ - task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - task.options - ]); + return nativeRemoveEventListener.call( + task.target, task.eventName, + task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; const customScheduleNonGlobal = function(task: Task) { - return nativeAddEventListener.apply( - taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativeAddEventListener.call( + taskData.target, taskData.eventName, task.invoke, taskData.options); }; const customSchedulePrepend = function(task: Task) { - return nativePrependEventListener.apply( - taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativePrependEventListener.call( + taskData.target, taskData.eventName, task.invoke, taskData.options); }; const customCancelNonGlobal = function(task: any) { - return nativeRemoveEventListener.apply( - task.target, [task.eventName, task.invoke, task.options]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); }; const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; @@ -293,19 +283,15 @@ export function patchEventTarget( const compareTaskCallbackVsDelegate = function(task: any, delegate: any) { const typeOfDelegate = typeof delegate; - // n is 'function' string, p is 'object' string - if ((typeOfDelegate === n && task.callback === delegate) || - (typeOfDelegate === p && task.originalDelegate === delegate)) { - // same callback, same capture, same event name, just return - return true; - } - return false; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; const compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - const blackListedEvents: string[] = (Zone as any)[(Zone as any).s('BLACK_LISTED_EVENTS')]; + const blackListedEvents: string[] = (Zone as any)[Zone.__symbol__('BLACK_LISTED_EVENTS')]; const makeAddListener = function( nativeListener: any, addSource: string, customScheduleFn: any, customCancelFn: any, @@ -321,8 +307,7 @@ export function patchEventTarget( // case here to improve addEventListener performance // we will create the bind delegate when invoke let isHandleEvent = false; - // n is 'function' string - if (typeof delegate !== n) { + if (typeof delegate !== 'function') { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -358,25 +343,21 @@ export function patchEventTarget( once = options ? !!options.once : false; } - // Zone.current - const zone = (Zone as any).c; - const symbolEventNames = ens[eventName]; + const zone = Zone.current; + const symbolEventNames = zoneSymbolEventNames[eventName]; let symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - // l is 'false' string, k is 'true' string - const falseEventName = eventName + l; - const trueEventName = eventName + k; - // m is '__zone_symbol__' string - const symbol = m + falseEventName; - const symbolCapture = m + trueEventName; - ens[eventName] = {}; - // l is 'false' string, k is 'true' string - ens[eventName][l] = symbol; - ens[eventName][k] = symbolCapture; + const falseEventName = eventName + FALSE_STR; + const trueEventName = eventName + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; symbolEventName = capture ? symbolCapture : symbol; } else { - symbolEventName = symbolEventNames[capture ? k : l]; + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } let existingTasks = target[symbolEventName]; let isExisting = false; @@ -396,7 +377,7 @@ export function patchEventTarget( } let source; const constructorName = target.constructor['name']; - const targetSource = gs[constructorName]; + const targetSource = globalSources[constructorName]; if (targetSource) { source = targetSource[eventName]; } @@ -419,14 +400,13 @@ export function patchEventTarget( const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; - // keep taskData into data to allow onScheduleEventTask to acess the task information + // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { (data as any).taskData = taskData; } - // Zone.scehduleEventTask const task: any = - (zone as any).se(source, delegate, data, customScheduleFn, customCancelFn); + zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); // should clear taskData.target to avoid memory leak // issue, https://github.com/angular/angular/issues/20442 @@ -497,16 +477,15 @@ export function patchEventTarget( return; } - const symbolEventNames = ens[eventName]; + const symbolEventNames = zoneSymbolEventNames[eventName]; let symbolEventName; if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? k : l]; + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } const existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { for (let i = 0; i < existingTasks.length; i++) { const existingTask = existingTasks[i]; - const typeOfDelegate = typeof delegate; if (compare(existingTask, delegate)) { existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check @@ -517,7 +496,7 @@ export function patchEventTarget( (existingTask as any).allRemoved = true; target[symbolEventName] = null; } - (existingTask.zone as any).ct(existingTask); + existingTask.zone.cancelTask(existingTask); return; } } @@ -559,17 +538,16 @@ export function patchEventTarget( // so just keep removeListener eventListener until // all other eventListeners are removed if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, [evtName]); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } } // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { - const symbolEventNames = ens[eventName]; + const symbolEventNames = zoneSymbolEventNames[eventName]; if (symbolEventNames) { - // l is 'false' string, k is 'true' string - const symbolEventName = symbolEventNames[l]; - const symbolCaptureEventName = symbolEventNames[k]; + const symbolEventName = symbolEventNames[FALSE_STR]; + const symbolCaptureEventName = symbolEventNames[TRUE_STR]; const tasks = target[symbolEventName]; const captureTasks = target[symbolCaptureEventName]; @@ -579,7 +557,7 @@ export function patchEventTarget( for (let i = 0; i < removeTasks.length; i++) { const task = removeTasks[i]; let delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } @@ -588,7 +566,7 @@ export function patchEventTarget( for (let i = 0; i < removeTasks.length; i++) { const task = removeTasks[i]; let delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } } diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 26c470089..75e0766a9 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -5,11 +5,9 @@ * 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 as any).l('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - const a = Object.getOwnPropertyDescriptor; - const b = Object.defineProperty; - const n = 'function'; - const p = 'object'; +Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + const ObjectDefineProperty = Object.defineProperty; function readableObjectToString(obj: any) { if (obj && obj.toString === Object.prototype.toString) { @@ -53,8 +51,7 @@ while (_uncaughtPromiseErrors.length) { const uncaughtPromiseError: UncaughtPromiseError = _uncaughtPromiseErrors.shift(); try { - // zone.runGuarded - (uncaughtPromiseError.zone as any).rg(() => { + uncaughtPromiseError.zone.runGuarded(() => { throw uncaughtPromiseError; }); } catch (error) { @@ -70,9 +67,8 @@ api.onUnhandledError(e); try { const handler = (Zone as any)[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - // n is 'function' - if (handler && typeof handler === n) { - handler.apply(this, [e]); + if (handler && typeof handler === 'function') { + handler.call(this, e); } } catch (err) { } @@ -137,8 +133,7 @@ // should only get value.then once based on promise spec. let then: any = null; try { - // p is 'object', n is 'function' string - if (typeof value === p || typeof value === n) { + if (typeof value === 'object' || typeof value === 'function') { then = value && value.then; } } catch (err) { @@ -153,12 +148,11 @@ (value as any)[symbolState] !== UNRESOLVED) { clearRejectedNoCatch(>value); resolvePromise(promise, (value as any)[symbolState], (value as any)[symbolValue]); - // n is 'function' string - } else if (state !== REJECTED && typeof then === n) { + } else if (state !== REJECTED && typeof then === 'function') { try { - then.apply(value, [ - onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)) - ]); + then.call( + value, onceWrapper(makeResolver(promise, state)), + onceWrapper(makeResolver(promise, false))); } catch (err) { onceWrapper(() => { resolvePromise(promise, false, err); @@ -177,9 +171,9 @@ (Zone.currentTask.data as any)[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone - // b is Object.defineProperty - b(value, CURRENT_TASK_TRACE_SYMBOL, - {configurable: true, enumerable: false, writable: true, value: trace}); + ObjectDefineProperty( + value, CURRENT_TASK_TRACE_SYMBOL, + {configurable: true, enumerable: false, writable: true, value: trace}); } } @@ -197,8 +191,7 @@ const error: UncaughtPromiseError = err; error.rejection = value; error.promise = promise; - // Zone.current - error.zone = (Zone as any).c; + error.zone = Zone.current; error.task = Zone.currentTask; _uncaughtPromiseErrors.push(error); api.scheduleMicroTask(); // to make sure that it is running @@ -220,9 +213,8 @@ // eventHandler try { const handler = (Zone as any)[REJECTION_HANDLED_HANDLER]; - // n is 'function' string - if (handler && typeof handler === n) { - handler.apply(this, [{rejection: (promise as any)[symbolValue], promise: promise}]); + if (handler && typeof handler === 'function') { + handler.call(this, {rejection: (promise as any)[symbolValue], promise: promise}); } } catch (err) { } @@ -240,15 +232,12 @@ onFulfilled?: (value: R) => U1, onRejected?: (error: any) => U2): void { clearRejectedNoCatch(promise); const delegate = (promise as any)[symbolState] ? - // n is 'function' string - (typeof onFulfilled === n) ? onFulfilled : forwardResolution : - (typeof onRejected === n) ? onRejected : forwardRejection; - (zone as any).si(source, () => { + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, () => { try { - // zone.run resolvePromise( - chainPromise, true, - (zone as any).r(delegate, undefined, [(promise as any)[symbolValue]])); + chainPromise, true, zone.run(delegate, undefined, [(promise as any)[symbolValue]])); } catch (error) { resolvePromise(chainPromise, false, error); } @@ -343,8 +332,7 @@ null): Promise { const chainPromise: Promise = new (this.constructor as typeof ZoneAwarePromise)(null); - // Zone.current - const zone = (Zone as any).c; + const zone = Zone.current; if ((this as any)[symbolState] == UNRESOLVED) { ((this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected); } else { @@ -366,11 +354,9 @@ ZoneAwarePromise['all'] = ZoneAwarePromise.all; const NativePromise = global[symbolPromise] = global['Promise']; - // Zone.__symbol__ - const ZONE_AWARE_PROMISE = (Zone as any).s('ZoneAwarePromise'); + const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - // a is Object.getOwnPropertyDescriptor - let desc = a(global, 'Promise'); + let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; desc && delete desc.value; @@ -403,8 +389,7 @@ } }; - // b is Object.defineProperty - b(global, 'Promise', desc); + ObjectDefineProperty(global, 'Promise', desc); } global['Promise'] = ZoneAwarePromise; @@ -417,13 +402,11 @@ // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescritor is writable or not + // check Ctor.prototype.then propertyDescriptor is writable or not // in meteor env, writable is false, we have to make it to be true. - // a is Object.getOwnPropertyDescritor - const prop = a(Ctor.prototype, 'then'); + const prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { - // b is Object.defineProperty - b(Ctor.prototype, 'then', {writable: true}); + ObjectDefineProperty(Ctor.prototype, 'then', {writable: true}); } Ctor.prototype.then = function(onResolve: any, onReject: any) { @@ -453,14 +436,12 @@ patchThen(NativePromise); let fetch = global['fetch']; - // n is 'function' - if (typeof fetch == n) { + if (typeof fetch == 'function') { global['fetch'] = zoneify(fetch); } } // This is not part of public API, but it is useful for tests, so we expose it. - // s is '__symbol__' - (Promise as any)[(Zone as any).s('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + (Promise as any)[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; return ZoneAwarePromise; }); diff --git a/lib/common/timers.ts b/lib/common/timers.ts index f7d8b7825..1185f8a23 100644 --- a/lib/common/timers.ts +++ b/lib/common/timers.ts @@ -10,7 +10,7 @@ * @suppress {missingRequire} */ -import {n, patchMethod, q, r, zoneSymbol} from './utils'; +import {patchMethod, zoneSymbol} from './utils'; const taskSymbol = zoneSymbol('zoneTask'); @@ -33,21 +33,19 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam try { task.invoke.apply(this, arguments); } finally { - if (task.data && task.data.isPeriodic) { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - return; - } - // q is 'number' string - if (typeof data.handleId === q) { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - (data.handleId as any)[taskSymbol] = null; + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + (data.handleId as any)[taskSymbol] = null; + } } } } @@ -62,25 +60,22 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) { - // n is 'function' string - if (typeof args[0] === n) { + if (typeof args[0] === 'function') { // Zone.current - const zone = (Zone as any).c; + const zone = Zone.current; const options: TimerOptions = { handleId: null, isPeriodic: nameSuffix === 'Interval', delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, args: args }; - // Zone.scheduleMacroTask - const task = (zone as any).sc(setName, args[0], options, scheduleTask, clearTask); + const task = zone.scheduleMacroTask(setName, args[0], options, scheduleTask, clearTask); if (!task) { return task; } // Node.js must additionally support the ref and unref functions. const handle: any = (task.data).handleId; - // q is 'number' string - if (typeof handle === q) { + if (typeof handle === 'number') { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -92,14 +87,12 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - // n is 'function' string - if (handle && handle.ref && handle.unref && typeof handle.ref === n && - typeof handle.unref === n) { + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { (task).ref = (handle).ref.bind(handle); (task).unref = (handle).unref.bind(handle); } - // q is 'number' string - if (typeof handle === q || handle) { + if (typeof handle === 'number' || handle) { return handle; } return task; @@ -113,8 +106,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam patchMethod(window, cancelName, (delegate: Function) => function(self: any, args: any[]) { const id = args[0]; let task: Task; - // q is 'number' string - if (typeof id === q) { + if (typeof id === 'number') { // non nodejs env. task = tasksByHandleId[id]; } else { @@ -125,19 +117,16 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam task = id; } } - // r is 'string' - if (task && typeof task.type === r) { + if (task && typeof task.type === 'string') { if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - // q is 'number' string - if (typeof id === q) { + if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { id[taskSymbol] = null; } // Do not cancel already canceled functions - // zone.cancelTask - (task.zone as any).ct(task); + task.zone.cancelTask(task); } } else { // cause an error by calling it directly. diff --git a/lib/common/to-string.ts b/lib/common/to-string.ts index c2f7a8c9a..a486ff423 100644 --- a/lib/common/to-string.ts +++ b/lib/common/to-string.ts @@ -5,11 +5,11 @@ * 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 {n, zoneSymbol} from './utils'; +import {zoneSymbol} from './utils'; // override Function.prototype.toString to make zone.js patched function // look like native function -(Zone as any).l('toString', (global: any, Zone: ZoneType) => { +Zone.__load_patch('toString', (global: any, Zone: ZoneType) => { // patch Func.prototype.toString to let them look like native const originalFunctionToString = (Zone as any)['__zone_symbol__originalToString'] = Function.prototype.toString; @@ -18,11 +18,10 @@ import {n, zoneSymbol} from './utils'; const PROMISE_SYMBOL = zoneSymbol('Promise'); const ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function() { - // n is 'function' string - if (typeof this === n) { + if (typeof this === 'function') { const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === n) { + if (typeof originalDelegate === 'function') { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { return Object.prototype.toString.call(originalDelegate); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 8ef229442..ba0b6d3f6 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -14,57 +14,45 @@ // issue #989, to reduce bundle size, use short name /** Object.getOwnPropertyDescriptor */ -export const a = Object.getOwnPropertyDescriptor; +export const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; /** Object.defineProperty */ -export const b = Object.defineProperty; -/** Object.defineProperties */ -export const c = Object.defineProperties; +export const ObjectDefineProperty = Object.defineProperty; /** Object.getPrototypeOf */ -export const d = Object.getPrototypeOf; +export const ObjectGetPrototypeOf = Object.getPrototypeOf; /** Object.create */ -export const e = Object.create; +export const ObjectCreate = Object.create; /** Array.prototype.slice */ -export const f = Array.prototype.slice; +export const ArraySlice = Array.prototype.slice; /** addEventListener string const */ -export const g = 'addEventListener'; +export const ADD_EVENT_LISTENER_STR = 'addEventListener'; /** removeEventListener string const */ -export const h = 'removeEventListener'; +export const REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; /** zoneSymbol addEventListener */ -export const i = (Zone as any).s(g); +export const ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); /** zoneSymbol removeEventListener */ -export const j = (Zone as any).s(h); +export const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); /** true string const */ -export const k = 'true'; +export const TRUE_STR = 'true'; /** false string const */ -export const l = 'false'; +export const FALSE_STR = 'false'; /** __zone_symbol__ string const */ -export const m = '__zone_symbol__'; -/** function type string const */ -export const n = 'function'; -/** undefined type string const */ -export const o = 'undefined'; -/** object type string const */ -export const p = 'object'; -/** number type string const */ -export const q = 'number'; -/** string type string const */ -export const r = 'string'; +export const ZONE_SYMBOL_PREFIX = '__zone_symbol__'; // Hack since TypeScript isn't compiling this for a worker. declare const WorkerGlobalScope: any; export const zoneSymbol = Zone.__symbol__; -const iw = typeof window !== o; -const w: any = iw ? window : undefined; -const _global: any = iw && w || typeof self === p && self || global; +const isWindowExists = typeof window !== 'undefined'; +const internalWindow: any = isWindowExists ? window : undefined; +const _global: any = isWindowExists && internalWindow || typeof self === 'object' && self || global; const REMOVE_ATTRIBUTE = 'removeAttribute'; const NULL_ON_PROP_VALUE: any[] = [null]; export function bindArguments(args: any[], source: string): any[] { for (let i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === n) { - args[i] = (Zone as any).c.w(args[i], source + '_' + i); + if (typeof args[i] === 'function') { + args[i] = Zone.current.wrap(args[i], source + '_' + i); } } return args; @@ -76,7 +64,7 @@ export function patchPrototype(prototype: any, fnNames: string[]) { const name = fnNames[i]; const delegate = prototype[name]; if (delegate) { - const prototypeDesc = a(prototype, name); + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name); if (!isPropertyWritable(prototypeDesc)) { continue; } @@ -100,30 +88,27 @@ export function isPropertyWritable(propertyDesc: any) { return false; } - if (typeof propertyDesc.get === n && typeof propertyDesc.set === o) { - return false; - } - - return true; + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } export const isWebWorker: boolean = - (typeof WorkerGlobalScope !== o && self instanceof WorkerGlobalScope); + (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. export const isNode: boolean = - (!('nw' in _global) && typeof _global.process !== o && + (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); -export const isBrowser: boolean = !isNode && !isWebWorker && !!(iw && w['HTMLElement']); +export const isBrowser: boolean = + !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. -export const isMix: boolean = typeof _global.process !== o && +export const isMix: boolean = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(iw && w['HTMLElement']); + !!(isWindowExists && internalWindow['HTMLElement']); const zoneSymbolEventNames: {[eventName: string]: string} = {}; @@ -149,10 +134,10 @@ const wrapFn = function(event: Event) { }; export function patchProperty(obj: any, prop: string, prototype?: any) { - let desc = a(obj, prop); + let desc = ObjectGetOwnPropertyDescriptor(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - const prototypeDesc = a(prototype, prop); + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); if (prototypeDesc) { desc = {enumerable: true, configurable: true}; } @@ -202,7 +187,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { originalDescSet.apply(target, NULL_ON_PROP_VALUE); } - if (typeof newValue === n) { + if (typeof newValue === 'function') { target[eventNameSymbol] = newValue; target.addEventListener(eventName, wrapFn, false); } else { @@ -232,10 +217,10 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { // the onclick will be evaluated when first time event was triggered or // the property is accessed, https://github.com/angular/zone.js/issues/525 // so we should use original native get to retrieve the handler - let value = originalDescGet && originalDescGet.apply(this); + let value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === n) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } return value; @@ -244,7 +229,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { return null; }; - b(obj, prop, desc); + ObjectDefineProperty(obj, prop, desc); } export function patchOnProperties(obj: any, properties: string[], prototype?: any) { @@ -307,15 +292,15 @@ export function patchClass(className: string) { // https://bugs.webkit.org/show_bug.cgi?id=44721 if (className === 'XMLHttpRequest' && prop === 'responseBlob') continue; (function(prop) { - if (typeof instance[prop] === n) { + if (typeof instance[prop] === 'function') { _global[className].prototype[prop] = function() { return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); }; } else { - b(_global[className].prototype, prop, { + ObjectDefineProperty(_global[className].prototype, prop, { set: function(fn) { - if (typeof fn === n) { - this[originalInstanceKey][prop] = (Zone as any).c.w(fn, className + '.' + prop); + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); // keep callback in wrapped function so we can // use it in Function.prototype.toString to return // the native one. @@ -345,7 +330,7 @@ export function patchMethod( any): Function { let proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = d(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -358,7 +343,7 @@ export function patchMethod( delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - const desc = proto && a(proto, name); + const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { const patchDelegate = patchFn(delegate, delegateName, name); proto[name] = function() { @@ -393,9 +378,8 @@ export function patchMacroTask( setNative = patchMethod(obj, funcName, (delegate: Function) => function(self: any, args: any[]) { const meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === n) { - const task = (Zone as any).c.sc(meta.name, args[meta.cbIdx], meta, scheduleTask, null); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMacroTask(meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. return delegate.apply(self, args); @@ -425,9 +409,8 @@ export function patchMicroTask( setNative = patchMethod(obj, funcName, (delegate: Function) => function(self: any, args: any[]) { const meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === n) { - const task = (Zone as any).c.si(meta.name, args[meta.cbIdx], meta, scheduleTask); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. return delegate.apply(self, args); @@ -450,7 +433,7 @@ export function isIEOrEdge() { isDetectedIEOrEdge = true; try { - const ua = w.navigator.userAgent; + const ua = internalWindow.navigator.userAgent; if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } diff --git a/lib/extra/bluebird.ts b/lib/extra/bluebird.ts index d3f9b9cca..dd7f27743 100644 --- a/lib/extra/bluebird.ts +++ b/lib/extra/bluebird.ts @@ -5,7 +5,7 @@ * 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 as any).l('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('bluebird', (global: any, Zone: ZoneType) => { // TODO: @JiaLiPassion, we can automatically patch bluebird // if global.Promise = Bluebird, but sometimes in nodejs, // global.Promise is not Bluebird, and Bluebird is just be @@ -14,7 +14,7 @@ const BLUEBIRD = 'bluebird'; (Zone as any)[Zone.__symbol__(BLUEBIRD)] = function patchBluebird(Bluebird: any) { Bluebird.setScheduler((fn: Function) => { - (Zone as any).c.si(BLUEBIRD, fn); + Zone.current.scheduleMicroTask(BLUEBIRD, fn); }); }; }); diff --git a/lib/extra/cordova.ts b/lib/extra/cordova.ts index 4d32a46a0..0365248ec 100644 --- a/lib/extra/cordova.ts +++ b/lib/extra/cordova.ts @@ -5,25 +5,25 @@ * 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 as any).l('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => { if (global.cordova) { const SUCCESS_SOURCE = 'cordova.exec.success'; const ERROR_SOURCE = 'cordova.exec.error'; const FUNCTION = 'function'; - const nativeExec: Function = api.patchMethod( - global.cordova, 'exec', (delegate: Function) => function(self: any, args: any[]) { + const nativeExec: Function = + api.patchMethod(global.cordova, 'exec', () => function(self: any, args: any[]) { if (args.length > 0 && typeof args[0] === FUNCTION) { - args[0] = (Zone as any).c.w(args[0], SUCCESS_SOURCE); + args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE); } if (args.length > 1 && typeof args[1] === FUNCTION) { - args[1] = (Zone as any).c.w(args[1], ERROR_SOURCE); + args[1] = Zone.current.wrap(args[1], ERROR_SOURCE); } return nativeExec.apply(self, args); }); } }); -(Zone as any).l('cordova.FileReader', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('cordova.FileReader', (global: any, Zone: ZoneType) => { if (global.cordova && typeof global['FileReader'] !== 'undefined') { document.addEventListener('deviceReady', () => { const FileReader = global['FileReader']; diff --git a/lib/extra/electron.ts b/lib/extra/electron.ts index 9ed842b21..eee5b552b 100644 --- a/lib/extra/electron.ts +++ b/lib/extra/electron.ts @@ -5,13 +5,13 @@ * 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 as any).l('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) => { function patchArguments(target: any, name: string, source: string): Function { return api.patchMethod(target, name, (delegate: Function) => (self: any, args: any[]) => { return delegate && delegate.apply(self, api.bindArguments(args, source)); }); } - const {desktopCapturer, shell, CallbackRegistry} = require('electron'); + const {desktopCapturer, shell, CallbacksRegistry} = require('electron'); // patch api in renderer process directly // desktopCapturer if (desktopCapturer) { @@ -23,9 +23,9 @@ } // patch api in main process through CallbackRegistry - if (!CallbackRegistry) { + if (!CallbacksRegistry) { return; } - patchArguments(CallbackRegistry.prototype, 'add', 'CallbackRegistry.add'); + patchArguments(CallbacksRegistry.prototype, 'add', 'CallbackRegistry.add'); }); diff --git a/lib/node/events.ts b/lib/node/events.ts index 223721f1d..d7eda2596 100644 --- a/lib/node/events.ts +++ b/lib/node/events.ts @@ -6,16 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {ens, gs, patchEventTarget} from '../common/events'; - -(Zone as any).l('EventEmitter', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - const callAndReturnFirstParam = (fn: (self: any, args: any[]) => any) => { - return (self: any, args: any[]) => { - fn(self, args); - return self; - }; - }; +import {patchEventTarget} from '../common/events'; +Zone.__load_patch('EventEmitter', (global: any) => { // For EventEmitter const EE_ADD_LISTENER = 'addListener'; const EE_PREPEND_LISTENER = 'prependListener'; @@ -25,11 +18,8 @@ import {ens, gs, patchEventTarget} from '../common/events'; const EE_ON = 'on'; const compareTaskCallbackVsDelegate = function(task: any, delegate: any) { - if (task.callback === delegate || task.callback.listener === delegate) { - // same callback, same capture, same event name, just return - return true; - } - return false; + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; }; function patchEventEmitterMethods(obj: any) { diff --git a/lib/node/fs.ts b/lib/node/fs.ts index 11c115436..9af536abc 100644 --- a/lib/node/fs.ts +++ b/lib/node/fs.ts @@ -8,7 +8,7 @@ import {patchMacroTask} from '../common/utils'; -(Zone as any).l('fs', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('fs', () => { let fs: any; try { fs = require('fs'); diff --git a/lib/node/node.ts b/lib/node/node.ts index 388d00195..b4ab2f9e6 100644 --- a/lib/node/node.ts +++ b/lib/node/node.ts @@ -11,18 +11,18 @@ import './fs'; import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {bindArguments, f, isMix, patchMacroTask, patchMethod, patchMicroTask, patchOnProperties} from '../common/utils'; +import {ArraySlice, bindArguments, isMix, patchMacroTask, patchMethod, patchMicroTask, patchOnProperties} from '../common/utils'; const set = 'set'; const clear = 'clear'; -(Zone as any).l('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; api.bindArguments = bindArguments; }); -(Zone as any).l('node_timers', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('node_timers', (global: any, Zone: ZoneType) => { // Timers let globalUseTimeoutFromTimer = false; try { @@ -47,7 +47,7 @@ const clear = 'clear'; patchTimer(timers, set, clear, 'Interval'); patchTimer(timers, set, clear, 'Immediate'); } catch (error) { - // timers module not exists, for example, when we using nativescript + // timers module not exists, for example, when we using nativeScript // timers is not available } if (isMix) { @@ -65,7 +65,7 @@ const clear = 'clear'; patchTimer(global, set, clear, 'Immediate'); } else { // global use timers setTimeout, but not equals - // this happenes when use nodejs v0.10.x, global setTimeout will + // this happens when use nodejs v0.10.x, global setTimeout will // use a lazy load version of timers setTimeout // we should not double patch timer's setTimeout // so we only store the __symbol__ for consistency @@ -76,7 +76,7 @@ const clear = 'clear'; }); // patch process related methods -(Zone as any).l('nextTick', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('nextTick', () => { // patch nextTick as microTask patchMicroTask(process, 'nextTick', (self: any, args: any[]) => { return { @@ -88,8 +88,8 @@ const clear = 'clear'; }); }); -(Zone as any) - .l('handleUnhandledPromiseRejection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch( + 'handleUnhandledPromiseRejection', (global: any, Zone: ZoneType, api: _ZonePrivate) => { (Zone as any)[api.symbol('unhandledPromiseRejectionHandler')] = findProcessPromiseRejectionHandler('unhandledRejection'); @@ -116,7 +116,7 @@ const clear = 'clear'; // Crypto -(Zone as any).l('crypto', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('crypto', () => { let crypto: any; try { crypto = require('crypto'); @@ -141,15 +141,15 @@ const clear = 'clear'; } }); -(Zone as any).l('console', (global: any, Zone: ZoneType, api: _ZonePrivate) => { +Zone.__load_patch('console', (global: any, Zone: ZoneType) => { const consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; consoleMethods.forEach((m: string) => { const originalMethod = (console as any)[Zone.__symbol__(m)] = (console as any)[m]; if (originalMethod) { (console as any)[m] = function() { - const args = f.call(arguments); - if ((Zone as any).c === Zone.root) { + const args = ArraySlice.call(arguments); + if (Zone.current === Zone.root) { return originalMethod.apply(this, args); } else { return Zone.root.run(originalMethod, this, args); diff --git a/lib/rxjs/rxjs.ts b/lib/rxjs/rxjs.ts index 11c116b8a..71344a460 100644 --- a/lib/rxjs/rxjs.ts +++ b/lib/rxjs/rxjs.ts @@ -25,6 +25,8 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; const errorSource = 'rxjs.Subscriber.error'; const completeSource = 'rxjs.Subscriber.complete'; + const ObjectDefineProperties = Object.defineProperties; + const empty = { closed: true, next(value: any): void{}, @@ -58,7 +60,7 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; const _subscribe = ObservablePrototype[_symbolSubscribe] = ObservablePrototype._subscribe; const subscribe = ObservablePrototype[symbolSubscribe] = ObservablePrototype.subscribe; - Object.defineProperties(Observable.prototype, { + ObjectDefineProperties(Observable.prototype, { _zone: {value: null, writable: true, configurable: true}, _zoneSource: {value: null, writable: true, configurable: true}, _zoneSubscribe: {value: null, writable: true, configurable: true}, @@ -109,7 +111,7 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; const unsubscribeSymbol = symbol('unsubscribe'); const unsubscribe = (Subscription.prototype as any)[unsubscribeSymbol] = Subscription.prototype.unsubscribe; - Object.defineProperties(Subscription.prototype, { + ObjectDefineProperties(Subscription.prototype, { _zone: {value: null, writable: true, configurable: true}, _zoneUnsubscribe: {value: null, writable: true, configurable: true}, _unsubscribe: { @@ -341,7 +343,7 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; return work.apply(this, arguments); } }; - return schedule.apply(this, [patchedWork, delay, state]); + return schedule.call(this, patchedWork, delay, state); }; }; diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 31f1fae35..72ef0e115 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -182,7 +182,7 @@ namePrefix: string, private trackPendingRequestAnimationFrame = false, private macroTaskOptions?: MacroTaskOptions[]) { this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakyAsyncTestSpec + // in case user can't access the construction of FakeAsyncTestSpec // user can also define macroTaskOptions by define a global variable. if (!this.macroTaskOptions) { this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; @@ -328,16 +328,16 @@ // should pass additional arguments to callback if have any // currently we know process.nextTick will have such additional // arguments - let addtionalArgs: any[]; + let additionalArgs: any[]; if (args) { let callbackIndex = (task.data as any).cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - addtionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } } this._microtasks.push({ func: task.invoke, - args: addtionalArgs, + args: additionalArgs, target: task.data && (task.data as any).target }); break; @@ -378,7 +378,7 @@ task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); task.data.isPeriodic = true; } else { - // not periodic, use setTimout to simulate + // not periodic, use setTimeout to simulate task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } break; diff --git a/lib/zone.ts b/lib/zone.ts index 43df0a7a5..76efc031a 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -656,7 +656,7 @@ const Zone: ZoneType = (function(global: any) { } static get root(): AmbientZone { - let zone = Zone.c; + let zone = Zone.current; while (zone.parent) { zone = zone.parent; } @@ -667,10 +667,6 @@ const Zone: ZoneType = (function(global: any) { return _currentZoneFrame.zone; } - static get c(): AmbientZone { - return _currentZoneFrame.zone; - } - static get currentTask(): Task { return _currentTask; } @@ -1176,7 +1172,7 @@ const Zone: ZoneType = (function(global: any) { this.invoke = ZoneTask.invokeTask; } else { this.invoke = function() { - return ZoneTask.invokeTask.apply(global, [self, this, arguments]); + return ZoneTask.invokeTask.call(global, self, this, arguments); }; } } @@ -1292,7 +1288,6 @@ const Zone: ZoneType = (function(global: any) { } } } - const showError: boolean = !(Zone as any)[__symbol__('ignoreConsoleErrorUncaughtError')]; _api.microtaskDrainDone(); _isDrainingMicrotaskQueue = false; } @@ -1344,30 +1339,5 @@ const Zone: ZoneType = (function(global: any) { } performanceMeasure('Zone', 'Zone'); - const z: any = Zone.prototype; - /** shorter for Zone.prototype.wrap */ - z.w = z.wrap; - /** shorter for Zone.prototype.fork */ - z.f = z.fork; - /** shorter for Zone.prototype.run */ - z.r = z.run; - /** shorter for Zone.prototype.runGuarded */ - z.rg = z.runGuarded; - /** shorter for Zone.prototype.runTask */ - z.rt = z.runTask; - /** shorter for Zone.prototype.scheduleTask */ - z.st = z.scheduleTask; - /** shorter for Zone.prototype.scheduleMacroTask */ - z.sc = z.scheduleMacroTask; - /** shorter for Zone.prototype.scheduleMicroTask */ - z.si = z.scheduleMicroTask; - /** shorter for Zone.prototype.scheduleEventTask */ - z.se = z.scheduleEventTask; - /** shorter for Zone.prototype.cancelTask */ - z.ct = z.cancelTask; - /** shorter for Zone.__load_patch */ - (Zone as any).l = Zone.__load_patch; - /** shorter for Zone.__symbol__ */ - (Zone as any).s = Zone.__symbol__; return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/test/closure/zone.closure.ts b/test/closure/zone.closure.ts index 3e5cc3470..b065efde1 100644 --- a/test/closure/zone.closure.ts +++ b/test/closure/zone.closure.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ import '../../dist/zone-node'; -const shortKeys = ['w', 'f', 'r', 'rg', 'rt', 'st', 'sc', 'si', 'se', 'ct']; const testClosureFunction = () => { const logs: string[] = []; // call all Zone exposed functions @@ -69,9 +68,7 @@ const testClosureFunction = () => { logs.push('get' + keyZone.get('key')); logs.push('root' + Zone.root.name); Object.keys((Zone as any).prototype).forEach(key => { - if (shortKeys.indexOf(key) === -1) { - logs.push(key); - } + logs.push(key); }); Object.keys(testZoneSpec).forEach(key => { logs.push(key); From 8293c37d7d7f49db102b9df6341879ffd004844f Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Tue, 9 Jan 2018 16:07:35 +0900 Subject: [PATCH 007/106] fix(core): add helper method in util.ts to shorter zone.wrap/scehduleMacroTask --- lib/browser/browser.ts | 5 ++--- lib/browser/property-descriptor.ts | 4 ++-- lib/browser/register-element.ts | 8 ++++---- lib/common/timers.ts | 7 +++---- lib/common/utils.ts | 17 ++++++++++++++--- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 78f51ebcc..bba9994d7 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -12,7 +12,7 @@ import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {bindArguments, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, ZONE_SYMBOL_ADD_EVENT_LISTENER, ZONE_SYMBOL_REMOVE_EVENT_LISTENER, zoneSymbol} from '../common/utils'; +import {bindArguments, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, scheduleMacroTaskWithCurrentZone, ZONE_SYMBOL_ADD_EVENT_LISTENER, ZONE_SYMBOL_REMOVE_EVENT_LISTENER, zoneSymbol} from '../common/utils'; import {propertyPatch} from './define-property'; import {eventTargetPatch, patchEvent} from './event-target'; @@ -179,7 +179,6 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; const sendNative: Function = patchMethod(XMLHttpRequestPrototype, 'send', () => function(self: any, args: any[]) { - const 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); @@ -192,7 +191,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { args: args, aborted: false }; - return zone.scheduleMacroTask( + return scheduleMacroTaskWithCurrentZone( XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } }); diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 00ac86b1c..c381abfda 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -10,7 +10,7 @@ * @suppress {globalThis} */ -import {isBrowser, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, patchClass, patchOnProperties, zoneSymbol} from '../common/utils'; +import {isBrowser, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, patchClass, patchOnProperties, wrapWithCurrentZone, zoneSymbol} from '../common/utils'; import * as webSocketPatch from './websocket'; @@ -402,7 +402,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = Zone.current.wrap(elt[onproperty], source); + bound = wrapWithCurrentZone(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index d558e2dd1..aa1abbd7a 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor} from '../common/utils'; +import {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor, wrapWithCurrentZone} from '../common/utils'; import {_redefineProperty} from './define-property'; @@ -27,13 +27,13 @@ export function registerElementPatch(_global: any) { if (prototype.hasOwnProperty(callback)) { const descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); if (descriptor && descriptor.value) { - descriptor.value = Zone.current.wrap(descriptor.value, source); + descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } else { - prototype[callback] = Zone.current.wrap(prototype[callback], source); + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } else if (prototype[callback]) { - prototype[callback] = Zone.current.wrap(prototype[callback], source); + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } }); } diff --git a/lib/common/timers.ts b/lib/common/timers.ts index 1185f8a23..bdec80baf 100644 --- a/lib/common/timers.ts +++ b/lib/common/timers.ts @@ -10,7 +10,7 @@ * @suppress {missingRequire} */ -import {patchMethod, zoneSymbol} from './utils'; +import {patchMethod, scheduleMacroTaskWithCurrentZone, zoneSymbol} from './utils'; const taskSymbol = zoneSymbol('zoneTask'); @@ -61,15 +61,14 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) { if (typeof args[0] === 'function') { - // Zone.current - const zone = Zone.current; const options: TimerOptions = { handleId: null, isPeriodic: nameSuffix === 'Interval', delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, args: args }; - const task = zone.scheduleMacroTask(setName, args[0], options, scheduleTask, clearTask); + const task = + scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); if (!task) { return task; } diff --git a/lib/common/utils.ts b/lib/common/utils.ts index ba0b6d3f6..958bd863d 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -38,6 +38,16 @@ export const FALSE_STR = 'false'; /** __zone_symbol__ string const */ export const ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +export function wrapWithCurrentZone(callback: T, source: string): T { + return Zone.current.wrap(callback, source); +} + +export function scheduleMacroTaskWithCurrentZone( + source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, + customCancel: (task: Task) => void): MacroTask { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} + // Hack since TypeScript isn't compiling this for a worker. declare const WorkerGlobalScope: any; @@ -52,7 +62,7 @@ const NULL_ON_PROP_VALUE: any[] = [null]; export function bindArguments(args: any[], source: string): any[] { for (let i = args.length - 1; i >= 0; i--) { if (typeof args[i] === 'function') { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); } } return args; @@ -300,7 +310,7 @@ export function patchClass(className: string) { ObjectDefineProperty(_global[className].prototype, prop, { set: function(fn) { if (typeof fn === 'function') { - this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); // keep callback in wrapped function so we can // use it in Function.prototype.toString to return // the native one. @@ -379,7 +389,8 @@ export function patchMacroTask( setNative = patchMethod(obj, funcName, (delegate: Function) => function(self: any, args: any[]) { const meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return Zone.current.scheduleMacroTask(meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone( + meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. return delegate.apply(self, args); From fd91152e615e3e8fbe69102f370fd32df8e3e174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Wed, 10 Jan 2018 10:44:48 -0800 Subject: [PATCH 008/106] chore: release v0.8.20 --- CHANGELOG.md | 16 + dist/fake-async-test.js | 12 +- dist/webapis-media-query.js | 2 +- dist/webapis-media-query.min.js | 2 +- dist/webapis-rtc-peer-connection.js | 4 +- dist/webapis-rtc-peer-connection.min.js | 2 +- dist/zone-bluebird.js | 2 +- dist/zone-bluebird.min.js | 2 +- dist/zone-error.js | 6 +- dist/zone-error.min.js | 2 +- dist/zone-mix.js | 504 +++++++++++------------- dist/zone-node.js | 355 ++++++++--------- dist/zone-patch-cordova.js | 4 +- dist/zone-patch-cordova.min.js | 2 +- dist/zone-patch-electron.js | 16 +- dist/zone-patch-electron.min.js | 2 +- dist/zone-patch-rxjs.js | 13 +- dist/zone-patch-rxjs.min.js | 2 +- dist/zone-patch-user-media.js | 35 ++ dist/zone-patch-user-media.min.js | 1 + dist/zone-testing-bundle.js | 452 ++++++++++----------- dist/zone-testing-node-bundle.js | 367 +++++++++-------- dist/zone-testing.js | 12 +- dist/zone.js | 440 ++++++++++----------- dist/zone.min.js | 4 +- dist/zone_externs.js | 24 +- package.json | 2 +- 27 files changed, 1122 insertions(+), 1163 deletions(-) create mode 100644 dist/zone-patch-user-media.js create mode 100644 dist/zone-patch-user-media.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index e90a07617..896989b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ + +## [0.8.20](https://github.com/angular/zone.js/compare/v0.8.19...0.8.20) (2018-01-10) + + +### Bug Fixes + +* **core:** add comment for shorter var/function name ([67e8178](https://github.com/angular/zone.js/commit/67e8178)) +* **core:** add file check script in travis build ([615a6c1](https://github.com/angular/zone.js/commit/615a6c1)) +* **core:** add helper method in util.ts to shorter zone.wrap/scehduleMacroTask ([8293c37](https://github.com/angular/zone.js/commit/8293c37)) +* **core:** add rxjs test ([31832a7](https://github.com/angular/zone.js/commit/31832a7)) +* **core:** fix [#989](https://github.com/angular/zone.js/issues/989), remove unuse code, use shorter name to reduce bundle size ([73b0061](https://github.com/angular/zone.js/commit/73b0061)) +* **core:** fix shorter name closure conflict ([00a4e31](https://github.com/angular/zone.js/commit/00a4e31)) +* **core:** remove unreadable short names ([957351e](https://github.com/angular/zone.js/commit/957351e)) + + + ## [0.8.18](https://github.com/angular/zone.js/compare/v0.8.17...0.8.18) (2017-09-27) diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index bb4a2e6d3..fb5c807a8 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -161,7 +161,7 @@ this.pendingTimers = []; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakyAsyncTestSpec + // in case user can't access the construction of FakeAsyncTestSpec // user can also define macroTaskOptions by define a global variable. if (!this.macroTaskOptions) { this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; @@ -303,16 +303,16 @@ // should pass additional arguments to callback if have any // currently we know process.nextTick will have such additional // arguments - var addtionalArgs = void 0; + var additionalArgs = void 0; if (args) { - var callbackIndex = task.data.callbackIndex; + var callbackIndex = task.data.cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - addtionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } } this._microtasks.push({ func: task.invoke, - args: addtionalArgs, + args: additionalArgs, target: task.data && task.data.target }); break; @@ -350,7 +350,7 @@ task.data.isPeriodic = true; } else { - // not periodic, use setTimout to simulate + // not periodic, use setTimeout to simulate task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } break; diff --git a/dist/webapis-media-query.js b/dist/webapis-media-query.js index d8ff5db27..656e51f80 100644 --- a/dist/webapis-media-query.js +++ b/dist/webapis-media-query.js @@ -22,7 +22,7 @@ Zone.__load_patch('mediaQuery', function (global, Zone, api) { if (!global['MediaQueryList']) { return; } - api.patchEventTarget(global, [global['MediaQueryList'].prototype], { addEventListenerFnName: 'addListener', removeEventListenerFnName: 'removeListener' }); + api.patchEventTarget(global, [global['MediaQueryList'].prototype], { add: 'addListener', rm: 'removeListener' }); }); }))); diff --git a/dist/webapis-media-query.min.js b/dist/webapis-media-query.min.js index dc2e5589a..075a3d5bd 100644 --- a/dist/webapis-media-query.min.js +++ b/dist/webapis-media-query.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("mediaQuery",function(e,t,n){e.MediaQueryList&&n.patchEventTarget(e,[e.MediaQueryList.prototype],{addEventListenerFnName:"addListener",removeEventListenerFnName:"removeListener"})})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("mediaQuery",function(e,t,i){e.MediaQueryList&&i.patchEventTarget(e,[e.MediaQueryList.prototype],{add:"addListener",rm:"removeListener"})})}); \ No newline at end of file diff --git a/dist/webapis-rtc-peer-connection.js b/dist/webapis-rtc-peer-connection.js index 4bbd7c936..728232d67 100644 --- a/dist/webapis-rtc-peer-connection.js +++ b/dist/webapis-rtc-peer-connection.js @@ -28,10 +28,10 @@ Zone.__load_patch('RTCPeerConnection', function (global, Zone, api) { RTCPeerConnection.prototype.addEventListener = RTCPeerConnection.prototype[addSymbol]; RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol]; // RTCPeerConnection extends EventTarget, so we must clear the symbol - // to allow pathc RTCPeerConnection.prototype.addEventListener again + // to allow patch RTCPeerConnection.prototype.addEventListener again RTCPeerConnection.prototype[addSymbol] = null; RTCPeerConnection.prototype[removeSymbol] = null; - api.patchEventTarget(global, [RTCPeerConnection.prototype], { useGlobalCallback: false }); + api.patchEventTarget(global, [RTCPeerConnection.prototype], { useG: false }); }); }))); diff --git a/dist/webapis-rtc-peer-connection.min.js b/dist/webapis-rtc-peer-connection.min.js index 9e471c6b9..a2f70d40c 100644 --- a/dist/webapis-rtc-peer-connection.min.js +++ b/dist/webapis-rtc-peer-connection.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("RTCPeerConnection",function(e,t,o){var n=e.RTCPeerConnection;if(n){var p=o.symbol("addEventListener"),r=o.symbol("removeEventListener");n.prototype.addEventListener=n.prototype[p],n.prototype.removeEventListener=n.prototype[r],n.prototype[p]=null,n.prototype[r]=null,o.patchEventTarget(e,[n.prototype],{useGlobalCallback:!1})}})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("RTCPeerConnection",function(e,t,o){var n=e.RTCPeerConnection;if(n){var p=o.symbol("addEventListener"),r=o.symbol("removeEventListener");n.prototype.addEventListener=n.prototype[p],n.prototype.removeEventListener=n.prototype[r],n.prototype[p]=null,n.prototype[r]=null,o.patchEventTarget(e,[n.prototype],{useG:!1})}})}); \ No newline at end of file diff --git a/dist/zone-bluebird.js b/dist/zone-bluebird.js index a56b94189..4b5b0c797 100644 --- a/dist/zone-bluebird.js +++ b/dist/zone-bluebird.js @@ -18,7 +18,7 @@ * 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.__load_patch('bluebird', function (global, Zone, api) { +Zone.__load_patch('bluebird', function (global, Zone) { // TODO: @JiaLiPassion, we can automatically patch bluebird // if global.Promise = Bluebird, but sometimes in nodejs, // global.Promise is not Bluebird, and Bluebird is just be diff --git a/dist/zone-bluebird.min.js b/dist/zone-bluebird.min.js index da9f59d31..ad38e5632 100644 --- a/dist/zone-bluebird.min.js +++ b/dist/zone-bluebird.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("bluebird",function(e,n,t){var o="bluebird";n[n.__symbol__(o)]=function(e){e.setScheduler(function(e){n.current.scheduleMicroTask(o,e)})}})}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("bluebird",function(e,n){var t="bluebird";n[n.__symbol__(t)]=function(e){e.setScheduler(function(e){n.current.scheduleMicroTask(t,e)})}})}); \ No newline at end of file diff --git a/dist/zone-error.js b/dist/zone-error.js index 3e029aca7..66f27ddab 100644 --- a/dist/zone-error.js +++ b/dist/zone-error.js @@ -171,7 +171,7 @@ Zone.__load_patch('Error', function (global, Zone, api) { } } } - return value.apply(this, [error, structuredStackTrace]); + return value.call(this, error, structuredStackTrace); }; } }); @@ -197,7 +197,7 @@ Zone.__load_patch('Error', function (global, Zone, api) { var frame = frames_2.shift(); // On safari it is possible to have stack frame with no line number. // This check makes sure that we don't filter frames on name only (must have - // linenumber) + // line number) if (/:\d+:\d+/.test(frame)) { // Get rid of the path so that we don't accidentally find function name in path. // In chrome the separator is `(` and `@` in FF and safari @@ -263,7 +263,7 @@ Zone.__load_patch('Error', function (global, Zone, api) { // all kinds of tasks with one error thrown. childDetectZone.run(function () { childDetectZone.runGuarded(function () { - var fakeTransitionTo = function (toState, fromState1, fromState2) { }; + var fakeTransitionTo = function () { }; childDetectZone.scheduleEventTask(blacklistedStackFramesSymbol, function () { childDetectZone.scheduleMacroTask(blacklistedStackFramesSymbol, function () { childDetectZone.scheduleMicroTask(blacklistedStackFramesSymbol, function () { diff --git a/dist/zone-error.min.js b/dist/zone-error.min.js index 54e6e53f0..4aff20179 100644 --- a/dist/zone-error.min.js +++ b/dist/zone-error.min.js @@ -1 +1 @@ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("Error",function(r,t,e){function n(){var r=this,t=o.apply(this,arguments),i=t.originalStack=t.stack;if(n[f]&&i){for(var s=i.split("\n"),k=e.currentZoneFrame(),p=0;s[p]!==a&&s[p]!==c&&p= 0; i--) { - if (typeof args[i] === FUNCTION) { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); } } return args; } -function wrapFunctionArgs(func, source) { - return function () { - var args = Array.prototype.slice.call(arguments); - var wrappedArgs = bindArguments(args, source ? source : func.name); - return func.apply(this, wrappedArgs); - }; -} -function patchArguments(target, name, source) { - return patchMethod(target, name, function (delegate, delegateName, name) { return function (self, args) { - return delegate && delegate.apply(self, bindArguments(args, source)); - }; }); -} function patchPrototype(prototype, fnNames) { var source = prototype.constructor['name']; var _loop_1 = function (i) { var name_1 = fnNames[i]; var delegate = prototype[name_1]; if (delegate) { - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, name_1); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); if (!isPropertyWritable(prototypeDesc)) { return "continue"; } @@ -1142,23 +1165,20 @@ function isPropertyWritable(propertyDesc) { if (propertyDesc.writable === false) { return false; } - if (typeof propertyDesc.get === FUNCTION && typeof propertyDesc.set === UNDEFINED) { - return false; - } - return true; + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(typeof window !== 'undefined' && window['HTMLElement']); +var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== 'undefined' && window['HTMLElement']); + !!(isWindowExists && internalWindow['HTMLElement']); var zoneSymbolEventNames = {}; var wrapFn = function (event) { // https://github.com/angular/zone.js/issues/911, in IE, sometimes @@ -1180,10 +1200,10 @@ var wrapFn = function (event) { return result; }; function patchProperty(obj, prop, prototype) { - var desc = Object.getOwnPropertyDescriptor(obj, prop); + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); if (prototypeDesc) { desc = { enumerable: true, configurable: true }; } @@ -1258,10 +1278,10 @@ function patchProperty(obj, prop, prototype) { // the onclick will be evaluated when first time event was triggered or // the property is accessed, https://github.com/angular/zone.js/issues/525 // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.apply(this); + var value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === FUNCTION) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } return value; @@ -1269,7 +1289,7 @@ function patchProperty(obj, prop, prototype) { } return null; }; - Object.defineProperty(obj, prop, desc); + ObjectDefineProperty(obj, prop, desc); } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1334,10 +1354,10 @@ function patchClass(className) { }; } else { - Object.defineProperty(_global[className].prototype, prop, { + ObjectDefineProperty(_global[className].prototype, prop, { set: function (fn) { if (typeof fn === 'function') { - this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); // keep callback in wrapped function so we can // use it in Function.prototype.toString to return // the native one. @@ -1363,7 +1383,7 @@ function patchClass(className) { function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1375,7 +1395,7 @@ function patchMethod(target, name, patchFn) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && Object.getOwnPropertyDescriptor(proto, name); + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { var patchDelegate_1 = patchFn(delegate, delegateName, name); proto[name] = function () { @@ -1391,7 +1411,7 @@ function patchMacroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1399,9 +1419,8 @@ function patchMacroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMacroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask, null); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. @@ -1413,7 +1432,7 @@ function patchMicroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1421,9 +1440,8 @@ function patchMicroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMicroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1442,8 +1460,7 @@ function isIEOrEdge() { } isDetectedIEOrEdge = true; try { - var ua = window.navigator.userAgent; - var msie = ua.indexOf('MSIE '); + var ua = internalWindow.navigator.userAgent; if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } @@ -1462,19 +1479,18 @@ function isIEOrEdge() { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone, api) { +Zone.__load_patch('toString', function (global, Zone) { // patch Func.prototype.toString to let them look like native var originalFunctionToString = Zone['__zone_symbol__originalToString'] = Function.prototype.toString; - var FUNCTION = 'function'; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function () { - if (typeof this === FUNCTION) { + if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === FUNCTION) { + if (typeof originalDelegate === 'function') { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { @@ -1518,25 +1534,19 @@ Zone.__load_patch('toString', function (global, Zone, api) { * @fileoverview * @suppress {missingRequire} */ -var TRUE_STR = 'true'; -var FALSE_STR = 'false'; // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - isUsingGlobalCallback: true + useG: true }; var zoneSymbolEventNames$1 = {}; var globalSources = {}; -var CONSTRUCTOR_NAME = 'name'; -var FUNCTION_TYPE = 'function'; -var OBJECT_TYPE = 'object'; -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.addEventListenerFnName) || 'addEventListener'; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.removeEventListenerFnName) || 'removeEventListener'; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listenersFnName) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.removeAllFnName) || 'removeAllListeners'; + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; @@ -1548,7 +1558,7 @@ function patchEventTarget(_global, apis, patchOptions) { return; } var delegate = task.callback; - if (typeof delegate === OBJECT_TYPE && delegate.handleEvent) { + if (typeof delegate === 'object' && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = function (event) { return delegate.handleEvent(event); }; task.originalDelegate = delegate; @@ -1561,7 +1571,7 @@ function patchEventTarget(_global, apis, patchOptions) { // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].apply(target, [event.type, delegate_1, options]); + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } }; // global shared zoneAwareCallback to handle all event callback with capture = false @@ -1572,7 +1582,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; @@ -1604,7 +1614,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; @@ -1633,21 +1643,21 @@ function patchEventTarget(_global, apis, patchOptions) { return false; } var useGlobalCallback = true; - if (patchOptions && patchOptions.useGlobalCallback !== undefined) { - useGlobalCallback = patchOptions.useGlobalCallback; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; } - var validateHandler = patchOptions && patchOptions.validateHandler; + var validateHandler = patchOptions && patchOptions.vh; var checkDuplicate = true; - if (patchOptions && patchOptions.checkDuplicate !== undefined) { - checkDuplicate = patchOptions.checkDuplicate; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; } var returnTarget = false; - if (patchOptions && patchOptions.returnTarget !== undefined) { - returnTarget = patchOptions.returnTarget; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; } var proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1670,21 +1680,17 @@ function patchEventTarget(_global, apis, patchOptions) { var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; var nativePrependEventListener; - if (patchOptions && patchOptions.prependEventListenerFnName) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prependEventListenerFnName)] = - proto[patchOptions.prependEventListenerFnName]; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; } - var customScheduleGlobal = function (task) { + var customScheduleGlobal = function () { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } - return nativeAddEventListener.apply(taskData.target, [ - taskData.eventName, - taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - taskData.options - ]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { // if task is not marked as isRemoved, this call is directly @@ -1721,41 +1727,31 @@ function patchEventTarget(_global, apis, patchOptions) { if (!task.allRemoved) { return; } - return nativeRemoveEventListener.apply(task.target, [ - task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - task.options - ]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { - return nativeAddEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { - return nativePrependEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.apply(task.target, [task.eventName, task.invoke, task.options]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); }; var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; var compareTaskCallbackVsDelegate = function (task, delegate) { var typeOfDelegate = typeof delegate; - if ((typeOfDelegate === FUNCTION_TYPE && task.callback === delegate) || - (typeOfDelegate === OBJECT_TYPE && task.originalDelegate === delegate)) { - // same callback, same capture, same event name, just return - return true; - } - return false; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.compareTaskCallbackVsDelegate) ? - patchOptions.compareTaskCallbackVsDelegate : - compareTaskCallbackVsDelegate; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { if (returnTarget === void 0) { returnTarget = false; } if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; - var targetZone = Zone.current; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); @@ -1764,7 +1760,7 @@ function patchEventTarget(_global, apis, patchOptions) { // case here to improve addEventListener performance // we will create the bind delegate when invoke var isHandleEvent = false; - if (typeof delegate !== FUNCTION_TYPE) { + if (typeof delegate !== 'function') { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -1833,7 +1829,7 @@ function patchEventTarget(_global, apis, patchOptions) { existingTasks = target[symbolEventName] = []; } var source; - var constructorName = target.constructor[CONSTRUCTOR_NAME]; + var constructorName = target.constructor['name']; var targetSource = globalSources[constructorName]; if (targetSource) { source = targetSource[eventName]; @@ -1855,7 +1851,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.eventName = eventName; taskData.isExisting = isExisting; var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; - // keep taskData into data to allow onScheduleEventTask to acess the task information + // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; } @@ -1929,7 +1925,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (existingTasks) { for (var i = 0; i < existingTasks.length; i++) { var existingTask = existingTasks[i]; - var typeOfDelegate = typeof delegate; if (compare(existingTask, delegate)) { existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check @@ -1977,11 +1972,11 @@ function patchEventTarget(_global, apis, patchOptions) { // so just keep removeListener eventListener until // all other eventListeners are removed if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, [evtName]); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } } // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { var symbolEventNames = zoneSymbolEventNames$1[eventName]; @@ -1995,7 +1990,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } if (captureTasks) { @@ -2003,7 +1998,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } } @@ -2073,12 +2068,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { setName += nameSuffix; cancelName += nameSuffix; var tasksByHandleId = {}; - var NUMBER = 'number'; - var STRING = 'string'; - var FUNCTION = 'function'; - var INTERVAL = 'Interval'; - var TIMEOUT = 'Timeout'; - var NOT_SCHEDULED = 'notScheduled'; function scheduleTask(task) { var data = task.data; function timer() { @@ -2086,21 +2075,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task.invoke.apply(this, arguments); } finally { - if (task.data && task.data.isPeriodic) { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - return; - } - if (typeof data.handleId === NUMBER) { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } @@ -2113,21 +2101,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } setNative = patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === FUNCTION) { - var zone = Zone.current; + if (typeof args[0] === 'function') { var options = { handleId: null, - isPeriodic: nameSuffix === INTERVAL, - delay: (nameSuffix === TIMEOUT || nameSuffix === INTERVAL) ? args[1] || 0 : 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); + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === NUMBER) { + if (typeof handle === 'number') { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -2139,12 +2126,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === FUNCTION && - typeof handle.unref === FUNCTION) { + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { task.ref = handle.ref.bind(handle); task.unref = handle.unref.bind(handle); } - if (typeof handle === NUMBER || handle) { + if (typeof handle === 'number' || handle) { return handle; } return task; @@ -2158,7 +2145,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, cancelName, function (delegate) { return function (self, args) { var id = args[0]; var task; - if (typeof id === NUMBER) { + if (typeof id === 'number') { // non nodejs env. task = tasksByHandleId[id]; } @@ -2170,10 +2157,10 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task = id; } } - if (task && typeof task.type === STRING) { - if (task.state !== NOT_SCHEDULED && + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === NUMBER) { + if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { @@ -2206,16 +2193,13 @@ var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; var _create = Object.create; var unconfigurablesKey = zoneSymbol('unconfigurables'); -var PROTOTYPE = 'prototype'; -var OBJECT = 'object'; -var UNDEFINED$1 = 'undefined'; function propertyPatch() { Object.defineProperty = function (obj, prop, desc) { if (isUnconfigurable(obj, prop)) { throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); } var originalConfigurableFlag = desc.configurable; - if (prop !== PROTOTYPE) { + if (prop !== 'prototype') { desc = rewriteDescriptor(obj, prop, desc); } return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); @@ -2227,7 +2211,7 @@ function propertyPatch() { return obj; }; Object.create = function (obj, proto) { - if (typeof proto === OBJECT && !Object.isFrozen(proto)) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { Object.keys(proto).forEach(function (prop) { proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); }); @@ -2274,7 +2258,7 @@ function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { if (desc.configurable) { // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's // retry with the original flag value - if (typeof originalConfigurableFlag == UNDEFINED$1) { + if (typeof originalConfigurableFlag == 'undefined') { delete desc.configurable; } else { @@ -2315,22 +2299,22 @@ function apply(api, _global) { if (!_global.EventTarget) { patchEventTarget(_global, [WS.prototype]); } - _global.WebSocket = function (a, b) { - var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); var proxySocket; var proxySocketProto; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); + var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = Object.create(socket); + proxySocket = ObjectCreate(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method proxySocketProto = socket; - ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function (propName) { + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { proxySocket[propName] = function () { - var args = Array.prototype.slice.call(arguments); - if (propName === 'addEventListener' || propName === 'removeEventListener') { + var args = ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { var eventName = args.length > 0 ? args[0] : undefined; if (eventName) { var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); @@ -2602,12 +2586,13 @@ function propertyDescriptorPatch(api, _global) { var ignoreProperties = _global.__Zone_ignore_on_properties; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { + var internalWindow = window; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(window, eventNames.concat(['messageerror']), ignoreProperties, Object.getPrototypeOf(window)); + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof window['SVGElement'] !== 'undefined') { - patchFilteredProperties(window['SVGElement'].prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); } patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); @@ -2616,11 +2601,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = window['HTMLMarqueeElement']; + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; if (HTMLMarqueeElement_1) { patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); } - var Worker_1 = window['Worker']; + var Worker_1 = internalWindow['Worker']; if (Worker_1) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } @@ -2652,15 +2637,17 @@ function propertyDescriptorPatch(api, _global) { } } function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') { // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 // IDL interface attributes are not configurable - var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); + var desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; } - var xhrDesc = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'onreadystatechange'); + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera // by default XMLHttpRequest.prototype.onreadystatechange is undefined // without adding enumerable and configurable will cause onreadystatechange @@ -2668,7 +2655,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { @@ -2678,12 +2665,12 @@ function canPatchViaPropertyDescriptor() { var req = new XMLHttpRequest(); var result = !!req.onreadystatechange; // restore original desc - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', xhrDesc || {}); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fakeonreadystatechange'); - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fake'); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { @@ -2719,7 +2706,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = Zone.current.wrap(elt[onproperty], source); + bound = wrapWithCurrentZone(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } @@ -2824,7 +2811,9 @@ function eventTargetPatch(_global, api) { var type = _global[apis[i]]; apiTypes.push(type && type.prototype); } - patchEventTarget(_global, apiTypes, { validateHandler: checkIEAndCrossContext }); + // vh is validateHandler to check event handler + // is valid or not(for security check) + patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); api.patchEventTarget = patchEventTarget; return true; } @@ -2849,22 +2838,23 @@ function registerElementPatch(_global) { 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); + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); if (descriptor && descriptor.value) { - descriptor.value = Zone.current.wrap(descriptor.value, source); + descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } else { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } - else if (opts.prototype[callback]) { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + else if (prototype[callback]) { + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } }); } - return _registerElement.apply(document, [name, opts]); + return _registerElement.call(document, name, opts); }; attachOriginToPatched(document.registerElement, _registerElement); } @@ -2883,21 +2873,21 @@ function registerElementPatch(_global) { Zone.__load_patch('util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('timers', function (global, Zone, api) { +Zone.__load_patch('timers', function (global) { var set = 'set'; var clear = 'clear'; patchTimer(global, set, clear, 'Timeout'); patchTimer(global, set, clear, 'Interval'); patchTimer(global, set, clear, 'Immediate'); }); -Zone.__load_patch('requestAnimationFrame', function (global, Zone, api) { +Zone.__load_patch('requestAnimationFrame', function (global) { patchTimer(global, 'request', 'cancel', 'AnimationFrame'); patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); }); -Zone.__load_patch('blocking', function (global, Zone, api) { +Zone.__load_patch('blocking', function (global, Zone) { var blockingMethods = ['alert', 'prompt', 'confirm']; for (var i = 0; i < blockingMethods.length; i++) { var name_1 = blockingMethods[i]; @@ -2931,17 +2921,17 @@ Zone.__load_patch('on_property', function (global, Zone, api) { propertyPatch(); registerElementPatch(global); }); -Zone.__load_patch('canvas', function (global, Zone, api) { +Zone.__load_patch('canvas', function (global) { var HTMLCanvasElement = global['HTMLCanvasElement']; if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.toBlob) { patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, callbackIndex: 0, args: args }; + return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; }); } }); -Zone.__load_patch('XHR', function (global, Zone, api) { - // Treat XMLHTTPRequest as a macrotask. +Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. patchXHR(global); var XHR_TASK = zoneSymbol('xhrTask'); var XHR_SYNC = zoneSymbol('xhrSync'); @@ -2949,19 +2939,18 @@ Zone.__load_patch('XHR', function (global, Zone, api) { var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); var XHR_URL = zoneSymbol('xhrURL'); function patchXHR(window) { + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { - var pendingTask = target[XHR_TASK]; - return pendingTask; + return target[XHR_TASK]; } - var SYMBOL_ADDEVENTLISTENER = zoneSymbol('addEventListener'); - var SYMBOL_REMOVEEVENTLISTENER = zoneSymbol('removeEventListener'); - var oriAddListener = XMLHttpRequest.prototype[SYMBOL_ADDEVENTLISTENER]; - var oriRemoveListener = XMLHttpRequest.prototype[SYMBOL_REMOVEEVENTLISTENER]; + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { var XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { - oriAddListener = XMLHttpRequestEventTarget.prototype[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = XMLHttpRequestEventTarget.prototype[SYMBOL_REMOVEEVENTLISTENER]; + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } } var READY_STATE_CHANGE = 'readystatechange'; @@ -2973,11 +2962,11 @@ Zone.__load_patch('XHR', function (global, Zone, api) { // remove existing event listener var listener = target[XHR_LISTENER]; if (!oriAddListener) { - oriAddListener = target[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = target[SYMBOL_REMOVEEVENTLISTENER]; + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } if (listener) { - oriRemoveListener.apply(target, [READY_STATE_CHANGE, listener]); + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); } var newListener = target[XHR_LISTENER] = function () { if (target.readyState === target.DONE) { @@ -2988,7 +2977,7 @@ Zone.__load_patch('XHR', function (global, Zone, api) { } } }; - oriAddListener.apply(target, [READY_STATE_CHANGE, newListener]); + oriAddListener.call(target, READY_STATE_CHANGE, newListener); var storedTask = target[XHR_TASK]; if (!storedTask) { target[XHR_TASK] = task; @@ -3005,14 +2994,13 @@ Zone.__load_patch('XHR', function (global, Zone, api) { data.aborted = true; return abortNative.apply(data.target, data.args); } - var openNative = patchMethod(window.XMLHttpRequest.prototype, 'open', function () { return function (self, args) { + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { self[XHR_SYNC] = args[2] == false; self[XHR_URL] = args[1]; return openNative.apply(self, args); }; }); var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var sendNative = patchMethod(window.XMLHttpRequest.prototype, 'send', function () { return function (self, args) { - var zone = Zone.current; + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); @@ -3026,13 +3014,12 @@ Zone.__load_patch('XHR', function (global, Zone, api) { args: args, aborted: false }; - return zone.scheduleMacroTask(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + return scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } }; }); - var STRING_TYPE = 'string'; - var abortNative = patchMethod(window.XMLHttpRequest.prototype, 'abort', function (delegate) { return function (self, args) { + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self) { var task = findPendingTask(self); - if (task && typeof task.type == STRING_TYPE) { + if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. // If the XHR has already been aborted, do nothing. // Fix #569, call abort multiple times before done will cause @@ -3048,19 +3035,13 @@ Zone.__load_patch('XHR', function (global, Zone, api) { }; }); } }); -Zone.__load_patch('geolocation', function (global, Zone, api) { +Zone.__load_patch('geolocation', function (global) { /// GEO_LOCATION if (global['navigator'] && global['navigator'].geolocation) { patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); } }); -Zone.__load_patch('getUserMedia', function (global, Zone, api) { - var navigator = global['navigator']; - if (navigator && navigator.getUserMedia) { - navigator.getUserMedia = wrapFunctionArgs(navigator.getUserMedia); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone, api) { +Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { // handle unhandled promise rejection function findPromiseRejectionHandler(evtName) { return function (e) { @@ -3091,13 +3072,7 @@ Zone.__load_patch('PromiseRejectionEvent', function (global, Zone, api) { * 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.__load_patch('EventEmitter', function (global, Zone, api) { - var callAndReturnFirstParam = function (fn) { - return function (self, args) { - fn(self, args); - return self; - }; - }; +Zone.__load_patch('EventEmitter', function (global) { // For EventEmitter var EE_ADD_LISTENER = 'addListener'; var EE_PREPEND_LISTENER = 'prependListener'; @@ -3106,23 +3081,20 @@ Zone.__load_patch('EventEmitter', function (global, Zone, api) { var EE_LISTENERS = 'listeners'; var EE_ON = 'on'; var compareTaskCallbackVsDelegate = function (task, delegate) { - if (task.callback === delegate || task.callback.listener === delegate) { - // same callback, same capture, same event name, just return - return true; - } - return false; + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; }; function patchEventEmitterMethods(obj) { var result = patchEventTarget(global, [obj], { - useGlobalCallback: false, - addEventListenerFnName: EE_ADD_LISTENER, - removeEventListenerFnName: EE_REMOVE_LISTENER, - prependEventListenerFnName: EE_PREPEND_LISTENER, - removeAllFnName: EE_REMOVE_ALL_LISTENER, - listenersFnName: EE_LISTENERS, - checkDuplicate: false, - returnTarget: true, - compareTaskCallbackVsDelegate: compareTaskCallbackVsDelegate + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; @@ -3147,7 +3119,7 @@ Zone.__load_patch('EventEmitter', function (global, Zone, api) { * 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.__load_patch('fs', function (global, Zone, api) { +Zone.__load_patch('fs', function () { var fs; try { fs = require('fs'); @@ -3170,7 +3142,7 @@ Zone.__load_patch('fs', function (global, Zone, api) { return { name: 'fs.' + name, args: args, - callbackIndex: args.length > 0 ? args.length - 1 : -1, + cbIdx: args.length > 0 ? args.length - 1 : -1, target: self }; }); @@ -3190,9 +3162,9 @@ var clear = 'clear'; Zone.__load_patch('node_util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('node_timers', function (global, Zone, api) { +Zone.__load_patch('node_timers', function (global, Zone) { // Timers var globalUseTimeoutFromTimer = false; try { @@ -3218,7 +3190,7 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { patchTimer(timers, set, clear, 'Immediate'); } catch (error) { - // timers module not exists, for example, when we using nativescript + // timers module not exists, for example, when we using nativeScript // timers is not available } if (isMix) { @@ -3237,7 +3209,7 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { } else { // global use timers setTimeout, but not equals - // this happenes when use nodejs v0.10.x, global setTimeout will + // this happens when use nodejs v0.10.x, global setTimeout will // use a lazy load version of timers setTimeout // we should not double patch timer's setTimeout // so we only store the __symbol__ for consistency @@ -3247,13 +3219,13 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { } }); // patch process related methods -Zone.__load_patch('nextTick', function (global, Zone, api) { +Zone.__load_patch('nextTick', function () { // patch nextTick as microTask patchMicroTask(process, 'nextTick', function (self, args) { return { name: 'process.nextTick', args: args, - callbackIndex: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, target: process }; }); @@ -3281,7 +3253,7 @@ Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api } }); // Crypto -Zone.__load_patch('crypto', function (global, Zone, api) { +Zone.__load_patch('crypto', function () { var crypto; try { crypto = require('crypto'); @@ -3296,7 +3268,7 @@ Zone.__load_patch('crypto', function (global, Zone, api) { return { name: 'crypto.' + name, args: args, - callbackIndex: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? args.length - 1 : -1, target: crypto @@ -3305,13 +3277,13 @@ Zone.__load_patch('crypto', function (global, Zone, api) { }); } }); -Zone.__load_patch('console', function (global, Zone, api) { +Zone.__load_patch('console', function (global, Zone) { var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; consoleMethods.forEach(function (m) { var originalMethod = console[Zone.__symbol__(m)] = console[m]; if (originalMethod) { console[m] = function () { - var args = Array.prototype.slice.call(arguments); + var args = ArraySlice.call(arguments); if (Zone.current === Zone.root) { return originalMethod.apply(this, args); } diff --git a/dist/zone-node.js b/dist/zone-node.js index 19166a6f4..d4c3b5ff3 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -476,12 +476,13 @@ var Zone$1 = (function (global) { this.cancelFn = cancelFn; this.callback = callback; var self = this; - if (type === eventTask && options && options.isUsingGlobalCallback) { + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { this.invoke = ZoneTask.invokeTask; } else { this.invoke = function () { - return ZoneTask.invokeTask.apply(global, [self, this, arguments]); + return ZoneTask.invokeTask.call(global, self, this, arguments); }; } } @@ -598,7 +599,6 @@ var Zone$1 = (function (global) { } } } - var showError = !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; _api.microtaskDrainDone(); _isDrainingMicrotaskQueue = false; } @@ -622,7 +622,7 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - patchArguments: function () { return noop; }, + bindArguments: function () { return null; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -661,6 +661,8 @@ var __values = (undefined && undefined.__values) || function (o) { * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; function readableObjectToString(obj) { if (obj && obj.toString === Object.prototype.toString) { var className = obj.constructor && obj.constructor.name; @@ -708,7 +710,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { try { var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; if (handler && typeof handler === 'function') { - handler.apply(this, [e]); + handler.call(this, e); } } catch (err) { @@ -754,8 +756,6 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; }; var TYPE_ERROR = 'Promise resolved with itself'; - var OBJECT = 'object'; - var FUNCTION = 'function'; var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution function resolvePromise(promise, state, value) { @@ -767,7 +767,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // should only get value.then once based on promise spec. var then = null; try { - if (typeof value === OBJECT || typeof value === FUNCTION) { + if (typeof value === 'object' || typeof value === 'function') { then = value && value.then; } } @@ -784,11 +784,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { clearRejectedNoCatch(value); resolvePromise(promise, value[symbolState], value[symbolValue]); } - else if (state !== REJECTED && typeof then === FUNCTION) { + else if (state !== REJECTED && typeof then === 'function') { try { - then.apply(value, [ - onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)) - ]); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { onceWrapper(function () { @@ -808,7 +806,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Zone.currentTask.data[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone - Object.defineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); } } for (var i = 0; i < queue.length;) { @@ -846,8 +844,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // eventHandler try { var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === FUNCTION) { - handler.apply(this, [{ rejection: promise[symbolValue], promise: promise }]); + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); } } catch (err) { @@ -863,8 +861,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { clearRejectedNoCatch(promise); var delegate = promise[symbolState] ? - (typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution : - (typeof onRejected === FUNCTION) ? onRejected : forwardRejection; + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, function () { try { resolvePromise(chainPromise, true, zone.run(delegate, undefined, [promise[symbolValue]])); @@ -992,7 +990,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { ZoneAwarePromise['all'] = ZoneAwarePromise.all; var NativePromise = global[symbolPromise] = global['Promise']; var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = Object.getOwnPropertyDescriptor(global, 'Promise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; desc && delete desc.value; @@ -1025,7 +1023,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { api.setNativePromise(NewNativePromise); } }; - Object.defineProperty(global, 'Promise', desc); + ObjectDefineProperty(global, 'Promise', desc); } global['Promise'] = ZoneAwarePromise; var symbolThenPatched = __symbol__('thenPatched'); @@ -1034,11 +1032,11 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescritor is writable or not + // check Ctor.prototype.then propertyDescriptor is writable or not // in meteor env, writable is false, we have to make it to be true. - var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then'); + var prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { - Object.defineProperty(Ctor.prototype, 'then', { writable: true }); + ObjectDefineProperty(Ctor.prototype, 'then', { writable: true }); } Ctor.prototype.then = function (onResolve, onReject) { var _this = this; @@ -1065,7 +1063,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { if (NativePromise) { patchThen(NativePromise); var fetch_1 = global['fetch']; - if (typeof fetch_1 == FUNCTION) { + if (typeof fetch_1 == 'function') { global['fetch'] = zoneify(fetch_1); } } @@ -1086,27 +1084,58 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { * @fileoverview * @suppress {undefinedVars,globalThis,missingRequire} */ +// issue #989, to reduce bundle size, use short name +/** Object.getOwnPropertyDescriptor */ +/** + * @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 ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ +var ObjectDefineProperty = Object.defineProperty; +/** Object.getPrototypeOf */ +var ObjectGetPrototypeOf = Object.getPrototypeOf; +/** Object.create */ + +/** Array.prototype.slice */ +var ArraySlice = Array.prototype.slice; +/** addEventListener string const */ +var ADD_EVENT_LISTENER_STR = 'addEventListener'; +/** removeEventListener string const */ +var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; +/** zoneSymbol addEventListener */ +var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); +/** zoneSymbol removeEventListener */ +var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); +/** true string const */ +var TRUE_STR = 'true'; +/** false string const */ +var FALSE_STR = 'false'; +/** __zone_symbol__ string const */ +var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); +} +function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} var zoneSymbol = Zone.__symbol__; -var _global = typeof window === 'object' && window || typeof self === 'object' && self || global; -var FUNCTION = 'function'; -var UNDEFINED = 'undefined'; +var isWindowExists = typeof window !== 'undefined'; +var internalWindow = isWindowExists ? window : undefined; +var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; var REMOVE_ATTRIBUTE = 'removeAttribute'; var NULL_ON_PROP_VALUE = [null]; function bindArguments(args, source) { for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === FUNCTION) { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); } } return args; } -function patchArguments(target, name, source) { - return patchMethod(target, name, function (delegate, delegateName, name) { return function (self, args) { - return delegate && delegate.apply(self, bindArguments(args, source)); - }; }); -} - function isPropertyWritable(propertyDesc) { if (!propertyDesc) { return true; @@ -1114,23 +1143,20 @@ function isPropertyWritable(propertyDesc) { if (propertyDesc.writable === false) { return false; } - if (typeof propertyDesc.get === FUNCTION && typeof propertyDesc.set === UNDEFINED) { - return false; - } - return true; + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); // we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== 'undefined' && window['HTMLElement']); + !!(isWindowExists && internalWindow['HTMLElement']); var zoneSymbolEventNames = {}; var wrapFn = function (event) { // https://github.com/angular/zone.js/issues/911, in IE, sometimes @@ -1152,10 +1178,10 @@ var wrapFn = function (event) { return result; }; function patchProperty(obj, prop, prototype) { - var desc = Object.getOwnPropertyDescriptor(obj, prop); + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); if (prototypeDesc) { desc = { enumerable: true, configurable: true }; } @@ -1230,10 +1256,10 @@ function patchProperty(obj, prop, prototype) { // the onclick will be evaluated when first time event was triggered or // the property is accessed, https://github.com/angular/zone.js/issues/525 // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.apply(this); + var value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === FUNCTION) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } return value; @@ -1241,7 +1267,7 @@ function patchProperty(obj, prop, prototype) { } return null; }; - Object.defineProperty(obj, prop, desc); + ObjectDefineProperty(obj, prop, desc); } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1267,7 +1293,7 @@ var originalInstanceKey = zoneSymbol('originalInstance'); function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1279,7 +1305,7 @@ function patchMethod(target, name, patchFn) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && Object.getOwnPropertyDescriptor(proto, name); + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { var patchDelegate_1 = patchFn(delegate, delegateName, name); proto[name] = function () { @@ -1295,7 +1321,7 @@ function patchMacroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1303,9 +1329,8 @@ function patchMacroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMacroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask, null); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. @@ -1317,7 +1342,7 @@ function patchMicroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1325,9 +1350,8 @@ function patchMicroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMicroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1348,19 +1372,18 @@ function attachOriginToPatched(patched, original) { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone, api) { +Zone.__load_patch('toString', function (global, Zone) { // patch Func.prototype.toString to let them look like native var originalFunctionToString = Zone['__zone_symbol__originalToString'] = Function.prototype.toString; - var FUNCTION = 'function'; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function () { - if (typeof this === FUNCTION) { + if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === FUNCTION) { + if (typeof originalDelegate === 'function') { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { @@ -1404,25 +1427,19 @@ Zone.__load_patch('toString', function (global, Zone, api) { * @fileoverview * @suppress {missingRequire} */ -var TRUE_STR = 'true'; -var FALSE_STR = 'false'; // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - isUsingGlobalCallback: true + useG: true }; var zoneSymbolEventNames$1 = {}; var globalSources = {}; -var CONSTRUCTOR_NAME = 'name'; -var FUNCTION_TYPE = 'function'; -var OBJECT_TYPE = 'object'; -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.addEventListenerFnName) || 'addEventListener'; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.removeEventListenerFnName) || 'removeEventListener'; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listenersFnName) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.removeAllFnName) || 'removeAllListeners'; + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; @@ -1434,7 +1451,7 @@ function patchEventTarget(_global, apis, patchOptions) { return; } var delegate = task.callback; - if (typeof delegate === OBJECT_TYPE && delegate.handleEvent) { + if (typeof delegate === 'object' && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = function (event) { return delegate.handleEvent(event); }; task.originalDelegate = delegate; @@ -1447,7 +1464,7 @@ function patchEventTarget(_global, apis, patchOptions) { // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].apply(target, [event.type, delegate_1, options]); + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } }; // global shared zoneAwareCallback to handle all event callback with capture = false @@ -1458,7 +1475,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; @@ -1490,7 +1507,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; @@ -1519,21 +1536,21 @@ function patchEventTarget(_global, apis, patchOptions) { return false; } var useGlobalCallback = true; - if (patchOptions && patchOptions.useGlobalCallback !== undefined) { - useGlobalCallback = patchOptions.useGlobalCallback; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; } - var validateHandler = patchOptions && patchOptions.validateHandler; + var validateHandler = patchOptions && patchOptions.vh; var checkDuplicate = true; - if (patchOptions && patchOptions.checkDuplicate !== undefined) { - checkDuplicate = patchOptions.checkDuplicate; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; } var returnTarget = false; - if (patchOptions && patchOptions.returnTarget !== undefined) { - returnTarget = patchOptions.returnTarget; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; } var proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1556,21 +1573,17 @@ function patchEventTarget(_global, apis, patchOptions) { var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; var nativePrependEventListener; - if (patchOptions && patchOptions.prependEventListenerFnName) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prependEventListenerFnName)] = - proto[patchOptions.prependEventListenerFnName]; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; } - var customScheduleGlobal = function (task) { + var customScheduleGlobal = function () { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } - return nativeAddEventListener.apply(taskData.target, [ - taskData.eventName, - taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - taskData.options - ]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { // if task is not marked as isRemoved, this call is directly @@ -1607,41 +1620,31 @@ function patchEventTarget(_global, apis, patchOptions) { if (!task.allRemoved) { return; } - return nativeRemoveEventListener.apply(task.target, [ - task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - task.options - ]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { - return nativeAddEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { - return nativePrependEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.apply(task.target, [task.eventName, task.invoke, task.options]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); }; var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; var compareTaskCallbackVsDelegate = function (task, delegate) { var typeOfDelegate = typeof delegate; - if ((typeOfDelegate === FUNCTION_TYPE && task.callback === delegate) || - (typeOfDelegate === OBJECT_TYPE && task.originalDelegate === delegate)) { - // same callback, same capture, same event name, just return - return true; - } - return false; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.compareTaskCallbackVsDelegate) ? - patchOptions.compareTaskCallbackVsDelegate : - compareTaskCallbackVsDelegate; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { if (returnTarget === void 0) { returnTarget = false; } if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; - var targetZone = Zone.current; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); @@ -1650,7 +1653,7 @@ function patchEventTarget(_global, apis, patchOptions) { // case here to improve addEventListener performance // we will create the bind delegate when invoke var isHandleEvent = false; - if (typeof delegate !== FUNCTION_TYPE) { + if (typeof delegate !== 'function') { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -1719,7 +1722,7 @@ function patchEventTarget(_global, apis, patchOptions) { existingTasks = target[symbolEventName] = []; } var source; - var constructorName = target.constructor[CONSTRUCTOR_NAME]; + var constructorName = target.constructor['name']; var targetSource = globalSources[constructorName]; if (targetSource) { source = targetSource[eventName]; @@ -1741,7 +1744,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.eventName = eventName; taskData.isExisting = isExisting; var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; - // keep taskData into data to allow onScheduleEventTask to acess the task information + // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; } @@ -1815,7 +1818,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (existingTasks) { for (var i = 0; i < existingTasks.length; i++) { var existingTask = existingTasks[i]; - var typeOfDelegate = typeof delegate; if (compare(existingTask, delegate)) { existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check @@ -1863,11 +1865,11 @@ function patchEventTarget(_global, apis, patchOptions) { // so just keep removeListener eventListener until // all other eventListeners are removed if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, [evtName]); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } } // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { var symbolEventNames = zoneSymbolEventNames$1[eventName]; @@ -1881,7 +1883,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } if (captureTasks) { @@ -1889,7 +1891,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } } @@ -1936,13 +1938,7 @@ function findEventTasks(target, eventName) { * 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.__load_patch('EventEmitter', function (global, Zone, api) { - var callAndReturnFirstParam = function (fn) { - return function (self, args) { - fn(self, args); - return self; - }; - }; +Zone.__load_patch('EventEmitter', function (global) { // For EventEmitter var EE_ADD_LISTENER = 'addListener'; var EE_PREPEND_LISTENER = 'prependListener'; @@ -1951,23 +1947,20 @@ Zone.__load_patch('EventEmitter', function (global, Zone, api) { var EE_LISTENERS = 'listeners'; var EE_ON = 'on'; var compareTaskCallbackVsDelegate = function (task, delegate) { - if (task.callback === delegate || task.callback.listener === delegate) { - // same callback, same capture, same event name, just return - return true; - } - return false; + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; }; function patchEventEmitterMethods(obj) { var result = patchEventTarget(global, [obj], { - useGlobalCallback: false, - addEventListenerFnName: EE_ADD_LISTENER, - removeEventListenerFnName: EE_REMOVE_LISTENER, - prependEventListenerFnName: EE_PREPEND_LISTENER, - removeAllFnName: EE_REMOVE_ALL_LISTENER, - listenersFnName: EE_LISTENERS, - checkDuplicate: false, - returnTarget: true, - compareTaskCallbackVsDelegate: compareTaskCallbackVsDelegate + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; @@ -1992,7 +1985,7 @@ Zone.__load_patch('EventEmitter', function (global, Zone, api) { * 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.__load_patch('fs', function (global, Zone, api) { +Zone.__load_patch('fs', function () { var fs; try { fs = require('fs'); @@ -2015,7 +2008,7 @@ Zone.__load_patch('fs', function (global, Zone, api) { return { name: 'fs.' + name, args: args, - callbackIndex: args.length > 0 ? args.length - 1 : -1, + cbIdx: args.length > 0 ? args.length - 1 : -1, target: self }; }); @@ -2041,12 +2034,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { setName += nameSuffix; cancelName += nameSuffix; var tasksByHandleId = {}; - var NUMBER = 'number'; - var STRING = 'string'; - var FUNCTION = 'function'; - var INTERVAL = 'Interval'; - var TIMEOUT = 'Timeout'; - var NOT_SCHEDULED = 'notScheduled'; function scheduleTask(task) { var data = task.data; function timer() { @@ -2054,21 +2041,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task.invoke.apply(this, arguments); } finally { - if (task.data && task.data.isPeriodic) { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - return; - } - if (typeof data.handleId === NUMBER) { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } @@ -2081,21 +2067,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } setNative = patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === FUNCTION) { - var zone = Zone.current; + if (typeof args[0] === 'function') { var options = { handleId: null, - isPeriodic: nameSuffix === INTERVAL, - delay: (nameSuffix === TIMEOUT || nameSuffix === INTERVAL) ? args[1] || 0 : 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); + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === NUMBER) { + if (typeof handle === 'number') { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -2107,12 +2092,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === FUNCTION && - typeof handle.unref === FUNCTION) { + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { task.ref = handle.ref.bind(handle); task.unref = handle.unref.bind(handle); } - if (typeof handle === NUMBER || handle) { + if (typeof handle === 'number' || handle) { return handle; } return task; @@ -2126,7 +2111,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, cancelName, function (delegate) { return function (self, args) { var id = args[0]; var task; - if (typeof id === NUMBER) { + if (typeof id === 'number') { // non nodejs env. task = tasksByHandleId[id]; } @@ -2138,10 +2123,10 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task = id; } } - if (task && typeof task.type === STRING) { - if (task.state !== NOT_SCHEDULED && + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === NUMBER) { + if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { @@ -2170,9 +2155,9 @@ var clear = 'clear'; Zone.__load_patch('node_util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('node_timers', function (global, Zone, api) { +Zone.__load_patch('node_timers', function (global, Zone) { // Timers var globalUseTimeoutFromTimer = false; try { @@ -2198,7 +2183,7 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { patchTimer(timers, set, clear, 'Immediate'); } catch (error) { - // timers module not exists, for example, when we using nativescript + // timers module not exists, for example, when we using nativeScript // timers is not available } if (isMix) { @@ -2217,7 +2202,7 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { } else { // global use timers setTimeout, but not equals - // this happenes when use nodejs v0.10.x, global setTimeout will + // this happens when use nodejs v0.10.x, global setTimeout will // use a lazy load version of timers setTimeout // we should not double patch timer's setTimeout // so we only store the __symbol__ for consistency @@ -2227,13 +2212,13 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { } }); // patch process related methods -Zone.__load_patch('nextTick', function (global, Zone, api) { +Zone.__load_patch('nextTick', function () { // patch nextTick as microTask patchMicroTask(process, 'nextTick', function (self, args) { return { name: 'process.nextTick', args: args, - callbackIndex: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, target: process }; }); @@ -2261,7 +2246,7 @@ Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api } }); // Crypto -Zone.__load_patch('crypto', function (global, Zone, api) { +Zone.__load_patch('crypto', function () { var crypto; try { crypto = require('crypto'); @@ -2276,7 +2261,7 @@ Zone.__load_patch('crypto', function (global, Zone, api) { return { name: 'crypto.' + name, args: args, - callbackIndex: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? args.length - 1 : -1, target: crypto @@ -2285,13 +2270,13 @@ Zone.__load_patch('crypto', function (global, Zone, api) { }); } }); -Zone.__load_patch('console', function (global, Zone, api) { +Zone.__load_patch('console', function (global, Zone) { var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; consoleMethods.forEach(function (m) { var originalMethod = console[Zone.__symbol__(m)] = console[m]; if (originalMethod) { console[m] = function () { - var args = Array.prototype.slice.call(arguments); + var args = ArraySlice.call(arguments); if (Zone.current === Zone.root) { return originalMethod.apply(this, args); } diff --git a/dist/zone-patch-cordova.js b/dist/zone-patch-cordova.js index 1b0124c95..187f219f2 100644 --- a/dist/zone-patch-cordova.js +++ b/dist/zone-patch-cordova.js @@ -23,7 +23,7 @@ Zone.__load_patch('cordova', function (global, Zone, api) { var SUCCESS_SOURCE_1 = 'cordova.exec.success'; var ERROR_SOURCE_1 = 'cordova.exec.error'; var FUNCTION_1 = 'function'; - var nativeExec_1 = api.patchMethod(global.cordova, 'exec', function (delegate) { return function (self, args) { + var nativeExec_1 = api.patchMethod(global.cordova, 'exec', function () { return function (self, args) { if (args.length > 0 && typeof args[0] === FUNCTION_1) { args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE_1); } @@ -34,7 +34,7 @@ Zone.__load_patch('cordova', function (global, Zone, api) { }; }); } }); -Zone.__load_patch('cordova.FileReader', function (global, Zone, api) { +Zone.__load_patch('cordova.FileReader', function (global, Zone) { if (global.cordova && typeof global['FileReader'] !== 'undefined') { document.addEventListener('deviceReady', function () { var FileReader = global['FileReader']; diff --git a/dist/zone-patch-cordova.min.js b/dist/zone-patch-cordova.min.js index 60d1864aa..b30c6e97e 100644 --- a/dist/zone-patch-cordova.min.js +++ b/dist/zone-patch-cordova.min.js @@ -1 +1 @@ -!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("cordova",function(e,o,r){if(e.cordova)var t="cordova.exec.success",n="cordova.exec.error",a="function",c=r.patchMethod(e.cordova,"exec",function(e){return function(e,r){return r.length>0&&typeof r[0]===a&&(r[0]=o.current.wrap(r[0],t)),r.length>1&&typeof r[1]===a&&(r[1]=o.current.wrap(r[1],n)),c.apply(e,r)}})}),Zone.__load_patch("cordova.FileReader",function(e,o,r){e.cordova&&"undefined"!=typeof e.FileReader&&document.addEventListener("deviceReady",function(){var r=e.FileReader;["abort","error","load","loadstart","loadend","progress"].forEach(function(e){var t=o.__symbol__("ON_PROPERTY"+e);Object.defineProperty(r.prototype,t,{configurable:!0,get:function(){return this._realReader&&this._realReader[t]}})})})})}); \ No newline at end of file +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("cordova",function(e,o,r){if(e.cordova)var t="cordova.exec.success",n="cordova.exec.error",a="function",c=r.patchMethod(e.cordova,"exec",function(){return function(e,r){return r.length>0&&typeof r[0]===a&&(r[0]=o.current.wrap(r[0],t)),r.length>1&&typeof r[1]===a&&(r[1]=o.current.wrap(r[1],n)),c.apply(e,r)}})}),Zone.__load_patch("cordova.FileReader",function(e,o){e.cordova&&"undefined"!=typeof e.FileReader&&document.addEventListener("deviceReady",function(){var r=e.FileReader;["abort","error","load","loadstart","loadend","progress"].forEach(function(e){var t=o.__symbol__("ON_PROPERTY"+e);Object.defineProperty(r.prototype,t,{configurable:!0,get:function(){return this._realReader&&this._realReader[t]}})})})})}); \ No newline at end of file diff --git a/dist/zone-patch-electron.js b/dist/zone-patch-electron.js index 3ce0cd651..2efb290cd 100644 --- a/dist/zone-patch-electron.js +++ b/dist/zone-patch-electron.js @@ -19,22 +19,26 @@ * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('electron', function (global, Zone, api) { - var FUNCTION = 'function'; - var _a = require('electron'), desktopCapturer = _a.desktopCapturer, shell = _a.shell, CallbackRegistry = _a.CallbackRegistry; + function patchArguments(target, name, source) { + return api.patchMethod(target, name, function (delegate) { return function (self, args) { + return delegate && delegate.apply(self, api.bindArguments(args, source)); + }; }); + } + var _a = require('electron'), desktopCapturer = _a.desktopCapturer, shell = _a.shell, CallbacksRegistry = _a.CallbacksRegistry; // patch api in renderer process directly // desktopCapturer if (desktopCapturer) { - api.patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources'); + patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources'); } // shell if (shell) { - api.patchArguments(shell, 'openExternal', 'electron.shell.openExternal'); + patchArguments(shell, 'openExternal', 'electron.shell.openExternal'); } // patch api in main process through CallbackRegistry - if (!CallbackRegistry) { + if (!CallbacksRegistry) { return; } - api.patchArguments(CallbackRegistry.prototype, 'add', 'CallbackRegistry.add'); + patchArguments(CallbacksRegistry.prototype, 'add', 'CallbackRegistry.add'); }); }))); diff --git a/dist/zone-patch-electron.min.js b/dist/zone-patch-electron.min.js index 038dac7c4..0c049edac 100644 --- a/dist/zone-patch-electron.min.js +++ b/dist/zone-patch-electron.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("electron",function(e,t,n){var o=require("electron"),r=o.desktopCapturer,c=o.shell,a=o.CallbackRegistry;r&&n.patchArguments(r,"getSources","electron.desktopCapturer.getSources"),c&&n.patchArguments(c,"openExternal","electron.shell.openExternal"),a&&n.patchArguments(a.prototype,"add","CallbackRegistry.add")})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("electron",function(e,t,n){function o(e,t,o){return n.patchMethod(e,t,function(e){return function(t,r){return e&&e.apply(t,n.bindArguments(r,o))}})}var r=require("electron"),c=r.desktopCapturer,u=r.shell,i=r.CallbacksRegistry;c&&o(c,"getSources","electron.desktopCapturer.getSources"),u&&o(u,"openExternal","electron.shell.openExternal"),i&&o(i.prototype,"add","CallbackRegistry.add")})}); \ No newline at end of file diff --git a/dist/zone-patch-rxjs.js b/dist/zone-patch-rxjs.js index db7bd8d88..85cd93b22 100644 --- a/dist/zone-patch-rxjs.js +++ b/dist/zone-patch-rxjs.js @@ -18,14 +18,12 @@ * 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.__load_patch('rxjs', function (global, Zone, api) { +Zone.__load_patch('rxjs', function (global, Zone) { var symbol = Zone.__symbol__; - var subscribeSource = 'rxjs.subscribe'; var nextSource = 'rxjs.Subscriber.next'; var errorSource = 'rxjs.Subscriber.error'; var completeSource = 'rxjs.Subscriber.complete'; - var unsubscribeSource = 'rxjs.Subscriber.unsubscribe'; - var teardownSource = 'rxjs.Subscriber.teardownLogic'; + var ObjectDefineProperties = Object.defineProperties; var empty = { closed: true, next: function (value) { }, @@ -52,7 +50,7 @@ Zone.__load_patch('rxjs', function (global, Zone, api) { var _symbolSubscribe = symbol('_subscribe'); var _subscribe = ObservablePrototype[_symbolSubscribe] = ObservablePrototype._subscribe; var subscribe = ObservablePrototype[symbolSubscribe] = ObservablePrototype.subscribe; - Object.defineProperties(rxjs_Observable.Observable.prototype, { + ObjectDefineProperties(rxjs_Observable.Observable.prototype, { _zone: { value: null, writable: true, configurable: true }, _zoneSource: { value: null, writable: true, configurable: true }, _zoneSubscribe: { value: null, writable: true, configurable: true }, @@ -103,7 +101,7 @@ Zone.__load_patch('rxjs', function (global, Zone, api) { var unsubscribeSymbol = symbol('unsubscribe'); var unsubscribe = rxjs_Subscription.Subscription.prototype[unsubscribeSymbol] = rxjs_Subscription.Subscription.prototype.unsubscribe; - Object.defineProperties(rxjs_Subscription.Subscription.prototype, { + ObjectDefineProperties(rxjs_Subscription.Subscription.prototype, { _zone: { value: null, writable: true, configurable: true }, _zoneUnsubscribe: { value: null, writable: true, configurable: true }, _unsubscribe: { @@ -305,7 +303,6 @@ Zone.__load_patch('rxjs', function (global, Zone, api) { return; } var scheduleSymbol = symbol('scheduleSymbol'); - var flushSymbol = symbol('flushSymbol'); var zoneSymbol = symbol('zone'); if (asap$$1[scheduleSymbol]) { return; @@ -328,7 +325,7 @@ Zone.__load_patch('rxjs', function (global, Zone, api) { return work.apply(this, arguments); } }; - return schedule.apply(this, [patchedWork, delay, state]); + return schedule.call(this, patchedWork, delay, state); }; }; patchObservable(); diff --git a/dist/zone-patch-rxjs.min.js b/dist/zone-patch-rxjs.min.js index cd33f203f..8a509ada3 100644 --- a/dist/zone-patch-rxjs.min.js +++ b/dist/zone-patch-rxjs.min.js @@ -1 +1 @@ -!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("rxjs/add/observable/bindCallback"),require("rxjs/add/observable/bindNodeCallback"),require("rxjs/add/observable/defer"),require("rxjs/add/observable/forkJoin"),require("rxjs/add/observable/fromEventPattern"),require("rxjs/add/operator/multicast"),require("rxjs/Observable"),require("rxjs/scheduler/asap"),require("rxjs/Subscriber"),require("rxjs/Subscription"),require("rxjs/symbol/rxSubscriber")):"function"==typeof define&&define.amd?define(["rxjs/add/observable/bindCallback","rxjs/add/observable/bindNodeCallback","rxjs/add/observable/defer","rxjs/add/observable/forkJoin","rxjs/add/observable/fromEventPattern","rxjs/add/operator/multicast","rxjs/Observable","rxjs/scheduler/asap","rxjs/Subscriber","rxjs/Subscription","rxjs/symbol/rxSubscriber"],e):e(null,null,null,null,null,null,r.Rx,r.Rx.Scheduler,r.Rx,r.Rx,r.Rx.Symbol)}(this,function(r,e,t,n,i,u,o,s,b,c,a){"use strict";Zone.__load_patch("rxjs",function(r,e,t){function n(r,e,t){if(r){if(r instanceof b.Subscriber)return r;if(r[a.rxSubscriber])return r[a.rxSubscriber]()}return r||e||t?new b.Subscriber(r,e,t):new b.Subscriber(p)}var i=e.__symbol__,u="rxjs.Subscriber.next",l="rxjs.Subscriber.error",f="rxjs.Subscriber.complete",p={closed:!0,next:function(r){},error:function(r){throw r},complete:function(){}},v=function(){var r=o.Observable.prototype,t=i("subscribe"),u=i("_subscribe"),s=r[u]=r._subscribe,b=r[t]=r.subscribe;Object.defineProperties(o.Observable.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneSource:{value:null,writable:!0,configurable:!0},_zoneSubscribe:{value:null,writable:!0,configurable:!0},source:{configurable:!0,get:function(){return this._zoneSource},set:function(r){this._zone=e.current,this._zoneSource=r}},_subscribe:{configurable:!0,get:function(){if(this._zoneSubscribe)return this._zoneSubscribe;if(this.constructor===o.Observable)return s;var r=Object.getPrototypeOf(this);return r&&r._subscribe},set:function(r){this._zone=e.current,this._zoneSubscribe=r}},subscribe:{writable:!0,configurable:!0,value:function(r,t,i){var u=this._zone;return u&&u!==e.current?u.run(b,this,[n(r,t,i)]):b.call(this,r,t,i)}}})},d=function(){var r=i("unsubscribe"),t=c.Subscription.prototype[r]=c.Subscription.prototype.unsubscribe;Object.defineProperties(c.Subscription.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneUnsubscribe:{value:null,writable:!0,configurable:!0},_unsubscribe:{get:function(){if(this._zoneUnsubscribe)return this._zoneUnsubscribe;var r=Object.getPrototypeOf(this);return r&&r._unsubscribe},set:function(r){this._zone=e.current,this._zoneUnsubscribe=r}},unsubscribe:{writable:!0,configurable:!0,value:function(){var r=this._zone;r&&r!==e.current?r.run(t,this):t.apply(this)}}})},h=function(){var r=b.Subscriber.prototype.next,t=b.Subscriber.prototype.error,n=b.Subscriber.prototype.complete;Object.defineProperty(b.Subscriber.prototype,"destination",{configurable:!0,get:function(){return this._zoneDestination},set:function(r){this._zone=e.current,this._zoneDestination=r}}),b.Subscriber.prototype.next=function(){var t=e.current,n=this._zone;return n&&n!==t?n.run(r,this,arguments,u):r.apply(this,arguments)},b.Subscriber.prototype.error=function(){var r=e.current,n=this._zone;return n&&n!==r?n.run(t,this,arguments,l):t.apply(this,arguments)},b.Subscriber.prototype.complete=function(){var r=e.current,t=this._zone;return t&&t!==r?t.run(n,this,arguments,f):n.apply(this,arguments)}},y=function(r){r._zone=e.current},x=function(r,e){var t=i(e);if(!r[t]){var n=r[t]=r[e];n&&(r[e]=function(){var r=n.apply(this,arguments);return function(){var e=r.apply(this,arguments);return y(e),e}})}},_=function(r,e){var t=i(e);if(!r[t]){var n=r[t]=r[e];n&&(r[e]=function(){var r=n.apply(this,arguments);return y(r),r})}},S=function(r,t){var n=i(t);if(!r[n]){var u=r[n]=r[t];u&&(r[t]=function(){for(var r=e.current,t=Array.prototype.slice.call(arguments),n=function(n){var i=t[n];"function"==typeof i&&(t[n]=function(){var t=Array.prototype.slice.call(arguments),n=e.current;return r&&n&&r!==n?r.run(i,this,t):i.apply(this,t)})},i=0;i0?t[0]:void 0;if("function"!=typeof n){var i=n;n=function(){return i}}t[0]=function(){var t;return t=r&&r!==e.current?r.run(n,this,arguments):n.apply(this,arguments),t&&r&&(t._zone=r),t};var o=u.apply(this,t);return y(o),o})}},z=function(r){if(r){var t=i("scheduleSymbol"),n=(i("flushSymbol"),i("zone"));if(!r[t]){var u=r[t]=r.schedule;r.schedule=function(){var r=Array.prototype.slice.call(arguments),t=r.length>0?r[0]:void 0,i=r.length>1?r[1]:0,o=(r.length>2?r[2]:void 0)||{};o[n]=e.current;var s=function(){var r=Array.prototype.slice.call(arguments),i=r.length>0?r[0]:void 0,u=i&&i[n];return u&&u!==e.current?u.runGuarded(t,this,arguments):t.apply(this,arguments)};return u.apply(this,[s,i,o])}}}};v(),d(),h(),x(o.Observable,"bindCallback"),x(o.Observable,"bindNodeCallback"),_(o.Observable,"defer"),_(o.Observable,"forkJoin"),S(o.Observable,"fromEventPattern"),j(),z(s.asap)})}); \ No newline at end of file +!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("rxjs/add/observable/bindCallback"),require("rxjs/add/observable/bindNodeCallback"),require("rxjs/add/observable/defer"),require("rxjs/add/observable/forkJoin"),require("rxjs/add/observable/fromEventPattern"),require("rxjs/add/operator/multicast"),require("rxjs/Observable"),require("rxjs/scheduler/asap"),require("rxjs/Subscriber"),require("rxjs/Subscription"),require("rxjs/symbol/rxSubscriber")):"function"==typeof define&&define.amd?define(["rxjs/add/observable/bindCallback","rxjs/add/observable/bindNodeCallback","rxjs/add/observable/defer","rxjs/add/observable/forkJoin","rxjs/add/observable/fromEventPattern","rxjs/add/operator/multicast","rxjs/Observable","rxjs/scheduler/asap","rxjs/Subscriber","rxjs/Subscription","rxjs/symbol/rxSubscriber"],e):e(null,null,null,null,null,null,r.Rx,r.Rx.Scheduler,r.Rx,r.Rx,r.Rx.Symbol)}(this,function(r,e,t,n,i,u,o,s,b,c,a){"use strict";Zone.__load_patch("rxjs",function(r,e){function t(r,e,t){if(r){if(r instanceof b.Subscriber)return r;if(r[a.rxSubscriber])return r[a.rxSubscriber]()}return r||e||t?new b.Subscriber(r,e,t):new b.Subscriber(p)}var n=e.__symbol__,i="rxjs.Subscriber.next",u="rxjs.Subscriber.error",l="rxjs.Subscriber.complete",f=Object.defineProperties,p={closed:!0,next:function(r){},error:function(r){throw r},complete:function(){}},v=function(){var r=o.Observable.prototype,i=n("subscribe"),u=n("_subscribe"),s=r[u]=r._subscribe,b=r[i]=r.subscribe;f(o.Observable.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneSource:{value:null,writable:!0,configurable:!0},_zoneSubscribe:{value:null,writable:!0,configurable:!0},source:{configurable:!0,get:function(){return this._zoneSource},set:function(r){this._zone=e.current,this._zoneSource=r}},_subscribe:{configurable:!0,get:function(){if(this._zoneSubscribe)return this._zoneSubscribe;if(this.constructor===o.Observable)return s;var r=Object.getPrototypeOf(this);return r&&r._subscribe},set:function(r){this._zone=e.current,this._zoneSubscribe=r}},subscribe:{writable:!0,configurable:!0,value:function(r,n,i){var u=this._zone;return u&&u!==e.current?u.run(b,this,[t(r,n,i)]):b.call(this,r,n,i)}}})},d=function(){var r=n("unsubscribe"),t=c.Subscription.prototype[r]=c.Subscription.prototype.unsubscribe;f(c.Subscription.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneUnsubscribe:{value:null,writable:!0,configurable:!0},_unsubscribe:{get:function(){if(this._zoneUnsubscribe)return this._zoneUnsubscribe;var r=Object.getPrototypeOf(this);return r&&r._unsubscribe},set:function(r){this._zone=e.current,this._zoneUnsubscribe=r}},unsubscribe:{writable:!0,configurable:!0,value:function(){var r=this._zone;r&&r!==e.current?r.run(t,this):t.apply(this)}}})},h=function(){var r=b.Subscriber.prototype.next,t=b.Subscriber.prototype.error,n=b.Subscriber.prototype.complete;Object.defineProperty(b.Subscriber.prototype,"destination",{configurable:!0,get:function(){return this._zoneDestination},set:function(r){this._zone=e.current,this._zoneDestination=r}}),b.Subscriber.prototype.next=function(){var t=e.current,n=this._zone;return n&&n!==t?n.run(r,this,arguments,i):r.apply(this,arguments)},b.Subscriber.prototype.error=function(){var r=e.current,n=this._zone;return n&&n!==r?n.run(t,this,arguments,u):t.apply(this,arguments)},b.Subscriber.prototype.complete=function(){var r=e.current,t=this._zone;return t&&t!==r?t.run(n,this,arguments,l):n.apply(this,arguments)}},y=function(r){r._zone=e.current},x=function(r,e){var t=n(e);if(!r[t]){var i=r[t]=r[e];i&&(r[e]=function(){var r=i.apply(this,arguments);return function(){var e=r.apply(this,arguments);return y(e),e}})}},_=function(r,e){var t=n(e);if(!r[t]){var i=r[t]=r[e];i&&(r[e]=function(){var r=i.apply(this,arguments);return y(r),r})}},S=function(r,t){var i=n(t);if(!r[i]){var u=r[i]=r[t];u&&(r[t]=function(){for(var r=e.current,t=Array.prototype.slice.call(arguments),n=function(n){var i=t[n];"function"==typeof i&&(t[n]=function(){var t=Array.prototype.slice.call(arguments),n=e.current;return r&&n&&r!==n?r.run(i,this,t):i.apply(this,t)})},i=0;i0?t[0]:void 0;if("function"!=typeof n){var i=n;n=function(){return i}}t[0]=function(){var t;return t=r&&r!==e.current?r.run(n,this,arguments):n.apply(this,arguments),t&&r&&(t._zone=r),t};var o=u.apply(this,t);return y(o),o})}},z=function(r){if(r){var t=n("scheduleSymbol"),i=n("zone");if(!r[t]){var u=r[t]=r.schedule;r.schedule=function(){var r=Array.prototype.slice.call(arguments),t=r.length>0?r[0]:void 0,n=r.length>1?r[1]:0,o=(r.length>2?r[2]:void 0)||{};o[i]=e.current;var s=function(){var r=Array.prototype.slice.call(arguments),n=r.length>0?r[0]:void 0,u=n&&n[i];return u&&u!==e.current?u.runGuarded(t,this,arguments):t.apply(this,arguments)};return u.call(this,s,n,o)}}}};v(),d(),h(),x(o.Observable,"bindCallback"),x(o.Observable,"bindNodeCallback"),_(o.Observable,"defer"),_(o.Observable,"forkJoin"),S(o.Observable,"fromEventPattern"),j(),z(s.asap)})}); \ No newline at end of file diff --git a/dist/zone-patch-user-media.js b/dist/zone-patch-user-media.js new file mode 100644 index 000000000..8a3c28a58 --- /dev/null +++ b/dist/zone-patch-user-media.js @@ -0,0 +1,35 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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.__load_patch('getUserMedia', function (global, Zone, api) { + function wrapFunctionArgs(func, source) { + return function () { + var args = Array.prototype.slice.call(arguments); + var wrappedArgs = api.bindArguments(args, source ? source : func.name); + return func.apply(this, wrappedArgs); + }; + } + var navigator = global['navigator']; + if (navigator && navigator.getUserMedia) { + navigator.getUserMedia = wrapFunctionArgs(navigator.getUserMedia); + } +}); + +}))); diff --git a/dist/zone-patch-user-media.min.js b/dist/zone-patch-user-media.min.js new file mode 100644 index 000000000..8c56fe372 --- /dev/null +++ b/dist/zone-patch-user-media.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("getUserMedia",function(e,t,n){function i(e,t){return function(){var i=Array.prototype.slice.call(arguments),o=n.bindArguments(i,t?t:e.name);return e.apply(this,o)}}var o=e.navigator;o&&o.getUserMedia&&(o.getUserMedia=i(o.getUserMedia))})}); \ No newline at end of file diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index 8b3c79f9a..7d6eed199 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -476,12 +476,13 @@ var Zone$1 = (function (global) { this.cancelFn = cancelFn; this.callback = callback; var self = this; - if (type === eventTask && options && options.isUsingGlobalCallback) { + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { this.invoke = ZoneTask.invokeTask; } else { this.invoke = function () { - return ZoneTask.invokeTask.apply(global, [self, this, arguments]); + return ZoneTask.invokeTask.call(global, self, this, arguments); }; } } @@ -598,7 +599,6 @@ var Zone$1 = (function (global) { } } } - var showError = !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; _api.microtaskDrainDone(); _isDrainingMicrotaskQueue = false; } @@ -622,7 +622,7 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - patchArguments: function () { return noop; }, + bindArguments: function () { return null; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -661,6 +661,8 @@ var __values = (undefined && undefined.__values) || function (o) { * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; function readableObjectToString(obj) { if (obj && obj.toString === Object.prototype.toString) { var className = obj.constructor && obj.constructor.name; @@ -708,7 +710,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { try { var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; if (handler && typeof handler === 'function') { - handler.apply(this, [e]); + handler.call(this, e); } } catch (err) { @@ -754,8 +756,6 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; }; var TYPE_ERROR = 'Promise resolved with itself'; - var OBJECT = 'object'; - var FUNCTION = 'function'; var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution function resolvePromise(promise, state, value) { @@ -767,7 +767,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // should only get value.then once based on promise spec. var then = null; try { - if (typeof value === OBJECT || typeof value === FUNCTION) { + if (typeof value === 'object' || typeof value === 'function') { then = value && value.then; } } @@ -784,11 +784,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { clearRejectedNoCatch(value); resolvePromise(promise, value[symbolState], value[symbolValue]); } - else if (state !== REJECTED && typeof then === FUNCTION) { + else if (state !== REJECTED && typeof then === 'function') { try { - then.apply(value, [ - onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)) - ]); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { onceWrapper(function () { @@ -808,7 +806,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Zone.currentTask.data[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone - Object.defineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); } } for (var i = 0; i < queue.length;) { @@ -846,8 +844,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // eventHandler try { var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === FUNCTION) { - handler.apply(this, [{ rejection: promise[symbolValue], promise: promise }]); + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); } } catch (err) { @@ -863,8 +861,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { clearRejectedNoCatch(promise); var delegate = promise[symbolState] ? - (typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution : - (typeof onRejected === FUNCTION) ? onRejected : forwardRejection; + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, function () { try { resolvePromise(chainPromise, true, zone.run(delegate, undefined, [promise[symbolValue]])); @@ -992,7 +990,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { ZoneAwarePromise['all'] = ZoneAwarePromise.all; var NativePromise = global[symbolPromise] = global['Promise']; var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = Object.getOwnPropertyDescriptor(global, 'Promise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; desc && delete desc.value; @@ -1025,7 +1023,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { api.setNativePromise(NewNativePromise); } }; - Object.defineProperty(global, 'Promise', desc); + ObjectDefineProperty(global, 'Promise', desc); } global['Promise'] = ZoneAwarePromise; var symbolThenPatched = __symbol__('thenPatched'); @@ -1034,11 +1032,11 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescritor is writable or not + // check Ctor.prototype.then propertyDescriptor is writable or not // in meteor env, writable is false, we have to make it to be true. - var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then'); + var prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { - Object.defineProperty(Ctor.prototype, 'then', { writable: true }); + ObjectDefineProperty(Ctor.prototype, 'then', { writable: true }); } Ctor.prototype.then = function (onResolve, onReject) { var _this = this; @@ -1065,7 +1063,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { if (NativePromise) { patchThen(NativePromise); var fetch_1 = global['fetch']; - if (typeof fetch_1 == FUNCTION) { + if (typeof fetch_1 == 'function') { global['fetch'] = zoneify(fetch_1); } } @@ -1086,39 +1084,64 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { * @fileoverview * @suppress {undefinedVars,globalThis,missingRequire} */ +// issue #989, to reduce bundle size, use short name +/** Object.getOwnPropertyDescriptor */ +/** + * @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 ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ +var ObjectDefineProperty = Object.defineProperty; +/** Object.getPrototypeOf */ +var ObjectGetPrototypeOf = Object.getPrototypeOf; +/** Object.create */ +var ObjectCreate = Object.create; +/** Array.prototype.slice */ +var ArraySlice = Array.prototype.slice; +/** addEventListener string const */ +var ADD_EVENT_LISTENER_STR = 'addEventListener'; +/** removeEventListener string const */ +var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; +/** zoneSymbol addEventListener */ +var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); +/** zoneSymbol removeEventListener */ +var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); +/** true string const */ +var TRUE_STR = 'true'; +/** false string const */ +var FALSE_STR = 'false'; +/** __zone_symbol__ string const */ +var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); +} +function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} var zoneSymbol = Zone.__symbol__; -var _global = typeof window === 'object' && window || typeof self === 'object' && self || global; -var FUNCTION = 'function'; -var UNDEFINED = 'undefined'; +var isWindowExists = typeof window !== 'undefined'; +var internalWindow = isWindowExists ? window : undefined; +var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; var REMOVE_ATTRIBUTE = 'removeAttribute'; var NULL_ON_PROP_VALUE = [null]; function bindArguments(args, source) { for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === FUNCTION) { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); } } return args; } -function wrapFunctionArgs(func, source) { - return function () { - var args = Array.prototype.slice.call(arguments); - var wrappedArgs = bindArguments(args, source ? source : func.name); - return func.apply(this, wrappedArgs); - }; -} -function patchArguments(target, name, source) { - return patchMethod(target, name, function (delegate, delegateName, name) { return function (self, args) { - return delegate && delegate.apply(self, bindArguments(args, source)); - }; }); -} function patchPrototype(prototype, fnNames) { var source = prototype.constructor['name']; var _loop_1 = function (i) { var name_1 = fnNames[i]; var delegate = prototype[name_1]; if (delegate) { - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, name_1); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); if (!isPropertyWritable(prototypeDesc)) { return "continue"; } @@ -1142,23 +1165,20 @@ function isPropertyWritable(propertyDesc) { if (propertyDesc.writable === false) { return false; } - if (typeof propertyDesc.get === FUNCTION && typeof propertyDesc.set === UNDEFINED) { - return false; - } - return true; + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(typeof window !== 'undefined' && window['HTMLElement']); +var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== 'undefined' && window['HTMLElement']); + !!(isWindowExists && internalWindow['HTMLElement']); var zoneSymbolEventNames = {}; var wrapFn = function (event) { // https://github.com/angular/zone.js/issues/911, in IE, sometimes @@ -1180,10 +1200,10 @@ var wrapFn = function (event) { return result; }; function patchProperty(obj, prop, prototype) { - var desc = Object.getOwnPropertyDescriptor(obj, prop); + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); if (prototypeDesc) { desc = { enumerable: true, configurable: true }; } @@ -1258,10 +1278,10 @@ function patchProperty(obj, prop, prototype) { // the onclick will be evaluated when first time event was triggered or // the property is accessed, https://github.com/angular/zone.js/issues/525 // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.apply(this); + var value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === FUNCTION) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } return value; @@ -1269,7 +1289,7 @@ function patchProperty(obj, prop, prototype) { } return null; }; - Object.defineProperty(obj, prop, desc); + ObjectDefineProperty(obj, prop, desc); } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1334,10 +1354,10 @@ function patchClass(className) { }; } else { - Object.defineProperty(_global[className].prototype, prop, { + ObjectDefineProperty(_global[className].prototype, prop, { set: function (fn) { if (typeof fn === 'function') { - this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); // keep callback in wrapped function so we can // use it in Function.prototype.toString to return // the native one. @@ -1363,7 +1383,7 @@ function patchClass(className) { function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1375,7 +1395,7 @@ function patchMethod(target, name, patchFn) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && Object.getOwnPropertyDescriptor(proto, name); + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { var patchDelegate_1 = patchFn(delegate, delegateName, name); proto[name] = function () { @@ -1391,7 +1411,7 @@ function patchMacroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1399,9 +1419,8 @@ function patchMacroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMacroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask, null); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. @@ -1421,8 +1440,7 @@ function isIEOrEdge() { } isDetectedIEOrEdge = true; try { - var ua = window.navigator.userAgent; - var msie = ua.indexOf('MSIE '); + var ua = internalWindow.navigator.userAgent; if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } @@ -1441,19 +1459,18 @@ function isIEOrEdge() { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone, api) { +Zone.__load_patch('toString', function (global, Zone) { // patch Func.prototype.toString to let them look like native var originalFunctionToString = Zone['__zone_symbol__originalToString'] = Function.prototype.toString; - var FUNCTION = 'function'; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function () { - if (typeof this === FUNCTION) { + if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === FUNCTION) { + if (typeof originalDelegate === 'function') { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { @@ -1497,25 +1514,19 @@ Zone.__load_patch('toString', function (global, Zone, api) { * @fileoverview * @suppress {missingRequire} */ -var TRUE_STR = 'true'; -var FALSE_STR = 'false'; // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - isUsingGlobalCallback: true + useG: true }; var zoneSymbolEventNames$1 = {}; var globalSources = {}; -var CONSTRUCTOR_NAME = 'name'; -var FUNCTION_TYPE = 'function'; -var OBJECT_TYPE = 'object'; -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.addEventListenerFnName) || 'addEventListener'; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.removeEventListenerFnName) || 'removeEventListener'; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listenersFnName) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.removeAllFnName) || 'removeAllListeners'; + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; @@ -1527,7 +1538,7 @@ function patchEventTarget(_global, apis, patchOptions) { return; } var delegate = task.callback; - if (typeof delegate === OBJECT_TYPE && delegate.handleEvent) { + if (typeof delegate === 'object' && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = function (event) { return delegate.handleEvent(event); }; task.originalDelegate = delegate; @@ -1540,7 +1551,7 @@ function patchEventTarget(_global, apis, patchOptions) { // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].apply(target, [event.type, delegate_1, options]); + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } }; // global shared zoneAwareCallback to handle all event callback with capture = false @@ -1551,7 +1562,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; @@ -1583,7 +1594,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; @@ -1612,21 +1623,21 @@ function patchEventTarget(_global, apis, patchOptions) { return false; } var useGlobalCallback = true; - if (patchOptions && patchOptions.useGlobalCallback !== undefined) { - useGlobalCallback = patchOptions.useGlobalCallback; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; } - var validateHandler = patchOptions && patchOptions.validateHandler; + var validateHandler = patchOptions && patchOptions.vh; var checkDuplicate = true; - if (patchOptions && patchOptions.checkDuplicate !== undefined) { - checkDuplicate = patchOptions.checkDuplicate; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; } var returnTarget = false; - if (patchOptions && patchOptions.returnTarget !== undefined) { - returnTarget = patchOptions.returnTarget; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; } var proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1649,21 +1660,17 @@ function patchEventTarget(_global, apis, patchOptions) { var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; var nativePrependEventListener; - if (patchOptions && patchOptions.prependEventListenerFnName) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prependEventListenerFnName)] = - proto[patchOptions.prependEventListenerFnName]; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; } - var customScheduleGlobal = function (task) { + var customScheduleGlobal = function () { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } - return nativeAddEventListener.apply(taskData.target, [ - taskData.eventName, - taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - taskData.options - ]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { // if task is not marked as isRemoved, this call is directly @@ -1700,41 +1707,31 @@ function patchEventTarget(_global, apis, patchOptions) { if (!task.allRemoved) { return; } - return nativeRemoveEventListener.apply(task.target, [ - task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - task.options - ]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { - return nativeAddEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { - return nativePrependEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.apply(task.target, [task.eventName, task.invoke, task.options]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); }; var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; var compareTaskCallbackVsDelegate = function (task, delegate) { var typeOfDelegate = typeof delegate; - if ((typeOfDelegate === FUNCTION_TYPE && task.callback === delegate) || - (typeOfDelegate === OBJECT_TYPE && task.originalDelegate === delegate)) { - // same callback, same capture, same event name, just return - return true; - } - return false; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.compareTaskCallbackVsDelegate) ? - patchOptions.compareTaskCallbackVsDelegate : - compareTaskCallbackVsDelegate; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { if (returnTarget === void 0) { returnTarget = false; } if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; - var targetZone = Zone.current; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); @@ -1743,7 +1740,7 @@ function patchEventTarget(_global, apis, patchOptions) { // case here to improve addEventListener performance // we will create the bind delegate when invoke var isHandleEvent = false; - if (typeof delegate !== FUNCTION_TYPE) { + if (typeof delegate !== 'function') { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -1812,7 +1809,7 @@ function patchEventTarget(_global, apis, patchOptions) { existingTasks = target[symbolEventName] = []; } var source; - var constructorName = target.constructor[CONSTRUCTOR_NAME]; + var constructorName = target.constructor['name']; var targetSource = globalSources[constructorName]; if (targetSource) { source = targetSource[eventName]; @@ -1834,7 +1831,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.eventName = eventName; taskData.isExisting = isExisting; var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; - // keep taskData into data to allow onScheduleEventTask to acess the task information + // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; } @@ -1908,7 +1905,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (existingTasks) { for (var i = 0; i < existingTasks.length; i++) { var existingTask = existingTasks[i]; - var typeOfDelegate = typeof delegate; if (compare(existingTask, delegate)) { existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check @@ -1956,11 +1952,11 @@ function patchEventTarget(_global, apis, patchOptions) { // so just keep removeListener eventListener until // all other eventListeners are removed if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, [evtName]); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } } // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { var symbolEventNames = zoneSymbolEventNames$1[eventName]; @@ -1974,7 +1970,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } if (captureTasks) { @@ -1982,7 +1978,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } } @@ -2052,12 +2048,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { setName += nameSuffix; cancelName += nameSuffix; var tasksByHandleId = {}; - var NUMBER = 'number'; - var STRING = 'string'; - var FUNCTION = 'function'; - var INTERVAL = 'Interval'; - var TIMEOUT = 'Timeout'; - var NOT_SCHEDULED = 'notScheduled'; function scheduleTask(task) { var data = task.data; function timer() { @@ -2065,21 +2055,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task.invoke.apply(this, arguments); } finally { - if (task.data && task.data.isPeriodic) { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - return; - } - if (typeof data.handleId === NUMBER) { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } @@ -2092,21 +2081,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } setNative = patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === FUNCTION) { - var zone = Zone.current; + if (typeof args[0] === 'function') { var options = { handleId: null, - isPeriodic: nameSuffix === INTERVAL, - delay: (nameSuffix === TIMEOUT || nameSuffix === INTERVAL) ? args[1] || 0 : 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); + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === NUMBER) { + if (typeof handle === 'number') { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -2118,12 +2106,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === FUNCTION && - typeof handle.unref === FUNCTION) { + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { task.ref = handle.ref.bind(handle); task.unref = handle.unref.bind(handle); } - if (typeof handle === NUMBER || handle) { + if (typeof handle === 'number' || handle) { return handle; } return task; @@ -2137,7 +2125,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, cancelName, function (delegate) { return function (self, args) { var id = args[0]; var task; - if (typeof id === NUMBER) { + if (typeof id === 'number') { // non nodejs env. task = tasksByHandleId[id]; } @@ -2149,10 +2137,10 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task = id; } } - if (task && typeof task.type === STRING) { - if (task.state !== NOT_SCHEDULED && + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === NUMBER) { + if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { @@ -2185,16 +2173,13 @@ var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; var _create = Object.create; var unconfigurablesKey = zoneSymbol('unconfigurables'); -var PROTOTYPE = 'prototype'; -var OBJECT = 'object'; -var UNDEFINED$1 = 'undefined'; function propertyPatch() { Object.defineProperty = function (obj, prop, desc) { if (isUnconfigurable(obj, prop)) { throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); } var originalConfigurableFlag = desc.configurable; - if (prop !== PROTOTYPE) { + if (prop !== 'prototype') { desc = rewriteDescriptor(obj, prop, desc); } return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); @@ -2206,7 +2191,7 @@ function propertyPatch() { return obj; }; Object.create = function (obj, proto) { - if (typeof proto === OBJECT && !Object.isFrozen(proto)) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { Object.keys(proto).forEach(function (prop) { proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); }); @@ -2253,7 +2238,7 @@ function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { if (desc.configurable) { // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's // retry with the original flag value - if (typeof originalConfigurableFlag == UNDEFINED$1) { + if (typeof originalConfigurableFlag == 'undefined') { delete desc.configurable; } else { @@ -2294,22 +2279,22 @@ function apply(api, _global) { if (!_global.EventTarget) { patchEventTarget(_global, [WS.prototype]); } - _global.WebSocket = function (a, b) { - var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); var proxySocket; var proxySocketProto; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); + var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = Object.create(socket); + proxySocket = ObjectCreate(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method proxySocketProto = socket; - ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function (propName) { + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { proxySocket[propName] = function () { - var args = Array.prototype.slice.call(arguments); - if (propName === 'addEventListener' || propName === 'removeEventListener') { + var args = ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { var eventName = args.length > 0 ? args[0] : undefined; if (eventName) { var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); @@ -2581,12 +2566,13 @@ function propertyDescriptorPatch(api, _global) { var ignoreProperties = _global.__Zone_ignore_on_properties; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { + var internalWindow = window; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(window, eventNames.concat(['messageerror']), ignoreProperties, Object.getPrototypeOf(window)); + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof window['SVGElement'] !== 'undefined') { - patchFilteredProperties(window['SVGElement'].prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); } patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); @@ -2595,11 +2581,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = window['HTMLMarqueeElement']; + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; if (HTMLMarqueeElement_1) { patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); } - var Worker_1 = window['Worker']; + var Worker_1 = internalWindow['Worker']; if (Worker_1) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } @@ -2631,15 +2617,17 @@ function propertyDescriptorPatch(api, _global) { } } function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') { // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 // IDL interface attributes are not configurable - var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); + var desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; } - var xhrDesc = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'onreadystatechange'); + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera // by default XMLHttpRequest.prototype.onreadystatechange is undefined // without adding enumerable and configurable will cause onreadystatechange @@ -2647,7 +2635,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { @@ -2657,12 +2645,12 @@ function canPatchViaPropertyDescriptor() { var req = new XMLHttpRequest(); var result = !!req.onreadystatechange; // restore original desc - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', xhrDesc || {}); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fakeonreadystatechange'); - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fake'); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { @@ -2698,7 +2686,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = Zone.current.wrap(elt[onproperty], source); + bound = wrapWithCurrentZone(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } @@ -2803,7 +2791,9 @@ function eventTargetPatch(_global, api) { var type = _global[apis[i]]; apiTypes.push(type && type.prototype); } - patchEventTarget(_global, apiTypes, { validateHandler: checkIEAndCrossContext }); + // vh is validateHandler to check event handler + // is valid or not(for security check) + patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); api.patchEventTarget = patchEventTarget; return true; } @@ -2828,22 +2818,23 @@ function registerElementPatch(_global) { 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); + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); if (descriptor && descriptor.value) { - descriptor.value = Zone.current.wrap(descriptor.value, source); + descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } else { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } - else if (opts.prototype[callback]) { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + else if (prototype[callback]) { + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } }); } - return _registerElement.apply(document, [name, opts]); + return _registerElement.call(document, name, opts); }; attachOriginToPatched(document.registerElement, _registerElement); } @@ -2862,21 +2853,21 @@ function registerElementPatch(_global) { Zone.__load_patch('util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('timers', function (global, Zone, api) { +Zone.__load_patch('timers', function (global) { var set = 'set'; var clear = 'clear'; patchTimer(global, set, clear, 'Timeout'); patchTimer(global, set, clear, 'Interval'); patchTimer(global, set, clear, 'Immediate'); }); -Zone.__load_patch('requestAnimationFrame', function (global, Zone, api) { +Zone.__load_patch('requestAnimationFrame', function (global) { patchTimer(global, 'request', 'cancel', 'AnimationFrame'); patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); }); -Zone.__load_patch('blocking', function (global, Zone, api) { +Zone.__load_patch('blocking', function (global, Zone) { var blockingMethods = ['alert', 'prompt', 'confirm']; for (var i = 0; i < blockingMethods.length; i++) { var name_1 = blockingMethods[i]; @@ -2910,17 +2901,17 @@ Zone.__load_patch('on_property', function (global, Zone, api) { propertyPatch(); registerElementPatch(global); }); -Zone.__load_patch('canvas', function (global, Zone, api) { +Zone.__load_patch('canvas', function (global) { var HTMLCanvasElement = global['HTMLCanvasElement']; if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.toBlob) { patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, callbackIndex: 0, args: args }; + return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; }); } }); -Zone.__load_patch('XHR', function (global, Zone, api) { - // Treat XMLHTTPRequest as a macrotask. +Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. patchXHR(global); var XHR_TASK = zoneSymbol('xhrTask'); var XHR_SYNC = zoneSymbol('xhrSync'); @@ -2928,19 +2919,18 @@ Zone.__load_patch('XHR', function (global, Zone, api) { var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); var XHR_URL = zoneSymbol('xhrURL'); function patchXHR(window) { + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { - var pendingTask = target[XHR_TASK]; - return pendingTask; + return target[XHR_TASK]; } - var SYMBOL_ADDEVENTLISTENER = zoneSymbol('addEventListener'); - var SYMBOL_REMOVEEVENTLISTENER = zoneSymbol('removeEventListener'); - var oriAddListener = XMLHttpRequest.prototype[SYMBOL_ADDEVENTLISTENER]; - var oriRemoveListener = XMLHttpRequest.prototype[SYMBOL_REMOVEEVENTLISTENER]; + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { var XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { - oriAddListener = XMLHttpRequestEventTarget.prototype[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = XMLHttpRequestEventTarget.prototype[SYMBOL_REMOVEEVENTLISTENER]; + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } } var READY_STATE_CHANGE = 'readystatechange'; @@ -2952,11 +2942,11 @@ Zone.__load_patch('XHR', function (global, Zone, api) { // remove existing event listener var listener = target[XHR_LISTENER]; if (!oriAddListener) { - oriAddListener = target[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = target[SYMBOL_REMOVEEVENTLISTENER]; + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } if (listener) { - oriRemoveListener.apply(target, [READY_STATE_CHANGE, listener]); + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); } var newListener = target[XHR_LISTENER] = function () { if (target.readyState === target.DONE) { @@ -2967,7 +2957,7 @@ Zone.__load_patch('XHR', function (global, Zone, api) { } } }; - oriAddListener.apply(target, [READY_STATE_CHANGE, newListener]); + oriAddListener.call(target, READY_STATE_CHANGE, newListener); var storedTask = target[XHR_TASK]; if (!storedTask) { target[XHR_TASK] = task; @@ -2984,14 +2974,13 @@ Zone.__load_patch('XHR', function (global, Zone, api) { data.aborted = true; return abortNative.apply(data.target, data.args); } - var openNative = patchMethod(window.XMLHttpRequest.prototype, 'open', function () { return function (self, args) { + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { self[XHR_SYNC] = args[2] == false; self[XHR_URL] = args[1]; return openNative.apply(self, args); }; }); var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var sendNative = patchMethod(window.XMLHttpRequest.prototype, 'send', function () { return function (self, args) { - var zone = Zone.current; + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); @@ -3005,13 +2994,12 @@ Zone.__load_patch('XHR', function (global, Zone, api) { args: args, aborted: false }; - return zone.scheduleMacroTask(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + return scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } }; }); - var STRING_TYPE = 'string'; - var abortNative = patchMethod(window.XMLHttpRequest.prototype, 'abort', function (delegate) { return function (self, args) { + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self) { var task = findPendingTask(self); - if (task && typeof task.type == STRING_TYPE) { + if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. // If the XHR has already been aborted, do nothing. // Fix #569, call abort multiple times before done will cause @@ -3027,19 +3015,13 @@ Zone.__load_patch('XHR', function (global, Zone, api) { }; }); } }); -Zone.__load_patch('geolocation', function (global, Zone, api) { +Zone.__load_patch('geolocation', function (global) { /// GEO_LOCATION if (global['navigator'] && global['navigator'].geolocation) { patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); } }); -Zone.__load_patch('getUserMedia', function (global, Zone, api) { - var navigator = global['navigator']; - if (navigator && navigator.getUserMedia) { - navigator.getUserMedia = wrapFunctionArgs(navigator.getUserMedia); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone, api) { +Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { // handle unhandled promise rejection function findPromiseRejectionHandler(evtName) { return function (e) { @@ -3718,7 +3700,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this.pendingTimers = []; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakyAsyncTestSpec + // in case user can't access the construction of FakeAsyncTestSpec // user can also define macroTaskOptions by define a global variable. if (!this.macroTaskOptions) { this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; @@ -3860,16 +3842,16 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; // should pass additional arguments to callback if have any // currently we know process.nextTick will have such additional // arguments - var addtionalArgs = void 0; + var additionalArgs = void 0; if (args) { - var callbackIndex = task.data.callbackIndex; + var callbackIndex = task.data.cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - addtionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } } this._microtasks.push({ func: task.invoke, - args: addtionalArgs, + args: additionalArgs, target: task.data && task.data.target }); break; @@ -3907,7 +3889,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; task.data.isPeriodic = true; } else { - // not periodic, use setTimout to simulate + // not periodic, use setTimeout to simulate task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } break; diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index bfa92e32f..cd1f3f47b 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -476,12 +476,13 @@ var Zone$1 = (function (global) { this.cancelFn = cancelFn; this.callback = callback; var self = this; - if (type === eventTask && options && options.isUsingGlobalCallback) { + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { this.invoke = ZoneTask.invokeTask; } else { this.invoke = function () { - return ZoneTask.invokeTask.apply(global, [self, this, arguments]); + return ZoneTask.invokeTask.call(global, self, this, arguments); }; } } @@ -598,7 +599,6 @@ var Zone$1 = (function (global) { } } } - var showError = !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; _api.microtaskDrainDone(); _isDrainingMicrotaskQueue = false; } @@ -622,7 +622,7 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - patchArguments: function () { return noop; }, + bindArguments: function () { return null; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -661,6 +661,8 @@ var __values = (undefined && undefined.__values) || function (o) { * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; function readableObjectToString(obj) { if (obj && obj.toString === Object.prototype.toString) { var className = obj.constructor && obj.constructor.name; @@ -708,7 +710,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { try { var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; if (handler && typeof handler === 'function') { - handler.apply(this, [e]); + handler.call(this, e); } } catch (err) { @@ -754,8 +756,6 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; }; var TYPE_ERROR = 'Promise resolved with itself'; - var OBJECT = 'object'; - var FUNCTION = 'function'; var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution function resolvePromise(promise, state, value) { @@ -767,7 +767,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // should only get value.then once based on promise spec. var then = null; try { - if (typeof value === OBJECT || typeof value === FUNCTION) { + if (typeof value === 'object' || typeof value === 'function') { then = value && value.then; } } @@ -784,11 +784,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { clearRejectedNoCatch(value); resolvePromise(promise, value[symbolState], value[symbolValue]); } - else if (state !== REJECTED && typeof then === FUNCTION) { + else if (state !== REJECTED && typeof then === 'function') { try { - then.apply(value, [ - onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)) - ]); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { onceWrapper(function () { @@ -808,7 +806,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Zone.currentTask.data[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone - Object.defineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); } } for (var i = 0; i < queue.length;) { @@ -846,8 +844,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // eventHandler try { var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === FUNCTION) { - handler.apply(this, [{ rejection: promise[symbolValue], promise: promise }]); + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); } } catch (err) { @@ -863,8 +861,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { clearRejectedNoCatch(promise); var delegate = promise[symbolState] ? - (typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution : - (typeof onRejected === FUNCTION) ? onRejected : forwardRejection; + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, function () { try { resolvePromise(chainPromise, true, zone.run(delegate, undefined, [promise[symbolValue]])); @@ -992,7 +990,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { ZoneAwarePromise['all'] = ZoneAwarePromise.all; var NativePromise = global[symbolPromise] = global['Promise']; var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = Object.getOwnPropertyDescriptor(global, 'Promise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; desc && delete desc.value; @@ -1025,7 +1023,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { api.setNativePromise(NewNativePromise); } }; - Object.defineProperty(global, 'Promise', desc); + ObjectDefineProperty(global, 'Promise', desc); } global['Promise'] = ZoneAwarePromise; var symbolThenPatched = __symbol__('thenPatched'); @@ -1034,11 +1032,11 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescritor is writable or not + // check Ctor.prototype.then propertyDescriptor is writable or not // in meteor env, writable is false, we have to make it to be true. - var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then'); + var prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { - Object.defineProperty(Ctor.prototype, 'then', { writable: true }); + ObjectDefineProperty(Ctor.prototype, 'then', { writable: true }); } Ctor.prototype.then = function (onResolve, onReject) { var _this = this; @@ -1065,7 +1063,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { if (NativePromise) { patchThen(NativePromise); var fetch_1 = global['fetch']; - if (typeof fetch_1 == FUNCTION) { + if (typeof fetch_1 == 'function') { global['fetch'] = zoneify(fetch_1); } } @@ -1086,27 +1084,58 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { * @fileoverview * @suppress {undefinedVars,globalThis,missingRequire} */ +// issue #989, to reduce bundle size, use short name +/** Object.getOwnPropertyDescriptor */ +/** + * @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 ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ +var ObjectDefineProperty = Object.defineProperty; +/** Object.getPrototypeOf */ +var ObjectGetPrototypeOf = Object.getPrototypeOf; +/** Object.create */ + +/** Array.prototype.slice */ +var ArraySlice = Array.prototype.slice; +/** addEventListener string const */ +var ADD_EVENT_LISTENER_STR = 'addEventListener'; +/** removeEventListener string const */ +var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; +/** zoneSymbol addEventListener */ +var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); +/** zoneSymbol removeEventListener */ +var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); +/** true string const */ +var TRUE_STR = 'true'; +/** false string const */ +var FALSE_STR = 'false'; +/** __zone_symbol__ string const */ +var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); +} +function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} var zoneSymbol = Zone.__symbol__; -var _global = typeof window === 'object' && window || typeof self === 'object' && self || global; -var FUNCTION = 'function'; -var UNDEFINED = 'undefined'; +var isWindowExists = typeof window !== 'undefined'; +var internalWindow = isWindowExists ? window : undefined; +var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; var REMOVE_ATTRIBUTE = 'removeAttribute'; var NULL_ON_PROP_VALUE = [null]; function bindArguments(args, source) { for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === FUNCTION) { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); } } return args; } -function patchArguments(target, name, source) { - return patchMethod(target, name, function (delegate, delegateName, name) { return function (self, args) { - return delegate && delegate.apply(self, bindArguments(args, source)); - }; }); -} - function isPropertyWritable(propertyDesc) { if (!propertyDesc) { return true; @@ -1114,23 +1143,20 @@ function isPropertyWritable(propertyDesc) { if (propertyDesc.writable === false) { return false; } - if (typeof propertyDesc.get === FUNCTION && typeof propertyDesc.set === UNDEFINED) { - return false; - } - return true; + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); // we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== 'undefined' && window['HTMLElement']); + !!(isWindowExists && internalWindow['HTMLElement']); var zoneSymbolEventNames = {}; var wrapFn = function (event) { // https://github.com/angular/zone.js/issues/911, in IE, sometimes @@ -1152,10 +1178,10 @@ var wrapFn = function (event) { return result; }; function patchProperty(obj, prop, prototype) { - var desc = Object.getOwnPropertyDescriptor(obj, prop); + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); if (prototypeDesc) { desc = { enumerable: true, configurable: true }; } @@ -1230,10 +1256,10 @@ function patchProperty(obj, prop, prototype) { // the onclick will be evaluated when first time event was triggered or // the property is accessed, https://github.com/angular/zone.js/issues/525 // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.apply(this); + var value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === FUNCTION) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } return value; @@ -1241,7 +1267,7 @@ function patchProperty(obj, prop, prototype) { } return null; }; - Object.defineProperty(obj, prop, desc); + ObjectDefineProperty(obj, prop, desc); } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1267,7 +1293,7 @@ var originalInstanceKey = zoneSymbol('originalInstance'); function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1279,7 +1305,7 @@ function patchMethod(target, name, patchFn) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && Object.getOwnPropertyDescriptor(proto, name); + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { var patchDelegate_1 = patchFn(delegate, delegateName, name); proto[name] = function () { @@ -1295,7 +1321,7 @@ function patchMacroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1303,9 +1329,8 @@ function patchMacroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMacroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask, null); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. @@ -1317,7 +1342,7 @@ function patchMicroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1325,9 +1350,8 @@ function patchMicroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMicroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1348,19 +1372,18 @@ function attachOriginToPatched(patched, original) { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone, api) { +Zone.__load_patch('toString', function (global, Zone) { // patch Func.prototype.toString to let them look like native var originalFunctionToString = Zone['__zone_symbol__originalToString'] = Function.prototype.toString; - var FUNCTION = 'function'; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function () { - if (typeof this === FUNCTION) { + if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === FUNCTION) { + if (typeof originalDelegate === 'function') { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { @@ -1404,25 +1427,19 @@ Zone.__load_patch('toString', function (global, Zone, api) { * @fileoverview * @suppress {missingRequire} */ -var TRUE_STR = 'true'; -var FALSE_STR = 'false'; // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - isUsingGlobalCallback: true + useG: true }; var zoneSymbolEventNames$1 = {}; var globalSources = {}; -var CONSTRUCTOR_NAME = 'name'; -var FUNCTION_TYPE = 'function'; -var OBJECT_TYPE = 'object'; -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.addEventListenerFnName) || 'addEventListener'; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.removeEventListenerFnName) || 'removeEventListener'; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listenersFnName) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.removeAllFnName) || 'removeAllListeners'; + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; @@ -1434,7 +1451,7 @@ function patchEventTarget(_global, apis, patchOptions) { return; } var delegate = task.callback; - if (typeof delegate === OBJECT_TYPE && delegate.handleEvent) { + if (typeof delegate === 'object' && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = function (event) { return delegate.handleEvent(event); }; task.originalDelegate = delegate; @@ -1447,7 +1464,7 @@ function patchEventTarget(_global, apis, patchOptions) { // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].apply(target, [event.type, delegate_1, options]); + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } }; // global shared zoneAwareCallback to handle all event callback with capture = false @@ -1458,7 +1475,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; @@ -1490,7 +1507,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; @@ -1519,21 +1536,21 @@ function patchEventTarget(_global, apis, patchOptions) { return false; } var useGlobalCallback = true; - if (patchOptions && patchOptions.useGlobalCallback !== undefined) { - useGlobalCallback = patchOptions.useGlobalCallback; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; } - var validateHandler = patchOptions && patchOptions.validateHandler; + var validateHandler = patchOptions && patchOptions.vh; var checkDuplicate = true; - if (patchOptions && patchOptions.checkDuplicate !== undefined) { - checkDuplicate = patchOptions.checkDuplicate; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; } var returnTarget = false; - if (patchOptions && patchOptions.returnTarget !== undefined) { - returnTarget = patchOptions.returnTarget; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; } var proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1556,21 +1573,17 @@ function patchEventTarget(_global, apis, patchOptions) { var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; var nativePrependEventListener; - if (patchOptions && patchOptions.prependEventListenerFnName) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prependEventListenerFnName)] = - proto[patchOptions.prependEventListenerFnName]; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; } - var customScheduleGlobal = function (task) { + var customScheduleGlobal = function () { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } - return nativeAddEventListener.apply(taskData.target, [ - taskData.eventName, - taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - taskData.options - ]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { // if task is not marked as isRemoved, this call is directly @@ -1607,41 +1620,31 @@ function patchEventTarget(_global, apis, patchOptions) { if (!task.allRemoved) { return; } - return nativeRemoveEventListener.apply(task.target, [ - task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - task.options - ]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { - return nativeAddEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { - return nativePrependEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.apply(task.target, [task.eventName, task.invoke, task.options]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); }; var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; var compareTaskCallbackVsDelegate = function (task, delegate) { var typeOfDelegate = typeof delegate; - if ((typeOfDelegate === FUNCTION_TYPE && task.callback === delegate) || - (typeOfDelegate === OBJECT_TYPE && task.originalDelegate === delegate)) { - // same callback, same capture, same event name, just return - return true; - } - return false; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.compareTaskCallbackVsDelegate) ? - patchOptions.compareTaskCallbackVsDelegate : - compareTaskCallbackVsDelegate; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { if (returnTarget === void 0) { returnTarget = false; } if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; - var targetZone = Zone.current; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); @@ -1650,7 +1653,7 @@ function patchEventTarget(_global, apis, patchOptions) { // case here to improve addEventListener performance // we will create the bind delegate when invoke var isHandleEvent = false; - if (typeof delegate !== FUNCTION_TYPE) { + if (typeof delegate !== 'function') { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -1719,7 +1722,7 @@ function patchEventTarget(_global, apis, patchOptions) { existingTasks = target[symbolEventName] = []; } var source; - var constructorName = target.constructor[CONSTRUCTOR_NAME]; + var constructorName = target.constructor['name']; var targetSource = globalSources[constructorName]; if (targetSource) { source = targetSource[eventName]; @@ -1741,7 +1744,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.eventName = eventName; taskData.isExisting = isExisting; var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; - // keep taskData into data to allow onScheduleEventTask to acess the task information + // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; } @@ -1815,7 +1818,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (existingTasks) { for (var i = 0; i < existingTasks.length; i++) { var existingTask = existingTasks[i]; - var typeOfDelegate = typeof delegate; if (compare(existingTask, delegate)) { existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check @@ -1863,11 +1865,11 @@ function patchEventTarget(_global, apis, patchOptions) { // so just keep removeListener eventListener until // all other eventListeners are removed if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, [evtName]); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } } // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { var symbolEventNames = zoneSymbolEventNames$1[eventName]; @@ -1881,7 +1883,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } if (captureTasks) { @@ -1889,7 +1891,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } } @@ -1936,13 +1938,7 @@ function findEventTasks(target, eventName) { * 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.__load_patch('EventEmitter', function (global, Zone, api) { - var callAndReturnFirstParam = function (fn) { - return function (self, args) { - fn(self, args); - return self; - }; - }; +Zone.__load_patch('EventEmitter', function (global) { // For EventEmitter var EE_ADD_LISTENER = 'addListener'; var EE_PREPEND_LISTENER = 'prependListener'; @@ -1951,23 +1947,20 @@ Zone.__load_patch('EventEmitter', function (global, Zone, api) { var EE_LISTENERS = 'listeners'; var EE_ON = 'on'; var compareTaskCallbackVsDelegate = function (task, delegate) { - if (task.callback === delegate || task.callback.listener === delegate) { - // same callback, same capture, same event name, just return - return true; - } - return false; + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; }; function patchEventEmitterMethods(obj) { var result = patchEventTarget(global, [obj], { - useGlobalCallback: false, - addEventListenerFnName: EE_ADD_LISTENER, - removeEventListenerFnName: EE_REMOVE_LISTENER, - prependEventListenerFnName: EE_PREPEND_LISTENER, - removeAllFnName: EE_REMOVE_ALL_LISTENER, - listenersFnName: EE_LISTENERS, - checkDuplicate: false, - returnTarget: true, - compareTaskCallbackVsDelegate: compareTaskCallbackVsDelegate + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; @@ -1992,7 +1985,7 @@ Zone.__load_patch('EventEmitter', function (global, Zone, api) { * 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.__load_patch('fs', function (global, Zone, api) { +Zone.__load_patch('fs', function () { var fs; try { fs = require('fs'); @@ -2015,7 +2008,7 @@ Zone.__load_patch('fs', function (global, Zone, api) { return { name: 'fs.' + name, args: args, - callbackIndex: args.length > 0 ? args.length - 1 : -1, + cbIdx: args.length > 0 ? args.length - 1 : -1, target: self }; }); @@ -2041,12 +2034,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { setName += nameSuffix; cancelName += nameSuffix; var tasksByHandleId = {}; - var NUMBER = 'number'; - var STRING = 'string'; - var FUNCTION = 'function'; - var INTERVAL = 'Interval'; - var TIMEOUT = 'Timeout'; - var NOT_SCHEDULED = 'notScheduled'; function scheduleTask(task) { var data = task.data; function timer() { @@ -2054,21 +2041,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task.invoke.apply(this, arguments); } finally { - if (task.data && task.data.isPeriodic) { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - return; - } - if (typeof data.handleId === NUMBER) { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } @@ -2081,21 +2067,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } setNative = patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === FUNCTION) { - var zone = Zone.current; + if (typeof args[0] === 'function') { var options = { handleId: null, - isPeriodic: nameSuffix === INTERVAL, - delay: (nameSuffix === TIMEOUT || nameSuffix === INTERVAL) ? args[1] || 0 : 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); + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === NUMBER) { + if (typeof handle === 'number') { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -2107,12 +2092,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === FUNCTION && - typeof handle.unref === FUNCTION) { + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { task.ref = handle.ref.bind(handle); task.unref = handle.unref.bind(handle); } - if (typeof handle === NUMBER || handle) { + if (typeof handle === 'number' || handle) { return handle; } return task; @@ -2126,7 +2111,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, cancelName, function (delegate) { return function (self, args) { var id = args[0]; var task; - if (typeof id === NUMBER) { + if (typeof id === 'number') { // non nodejs env. task = tasksByHandleId[id]; } @@ -2138,10 +2123,10 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task = id; } } - if (task && typeof task.type === STRING) { - if (task.state !== NOT_SCHEDULED && + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === NUMBER) { + if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { @@ -2170,9 +2155,9 @@ var clear = 'clear'; Zone.__load_patch('node_util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('node_timers', function (global, Zone, api) { +Zone.__load_patch('node_timers', function (global, Zone) { // Timers var globalUseTimeoutFromTimer = false; try { @@ -2198,7 +2183,7 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { patchTimer(timers, set, clear, 'Immediate'); } catch (error) { - // timers module not exists, for example, when we using nativescript + // timers module not exists, for example, when we using nativeScript // timers is not available } if (isMix) { @@ -2217,7 +2202,7 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { } else { // global use timers setTimeout, but not equals - // this happenes when use nodejs v0.10.x, global setTimeout will + // this happens when use nodejs v0.10.x, global setTimeout will // use a lazy load version of timers setTimeout // we should not double patch timer's setTimeout // so we only store the __symbol__ for consistency @@ -2227,13 +2212,13 @@ Zone.__load_patch('node_timers', function (global, Zone, api) { } }); // patch process related methods -Zone.__load_patch('nextTick', function (global, Zone, api) { +Zone.__load_patch('nextTick', function () { // patch nextTick as microTask patchMicroTask(process, 'nextTick', function (self, args) { return { name: 'process.nextTick', args: args, - callbackIndex: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, target: process }; }); @@ -2261,7 +2246,7 @@ Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api } }); // Crypto -Zone.__load_patch('crypto', function (global, Zone, api) { +Zone.__load_patch('crypto', function () { var crypto; try { crypto = require('crypto'); @@ -2276,7 +2261,7 @@ Zone.__load_patch('crypto', function (global, Zone, api) { return { name: 'crypto.' + name, args: args, - callbackIndex: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? args.length - 1 : -1, target: crypto @@ -2285,13 +2270,13 @@ Zone.__load_patch('crypto', function (global, Zone, api) { }); } }); -Zone.__load_patch('console', function (global, Zone, api) { +Zone.__load_patch('console', function (global, Zone) { var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; consoleMethods.forEach(function (m) { var originalMethod = console[Zone.__symbol__(m)] = console[m]; if (originalMethod) { console[m] = function () { - var args = Array.prototype.slice.call(arguments); + var args = ArraySlice.call(arguments); if (Zone.current === Zone.root) { return originalMethod.apply(this, args); } @@ -2958,7 +2943,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this.pendingTimers = []; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakyAsyncTestSpec + // in case user can't access the construction of FakeAsyncTestSpec // user can also define macroTaskOptions by define a global variable. if (!this.macroTaskOptions) { this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; @@ -3100,16 +3085,16 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; // should pass additional arguments to callback if have any // currently we know process.nextTick will have such additional // arguments - var addtionalArgs = void 0; + var additionalArgs = void 0; if (args) { - var callbackIndex = task.data.callbackIndex; + var callbackIndex = task.data.cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - addtionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } } this._microtasks.push({ func: task.invoke, - args: addtionalArgs, + args: additionalArgs, target: task.data && task.data.target }); break; @@ -3147,7 +3132,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; task.data.isPeriodic = true; } else { - // not periodic, use setTimout to simulate + // not periodic, use setTimeout to simulate task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } break; diff --git a/dist/zone-testing.js b/dist/zone-testing.js index b8ab642e3..1bdcad041 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -658,7 +658,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this.pendingTimers = []; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakyAsyncTestSpec + // in case user can't access the construction of FakeAsyncTestSpec // user can also define macroTaskOptions by define a global variable. if (!this.macroTaskOptions) { this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; @@ -800,16 +800,16 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; // should pass additional arguments to callback if have any // currently we know process.nextTick will have such additional // arguments - var addtionalArgs = void 0; + var additionalArgs = void 0; if (args) { - var callbackIndex = task.data.callbackIndex; + var callbackIndex = task.data.cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - addtionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } } this._microtasks.push({ func: task.invoke, - args: addtionalArgs, + args: additionalArgs, target: task.data && task.data.target }); break; @@ -847,7 +847,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; task.data.isPeriodic = true; } else { - // not periodic, use setTimout to simulate + // not periodic, use setTimeout to simulate task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } break; diff --git a/dist/zone.js b/dist/zone.js index 3d28db64d..651ac6966 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -476,12 +476,13 @@ var Zone$1 = (function (global) { this.cancelFn = cancelFn; this.callback = callback; var self = this; - if (type === eventTask && options && options.isUsingGlobalCallback) { + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { this.invoke = ZoneTask.invokeTask; } else { this.invoke = function () { - return ZoneTask.invokeTask.apply(global, [self, this, arguments]); + return ZoneTask.invokeTask.call(global, self, this, arguments); }; } } @@ -598,7 +599,6 @@ var Zone$1 = (function (global) { } } } - var showError = !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; _api.microtaskDrainDone(); _isDrainingMicrotaskQueue = false; } @@ -622,7 +622,7 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - patchArguments: function () { return noop; }, + bindArguments: function () { return null; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -661,6 +661,8 @@ var __values = (undefined && undefined.__values) || function (o) { * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; function readableObjectToString(obj) { if (obj && obj.toString === Object.prototype.toString) { var className = obj.constructor && obj.constructor.name; @@ -708,7 +710,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { try { var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; if (handler && typeof handler === 'function') { - handler.apply(this, [e]); + handler.call(this, e); } } catch (err) { @@ -754,8 +756,6 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; }; var TYPE_ERROR = 'Promise resolved with itself'; - var OBJECT = 'object'; - var FUNCTION = 'function'; var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); // Promise Resolution function resolvePromise(promise, state, value) { @@ -767,7 +767,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // should only get value.then once based on promise spec. var then = null; try { - if (typeof value === OBJECT || typeof value === FUNCTION) { + if (typeof value === 'object' || typeof value === 'function') { then = value && value.then; } } @@ -784,11 +784,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { clearRejectedNoCatch(value); resolvePromise(promise, value[symbolState], value[symbolValue]); } - else if (state !== REJECTED && typeof then === FUNCTION) { + else if (state !== REJECTED && typeof then === 'function') { try { - then.apply(value, [ - onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false)) - ]); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { onceWrapper(function () { @@ -808,7 +806,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Zone.currentTask.data[creationTrace]; if (trace) { // only keep the long stack trace into error when in longStackTraceZone - Object.defineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); } } for (var i = 0; i < queue.length;) { @@ -846,8 +844,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { // eventHandler try { var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === FUNCTION) { - handler.apply(this, [{ rejection: promise[symbolValue], promise: promise }]); + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); } } catch (err) { @@ -863,8 +861,8 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { clearRejectedNoCatch(promise); var delegate = promise[symbolState] ? - (typeof onFulfilled === FUNCTION) ? onFulfilled : forwardResolution : - (typeof onRejected === FUNCTION) ? onRejected : forwardRejection; + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, function () { try { resolvePromise(chainPromise, true, zone.run(delegate, undefined, [promise[symbolValue]])); @@ -992,7 +990,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { ZoneAwarePromise['all'] = ZoneAwarePromise.all; var NativePromise = global[symbolPromise] = global['Promise']; var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = Object.getOwnPropertyDescriptor(global, 'Promise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); if (!desc || desc.configurable) { desc && delete desc.writable; desc && delete desc.value; @@ -1025,7 +1023,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { api.setNativePromise(NewNativePromise); } }; - Object.defineProperty(global, 'Promise', desc); + ObjectDefineProperty(global, 'Promise', desc); } global['Promise'] = ZoneAwarePromise; var symbolThenPatched = __symbol__('thenPatched'); @@ -1034,11 +1032,11 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescritor is writable or not + // check Ctor.prototype.then propertyDescriptor is writable or not // in meteor env, writable is false, we have to make it to be true. - var prop = Object.getOwnPropertyDescriptor(Ctor.prototype, 'then'); + var prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); if (prop && prop.writable === false && prop.configurable) { - Object.defineProperty(Ctor.prototype, 'then', { writable: true }); + ObjectDefineProperty(Ctor.prototype, 'then', { writable: true }); } Ctor.prototype.then = function (onResolve, onReject) { var _this = this; @@ -1065,7 +1063,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { if (NativePromise) { patchThen(NativePromise); var fetch_1 = global['fetch']; - if (typeof fetch_1 == FUNCTION) { + if (typeof fetch_1 == 'function') { global['fetch'] = zoneify(fetch_1); } } @@ -1086,39 +1084,64 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { * @fileoverview * @suppress {undefinedVars,globalThis,missingRequire} */ +// issue #989, to reduce bundle size, use short name +/** Object.getOwnPropertyDescriptor */ +/** + * @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 ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ +var ObjectDefineProperty = Object.defineProperty; +/** Object.getPrototypeOf */ +var ObjectGetPrototypeOf = Object.getPrototypeOf; +/** Object.create */ +var ObjectCreate = Object.create; +/** Array.prototype.slice */ +var ArraySlice = Array.prototype.slice; +/** addEventListener string const */ +var ADD_EVENT_LISTENER_STR = 'addEventListener'; +/** removeEventListener string const */ +var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; +/** zoneSymbol addEventListener */ +var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); +/** zoneSymbol removeEventListener */ +var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); +/** true string const */ +var TRUE_STR = 'true'; +/** false string const */ +var FALSE_STR = 'false'; +/** __zone_symbol__ string const */ +var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); +} +function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} var zoneSymbol = Zone.__symbol__; -var _global = typeof window === 'object' && window || typeof self === 'object' && self || global; -var FUNCTION = 'function'; -var UNDEFINED = 'undefined'; +var isWindowExists = typeof window !== 'undefined'; +var internalWindow = isWindowExists ? window : undefined; +var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; var REMOVE_ATTRIBUTE = 'removeAttribute'; var NULL_ON_PROP_VALUE = [null]; function bindArguments(args, source) { for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === FUNCTION) { - args[i] = Zone.current.wrap(args[i], source + '_' + i); + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); } } return args; } -function wrapFunctionArgs(func, source) { - return function () { - var args = Array.prototype.slice.call(arguments); - var wrappedArgs = bindArguments(args, source ? source : func.name); - return func.apply(this, wrappedArgs); - }; -} -function patchArguments(target, name, source) { - return patchMethod(target, name, function (delegate, delegateName, name) { return function (self, args) { - return delegate && delegate.apply(self, bindArguments(args, source)); - }; }); -} function patchPrototype(prototype, fnNames) { var source = prototype.constructor['name']; var _loop_1 = function (i) { var name_1 = fnNames[i]; var delegate = prototype[name_1]; if (delegate) { - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, name_1); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); if (!isPropertyWritable(prototypeDesc)) { return "continue"; } @@ -1142,23 +1165,20 @@ function isPropertyWritable(propertyDesc) { if (propertyDesc.writable === false) { return false; } - if (typeof propertyDesc.get === FUNCTION && typeof propertyDesc.set === UNDEFINED) { - return false; - } - return true; + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(typeof window !== 'undefined' && window['HTMLElement']); +var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidently browserify +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. var isMix = typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(typeof window !== 'undefined' && window['HTMLElement']); + !!(isWindowExists && internalWindow['HTMLElement']); var zoneSymbolEventNames = {}; var wrapFn = function (event) { // https://github.com/angular/zone.js/issues/911, in IE, sometimes @@ -1180,10 +1200,10 @@ var wrapFn = function (event) { return result; }; function patchProperty(obj, prop, prototype) { - var desc = Object.getOwnPropertyDescriptor(obj, prop); + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); if (!desc && prototype) { // when patch window object, use prototype to check prop exist or not - var prototypeDesc = Object.getOwnPropertyDescriptor(prototype, prop); + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); if (prototypeDesc) { desc = { enumerable: true, configurable: true }; } @@ -1258,10 +1278,10 @@ function patchProperty(obj, prop, prototype) { // the onclick will be evaluated when first time event was triggered or // the property is accessed, https://github.com/angular/zone.js/issues/525 // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.apply(this); + var value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.apply(this, [value]); - if (typeof target[REMOVE_ATTRIBUTE] === FUNCTION) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } return value; @@ -1269,7 +1289,7 @@ function patchProperty(obj, prop, prototype) { } return null; }; - Object.defineProperty(obj, prop, desc); + ObjectDefineProperty(obj, prop, desc); } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1334,10 +1354,10 @@ function patchClass(className) { }; } else { - Object.defineProperty(_global[className].prototype, prop, { + ObjectDefineProperty(_global[className].prototype, prop, { set: function (fn) { if (typeof fn === 'function') { - this[originalInstanceKey][prop] = Zone.current.wrap(fn, className + '.' + prop); + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); // keep callback in wrapped function so we can // use it in Function.prototype.toString to return // the native one. @@ -1363,7 +1383,7 @@ function patchClass(className) { function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && target[name]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1375,7 +1395,7 @@ function patchMethod(target, name, patchFn) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && Object.getOwnPropertyDescriptor(proto, name); + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { var patchDelegate_1 = patchFn(delegate, delegateName, name); proto[name] = function () { @@ -1391,7 +1411,7 @@ function patchMacroTask(obj, funcName, metaCreator) { var setNative = null; function scheduleTask(task) { var data = task.data; - data.args[data.callbackIndex] = function () { + data.args[data.cbIdx] = function () { task.invoke.apply(this, arguments); }; setNative.apply(data.target, data.args); @@ -1399,9 +1419,8 @@ function patchMacroTask(obj, funcName, metaCreator) { } setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); - if (meta.callbackIndex >= 0 && typeof args[meta.callbackIndex] === 'function') { - var task = Zone.current.scheduleMacroTask(meta.name, args[meta.callbackIndex], meta, scheduleTask, null); - return task; + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); } else { // cause an error by calling it directly. @@ -1421,8 +1440,7 @@ function isIEOrEdge() { } isDetectedIEOrEdge = true; try { - var ua = window.navigator.userAgent; - var msie = ua.indexOf('MSIE '); + var ua = internalWindow.navigator.userAgent; if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } @@ -1441,19 +1459,18 @@ function isIEOrEdge() { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone, api) { +Zone.__load_patch('toString', function (global, Zone) { // patch Func.prototype.toString to let them look like native var originalFunctionToString = Zone['__zone_symbol__originalToString'] = Function.prototype.toString; - var FUNCTION = 'function'; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); Function.prototype.toString = function () { - if (typeof this === FUNCTION) { + if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { - if (typeof originalDelegate === FUNCTION) { + if (typeof originalDelegate === 'function') { return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); } else { @@ -1497,25 +1514,19 @@ Zone.__load_patch('toString', function (global, Zone, api) { * @fileoverview * @suppress {missingRequire} */ -var TRUE_STR = 'true'; -var FALSE_STR = 'false'; // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - isUsingGlobalCallback: true + useG: true }; var zoneSymbolEventNames$1 = {}; var globalSources = {}; -var CONSTRUCTOR_NAME = 'name'; -var FUNCTION_TYPE = 'function'; -var OBJECT_TYPE = 'object'; -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.addEventListenerFnName) || 'addEventListener'; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.removeEventListenerFnName) || 'removeEventListener'; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listenersFnName) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.removeAllFnName) || 'removeAllListeners'; + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; var PREPEND_EVENT_LISTENER = 'prependListener'; @@ -1527,7 +1538,7 @@ function patchEventTarget(_global, apis, patchOptions) { return; } var delegate = task.callback; - if (typeof delegate === OBJECT_TYPE && delegate.handleEvent) { + if (typeof delegate === 'object' && delegate.handleEvent) { // create the bind version of handleEvent when invoke task.callback = function (event) { return delegate.handleEvent(event); }; task.originalDelegate = delegate; @@ -1540,7 +1551,7 @@ function patchEventTarget(_global, apis, patchOptions) { // only browser need to do this, nodejs eventEmitter will cal removeListener // inside EventEmitter.once var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].apply(target, [event.type, delegate_1, options]); + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } }; // global shared zoneAwareCallback to handle all event callback with capture = false @@ -1551,7 +1562,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; @@ -1583,7 +1594,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (!event) { return; } - // event.target is needed for Samusung TV and SourceBuffer + // event.target is needed for Samsung TV and SourceBuffer // || global is needed https://github.com/angular/zone.js/issues/190 var target = this || event.target || _global; var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; @@ -1612,21 +1623,21 @@ function patchEventTarget(_global, apis, patchOptions) { return false; } var useGlobalCallback = true; - if (patchOptions && patchOptions.useGlobalCallback !== undefined) { - useGlobalCallback = patchOptions.useGlobalCallback; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; } - var validateHandler = patchOptions && patchOptions.validateHandler; + var validateHandler = patchOptions && patchOptions.vh; var checkDuplicate = true; - if (patchOptions && patchOptions.checkDuplicate !== undefined) { - checkDuplicate = patchOptions.checkDuplicate; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; } var returnTarget = false; - if (patchOptions && patchOptions.returnTarget !== undefined) { - returnTarget = patchOptions.returnTarget; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; } var proto = obj; while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = Object.getPrototypeOf(proto); + proto = ObjectGetPrototypeOf(proto); } if (!proto && obj[ADD_EVENT_LISTENER]) { // somehow we did not find it, but we can see it. This happens on IE for Window properties. @@ -1649,21 +1660,17 @@ function patchEventTarget(_global, apis, patchOptions) { var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; var nativePrependEventListener; - if (patchOptions && patchOptions.prependEventListenerFnName) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prependEventListenerFnName)] = - proto[patchOptions.prependEventListenerFnName]; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; } - var customScheduleGlobal = function (task) { + var customScheduleGlobal = function () { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } - return nativeAddEventListener.apply(taskData.target, [ - taskData.eventName, - taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - taskData.options - ]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { // if task is not marked as isRemoved, this call is directly @@ -1700,41 +1707,31 @@ function patchEventTarget(_global, apis, patchOptions) { if (!task.allRemoved) { return; } - return nativeRemoveEventListener.apply(task.target, [ - task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, - task.options - ]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { - return nativeAddEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { - return nativePrependEventListener.apply(taskData.target, [taskData.eventName, task.invoke, taskData.options]); + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.apply(task.target, [task.eventName, task.invoke, task.options]); + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); }; var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; var compareTaskCallbackVsDelegate = function (task, delegate) { var typeOfDelegate = typeof delegate; - if ((typeOfDelegate === FUNCTION_TYPE && task.callback === delegate) || - (typeOfDelegate === OBJECT_TYPE && task.originalDelegate === delegate)) { - // same callback, same capture, same event name, just return - return true; - } - return false; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.compareTaskCallbackVsDelegate) ? - patchOptions.compareTaskCallbackVsDelegate : - compareTaskCallbackVsDelegate; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { if (returnTarget === void 0) { returnTarget = false; } if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; - var targetZone = Zone.current; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); @@ -1743,7 +1740,7 @@ function patchEventTarget(_global, apis, patchOptions) { // case here to improve addEventListener performance // we will create the bind delegate when invoke var isHandleEvent = false; - if (typeof delegate !== FUNCTION_TYPE) { + if (typeof delegate !== 'function') { if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } @@ -1812,7 +1809,7 @@ function patchEventTarget(_global, apis, patchOptions) { existingTasks = target[symbolEventName] = []; } var source; - var constructorName = target.constructor[CONSTRUCTOR_NAME]; + var constructorName = target.constructor['name']; var targetSource = globalSources[constructorName]; if (targetSource) { source = targetSource[eventName]; @@ -1834,7 +1831,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.eventName = eventName; taskData.isExisting = isExisting; var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; - // keep taskData into data to allow onScheduleEventTask to acess the task information + // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; } @@ -1908,7 +1905,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (existingTasks) { for (var i = 0; i < existingTasks.length; i++) { var existingTask = existingTasks[i]; - var typeOfDelegate = typeof delegate; if (compare(existingTask, delegate)) { existingTasks.splice(i, 1); // set isRemoved to data for faster invokeTask check @@ -1956,11 +1952,11 @@ function patchEventTarget(_global, apis, patchOptions) { // so just keep removeListener eventListener until // all other eventListeners are removed if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, [evtName]); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } } // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].apply(this, ['removeListener']); + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { var symbolEventNames = zoneSymbolEventNames$1[eventName]; @@ -1974,7 +1970,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } if (captureTasks) { @@ -1982,7 +1978,7 @@ function patchEventTarget(_global, apis, patchOptions) { for (var i = 0; i < removeTasks.length; i++) { var task = removeTasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].apply(this, [eventName, delegate, task.options]); + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); } } } @@ -2052,12 +2048,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { setName += nameSuffix; cancelName += nameSuffix; var tasksByHandleId = {}; - var NUMBER = 'number'; - var STRING = 'string'; - var FUNCTION = 'function'; - var INTERVAL = 'Interval'; - var TIMEOUT = 'Timeout'; - var NOT_SCHEDULED = 'notScheduled'; function scheduleTask(task) { var data = task.data; function timer() { @@ -2065,21 +2055,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task.invoke.apply(this, arguments); } finally { - if (task.data && task.data.isPeriodic) { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - return; - } - if (typeof data.handleId === NUMBER) { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } @@ -2092,21 +2081,20 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } setNative = patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === FUNCTION) { - var zone = Zone.current; + if (typeof args[0] === 'function') { var options = { handleId: null, - isPeriodic: nameSuffix === INTERVAL, - delay: (nameSuffix === TIMEOUT || nameSuffix === INTERVAL) ? args[1] || 0 : 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); + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === NUMBER) { + if (typeof handle === 'number') { // for non nodejs env, we save handleId: task // mapping in local cache for clearTimeout tasksByHandleId[handle] = task; @@ -2118,12 +2106,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { } // check whether handle is null, because some polyfill or browser // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === FUNCTION && - typeof handle.unref === FUNCTION) { + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { task.ref = handle.ref.bind(handle); task.unref = handle.unref.bind(handle); } - if (typeof handle === NUMBER || handle) { + if (typeof handle === 'number' || handle) { return handle; } return task; @@ -2137,7 +2125,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, cancelName, function (delegate) { return function (self, args) { var id = args[0]; var task; - if (typeof id === NUMBER) { + if (typeof id === 'number') { // non nodejs env. task = tasksByHandleId[id]; } @@ -2149,10 +2137,10 @@ function patchTimer(window, setName, cancelName, nameSuffix) { task = id; } } - if (task && typeof task.type === STRING) { - if (task.state !== NOT_SCHEDULED && + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === NUMBER) { + if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { @@ -2185,16 +2173,13 @@ var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; var _create = Object.create; var unconfigurablesKey = zoneSymbol('unconfigurables'); -var PROTOTYPE = 'prototype'; -var OBJECT = 'object'; -var UNDEFINED$1 = 'undefined'; function propertyPatch() { Object.defineProperty = function (obj, prop, desc) { if (isUnconfigurable(obj, prop)) { throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); } var originalConfigurableFlag = desc.configurable; - if (prop !== PROTOTYPE) { + if (prop !== 'prototype') { desc = rewriteDescriptor(obj, prop, desc); } return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); @@ -2206,7 +2191,7 @@ function propertyPatch() { return obj; }; Object.create = function (obj, proto) { - if (typeof proto === OBJECT && !Object.isFrozen(proto)) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { Object.keys(proto).forEach(function (prop) { proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); }); @@ -2253,7 +2238,7 @@ function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { if (desc.configurable) { // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's // retry with the original flag value - if (typeof originalConfigurableFlag == UNDEFINED$1) { + if (typeof originalConfigurableFlag == 'undefined') { delete desc.configurable; } else { @@ -2294,22 +2279,22 @@ function apply(api, _global) { if (!_global.EventTarget) { patchEventTarget(_global, [WS.prototype]); } - _global.WebSocket = function (a, b) { - var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); var proxySocket; var proxySocketProto; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); + var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = Object.create(socket); + proxySocket = ObjectCreate(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method proxySocketProto = socket; - ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function (propName) { + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { proxySocket[propName] = function () { - var args = Array.prototype.slice.call(arguments); - if (propName === 'addEventListener' || propName === 'removeEventListener') { + var args = ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { var eventName = args.length > 0 ? args[0] : undefined; if (eventName) { var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); @@ -2581,12 +2566,13 @@ function propertyDescriptorPatch(api, _global) { var ignoreProperties = _global.__Zone_ignore_on_properties; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { + var internalWindow = window; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(window, eventNames.concat(['messageerror']), ignoreProperties, Object.getPrototypeOf(window)); + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof window['SVGElement'] !== 'undefined') { - patchFilteredProperties(window['SVGElement'].prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); } patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); @@ -2595,11 +2581,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = window['HTMLMarqueeElement']; + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; if (HTMLMarqueeElement_1) { patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); } - var Worker_1 = window['Worker']; + var Worker_1 = internalWindow['Worker']; if (Worker_1) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } @@ -2631,15 +2617,17 @@ function propertyDescriptorPatch(api, _global) { } } function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') { // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 // IDL interface attributes are not configurable - var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); + var desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; } - var xhrDesc = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'onreadystatechange'); + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera // by default XMLHttpRequest.prototype.onreadystatechange is undefined // without adding enumerable and configurable will cause onreadystatechange @@ -2647,7 +2635,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { @@ -2657,12 +2645,12 @@ function canPatchViaPropertyDescriptor() { var req = new XMLHttpRequest(); var result = !!req.onreadystatechange; // restore original desc - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', xhrDesc || {}); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fakeonreadystatechange'); - Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fake'); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { @@ -2698,7 +2686,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = Zone.current.wrap(elt[onproperty], source); + bound = wrapWithCurrentZone(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } @@ -2803,7 +2791,9 @@ function eventTargetPatch(_global, api) { var type = _global[apis[i]]; apiTypes.push(type && type.prototype); } - patchEventTarget(_global, apiTypes, { validateHandler: checkIEAndCrossContext }); + // vh is validateHandler to check event handler + // is valid or not(for security check) + patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); api.patchEventTarget = patchEventTarget; return true; } @@ -2828,22 +2818,23 @@ function registerElementPatch(_global) { 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); + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); if (descriptor && descriptor.value) { - descriptor.value = Zone.current.wrap(descriptor.value, source); + descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } else { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } - else if (opts.prototype[callback]) { - opts.prototype[callback] = Zone.current.wrap(opts.prototype[callback], source); + else if (prototype[callback]) { + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } }); } - return _registerElement.apply(document, [name, opts]); + return _registerElement.call(document, name, opts); }; attachOriginToPatched(document.registerElement, _registerElement); } @@ -2862,21 +2853,21 @@ function registerElementPatch(_global) { Zone.__load_patch('util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; - api.patchArguments = patchArguments; + api.bindArguments = bindArguments; }); -Zone.__load_patch('timers', function (global, Zone, api) { +Zone.__load_patch('timers', function (global) { var set = 'set'; var clear = 'clear'; patchTimer(global, set, clear, 'Timeout'); patchTimer(global, set, clear, 'Interval'); patchTimer(global, set, clear, 'Immediate'); }); -Zone.__load_patch('requestAnimationFrame', function (global, Zone, api) { +Zone.__load_patch('requestAnimationFrame', function (global) { patchTimer(global, 'request', 'cancel', 'AnimationFrame'); patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); }); -Zone.__load_patch('blocking', function (global, Zone, api) { +Zone.__load_patch('blocking', function (global, Zone) { var blockingMethods = ['alert', 'prompt', 'confirm']; for (var i = 0; i < blockingMethods.length; i++) { var name_1 = blockingMethods[i]; @@ -2910,17 +2901,17 @@ Zone.__load_patch('on_property', function (global, Zone, api) { propertyPatch(); registerElementPatch(global); }); -Zone.__load_patch('canvas', function (global, Zone, api) { +Zone.__load_patch('canvas', function (global) { var HTMLCanvasElement = global['HTMLCanvasElement']; if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && HTMLCanvasElement.prototype.toBlob) { patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, callbackIndex: 0, args: args }; + return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; }); } }); -Zone.__load_patch('XHR', function (global, Zone, api) { - // Treat XMLHTTPRequest as a macrotask. +Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. patchXHR(global); var XHR_TASK = zoneSymbol('xhrTask'); var XHR_SYNC = zoneSymbol('xhrSync'); @@ -2928,19 +2919,18 @@ Zone.__load_patch('XHR', function (global, Zone, api) { var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); var XHR_URL = zoneSymbol('xhrURL'); function patchXHR(window) { + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { - var pendingTask = target[XHR_TASK]; - return pendingTask; + return target[XHR_TASK]; } - var SYMBOL_ADDEVENTLISTENER = zoneSymbol('addEventListener'); - var SYMBOL_REMOVEEVENTLISTENER = zoneSymbol('removeEventListener'); - var oriAddListener = XMLHttpRequest.prototype[SYMBOL_ADDEVENTLISTENER]; - var oriRemoveListener = XMLHttpRequest.prototype[SYMBOL_REMOVEEVENTLISTENER]; + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { var XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { - oriAddListener = XMLHttpRequestEventTarget.prototype[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = XMLHttpRequestEventTarget.prototype[SYMBOL_REMOVEEVENTLISTENER]; + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } } var READY_STATE_CHANGE = 'readystatechange'; @@ -2952,11 +2942,11 @@ Zone.__load_patch('XHR', function (global, Zone, api) { // remove existing event listener var listener = target[XHR_LISTENER]; if (!oriAddListener) { - oriAddListener = target[SYMBOL_ADDEVENTLISTENER]; - oriRemoveListener = target[SYMBOL_REMOVEEVENTLISTENER]; + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } if (listener) { - oriRemoveListener.apply(target, [READY_STATE_CHANGE, listener]); + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); } var newListener = target[XHR_LISTENER] = function () { if (target.readyState === target.DONE) { @@ -2967,7 +2957,7 @@ Zone.__load_patch('XHR', function (global, Zone, api) { } } }; - oriAddListener.apply(target, [READY_STATE_CHANGE, newListener]); + oriAddListener.call(target, READY_STATE_CHANGE, newListener); var storedTask = target[XHR_TASK]; if (!storedTask) { target[XHR_TASK] = task; @@ -2984,14 +2974,13 @@ Zone.__load_patch('XHR', function (global, Zone, api) { data.aborted = true; return abortNative.apply(data.target, data.args); } - var openNative = patchMethod(window.XMLHttpRequest.prototype, 'open', function () { return function (self, args) { + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { self[XHR_SYNC] = args[2] == false; self[XHR_URL] = args[1]; return openNative.apply(self, args); }; }); var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var sendNative = patchMethod(window.XMLHttpRequest.prototype, 'send', function () { return function (self, args) { - var zone = Zone.current; + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); @@ -3005,13 +2994,12 @@ Zone.__load_patch('XHR', function (global, Zone, api) { args: args, aborted: false }; - return zone.scheduleMacroTask(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + return scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } }; }); - var STRING_TYPE = 'string'; - var abortNative = patchMethod(window.XMLHttpRequest.prototype, 'abort', function (delegate) { return function (self, args) { + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self) { var task = findPendingTask(self); - if (task && typeof task.type == STRING_TYPE) { + if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. // If the XHR has already been aborted, do nothing. // Fix #569, call abort multiple times before done will cause @@ -3027,19 +3015,13 @@ Zone.__load_patch('XHR', function (global, Zone, api) { }; }); } }); -Zone.__load_patch('geolocation', function (global, Zone, api) { +Zone.__load_patch('geolocation', function (global) { /// GEO_LOCATION if (global['navigator'] && global['navigator'].geolocation) { patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); } }); -Zone.__load_patch('getUserMedia', function (global, Zone, api) { - var navigator = global['navigator']; - if (navigator && navigator.getUserMedia) { - navigator.getUserMedia = wrapFunctionArgs(navigator.getUserMedia); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone, api) { +Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { // handle unhandled promise rejection function findPromiseRejectionHandler(evtName) { return function (e) { diff --git a/dist/zone.min.js b/dist/zone.min.js index a89a96190..9c6bff9af 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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--)typeof e[n]===L&&(e[n]=Zone.current.wrap(e[n],t+"_"+n));return e}function t(t,n){return function(){var r=Array.prototype.slice.call(arguments),o=e(r,n?n:t.name);return t.apply(this,o)}}function n(t,n,r){return c(t,n,function(t,n,o){return function(n,o){return t&&t.apply(n,e(o,r))}})}function r(t,n){for(var r=t.constructor.name,a=function(a){var i=n[a],s=t[i];if(s){var c=Object.getOwnPropertyDescriptor(t,i);if(!o(c))return"continue";t[i]=function(t){var n=function(){return t.apply(this,e(arguments,r+"."+i))};return l(n,t),n}(s)}},i=0;i=0&&"function"==typeof o[a.callbackIndex]){var i=Zone.current.scheduleMacroTask(a.name,o[a.callbackIndex],a,r,null);return i}return e.apply(t,o)}})}function l(e,t){e[j("OriginalDelegate")]=t}function p(){if(X)return U;X=!0;try{var e=window.navigator.userAgent;e.indexOf("MSIE ");return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(U=!0),U}catch(t){}}function f(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useGlobalCallback&&(r=n.useGlobalCallback);var d=n&&n.validateHandler,y=!0;n&&void 0!==n.checkDuplicate&&(y=n.checkDuplicate);var k=!1;n&&void 0!==n.returnTarget&&(k=n.returnTarget);for(var m=t;m&&!m.hasOwnProperty(o);)m=Object.getPrototypeOf(m);if(!m&&t[o]&&(m=t),!m)return!1;if(m[c])return!1;var _,b={},T=m[c]=m[o],w=m[j(a)]=m[a],E=m[j(i)]=m[i],D=m[j(s)]=m[s];n&&n.prependEventListenerFnName&&(_=m[j(n.prependEventListenerFnName)]=m[n.prependEventListenerFnName]);var O=function(e){if(!b.isExisting)return T.apply(b.target,[b.eventName,b.capture?g:v,b.options])},S=function(e){if(!e.isRemoved){var t=K[e.eventName],n=void 0;t&&(n=t[e.capture?W:G]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=Object.getOwnPropertyDescriptor(a,"onmessage");return s&&s.configurable===!1?(r=Object.create(a),o=a,["addEventListener","removeEventListener","send","close"].forEach(function(e){r[e]=function(){var t=Array.prototype.slice.call(arguments);if("addEventListener"===e||"removeEventListener"===e){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){var o=T(e,t,n);i(e,o,r)}function E(e,t){if(!x||q){var n="undefined"!=typeof WebSocket;if(D()){var r=t.__Zone_ignore_on_properties;if(F){w(window,Se.concat(["messageerror"]),r,Object.getPrototypeOf(window)),w(Document.prototype,Se,r),"undefined"!=typeof window.SVGElement&&w(window.SVGElement.prototype,Se,r),w(Element.prototype,Se,r),w(HTMLElement.prototype,Se,r),w(HTMLMediaElement.prototype,ve,r),w(HTMLFrameSetElement.prototype,he.concat(be),r),w(HTMLBodyElement.prototype,he.concat(be),r),w(HTMLFrameElement.prototype,_e,r),w(HTMLIFrameElement.prototype,_e,r);var o=window.HTMLMarqueeElement;o&&w(o.prototype,Te,r);var a=window.Worker;a&&w(a.prototype,Oe,r)}w(XMLHttpRequest.prototype,we,r);var i=t.XMLHttpRequestEventTarget;i&&w(i&&i.prototype,we,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ee,r),w(IDBRequest.prototype,Ee,r),w(IDBOpenDBRequest.prototype,Ee,r),w(IDBDatabase.prototype,Ee,r),w(IDBTransaction.prototype,Ee,r),w(IDBCursor.prototype,Ee,r)),n&&w(WebSocket.prototype,De,r)}else O(),s("XMLHttpRequest"),n&&b(e,t)}}function D(){if((F||q)&&!Object.getOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=Object.getOwnPropertyDescriptor(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t=Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype,"onreadystatechange");if(t){Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return!0}});var n=new XMLHttpRequest,r=!!n.onreadystatechange;return Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",t||{}),r}var o=j("fakeonreadystatechange");Object.defineProperty(XMLHttpRequest.prototype,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return this[o]},set:function(e){this[o]=e}});var n=new XMLHttpRequest,a=function(){};n.onreadystatechange=a;var r=n[o]===a;return n.onreadystatechange=null,r}function O(){for(var e=function(e){var t=Se[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][Ze]&&(t=Zone.current.wrap(o[n],r),t[Ze]=o[n],o[n]=t),o=o.parentElement},!0)},t=0;t",this._properties=t&&t.properties||{},this._zoneDelegate=new f(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(P.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),P[o]=a(e,r,z),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||m).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==Z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==S&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==D&&(e.type==Z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(D,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(O,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(S,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||m).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(D,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===Z&&a&&a.isUsingGlobalCallback?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.apply(e,[c,this,arguments])}}return t.invokeTask=function(e,t,n){e||(e=this),L++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==L&&o(),L--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],k=!1,m={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",D="unknown",O="microTask",S="macroTask",Z="eventTask",P={},z={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!u[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},patchArguments:function(){return a},setNativePromise:function(e){e&&typeof e.resolve===s&&(l=e.resolve(0))}},j={parent:null,zone:new u(null,null)},C=null,L=0;return n("Zone","Zone"),e.Zone=u}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[m];r&&"function"==typeof r&&r.apply(this,[e])}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return I.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=S();if(e===a)throw new TypeError(Z);if(e[_]===w){var s=null;try{typeof a!==P&&typeof a!==j||(s=a&&a.then)}catch(f){return i(function(){u(e,!1,f)})(),e}if(o!==D&&a instanceof I&&a.hasOwnProperty(_)&&a.hasOwnProperty(b)&&a[_]!==w)l(a),u(e,a[_],a[b]);else if(o!==D&&typeof s===j)try{s.apply(a,[i(c(e,o)),i(c(e,!1))])}catch(f){i(function(){u(e,!1,f)})()}else{e[_]=o;var h=e[b];if(e[b]=a,o===D&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[k];d&&Object.defineProperty(a,C,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=j(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[N("OriginalDelegate")]=t}function f(){if(ne)return re;ne=!0;try{var e=X.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(re=!0),re}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=I(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[N(a)]=k[a],E=k[N(i)]=k[i],S=k[N(s)]=k[s];n&&n.prepend&&(_=k[N(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=ae[e.eventName],n=void 0;t&&(n=t[e.capture?q:A]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=j(a,"onmessage");return s&&s.configurable===!1?(r=L(a),o=a,[R,x,"send","close"].forEach(function(e){r[e]=function(){var t=M.call(arguments);if(e===R||e===x){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){var o=T(e,t,n);i(e,o,r)}function E(e,t){if(!J||Q){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(Y){var o=window;w(o,Pe.concat(["messageerror"]),r,I(o)),w(Document.prototype,Pe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Pe,r),w(Element.prototype,Pe,r),w(HTMLElement.prototype,Pe,r),w(HTMLMediaElement.prototype,me,r),w(HTMLFrameSetElement.prototype,ge.concat(Ee),r),w(HTMLBodyElement.prototype,ge.concat(Ee),r),w(HTMLFrameElement.prototype,we,r),w(HTMLIFrameElement.prototype,we,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Se,r);var i=o.Worker;i&&w(i.prototype,Oe,r)}w(XMLHttpRequest.prototype,De,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,De,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ze,r),w(IDBRequest.prototype,Ze,r),w(IDBOpenDBRequest.prototype,Ze,r),w(IDBDatabase.prototype,Ze,r),w(IDBTransaction.prototype,Ze,r),w(IDBCursor.prototype,Ze,r)),n&&w(WebSocket.prototype,ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((Y||Q)&&!j(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=j(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=j(n,t);if(r){C(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return C(n,t,r||{}),a}var i=N("fake");C(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Pe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][je]&&(n=e(a[r],o),n[je]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!u[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(l=e.resolve(0))}},j={parent:null,zone:new u(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=u}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return M.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=O();if(e===a)throw new TypeError(j);if(e[T]===S){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==Z&&a instanceof M&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==S)l(a),u(e,a[T],a[w]);else if(o!==Z&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,o===Z&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,C,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g Date: Thu, 8 Feb 2018 13:46:27 +0900 Subject: [PATCH 009/106] doc(electron): add document for electron patch (#985) --- NON-STANDARD-APIS.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/NON-STANDARD-APIS.md b/NON-STANDARD-APIS.md index 61fe7da1a..b87f2022e 100644 --- a/NON-STANDARD-APIS.md +++ b/NON-STANDARD-APIS.md @@ -162,13 +162,22 @@ import 'zone.js/dist/zone-patch-rxjs'; * electron +In electron, we patched the following APIs with `zone.js` + +1. Browser API +2. NodeJS +3. Electorn Native API + ## Usage. -add following line into `polyfill.ts` after load zone-mix. +add/update following line into `polyfill.ts`. ``` -import 'zone.js/dist/zone-patch-electron'; +//import 'zone.js/dist/zone'; // originally added by angular-cli, comment it out +import 'zone.js/dist/zone-mix'; // add zone-mix to patch both Browser and Nodejs +import 'zone.js/dist/zone-patch-electron'; // add zone-patch-electron to patch Electron native API ``` -there is a sampel repo [zone-electron](https://github.com/JiaLiPassion/zone-electron) here +there is a sampel repo [zone-electron](https://github.com/JiaLiPassion/zone-electron). + From 2dc7e5c72ac2cc7ad21ea5a90456301609a1fd21 Mon Sep 17 00:00:00 2001 From: Dahan Gong Date: Thu, 8 Feb 2018 12:48:03 +0800 Subject: [PATCH 010/106] fix: add OriginalDelegate prop to Function::toString (#993) This makes `Function.prototype.toString.toString()` also returns `"function toString() { [native code] }"`, which should be a little safer. Squashed: store originalFunctionToString only in one place add a test to Function::toString --- lib/common/to-string.ts | 9 +++++---- test/common/toString.spec.ts | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/common/to-string.ts b/lib/common/to-string.ts index a486ff423..ae884a7ac 100644 --- a/lib/common/to-string.ts +++ b/lib/common/to-string.ts @@ -9,15 +9,14 @@ import {zoneSymbol} from './utils'; // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', (global: any, Zone: ZoneType) => { +Zone.__load_patch('toString', (global: any) => { // patch Func.prototype.toString to let them look like native - const originalFunctionToString = (Zone as any)['__zone_symbol__originalToString'] = - Function.prototype.toString; + const originalFunctionToString = Function.prototype.toString; const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); const PROMISE_SYMBOL = zoneSymbol('Promise'); const ERROR_SYMBOL = zoneSymbol('Error'); - Function.prototype.toString = function() { + const newFunctionToString = function toString() { if (typeof this === 'function') { const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { @@ -42,6 +41,8 @@ Zone.__load_patch('toString', (global: any, Zone: ZoneType) => { } return originalFunctionToString.apply(this, arguments); }; + (newFunctionToString as any)[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; // patch Object.prototype.toString to let them look like native diff --git a/test/common/toString.spec.ts b/test/common/toString.spec.ts index 48e7474f0..1eb33c839 100644 --- a/test/common/toString.spec.ts +++ b/test/common/toString.spec.ts @@ -36,6 +36,10 @@ describe('global function patch', () => { expect(Function.prototype.toString.call(Error)).toContain('[native code]'); }); + it('Function toString should look like native', () => { + expect(Function.prototype.toString.call(Function.prototype.toString)).toContain('[native code]'); + }); + it('EventTarget addEventListener should look like native', ifEnvSupports('HTMLElement', () => { expect(Function.prototype.toString.call(HTMLElement.prototype.addEventListener)) .toContain('[native code]'); From b3db9f41a55057e77e9bc5ab8cacb8d6e646871b Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Tue, 16 Jan 2018 22:39:57 +0900 Subject: [PATCH 011/106] feat(patch): fix #828, patch socket.io client --- NON-STANDARD-APIS.md | 17 + gulpfile.js | 10 + lib/extra/socket-io.ts | 24 + package-lock.json | 6168 ++++++++++++------ package.json | 14 +- test/browser/browser.spec.ts | 2 +- test/rxjs/rxjs.Observable.collection.spec.ts | 6 + test/rxjs/rxjs.Observable.merge.spec.ts | 6 + test/rxjs/rxjs.Observable.take.spec.ts | 6 + test/zone-spec/long-stack-trace-zone.spec.ts | 6 + 10 files changed, 4131 insertions(+), 2128 deletions(-) create mode 100644 lib/extra/socket-io.ts diff --git a/NON-STANDARD-APIS.md b/NON-STANDARD-APIS.md index b87f2022e..71826f7c5 100644 --- a/NON-STANDARD-APIS.md +++ b/NON-STANDARD-APIS.md @@ -180,4 +180,21 @@ import 'zone.js/dist/zone-patch-electron'; // add zone-patch-electron to patch E there is a sampel repo [zone-electron](https://github.com/JiaLiPassion/zone-electron). +* socket.io-client + +user need to patch `io` themselves just like following code. + +```javascript + + + + +``` + + +please reference the sample repo [zone-socketio](https://github.com/JiaLiPassion/zone-socketio) about +detail usage. diff --git a/gulpfile.js b/gulpfile.js index b524bf3ca..c79d1970e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -192,6 +192,14 @@ gulp.task('build/zone-patch-user-media.min.js', ['compile-esm'], function(cb) { return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb); }); +gulp.task('build/zone-patch-socket-io.js', ['compile-esm'], function(cb) { + return generateScript('./lib/extra/socket-io.ts', 'zone-patch-socket-io.js', false, cb); +}); + +gulp.task('build/zone-patch-socket-io.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/extra/socket-io.ts', 'zone-patch-socket-io.min.js', true, cb); +}); + gulp.task('build/bluebird.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb); }); @@ -297,6 +305,8 @@ gulp.task('build', [ 'build/zone-patch-electron.min.js', 'build/zone-patch-user-media.js', 'build/zone-patch-user-media.min.js', + 'build/zone-patch-socket-io.js', + 'build/zone-patch-socket-io.min.js', 'build/zone-mix.js', 'build/bluebird.js', 'build/bluebird.min.js', diff --git a/lib/extra/socket-io.ts b/lib/extra/socket-io.ts new file mode 100644 index 000000000..ffb91670a --- /dev/null +++ b/lib/extra/socket-io.ts @@ -0,0 +1,24 @@ +/** + * @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.__load_patch('socketio', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + (Zone as any)[Zone.__symbol__('socketio')] = function patchSocketIO(io: any) { + // patch io.Socket.prototype event listener related method + api.patchEventTarget(global, [io.Socket.prototype], { + useG: false, + chkDup: false, + rt: true, + diff: (task: any, delegate: any) => { + return task.callback === delegate; + } + }); + // also patch io.Socket.prototype.on/off/removeListener/removeAllListeners + io.Socket.prototype.on = io.Socket.prototype.addEventListener; + io.Socket.prototype.off = io.Socket.prototype.removeListener = + io.Socket.prototype.removeAllListeners = io.Socket.prototype.removeEventListener; + }; +}); diff --git a/package-lock.json b/package-lock.json index e0bbd200b..6f7fe34c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "zone.js", - "version": "0.8.18", + "version": "0.8.20", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -10,9 +10,9 @@ "dev": true }, "@types/node": { - "version": "6.0.89", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.89.tgz", - "integrity": "sha512-Z/67L97+6H1qJiEEHSN1SQapkWjDss1D90rAnFcQ6UxKkah9juzotK5UNEP1bDv/0lJ3NAQTnVfc/JWdgCGruA==", + "version": "6.0.96", + "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.96.tgz", + "integrity": "sha512-fsOOY6tMQ3jCB2wD51XFDmmpgm4wVKkJECdcVRqapbJEa7awJDcr+SaH8toz+4r4KW8YQ3M7ybXMoSDo1QGewA==", "dev": true }, "@types/systemjs": { @@ -20,6 +20,24 @@ "integrity": "sha1-R8R+djmGe2aUvrP2DE9TrVXrGxM=", "dev": true }, + "JSONStream": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", + "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + }, + "dependencies": { + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + } + } + }, "accepts": { "version": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", @@ -29,6 +47,12 @@ "negotiator": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz" } }, + "add-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", + "integrity": "sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=", + "dev": true + }, "adm-zip": { "version": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", "integrity": "sha1-hgbCy/HEJs6MjsABdER/1Jtur8E=", @@ -58,15 +82,14 @@ "repeat-string": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" } }, - "amdefine": { - "version": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true - }, - "ansi-escapes": { - "version": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true + "ansi-colors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.0.1.tgz", + "integrity": "sha512-yopkAU0ZD/WQ56Tms3xLn6jRuX3SyUMAVi0FdmDIbmmnHW3jHiI1sQFdUl3gfVddjnrsP3Y6ywFKvCRopvoVIA==", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } }, "ansi-regex": { "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", @@ -78,6 +101,12 @@ "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", "dev": true }, + "ansi-wrap": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", + "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", + "dev": true + }, "anymatch": { "version": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz", "integrity": "sha1-o+Uvo5FoyCX/V7AkgSbOWo/5VQc=", @@ -149,29 +178,6 @@ } } }, - "archiver-utils": { - "version": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-1.3.0.tgz", - "integrity": "sha1-5QtMCccL89aA4y/xt5lOn52JUXQ=", - "dev": true, - "requires": { - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "lazystream": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "normalize-path": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" - }, - "dependencies": { - "lazystream": { - "version": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", - "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" - } - } - } - }, "archy": { "version": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", @@ -190,11 +196,29 @@ "integrity": "sha1-5f/lTUXhnzLyFukeuZyM6JK7YEs=", "dev": true }, + "arr-union": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", + "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", + "dev": true + }, "array-differ": { "version": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", "dev": true }, + "array-find-index": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", + "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "dev": true + }, + "array-ify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", + "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "dev": true + }, "array-slice": { "version": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", @@ -238,6 +262,12 @@ "integrity": "sha1-7nQAlBMALYTOxyGcasgRgS5yMWA=", "dev": true }, + "assign-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", + "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "dev": true + }, "async": { "version": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", @@ -253,11 +283,6 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, - "atob": { - "version": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz", - "integrity": "sha1-lfE2KbEsOlGl0hWr3OKqnzL4B3M=", - "dev": true - }, "attempt-x": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/attempt-x/-/attempt-x-1.1.1.tgz", @@ -274,15 +299,6 @@ "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", "dev": true }, - "babel-runtime": { - "version": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.23.0.tgz", - "integrity": "sha1-CpSJ8UTecO+zzkMArM2zKeL8VDs=", - "dev": true, - "requires": { - "core-js": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz", - "regenerator-runtime": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz" - } - }, "backo2": { "version": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=", @@ -425,11 +441,26 @@ "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", "dev": true }, + "buffer-from": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-0.1.1.tgz", + "integrity": "sha1-V7GLHaChnsBvM4N6UnWiQjUb114=", + "dev": true, + "requires": { + "is-array-buffer-x": "1.7.0" + } + }, "buffer-shims": { "version": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", "dev": true }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, "byline": { "version": "https://registry.npmjs.org/byline/-/byline-4.2.2.tgz", "integrity": "sha1-wgOpilsCkIIqk4anjtosvVvNsy8=", @@ -451,6 +482,22 @@ "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=", "dev": true }, + "camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", + "dev": true + }, + "camelcase-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", + "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", + "dev": true, + "requires": { + "camelcase": "2.1.1", + "map-obj": "1.0.1" + } + }, "capture-stack-trace": { "version": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", @@ -482,6 +529,12 @@ "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz" } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, "chokidar": { "version": "https://registry.npmjs.org/chokidar/-/chokidar-1.6.1.tgz", "integrity": "sha1-L0RHq16W5Q+z14n9kNTHLg5McMI=", @@ -507,39 +560,6 @@ "resolve": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz" } }, - "cli-color": { - "version": "https://registry.npmjs.org/cli-color/-/cli-color-1.1.0.tgz", - "integrity": "sha1-3hiM3Ekp2DtnrqBBEPvtQP2/Z3U=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "es6-iterator": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", - "memoizee": "https://registry.npmjs.org/memoizee/-/memoizee-0.3.10.tgz", - "timers-ext": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.0.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - } - } - }, - "cli-cursor": { - "version": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz" - } - }, - "cli-width": { - "version": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz", - "integrity": "sha1-sjTKIJsp72b8UY2bmNWEewDt8Ao=", - "dev": true - }, "cliui": { "version": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", @@ -625,6 +645,33 @@ "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", "dev": true }, + "compare-func": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", + "integrity": "sha1-md0LpFfh+bxyKxLAjsM+6rMfpkg=", + "dev": true, + "requires": { + "array-ify": "1.0.0", + "dot-prop": "3.0.0" + }, + "dependencies": { + "dot-prop": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz", + "integrity": "sha1-G3CK8JSknJoOfbyteQq6U52sEXc=", + "dev": true, + "requires": { + "is-obj": "1.0.1" + } + }, + "is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", + "dev": true + } + } + }, "component-bind": { "version": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", @@ -674,16 +721,6 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, - "concat-stream": { - "version": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", - "typedarray": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" - } - }, "concurrently": { "version": "https://registry.npmjs.org/concurrently/-/concurrently-2.2.0.tgz", "integrity": "sha1-utJI4LsSn7FiF2iQOmMR1F1WiVo=", @@ -730,683 +767,509 @@ "dev": true }, "conventional-changelog": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.6.tgz", - "integrity": "sha512-AaQRALJYQVbfMs0UYJ3jf5yIAJwGnm/E7ETwzZMwF/3JDMyDaa4agLQomz94pcYiGH7zcrxFcwHApSODOYnunA==", - "dev": true, - "requires": { - "conventional-changelog-angular": "1.5.1", - "conventional-changelog-atom": "0.1.1", - "conventional-changelog-codemirror": "0.2.0", - "conventional-changelog-core": "1.9.2", - "conventional-changelog-ember": "0.2.8", - "conventional-changelog-eslint": "0.2.0", - "conventional-changelog-express": "0.2.0", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.7.tgz", + "integrity": "sha1-kVGmKx2O2y2CcR2r9bfPcQQfgrE=", + "dev": true, + "requires": { + "conventional-changelog-angular": "1.6.0", + "conventional-changelog-atom": "0.1.2", + "conventional-changelog-codemirror": "0.2.1", + "conventional-changelog-core": "1.9.5", + "conventional-changelog-ember": "0.2.10", + "conventional-changelog-eslint": "0.2.1", + "conventional-changelog-express": "0.2.1", "conventional-changelog-jquery": "0.1.0", "conventional-changelog-jscs": "0.1.0", - "conventional-changelog-jshint": "0.2.0" + "conventional-changelog-jshint": "0.2.1" + } + }, + "conventional-changelog-angular": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.6.0.tgz", + "integrity": "sha1-CiagcfLJ/PzyuGugz79uYwG3W/o=", + "dev": true, + "requires": { + "compare-func": "1.3.2", + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-atom": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-0.1.2.tgz", + "integrity": "sha1-Ella1SZ6aTfDTPkAKBscZRmKTGM=", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-codemirror": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.2.1.tgz", + "integrity": "sha1-KZpPcUe681DmyBWPxUlUopHFzAk=", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-core": { + "version": "1.9.5", + "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-1.9.5.tgz", + "integrity": "sha1-XbdWba18DLddr0f7spdve/mSjB0=", + "dev": true, + "requires": { + "conventional-changelog-writer": "2.0.3", + "conventional-commits-parser": "2.1.0", + "dateformat": "1.0.12", + "get-pkg-repo": "1.4.0", + "git-raw-commits": "1.3.0", + "git-remote-origin-url": "2.0.0", + "git-semver-tags": "1.2.3", + "lodash": "4.17.4", + "normalize-package-data": "2.4.0", + "q": "1.5.1", + "read-pkg": "1.1.0", + "read-pkg-up": "1.0.1", + "through2": "2.0.3" }, "dependencies": { - "array-find-index": { + "core-util-is": { "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "requires": { - "camelcase": "2.1.1", - "map-obj": "1.0.1" - } - }, - "compare-func": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", - "integrity": "sha1-md0LpFfh+bxyKxLAjsM+6rMfpkg=", - "dev": true, - "requires": { - "array-ify": "1.0.0", - "dot-prop": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz" - } + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true }, - "conventional-changelog-angular": { + "q": { "version": "1.5.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.5.1.tgz", - "integrity": "sha512-AnjnPyqHp8yR2IOWsXYOCv6Ly0WC2rLRK04fgAS/5QoA3ovYLSoz9PKB5pcSG3M9lAf40IqZwU3R3G6Hy7XCSA==", - "dev": true, - "requires": { - "compare-func": "1.3.2", - "q": "1.5.0" - } - }, - "conventional-changelog-atom": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-0.1.1.tgz", - "integrity": "sha512-6Nlu/+MiD4gi7k3Z+N1vMJWpaPSdvFPWzPGnH4OXewHAxiAl0L/TT9CGgA01fosPxmYr4hMNtD7kyN0tkg8vIA==", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-codemirror": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.2.0.tgz", - "integrity": "sha512-jUbY98JoKdAOR5k3pOBiKZ+Iz9t2F84hL7x4WjSRW6x7FdeCEUOjyfml+YClE2h/h62Tf3mwur5jSO8upxxc1g==", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-core": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-1.9.2.tgz", - "integrity": "sha512-L/boGKXaKWrlCU8bHa1QM36Pb/JopCPmekj5SFqqAuBfjya860xX2fAC5Ggelse++Bw39AZ2NrHwBnJrdwLlLw==", - "dev": true, - "requires": { - "conventional-changelog-writer": "2.0.1", - "conventional-commits-parser": "2.0.0", - "dateformat": "1.0.12", - "get-pkg-repo": "1.4.0", - "git-raw-commits": "1.2.0", - "git-remote-origin-url": "2.0.0", - "git-semver-tags": "1.2.2", - "lodash": "4.17.4", - "normalize-package-data": "2.4.0", - "q": "1.5.0", - "read-pkg": "1.1.0", - "read-pkg-up": "1.0.1", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } - }, - "conventional-changelog-ember": { - "version": "0.2.8", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.2.8.tgz", - "integrity": "sha512-smsh0o/S95n22lrQZrSHYjJrxIGoFl+OFHK+q2KGHA2zRFrW7QilYM7VUjgmB+emzwqFguPjrq+D2U8iPhMNJg==", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-eslint": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-0.2.0.tgz", - "integrity": "sha512-WGKnC0bGPD6BHGiRBfYqNGfy6DZDn2jGs1yxPRT8I2796wYdGqsbDF4477o4fdsxUJvckoW2OFPqkmRMQaCHSA==", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-express": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-0.2.0.tgz", - "integrity": "sha512-ujSEmbWfozC1iIjH5Pl7AKtREowvAl10whs1q6c7nZLnoNZK5CmdB2PQ/V42O6rCgUzaLX+ACRW2+g0A/Htqvw==", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-jquery": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz", - "integrity": "sha1-Agg5cWLjhGmG5xJztsecW1+A9RA=", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-jscs": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz", - "integrity": "sha1-BHnrRDzH1yxYvwvPDvHURKkvDlw=", - "dev": true, - "requires": { - "q": "1.5.0" - } - }, - "conventional-changelog-jshint": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-0.2.0.tgz", - "integrity": "sha512-uUP4c0et6F2teapl+YY2JHFAHD401U5CkgI+P8PyU0y1zS8BdBy6EnhqgZEXhFOp9fPzUdic+Wv/9alOqw3agQ==", - "dev": true, - "requires": { - "compare-func": "1.3.2", - "q": "1.5.0" - } - }, - "conventional-changelog-writer": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-2.0.1.tgz", - "integrity": "sha512-X4qC758celQOKw0iUPAsH5sJX6fH6N5dboFc3elXb1/SIKhsYMukhhaxWmxRdtVUSqGt9rZg8giwBQG5B2GeKg==", - "dev": true, - "requires": { - "compare-func": "1.3.2", - "conventional-commits-filter": "1.0.0", - "dateformat": "1.0.12", - "handlebars": "4.0.10", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "lodash": "4.17.4", - "meow": "3.7.0", - "semver": "5.4.1", - "split": "1.0.1", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true }, - "conventional-commits-filter": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.0.0.tgz", - "integrity": "sha1-b8KmWTcrw/IznPn//34bA0S5MDk=", + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "is-subset": "0.1.1", - "modify-values": "1.0.0" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, - "conventional-commits-parser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.0.0.tgz", - "integrity": "sha512-8od6g684Fhi5Vpp4ABRv/RBsW1AY6wSHbJHEK6FGTv+8jvAAnlABniZu/FVmX9TcirkHepaEsa1QGkRvbg0CKw==", - "dev": true, - "requires": { - "is-text-path": "1.0.1", - "JSONStream": "1.3.1", - "lodash": "4.17.4", - "meow": "3.7.0", - "split2": "2.2.0", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "trim-off-newlines": "1.0.1" - } + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "array-find-index": "1.0.2" + "safe-buffer": "5.1.1" } }, - "dargs": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/dargs/-/dargs-4.1.0.tgz", - "integrity": "sha1-A6nbtLXC8Tm/FK5T8LiipqhvThc=", + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" + "readable-stream": "2.3.3", + "xtend": "4.0.1" } }, - "dateformat": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", - "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", - "dev": true, - "requires": { - "get-stdin": "4.0.1", - "meow": "3.7.0" - } + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } - }, - "get-pkg-repo": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz", - "integrity": "sha1-xztInAbYDMVTbCyFP54FIyBWly0=", - "dev": true, - "requires": { - "hosted-git-info": "2.5.0", - "meow": "3.7.0", - "normalize-package-data": "2.4.0", - "parse-github-repo-url": "1.4.1", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } - }, - "get-stdin": { + "xtend": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true - }, - "git-raw-commits": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-1.2.0.tgz", - "integrity": "sha1-DzqL/ZmuDy2LkiTViJKXXppS0Dw=", - "dev": true, - "requires": { - "dargs": "4.1.0", - "lodash.template": "4.4.0", - "meow": "3.7.0", - "split2": "2.2.0", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } - }, - "git-remote-origin-url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz", - "integrity": "sha1-UoJlna4hBxRaERJhEq0yFuxfpl8=", - "dev": true, - "requires": { - "gitconfiglocal": "1.0.0", - "pify": "2.3.0" - } - }, - "git-semver-tags": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-1.2.2.tgz", - "integrity": "sha512-fhINopzKBQ8m6YlQt7gPf6T6hFnTF84O7U+8kYJmfjjKk7gbmKGj+BLcKNWi+japPbBwCeXXnfKwThpJpR9ZnQ==", - "dev": true, - "requires": { - "meow": "3.7.0", - "semver": "5.4.1" - } - }, - "gitconfiglocal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz", - "integrity": "sha1-QdBF84UaXqiPA/JMocYXgRRGS5s=", - "dev": true, - "requires": { - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + } + } + }, + "conventional-changelog-ember": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.2.10.tgz", + "integrity": "sha512-LBBBZO6Q7ib4HhSdyCNVR25OtaXl710UJg1aSHCLmR8AjuXKs3BO8tnbY1MH+D1C+z5IFoEDkpjOddefNTyhCQ==", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true - }, - "handlebars": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.10.tgz", - "integrity": "sha1-PTDHGLCaPZbyPqTMH0A8TTup/08=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "optimist": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "source-map": "0.4.4", - "uglify-js": "2.8.29" - } - }, - "hosted-git-info": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + } + } + }, + "conventional-changelog-eslint": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-0.2.1.tgz", + "integrity": "sha1-LCoRvrIW+AZJunKDQYApO2h8BmI=", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-express": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-0.2.1.tgz", + "integrity": "sha1-g42eHmyQmXA7FQucGaoteBdCvWw=", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-jquery": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz", + "integrity": "sha1-Agg5cWLjhGmG5xJztsecW1+A9RA=", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-jscs": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz", + "integrity": "sha1-BHnrRDzH1yxYvwvPDvHURKkvDlw=", + "dev": true, + "requires": { + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-jshint": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-0.2.1.tgz", + "integrity": "sha1-hhObs6yZiZ8rF36WF+CbN9mbzzo=", + "dev": true, + "requires": { + "compare-func": "1.3.2", + "q": "1.5.1" + }, + "dependencies": { + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + } + } + }, + "conventional-changelog-writer": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-2.0.3.tgz", + "integrity": "sha512-2E1h7UXL0fhRO5h0CxDZ5EBc5sfBZEQePvuZ+gPvApiRrICUyNDy/NQIP+2TBd4wKZQf2Zm7TxbzXHG5HkPIbA==", + "dev": true, + "requires": { + "compare-func": "1.3.2", + "conventional-commits-filter": "1.1.1", + "dateformat": "1.0.12", + "handlebars": "4.0.11", + "json-stringify-safe": "5.0.1", + "lodash": "4.17.4", + "meow": "3.7.0", + "semver": "5.5.0", + "split": "1.0.1", + "through2": "2.0.3" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz" - } + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, - "is-builtin-module": { + "isarray": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "1.1.1" - } - }, - "is-subset": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", - "integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "is-text-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", - "dev": true, - "requires": { - "text-extensions": "1.7.0" - } - }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "parse-json": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "pify": "2.3.0", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "strip-bom": "2.0.0" - } - }, "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, - "lodash.template": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz", - "integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=", - "dev": true, - "requires": { - "lodash._reinterpolate": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "lodash.templatesettings": "4.1.0" - } + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true }, - "lodash.templatesettings": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz", - "integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=", + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "lodash._reinterpolate": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, - "requires": { - "currently-unhandled": "0.4.1", - "signal-exit": "3.0.2" - } + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "dev": true }, - "meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "camelcase-keys": "2.1.0", - "decamelize": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "loud-rejection": "1.6.0", - "map-obj": "1.0.1", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "normalize-package-data": "2.4.0", - "object-assign": "4.1.1", - "read-pkg-up": "1.0.1", - "redent": "1.0.0", - "trim-newlines": "1.0.0" + "safe-buffer": "5.1.1" } }, - "modify-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.0.tgz", - "integrity": "sha1-4rbN65zhn5kxelNyLz2/XfXqqrI=", - "dev": true - }, - "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "hosted-git-info": "2.5.0", - "is-builtin-module": "1.0.0", - "semver": "5.4.1", - "validate-npm-package-license": "3.0.1" + "readable-stream": "2.3.3", + "xtend": "4.0.1" } }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "parse-github-repo-url": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz", - "integrity": "sha1-nn2LslKmy2ukJZUGC3v23z28H1A=", + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "conventional-commits-filter": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.1.tgz", + "integrity": "sha512-bQyatySNKHhcaeKVr9vFxYWA1W1Tdz6ybVMYDmv4/FhOXY1+fchiW07TzRbIQZhVa4cvBwrEaEUQBbCncFSdJQ==", + "dev": true, + "requires": { + "is-subset": "0.1.1", + "modify-values": "1.0.0" + } + }, + "conventional-commits-parser": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.0.tgz", + "integrity": "sha512-8MD05yN0Zb6aRsZnFX1ET+8rHWfWJk+my7ANCJZBU2mhz7TSB1fk2vZhkrwVy/PCllcTYAP/1T1NiWQ7Z01mKw==", + "dev": true, + "requires": { + "JSONStream": "1.3.2", + "is-text-path": "1.0.1", + "lodash": "4.17.4", + "meow": "3.7.0", + "split2": "2.2.0", + "through2": "2.0.3", + "trim-off-newlines": "1.0.1" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "pify": "2.3.0", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, - "q": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.0.tgz", - "integrity": "sha1-3QG6ydBtMObyGa7LglPunr3DCPE=", + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "load-json-file": "1.1.0", - "normalize-package-data": "2.4.0", - "path-type": "1.1.0" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "find-up": "1.1.2", - "read-pkg": "1.1.0" + "safe-buffer": "5.1.1" } }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "indent-string": "2.1.0", - "strip-indent": "1.0.1" + "readable-stream": "2.3.3", + "xtend": "4.0.1" } }, - "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true - }, - "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", - "dev": true, - "requires": { - "amdefine": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" - } - }, - "spdx-correct": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", - "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", - "dev": true, - "requires": { - "spdx-license-ids": "1.2.2" - } - }, - "spdx-expression-parse": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", - "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", - "dev": true - }, - "spdx-license-ids": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", - "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", - "dev": true - }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, - "split2": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", - "dev": true, - "requires": { - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" - } - }, - "strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "requires": { - "get-stdin": "4.0.1" - } - }, - "text-extensions": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.7.0.tgz", - "integrity": "sha512-AKXZeDq230UaSzaO5s3qQUZOaC7iKbzq0jOFL614R7d9R593HLqAOL0cYoqLdkNrjBSOdmoQI06yigq1TSBXAg==", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true - }, - "trim-off-newlines": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz", - "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", - "dev": true - }, - "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", - "dev": true, - "optional": true, - "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "yargs": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz" - }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "optional": true - } - } - }, - "validate-npm-package-license": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", - "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", - "dev": true, - "requires": { - "spdx-correct": "1.0.2", - "spdx-expression-parse": "1.0.4" - } } } }, @@ -1425,11 +1288,6 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "crc": { - "version": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", - "integrity": "sha1-naHpgOO9RPxck79as9ozeNheRms=", - "dev": true - }, "crc32-stream": { "version": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-0.3.4.tgz", "integrity": "sha1-c7wltF+sHbZjIjGnv86JJ+nwZVI=", @@ -1487,56 +1345,40 @@ "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", "dev": true }, - "css": { - "version": "https://registry.npmjs.org/css/-/css-2.2.1.tgz", - "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "source-map": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "source-map-resolve": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz", - "urix": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz" - }, - "dependencies": { - "source-map": { - "version": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "requires": { - "amdefine": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz" - } - } - } - }, - "css-parse": { - "version": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz", - "integrity": "sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q=", - "dev": true, - "requires": { - "css": "https://registry.npmjs.org/css/-/css-2.2.1.tgz" - } - }, - "css-value": { - "version": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", - "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", - "dev": true - }, "ctype": { "version": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz", "integrity": "sha1-gsGMJGH3QRTvFsE1IkrQuRRMoS8=", "dev": true }, + "currently-unhandled": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", + "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", + "dev": true, + "requires": { + "array-find-index": "1.0.2" + } + }, "custom-event": { "version": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", "dev": true }, - "d": { - "version": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "integrity": "sha1-2hhMU10Y2O57oqoim5FACfrhEwk=", + "dargs": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/dargs/-/dargs-4.1.0.tgz", + "integrity": "sha1-A6nbtLXC8Tm/FK5T8LiipqhvThc=", "dev": true, "requires": { - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" + "number-is-nan": "1.0.1" + }, + "dependencies": { + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + } } }, "dashdash": { @@ -1554,6 +1396,16 @@ } } }, + "dateformat": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", + "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", + "dev": true, + "requires": { + "get-stdin": "4.0.1", + "meow": "3.7.0" + } + }, "deap": { "version": "https://registry.npmjs.org/deap/-/deap-1.0.0.tgz", "integrity": "sha1-sUi/gkMKJ2mbdIOgPra2dYW/yIg=", @@ -1577,11 +1429,6 @@ "integrity": "sha1-7+QRPQgIX05vlod1mBD4B0aeIlM=", "dev": true }, - "deepmerge": { - "version": "https://registry.npmjs.org/deepmerge/-/deepmerge-1.3.2.tgz", - "integrity": "sha1-FmNpFinU2/42T6EqKk8KqGqjoFA=", - "dev": true - }, "defaults": { "version": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", @@ -1632,11 +1479,6 @@ "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", "dev": true }, - "diff": { - "version": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", - "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", - "dev": true - }, "dom-serialize": { "version": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", @@ -1648,19 +1490,6 @@ "void-elements": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz" } }, - "dot-prop": { - "version": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz", - "integrity": "sha1-G3CK8JSknJoOfbyteQq6U52sEXc=", - "dev": true, - "requires": { - "is-obj": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz" - } - }, - "duplexer": { - "version": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", - "dev": true - }, "duplexer2": { "version": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", @@ -1707,11 +1536,6 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", "dev": true }, - "ejs": { - "version": "https://registry.npmjs.org/ejs/-/ejs-2.5.6.tgz", - "integrity": "sha1-R5Y2v6P+Ox3r1SCH8KyyBLTxnIg=", - "dev": true - }, "emojis-list": { "version": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", @@ -1820,79 +1644,11 @@ "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", "dev": true }, - "error-ex": { - "version": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.0.tgz", - "integrity": "sha1-5ntD8+gsluo6WE/+4Ln8MyXYAtk=", - "dev": true, - "requires": { - "is-arrayish": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz" - } - }, - "es5-ext": { - "version": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "integrity": "sha1-qoRkHU23a2Krul5F/YBey6sUAEc=", - "dev": true, - "requires": { - "es6-iterator": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", - "es6-symbol": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz" - } - }, - "es6-iterator": { - "version": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", - "integrity": "sha1-vZaFZ9YWNeM8C4BydhPJy0sJa6w=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "es6-symbol": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz" - } - }, "es6-promise": { "version": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=", "dev": true }, - "es6-symbol": { - "version": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz", - "integrity": "sha1-lEgcZV56fK2C66gy2X1UM0ltf/o=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" - } - }, - "es6-weak-map": { - "version": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-0.1.4.tgz", - "integrity": "sha1-cGzvnpmqI2undmwjnIueKG6n0ig=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "es6-iterator": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz", - "es6-symbol": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz" - }, - "dependencies": { - "es6-iterator": { - "version": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-0.1.3.tgz", - "integrity": "sha1-1vWLjE/EE8JJtLqhl2j45NfIlE4=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "es6-symbol": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz" - } - }, - "es6-symbol": { - "version": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-2.0.1.tgz", - "integrity": "sha1-dhtcZ8/U8dGK+yNPaR1nhoLLO/M=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" - } - } - } - }, "escape-html": { "version": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", @@ -1903,39 +1659,6 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "event-emitter": { - "version": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.4.tgz", - "integrity": "sha1-jWPd+0z+H647MsomXExyAiIIC7U=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" - } - }, - "event-stream": { - "version": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "dev": true, - "requires": { - "duplexer": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "from": "https://registry.npmjs.org/from/-/from-0.1.3.tgz", - "map-stream": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "pause-stream": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "split": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "stream-combiner": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - }, - "dependencies": { - "split": { - "version": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", - "dev": true, - "requires": { - "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - } - } - } - }, "eventemitter3": { "version": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=", @@ -2000,11 +1723,6 @@ } } }, - "exit": { - "version": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true - }, "expand-braces": { "version": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", @@ -2073,20 +1791,24 @@ "integrity": "sha1-WkdDU7nzNT3dgXbf03uRyDpG8dQ=", "dev": true }, - "external-editor": { - "version": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz", - "integrity": "sha1-HtkZnanL/i7y96MbL96LDRI2iXI=", + "extend-shallow": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", + "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, "requires": { - "iconv-lite": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz", - "jschardet": "https://registry.npmjs.org/jschardet/-/jschardet-1.5.0.tgz", - "tmp": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz" + "assign-symbols": "1.0.0", + "is-extendable": "1.0.1" }, "dependencies": { - "iconv-lite": { - "version": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz", - "integrity": "sha1-I9hlaxaq5nQqwpcy6o8DNqR4nPI=", - "dev": true + "is-extendable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", + "dev": true, + "requires": { + "is-plain-object": "2.0.4" + } } } }, @@ -2211,6 +1933,18 @@ } } }, + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "fd-slicer": { "version": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", @@ -2219,14 +1953,6 @@ "pend": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz" } }, - "figures": { - "version": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz" - } - }, "filename-regex": { "version": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz", "integrity": "sha1-mW4+gEebmLmJfxWopYs9CE6SZ3U=", @@ -2276,6 +2002,33 @@ "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", "dev": true }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + } + } + }, "findup-sync": { "version": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", @@ -2367,11 +2120,6 @@ "samsam": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz" } }, - "from": { - "version": "https://registry.npmjs.org/from/-/from-0.1.3.tgz", - "integrity": "sha1-72OsIGKsMqz3hi4NQLRLiW8i87w=", - "dev": true - }, "fs-access": { "version": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", @@ -2421,6 +2169,103 @@ "is-property": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz" } }, + "get-pkg-repo": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz", + "integrity": "sha1-xztInAbYDMVTbCyFP54FIyBWly0=", + "dev": true, + "requires": { + "hosted-git-info": "2.5.0", + "meow": "3.7.0", + "normalize-package-data": "2.4.0", + "parse-github-repo-url": "1.4.1", + "through2": "2.0.3" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "dev": true + }, "get-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", @@ -2442,14 +2287,158 @@ } } }, - "glob": { - "version": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "git-raw-commits": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-1.3.0.tgz", + "integrity": "sha1-C8hZbpDV/+c29/VUa9LRL3OrqsY=", "dev": true, "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "dargs": "4.1.0", + "lodash.template": "4.4.0", + "meow": "3.7.0", + "split2": "2.2.0", + "through2": "2.0.3" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "git-remote-origin-url": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz", + "integrity": "sha1-UoJlna4hBxRaERJhEq0yFuxfpl8=", + "dev": true, + "requires": { + "gitconfiglocal": "1.0.0", + "pify": "2.3.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, + "git-semver-tags": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-1.2.3.tgz", + "integrity": "sha1-GItFOIK/nXojr9Mbq6U32rc4jV0=", + "dev": true, + "requires": { + "meow": "3.7.0", + "semver": "5.5.0" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } + } + }, + "gitconfiglocal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz", + "integrity": "sha1-QdBF84UaXqiPA/JMocYXgRRGS5s=", + "dev": true, + "requires": { + "ini": "1.3.5" + }, + "dependencies": { + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true + } + } + }, + "glob": { + "version": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" @@ -2808,358 +2797,345 @@ } }, "gulp-clang-format": { - "version": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.23.tgz", - "integrity": "sha1-/iWFhrg5mEkeYy/AxPwOzfoQyJ8=", + "version": "1.0.25", + "resolved": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.25.tgz", + "integrity": "sha512-YSYk3st/ktKrBWfnDSutYZU9pLnCdaeJBTT8YguTJJLkQjSFZjBCBquecSXfoWW+NcVfGuei3N7vs7xuSR+2bg==", "dev": true, "requires": { "clang-format": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.46.tgz", - "gulp-diff": "https://registry.npmjs.org/gulp-diff/-/gulp-diff-1.0.0.tgz", + "gulp-diff": "1.0.0", "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "pkginfo": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", - "stream-combiner2": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "stream-equal": "https://registry.npmjs.org/stream-equal/-/stream-equal-0.1.6.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz" + "pkginfo": "0.3.1", + "stream-combiner2": "1.1.1", + "stream-equal": "0.1.6", + "through2": "0.6.5" }, "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "cli-color": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-1.2.0.tgz", + "integrity": "sha1-OlrnT9drYmevZm5p4q+70B3vNNE=", "dev": true, "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + "ansi-regex": "2.1.1", + "d": "1.0.0", + "es5-ext": "0.10.38", + "es6-iterator": "2.0.3", + "memoizee": "0.4.11", + "timers-ext": "0.1.2" } }, - "through2": { - "version": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "d": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", + "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" + "es5-ext": "0.10.38" } - } - } - }, - "gulp-conventional-changelog": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/gulp-conventional-changelog/-/gulp-conventional-changelog-1.1.6.tgz", - "integrity": "sha512-zJ3ZfEukUqzLmFTWA5r8k9D4UAsymq+zsgINJmTRhw+H6Q1O9iCgREeye0gxicmusm6z6jI0fz5wLvlS66cmFg==", - "dev": true, - "requires": { - "add-stream": "1.0.0", - "concat-stream": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "conventional-changelog": "1.1.6", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "object-assign": "4.1.1", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - }, - "dependencies": { - "add-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", - "integrity": "sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=", - "dev": true }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "diff": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", + "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", "dev": true - } - } - }, - "gulp-diff": { - "version": "https://registry.npmjs.org/gulp-diff/-/gulp-diff-1.0.0.tgz", - "integrity": "sha1-EBsjcS3WsQe9B9BauI6jrEhf7Xc=", - "dev": true, - "requires": { - "cli-color": "https://registry.npmjs.org/cli-color/-/cli-color-1.1.0.tgz", - "diff": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", - "event-stream": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } - }, - "gulp-rename": { - "version": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz", - "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=", - "dev": true - }, - "gulp-rollup": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/gulp-rollup/-/gulp-rollup-2.15.0.tgz", - "integrity": "sha512-CIKB5ce83xBzloMj5Cf17yeXc46BXWhPh8dICtpeLVZvqdKPmLlSAKy0Txf848PO9Ijcr0Jsror7gLi7ZIop/A==", - "dev": true, - "requires": { - "buffer-from": "0.1.1", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "readable-stream": "2.3.3", - "rollup": "0.49.3", - "rollup-plugin-hypothetical": "1.2.1" - }, - "dependencies": { - "buffer-from": { + }, + "duplexer": { "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-0.1.1.tgz", - "integrity": "sha1-V7GLHaChnsBvM4N6UnWiQjUb114=", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "dev": true + }, + "duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", "dev": true, "requires": { - "is-array-buffer-x": "1.7.0" + "readable-stream": "2.3.3" } }, - "has-symbol-support-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", - "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", - "dev": true + "es5-ext": { + "version": "0.10.38", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.38.tgz", + "integrity": "sha512-jCMyePo7AXbUESwbl8Qi01VSH2piY9s/a3rSU/5w/MlTIx8HPL1xn2InGN8ejt/xulcJgnTO7vqNtOAxzYd2Kg==", + "dev": true, + "requires": { + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" + } }, - "has-to-string-tag-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", - "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { - "has-symbol-support-x": "1.4.1" + "d": "1.0.0", + "es5-ext": "0.10.38", + "es6-symbol": "3.1.1" } }, - "is-array-buffer-x": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/is-array-buffer-x/-/is-array-buffer-x-1.7.0.tgz", - "integrity": "sha512-ufSZRMY2WZX5xyNvk0NOZAG7cgi35B/sGQDGqv8w0X7MoQ2GC9vedanJhuYTPaC4PUCqLQsda1w7NF+dPZmAJw==", + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true, "requires": { - "attempt-x": "1.1.1", - "has-to-string-tag-x": "1.4.1", - "is-object-like-x": "1.5.1", - "object-get-own-property-descriptor-x": "3.2.0", - "to-string-tag-x": "1.4.2" + "d": "1.0.0", + "es5-ext": "0.10.38" } }, - "is-function-x": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/is-function-x/-/is-function-x-3.2.0.tgz", - "integrity": "sha512-ANQAythCIUKu0UprLZubZsYwAhYcNoM/FlrQSyFIXDoBzeGcHo6SHNPHCAl/T7UQyNiGzBirfUq0znic8P/Bew==", + "es6-weak-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", + "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true, "requires": { - "attempt-x": "1.1.1", - "has-to-string-tag-x": "1.4.1", - "is-falsey-x": "1.0.1", - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "normalize-space-x": "2.0.0", - "replace-comments-x": "2.0.0", - "to-boolean-x": "1.0.1", - "to-string-tag-x": "1.4.2" + "d": "1.0.0", + "es5-ext": "0.10.38", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" } }, - "is-object-like-x": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/is-object-like-x/-/is-object-like-x-1.5.1.tgz", - "integrity": "sha512-AtUeYE4Xs8EbuHuG6yBHiLdIlWRPPFidcIs3JE6PJZ/mzUQFOK8X5J1OA+3cVi0rlrdUCjiX52obtCV2hxs+HA==", + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true, "requires": { - "is-function-x": "3.2.0", - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz" + "d": "1.0.0", + "es5-ext": "0.10.38" } }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "event-stream": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "dev": true, + "requires": { + "duplexer": "0.1.1", + "from": "0.1.7", + "map-stream": "0.1.0", + "pause-stream": "0.0.11", + "split": "0.3.3", + "stream-combiner": "0.0.4", + "through": "2.3.8" + } }, - "lodash.isnull": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz", - "integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4=", + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", "dev": true }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "gulp-diff": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulp-diff/-/gulp-diff-1.0.0.tgz", + "integrity": "sha1-EBsjcS3WsQe9B9BauI6jrEhf7Xc=", "dev": true, "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "1.0.0", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "string_decoder": "1.0.3", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + "cli-color": "1.2.0", + "diff": "2.2.3", + "event-stream": "3.3.4", + "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "through2": "2.0.3" + }, + "dependencies": { + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + } } }, - "rollup": { - "version": "0.49.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.49.3.tgz", - "integrity": "sha512-n/vHRX4GhMIyGZEQRANcSFVtvz99bSRbNMuoC33ar9f4CViqffyF9WklLb2mxIQ6I/uFf7wDEpc66bXBFE7FvA==", + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "rollup-plugin-hypothetical": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-hypothetical/-/rollup-plugin-hypothetical-1.2.1.tgz", - "integrity": "sha1-9CcHe3urWSzCmBl6uaqsT+TvoFU=", + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "lru-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", + "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", "dev": true, "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" + "es5-ext": "0.10.38" } }, - "to-string-tag-x": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/to-string-tag-x/-/to-string-tag-x-1.4.2.tgz", - "integrity": "sha512-ytO9eLigxsQQLGuab0C1iSSTzKdJNVSlBg0Spg4J/rGAVrQJ5y774mo0SSzgGeTT4RJGGyJNfObXaTMzX0XDOQ==", + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "dev": true + }, + "memoizee": { + "version": "0.4.11", + "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.11.tgz", + "integrity": "sha1-vemBdmPJ5A/bKk6hw2cpYIeujI8=", "dev": true, "requires": { - "lodash.isnull": "3.0.0", - "validate.io-undefined": "1.0.3" + "d": "1.0.0", + "es5-ext": "0.10.38", + "es6-weak-map": "2.0.2", + "event-emitter": "0.3.5", + "is-promise": "2.1.0", + "lru-queue": "0.1.0", + "next-tick": "1.0.0", + "timers-ext": "0.1.2" } }, - "validate.io-undefined": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz", - "integrity": "sha1-fif8uzFbhB54JDQxiXZxkp4gt/Q=", + "next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true - } - } - }, - "gulp-tsc": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/gulp-tsc/-/gulp-tsc-1.3.2.tgz", - "integrity": "sha1-Wmb4CvOXYAXm9fBrnPzLDm1zmc4=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "byline": "https://registry.npmjs.org/byline/-/byline-4.2.2.tgz", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "lodash": "3.10.1", - "node-version-compare": "https://registry.npmjs.org/node-version-compare/-/node-version-compare-1.0.1.tgz", - "resolve": "1.4.0", - "rimraf": "2.6.2", - "temp": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "vinyl-fs": "1.0.0", - "which": "1.3.0" - }, - "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "dev": true, + "requires": { + "through": "2.3.8" + } + }, + "pkginfo": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", + "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", "dev": true }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "balanced-match": "1.0.0", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, - "clone": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, - "duplexify": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz", - "integrity": "sha512-j5goxHTwVED1Fpe5hh3q9R93Kip0Bg2KVAt4f8CEYM3UEwYcPSvWbXaUQOzdX/HtiNomipv+gU7ASQPDbV7pGQ==", + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", "dev": true, "requires": { - "end-of-stream": "1.4.0", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "readable-stream": "2.3.3", - "stream-shift": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz" + "through": "2.3.8" } }, - "end-of-stream": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", - "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", "dev": true, "requires": { - "once": "1.4.0" + "duplexer": "0.1.1" } }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "stream-combiner2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", + "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", "dev": true, "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" + "duplexer2": "0.1.4", + "readable-stream": "2.3.3" } }, - "glob-stream": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-4.1.1.tgz", - "integrity": "sha1-uELfENaIx+trz869hG84UilrMgA=", + "stream-equal": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/stream-equal/-/stream-equal-0.1.6.tgz", + "integrity": "sha1-zFIvqzhRYBLk1O5HUTsUe3I1kBk=", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "glob": "4.5.3", - "glob2base": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "minimatch": "2.0.10", - "ordered-read-streams": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "through2": "0.6.5", - "unique-stream": "2.2.1" + "safe-buffer": "5.1.1" + } + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "4.0.1" }, "dependencies": { - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "2.0.10", - "once": "1.4.0" - } - }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, "readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", "dev": true, "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "0.0.1", "string_decoder": "0.10.31" } @@ -3169,78 +3145,87 @@ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } } } }, - "glob-watcher": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.8.tgz", - "integrity": "sha1-aK62Yefizo02NDgbLsQV8AxrwqQ=", + "timers-ext": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.2.tgz", + "integrity": "sha1-YcxHp2wavTGV8UUn+XjViulMUgQ=", "dev": true, "requires": { - "gaze": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz" + "es5-ext": "0.10.38", + "next-tick": "1.0.0" } }, - "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "gulp-conventional-changelog": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/gulp-conventional-changelog/-/gulp-conventional-changelog-1.1.7.tgz", + "integrity": "sha1-Azf2hLSeKTWOYj4W6UtJ8FotK/E=", + "dev": true, + "requires": { + "add-stream": "1.0.0", + "concat-stream": "1.6.0", + "conventional-changelog": "1.1.7", + "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "object-assign": "4.1.1", + "through2": "2.0.3" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", "dev": true, "requires": { - "natives": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" + "inherits": "2.0.3", + "readable-stream": "2.3.3", + "typedarray": "0.0.6" } }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, "object-assign": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", - "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true }, "readable-stream": { "version": "2.3.3", @@ -3248,32 +3233,20 @@ "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "core-util-is": "1.0.2", + "inherits": "2.0.3", "isarray": "1.0.0", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", "string_decoder": "1.0.3", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - } - }, - "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", - "dev": true, - "requires": { - "path-parse": "1.0.5" + "util-deprecate": "1.0.2" } }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true }, "string_decoder": { "version": "1.0.3", @@ -3281,63 +3254,308 @@ "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" + "safe-buffer": "5.1.1" } }, - "strip-bom": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", "dev": true, "requires": { - "first-chunk-stream": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" + "readable-stream": "2.3.3", + "xtend": "4.0.1" } }, - "unique-stream": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.2.1.tgz", - "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", - "dev": true, - "requires": { - "json-stable-stringify": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "through2-filter": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz" - } + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true }, - "vinyl": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "gulp-rename": { + "version": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz", + "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=", + "dev": true + }, + "gulp-rollup": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/gulp-rollup/-/gulp-rollup-2.16.2.tgz", + "integrity": "sha512-Gs9NYcUl0xXod7qenC1Lm49a/PGllAa5ONyCXu29lXfkP1oJnJzSdPBjopm9RlOVhefadbHlfy9AijovFrqABA==", + "dev": true, + "requires": { + "buffer-from": "0.1.1", + "plugin-error": "1.0.1", + "readable-stream": "2.3.3", + "rollup": "0.54.1", + "rollup-plugin-hypothetical": "2.1.0", + "vinyl": "2.1.0" + }, + "dependencies": { + "clone": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", + "integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=", + "dev": true + }, + "clone-buffer": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", + "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", + "dev": true + }, + "clone-stats": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", + "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", + "dev": true + }, + "cloneable-readable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.0.0.tgz", + "integrity": "sha1-pikNQT8hemEjL5XkWP84QYz7ARc=", "dev": true, "requires": { - "clone": "0.2.0", - "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" + "inherits": "2.0.3", + "process-nextick-args": "1.0.7", + "through2": "2.0.3" } }, - "vinyl-fs": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "isarray": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-1.0.0.tgz", - "integrity": "sha1-0VdS5owtrXQ2Tn6FNHNzU1RpLt8=", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "duplexify": "3.5.1", - "glob-stream": "4.1.1", - "glob-watcher": "0.0.8", - "graceful-fs": "3.0.11", - "merge-stream": "https://registry.npmjs.org/merge-stream/-/merge-stream-0.1.8.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "object-assign": "2.1.1", - "strip-bom": "1.0.0", + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "vinyl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.1.0.tgz", + "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", + "dev": true, + "requires": { + "clone": "2.1.1", + "clone-buffer": "1.0.0", + "clone-stats": "1.0.0", + "cloneable-readable": "1.0.0", + "remove-trailing-separator": "1.1.0", + "replace-ext": "1.0.0" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, + "gulp-tsc": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/gulp-tsc/-/gulp-tsc-1.3.2.tgz", + "integrity": "sha1-Wmb4CvOXYAXm9fBrnPzLDm1zmc4=", + "dev": true, + "requires": { + "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "byline": "https://registry.npmjs.org/byline/-/byline-4.2.2.tgz", + "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "lodash": "3.10.1", + "node-version-compare": "https://registry.npmjs.org/node-version-compare/-/node-version-compare-1.0.1.tgz", + "resolve": "1.4.0", + "rimraf": "2.6.2", + "temp": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", + "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "vinyl-fs": "1.0.0", + "which": "1.3.0" + }, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + } + }, + "clone": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", + "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", + "dev": true + }, + "duplexify": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz", + "integrity": "sha512-j5goxHTwVED1Fpe5hh3q9R93Kip0Bg2KVAt4f8CEYM3UEwYcPSvWbXaUQOzdX/HtiNomipv+gU7ASQPDbV7pGQ==", + "dev": true, + "requires": { + "end-of-stream": "1.4.0", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "readable-stream": "2.3.3", + "stream-shift": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz" + } + }, + "end-of-stream": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", + "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" + } + }, + "glob-stream": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-4.1.1.tgz", + "integrity": "sha1-uELfENaIx+trz869hG84UilrMgA=", + "dev": true, + "requires": { + "glob": "4.5.3", + "glob2base": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", + "minimatch": "2.0.10", + "ordered-read-streams": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", "through2": "0.6.5", - "vinyl": "0.4.6" + "unique-stream": "2.2.1" }, "dependencies": { + "glob": { + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", + "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", + "dev": true, + "requires": { + "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "minimatch": "2.0.10", + "once": "1.4.0" + } + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, "readable-stream": { "version": "1.0.34", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", @@ -3368,44 +3586,230 @@ } } }, - "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "glob-watcher": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.8.tgz", + "integrity": "sha1-aK62Yefizo02NDgbLsQV8AxrwqQ=", "dev": true, "requires": { - "isexe": "2.0.0" + "gaze": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz" } - } - } - }, - "gulp-tslint": { - "version": "https://registry.npmjs.org/gulp-tslint/-/gulp-tslint-7.1.0.tgz", - "integrity": "sha1-m9P/T7wW1MvZq7CP94bbibVj6T0=", - "dev": true, - "requires": { - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "map-stream": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - } - }, - "gulp-uglify": { - "version": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-1.5.4.tgz", - "integrity": "sha1-UkeI2HZm0J+dDCH7IXf5ADmmWMk=", - "dev": true, - "requires": { - "deap": "https://registry.npmjs.org/deap/-/deap-1.0.0.tgz", - "fancy-log": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "isobject": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "uglify-js": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", - "uglify-save-license": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz", - "vinyl-sourcemaps-apply": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + }, + "graceful-fs": { + "version": "3.0.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", + "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", + "dev": true, + "requires": { + "natives": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "object-assign": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", + "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" + } + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "isarray": "1.0.0", + "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "string_decoder": "1.0.3", + "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" + } + }, + "resolve": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", + "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", + "dev": true, + "requires": { + "path-parse": "1.0.5" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, + "requires": { + "glob": "7.1.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" + } + }, + "strip-bom": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", + "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "dev": true, + "requires": { + "first-chunk-stream": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", + "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" + } + }, + "unique-stream": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.2.1.tgz", + "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", + "dev": true, + "requires": { + "json-stable-stringify": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "through2-filter": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz" + } + }, + "vinyl": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", + "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "dev": true, + "requires": { + "clone": "0.2.0", + "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" + } + }, + "vinyl-fs": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-1.0.0.tgz", + "integrity": "sha1-0VdS5owtrXQ2Tn6FNHNzU1RpLt8=", + "dev": true, + "requires": { + "duplexify": "3.5.1", + "glob-stream": "4.1.1", + "glob-watcher": "0.0.8", + "graceful-fs": "3.0.11", + "merge-stream": "https://registry.npmjs.org/merge-stream/-/merge-stream-0.1.8.tgz", + "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "object-assign": "2.1.1", + "strip-bom": "1.0.0", + "through2": "0.6.5", + "vinyl": "0.4.6" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, + "through2": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "1.0.34", + "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" + } + } + } + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + } + } + }, + "gulp-tslint": { + "version": "https://registry.npmjs.org/gulp-tslint/-/gulp-tslint-7.1.0.tgz", + "integrity": "sha1-m9P/T7wW1MvZq7CP94bbibVj6T0=", + "dev": true, + "requires": { + "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "map-stream": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" + } + }, + "gulp-uglify": { + "version": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-1.5.4.tgz", + "integrity": "sha1-UkeI2HZm0J+dDCH7IXf5ADmmWMk=", + "dev": true, + "requires": { + "deap": "https://registry.npmjs.org/deap/-/deap-1.0.0.tgz", + "fancy-log": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", + "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "isobject": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "uglify-js": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", + "uglify-save-license": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz", + "vinyl-sourcemaps-apply": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz" + }, + "dependencies": { + "async": { + "version": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", "dev": true }, @@ -3540,6 +3944,48 @@ "glogg": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz" } }, + "handlebars": { + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", + "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", + "dev": true, + "requires": { + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "0.0.10", + "wordwrap": "0.0.3" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, "har-schema": { "version": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", @@ -3665,6 +4111,21 @@ "to-property-key-x": "2.0.2" } }, + "has-symbol-support-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", + "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", + "dev": true + }, + "has-to-string-tag-x": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", + "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", + "dev": true, + "requires": { + "has-symbol-support-x": "1.4.1" + } + }, "hasha": { "version": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", @@ -3704,6 +4165,12 @@ "parse-passwd": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz" } }, + "hosted-git-info": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", + "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", + "dev": true + }, "http-errors": { "version": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", "integrity": "sha1-eIwNLB3iyBuebowBhDtrl+uSB1A=", @@ -3755,16 +4222,51 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, - "indexof": { - "version": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", - "dev": true - }, - "infinity-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/infinity-x/-/infinity-x-1.0.0.tgz", - "integrity": "sha512-wjy2TupBtZ+aAniKt+xs/PO0xOkuaL6wBysUKbgD7aL1PMW/qY5xXDG59zXZ7dU+gk3zwXOu4yIEWPCEFBTgHQ==", - "dev": true + "indent-string": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", + "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", + "dev": true, + "requires": { + "repeating": "2.0.1" + }, + "dependencies": { + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "repeating": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", + "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", + "dev": true, + "requires": { + "is-finite": "1.0.2" + } + } + } + }, + "indexof": { + "version": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", + "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "dev": true + }, + "infinity-x": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/infinity-x/-/infinity-x-1.0.0.tgz", + "integrity": "sha512-wjy2TupBtZ+aAniKt+xs/PO0xOkuaL6wBysUKbgD7aL1PMW/qY5xXDG59zXZ7dU+gk3zwXOu4yIEWPCEFBTgHQ==", + "dev": true }, "inflight": { "version": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -3785,105 +4287,6 @@ "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", "dev": true }, - "inquirer": { - "version": "https://registry.npmjs.org/inquirer/-/inquirer-3.0.6.tgz", - "integrity": "sha1-4EqqnQW3o8ubD0B9BDdfBEcZA0c=", - "dev": true, - "requires": { - "ansi-escapes": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "cli-cursor": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "cli-width": "https://registry.npmjs.org/cli-width/-/cli-width-2.1.0.tgz", - "external-editor": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.4.tgz", - "figures": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "mute-stream": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "run-async": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "rx": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", - "string-width": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "is-fullwidth-code-point": { - "version": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "rx": { - "version": "https://registry.npmjs.org/rx/-/rx-4.1.0.tgz", - "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=", - "dev": true - }, - "string-width": { - "version": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha1-q5Pyeo3BPSjKyBXEYhQ6bZASrp4=", - "dev": true, - "requires": { - "is-fullwidth-code-point": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz" - } - } - } - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, "interpret": { "version": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz", "integrity": "sha1-1Xn7f2k7hYAElHrzn6DbSfeVYCw=", @@ -3898,10 +4301,18 @@ "is-windows": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz" } }, - "is-arrayish": { - "version": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true + "is-array-buffer-x": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/is-array-buffer-x/-/is-array-buffer-x-1.7.0.tgz", + "integrity": "sha512-ufSZRMY2WZX5xyNvk0NOZAG7cgi35B/sGQDGqv8w0X7MoQ2GC9vedanJhuYTPaC4PUCqLQsda1w7NF+dPZmAJw==", + "dev": true, + "requires": { + "attempt-x": "1.1.1", + "has-to-string-tag-x": "1.4.1", + "is-object-like-x": "1.6.0", + "object-get-own-property-descriptor-x": "3.2.0", + "to-string-tag-x": "1.4.2" + } }, "is-binary-path": { "version": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -3916,6 +4327,15 @@ "integrity": "sha1-z8hszV3FpS+oBIkRHGkgxFfi2Ys=", "dev": true }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true, + "requires": { + "builtin-modules": "1.1.1" + } + }, "is-date-object": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", @@ -3954,14 +4374,6 @@ "to-boolean-x": "1.0.1" } }, - "is-finite": { - "version": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, - "requires": { - "number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" - } - }, "is-finite-x": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/is-finite-x/-/is-finite-x-3.0.2.tgz", @@ -3980,6 +4392,79 @@ "number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" } }, + "is-function-x": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/is-function-x/-/is-function-x-3.3.0.tgz", + "integrity": "sha512-SreSSU1dlgYaXR5c0mm4qJHKYHIiGiEY+7Cd8/aRLLoMP/VvofD2XcWgBnP833ajpU5XzXbUSpfysnfKZLJFlg==", + "dev": true, + "requires": { + "attempt-x": "1.1.1", + "has-to-string-tag-x": "1.4.1", + "is-falsey-x": "1.0.1", + "is-primitive": "2.0.0", + "normalize-space-x": "3.0.0", + "replace-comments-x": "2.0.0", + "to-boolean-x": "1.0.1", + "to-string-tag-x": "1.4.2" + }, + "dependencies": { + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + }, + "normalize-space-x": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-space-x/-/normalize-space-x-3.0.0.tgz", + "integrity": "sha512-tbCJerqZCCHPst4rRKgsTanLf45fjOyeAU5zE3mhDxJtFJKt66q39g2XArWhXelgTFVib8mNBUm6Wrd0LxYcfQ==", + "dev": true, + "requires": { + "cached-constructors-x": "1.0.0", + "trim-x": "3.0.0", + "white-space-x": "3.0.0" + } + }, + "trim-left-x": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/trim-left-x/-/trim-left-x-3.0.0.tgz", + "integrity": "sha512-+m6cqkppI+CxQBTwWEZliOHpOBnCArGyMnS1WCLb6IRgukhTkiQu/TNEN5Lj2eM9jk8ewJsc7WxFZfmwNpRXWQ==", + "dev": true, + "requires": { + "cached-constructors-x": "1.0.0", + "require-coercible-to-string-x": "1.0.0", + "white-space-x": "3.0.0" + } + }, + "trim-right-x": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/trim-right-x/-/trim-right-x-3.0.0.tgz", + "integrity": "sha512-iIqEsWEbWVodqdixJHi4FoayJkUxhoL4AvSNGp4FF4FfQKRPGizt8++/RnyC9od75y7P/S6EfONoVqP+NddiKA==", + "dev": true, + "requires": { + "cached-constructors-x": "1.0.0", + "require-coercible-to-string-x": "1.0.0", + "white-space-x": "3.0.0" + } + }, + "trim-x": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/trim-x/-/trim-x-3.0.0.tgz", + "integrity": "sha512-w8s38RAUScQ6t3XqMkS75iz5ZkIYLQpVnv2lp3IuTS36JdlVzC54oe6okOf4Wz3UH4rr3XAb2xR3kR5Xei82fw==", + "dev": true, + "requires": { + "trim-left-x": "3.0.0", + "trim-right-x": "3.0.0" + } + }, + "white-space-x": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/white-space-x/-/white-space-x-3.0.0.tgz", + "integrity": "sha512-nMPVXGMdi/jQepXKryxqzEh/vCwdOYY/u6NZy40glMHvZfEr7/+vQKnDhEq4rZ1nniOFq9GWohQYB30uW/5Olg==", + "dev": true + } + } + }, "is-glob": { "version": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", @@ -4087,6 +4572,24 @@ "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", "dev": true }, + "is-object-like-x": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/is-object-like-x/-/is-object-like-x-1.6.0.tgz", + "integrity": "sha512-mc3dBMv1jEOdk0f1i2RkJFsZDux0MuHqGwHOoRo770ShUOf4VE6tWThAW8dAZARr9a5RN+iNX1yzMDA5ad1clQ==", + "dev": true, + "requires": { + "is-function-x": "3.3.0", + "is-primitive": "2.0.0" + }, + "dependencies": { + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + } + } + }, "is-path-cwd": { "version": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", @@ -4108,6 +4611,23 @@ "path-is-inside": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz" } }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "3.0.1" + }, + "dependencies": { + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true + } + } + }, "is-posix-bracket": { "version": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", @@ -4118,11 +4638,6 @@ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", "dev": true }, - "is-promise": { - "version": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, "is-property": { "version": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", @@ -4157,12 +4672,27 @@ "integrity": "sha1-zDqbaYV9Yh6WNyWiTK7shzuCbmQ=", "dev": true }, + "is-subset": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", + "integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=", + "dev": true + }, "is-symbol": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", "dev": true }, + "is-text-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", + "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", + "dev": true, + "requires": { + "text-extensions": "1.7.0" + } + }, "is-typedarray": { "version": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", @@ -4236,70 +4766,66 @@ } }, "jasmine": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.8.0.tgz", - "integrity": "sha1-awicChFXax8W3xG4AUbZHU6Lij4=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.4.1.tgz", + "integrity": "sha1-kBbdpFMhPSesbUPcTqlzFaGJCF4=", "dev": true, "requires": { - "exit": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "glob": "7.1.2", - "jasmine-core": "2.8.0" + "exit": "0.1.2", + "glob": "3.2.11", + "jasmine-core": "2.4.1" }, "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", "dev": true, "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" + "inherits": "2.0.3", + "minimatch": "0.3.0" } }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "lru-cache": "2.7.3", + "sigmund": "1.0.1" } }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true } } }, "jasmine-core": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.8.0.tgz", - "integrity": "sha1-vMl5rh+f0FcB5F5S5l06XWPxok4=", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.4.1.tgz", + "integrity": "sha1-b4OrOg8WlRcizgfSBsdz1XzIOL4=", "dev": true }, "jsbn": { @@ -4308,16 +4834,17 @@ "dev": true, "optional": true }, - "jschardet": { - "version": "https://registry.npmjs.org/jschardet/-/jschardet-1.5.0.tgz", - "integrity": "sha1-ph8xAwalpxGI4bGs0IrdPPuwix4=", - "dev": true - }, "json-schema": { "version": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "dev": true }, + "json-schema-traverse": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "dev": true + }, "json-stable-stringify": { "version": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", @@ -4354,6 +4881,12 @@ "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, + "jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "dev": true + }, "jsonpointer": { "version": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", @@ -4798,29 +5331,95 @@ "resolve": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz" } }, - "loader-utils": { - "version": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.16.tgz", - "integrity": "sha1-8IYyBm7YKCg13/iN+1JwR2Wt7m0=", + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { - "big.js": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", - "emojis-list": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "json5": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" - } - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "lodash._basecopy": { - "version": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", - "dev": true - }, - "lodash._basetostring": { - "version": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "strip-bom": "2.0.0" + }, + "dependencies": { + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true, + "requires": { + "is-arrayish": "0.2.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "1.3.1" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + } + } + }, + "loader-utils": { + "version": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.16.tgz", + "integrity": "sha1-8IYyBm7YKCg13/iN+1JwR2Wt7m0=", + "dev": true, + "requires": { + "big.js": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", + "emojis-list": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "json5": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", + "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" + } + }, + "lodash": { + "version": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "dev": true + }, + "lodash._basecopy": { + "version": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basetostring": { + "version": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", "dev": true }, @@ -4887,6 +5486,12 @@ "integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=", "dev": true }, + "lodash.isnull": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz", + "integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4=", + "dev": true + }, "lodash.isplainobject": { "version": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", @@ -4922,6 +5527,41 @@ "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", "dev": true }, + "lodash.template": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz", + "integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=", + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0", + "lodash.templatesettings": "4.1.0" + }, + "dependencies": { + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + } + } + }, + "lodash.templatesettings": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz", + "integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=", + "dev": true, + "requires": { + "lodash._reinterpolate": "3.0.0" + }, + "dependencies": { + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + } + } + }, "log4js": { "version": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=", @@ -4964,6 +5604,24 @@ "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", "dev": true }, + "loud-rejection": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", + "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", + "dev": true, + "requires": { + "currently-unhandled": "0.4.1", + "signal-exit": "3.0.2" + }, + "dependencies": { + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + } + } + }, "lowercase-keys": { "version": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", @@ -4974,14 +5632,6 @@ "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", "dev": true }, - "lru-queue": { - "version": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", - "dev": true, - "requires": { - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" - } - }, "make-dir": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz", @@ -5004,6 +5654,12 @@ "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, + "map-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", + "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", + "dev": true + }, "map-stream": { "version": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", @@ -5039,25 +5695,49 @@ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", "dev": true }, - "memoizee": { - "version": "https://registry.npmjs.org/memoizee/-/memoizee-0.3.10.tgz", - "integrity": "sha1-TsoNiu057J0Bf0xcLy9kMvQuXI8=", - "dev": true, - "requires": { - "d": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "es6-weak-map": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-0.1.4.tgz", - "event-emitter": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.4.tgz", - "lru-queue": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "next-tick": "https://registry.npmjs.org/next-tick/-/next-tick-0.2.2.tgz", - "timers-ext": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.0.tgz" - } - }, "memory-fs": { "version": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz", "integrity": "sha1-8rslNovBIeORwlIN6Slpyu4KApA=", "dev": true }, + "meow": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", + "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", + "dev": true, + "requires": { + "camelcase-keys": "2.1.0", + "decamelize": "1.2.0", + "loud-rejection": "1.6.0", + "map-obj": "1.0.1", + "minimist": "1.2.0", + "normalize-package-data": "2.4.0", + "object-assign": "4.1.1", + "read-pkg-up": "1.0.1", + "redent": "1.0.0", + "trim-newlines": "1.0.0" + }, + "dependencies": { + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + } + } + }, "merge-stream": { "version": "https://registry.npmjs.org/merge-stream/-/merge-stream-0.1.8.tgz", "integrity": "sha1-SKB7O0oSHXSj7b/c20sIrb8CQLE=", @@ -5131,11 +5811,6 @@ "mime-db": "https://registry.npmjs.org/mime-db/-/mime-db-1.26.0.tgz" } }, - "mimic-fn": { - "version": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", - "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", - "dev": true - }, "minimatch": { "version": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", "integrity": "sha1-Kk5AkLlrLbBqnX3wEFWmKnfJt3Q=", @@ -5318,6 +5993,12 @@ } } }, + "modify-values": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.0.tgz", + "integrity": "sha1-4rbN65zhn5kxelNyLz2/XfXqqrI=", + "dev": true + }, "moment": { "version": "https://registry.npmjs.org/moment/-/moment-2.17.1.tgz", "integrity": "sha1-/tlQYGPzaxDwZsi1mhRNf66+HYI=", @@ -5336,11 +6017,6 @@ "duplexer2": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz" } }, - "mute-stream": { - "version": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, "nan-x": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/nan-x/-/nan-x-1.0.0.tgz", @@ -5357,11 +6033,6 @@ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, - "next-tick": { - "version": "https://registry.npmjs.org/next-tick/-/next-tick-0.2.2.tgz", - "integrity": "sha1-ddpKkn7liH45BliABltzNkE7MQ0=", - "dev": true - }, "node-int64": { "version": "https://registry.npmjs.org/node-int64/-/node-int64-0.3.3.tgz", "integrity": "sha1-LW5rLs5d6FiLQ9iNG8QbJs0fqE0=", @@ -5382,6 +6053,26 @@ "integrity": "sha1-zM+7qCO/HPqWgPFoq3q1MSHkhBA=", "dev": true }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "dev": true, + "requires": { + "hosted-git-info": "2.5.0", + "is-builtin-module": "1.0.0", + "semver": "5.5.0", + "validate-npm-package-license": "3.0.1" + }, + "dependencies": { + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + } + } + }, "normalize-path": { "version": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", "integrity": "sha1-R4hqwWYnYNQmG32XnSQXCdPOP3o=", @@ -5398,11 +6089,6 @@ "white-space-x": "2.0.3" } }, - "npm-install-package": { - "version": "https://registry.npmjs.org/npm-install-package/-/npm-install-package-2.1.0.tgz", - "integrity": "sha1-1+/jz816sAYUuJbqUxGdyaslkSU=", - "dev": true - }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -5488,14 +6174,6 @@ "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" } }, - "onetime": { - "version": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz" - } - }, "optimist": { "version": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", @@ -5564,6 +6242,12 @@ "path-root": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz" } }, + "parse-github-repo-url": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz", + "integrity": "sha1-nn2LslKmy2ukJZUGC3v23z28H1A=", + "dev": true + }, "parse-glob": { "version": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", @@ -5587,14 +6271,6 @@ "white-space-x": "2.0.3" } }, - "parse-json": { - "version": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "requires": { - "error-ex": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.0.tgz" - } - }, "parse-passwd": { "version": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", @@ -5629,6 +6305,32 @@ "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=", "dev": true }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + } + } + }, "path-is-absolute": { "version": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", @@ -5664,12 +6366,44 @@ "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", "dev": true }, - "pause-stream": { - "version": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { - "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" + "graceful-fs": "4.1.11", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "2.0.4" + } + } } }, "pend": { @@ -5918,10 +6652,25 @@ "pinkie": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz" } }, - "pkginfo": { - "version": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", - "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", - "dev": true + "plugin-error": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", + "dev": true, + "requires": { + "ansi-colors": "1.0.1", + "arr-diff": "4.0.0", + "arr-union": "3.1.0", + "extend-shallow": "3.0.2" + }, + "dependencies": { + "arr-diff": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", + "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "dev": true + } + } }, "prepend-http": { "version": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", @@ -6045,31 +6794,38 @@ "dev": true }, "pump": { - "version": "https://registry.npmjs.org/pump/-/pump-1.0.2.tgz", - "integrity": "sha1-Oz7mUS+U8OV1U4wXmV+fFpkKXVE=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", + "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", "dev": true, "requires": { - "end-of-stream": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.1.0.tgz", - "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz" + "end-of-stream": "1.4.1", + "once": "1.4.0" }, "dependencies": { "end-of-stream": { - "version": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.1.0.tgz", - "integrity": "sha1-6TUyWLqpEIll78QcsO+K3i88+wc=", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", "dev": true, "requires": { - "once": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" - }, - "dependencies": { - "once": { - "version": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - } + "once": "1.4.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true } } }, @@ -6088,11 +6844,6 @@ "integrity": "sha1-zgPF/wk1vB2daanxTL0Y5WjWdiU=", "dev": true }, - "querystring": { - "version": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true - }, "randomatic": { "version": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", "integrity": "sha1-EQ3Kv/OX6dz/fAeJzMCkmt8exbs=", @@ -6123,6 +6874,27 @@ "strip-json-comments": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz" } }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "1.1.0", + "normalize-package-data": "2.4.0", + "path-type": "1.1.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, + "requires": { + "find-up": "1.1.2", + "read-pkg": "1.1.0" + } + }, "readable-stream": { "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", "integrity": "sha1-qeb+w8fdqF+LsbO6cChgRVb8gl4=", @@ -6156,10 +6928,15 @@ "resolve": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz" } }, - "regenerator-runtime": { - "version": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz", - "integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg=", - "dev": true + "redent": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", + "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", + "dev": true, + "requires": { + "indent-string": "2.1.0", + "strip-indent": "1.0.1" + } }, "regex-cache": { "version": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", @@ -6193,14 +6970,6 @@ "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true }, - "repeating": { - "version": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, - "requires": { - "is-finite": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz" - } - }, "replace-comments-x": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/replace-comments-x/-/replace-comments-x-2.0.0.tgz", @@ -6307,25 +7076,6 @@ "global-modules": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz" } }, - "resolve-url": { - "version": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "restore-cursor": { - "version": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "signal-exit": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz" - } - }, - "rgb2hex": { - "version": "https://registry.npmjs.org/rgb2hex/-/rgb2hex-0.1.0.tgz", - "integrity": "sha1-zNVfhgrgxcTqN1BLlY5ELY0SMls=", - "dev": true - }, "right-align": { "version": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", @@ -6342,34 +7092,45 @@ "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz" } }, - "run-async": { - "version": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz" - } + "rollup": { + "version": "0.54.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.54.1.tgz", + "integrity": "sha512-ebUUgUQ7K/sLn67CtO8Jj8H3RgKAoVWrpiJA7enOkwZPZzTCl8GC8CZ00g5jowjX80KgBmzs4Z1MV6cgglT86A==", + "dev": true }, - "rx": { + "rollup-plugin-hypothetical": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-hypothetical/-/rollup-plugin-hypothetical-2.1.0.tgz", + "integrity": "sha512-MlxPQTkMtiRUtyhIJ7FpBvTzWtar8eFBA+V7/J6Deg9fSgIIHwL6bJKK1Wl1uWSWtOrWhOmtsMwb9F6aagP/Pg==", + "dev": true + }, + "rx": { "version": "https://registry.npmjs.org/rx/-/rx-2.3.24.tgz", "integrity": "sha1-FPlQpCF9fjXapxu8vljv9o6ksrc=", "dev": true }, + "rx-lite": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", + "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", + "dev": true + }, + "rx-lite-aggregates": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", + "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", + "dev": true, + "requires": { + "rx-lite": "4.0.8" + } + }, "rxjs": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.4.3.tgz", - "integrity": "sha512-fSNi+y+P9ss+EZuV0GcIIqPUK07DEaMRUtLJvdcvMyFjc9dizuDjere+A4V7JrLGnm9iCc+nagV/4QdMTkqC4A==", + "version": "5.5.6", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz", + "integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==", "dev": true, "requires": { - "symbol-observable": "1.0.4" - }, - "dependencies": { - "symbol-observable": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.4.tgz", - "integrity": "sha1-Kb9hXUqnEhvdiYsi1LP5vE4qoD0=", - "dev": true - } + "symbol-observable": "1.0.1" } }, "safe-buffer": { @@ -6579,11 +7340,6 @@ "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", "dev": true }, - "signal-exit": { - "version": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, "sinon": { "version": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", "integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", @@ -6715,27 +7471,153 @@ } } }, - "source-map-resolve": { - "version": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz", - "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", "dev": true, "requires": { - "atob": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz", - "resolve-url": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "source-map-url": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz", - "urix": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz" + "amdefine": "1.0.1" + }, + "dependencies": { + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + } } }, - "source-map-url": { - "version": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz", - "integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=", - "dev": true - }, "sparkles": { "version": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", "dev": true }, + "spdx-correct": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", + "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", + "dev": true, + "requires": { + "spdx-license-ids": "1.2.2" + } + }, + "spdx-expression-parse": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", + "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "dev": true + }, + "spdx-license-ids": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", + "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", + "dev": true + }, + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", + "dev": true, + "requires": { + "through": "2.3.8" + }, + "dependencies": { + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + } + } + }, + "split2": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", + "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", + "dev": true, + "requires": { + "through2": "2.0.3" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true + } + } + }, "sshpk": { "version": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", @@ -6768,53 +7650,16 @@ "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", "dev": true }, - "stream-combiner": { - "version": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", - "dev": true, - "requires": { - "duplexer": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz" - } - }, - "stream-combiner2": { - "version": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "requires": { - "duplexer2": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" - }, - "dependencies": { - "duplexer2": { - "version": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" - } - } - } - }, "stream-consume": { "version": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", "dev": true }, - "stream-equal": { - "version": "https://registry.npmjs.org/stream-equal/-/stream-equal-0.1.6.tgz", - "integrity": "sha1-zFIvqzhRYBLk1O5HUTsUe3I1kBk=", - "dev": true - }, "stream-shift": { "version": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, - "string_decoder": { - "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "string-width": { "version": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", @@ -6840,6 +7685,11 @@ } } }, + "string_decoder": { + "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, "stringstream": { "version": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", @@ -6853,12 +7703,38 @@ "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz" } }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "0.2.1" + }, + "dependencies": { + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + } + } + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, + "strip-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", + "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", + "dev": true, + "requires": { + "get-stdin": "4.0.1" + } + }, "strip-json-comments": { "version": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", @@ -6869,6 +7745,12 @@ "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", "dev": true }, + "symbol-observable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", + "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=", + "dev": true + }, "systemjs": { "version": "0.19.47", "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-0.19.47.tgz", @@ -6961,6 +7843,12 @@ "execa": "0.7.0" } }, + "text-extensions": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.7.0.tgz", + "integrity": "sha512-AKXZeDq230UaSzaO5s3qQUZOaC7iKbzq0jOFL614R7d9R593HLqAOL0cYoqLdkNrjBSOdmoQI06yigq1TSBXAg==", + "dev": true + }, "throttleit": { "version": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", @@ -7002,15 +7890,6 @@ "integrity": "sha1-n0vSNVnJNllm8zAtu6KwfGuZsVE=", "dev": true }, - "timers-ext": { - "version": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.0.tgz", - "integrity": "sha1-ADRaLKkwidElEyIFQ4nSY+J7d+I=", - "dev": true, - "requires": { - "es5-ext": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "next-tick": "https://registry.npmjs.org/next-tick/-/next-tick-0.2.2.tgz" - } - }, "tmp": { "version": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", @@ -7179,6 +8058,16 @@ } } }, + "to-string-tag-x": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/to-string-tag-x/-/to-string-tag-x-1.4.2.tgz", + "integrity": "sha512-ytO9eLigxsQQLGuab0C1iSSTzKdJNVSlBg0Spg4J/rGAVrQJ5y774mo0SSzgGeTT4RJGGyJNfObXaTMzX0XDOQ==", + "dev": true, + "requires": { + "lodash.isnull": "3.0.0", + "validate.io-undefined": "1.0.3" + } + }, "to-string-x": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/to-string-x/-/to-string-x-1.4.2.tgz", @@ -7207,6 +8096,18 @@ "white-space-x": "2.0.3" } }, + "trim-newlines": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", + "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", + "dev": true + }, + "trim-off-newlines": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz", + "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", + "dev": true + }, "trim-right-x": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/trim-right-x/-/trim-right-x-2.0.1.tgz", @@ -7789,11 +8690,158 @@ "dev": true }, "typescript": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.3.4.tgz", - "integrity": "sha1-PTgyGCgjHkNPKHUUlZw3qCtin0I=", + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.2.tgz", + "integrity": "sha1-A4qV99m7tCCxvzW6MdTFwd0//jQ=", "dev": true }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "optional": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + }, + "dependencies": { + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true, + "optional": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "optional": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "optional": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true, + "optional": true + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true, + "optional": true + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "optional": true, + "requires": { + "align-text": "0.1.4" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "optional": true + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true, + "optional": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true, + "optional": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "optional": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } + }, "uglify-save-license": { "version": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz", "integrity": "sha1-lXJsF8xv0XHDYX479NjYKqjEzOE=", @@ -7843,27 +8891,6 @@ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", "dev": true }, - "urix": { - "version": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "url": { - "version": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "dev": true, - "requires": { - "punycode": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "querystring": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz" - }, - "dependencies": { - "punycode": { - "version": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } - } - }, "url-parse-lax": { "version": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", @@ -7918,6 +8945,12 @@ "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", "dev": true }, + "uuid": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", + "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", + "dev": true + }, "v8flags": { "version": "https://registry.npmjs.org/v8flags/-/v8flags-2.0.11.tgz", "integrity": "sha1-vKjzDw1tYGEswsAGQeaWLUKuaIE=", @@ -7926,9 +8959,20 @@ "user-home": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz" } }, - "validator": { - "version": "https://registry.npmjs.org/validator/-/validator-7.0.0.tgz", - "integrity": "sha1-x03rgGNRL6w1VHk45vCxUEooL9I=", + "validate-npm-package-license": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", + "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", + "dev": true, + "requires": { + "spdx-correct": "1.0.2", + "spdx-expression-parse": "1.0.4" + } + }, + "validate.io-undefined": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz", + "integrity": "sha1-fif8uzFbhB54JDQxiXZxkp4gt/Q=", "dev": true }, "vargs": { @@ -7979,575 +9023,1459 @@ "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", "dev": true, "requires": { - "natives": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" + "natives": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" + } + }, + "isarray": { + "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + } + }, + "strip-bom": { + "version": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", + "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "dev": true, + "requires": { + "first-chunk-stream": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", + "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" + } + }, + "through2": { + "version": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", + "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "dev": true, + "requires": { + "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" + } + }, + "vinyl": { + "version": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", + "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "dev": true, + "requires": { + "clone": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", + "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" + } + } + } + }, + "vinyl-sourcemaps-apply": { + "version": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", + "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", + "dev": true, + "requires": { + "source-map": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" + }, + "dependencies": { + "source-map": { + "version": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", + "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + "dev": true + } + } + }, + "void-elements": { + "version": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", + "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", + "dev": true + }, + "vrsource-tslint-rules": { + "version": "https://registry.npmjs.org/vrsource-tslint-rules/-/vrsource-tslint-rules-4.0.1.tgz", + "integrity": "sha1-88+AJuHTqbY9Jj3VkSSNyW3D7Bw=", + "dev": true, + "requires": { + "tslint": "4.5.1" + } + }, + "wd": { + "version": "https://registry.npmjs.org/wd/-/wd-0.3.12.tgz", + "integrity": "sha1-P7Tx11n4yF3eU5PRczT/4D6bsyk=", + "dev": true, + "requires": { + "archiver": "https://registry.npmjs.org/archiver/-/archiver-0.14.4.tgz", + "async": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", + "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", + "q": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", + "request": "https://registry.npmjs.org/request/-/request-2.55.0.tgz", + "underscore.string": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.0.3.tgz", + "vargs": "https://registry.npmjs.org/vargs/-/vargs-0.1.0.tgz" + }, + "dependencies": { + "async": { + "version": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", + "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", + "dev": true + }, + "lodash": { + "version": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", + "integrity": "sha1-AVnoaDL+/8bWHYUrEqlTuZSWvTI=", + "dev": true + } + } + }, + "webdriver-manager": { + "version": "https://registry.npmjs.org/webdriver-manager/-/webdriver-manager-12.0.6.tgz", + "integrity": "sha1-PfGkgZdwELTL+MnYXHpXeCjA5ws=", + "dev": true, + "requires": { + "adm-zip": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", + "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "del": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "q": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", + "request": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", + "semver": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", + "xml2js": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz" + }, + "dependencies": { + "ansi-regex": { + "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "assert-plus": { + "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "dev": true + }, + "aws-sign2": { + "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "dev": true + }, + "caseless": { + "version": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + } + }, + "combined-stream": { + "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "dev": true, + "requires": { + "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" + } + }, + "delayed-stream": { + "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "form-data": { + "version": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "dev": true, + "requires": { + "asynckit": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" + } + }, + "har-validator": { + "version": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "dev": true, + "requires": { + "ajv": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", + "har-schema": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz" + } + }, + "has-ansi": { + "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" + } + }, + "hawk": { + "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "dev": true, + "requires": { + "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", + "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", + "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", + "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" + } + }, + "http-signature": { + "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "dev": true, + "requires": { + "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", + "jsprim": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", + "sshpk": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz" + } + }, + "oauth-sign": { + "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "dev": true + }, + "qs": { + "version": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "dev": true + }, + "request": { + "version": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", + "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "dev": true, + "requires": { + "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", + "aws4": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", + "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "form-data": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", + "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", + "hawk": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", + "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", + "is-typedarray": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", + "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "performance-now": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", + "qs": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", + "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "uuid": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz" + } + }, + "strip-ansi": { + "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" + } + }, + "supports-color": { + "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + }, + "tunnel-agent": { + "version": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" + } + }, + "uuid": { + "version": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "dev": true + } + } + }, + "webdriverio": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-4.10.1.tgz", + "integrity": "sha1-Qvekh7czebJ0Oi+uULMUJhX2EXA=", + "dev": true, + "requires": { + "archiver": "2.1.1", + "babel-runtime": "6.26.0", + "css-parse": "2.0.0", + "css-value": "0.0.1", + "deepmerge": "2.0.1", + "ejs": "2.5.7", + "gaze": "1.1.2", + "glob": "7.1.2", + "inquirer": "3.3.0", + "json-stringify-safe": "5.0.1", + "mkdirp": "0.5.1", + "npm-install-package": "2.1.0", + "optimist": "0.6.1", + "q": "1.5.1", + "request": "2.83.0", + "rgb2hex": "0.1.0", + "safe-buffer": "5.1.1", + "supports-color": "5.0.1", + "url": "0.11.0", + "validator": "9.1.2", + "wdio-dot-reporter": "0.0.9", + "wgxpath": "1.0.0" + }, + "dependencies": { + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "dev": true, + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-escapes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", + "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", + "dev": true + }, + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "dev": true + }, + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "dev": true, + "requires": { + "color-convert": "1.9.0" + } + }, + "archiver": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/archiver/-/archiver-2.1.1.tgz", + "integrity": "sha1-/2YrSnggFJSj7lRNOjP+dJZQnrw=", + "dev": true, + "requires": { + "archiver-utils": "1.3.0", + "async": "2.6.0", + "buffer-crc32": "0.2.13", + "glob": "7.1.2", + "lodash": "4.17.4", + "readable-stream": "2.3.3", + "tar-stream": "1.5.5", + "zip-stream": "1.2.0" + } + }, + "archiver-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-1.3.0.tgz", + "integrity": "sha1-5QtMCccL89aA4y/xt5lOn52JUXQ=", + "dev": true, + "requires": { + "glob": "7.1.2", + "graceful-fs": "4.1.11", + "lazystream": "1.0.0", + "lodash": "4.17.4", + "normalize-path": "2.1.1", + "readable-stream": "2.3.3" + } + }, + "asn1": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", + "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", + "dev": true + }, + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "dev": true, + "requires": { + "lodash": "4.17.4" + } + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + }, + "atob": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz", + "integrity": "sha1-lfE2KbEsOlGl0hWr3OKqnzL4B3M=", + "dev": true + }, + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", + "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", + "dev": true + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "2.5.3", + "regenerator-runtime": "0.11.1" + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", + "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", + "dev": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "bl": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", + "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3" + } + }, + "boom": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", + "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", + "dev": true, + "requires": { + "hoek": "4.2.0" + } + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "dev": true, + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + }, + "dependencies": { + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } + } + } + }, + "cli-cursor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", + "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "dev": true, + "requires": { + "restore-cursor": "2.0.0" + } + }, + "cli-width": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", + "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "dev": true + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true + }, + "combined-stream": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", + "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "dev": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "compress-commons": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.2.tgz", + "integrity": "sha1-UkqfEJA/OoEzibAiXSfEi7dRiQ8=", + "dev": true, + "requires": { + "buffer-crc32": "0.2.13", + "crc32-stream": "2.0.0", + "normalize-path": "2.1.1", + "readable-stream": "2.3.3" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "core-js": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "crc": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/crc/-/crc-3.5.0.tgz", + "integrity": "sha1-mLi6fUiWZbo5efWbITgTdBAaGWQ=", + "dev": true + }, + "crc32-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-2.0.0.tgz", + "integrity": "sha1-483TtN8xaN10494/u8t7KX/pCPQ=", + "dev": true, + "requires": { + "crc": "3.5.0", + "readable-stream": "2.3.3" + } + }, + "cryptiles": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", + "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", + "dev": true, + "requires": { + "boom": "5.2.0" + }, + "dependencies": { + "boom": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", + "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", + "dev": true, + "requires": { + "hoek": "4.2.0" + } + } + } + }, + "css": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/css/-/css-2.2.1.tgz", + "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "source-map": "0.1.43", + "source-map-resolve": "0.3.1", + "urix": "0.1.0" + } + }, + "css-parse": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz", + "integrity": "sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q=", + "dev": true, + "requires": { + "css": "2.2.1" + } + }, + "css-value": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", + "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", + "dev": true + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "1.0.0" + } + }, + "deepmerge": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.0.1.tgz", + "integrity": "sha512-VIPwiMJqJ13ZQfaCsIFnp5Me9tnjURiaIFxfz7EH0Ci0dTSQpZtSLrqOicXqEd/z2r+z+Klk9GzmnRsgpgbOsQ==", + "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", + "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", + "dev": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "ejs": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.5.7.tgz", + "integrity": "sha1-zIcsFoiArjxxiXYv1f/ACJbJUYo=", + "dev": true + }, + "end-of-stream": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", + "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", + "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", + "dev": true + }, + "external-editor": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", + "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", + "dev": true, + "requires": { + "chardet": "0.4.2", + "iconv-lite": "0.4.19", + "tmp": "0.0.33" + } + }, + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "figures": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", + "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5" + } + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", + "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", + "dev": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "gaze": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz", + "integrity": "sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU=", + "dev": true, + "requires": { + "globule": "1.2.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "1.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "globule": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz", + "integrity": "sha1-HcScaCLdnoovoAuiopUAboZkvQk=", + "dev": true, + "requires": { + "glob": "7.1.2", + "lodash": "4.17.4", + "minimatch": "3.0.4" + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + }, + "har-validator": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "dev": true, + "requires": { + "ajv": "5.5.2", + "har-schema": "2.0.0" } }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "hawk": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", + "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", "dev": true, "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + "boom": "4.3.1", + "cryptiles": "3.1.2", + "hoek": "4.2.0", + "sntp": "2.1.0" } }, - "strip-bom": { - "version": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", + "hoek": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", + "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==", + "dev": true + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "dev": true, "requires": { - "first-chunk-stream": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" + "assert-plus": "1.0.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" } }, - "through2": { - "version": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" + "once": "1.4.0", + "wrappy": "1.0.2" } }, - "vinyl": { - "version": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "inquirer": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", + "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", "dev": true, "requires": { - "clone": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" + "ansi-escapes": "3.0.0", + "chalk": "2.3.0", + "cli-cursor": "2.1.0", + "cli-width": "2.2.0", + "external-editor": "2.1.0", + "figures": "2.0.0", + "lodash": "4.17.4", + "mute-stream": "0.0.7", + "run-async": "2.3.0", + "rx-lite": "4.0.8", + "rx-lite-aggregates": "4.0.8", + "string-width": "2.1.1", + "strip-ansi": "4.0.0", + "through": "2.3.8" } - } - } - }, - "vinyl-sourcemaps-apply": { - "version": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", - "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", - "dev": true, - "requires": { - "source-map": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" - }, - "dependencies": { - "source-map": { - "version": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true - } - } - }, - "void-elements": { - "version": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", - "dev": true - }, - "vrsource-tslint-rules": { - "version": "https://registry.npmjs.org/vrsource-tslint-rules/-/vrsource-tslint-rules-4.0.1.tgz", - "integrity": "sha1-88+AJuHTqbY9Jj3VkSSNyW3D7Bw=", - "dev": true, - "requires": { - "tslint": "4.5.1" - } - }, - "walkdir": { - "version": "https://registry.npmjs.org/walkdir/-/walkdir-0.0.11.tgz", - "integrity": "sha1-oW0CXrkxvQO1LzCMrtD0D86+lTI=", - "dev": true - }, - "wd": { - "version": "https://registry.npmjs.org/wd/-/wd-0.3.12.tgz", - "integrity": "sha1-P7Tx11n4yF3eU5PRczT/4D6bsyk=", - "dev": true, - "requires": { - "archiver": "https://registry.npmjs.org/archiver/-/archiver-0.14.4.tgz", - "async": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", - "q": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.55.0.tgz", - "underscore.string": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.0.3.tgz", - "vargs": "https://registry.npmjs.org/vargs/-/vargs-0.1.0.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", - "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", + }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", "dev": true }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", - "integrity": "sha1-AVnoaDL+/8bWHYUrEqlTuZSWvTI=", + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true - } - } - }, - "wdio-dot-reporter": { - "version": "https://registry.npmjs.org/wdio-dot-reporter/-/wdio-dot-reporter-0.0.8.tgz", - "integrity": "sha1-NhlVdtoNmYIQxxlIy7ZfW/Eb/GU=", - "dev": true - }, - "webdriver-manager": { - "version": "https://registry.npmjs.org/webdriver-manager/-/webdriver-manager-12.0.6.tgz", - "integrity": "sha1-PfGkgZdwELTL+MnYXHpXeCjA5ws=", - "dev": true, - "requires": { - "adm-zip": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "del": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "q": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", - "semver": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "xml2js": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "dev": true }, - "aws-sign2": { - "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, - "caseless": { - "version": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + } + }, + "lazystream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", + "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", + "dev": true, + "requires": { + "readable-stream": "2.3.3" + } + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", "dev": true }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "mime-db": { + "version": "1.30.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", + "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", + "dev": true + }, + "mime-types": { + "version": "2.1.17", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", + "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", "dev": true, "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + "mime-db": "1.30.0" } }, - "combined-stream": { - "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "mimic-fn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", + "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" + "brace-expansion": "1.1.8" } }, - "delayed-stream": { - "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true }, - "form-data": { - "version": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { - "asynckit": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" + "minimist": "0.0.8" } }, - "har-validator": { - "version": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "mute-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", + "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", + "dev": true + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "ajv": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "har-schema": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz" + "remove-trailing-separator": "1.1.0" } }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "npm-install-package": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/npm-install-package/-/npm-install-package-2.1.0.tgz", + "integrity": "sha1-1+/jz816sAYUuJbqUxGdyaslkSU=", + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" + "wrappy": "1.0.2" } }, - "hawk": { - "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "onetime": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", + "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "dev": true, "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" + "mimic-fn": "1.1.0" } }, - "http-signature": { - "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "jsprim": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "sshpk": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz" + "minimist": "0.0.8", + "wordwrap": "0.0.3" } }, - "oauth-sign": { - "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", "dev": true }, "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", + "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", "dev": true }, - "request": { - "version": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "dev": true, - "requires": { - "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "aws4": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "form-data": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "hawk": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "is-typedarray": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "performance-now": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "uuid": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz" - } + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", "dev": true, "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" } }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", "dev": true }, - "tunnel-agent": { - "version": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "remove-trailing-separator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", + "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "dev": true + }, + "request": { + "version": "2.83.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", + "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", + "dev": true, + "requires": { + "aws-sign2": "0.7.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.3.1", + "har-validator": "5.0.3", + "hawk": "6.0.2", + "http-signature": "1.2.0", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "2.1.0", + "qs": "6.5.1", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.2.1" + } + }, + "resolve-url": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", + "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "dev": true + }, + "restore-cursor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", + "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "dev": true, "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" + "onetime": "2.0.1", + "signal-exit": "3.0.2" } }, - "uuid": { - "version": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "rgb2hex": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/rgb2hex/-/rgb2hex-0.1.0.tgz", + "integrity": "sha1-zNVfhgrgxcTqN1BLlY5ELY0SMls=", "dev": true - } - } - }, - "webdriverio": { - "version": "https://registry.npmjs.org/webdriverio/-/webdriverio-4.8.0.tgz", - "integrity": "sha1-1Skpt0kID4mWf24WFAUcvIFy0TI=", - "dev": true, - "requires": { - "archiver": "https://registry.npmjs.org/archiver/-/archiver-1.3.0.tgz", - "babel-runtime": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.23.0.tgz", - "css-parse": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz", - "css-value": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", - "deepmerge": "https://registry.npmjs.org/deepmerge/-/deepmerge-1.3.2.tgz", - "ejs": "https://registry.npmjs.org/ejs/-/ejs-2.5.6.tgz", - "gaze": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "inquirer": "https://registry.npmjs.org/inquirer/-/inquirer-3.0.6.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "npm-install-package": "https://registry.npmjs.org/npm-install-package/-/npm-install-package-2.1.0.tgz", - "optimist": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "q": "https://registry.npmjs.org/q/-/q-1.5.0.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "rgb2hex": "https://registry.npmjs.org/rgb2hex/-/rgb2hex-0.1.0.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "url": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "validator": "https://registry.npmjs.org/validator/-/validator-7.0.0.tgz", - "wdio-dot-reporter": "https://registry.npmjs.org/wdio-dot-reporter/-/wdio-dot-reporter-0.0.8.tgz", - "wgxpath": "https://registry.npmjs.org/wgxpath/-/wgxpath-1.0.0.tgz" - }, - "dependencies": { - "archiver": { - "version": "https://registry.npmjs.org/archiver/-/archiver-1.3.0.tgz", - "integrity": "sha1-TyGU1tj5nfP1MeaIHxTxXVX6ryI=", + }, + "run-async": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", + "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", "dev": true, "requires": { - "archiver-utils": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-1.3.0.tgz", - "async": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "buffer-crc32": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", - "tar-stream": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.4.tgz", - "walkdir": "https://registry.npmjs.org/walkdir/-/walkdir-0.0.11.tgz", - "zip-stream": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz" + "is-promise": "2.1.0" } }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", "dev": true }, - "async": { - "version": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", + "signal-exit": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true + }, + "sntp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", + "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", "dev": true, "requires": { - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz" + "hoek": "4.2.0" } }, - "aws-sign2": { - "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true + "source-map": { + "version": "0.1.43", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", + "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } }, - "bl": { - "version": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", - "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", + "source-map-resolve": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz", + "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", "dev": true, "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" + "atob": "1.1.3", + "resolve-url": "0.2.1", + "source-map-url": "0.3.0", + "urix": "0.1.0" } }, - "caseless": { - "version": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "source-map-url": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz", + "integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=", "dev": true }, - "combined-stream": { - "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "sshpk": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", + "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", "dev": true, "requires": { - "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" } }, - "compress-commons": { - "version": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.0.tgz", - "integrity": "sha1-WFhwku8g03y1i68AARLJJ4/3O58=", + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { - "buffer-crc32": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "crc32-stream": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-2.0.0.tgz", - "normalize-path": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" } }, - "crc32-stream": { - "version": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-2.0.0.tgz", - "integrity": "sha1-483TtN8xaN10494/u8t7KX/pCPQ=", + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { - "crc": "https://registry.npmjs.org/crc/-/crc-3.4.4.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" + "safe-buffer": "5.1.1" } }, - "delayed-stream": { - "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "stringstream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", + "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", "dev": true }, - "end-of-stream": { - "version": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", - "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { - "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz" + "ansi-regex": "3.0.0" } }, - "form-data": { - "version": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", + "supports-color": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.0.1.tgz", + "integrity": "sha512-7FQGOlSQ+AQxBNXJpVDj8efTA/FtyB5wcNE1omXXJ0cq6jm1jjDwuROlYDbnzHqdNPqliWFhcioCWSyav+xBnA==", "dev": true, "requires": { - "asynckit": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" + "has-flag": "2.0.0" } }, - "gaze": { - "version": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz", - "integrity": "sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU=", + "tar-stream": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.5.tgz", + "integrity": "sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg==", "dev": true, "requires": { - "globule": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz" + "bl": "1.2.1", + "end-of-stream": "1.4.1", + "readable-stream": "2.3.3", + "xtend": "4.0.1" } }, - "globule": { - "version": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz", - "integrity": "sha1-HcScaCLdnoovoAuiopUAboZkvQk=", + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, "requires": { - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz" + "os-tmpdir": "1.0.2" } }, - "har-validator": { - "version": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", + "tough-cookie": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", + "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", "dev": true, "requires": { - "ajv": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "har-schema": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz" + "punycode": "1.4.1" } }, - "hawk": { - "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "dev": true, "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" + "safe-buffer": "5.1.1" } }, - "http-signature": { - "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "jsprim": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "sshpk": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz" - } + "optional": true }, - "oauth-sign": { - "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "urix": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", + "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", "dev": true }, - "q": { - "version": "https://registry.npmjs.org/q/-/q-1.5.0.tgz", - "integrity": "sha1-3QG6ydBtMObyGa7LglPunr3DCPE=", + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + }, + "dependencies": { + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + } + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, - "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", + "validator": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.1.2.tgz", + "integrity": "sha512-1Tml6crNdsSC61jHssWksQxq6C7MmSFCCmf99Eb+l/V/cwVlw4/Pg3YXBP1WKcHLsyqe3E+iJXUZgoTTQFcqQg==", "dev": true }, - "request": { - "version": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "dev": true, "requires": { - "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "aws4": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "form-data": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "hawk": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "is-typedarray": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "performance-now": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "uuid": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz" + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" } }, - "safe-buffer": { - "version": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", + "wdio-dot-reporter": { + "version": "0.0.9", + "resolved": "https://registry.npmjs.org/wdio-dot-reporter/-/wdio-dot-reporter-0.0.9.tgz", + "integrity": "sha1-kpsq2v1J1rBTT9oGjocxm0fjj+U=", "dev": true }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", - "dev": true, - "requires": { - "has-flag": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz" - } + "wgxpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wgxpath/-/wgxpath-1.0.0.tgz", + "integrity": "sha1-7vikudVYzEla06mit1FZfs2a9pA=", + "dev": true }, - "tar-stream": { - "version": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.4.tgz", - "integrity": "sha1-NlSc8E7RrumyowwBQyUiONr5QBY=", - "dev": true, - "requires": { - "bl": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", - "end-of-stream": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true }, - "tunnel-agent": { - "version": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz" - } + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, - "uuid": { - "version": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true }, "zip-stream": { - "version": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz", "integrity": "sha1-qLxF9MG0lpnGuQGYuqyqzbzUugQ=", "dev": true, "requires": { - "archiver-utils": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-1.3.0.tgz", - "compress-commons": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz" + "archiver-utils": "1.3.0", + "compress-commons": "1.2.2", + "lodash": "4.17.4", + "readable-stream": "2.3.3" } } } }, - "wgxpath": { - "version": "https://registry.npmjs.org/wgxpath/-/wgxpath-1.0.0.tgz", - "integrity": "sha1-7vikudVYzEla06mit1FZfs2a9pA=", - "dev": true - }, "whatwg-fetch": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", diff --git a/package.json b/package.json index 34ef75eb0..8faa94ece 100644 --- a/package.json +++ b/package.json @@ -57,24 +57,24 @@ "dependencies": {}, "devDependencies": { "@types/jasmine": "2.2.33", - "@types/node": "^6.0.38", + "@types/node": "^6.0.96", "@types/systemjs": "^0.19.30", "clang-format": "1.0.46", "concurrently": "^2.2.0", - "conventional-changelog": "^1.1.0", + "conventional-changelog": "^1.1.7", "es6-promise": "^3.0.2", "google-closure-compiler": "^20170409.0.0", "gulp": "^3.8.11", - "gulp-clang-format": "^1.0.23", - "gulp-conventional-changelog": "^1.1.0", + "gulp-clang-format": "^1.0.25", + "gulp-conventional-changelog": "^1.1.7", "gulp-rename": "^1.2.2", - "gulp-rollup": "^2.3.0", + "gulp-rollup": "^2.16.1", "gulp-tsc": "^1.1.4", "gulp-tslint": "^7.0.1", "gulp-uglify": "^1.2.0", "gulp-util": "^3.0.7", - "jasmine": "^2.4.1", - "jasmine-core": "^2.2.0", + "jasmine": "2.4.1", + "jasmine-core": "2.4.1", "karma": "^0.13.14", "karma-chrome-launcher": "^0.2.1", "karma-firefox-launcher": "^0.1.4", diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 6276d1e8e..82845f2ae 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -2470,7 +2470,7 @@ describe('Zone', function() { }); })); - describe('getUserMedia', () => { + xdescribe('getUserMedia', () => { it('navigator.mediaDevices.getUserMedia should in zone', ifEnvSupportsWithDone( () => { diff --git a/test/rxjs/rxjs.Observable.collection.spec.ts b/test/rxjs/rxjs.Observable.collection.spec.ts index 00bd1d130..e7f6ba608 100644 --- a/test/rxjs/rxjs.Observable.collection.spec.ts +++ b/test/rxjs/rxjs.Observable.collection.spec.ts @@ -11,9 +11,15 @@ import {asyncTest} from '../test-util'; describe('Observable.collection', () => { let log: string[]; let observable1: any; + let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { log = []; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + }); + + afterEach(function() { + jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; }); it('elementAt func callback should run in the correct zone', () => { diff --git a/test/rxjs/rxjs.Observable.merge.spec.ts b/test/rxjs/rxjs.Observable.merge.spec.ts index bb940cae8..9f1528009 100644 --- a/test/rxjs/rxjs.Observable.merge.spec.ts +++ b/test/rxjs/rxjs.Observable.merge.spec.ts @@ -11,9 +11,15 @@ import {asyncTest} from '../test-util'; describe('Observable.merge', () => { let log: string[]; let observable1: any; + let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { log = []; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + }); + + afterEach(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; }); it('expand func callback should run in the correct zone', () => { diff --git a/test/rxjs/rxjs.Observable.take.spec.ts b/test/rxjs/rxjs.Observable.take.spec.ts index 42aed8445..0edc377a2 100644 --- a/test/rxjs/rxjs.Observable.take.spec.ts +++ b/test/rxjs/rxjs.Observable.take.spec.ts @@ -11,9 +11,15 @@ import {asyncTest} from '../test-util'; describe('Observable.take', () => { let log: string[]; let observable1: any; + let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { log = []; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + }); + + afterEach(() => { + jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; }); it('take func callback should run in the correct zone', () => { diff --git a/test/zone-spec/long-stack-trace-zone.spec.ts b/test/zone-spec/long-stack-trace-zone.spec.ts index 540128928..4515c2965 100644 --- a/test/zone-spec/long-stack-trace-zone.spec.ts +++ b/test/zone-spec/long-stack-trace-zone.spec.ts @@ -16,6 +16,7 @@ describe( let log: Error[]; let lstz: Zone; let longStackTraceZoneSpec = (Zone as any)['longStackTraceZoneSpec']; + let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(function() { lstz = Zone.current.fork(longStackTraceZoneSpec).fork({ @@ -29,6 +30,11 @@ describe( }); log = []; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + }); + + afterEach(function() { + jasmine.DEFAULT_TIMEOUT_INTERVAL = defaultTimeout; }); function expectElapsed(stack: string, expectedCount: number) { From 42b9edb6916503c17e39803e3bb5ac60098b28c6 Mon Sep 17 00:00:00 2001 From: Edwin Chu Date: Thu, 8 Feb 2018 09:37:16 -0800 Subject: [PATCH 012/106] style(License): update copyright year (#986) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 13a6fd789..c5de4726c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2016 Google, Inc. +Copyright (c) 2016-2018 Google, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 008fd434a6c685993a901b1e77b3ada3dd06779b Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 10 Feb 2018 09:09:59 +0900 Subject: [PATCH 013/106] feat(jsonp): provide a help method to patch jsonp (#997) --- NON-STANDARD-APIS.md | 19 +++++++++++ gulpfile.js | 10 ++++++ lib/extra/jsonp.ts | 77 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 lib/extra/jsonp.ts diff --git a/NON-STANDARD-APIS.md b/NON-STANDARD-APIS.md index 71826f7c5..4e4dbe9a7 100644 --- a/NON-STANDARD-APIS.md +++ b/NON-STANDARD-APIS.md @@ -198,3 +198,22 @@ user need to patch `io` themselves just like following code. please reference the sample repo [zone-socketio](https://github.com/JiaLiPassion/zone-socketio) about detail usage. +* jsonp + +## Usage. + +provide a helper method to patch jsonp. Because jsonp has a lot of implementation, so +user need to provide the information to let json `send` and `callback` in zone. + +there is a sampel repo [zone-jsonp](https://github.com/JiaLiPassion/test-zone-js-with-jsonp) here, +sample usage is: + +```javascript +import 'zone.js/dist/zone-patch-jsonp'; +Zone['__zone_symbol__jsonp']({ + jsonp: getJSONP, + sendFuncName: 'send', + successFuncName: 'jsonpSuccessCallback', + failedFuncName: 'jsonpFailedCallback' +}); +``` diff --git a/gulpfile.js b/gulpfile.js index c79d1970e..a35ba26e6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -208,6 +208,14 @@ gulp.task('build/bluebird.min.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb); }); +gulp.task('build/zone-patch-jsonp.js', ['compile-esm'], function(cb) { + return generateScript('./lib/extra/jsonp.ts', 'zone-patch-jsonp.js', false, cb); +}); + +gulp.task('build/zone-patch-jsonp.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/extra/jsonp.ts', 'zone-patch-jsonp.min.js', true, cb); +}); + gulp.task('build/jasmine-patch.js', ['compile-esm'], function(cb) { return generateScript('./lib/jasmine/jasmine.ts', 'jasmine-patch.js', false, cb); }); @@ -310,6 +318,8 @@ gulp.task('build', [ 'build/zone-mix.js', 'build/bluebird.js', 'build/bluebird.min.js', + 'build/zone-patch-jsonp.js', + 'build/zone-patch-jsonp.min.js', 'build/jasmine-patch.js', 'build/jasmine-patch.min.js', 'build/mocha-patch.js', diff --git a/lib/extra/jsonp.ts b/lib/extra/jsonp.ts new file mode 100644 index 000000000..3b2166081 --- /dev/null +++ b/lib/extra/jsonp.ts @@ -0,0 +1,77 @@ +/** + * @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.__load_patch('jsonp', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const noop = function() {}; + // because jsonp is not a standard api, there are a lot of + // implementations, so zone.js just provide a helper util to + // patch the jsonp send and onSuccess/onError callback + // the options is an object which contains + // - jsonp, the jsonp object which hold the send function + // - sendFuncName, the name of the send function + // - successFuncName, success func name + // - failedFuncName, failed func name + (Zone as any)[Zone.__symbol__('jsonp')] = function patchJsonp(options: any) { + if (!options || !options.jsonp || !options.sendFuncName) { + return; + } + const noop = function() {}; + + [options.successFuncName, options.failedFuncName].forEach(methodName => { + if (!methodName) { + return; + } + + const oriFunc = global[methodName]; + if (oriFunc) { + api.patchMethod(global, methodName, (delegate: Function) => (self: any, args: any[]) => { + const task = global[api.symbol('jsonTask')]; + if (task) { + task.callback = delegate; + return task.invoke.apply(self, args); + } else { + return delegate.apply(self, args); + } + }); + } else { + Object.defineProperty(global, methodName, { + configurable: true, + enumerable: true, + get: function() { + return function() { + const task = global[api.symbol('jsonpTask')]; + const target = this ? this : global; + const delegate = global[api.symbol(`jsonp${methodName}callback`)]; + + if (task) { + if (delegate) { + task.callback = delegate; + } + global[api.symbol('jsonpTask')] = undefined; + return task.invoke.apply(this, arguments); + } else { + if (delegate) { + return delegate.apply(this, arguments); + } + } + return null; + }; + }, + set: function(callback: Function) { + this[api.symbol(`jsonp${methodName}callback`)] = callback; + } + }); + } + }); + + api.patchMethod(options.jsonp, options.sendFuncName, (delegate: Function) => (self: any, args: any[]) => { + global[api.symbol('jsonpTask')] = Zone.current.scheduleMacroTask('jsonp', noop, {}, (task: Task) => { + return delegate.apply(self, args); + }, noop); + }); + }; +}); From c7c7db5430850fe08cce17b25826ca5568a568c8 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 10 Feb 2018 09:15:04 +0900 Subject: [PATCH 014/106] fix(patch): fix #998, patch mediaQuery for new Safari (#1003) --- lib/browser/webapis-media-query.ts | 59 ++++++++++++++++++++++++++++-- test/test-env-setup-jasmine.ts | 2 +- 2 files changed, 56 insertions(+), 5 deletions(-) diff --git a/lib/browser/webapis-media-query.ts b/lib/browser/webapis-media-query.ts index 0bb841826..8db02cd0b 100644 --- a/lib/browser/webapis-media-query.ts +++ b/lib/browser/webapis-media-query.ts @@ -6,9 +6,60 @@ * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - if (!global['MediaQueryList']) { - return; + function patchAddListener(proto: any) { + api.patchMethod(proto, 'addListener', (delegate: Function) => (self: any, args: any[]) => { + const callback = args.length > 0 ? args[0] : null; + if (typeof callback === 'function') { + const wrapperedCallback = Zone.current.wrap(callback, 'MediaQuery'); + callback[api.symbol('mediaQueryCallback')] = wrapperedCallback; + return delegate.call(self, wrapperedCallback); + } else { + return delegate.apply(self, args); + } + }); + } + + function patchRemoveListener(proto: any) { + api.patchMethod(proto, 'removeListener', (delegate: Function) => (self: any, args: any[]) => { + const callback = args.length > 0 ? args[0] : null; + if (typeof callback === 'function') { + const wrapperedCallback = callback[api.symbol('mediaQueryCallback')]; + if (wrapperedCallback) { + return delegate.call(self, wrapperedCallback); + } else { + return delegate.apply(self, args); + } + } else { + return delegate.apply(self, args); + } + }); + } + + if (global['MediaQueryList']) { + const proto = global['MediaQueryList'].prototype; + patchAddListener(proto); + patchRemoveListener(proto); + } else if (global['matchMedia']) { + api.patchMethod(global, 'matchMedia', (delegate: Function) => (self: any, args: any[]) => { + const mql = delegate.apply(self, args); + if (mql) { + // try to patch MediaQueryList.prototype + const proto = Object.getPrototypeOf(mql); + if (proto && proto['addListener']) { + // try to patch proto, don't need to worry about patch + // multiple times, because, api.patchEventTarget will check it + patchAddListener(proto); + patchRemoveListener(proto); + patchAddListener(mql); + patchRemoveListener(mql); + } else if (mql['addListener']) { + // proto not exists, or proto has no addListener method + // try to patch mql instance + patchAddListener(mql); + patchRemoveListener(mql); + } + } + return mql; + }); } - api.patchEventTarget( - global, [global['MediaQueryList'].prototype], {add: 'addListener', rm: 'removeListener'}); }); diff --git a/test/test-env-setup-jasmine.ts b/test/test-env-setup-jasmine.ts index 955bb1e59..8cee81df5 100644 --- a/test/test-env-setup-jasmine.ts +++ b/test/test-env-setup-jasmine.ts @@ -6,5 +6,5 @@ * found in the LICENSE file at https://angular.io/license */ -(jasmine).DEFAULT_TIMEOUT_INTERVAL = 2000; +(jasmine).DEFAULT_TIMEOUT_INTERVAL = 5000; import '../lib/jasmine/jasmine'; From 5c139e5c4e086eb7ac5e8579bb80c472dcb85b77 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 10 Feb 2018 09:15:22 +0900 Subject: [PATCH 015/106] fix(core): fix #1000, check target is null or not when patchOnProperty (#1004) --- lib/browser/property-descriptor.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index c381abfda..221962802 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -256,6 +256,11 @@ function filterProperties( export function patchFilteredProperties( target: any, onProperties: string[], ignoreProperties: IgnoreProperty[], prototype?: any) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } const filteredProperties: string[] = filterProperties(target, onProperties, ignoreProperties); patchOnProperties(target, filteredProperties, prototype); } From 6a1a8309c1db39b33e08f24599873c4c0a767bbc Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 10 Feb 2018 09:16:31 +0900 Subject: [PATCH 016/106] feat(promise): support Promise.prototype.finally (#1005) --- .travis.yml | 1 + gulpfile.js | 2 + lib/common/promise.ts | 46 ++++- package-lock.json | 11 +- package.json | 2 + promise.finally.spec.js | 345 ++++++++++++++++++++++++++++++++++++ test/common/Promise.spec.ts | 32 ++++ 7 files changed, 435 insertions(+), 4 deletions(-) create mode 100644 promise.finally.spec.js diff --git a/.travis.yml b/.travis.yml index fc734678d..a9f810124 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ script: - node_modules/.bin/gulp filesize - scripts/closure/closure_compiler.sh - node_modules/.bin/gulp promisetest + - npm run promisefinallytest - npm run test:phantomjs-single - node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run diff --git a/gulpfile.js b/gulpfile.js index a35ba26e6..44cbf142d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -427,6 +427,8 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => { promisesAplusTests(adapter, { reporter: "dot" }, function (err) { if (err) { cb(err); + } else { + cb(); } }); }); diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 75e0766a9..f0e4995d7 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -5,6 +5,10 @@ * 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 */ +interface Promise { + finally(onFinally?: () => U | PromiseLike): Promise; +} + Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; const ObjectDefineProperty = Object.defineProperty; @@ -88,6 +92,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr const symbolState: string = __symbol__('state'); const symbolValue: string = __symbol__('value'); + const symbolFinally: string = __symbol__('finally'); + const symbolParentPromiseValue: string = __symbol__('parentPromiseValue'); + const symbolParentPromiseState: string = __symbol__('parentPromiseState'); const source: string = 'Promise.then'; const UNRESOLVED: null = null; const RESOLVED = true; @@ -163,6 +170,16 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr const queue = (promise as any)[symbolValue]; (promise as any)[symbolValue] = value; + if ((promise as any)[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + (promise as any)[symbolState] = (promise as any)[symbolParentPromiseState]; + (promise as any)[symbolValue] = (promise as any)[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can // do some additional work such as render longStackTrace if (state === REJECTED && value instanceof Error) { @@ -231,14 +248,24 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr promise: ZoneAwarePromise, zone: AmbientZone, chainPromise: ZoneAwarePromise, onFulfilled?: (value: R) => U1, onRejected?: (error: any) => U2): void { clearRejectedNoCatch(promise); - const delegate = (promise as any)[symbolState] ? + const promiseState = (promise as any)[symbolState]; + const delegate = promiseState ? (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, () => { try { - resolvePromise( - chainPromise, true, zone.run(delegate, undefined, [(promise as any)[symbolValue]])); + const parentPromiseValue = (promise as any)[symbolValue]; + const isFinallyPromise = chainPromise && symbolFinally === (chainPromise as any)[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + (chainPromise as any)[symbolParentPromiseValue] = parentPromiseValue; + (chainPromise as any)[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + resolvePromise(chainPromise, true, value); } catch (error) { + // if error occurs, should always return this error resolvePromise(chainPromise, false, error); } }); @@ -345,6 +372,19 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr null): Promise { return this.then(null, onRejected); } + + finally(onFinally?: () => U | PromiseLike): Promise { + const chainPromise: Promise = + new (this.constructor as typeof ZoneAwarePromise)(null); + (chainPromise as any)[symbolFinally] = symbolFinally; + const zone = Zone.current; + if ((this as any)[symbolState] == UNRESOLVED) { + ((this as any)[symbolValue]).push(zone, chainPromise, onFinally, onFinally); + } else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + } } // Protect against aggressive optimizers dropping seemingly unused properties. // E.g. Closure Compiler in advanced mode. diff --git a/package-lock.json b/package-lock.json index 6f7fe34c9..47fd50988 100644 --- a/package-lock.json +++ b/package-lock.json @@ -257,6 +257,15 @@ "integrity": "sha1-VZvhg3bQik7E2+gId9J4GGObLfc=", "dev": true }, + "assert": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", + "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "dev": true, + "requires": { + "util": "https://registry.npmjs.org/util/-/util-0.10.3.tgz" + } + }, "assert-plus": { "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz", "integrity": "sha1-7nQAlBMALYTOxyGcasgRgS5yMWA=", @@ -7187,7 +7196,7 @@ }, "sax": { "version": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha1-KBYjTiN4vdxOU1T6tcqold9xANk=", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", "dev": true }, "selenium-webdriver": { diff --git a/package.json b/package.json index 8faa94ece..1a3e65d9f 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "lint": "gulp lint", "prepublish": "tsc && gulp build", "promisetest": "gulp promisetest", + "promisefinallytest": "mocha promise.finally.spec.js", "webdriver-start": "webdriver-manager update && webdriver-manager start", "webdriver-http": "node simple-server.js", "webdriver-test": "node test/webdriver/test.js", @@ -59,6 +60,7 @@ "@types/jasmine": "2.2.33", "@types/node": "^6.0.96", "@types/systemjs": "^0.19.30", + "assert": "^1.4.1", "clang-format": "1.0.46", "concurrently": "^2.2.0", "conventional-changelog": "^1.1.7", diff --git a/promise.finally.spec.js b/promise.finally.spec.js new file mode 100644 index 000000000..35a5c4e57 --- /dev/null +++ b/promise.finally.spec.js @@ -0,0 +1,345 @@ +'use strict'; + +var assert = require('assert'); +var adapter = require('./promise-adapter'); +var P = global['__zone_symbol__Promise']; + +var someRejectionReason = {message: 'some rejection reason'}; +var anotherReason = {message: 'another rejection reason'}; +process.on('unhandledRejection', function(reason, promise) { + console.log('unhandledRejection', reason); +}); + +describe('mocha promise sanity check', () => { + it('passes with a resolved promise', () => { + return P.resolve(3); + }); + + it('passes with a rejected then resolved promise', () => { + return P.reject(someRejectionReason).catch(x => 'this should be resolved'); + }); + + var ifPromiseIt = P === Promise ? it : it.skip; + ifPromiseIt('is the native Promise', () => { + assert.equal(P, Promise); + }); +}); + +describe('onFinally', () => { + describe('no callback', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally() + .then(function onFulfilled(x) { + assert.strictEqual(x, 3); + done(); + }, function onRejected() { + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally() + .then(function onFulfilled() { + done(new Error('should not be called')); + }, function onRejected(reason) { + assert.strictEqual(reason, someRejectionReason); + done(); + }); + }); + }); + + describe('throws an exception', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + throw someRejectionReason; + }).then(function onFulfilled() { + done(new Error('should not be called')); + }, function onRejected(reason) { + assert.strictEqual(reason, someRejectionReason); + done(); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(anotherReason).finally(function onFinally() { + assert(arguments.length === 0); + throw someRejectionReason; + }).then(function onFulfilled() { + done(new Error('should not be called')); + }, function onRejected(reason) { + assert.strictEqual(reason, someRejectionReason); + done(); + }); + }); + }); + + describe('returns a non-promise', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return 4; + }).then(function onFulfilled(x) { + assert.strictEqual(x, 3); + done(); + }, function onRejected() { + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(anotherReason) + .catch((e) => { + assert.strictEqual(e, anotherReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + throw someRejectionReason; + }).then(function onFulfilled() { + done(new Error('should not be called')); + }, function onRejected(e) { + assert.strictEqual(e, someRejectionReason); + done(); + }); + }); + }); + + describe('returns a pending-forever promise', () => { + specify('from resolved', (done) => { + var timeout; + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 0.1e3); + return new P(() => {}); // forever pending + }).then(function onFulfilled(x) { + clearTimeout(timeout); + done(new Error('should not be called')); + }, function onRejected() { + clearTimeout(timeout); + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + var timeout; + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 0.1e3); + return new P(() => {}); // forever pending + }).then(function onFulfilled(x) { + clearTimeout(timeout); + done(new Error('should not be called')); + }, function onRejected() { + clearTimeout(timeout); + done(new Error('should not be called')); + }); + }); + }); + + describe('returns an immediately-fulfilled promise', () => { + specify('from resolved', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.resolved(4); + }).then(function onFulfilled(x) { + assert.strictEqual(x, 3); + done(); + }, function onRejected() { + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.resolved(4); + }).then(function onFulfilled() { + done(new Error('should not be called')); + }, function onRejected(e) { + assert.strictEqual(e, someRejectionReason); + done(); + }); + }); + }); + + describe('returns an immediately-rejected promise', () => { + specify('from resolved ', (done) => { + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.rejected(4); + }).then(function onFulfilled(x) { + done(new Error('should not be called')); + }, function onRejected(e) { + assert.strictEqual(e, 4); + done(); + }); + }); + + specify('from rejected', (done) => { + const newReason = {}; + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + return adapter.rejected(newReason); + }).then(function onFulfilled(x) { + done(new Error('should not be called')); + }, function onRejected(e) { + assert.strictEqual(e, newReason); + done(); + }); + }); + }); + + describe('returns a fulfilled-after-a-second promise', () => { + specify('from resolved', (done) => { + var timeout; + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve) => { + setTimeout(() => resolve(4), 1e3); + }); + }).then(function onFulfilled(x) { + clearTimeout(timeout); + assert.strictEqual(x, 3); + done(); + }, function onRejected() { + clearTimeout(timeout); + done(new Error('should not be called')); + }); + }); + + specify('from rejected', (done) => { + var timeout; + adapter.rejected(3) + .catch((e) => { + assert.strictEqual(e, 3); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve) => { + setTimeout(() => resolve(4), 1e3); + }); + }).then(function onFulfilled() { + clearTimeout(timeout); + done(new Error('should not be called')); + }, function onRejected(e) { + clearTimeout(timeout); + assert.strictEqual(e, 3); + done(); + }); + }); + }); + + describe('returns a rejected-after-a-second promise', () => { + specify('from resolved', (done) => { + var timeout; + adapter.resolved(3) + .then((x) => { + assert.strictEqual(x, 3); + return x; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve, reject) => { + setTimeout(() => reject(4), 1e3); + }); + }).then(function onFulfilled() { + clearTimeout(timeout); + done(new Error('should not be called')); + }, function onRejected(e) { + clearTimeout(timeout); + assert.strictEqual(e, 4); + done(); + }); + }); + + specify('from rejected', (done) => { + var timeout; + adapter.rejected(someRejectionReason) + .catch((e) => { + assert.strictEqual(e, someRejectionReason); + throw e; + }) + .finally(function onFinally() { + assert(arguments.length === 0); + timeout = setTimeout(done, 1.5e3); + return new P((resolve, reject) => { + setTimeout(() => reject(anotherReason), 1e3); + }); + }).then(function onFulfilled() { + clearTimeout(timeout); + done(new Error('should not be called')); + }, function onRejected(e) { + clearTimeout(timeout); + assert.strictEqual(e, anotherReason); + done(); + }); + }); + }); + + specify('has the correct property descriptor', () => { + var descriptor = Object.getOwnPropertyDescriptor(Promise.prototype, 'finally'); + + assert.strictEqual(descriptor.writable, true); + assert.strictEqual(descriptor.configurable, true); + }); +}); \ No newline at end of file diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 6f2ea565f..11f74fe05 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -215,6 +215,38 @@ describe( expect(reject()).toBe(undefined); }); + it('should work with .finally with resolved promise', function(done) { + let resolve: Function = null; + + testZone.run(function() { + new Promise(function(resolveFn) { + resolve = resolveFn; + }).finally(function() { + expect(arguments.length).toBe(0); + expect(Zone.current).toBe(testZone); + done(); + }); + }); + + resolve('value'); + }); + + it('should work with .finally with rejected promise', function(done) { + let reject: Function = null; + + testZone.run(function() { + new Promise(function(_, rejectFn) { + reject = rejectFn; + }).finally(function() { + expect(arguments.length).toBe(0); + expect(Zone.current).toBe(testZone); + done(); + }); + }); + + reject('error'); + }); + it('should work with Promise.resolve', () => { queueZone.run(() => { let value = null; From f22065eec207da887872cf29c0b041c9cc9261b2 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 10 Feb 2018 09:17:59 +0900 Subject: [PATCH 017/106] feat(jasmine): support Date.now in fakeAsyncTest (#1009) --- gulpfile.js | 10 +++ lib/jasmine/jasmine.ts | 72 ++++++++++++++++++-- lib/rxjs/rxjs-fake-async.ts | 23 +++++++ lib/zone-spec/fake-async-test.ts | 74 ++++++++++++++++++++ test/zone-spec/fake-async-test.spec.ts | 94 ++++++++++++++++++++++++++ 5 files changed, 268 insertions(+), 5 deletions(-) create mode 100644 lib/rxjs/rxjs-fake-async.ts diff --git a/gulpfile.js b/gulpfile.js index 44cbf142d..dda3b4e81 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -284,6 +284,14 @@ gulp.task('build/rxjs.min.js', ['compile-esm'], function(cb) { return generateScript('./lib/rxjs/rxjs.ts', 'zone-patch-rxjs.min.js', true, cb); }); +gulp.task('build/rxjs-fake-async.js', ['compile-esm'], function(cb) { + return generateScript('./lib/rxjs/rxjs-fake-async.ts', 'zone-patch-rxjs-fake-async.js', false, cb); +}); + +gulp.task('build/rxjs-fake-async.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/rxjs/rxjs-fake-async.ts', 'zone-patch-rxjs-fake-async.min.js', true, cb); +}); + gulp.task('build/closure.js', function() { return gulp.src('./lib/closure/zone_externs.js') .pipe(gulp.dest('./dist')); @@ -337,6 +345,8 @@ gulp.task('build', [ 'build/sync-test.js', 'build/rxjs.js', 'build/rxjs.min.js', + 'build/rxjs-fake-async.js', + 'build/rxjs-fake-async.min.js', 'build/closure.js' ]); diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index ce5c018c7..ddca40bcf 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -35,6 +35,8 @@ // a `beforeEach` or `it`. const syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + const symbol = Zone.__symbol__; + // This is the zone which will be used for running individual tests. // It will be a proxy zone, so that the tests function can retroactively install // different zones. @@ -45,6 +47,7 @@ // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add // fakeAsync behavior to the childZone. let testProxyZone: Zone = null; + let testProxyZoneSpec: ZoneSpec = null; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. const jasmineEnv: any = jasmine.getEnv(); @@ -56,7 +59,7 @@ }); ['it', 'xit', 'fit'].forEach((methodName) => { let originalJasmineFn: Function = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function( description: string, specDefinitions: Function, timeout: number) { arguments[1] = wrapTestInZone(specDefinitions); @@ -65,12 +68,45 @@ }); ['beforeEach', 'afterEach'].forEach((methodName) => { let originalJasmineFn: Function = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { arguments[0] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); + const originalClockFn: Function = (jasmine as any)[symbol('clock')] = jasmine['clock']; + (jasmine as any)['clock'] = function() { + const clock = originalClockFn.apply(this, arguments); + const originalTick = clock[symbol('tick')] = clock.tick; + clock.tick = function() { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); + }; + const originalMockDate = clock[symbol('mockDate')] = clock.mockDate; + clock.mockDate = function() { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + const dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(methodName => { + const originalClockFn: Function = clock[symbol(methodName)] = clock[methodName]; + clock[methodName] = function() { + const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a @@ -82,6 +118,30 @@ }; } + function runInTestZone(testBody: Function, done?: Function) { + const isClockInstalled = !!(jasmine as any)[symbol('clockInstalled')]; + let lastDelegate; + if (isClockInstalled) { + const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + const _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + lastDelegate = (testProxyZoneSpec as any).getDelegate(); + (testProxyZoneSpec as any).setDelegate(_fakeAsyncTestZoneSpec); + } + } + try { + if (done) { + return testProxyZone.run(testBody, this, [done]); + } else { + return testProxyZone.run(testBody, this); + } + } finally { + if (isClockInstalled) { + (testProxyZoneSpec as any).setDelegate(lastDelegate); + } + } + } + /** * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to * execute in a ProxyZone zone. @@ -92,9 +152,9 @@ // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. return testBody && (testBody.length ? function(done: Function) { - return testProxyZone.run(testBody, this, [done]); + runInTestZone(testBody, done); } : function() { - return testProxyZone.run(testBody, this); + runInTestZone(testBody); }); } interface QueueRunner { @@ -118,13 +178,15 @@ attrs.onComplete = ((fn) => () => { // All functions are done, clear the test zone. testProxyZone = null; + testProxyZoneSpec = null; ambientZone.scheduleMicroTask('jasmine.onComplete', fn); })(attrs.onComplete); _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function() { if (Zone.current !== ambientZone) throw new Error('Unexpected Zone: ' + Zone.current.name); - testProxyZone = ambientZone.fork(new ProxyZoneSpec()); + testProxyZoneSpec = new ProxyZoneSpec(); + testProxyZone = ambientZone.fork(testProxyZoneSpec); if (!Zone.currentTask) { // if we are not running in a task then if someone would register a // element.addEventListener and then calling element.click() the diff --git a/lib/rxjs/rxjs-fake-async.ts b/lib/rxjs/rxjs-fake-async.ts new file mode 100644 index 000000000..b5bb44bd9 --- /dev/null +++ b/lib/rxjs/rxjs-fake-async.ts @@ -0,0 +1,23 @@ +/** + * @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 {Scheduler} from 'rxjs/Scheduler'; +import {async} from 'rxjs/scheduler/async'; +import {asap} from 'rxjs/scheduler/asap'; + +Zone.__load_patch('rxjs.Scheduler.now', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + api.patchMethod(Scheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { + return Date.now.apply(self, args); + }); + api.patchMethod(async, 'now', (delegate: Function) => (self: any, args: any[]) => { + return Date.now.apply(self, args); + }); + api.patchMethod(asap, 'now', (delegate: Function) => (self: any, args: any[]) => { + return Date.now.apply(self, args); + }); +}); diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 72ef0e115..4e61c04b9 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -29,6 +29,31 @@ callbackArgs?: any; } + const OriginalDate = global.Date; + class FakeDate { + constructor() { + const d = new OriginalDate(); + d.setTime(global.Date.now()); + return d; + } + + static UTC() { + return OriginalDate.UTC(); + } + + static now() { + const fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + } + + static parse() { + return OriginalDate.parse(); + } + } + class Scheduler { // Next scheduler id. public nextId: number = 0; @@ -37,9 +62,23 @@ private _schedulerQueue: ScheduledFunction[] = []; // Current simulated time in millis. private _currentTime: number = 0; + // Current real time in millis. + private _currentRealTime: number = Date.now(); constructor() {} + getCurrentTime() { + return this._currentTime; + } + + getCurrentRealTime() { + return this._currentRealTime; + } + + setCurrentRealTime(realTime: number) { + this._currentRealTime = realTime; + } + scheduleFunction( cb: Function, delay: number, args: any[] = [], isPeriodic: boolean = false, isRequestAnimationFrame: boolean = false, id: number = -1): number { @@ -281,6 +320,32 @@ throw error; } + getCurrentTime() { + return this._scheduler.getCurrentTime(); + } + + getCurrentRealTime() { + return this._scheduler.getCurrentRealTime(); + } + + setCurrentRealTime(realTime: number) { + this._scheduler.setCurrentRealTime(realTime); + } + + static patchDate() { + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + } + + static resetDate() { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + } + tick(millis: number = 0, doTick?: (elapsed: number) => void): void { FakeAsyncTestZoneSpec.assertInZone(); this.flushMicrotasks(); @@ -415,6 +480,15 @@ } } + onInvoke(delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string): any { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } finally { + FakeAsyncTestZoneSpec.resetDate(); + } + } + findMacroTaskOption(task: Task) { if (!this.macroTaskOptions) { return null; diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 7e2dfe5c8..d9d3434ac 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -10,6 +10,9 @@ import '../../lib/zone-spec/fake-async-test'; import {isNode, patchMacroTask} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/operator/delay'; +import '../../lib/rxjs/rxjs-fake-async'; function supportNode() { return isNode; @@ -805,4 +808,95 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); }); + + describe('fakeAsyncTest should patch Date', () => { + let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + let testZoneSpec: any; + let fakeAsyncTestZone: Zone; + + beforeEach(() => { + testZoneSpec = new FakeAsyncTestZoneSpec( + 'name', false); + fakeAsyncTestZone = Zone.current.fork(testZoneSpec); + }); + + it('should get date diff correctly', () => { + fakeAsyncTestZone.run(() => { + const start = Date.now(); + testZoneSpec.tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + }); + }); + }); + + describe('fakeAsyncTest should patch jasmine.clock', ifEnvSupports(() => { + return typeof jasmine.clock === 'function'; + }, () => { + beforeEach(() => { + jasmine.clock().install(); + }); + + afterEach(() => { + jasmine.clock().uninstall(); + }); + + it('should get date diff correctly', () => { + const start = Date.now(); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + }); + + it('should mock date correctly', () => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = Date.now(); + expect(start).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + expect(end).toBe(baseTime.getTime() + 100); + }); + + it('should handle new Date correctly', () => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = new Date(); + expect(start.getTime()).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = new Date(); + expect(end.getTime() - start.getTime()).toBe(100); + expect(end.getTime()).toBe(baseTime.getTime() + 100); + }); + })); + + describe('fakeAsyncTest should patch rxjs scheduler', () => { + let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + let testZoneSpec: any; + let fakeAsyncTestZone: Zone; + + beforeEach(() => { + testZoneSpec = new FakeAsyncTestZoneSpec( + 'name', false); + fakeAsyncTestZone = Zone.current.fork(testZoneSpec); + }); + + it('should get date diff correctly', (done) => { + fakeAsyncTestZone.run(() => { + let result = null; + const observable = new Observable((subscribe: any) => { + subscribe.next('hello'); + subscribe.complete(); + }); + observable.delay(1000).subscribe(v => { + result = v; + }); + expect(result).toBe(null); + testZoneSpec.tick(1000); + expect(result).toBe('hello'); + done(); + }); + }); + }); }); From 26131098181df9b3c9d8d0f17946c725a160bb3c Mon Sep 17 00:00:00 2001 From: "Anders D. Johnson" Date: Fri, 9 Feb 2018 18:18:19 -0600 Subject: [PATCH 018/106] docs: minor formatting in API support section (#1010) * docs: minor formatting in API support section * docs: use word nonstandard --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 237d9e556..a9f854ce8 100644 --- a/README.md +++ b/README.md @@ -35,12 +35,12 @@ See this video from ng-conf 2014 for a detailed explanation: ## Standard API support -zone.js patched most standard web APIs(such as DOM events, XMLHttpRequest...) and nodejs APIs -(EventEmitter,fs ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md). +zone.js patched most standard web APIs (such as DOM events, `XMLHttpRequest`, ...) and nodejs APIs +(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md). -## Non standard API support +## Nonstandard API support -We are adding support to some non standard APIs, such as MediaQuery and +We are adding support to some nonstandard APIs, such as MediaQuery and Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details. ## Modules From 6852f1d96c74a0061333d1b1a1e3675199987d07 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 10 Feb 2018 09:19:26 +0900 Subject: [PATCH 019/106] feat(test): can handle non zone aware task in promise (#1014) --- gulpfile.js | 10 +++++ karma-dist.conf.js | 1 + lib/common/promise.ts | 2 +- lib/testing/promise-testing.ts | 68 +++++++++++++++++++++++++++++++ lib/testing/zone-testing.ts | 3 +- lib/zone-spec/async-test.ts | 37 ++++++++++++++++- test/browser-zone-setup.ts | 1 + test/node_entry_point.ts | 1 + test/zone-spec/async-test.spec.ts | 27 ++++++++++++ 9 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 lib/testing/promise-testing.ts diff --git a/gulpfile.js b/gulpfile.js index dda3b4e81..0650bff2c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -200,6 +200,14 @@ gulp.task('build/zone-patch-socket-io.min.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/socket-io.ts', 'zone-patch-socket-io.min.js', true, cb); }); +gulp.task('build/zone-patch-promise-testing.js', ['compile-esm'], function(cb) { + return generateScript('./lib/testing/promise-testing.ts', 'zone-patch-promise-test.js', false, cb); +}); + +gulp.task('build/zone-patch-promise-testing.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/testing/promise-testing.ts', 'zone-patch-promise-test.min.js', true, cb); +}); + gulp.task('build/bluebird.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb); }); @@ -323,6 +331,8 @@ gulp.task('build', [ 'build/zone-patch-user-media.min.js', 'build/zone-patch-socket-io.js', 'build/zone-patch-socket-io.min.js', + 'build/zone-patch-promise-testing.js', + 'build/zone-patch-promise-testing.min.js', 'build/zone-mix.js', 'build/bluebird.js', 'build/bluebird.min.js', diff --git a/karma-dist.conf.js b/karma-dist.conf.js index 517088ac8..a96fe0993 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -20,5 +20,6 @@ module.exports = function (config) { config.files.push('dist/sync-test.js'); config.files.push('dist/task-tracking.js'); config.files.push('dist/wtf.js'); + config.files.push('dist/zone-patch-promise-test.js'); config.files.push('build/test/main.js'); }; diff --git a/lib/common/promise.ts b/lib/common/promise.ts index f0e4995d7..bb34f5a20 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -268,7 +268,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr // if error occurs, should always return this error resolvePromise(chainPromise, false, error); } - }); + }, chainPromise as TaskData); } const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; diff --git a/lib/testing/promise-testing.ts b/lib/testing/promise-testing.ts new file mode 100644 index 000000000..f16a7120f --- /dev/null +++ b/lib/testing/promise-testing.ts @@ -0,0 +1,68 @@ +/** + * @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 + */ + + /** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ +Zone.__load_patch('promisefortest', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const symbolState: string = api.symbol('state'); + const UNRESOLVED: null = null; + const symbolParentUnresolved = api.symbol('parentUnresolved'); + + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + (Promise as any)[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + let oriThen = (Promise as any)[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = (Promise as any)[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function() { + const chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + const asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount ++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + + (Promise as any)[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + const oriThen = (Promise as any)[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + (Promise as any)[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; +}); \ No newline at end of file diff --git a/lib/testing/zone-testing.ts b/lib/testing/zone-testing.ts index 3f0984fce..51218110e 100644 --- a/lib/testing/zone-testing.ts +++ b/lib/testing/zone-testing.ts @@ -12,4 +12,5 @@ import '../zone-spec/proxy'; import '../zone-spec/sync-test'; import '../jasmine/jasmine'; import '../zone-spec/async-test'; -import '../zone-spec/fake-async-test'; \ No newline at end of file +import '../zone-spec/fake-async-test'; +import './promise-testing'; \ No newline at end of file diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index 1a11663ac..c68c24777 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -7,21 +7,27 @@ */ class AsyncTestZoneSpec implements ZoneSpec { + static symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + _finishCallback: Function; _failCallback: Function; _pendingMicroTasks: boolean = false; _pendingMacroTasks: boolean = false; _alreadyErrored: boolean = false; runZone = Zone.current; + unresolvedChainedPromiseCount = 0; constructor(finishCallback: Function, failCallback: Function, namePrefix: string) { this._finishCallback = finishCallback; this._failCallback = failCallback; this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { + 'AsyncTestZoneSpec': this + }; } _finishCallbackIfDone() { - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(() => { setTimeout(() => { @@ -33,10 +39,37 @@ class AsyncTestZoneSpec implements ZoneSpec { } } + patchPromiseForTest() { + const patchPromiseForTest = (Promise as any)[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + } + + unPatchPromiseForTest() { + const unPatchPromiseForTest = (Promise as any)[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + } + // ZoneSpec implementation below. name: string; + properties: {[key: string]: any}; + + onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task { + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if ((task.data as any)[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount --; + } + } + return delegate.scheduleTask(target, task); + } + // 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. @@ -44,8 +77,10 @@ class AsyncTestZoneSpec implements ZoneSpec { parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, applyThis: any, applyArgs: any[], source: string): any { try { + this.patchPromiseForTest(); return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { + this.unPatchPromiseForTest(); this._finishCallbackIfDone(); } } diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index bdefeff31..2e6974bb2 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -19,3 +19,4 @@ import '../lib/zone-spec/sync-test'; import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/extra/cordova'; +import '../lib/testing/promise-testing'; diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index 1a926e3c5..27ba367ca 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -24,6 +24,7 @@ import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/rxjs/rxjs'; +import '../lib/testing/promise-testing'; // Setup test environment import './test-env-setup-jasmine'; diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index c70b5ef49..1fdf30072 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -316,4 +316,31 @@ describe('AsyncTestZoneSpec', function() { }); }); + + describe('non zone aware async task in promise should be detected', () => { + it('should be able to detect non zone aware async task in promise', (done) => { + let finished = false; + + const testZoneSpec = new AsyncTestZoneSpec( + () => { + expect(finished).toBe(true); + done(); + }, + () => { + done.fail('async zone called failCallback unexpectedly'); + }, + 'name'); + + const atz = Zone.current.fork(testZoneSpec); + + atz.run(() => { + new Promise((res, rej) => { + const g: any = typeof window === 'undefined' ? global : window; + g[Zone.__symbol__('setTimeout')](res, 100); + }).then(() => { + finished = true; + }); + }); + }); + }); }); From 6b6b38a6a6ce0bd2c75718f79f01c0b0e3bf34c8 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 13 Feb 2018 07:46:34 +0900 Subject: [PATCH 020/106] feat(rollup): use new rollup config to prevent warning (#1006) --- gulpfile.js | 188 +++++++++++++++++++++++++++++----------------------- 1 file changed, 105 insertions(+), 83 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 0650bff2c..cae2fc587 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -9,7 +9,7 @@ var gulp = require('gulp'); var rollup = require('gulp-rollup'); -var rename = require("gulp-rename"); +var rename = require('gulp-rename'); var uglify = require('gulp-uglify'); var pump = require('pump'); var path = require('path'); @@ -21,28 +21,36 @@ function generateScript(inFile, outFile, minify, callback) { var parts = [ gulp.src('./build-esm/lib/**/*.js') .pipe(rollup({ - entry: inFile, - format: 'umd', - onwarn: function (warning) { + input: inFile, + onwarn: function(warning) { // https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined if (warning.code === 'THIS_IS_UNDEFINED') { return; } console.error(warning.message); }, - banner: '/**\n' - + '* @license\n' - + '* Copyright Google Inc. All Rights Reserved.\n' - + '*\n' - + '* Use of this source code is governed by an MIT-style license that can be\n' - + '* found in the LICENSE file at https://angular.io/license\n' - + '*/', - globals: { - 'rxjs/Observable': 'Rx', - 'rxjs/Subscriber': 'Rx', - 'rxjs/Subscription': 'Rx', - 'rxjs/scheduler/asap': 'Rx.Scheduler', - 'rxjs/symbol/rxSubscriber': 'Rx.Symbol' + output: { + format: 'umd', + banner: '/**\n' + + '* @license\n' + + '* Copyright Google Inc. All Rights Reserved.\n' + + '*\n' + + '* Use of this source code is governed by an MIT-style license that can be\n' + + '* found in the LICENSE file at https://angular.io/license\n' + + '*/', + globals: { + 'rxjs/Observable': 'Rx', + 'rxjs/Subscriber': 'Rx', + 'rxjs/Subscription': 'Rx', + 'rxjs/scheduler/asap': 'Rx.Scheduler', + 'rxjs/symbol/rxSubscriber': 'Rx.Symbol' + } + }, + external: id => { + if (/build-esm/.test(id)) { + return false; + } + return /rxjs/.test(id); } })) .pipe(rename(outFile)), @@ -56,21 +64,22 @@ function generateScript(inFile, outFile, minify, callback) { // returns the script path for the current platform function platformScriptPath(path) { - return /^win/.test(os.platform()) ? `${path}.cmd` : path; + return /^win/.test(os.platform()) ? `${path}.cmd` : path; } function tsc(config, cb) { - spawn(path.normalize(platformScriptPath('./node_modules/.bin/tsc')), ['-p', config], {stdio: 'inherit'}) - .on('close', function(exitCode) { - if (exitCode) { - var err = new Error('TypeScript compiler failed'); - // The stack is not useful in this context. - err.showStack = false; - cb(err); - } else { - cb(); - } - }); + spawn(path.normalize(platformScriptPath('./node_modules/.bin/tsc')), ['-p', config], { + stdio: 'inherit' + }).on('close', function(exitCode) { + if (exitCode) { + var err = new Error('TypeScript compiler failed'); + // The stack is not useful in this context. + err.showStack = false; + cb(err); + } else { + cb(); + } + }); } // This is equivalent to `npm run tsc`. @@ -91,7 +100,9 @@ gulp.task('compile-esm-node', function(cb) { }); gulp.task('build/zone.js.d.ts', ['compile-esm'], function() { - return gulp.src('./build-esm/lib/zone.d.ts').pipe(rename('zone.js.d.ts')).pipe(gulp.dest('./dist')); + return gulp.src('./build-esm/lib/zone.d.ts') + .pipe(rename('zone.js.d.ts')) + .pipe(gulp.dest('./dist')); }); // Zone for Node.js environment. @@ -125,7 +136,7 @@ gulp.task('build/zone-testing.js', ['compile-esm'], function(cb) { // Zone for electron/nw environment. gulp.task('build/zone-mix.js', ['compile-esm-node'], function(cb) { - return generateScript('./lib/mix/rollup-mix.ts', 'zone-mix.js', false, cb); + return generateScript('./lib/mix/rollup-mix.ts', 'zone-mix.js', false, cb); }); gulp.task('build/zone-error.js', ['compile-esm'], function(cb) { @@ -137,59 +148,68 @@ gulp.task('build/zone-error.min.js', ['compile-esm'], function(cb) { }); gulp.task('build/webapis-media-query.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-media-query.ts', 'webapis-media-query.js', false, cb); + return generateScript( + './lib/browser/webapis-media-query.ts', 'webapis-media-query.js', false, cb); }); gulp.task('build/webapis-media-query.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-media-query.ts', 'webapis-media-query.min.js', true, cb); + return generateScript( + './lib/browser/webapis-media-query.ts', 'webapis-media-query.min.js', true, cb); }); gulp.task('build/webapis-notification.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.js', false, cb); + return generateScript( + './lib/browser/webapis-notification.ts', 'webapis-notification.js', false, cb); }); gulp.task('build/webapis-notification.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb); + return generateScript( + './lib/browser/webapis-notification.ts', 'webapis-notification.min.js', true, cb); }); gulp.task('build/webapis-rtc-peer-connection.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb); + return generateScript( + './lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.js', false, cb); }); gulp.task('build/webapis-rtc-peer-connection.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true, cb); + return generateScript( + './lib/browser/webapis-rtc-peer-connection.ts', 'webapis-rtc-peer-connection.min.js', true, + cb); }); gulp.task('build/webapis-shadydom.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb); + return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.js', false, cb); }); gulp.task('build/webapis-shadydom.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.min.js', true, cb); + return generateScript('./lib/browser/shadydom.ts', 'webapis-shadydom.min.js', true, cb); }); gulp.task('build/zone-patch-cordova.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.js', false, cb); + return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.js', false, cb); }); gulp.task('build/zone-patch-cordova.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.min.js', true, cb); + return generateScript('./lib/extra/cordova.ts', 'zone-patch-cordova.min.js', true, cb); }); gulp.task('build/zone-patch-electron.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.js', false, cb); + return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.js', false, cb); }); gulp.task('build/zone-patch-electron.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.min.js', true, cb); + return generateScript('./lib/extra/electron.ts', 'zone-patch-electron.min.js', true, cb); }); gulp.task('build/zone-patch-user-media.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.js', false, cb); + return generateScript( + './lib/browser/webapis-user-media.ts', 'zone-patch-user-media.js', false, cb); }); gulp.task('build/zone-patch-user-media.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb); + return generateScript( + './lib/browser/webapis-user-media.ts', 'zone-patch-user-media.min.js', true, cb); }); gulp.task('build/zone-patch-socket-io.js', ['compile-esm'], function(cb) { @@ -209,11 +229,11 @@ gulp.task('build/zone-patch-promise-testing.min.js', ['compile-esm'], function(c }); gulp.task('build/bluebird.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb); + return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb); }); gulp.task('build/bluebird.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb); + return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.min.js', true, cb); }); gulp.task('build/zone-patch-jsonp.js', ['compile-esm'], function(cb) { @@ -241,11 +261,13 @@ gulp.task('build/mocha-patch.min.js', ['compile-esm'], function(cb) { }); gulp.task('build/long-stack-trace-zone.js', ['compile-esm'], function(cb) { - return generateScript('./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.js', false, cb); + return generateScript( + './lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.js', false, cb); }); gulp.task('build/long-stack-trace-zone.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.min.js', true, cb); + return generateScript( + './lib/zone-spec/long-stack-trace.ts', 'long-stack-trace-zone.min.js', true, cb); }); gulp.task('build/proxy-zone.js', ['compile-esm'], function(cb) { @@ -301,8 +323,7 @@ gulp.task('build/rxjs-fake-async.min.js', ['compile-esm'], function(cb) { }); gulp.task('build/closure.js', function() { - return gulp.src('./lib/closure/zone_externs.js') - .pipe(gulp.dest('./dist')); + return gulp.src('./lib/closure/zone_externs.js').pipe(gulp.dest('./dist')); }); gulp.task('build', [ @@ -396,12 +417,12 @@ gulp.task('lint', () => { const tslintConfig = require('./tslint.json'); return gulp.src(['lib/**/*.ts', 'test/**/*.ts']) - .pipe(tslint({ - tslint: require('tslint').default, - configuration: tslintConfig, - formatter: 'prose', - })) - .pipe(tslint.report({emitError: true})); + .pipe(tslint({ + tslint: require('tslint').default, + configuration: tslintConfig, + formatter: 'prose', + })) + .pipe(tslint.report({emitError: true})); }); // clang-format entry points @@ -415,15 +436,16 @@ gulp.task('format:enforce', () => { const format = require('gulp-clang-format'); const clangFormat = require('clang-format'); return gulp.src(srcsToFmt).pipe( - format.checkFormat('file', clangFormat, {verbose: true, fail: true})); + format.checkFormat('file', clangFormat, {verbose: true, fail: true})); }); // Format the source code with clang-format (see .clang-format) gulp.task('format', () => { const format = require('gulp-clang-format'); const clangFormat = require('clang-format'); - return gulp.src(srcsToFmt, { base: '.' }).pipe( - format.format('file', clangFormat)).pipe(gulp.dest('.')); + return gulp.src(srcsToFmt, {base: '.'}) + .pipe(format.format('file', clangFormat)) + .pipe(gulp.dest('.')); }); // Update the changelog with the latest changes @@ -431,35 +453,35 @@ gulp.task('changelog', () => { const conventionalChangelog = require('gulp-conventional-changelog'); return gulp.src('CHANGELOG.md') - .pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, { - // Conventional Changelog Context - // We have to manually set version number so it doesn't get prefixed with `v` - // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10 - currentTag: require('./package.json').version - })) - .pipe(gulp.dest('./')); + .pipe(conventionalChangelog({preset: 'angular', releaseCount: 1}, { + // Conventional Changelog Context + // We have to manually set version number so it doesn't get prefixed with `v` + // See https://github.com/conventional-changelog/conventional-changelog-core/issues/10 + currentTag: require('./package.json').version + })) + .pipe(gulp.dest('./')); }); // run promise aplus test gulp.task('promisetest', ['build/zone-node.js'], (cb) => { - const promisesAplusTests = require('promises-aplus-tests'); - const adapter = require('./promise-adapter'); - promisesAplusTests(adapter, { reporter: "dot" }, function (err) { - if (err) { - cb(err); - } else { - cb(); - } - }); + const promisesAplusTests = require('promises-aplus-tests'); + const adapter = require('./promise-adapter'); + promisesAplusTests(adapter, {reporter: 'dot'}, function(err) { + if (err) { + cb(err); + } else { + cb(); + } + }); }); // check dist file size limitation gulp.task('filesize', ['build'], (cb) => { - const checker = require('./check-file-size'); - const result = checker(require('./file-size-limit.json')); - if (result) { - cb(); - } else { - cb('check file size failed'); - } + const checker = require('./check-file-size'); + const result = checker(require('./file-size-limit.json')); + if (result) { + cb(); + } else { + cb('check file size failed'); + } }); From 8ee88da4087cbac9593a0cef04d43c04c1de0828 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 13 Feb 2018 07:47:15 +0900 Subject: [PATCH 021/106] feat(patch): fix #1011, patch ResizeObserver (#1012) --- NON-STANDARD-APIS.md | 14 +++- gulpfile.js | 10 +++ lib/browser/webapis-resize-observer.ts | 88 ++++++++++++++++++++++++++ test/browser-zone-setup.ts | 1 + test/browser/browser.spec.ts | 57 +++++++++++++++++ 5 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 lib/browser/webapis-resize-observer.ts diff --git a/NON-STANDARD-APIS.md b/NON-STANDARD-APIS.md index 4e4dbe9a7..8cca25bdd 100644 --- a/NON-STANDARD-APIS.md +++ b/NON-STANDARD-APIS.md @@ -170,7 +170,7 @@ In electron, we patched the following APIs with `zone.js` ## Usage. -add/update following line into `polyfill.ts`. +add following line into `polyfill.ts` after loading zone-mix. ``` //import 'zone.js/dist/zone'; // originally added by angular-cli, comment it out @@ -194,7 +194,6 @@ user need to patch `io` themselves just like following code. ``` - please reference the sample repo [zone-socketio](https://github.com/JiaLiPassion/zone-socketio) about detail usage. @@ -217,3 +216,14 @@ Zone['__zone_symbol__jsonp']({ failedFuncName: 'jsonpFailedCallback' }); ``` +* ResizeObserver + +Currently only `Chrome 64` native support this feature. +you can add the following line into `polyfill.ts` after loading `zone.js`. + +``` +import 'zone.js/dist/zone'; +import 'zone.js/dist/zone-patch-resize-observer'; +``` + +there is a sample repo [zone-resize-observer](https://github.com/JiaLiPassion/zone-resize-observer) here diff --git a/gulpfile.js b/gulpfile.js index cae2fc587..b3f63b29a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -228,6 +228,14 @@ gulp.task('build/zone-patch-promise-testing.min.js', ['compile-esm'], function(c return generateScript('./lib/testing/promise-testing.ts', 'zone-patch-promise-test.min.js', true, cb); }); +gulp.task('build/zone-patch-resize-observer.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/webapis-resize-observer.ts', 'zone-patch-resize-observer.js', false, cb); +}); + +gulp.task('build/zone-patch-resize-observer.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/webapis-resize-observer.ts', 'zone-patch-resize-observer.min.js', true, cb); +}); + gulp.task('build/bluebird.js', ['compile-esm'], function(cb) { return generateScript('./lib/extra/bluebird.ts', 'zone-bluebird.js', false, cb); }); @@ -354,6 +362,8 @@ gulp.task('build', [ 'build/zone-patch-socket-io.min.js', 'build/zone-patch-promise-testing.js', 'build/zone-patch-promise-testing.min.js', + 'build/zone-patch-resize-observer.js', + 'build/zone-patch-resize-observer.min.js', 'build/zone-mix.js', 'build/bluebird.js', 'build/bluebird.min.js', diff --git a/lib/browser/webapis-resize-observer.ts b/lib/browser/webapis-resize-observer.ts new file mode 100644 index 000000000..cfaa70f0b --- /dev/null +++ b/lib/browser/webapis-resize-observer.ts @@ -0,0 +1,88 @@ +/** + * @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.__load_patch('ResizeObserver', (global: any, Zone: any, api: _ZonePrivate) => { + const ResizeObserver = global['ResizeObserver']; + if (!ResizeObserver) { + return; + } + + const resizeObserverSymbol = api.symbol('ResizeObserver'); + + api.patchMethod(global, 'ResizeObserver', (delegate: Function) => (self: any, args: any[]) => { + const callback = args.length > 0 ? args[0] : null; + if (callback) { + args[0] = function(entries: any, observer: any) { + const zones: {[zoneName: string]: any} = {}; + const currZone = Zone.current; + for (let entry of entries) { + let zone = entry.target[resizeObserverSymbol]; + if (!zone) { + zone = currZone; + } + let zoneEntriesInfo = zones[zone.name]; + if (!zoneEntriesInfo) { + zones[zone.name] = zoneEntriesInfo = {entries: [], zone: zone}; + } + zoneEntriesInfo.entries.push(entry); + } + + Object.keys(zones).forEach(zoneName => { + const zoneEntriesInfo = zones[zoneName]; + if (zoneEntriesInfo.zone !== Zone.current) { + zoneEntriesInfo.zone.run( + callback, this, [zoneEntriesInfo.entries, observer], 'ResizeObserver'); + } else { + callback.call(this, zoneEntriesInfo.entries, observer); + } + }); + }; + } + return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); + }); + + api.patchMethod(ResizeObserver.prototype, 'observe', (delegate: Function) => (self: any, args: any[]) => { + const target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + let targets = self[resizeObserverSymbol]; + if (!targets) { + targets = self[resizeObserverSymbol] = []; + } + targets.push(target); + target[resizeObserverSymbol] = Zone.current; + return delegate.apply(self, args); + }); + + api.patchMethod(ResizeObserver.prototype, 'unobserve', (delegate: Function) => (self: any, args: any[]) => { + const target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + let targets = self[resizeObserverSymbol]; + if (targets) { + for (let i = 0; i < targets.length; i ++) { + if (targets[i] === target) { + targets.splice(i, 1); + break; + } + } + } + target[resizeObserverSymbol] = undefined; + return delegate.apply(self, args); + }); + + api.patchMethod(ResizeObserver.prototype, 'disconnect', (delegate: Function) => (self: any, args: any[]) => { + const targets = self[resizeObserverSymbol]; + if (targets) { + targets.forEach((target: any) => {target[resizeObserverSymbol] = undefined;}); + self[resizeObserverSymbol] = undefined; + } + return delegate.apply(self, args); + }); +}); diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 2e6974bb2..476ffdb0d 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -20,3 +20,4 @@ import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/extra/cordova'; import '../lib/testing/promise-testing'; +import '../lib/browser/webapis-resize-observer'; diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 82845f2ae..6f312eafe 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -2470,6 +2470,62 @@ describe('Zone', function() { }); })); + describe('ResizeObserver', ifEnvSupports('ResizeObserver', () => { + it('ResizeObserver callback should be in zone', (done) => { + const ResizeObserver = (window as any)['ResizeObserver']; + const div = document.createElement('div'); + const zone = Zone.current.fork({ + name: 'observer' + }); + const observer = new ResizeObserver((entries: any, ob: any) => { + expect(Zone.current.name).toEqual(zone.name); + + expect(entries.length).toBe(1); + expect(entries[0].target).toBe(div); + done(); + }); + + zone.run(() => { + observer.observe(div); + }); + + document.body.appendChild(div); + }); + + it('ResizeObserver callback should be able to in different zones which when they were observed', (done) => { + const ResizeObserver = (window as any)['ResizeObserver']; + const div1 = document.createElement('div'); + const div2 = document.createElement('div'); + const zone = Zone.current.fork({ + name: 'observer' + }); + let count = 0; + const observer = new ResizeObserver((entries: any, ob: any) => { + entries.forEach((entry: any) => { + if (entry.target === div1) { + expect(Zone.current.name).toEqual(zone.name); + } else { + expect(Zone.current.name).toEqual(''); + } + }); + count ++; + if (count === 2) { + done(); + } + }); + + zone.run(() => { + observer.observe(div1); + }); + Zone.root.run(() => { + observer.observe(div2); + }); + + document.body.appendChild(div1); + document.body.appendChild(div2); + }); + })); + xdescribe('getUserMedia', () => { it('navigator.mediaDevices.getUserMedia should in zone', ifEnvSupportsWithDone( @@ -2516,6 +2572,7 @@ describe('Zone', function() { }); }); })); + }); }); }); From e1df4bc636b4de6e89b24349dcbb3a95ce17220c Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 17 Feb 2018 10:39:08 +0900 Subject: [PATCH 022/106] fix(jasmine): fix #1015, make jasmine patch compatible to jasmine 3.x (#1016) --- .travis.yml | 4 + karma-dist-sauce-jasmine3.conf.js | 12 + lib/jasmine/jasmine.ts | 164 +++-- package-lock.json | 703 ++++++++++++++------- package.json | 6 +- test/browser/browser.spec.ts | 2 + test/browser/requestAnimationFrame.spec.ts | 84 +-- test/common/Promise.spec.ts | 9 +- test/rxjs/rxjs.fromEvent.spec.ts | 173 ++--- test/test-util.ts | 4 +- 10 files changed, 771 insertions(+), 390 deletions(-) create mode 100644 karma-dist-sauce-jasmine3.conf.js diff --git a/.travis.yml b/.travis.yml index a9f810124..55a77ad33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,3 +38,7 @@ script: - node_modules/.bin/gulp test/node - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js + - npm install jasmine@3.0.0 jasmine-core@3.0.0 + - npm run test:phantomjs-single + - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run + - node_modules/.bin/gulp test/node diff --git a/karma-dist-sauce-jasmine3.conf.js b/karma-dist-sauce-jasmine3.conf.js new file mode 100644 index 000000000..550d2ad94 --- /dev/null +++ b/karma-dist-sauce-jasmine3.conf.js @@ -0,0 +1,12 @@ +/** + * @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 + */ + +module.exports = function (config) { + require('./karma-dist-jasmine.conf.js')(config); + require('./sauce.conf')(config, ['SL_IOS9', 'SL_CHROME', 'SL_FIREFOX_54', 'SL_SAFARI8', 'SL_SAFARI9', 'SL_SAFARI10', 'SL_IOS8', 'SL_IOS9', 'SL_IOS10', 'SL_IE9', 'SL_IE10', 'SL_IE11', 'SL_MSEDGE15', 'SL_ANDROID4.4', 'SL_ANDROID5.1']) +}; diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index ddca40bcf..00d9810d9 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -9,23 +9,27 @@ 'use strict'; (() => { const __extends = function(d: any, b: any) { - for (const p in b) - if (b.hasOwnProperty(p)) d[p] = b[p]; + for (const 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 (__ as any)()); + d.prototype = + b === null + ? Object.create(b) + : ((__.prototype = b.prototype), new (__ as any)()); }; // 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 as any)['__zone_patch__']) - throw new Error('\'jasmine\' has already been patched with \'Zone\'.'); + throw new Error(`'jasmine' has already been patched with 'Zone'.`); (jasmine as any)['__zone_patch__'] = true; - const SyncTestZoneSpec: {new (name: string): ZoneSpec} = (Zone as any)['SyncTestZoneSpec']; - const ProxyZoneSpec: {new (): ZoneSpec} = (Zone as any)['ProxyZoneSpec']; + const SyncTestZoneSpec: { new (name: string): ZoneSpec } = (Zone as any)[ + 'SyncTestZoneSpec' + ]; + const ProxyZoneSpec: { new (): ZoneSpec } = (Zone as any)['ProxyZoneSpec']; if (!SyncTestZoneSpec) throw new Error('Missing: SyncTestZoneSpec'); if (!ProxyZoneSpec) throw new Error('Missing: ProxyZoneSpec'); @@ -37,47 +41,49 @@ const symbol = Zone.__symbol__; - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - let testProxyZone: Zone = null; - let testProxyZoneSpec: ZoneSpec = null; - // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. const jasmineEnv: any = jasmine.getEnv(); - ['describe', 'xdescribe', 'fdescribe'].forEach((methodName) => { + ['describe', 'xdescribe', 'fdescribe'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; - jasmineEnv[methodName] = function(description: string, specDefinitions: Function) { - return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + jasmineEnv[methodName] = function( + description: string, + specDefinitions: Function + ) { + return originalJasmineFn.call( + this, + description, + wrapDescribeInZone(specDefinitions) + ); }; }); - ['it', 'xit', 'fit'].forEach((methodName) => { + ['it', 'xit', 'fit'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function( - description: string, specDefinitions: Function, timeout: number) { + description: string, + specDefinitions: Function, + timeout: number + ) { arguments[1] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach((methodName) => { + ['beforeEach', 'afterEach'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { + jasmineEnv[methodName] = function( + specDefinitions: Function, + timeout: number + ) { arguments[0] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); - const originalClockFn: Function = (jasmine as any)[symbol('clock')] = jasmine['clock']; + const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = + jasmine['clock']); (jasmine as any)['clock'] = function() { const clock = originalClockFn.apply(this, arguments); - const originalTick = clock[symbol('tick')] = clock.tick; + const originalTick = (clock[symbol('tick')] = clock.tick); clock.tick = function() { const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { @@ -85,17 +91,23 @@ } return originalTick.apply(this, arguments); }; - const originalMockDate = clock[symbol('mockDate')] = clock.mockDate; + const originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); clock.mockDate = function() { const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { const dateTime = arguments[0]; - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); + return fakeAsyncZoneSpec.setCurrentRealTime.apply( + fakeAsyncZoneSpec, + dateTime && typeof dateTime.getTime === 'function' + ? [dateTime.getTime()] + : arguments + ); } return originalMockDate.apply(this, arguments); }; ['install', 'uninstall'].forEach(methodName => { - const originalClockFn: Function = clock[symbol(methodName)] = clock[methodName]; + const originalClockFn: Function = (clock[symbol(methodName)] = + clock[methodName]); clock[methodName] = function() { const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; if (FakeAsyncTestZoneSpec) { @@ -114,12 +126,18 @@ */ function wrapDescribeInZone(describeBody: Function): Function { return function() { - return syncZone.run(describeBody, this, arguments as any as any[]); + return syncZone.run(describeBody, this, (arguments as any) as any[]); }; } - function runInTestZone(testBody: Function, done?: Function) { + function runInTestZone( + testBody: Function, + queueRunner: any, + done?: Function + ) { const isClockInstalled = !!(jasmine as any)[symbol('clockInstalled')]; + const testProxyZoneSpec = queueRunner.testProxyZoneSpec; + const testProxyZone = queueRunner.testProxyZone; let lastDelegate; if (isClockInstalled) { const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; @@ -151,54 +169,100 @@ // The `done` callback is only passed through if the function expects at least one argument. // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. - return testBody && (testBody.length ? function(done: Function) { - runInTestZone(testBody, done); - } : function() { - runInTestZone(testBody); - }); + return ( + testBody && + (testBody.length + ? function(done: Function) { + return runInTestZone(testBody, this.queueRunner, done); + } + : function() { + return runInTestZone(testBody, this.queueRunner); + }) + ); } interface QueueRunner { execute(): void; } interface QueueRunnerAttrs { - queueableFns: {fn: Function}[]; + queueableFns: { fn: Function }[]; onComplete: () => void; clearStack: (fn: any) => void; onException: (error: any) => void; catchException: () => boolean; userContext: any; - timeout: {setTimeout: Function, clearTimeout: Function}; + timeout: { setTimeout: Function; clearTimeout: Function }; fail: () => void; } - const QueueRunner = (jasmine as any).QueueRunner as {new (attrs: QueueRunnerAttrs): QueueRunner}; + const QueueRunner = (jasmine as any).QueueRunner as { + new (attrs: QueueRunnerAttrs): QueueRunner; + }; (jasmine as any).QueueRunner = (function(_super) { __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs: {onComplete: Function}) { - attrs.onComplete = ((fn) => () => { + function ZoneQueueRunner(attrs: { + onComplete: Function; + userContext?: any; + }) { + attrs.onComplete = (fn => () => { // All functions are done, clear the test zone. - testProxyZone = null; - testProxyZoneSpec = null; + this.testProxyZone = null; + this.testProxyZoneSpec = null; ambientZone.scheduleMicroTask('jasmine.onComplete', fn); })(attrs.onComplete); + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if ((jasmine as any).UserContext) { + if (!attrs.userContext) { + attrs.userContext = new (jasmine as any).UserContext(); + } + attrs.userContext.queueRunner = this; + } else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function() { - if (Zone.current !== ambientZone) throw new Error('Unexpected Zone: ' + Zone.current.name); - testProxyZoneSpec = new ProxyZoneSpec(); - testProxyZone = ambientZone.fork(testProxyZoneSpec); + let zone: Zone = Zone.current; + let isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); if (!Zone.currentTask) { // if we are not running in a task then if someone would register a // element.addEventListener and then calling element.click() the // addEventListener callback would think that it is the top most task and would // drain the microtask queue on element.click() which would be incorrect. // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask( - 'jasmine.execute().forceTask', () => QueueRunner.prototype.execute.call(this)); + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', () => + QueueRunner.prototype.execute.call(this) + ); } else { _super.prototype.execute.call(this); } }; return ZoneQueueRunner; - }(QueueRunner)); + })(QueueRunner); })(); diff --git a/package-lock.json b/package-lock.json index 47fd50988..bcdc7d6af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -91,6 +91,15 @@ "ansi-wrap": "0.1.0" } }, + "ansi-gray": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", + "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", + "dev": true, + "requires": { + "ansi-wrap": "0.1.0" + } + }, "ansi-regex": { "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", @@ -202,11 +211,6 @@ "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", "dev": true }, - "array-differ": { - "version": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", - "dev": true - }, "array-find-index": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", @@ -342,11 +346,6 @@ "tweetnacl": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" } }, - "beeper": { - "version": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", - "dev": true - }, "better-assert": { "version": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", @@ -636,6 +635,12 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "dev": true + }, "colors": { "version": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", @@ -1499,32 +1504,6 @@ "void-elements": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz" } }, - "duplexer2": { - "version": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, "duplexer3": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", @@ -1732,6 +1711,12 @@ } } }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "dev": true + }, "expand-braces": { "version": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", @@ -2633,14 +2618,6 @@ } } }, - "glogg": { - "version": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz", - "integrity": "sha1-f+DxmfV6yQbPUS/urY+Q7kooT8U=", - "dev": true, - "requires": { - "sparkles": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz" - } - }, "google-closure-compiler": { "version": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20170409.0.0.tgz", "integrity": "sha1-3Bvimp9+74YRNkUzsnG5+sdXyXA=", @@ -2743,7 +2720,7 @@ "archy": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "deprecated": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "interpret": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz", "liftoff": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", @@ -2813,7 +2790,7 @@ "requires": { "clang-format": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.46.tgz", "gulp-diff": "1.0.0", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "pkginfo": "0.3.1", "stream-combiner2": "1.1.1", "stream-equal": "0.1.6", @@ -2959,7 +2936,7 @@ "cli-color": "1.2.0", "diff": "2.2.3", "event-stream": "3.3.4", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "through2": "2.0.3" }, "dependencies": { @@ -3190,7 +3167,7 @@ "add-stream": "1.0.0", "concat-stream": "1.6.0", "conventional-changelog": "1.1.7", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "object-assign": "4.1.1", "through2": "2.0.3" }, @@ -3456,7 +3433,7 @@ "requires": { "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "byline": "https://registry.npmjs.org/byline/-/byline-4.2.2.tgz", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "lodash": "3.10.1", "node-version-compare": "https://registry.npmjs.org/node-version-compare/-/node-version-compare-1.0.1.tgz", "resolve": "1.4.0", @@ -3797,7 +3774,7 @@ "integrity": "sha1-m9P/T7wW1MvZq7CP94bbibVj6T0=", "dev": true, "requires": { - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "map-stream": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" } @@ -3809,7 +3786,7 @@ "requires": { "deap": "https://registry.npmjs.org/deap/-/deap-1.0.0.tgz", "fancy-log": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "gulp-util": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "gulp-util": "3.0.8", "isobject": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", "uglify-js": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", @@ -3841,118 +3818,442 @@ } }, "gulp-util": { - "version": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", "dev": true, "requires": { - "array-differ": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "array-uniq": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "beeper": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "dateformat": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", - "fancy-log": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "gulplog": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "has-gulplog": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "lodash._reescape": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "lodash._reevaluate": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "lodash._reinterpolate": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "lodash.template": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "multipipe": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "replace-ext": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "vinyl": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz" + "array-differ": "1.0.0", + "array-uniq": "1.0.3", + "beeper": "1.1.1", + "chalk": "1.1.3", + "dateformat": "2.2.0", + "fancy-log": "1.3.2", + "gulplog": "1.0.0", + "has-gulplog": "0.1.0", + "lodash._reescape": "3.0.0", + "lodash._reevaluate": "3.0.0", + "lodash._reinterpolate": "3.0.0", + "lodash.template": "3.6.2", + "minimist": "1.2.0", + "multipipe": "0.1.2", + "object-assign": "3.0.0", + "replace-ext": "0.0.1", + "through2": "2.0.3", + "vinyl": "0.5.3" }, "dependencies": { "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, + "array-differ": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", + "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", + "dev": true + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "beeper": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", + "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", + "dev": true + }, "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" } }, + "clone": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", + "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", + "dev": true + }, + "clone-stats": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", + "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, "dateformat": { - "version": "https://registry.npmjs.org/dateformat/-/dateformat-2.0.0.tgz", - "integrity": "sha1-J0Pjq7XD/CRi5SfcpEXgTp9N7hc=", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", + "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", "dev": true }, + "duplexer2": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", + "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", + "dev": true, + "requires": { + "readable-stream": "1.1.14" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "fancy-log": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.2.tgz", + "integrity": "sha1-9BEl49hPLn2JpD0G2VjI94vha+E=", + "dev": true, + "requires": { + "ansi-gray": "0.1.1", + "color-support": "1.1.3", + "time-stamp": "1.1.0" + } + }, + "glogg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.1.tgz", + "integrity": "sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw==", + "dev": true, + "requires": { + "sparkles": "1.0.0" + } + }, + "gulplog": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", + "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", + "dev": true, + "requires": { + "glogg": "1.0.1" + } + }, "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" + "ansi-regex": "2.1.1" + } + }, + "has-gulplog": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", + "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "dev": true, + "requires": { + "sparkles": "1.0.0" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basetostring": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", + "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", + "dev": true + }, + "lodash._basevalues": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", + "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash._reescape": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", + "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", + "dev": true + }, + "lodash._reevaluate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", + "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", + "dev": true + }, + "lodash._reinterpolate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", + "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", + "dev": true + }, + "lodash._root": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", + "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", + "dev": true + }, + "lodash.escape": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", + "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", + "dev": true, + "requires": { + "lodash._root": "3.0.1" } }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.restparam": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", + "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "dev": true + }, "lodash.template": { - "version": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", "dev": true, "requires": { - "lodash._basecopy": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "lodash._basetostring": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "lodash._basevalues": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "lodash._isiterateecall": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "lodash._reinterpolate": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "lodash.escape": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "lodash.keys": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "lodash.restparam": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "lodash.templatesettings": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz" + "lodash._basecopy": "3.0.1", + "lodash._basetostring": "3.0.1", + "lodash._basevalues": "3.0.0", + "lodash._isiterateecall": "3.0.9", + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0", + "lodash.keys": "3.1.2", + "lodash.restparam": "3.6.1", + "lodash.templatesettings": "3.1.1" } }, "lodash.templatesettings": { - "version": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", "dev": true, "requires": { - "lodash._reinterpolate": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "lodash.escape": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz" + "lodash._reinterpolate": "3.0.0", + "lodash.escape": "3.2.0" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "multipipe": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", + "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", + "dev": true, + "requires": { + "duplexer2": "0.0.2" } }, "object-assign": { - "version": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", "dev": true }, + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "dev": true + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "0.0.1", + "string_decoder": "0.10.31" + } + }, + "replace-ext": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", + "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "sparkles": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", + "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", + "dev": true + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" + "ansi-regex": "2.1.1" } }, "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true + }, + "through2": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", + "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "dev": true, + "requires": { + "readable-stream": "2.3.3", + "xtend": "4.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "readable-stream": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", + "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + } + } + }, + "time-stamp": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", + "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "vinyl": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", + "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", + "dev": true, + "requires": { + "clone": "1.0.3", + "clone-stats": "0.0.1", + "replace-ext": "0.0.1" + } + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "dev": true } } }, - "gulplog": { - "version": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", - "dev": true, - "requires": { - "glogg": "https://registry.npmjs.org/glogg/-/glogg-1.0.0.tgz" - } - }, "handlebars": { "version": "4.0.11", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", @@ -4102,14 +4403,6 @@ "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "dev": true }, - "has-gulplog": { - "version": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", - "dev": true, - "requires": { - "sparkles": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz" - } - }, "has-own-property-x": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/has-own-property-x/-/has-own-property-x-3.1.1.tgz", @@ -4775,30 +5068,66 @@ } }, "jasmine": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.4.1.tgz", - "integrity": "sha1-kBbdpFMhPSesbUPcTqlzFaGJCF4=", + "version": "2.99.0", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.99.0.tgz", + "integrity": "sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc=", "dev": true, "requires": { "exit": "0.1.2", - "glob": "3.2.11", - "jasmine-core": "2.4.1" + "glob": "7.1.2", + "jasmine-core": "2.99.1" }, "dependencies": { - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", "inherits": "2.0.3", - "minimatch": "0.3.0" + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -4807,34 +5136,42 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "lru-cache": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true - }, "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "lru-cache": "2.7.3", - "sigmund": "1.0.1" + "brace-expansion": "1.1.11" } }, - "sigmund": { + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "path-is-absolute": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true } } }, "jasmine-core": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.4.1.tgz", - "integrity": "sha1-b4OrOg8WlRcizgfSBsdz1XzIOL4=", + "version": "2.99.1", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", + "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", "dev": true }, "jsbn": { @@ -5028,8 +5365,9 @@ "dev": true }, "karma-jasmine": { - "version": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-0.3.8.tgz", - "integrity": "sha1-W2RXeRrZuJqhc/B54+vhuMgFI2w=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-1.1.1.tgz", + "integrity": "sha1-b+hA51oRYAydkehLM8RY4cRqNSk=", "dev": true }, "karma-mocha": { @@ -5427,16 +5765,6 @@ "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", "dev": true }, - "lodash._basetostring": { - "version": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", - "dev": true - }, - "lodash._basevalues": { - "version": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", - "dev": true - }, "lodash._getnative": { "version": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", @@ -5447,39 +5775,11 @@ "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", "dev": true }, - "lodash._reescape": { - "version": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", - "dev": true - }, - "lodash._reevaluate": { - "version": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", - "dev": true - }, - "lodash._reinterpolate": { - "version": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", - "dev": true - }, - "lodash._root": { - "version": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", - "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", - "dev": true - }, "lodash.assignwith": { "version": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", "integrity": "sha1-EnqX8CrcQXUalU0ksN4X4QDgOOs=", "dev": true }, - "lodash.escape": { - "version": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true, - "requires": { - "lodash._root": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz" - } - }, "lodash.isarguments": { "version": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", @@ -5531,11 +5831,6 @@ "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", "dev": true }, - "lodash.restparam": { - "version": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", - "dev": true - }, "lodash.template": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz", @@ -6018,14 +6313,6 @@ "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", "dev": true }, - "multipipe": { - "version": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", - "dev": true, - "requires": { - "duplexer2": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz" - } - }, "nan-x": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/nan-x/-/nan-x-1.0.0.tgz", @@ -6989,11 +7276,6 @@ "to-string-x": "1.4.2" } }, - "replace-ext": { - "version": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", - "dev": true - }, "request": { "version": "https://registry.npmjs.org/request/-/request-2.55.0.tgz", "integrity": "sha1-11wc32eddrsQD5v/4f5VG1wk6T0=", @@ -7497,11 +7779,6 @@ } } }, - "sparkles": { - "version": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", - "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", - "dev": true - }, "spdx-correct": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", @@ -8997,16 +9274,6 @@ "extsprintf": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz" } }, - "vinyl": { - "version": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", - "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", - "dev": true, - "requires": { - "clone": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "replace-ext": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz" - } - }, "vinyl-fs": { "version": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", diff --git a/package.json b/package.json index 1a3e65d9f..28ad61e49 100644 --- a/package.json +++ b/package.json @@ -75,12 +75,12 @@ "gulp-tslint": "^7.0.1", "gulp-uglify": "^1.2.0", "gulp-util": "^3.0.7", - "jasmine": "2.4.1", - "jasmine-core": "2.4.1", + "jasmine": "^2.9.1", + "jasmine-core": "^2.9.1", "karma": "^0.13.14", "karma-chrome-launcher": "^0.2.1", "karma-firefox-launcher": "^0.1.4", - "karma-jasmine": "^0.3.6", + "karma-jasmine": "^1.1.1", "karma-mocha": "^1.2.0", "karma-phantomjs-launcher": "^1.0.4", "karma-safari-launcher": "^0.1.1", diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 6f312eafe..9b013d70c 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -14,6 +14,8 @@ import {getIEVersion, ifEnvSupports, ifEnvSupportsWithDone, isEdge} from '../tes import Spy = jasmine.Spy; declare const global: any; +const noop = function() {}; + function windowPrototype() { return !!(global['Window'] && global['Window'].prototype); } diff --git a/test/browser/requestAnimationFrame.spec.ts b/test/browser/requestAnimationFrame.spec.ts index 63a12540b..2df631e9d 100644 --- a/test/browser/requestAnimationFrame.spec.ts +++ b/test/browser/requestAnimationFrame.spec.ts @@ -10,43 +10,55 @@ import {ifEnvSupports} from '../test-util'; declare const window: any; describe('requestAnimationFrame', function() { - const functions = - ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame']; + const functions = [ + 'requestAnimationFrame', + 'webkitRequestAnimationFrame', + 'mozRequestAnimationFrame' + ]; functions.forEach(function(fnName) { - describe(fnName, ifEnvSupports(fnName, function() { - const rAF = window[fnName]; - - it('should be tolerant of invalid arguments', function() { - // rAF throws an error on invalid arguments, so expect that. - expect(function() { - rAF(null); - }).toThrow(); - }); - - it('should bind to same zone when called recursively', function(done) { - const originalTimeout: number = (jasmine).DEFAULT_TIMEOUT_INTERVAL; - (jasmine).DEFAULT_TIMEOUT_INTERVAL = 10000; - Zone.current.fork({name: 'TestZone'}).run(() => { - let frames = 0; - let previousTimeStamp = 0; - - function frameCallback(timestamp: number) { - expect(timestamp).toMatch(/^[\d.]+$/); - // expect previous <= current - expect(previousTimeStamp).not.toBeGreaterThan(timestamp); - previousTimeStamp = timestamp; - - if (frames++ > 15) { - (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - return done(); - } - rAF(frameCallback); - } - - rAF(frameCallback); - }); - }); - })); + describe( + fnName, + ifEnvSupports(fnName, function() { + const originalTimeout: number = (jasmine).DEFAULT_TIMEOUT_INTERVAL; + beforeEach(() => { + (jasmine).DEFAULT_TIMEOUT_INTERVAL = 10000; + }); + + afterEach(() => { + (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + }); + const rAF = window[fnName]; + + it('should be tolerant of invalid arguments', function() { + // rAF throws an error on invalid arguments, so expect that. + expect(function() { + rAF(null); + }).toThrow(); + }); + + it('should bind to same zone when called recursively', function(done) { + Zone.current.fork({ name: 'TestZone' }).run(() => { + let frames = 0; + let previousTimeStamp = 0; + + function frameCallback(timestamp: number) { + expect(timestamp).toMatch(/^[\d.]+$/); + // expect previous <= current + expect(previousTimeStamp).not.toBeGreaterThan(timestamp); + previousTimeStamp = timestamp; + + if (frames++ > 15) { + (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + return done(); + } + rAF(frameCallback); + } + + rAF(frameCallback); + }); + }); + }) + ); }); }); diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 11f74fe05..d6a803b72 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -527,7 +527,7 @@ describe( }); }); - it('should resolve if the Promise subclass resolves', function() { + function testPromiseSubClass(done?: Function) { const myPromise = new MyPromise(function(resolve: any, reject: Function) { resolve('foo'); }); @@ -538,7 +538,14 @@ describe( }) .then(function(result) { expect(result).toBe('foo'); + done && done(); }); + } + + it('should resolve if the Promise subclass resolves', jasmine ? function(done) { + testPromiseSubClass(done); + } : function() { + testPromiseSubClass(); }); }); diff --git a/test/rxjs/rxjs.fromEvent.spec.ts b/test/rxjs/rxjs.fromEvent.spec.ts index cbc2ba768..6020ee795 100644 --- a/test/rxjs/rxjs.fromEvent.spec.ts +++ b/test/rxjs/rxjs.fromEvent.spec.ts @@ -19,88 +19,103 @@ function isEventTarget() { describe('Observable.fromEvent', () => { let log: string[]; - const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); - const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - const triggerZone: Zone = Zone.current.fork({name: 'Trigger Zone'}); + const constructorZone1: Zone = Zone.current.fork({ + name: 'Constructor Zone1' + }); + const subscriptionZone: Zone = Zone.current.fork({ + name: 'Subscription Zone' + }); + const triggerZone: Zone = Zone.current.fork({ name: 'Trigger Zone' }); let observable1: any; beforeEach(() => { log = []; }); - it('fromEvent EventTarget func callback should run in the correct zone', - ifEnvSupports(isEventTarget, () => { - observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEvent(document, 'click'); - }); - - const clickEvent = document.createEvent('Event'); - clickEvent.initEvent('click', true, true); - - subscriptionZone.run(() => { - observable1.subscribe( - (result: any) => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push(result); - }, - () => { - fail('should not call error'); - }, - () => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push('completed'); - }); - }); - - triggerZone.run(() => { - document.dispatchEvent(clickEvent); - }); - - expect(log).toEqual([clickEvent]); - })); - - it('fromEventPattern EventTarget func callback should run in the correct zone', - ifEnvSupports(isEventTarget, () => { - observable1 = constructorZone1.run(() => { - const handler = function() { - log.push('handler'); - }; - return Rx.Observable.fromEventPattern( - () => { - expect(Zone.current.name).toEqual(constructorZone1.name); - document.addEventListener('click', handler); - log.push('addListener'); - }, - () => { - expect(Zone.current.name).toEqual(constructorZone1.name); - document.removeEventListener('click', handler); - log.push('removeListener'); - }); - }); - - const clickEvent = document.createEvent('Event'); - clickEvent.initEvent('click', true, true); - - const subscriper: any = subscriptionZone.run(() => { - return observable1.subscribe( - (result: any) => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push(result); - }, - () => { - fail('should not call error'); - }, - () => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push('completed'); - }); - }); - - triggerZone.run(() => { - document.dispatchEvent(clickEvent); - subscriper.complete(); - }); - - expect(log).toEqual(['addListener', clickEvent, 'handler', 'completed', 'removeListener']); - })); -}); \ No newline at end of file + it( + 'fromEvent EventTarget func callback should run in the correct zone', + ifEnvSupports(isEventTarget, () => { + observable1 = constructorZone1.run(() => { + return Rx.Observable.fromEvent(document, 'click'); + }); + + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', true, true); + + subscriptionZone.run(() => { + observable1.subscribe( + (result: any) => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push(result); + }, + () => { + fail('should not call error'); + }, + () => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push('completed'); + } + ); + }); + + triggerZone.run(() => { + document.dispatchEvent(clickEvent); + }); + + expect(log).toEqual([clickEvent]); + }) + ); + + it( + 'fromEventPattern EventTarget func callback should run in the correct zone', + ifEnvSupports(isEventTarget, () => { + const button = document.createElement('button'); + document.body.appendChild(button); + observable1 = constructorZone1.run(() => { + return Rx.Observable.fromEventPattern( + (handler: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + button.addEventListener('click', handler); + log.push('addListener'); + }, + (handler: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + button.removeEventListener('click', handler); + document.body.removeChild(button); + log.push('removeListener'); + } + ); + }); + + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', false, false); + + const subscriper: any = subscriptionZone.run(() => { + return observable1.subscribe( + (result: any) => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push(result); + }, + () => { + fail('should not call error'); + }, + () => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push('completed'); + } + ); + }); + + triggerZone.run(() => { + button.dispatchEvent(clickEvent); + subscriper.complete(); + }); + expect(log).toEqual([ + 'addListener', + clickEvent, + 'completed', + 'removeListener' + ]); + }) + ); +}); diff --git a/test/test-util.ts b/test/test-util.ts index d1ae6a14b..77907f522 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -51,10 +51,8 @@ function _runTest(test: any, block: Function, done: Function) { block(); } } else { + console.log('WARNING: skipping ' + message + ' tests (missing this API)'); done && done(); - it('should skip the test if the API does not exist', function() { - console.log('WARNING: skipping ' + message + ' tests (missing this API)'); - }); } } From 40b110de61c0295b4bdd7ef912b65adb7e5ee9dc Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 28 Feb 2018 08:21:36 +0900 Subject: [PATCH 023/106] fix(proxy): proxyZone should call onHasTask when change delegate (#1030) --- lib/jasmine/jasmine.ts | 12 ++ lib/zone-spec/async-test.ts | 27 +++- lib/zone-spec/proxy.ts | 25 +++- test/zone-spec/async-test.spec.ts | 212 +++++++++++++++++++++++++++++- test/zone-spec/proxy.spec.ts | 63 +++++++++ 5 files changed, 333 insertions(+), 6 deletions(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 00d9810d9..47f44c8c1 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -18,6 +18,7 @@ ? Object.create(b) : ((__.prototype = b.prototype), new (__ as any)()); }; + const _global: any = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; // 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'); @@ -202,6 +203,7 @@ function ZoneQueueRunner(attrs: { onComplete: Function; userContext?: any; + timeout?: { setTimeout: Function; clearTimeout: Function }; }) { attrs.onComplete = (fn => () => { // All functions are done, clear the test zone. @@ -209,6 +211,16 @@ this.testProxyZoneSpec = null; ambientZone.scheduleMicroTask('jasmine.onComplete', fn); })(attrs.onComplete); + + const nativeSetTimeout = _global['__zone_symbol__setTimeout']; + const nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } // create a userContext to hold the queueRunner itself // so we can access the testProxy in it/xit/beforeEach ... if ((jasmine as any).UserContext) { diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index c68c24777..f6935de0e 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -14,6 +14,7 @@ class AsyncTestZoneSpec implements ZoneSpec { _pendingMicroTasks: boolean = false; _pendingMacroTasks: boolean = false; _alreadyErrored: boolean = false; + _isSync: boolean = false; runZone = Zone.current; unresolvedChainedPromiseCount = 0; @@ -60,6 +61,9 @@ class AsyncTestZoneSpec implements ZoneSpec { properties: {[key: string]: any}; onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task { + if (task.type !== 'eventTask') { + this._isSync = false; + } if (task.type === 'microTask' && task.data && task.data instanceof Promise) { // check whether the promise is a chained promise if ((task.data as any)[AsyncTestZoneSpec.symbolParentUnresolved] === true) { @@ -70,18 +74,39 @@ class AsyncTestZoneSpec implements ZoneSpec { return delegate.scheduleTask(target, task); } + onInvokeTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, applyThis: any, applyArgs: any) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + } + + onCancelTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + } + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. onInvoke( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, applyThis: any, applyArgs: any[], source: string): any { + let previousTaskCounts: any = null; try { this.patchPromiseForTest(); + this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { this.unPatchPromiseForTest(); - this._finishCallbackIfDone(); + const afterTaskCounts: any = (parentZoneDelegate as any)._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } } } diff --git a/lib/zone-spec/proxy.ts b/lib/zone-spec/proxy.ts index a1fe1c475..81c3110f3 100644 --- a/lib/zone-spec/proxy.ts +++ b/lib/zone-spec/proxy.ts @@ -14,6 +14,9 @@ class ProxyZoneSpec implements ZoneSpec { properties: {[k: string]: any} = {'ProxyZoneSpec': this}; propertyKeys: string[] = null; + lastTaskState: HasTaskState = null; + isNeedToTriggerHasTask = false; + static get(): ProxyZoneSpec { return Zone.current.get('ProxyZoneSpec'); } @@ -35,6 +38,7 @@ class ProxyZoneSpec implements ZoneSpec { setDelegate(delegateSpec: ZoneSpec) { + const isNewDelegate = this._delegateSpec !== delegateSpec; this._delegateSpec = delegateSpec; this.propertyKeys && this.propertyKeys.forEach((key) => delete this.properties[key]); this.propertyKeys = null; @@ -42,6 +46,12 @@ class ProxyZoneSpec implements ZoneSpec { this.propertyKeys = Object.keys(delegateSpec.properties); this.propertyKeys.forEach((k) => this.properties[k] = delegateSpec.properties[k]); } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } } getDelegate() { @@ -53,6 +63,15 @@ class ProxyZoneSpec implements ZoneSpec { this.setDelegate(this.defaultSpecDelegate); } + tryTriggerHasTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + } + onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, zoneSpec: ZoneSpec): Zone { @@ -79,6 +98,7 @@ class ProxyZoneSpec implements ZoneSpec { onInvoke( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, applyThis: any, applyArgs: any[], source: string): any { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onInvoke) { return this._delegateSpec.onInvoke( parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); @@ -108,7 +128,8 @@ class ProxyZoneSpec implements ZoneSpec { onInvokeTask( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, applyThis: any, applyArgs: any): any { - if (this._delegateSpec && this._delegateSpec.onFork) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { return this._delegateSpec.onInvokeTask( parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); } else { @@ -118,6 +139,7 @@ class ProxyZoneSpec implements ZoneSpec { onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onCancelTask) { return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); } else { @@ -126,6 +148,7 @@ class ProxyZoneSpec implements ZoneSpec { } onHasTask(delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState): void { + this.lastTaskState = hasTaskState; if (this._delegateSpec && this._delegateSpec.onHasTask) { this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); } else { diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index 1fdf30072..8d0f59e5e 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -25,7 +25,7 @@ describe('AsyncTestZoneSpec', function() { log = []; }); - it('should call finish after zone is run', (done) => { + it('should call finish after zone is run in sync call', (done) => { let finished = false; const testZoneSpec = new AsyncTestZoneSpec(() => { expect(finished).toBe(true); @@ -143,7 +143,7 @@ describe('AsyncTestZoneSpec', function() { document.body.removeChild(button); }); - it('should call finish after an event task is done', (done) => { + it('should call finish because an event task is considered as sync', (done) => { let finished = false; const testZoneSpec = new AsyncTestZoneSpec( @@ -159,9 +159,10 @@ describe('AsyncTestZoneSpec', function() { const atz = Zone.current.fork(testZoneSpec); atz.run(function() { - button.addEventListener('click', () => { + const listener = () => { finished = true; - }); + }; + button.addEventListener('click', listener); const clickEvent = document.createEvent('Event'); clickEvent.initEvent('click', true, true); @@ -343,4 +344,207 @@ describe('AsyncTestZoneSpec', function() { }); }); }); + + describe('ProxyZone with AsyncTestZoneSpec', () => { + const ProxyZoneSpec = (Zone as any)['ProxyZoneSpec']; + const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; + + function testAsync(fn: Function, doneFn?: Function) { + return function(done: any) { + runInTestZone(fn, this, function() { + if (doneFn) { + doneFn(); + } + done(); + }, (err: any) => { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } else { + done.fail(err); + } + }); + }; + } + + function runInTestZone( + fn: Function, context: any, finishCallback: Function, failCallback: Function) { + const currentZone = Zone.current; + const proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + const previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(() => { + const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec( + () => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(() => { + finishCallback(); + }); + }, + (error: any) => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(() => { + failCallback(error); + }); + }, + 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); + } + + describe('test without beforeEach', () => { + const logs: string[] = []; + it('should automatically done after async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['timeout']); + logs.splice(0); + })); + + it('should automatically done after all nested async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + setTimeout(() => { + logs.push('nested timeout'); + }, 100); + }, 100); + }, () => { + expect(logs).toEqual(['timeout', 'nested timeout']); + logs.splice(0); + })); + + it('should automatically done after multiple async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('1st timeout'); + }, 100); + + setTimeout(() => { + logs.push('2nd timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['1st timeout', '2nd timeout']); + logs.splice(0); + })); + }); + + describe('test with sync beforeEach', () => { + const logs: string[] = []; + + beforeEach(() => { + logs.splice(0); + logs.push('beforeEach'); + }); + + it('should automatically done after async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); + }); + + describe('test with async beforeEach', () => { + const logs: string[] = []; + + beforeEach(testAsync(() => { + setTimeout(() => { + logs.splice(0); + logs.push('beforeEach'); + }, 100); + })); + + it('should automatically done after async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); + + it('should automatically done after all nested async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + setTimeout(() => { + logs.push('nested timeout'); + }, 100); + }, 100); + }, () => { + expect(logs).toEqual(['beforeEach', 'timeout', 'nested timeout']); + })); + + it('should automatically done after multiple async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('1st timeout'); + }, 100); + + setTimeout(() => { + logs.push('2nd timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['beforeEach', '1st timeout', '2nd timeout']); + })); + }); + + describe('test with async beforeEach and sync afterEach', () => { + const logs: string[] = []; + + beforeEach(testAsync(() => { + setTimeout(() => { + expect(logs).toEqual([]); + logs.push('beforeEach'); + }, 100); + })); + + afterEach(() => { + logs.splice(0); + }); + + it('should automatically done after async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); + }); + + describe('test with async beforeEach and async afterEach', () => { + const logs: string[] = []; + + beforeEach(testAsync(() => { + setTimeout(() => { + expect(logs).toEqual([]); + logs.push('beforeEach'); + }, 100); + })); + + afterEach(testAsync(() => { + setTimeout(() => { + logs.splice(0); + }, 100); + })); + + it('should automatically done after async tasks finished', testAsync(() => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); + }); + }); }); diff --git a/test/zone-spec/proxy.spec.ts b/test/zone-spec/proxy.spec.ts index 348ac2a16..d815ce631 100644 --- a/test/zone-spec/proxy.spec.ts +++ b/test/zone-spec/proxy.spec.ts @@ -144,4 +144,67 @@ describe('ProxySpec', () => { proxyZone.cancelTask(task); }); }); + + describe('delegateSpec change', () => { + let log: string[] = []; + beforeEach(() => { + log = []; + }); + it('should trigger hasTask when invoke', (done: Function) => { + const zoneSpec1 = { + name: 'zone1', + onHasTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, hasTask: HasTaskState) => { + log.push(`zoneSpec1 hasTask: ${hasTask.microTask},${hasTask.macroTask}`); + return delegate.hasTask(target, hasTask); + } + }; + const zoneSpec2 = { + name: 'zone2', + onHasTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, hasTask: HasTaskState) => { + log.push(`zoneSpec2 hasTask: ${hasTask.microTask},${hasTask.macroTask}`); + return delegate.hasTask(target, hasTask); + } + }; + proxyZoneSpec.setDelegate(zoneSpec1); + proxyZone.run(() => { + setTimeout(() => { + log.push('timeout in zoneSpec1'); + }, 50); + }); + proxyZoneSpec.setDelegate(zoneSpec2); + proxyZone.run(() => { + Promise.resolve(1).then(() => { + log.push('then in zoneSpec2'); + }); + }); + proxyZoneSpec.setDelegate(null); + proxyZone.run(() => { + setTimeout(() => { + log.push('timeout in null spec'); + }, 50); + }); + proxyZoneSpec.setDelegate(zoneSpec2); + proxyZone.run(() => { + Promise.resolve(1).then(() => { + log.push('then in zoneSpec2'); + }); + }); + + setTimeout(() => { + expect(log).toEqual([ + 'zoneSpec1 hasTask: false,true', + 'zoneSpec2 hasTask: false,true', + 'zoneSpec2 hasTask: true,true', + 'zoneSpec2 hasTask: true,true', + 'then in zoneSpec2', + 'then in zoneSpec2', + 'zoneSpec2 hasTask: false,true', + 'timeout in zoneSpec1', + 'timeout in null spec', + 'zoneSpec2 hasTask: false,false' + ]); + done(); + }, 300); + }); + }); }); From ebd348c639800d466abf66b5bba1d65114bef013 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 28 Feb 2018 08:22:12 +0900 Subject: [PATCH 024/106] feat(build): use yarn instead of npm (#1025) --- .travis.yml | 16 +- DEVELOPER.md | 28 +- package-lock.json | 10910 -------------------------------------------- yarn.lock | 5963 ++++++++++++++++++++++++ 4 files changed, 5987 insertions(+), 10930 deletions(-) delete mode 100644 package-lock.json create mode 100644 yarn.lock diff --git a/.travis.yml b/.travis.yml index 55a77ad33..97d706205 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,9 @@ language: node_js sudo: false +dist: trusty +cache: yarn node_js: - - '6.3.1' + - 6 env: global: - BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready @@ -16,21 +18,23 @@ env: # (password is in Valentine) - TSD_GITHUB_TOKEN=ef474500309daea53d5991b3079159a29520a40b +before_install: + - npm install -g yarn before_script: - mkdir -p $LOGS_DIR - ./scripts/sauce/sauce_connect_setup.sh - ./scripts/sauce/sauce_connect_block.sh script: - - npm run tslint + - yarn tslint - node_modules/.bin/gulp lint - node_modules/.bin/gulp format:enforce - node_modules/.bin/gulp build - node_modules/.bin/gulp filesize - scripts/closure/closure_compiler.sh - node_modules/.bin/gulp promisetest - - npm run promisefinallytest - - npm run test:phantomjs-single + - yarn promisefinallytest + - yarn test:phantomjs-single - node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run - node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run @@ -38,7 +42,7 @@ script: - node_modules/.bin/gulp test/node - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js - - npm install jasmine@3.0.0 jasmine-core@3.0.0 - - npm run test:phantomjs-single + - yarn add jasmine@3.0.0 jasmine-core@3.0.0 + - yarn test:phantomjs-single - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run - node_modules/.bin/gulp test/node diff --git a/DEVELOPER.md b/DEVELOPER.md index 5804d31e1..2703c78e0 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -10,31 +10,31 @@ To run tests Make sure your environment is set up with: -`npm install` +`yarn` In a separate process, run the WebSockets server: -`npm run ws-server` +`yarn ws-server` Run the browser tests using Karma: -`npm test` +`yarn test` Run the node.js tests: -`npm run test-node` +`yarn test-node` Run tslint: -`npm run lint` +`yarn lint` Run format with clang-format: -`npm run format` +`yarn format` Run all checks (lint/format/browser test/test-node): -`npm run ci` +`yarn ci` Before Commit ------------ @@ -44,12 +44,12 @@ Please make sure you pass all following checks before commit - gulp lint (tslint) - gulp format:enforce (clang-format) - gulp promisetest (promise a+ test) -- npm test (karma browser test) +- yarn test (karma browser test) - gulp test-node (node test) You can run -`npm run ci` +`yarn ci` to do all those checks for you. You can also add the script into your git pre-commit hook @@ -67,9 +67,9 @@ Webdriver Test 1. run locally ``` -npm run webdriver-start -npm run webdriver-http -npm run webdriver-test +yarn webdriver-start +yarn webdriver-http +yarn webdriver-test ``` 2. run locally with sauce connect @@ -80,6 +80,6 @@ export SAUCE_USERNAME=XXXX export SAUCE_ACCESS_KEY=XXX sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -npm run webdriver-http -npm run webdriver-sauce-test +yarn webdriver-http +yarn webdriver-sauce-test ``` \ No newline at end of file diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index bcdc7d6af..000000000 --- a/package-lock.json +++ /dev/null @@ -1,10910 +0,0 @@ -{ - "name": "zone.js", - "version": "0.8.20", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@types/jasmine": { - "version": "https://registry.npmjs.org/@types/jasmine/-/jasmine-2.2.33.tgz", - "integrity": "sha1-RxXP0sp/vWMvx/F4TxPmN77QKMU=", - "dev": true - }, - "@types/node": { - "version": "6.0.96", - "resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.96.tgz", - "integrity": "sha512-fsOOY6tMQ3jCB2wD51XFDmmpgm4wVKkJECdcVRqapbJEa7awJDcr+SaH8toz+4r4KW8YQ3M7ybXMoSDo1QGewA==", - "dev": true - }, - "@types/systemjs": { - "version": "https://registry.npmjs.org/@types/systemjs/-/systemjs-0.19.33.tgz", - "integrity": "sha1-R8R+djmGe2aUvrP2DE9TrVXrGxM=", - "dev": true - }, - "JSONStream": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.2.tgz", - "integrity": "sha1-wQI3G27Dp887hHygDCC7D85Mbeo=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - }, - "dependencies": { - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - } - } - }, - "accepts": { - "version": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", - "integrity": "sha1-w8p0NJOGSMPg2cHjKN1otiLChMo=", - "dev": true, - "requires": { - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "negotiator": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz" - } - }, - "add-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/add-stream/-/add-stream-1.0.0.tgz", - "integrity": "sha1-anmQQ3ynNtXhKI25K9MmbV9csqo=", - "dev": true - }, - "adm-zip": { - "version": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", - "integrity": "sha1-hgbCy/HEJs6MjsABdER/1Jtur8E=", - "dev": true - }, - "after": { - "version": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", - "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", - "dev": true - }, - "ajv": { - "version": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true, - "requires": { - "co": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "json-stable-stringify": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz" - } - }, - "align-text": { - "version": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", - "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", - "dev": true, - "requires": { - "kind-of": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz", - "longest": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "repeat-string": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" - } - }, - "ansi-colors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.0.1.tgz", - "integrity": "sha512-yopkAU0ZD/WQ56Tms3xLn6jRuX3SyUMAVi0FdmDIbmmnHW3jHiI1sQFdUl3gfVddjnrsP3Y6ywFKvCRopvoVIA==", - "dev": true, - "requires": { - "ansi-wrap": "0.1.0" - } - }, - "ansi-gray": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ansi-gray/-/ansi-gray-0.1.1.tgz", - "integrity": "sha1-KWLPVOyXksSFEKPetSRDaGHvclE=", - "dev": true, - "requires": { - "ansi-wrap": "0.1.0" - } - }, - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true - }, - "ansi-wrap": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz", - "integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=", - "dev": true - }, - "anymatch": { - "version": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz", - "integrity": "sha1-o+Uvo5FoyCX/V7AkgSbOWo/5VQc=", - "dev": true, - "requires": { - "arrify": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "micromatch": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz" - } - }, - "archiver": { - "version": "https://registry.npmjs.org/archiver/-/archiver-0.14.4.tgz", - "integrity": "sha1-W53bn17hzu8hy487Ag5iQOy0MVw=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "buffer-crc32": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-4.3.5.tgz", - "lazystream": "https://registry.npmjs.org/lazystream/-/lazystream-0.1.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.2.0.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "tar-stream": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.1.5.tgz", - "zip-stream": "https://registry.npmjs.org/zip-stream/-/zip-stream-0.5.2.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", - "dev": true - }, - "glob": { - "version": "https://registry.npmjs.org/glob/-/glob-4.3.5.tgz", - "integrity": "sha1-gPuwjKVA8jiszl0R0em8QedRc9M=", - "dev": true, - "requires": { - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - } - }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-3.2.0.tgz", - "integrity": "sha1-S/UKMkP5rrC6xBpV09WZBnWkYvs=", - "dev": true - }, - "minimatch": { - "version": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz" - } - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, - "archy": { - "version": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", - "dev": true - }, - "arr-diff": { - "version": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.1.tgz" - } - }, - "arr-flatten": { - "version": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.0.1.tgz", - "integrity": "sha1-5f/lTUXhnzLyFukeuZyM6JK7YEs=", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-find-index": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz", - "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", - "dev": true - }, - "array-ify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", - "integrity": "sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4=", - "dev": true - }, - "array-slice": { - "version": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", - "dev": true - }, - "array-union": { - "version": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz" - } - }, - "array-uniq": { - "version": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "array-unique": { - "version": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "arraybuffer.slice": { - "version": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", - "integrity": "sha1-8zshWfBTKj8xB6JywMz70a0peco=", - "dev": true - }, - "arrify": { - "version": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", - "dev": true - }, - "asn1": { - "version": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz", - "integrity": "sha1-VZvhg3bQik7E2+gId9J4GGObLfc=", - "dev": true - }, - "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", - "dev": true, - "requires": { - "util": "https://registry.npmjs.org/util/-/util-0.10.3.tgz" - } - }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz", - "integrity": "sha1-7nQAlBMALYTOxyGcasgRgS5yMWA=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "async": { - "version": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, - "async-each": { - "version": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", - "dev": true - }, - "asynckit": { - "version": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "attempt-x": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/attempt-x/-/attempt-x-1.1.1.tgz", - "integrity": "sha512-hIp37ojJRRW8ExWSxxLpkDHUufk/DFfsb7/cUC1cVbBg7JV4gJTkCTRa44dlL9e5jx1P3VNrjL7QOQfi4MyltA==", - "dev": true - }, - "aws-sign2": { - "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz", - "integrity": "sha1-xXED96F/wDfwLXwuZLYC6iI/fWM=", - "dev": true - }, - "aws4": { - "version": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", - "dev": true - }, - "backo2": { - "version": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", - "integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=", - "dev": true - }, - "balanced-match": { - "version": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", - "dev": true - }, - "base64-arraybuffer": { - "version": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", - "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=", - "dev": true - }, - "base64id": { - "version": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", - "integrity": "sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY=", - "dev": true - }, - "batch": { - "version": "https://registry.npmjs.org/batch/-/batch-0.5.3.tgz", - "integrity": "sha1-PzQU84AyF0O/wQQvmoP/HVgk1GQ=", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" - } - }, - "better-assert": { - "version": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz", - "integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=", - "dev": true, - "requires": { - "callsite": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz" - } - }, - "big.js": { - "version": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", - "integrity": "sha1-TK2iGTZS6zyp7I5VyQFWacmAaXg=", - "dev": true - }, - "binary-extensions": { - "version": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.8.0.tgz", - "integrity": "sha1-SOyNFt9Dd+rl+liEaCSAr02Vx3Q=", - "dev": true - }, - "bl": { - "version": "https://registry.npmjs.org/bl/-/bl-0.9.5.tgz", - "integrity": "sha1-wGt5evCF6gC8Unr8jvzxHeIjIFQ=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, - "blob": { - "version": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", - "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=", - "dev": true - }, - "bluebird": { - "version": "https://registry.npmjs.org/bluebird/-/bluebird-2.9.6.tgz", - "integrity": "sha1-H8OmsWhSZ9wSG17ImzLOBp2Bq30=", - "dev": true - }, - "body-parser": { - "version": "https://registry.npmjs.org/body-parser/-/body-parser-1.16.0.tgz", - "integrity": "sha1-kkpeRyxiKfudabhaINXyUy3seIs=", - "dev": true, - "requires": { - "bytes": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", - "content-type": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz", - "depd": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "http-errors": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", - "iconv-lite": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", - "on-finished": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-6.2.1.tgz", - "raw-body": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz", - "type-is": "https://registry.npmjs.org/type-is/-/type-is-1.6.14.tgz" - } - }, - "boom": { - "version": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, - "requires": { - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz" - } - }, - "brace-expansion": { - "version": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz", - "integrity": "sha1-cZfX6qm4fmSDkOph/GbIRCdCDfk=", - "dev": true, - "requires": { - "balanced-match": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - }, - "braces": { - "version": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "preserve": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "repeat-element": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz" - } - }, - "buffer-crc32": { - "version": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true - }, - "buffer-from": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-0.1.1.tgz", - "integrity": "sha1-V7GLHaChnsBvM4N6UnWiQjUb114=", - "dev": true, - "requires": { - "is-array-buffer-x": "1.7.0" - } - }, - "buffer-shims": { - "version": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", - "dev": true - }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true - }, - "byline": { - "version": "https://registry.npmjs.org/byline/-/byline-4.2.2.tgz", - "integrity": "sha1-wgOpilsCkIIqk4anjtosvVvNsy8=", - "dev": true - }, - "bytes": { - "version": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", - "integrity": "sha1-fZcZb51br39pNeJZhVSe3SpsIzk=", - "dev": true - }, - "cached-constructors-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/cached-constructors-x/-/cached-constructors-x-1.0.0.tgz", - "integrity": "sha512-JVP0oilYlPgBTD8bkQ+of7hSIJRtydCCJiMtzdRMXVQ98gdj0NyrJTZzbu5wtlO26Ev/1HXRTtbBNsVlLJ3+3A==", - "dev": true - }, - "callsite": { - "version": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", - "integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=", - "dev": true - }, - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true - }, - "camelcase-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", - "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", - "dev": true, - "requires": { - "camelcase": "2.1.1", - "map-obj": "1.0.1" - } - }, - "capture-stack-trace": { - "version": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz", - "integrity": "sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0=", - "dev": true - }, - "caseless": { - "version": "https://registry.npmjs.org/caseless/-/caseless-0.9.0.tgz", - "integrity": "sha1-t7Zc5r8UE4hlOc/VM/CzDv+pz4g=", - "dev": true - }, - "center-align": { - "version": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", - "dev": true, - "requires": { - "align-text": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", - "lazy-cache": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz" - } - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz" - } - }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", - "dev": true - }, - "chokidar": { - "version": "https://registry.npmjs.org/chokidar/-/chokidar-1.6.1.tgz", - "integrity": "sha1-L0RHq16W5Q+z14n9kNTHLg5McMI=", - "dev": true, - "requires": { - "anymatch": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.0.tgz", - "async-each": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "glob-parent": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "is-binary-path": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "is-glob": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "readdirp": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz" - } - }, - "clang-format": { - "version": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.46.tgz", - "integrity": "sha1-9p3knNUJCbMUnJBTySQN79UTURQ=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "resolve": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz" - } - }, - "cliui": { - "version": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "requires": { - "center-align": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "right-align": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "wordwrap": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz" - }, - "dependencies": { - "wordwrap": { - "version": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true - } - } - }, - "clone": { - "version": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "integrity": "sha1-Jgt6meux7f4kdTgXX3gyQ8sZ0Uk=", - "dev": true - }, - "clone-buffer": { - "version": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", - "dev": true - }, - "clone-stats": { - "version": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "cloneable-readable": { - "version": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.0.0.tgz", - "integrity": "sha1-pikNQT8hemEjL5XkWP84QYz7ARc=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz" - } - }, - "co": { - "version": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, - "code-point-at": { - "version": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, - "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "color-support": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", - "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", - "dev": true - }, - "colors": { - "version": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", - "dev": true - }, - "combined-stream": { - "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", - "integrity": "sha1-ATfmV7qlp1QcV6w3rF/AfXO03B8=", - "dev": true, - "requires": { - "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz" - } - }, - "commander": { - "version": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", - "integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=", - "dev": true - }, - "compare-func": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/compare-func/-/compare-func-1.3.2.tgz", - "integrity": "sha1-md0LpFfh+bxyKxLAjsM+6rMfpkg=", - "dev": true, - "requires": { - "array-ify": "1.0.0", - "dot-prop": "3.0.0" - }, - "dependencies": { - "dot-prop": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-3.0.0.tgz", - "integrity": "sha1-G3CK8JSknJoOfbyteQq6U52sEXc=", - "dev": true, - "requires": { - "is-obj": "1.0.1" - } - }, - "is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true - } - } - }, - "component-bind": { - "version": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", - "integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=", - "dev": true - }, - "component-emitter": { - "version": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz", - "integrity": "sha1-KWWU8nU9qmOZbSrwjRWpURbJrsM=", - "dev": true - }, - "component-inherit": { - "version": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", - "integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=", - "dev": true - }, - "compress-commons": { - "version": "https://registry.npmjs.org/compress-commons/-/compress-commons-0.2.9.tgz", - "integrity": "sha1-Qi2SdDDAGr0GzUVbbfwEy0z4ADw=", - "dev": true, - "requires": { - "buffer-crc32": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "crc32-stream": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-0.3.4.tgz", - "node-int64": "https://registry.npmjs.org/node-int64/-/node-int64-0.3.3.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, - "concat-map": { - "version": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "concurrently": { - "version": "https://registry.npmjs.org/concurrently/-/concurrently-2.2.0.tgz", - "integrity": "sha1-utJI4LsSn7FiF2iQOmMR1F1WiVo=", - "dev": true, - "requires": { - "bluebird": "https://registry.npmjs.org/bluebird/-/bluebird-2.9.6.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "commander": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz", - "cross-spawn": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-0.2.9.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "moment": "https://registry.npmjs.org/moment/-/moment-2.17.1.tgz", - "rx": "https://registry.npmjs.org/rx/-/rx-2.3.24.tgz" - } - }, - "connect": { - "version": "https://registry.npmjs.org/connect/-/connect-3.5.0.tgz", - "integrity": "sha1-s1dSWgtMH1BZnNmD4dnv7qlncZg=", - "dev": true, - "requires": { - "debug": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "finalhandler": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz", - "parseurl": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", - "utils-merge": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz" - }, - "dependencies": { - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - } - }, - "ms": { - "version": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - } - } - }, - "content-type": { - "version": "https://registry.npmjs.org/content-type/-/content-type-1.0.2.tgz", - "integrity": "sha1-t9ETrueo3Se9IRM8TcJSnfFyHu0=", - "dev": true - }, - "conventional-changelog": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/conventional-changelog/-/conventional-changelog-1.1.7.tgz", - "integrity": "sha1-kVGmKx2O2y2CcR2r9bfPcQQfgrE=", - "dev": true, - "requires": { - "conventional-changelog-angular": "1.6.0", - "conventional-changelog-atom": "0.1.2", - "conventional-changelog-codemirror": "0.2.1", - "conventional-changelog-core": "1.9.5", - "conventional-changelog-ember": "0.2.10", - "conventional-changelog-eslint": "0.2.1", - "conventional-changelog-express": "0.2.1", - "conventional-changelog-jquery": "0.1.0", - "conventional-changelog-jscs": "0.1.0", - "conventional-changelog-jshint": "0.2.1" - } - }, - "conventional-changelog-angular": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-1.6.0.tgz", - "integrity": "sha1-CiagcfLJ/PzyuGugz79uYwG3W/o=", - "dev": true, - "requires": { - "compare-func": "1.3.2", - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-atom": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/conventional-changelog-atom/-/conventional-changelog-atom-0.1.2.tgz", - "integrity": "sha1-Ella1SZ6aTfDTPkAKBscZRmKTGM=", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-codemirror": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.2.1.tgz", - "integrity": "sha1-KZpPcUe681DmyBWPxUlUopHFzAk=", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-core": { - "version": "1.9.5", - "resolved": "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-1.9.5.tgz", - "integrity": "sha1-XbdWba18DLddr0f7spdve/mSjB0=", - "dev": true, - "requires": { - "conventional-changelog-writer": "2.0.3", - "conventional-commits-parser": "2.1.0", - "dateformat": "1.0.12", - "get-pkg-repo": "1.4.0", - "git-raw-commits": "1.3.0", - "git-remote-origin-url": "2.0.0", - "git-semver-tags": "1.2.3", - "lodash": "4.17.4", - "normalize-package-data": "2.4.0", - "q": "1.5.1", - "read-pkg": "1.1.0", - "read-pkg-up": "1.0.1", - "through2": "2.0.3" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "conventional-changelog-ember": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/conventional-changelog-ember/-/conventional-changelog-ember-0.2.10.tgz", - "integrity": "sha512-LBBBZO6Q7ib4HhSdyCNVR25OtaXl710UJg1aSHCLmR8AjuXKs3BO8tnbY1MH+D1C+z5IFoEDkpjOddefNTyhCQ==", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-eslint": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-eslint/-/conventional-changelog-eslint-0.2.1.tgz", - "integrity": "sha1-LCoRvrIW+AZJunKDQYApO2h8BmI=", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-express": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-express/-/conventional-changelog-express-0.2.1.tgz", - "integrity": "sha1-g42eHmyQmXA7FQucGaoteBdCvWw=", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-jquery": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz", - "integrity": "sha1-Agg5cWLjhGmG5xJztsecW1+A9RA=", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-jscs": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz", - "integrity": "sha1-BHnrRDzH1yxYvwvPDvHURKkvDlw=", - "dev": true, - "requires": { - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-jshint": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/conventional-changelog-jshint/-/conventional-changelog-jshint-0.2.1.tgz", - "integrity": "sha1-hhObs6yZiZ8rF36WF+CbN9mbzzo=", - "dev": true, - "requires": { - "compare-func": "1.3.2", - "q": "1.5.1" - }, - "dependencies": { - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - } - } - }, - "conventional-changelog-writer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/conventional-changelog-writer/-/conventional-changelog-writer-2.0.3.tgz", - "integrity": "sha512-2E1h7UXL0fhRO5h0CxDZ5EBc5sfBZEQePvuZ+gPvApiRrICUyNDy/NQIP+2TBd4wKZQf2Zm7TxbzXHG5HkPIbA==", - "dev": true, - "requires": { - "compare-func": "1.3.2", - "conventional-commits-filter": "1.1.1", - "dateformat": "1.0.12", - "handlebars": "4.0.11", - "json-stringify-safe": "5.0.1", - "lodash": "4.17.4", - "meow": "3.7.0", - "semver": "5.5.0", - "split": "1.0.1", - "through2": "2.0.3" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "conventional-commits-filter": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/conventional-commits-filter/-/conventional-commits-filter-1.1.1.tgz", - "integrity": "sha512-bQyatySNKHhcaeKVr9vFxYWA1W1Tdz6ybVMYDmv4/FhOXY1+fchiW07TzRbIQZhVa4cvBwrEaEUQBbCncFSdJQ==", - "dev": true, - "requires": { - "is-subset": "0.1.1", - "modify-values": "1.0.0" - } - }, - "conventional-commits-parser": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/conventional-commits-parser/-/conventional-commits-parser-2.1.0.tgz", - "integrity": "sha512-8MD05yN0Zb6aRsZnFX1ET+8rHWfWJk+my7ANCJZBU2mhz7TSB1fk2vZhkrwVy/PCllcTYAP/1T1NiWQ7Z01mKw==", - "dev": true, - "requires": { - "JSONStream": "1.3.2", - "is-text-path": "1.0.1", - "lodash": "4.17.4", - "meow": "3.7.0", - "split2": "2.2.0", - "through2": "2.0.3", - "trim-off-newlines": "1.0.1" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "cookie": { - "version": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=", - "dev": true - }, - "core-js": { - "version": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz", - "integrity": "sha1-TekR5mew6ukSTjQlS1OupvxhjT4=", - "dev": true - }, - "core-util-is": { - "version": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "crc32-stream": { - "version": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-0.3.4.tgz", - "integrity": "sha1-c7wltF+sHbZjIjGnv86JJ+nwZVI=", - "dev": true, - "requires": { - "buffer-crc32": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, - "create-error-class": { - "version": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", - "integrity": "sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y=", - "dev": true, - "requires": { - "capture-stack-trace": "https://registry.npmjs.org/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz" - } - }, - "cross-spawn": { - "version": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-0.2.9.tgz", - "integrity": "sha1-vWf5bAfvtjA7f+lMHpefiEeOCjk=", - "dev": true, - "requires": { - "lru-cache": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz" - } - }, - "cryptiles": { - "version": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, - "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz" - } - }, - "crypto-random-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz", - "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=", - "dev": true - }, - "ctype": { - "version": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz", - "integrity": "sha1-gsGMJGH3QRTvFsE1IkrQuRRMoS8=", - "dev": true - }, - "currently-unhandled": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", - "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", - "dev": true, - "requires": { - "array-find-index": "1.0.2" - } - }, - "custom-event": { - "version": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "integrity": "sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU=", - "dev": true - }, - "dargs": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/dargs/-/dargs-4.1.0.tgz", - "integrity": "sha1-A6nbtLXC8Tm/FK5T8LiipqhvThc=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - }, - "dependencies": { - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - } - } - }, - "dashdash": { - "version": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" - }, - "dependencies": { - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - } - } - }, - "dateformat": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", - "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", - "dev": true, - "requires": { - "get-stdin": "4.0.1", - "meow": "3.7.0" - } - }, - "deap": { - "version": "https://registry.npmjs.org/deap/-/deap-1.0.0.tgz", - "integrity": "sha1-sUi/gkMKJ2mbdIOgPra2dYW/yIg=", - "dev": true - }, - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz", - "integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - } - }, - "decamelize": { - "version": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "deep-extend": { - "version": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", - "integrity": "sha1-7+QRPQgIX05vlod1mBD4B0aeIlM=", - "dev": true - }, - "defaults": { - "version": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "dev": true, - "requires": { - "clone": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz" - } - }, - "del": { - "version": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", - "dev": true, - "requires": { - "globby": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", - "is-path-cwd": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", - "is-path-in-cwd": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "pify": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz" - } - }, - "delayed-stream": { - "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz", - "integrity": "sha1-1LH0OpPoKW3+AmlPRoC8N6MTxz8=", - "dev": true - }, - "depd": { - "version": "https://registry.npmjs.org/depd/-/depd-1.1.0.tgz", - "integrity": "sha1-4b2Cxqq2ztlluXuIsX7T5SjKGMM=", - "dev": true - }, - "deprecated": { - "version": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", - "integrity": "sha1-+cmvVGSvoeepcUWKi97yqpTVuxk=", - "dev": true - }, - "detect-file": { - "version": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", - "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", - "dev": true, - "requires": { - "fs-exists-sync": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz" - } - }, - "di": { - "version": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "integrity": "sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw=", - "dev": true - }, - "dom-serialize": { - "version": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "integrity": "sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=", - "dev": true, - "requires": { - "custom-event": "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz", - "ent": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "void-elements": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz" - } - }, - "duplexer3": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.4.tgz", - "integrity": "sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=", - "dev": true - }, - "ecc-jsbn": { - "version": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "dev": true, - "optional": true, - "requires": { - "jsbn": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz" - } - }, - "ee-first": { - "version": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true - }, - "emojis-list": { - "version": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", - "dev": true - }, - "end-of-stream": { - "version": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", - "integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=", - "dev": true, - "requires": { - "once": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" - }, - "dependencies": { - "once": { - "version": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - } - } - }, - "engine.io": { - "version": "https://registry.npmjs.org/engine.io/-/engine.io-1.8.2.tgz", - "integrity": "sha1-a1m+cws0jAElsKRYneHDVavPen4=", - "dev": true, - "requires": { - "accepts": "https://registry.npmjs.org/accepts/-/accepts-1.3.3.tgz", - "base64id": "https://registry.npmjs.org/base64id/-/base64id-1.0.0.tgz", - "cookie": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "engine.io-parser": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.2.tgz", - "ws": "https://registry.npmjs.org/ws/-/ws-1.1.1.tgz" - }, - "dependencies": { - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - } - } - } - }, - "engine.io-client": { - "version": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-1.8.2.tgz", - "integrity": "sha1-w4dnVH8qfRhPV1L28K1QEAZwN2Y=", - "dev": true, - "requires": { - "component-emitter": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "component-inherit": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "engine.io-parser": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.2.tgz", - "has-cors": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", - "indexof": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "parsejson": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz", - "parseqs": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", - "parseuri": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", - "ws": "https://registry.npmjs.org/ws/-/ws-1.1.1.tgz", - "xmlhttprequest-ssl": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", - "yeast": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz" - }, - "dependencies": { - "component-emitter": { - "version": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - } - } - } - }, - "engine.io-parser": { - "version": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-1.3.2.tgz", - "integrity": "sha1-k3sHnwAH0Ik+xW1GyyILjLQ1Igo=", - "dev": true, - "requires": { - "after": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", - "arraybuffer.slice": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz", - "base64-arraybuffer": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", - "blob": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", - "has-binary": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", - "wtf-8": "https://registry.npmjs.org/wtf-8/-/wtf-8-1.0.0.tgz" - } - }, - "enhanced-resolve": { - "version": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz", - "integrity": "sha1-TW5omzcl+GCQknzMhs2fFjW4ni4=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "memory-fs": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz", - "tapable": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz" - } - }, - "ent": { - "version": "https://registry.npmjs.org/ent/-/ent-2.2.0.tgz", - "integrity": "sha1-6WQhkyWiHQX0RGai9obtbOX13R0=", - "dev": true - }, - "es6-promise": { - "version": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.3.1.tgz", - "integrity": "sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM=", - "dev": true - }, - "escape-html": { - "version": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "eventemitter3": { - "version": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", - "integrity": "sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg=", - "dev": true - }, - "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", - "dev": true, - "requires": { - "cross-spawn": "5.1.0", - "get-stream": "3.0.0", - "is-stream": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "npm-run-path": "2.0.2", - "p-finally": "1.0.0", - "signal-exit": "3.0.2", - "strip-eof": "1.0.0" - }, - "dependencies": { - "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "dev": true, - "requires": { - "lru-cache": "4.1.1", - "shebang-command": "1.2.0", - "which": "1.3.0" - } - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "lru-cache": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", - "integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==", - "dev": true, - "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" - } - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", - "dev": true, - "requires": { - "isexe": "2.0.0" - } - } - } - }, - "exit": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", - "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", - "dev": true - }, - "expand-braces": { - "version": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", - "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", - "dev": true, - "requires": { - "array-slice": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "array-unique": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "braces": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz" - }, - "dependencies": { - "braces": { - "version": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz", - "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=", - "dev": true, - "requires": { - "expand-range": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz" - } - }, - "expand-range": { - "version": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", - "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", - "dev": true, - "requires": { - "is-number": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", - "repeat-string": "https://registry.npmjs.org/repeat-string/-/repeat-string-0.2.2.tgz" - } - }, - "is-number": { - "version": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", - "integrity": "sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY=", - "dev": true - }, - "repeat-string": { - "version": "https://registry.npmjs.org/repeat-string/-/repeat-string-0.2.2.tgz", - "integrity": "sha1-x6jTI2BoNiBZp+RlH8aITosftK4=", - "dev": true - } - } - }, - "expand-brackets": { - "version": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz" - } - }, - "expand-range": { - "version": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, - "requires": { - "fill-range": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz" - } - }, - "expand-tilde": { - "version": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", - "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", - "dev": true, - "requires": { - "os-homedir": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz" - } - }, - "extend": { - "version": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "integrity": "sha1-WkdDU7nzNT3dgXbf03uRyDpG8dQ=", - "dev": true - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } - } - } - }, - "extglob": { - "version": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz" - } - }, - "extract-zip": { - "version": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.5.0.tgz", - "integrity": "sha1-ksz22B73Cp+kwXRxFMzvbYaIpsQ=", - "dev": true, - "requires": { - "concat-stream": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.0.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "yauzl": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz" - }, - "dependencies": { - "concat-stream": { - "version": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.0.tgz", - "integrity": "sha1-U/fUPFHF5D+ByP3QMyHGMb5o1hE=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "typedarray": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" - } - }, - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", - "integrity": "sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk=", - "dev": true - }, - "minimist": { - "version": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", - "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", - "dev": true, - "requires": { - "minimist": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" - } - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - } - } - } - }, - "extsprintf": { - "version": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", - "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", - "dev": true - }, - "fancy-log": { - "version": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "integrity": "sha1-Rb4X0Cu5kX1gzP/UmVyZnmyMmUg=", - "dev": true, - "requires": { - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "time-stamp": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.0.1.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true - }, - "fd-slicer": { - "version": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", - "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", - "dev": true, - "requires": { - "pend": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz" - } - }, - "filename-regex": { - "version": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz", - "integrity": "sha1-mW4+gEebmLmJfxWopYs9CE6SZ3U=", - "dev": true - }, - "fill-range": { - "version": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", - "dev": true, - "requires": { - "is-number": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "isobject": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "randomatic": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", - "repeat-element": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "repeat-string": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz" - } - }, - "finalhandler": { - "version": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.0.tgz", - "integrity": "sha1-6VCKvs6bbbqHGmlCodeRG5GRGsc=", - "dev": true, - "requires": { - "debug": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "escape-html": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "on-finished": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "statuses": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "unpipe": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" - }, - "dependencies": { - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - } - }, - "ms": { - "version": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - } - } - }, - "find-index": { - "version": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz", - "integrity": "sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ=", - "dev": true - }, - "find-up": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", - "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", - "dev": true, - "requires": { - "path-exists": "2.1.0", - "pinkie-promise": "2.0.1" - }, - "dependencies": { - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "2.0.4" - } - } - } - }, - "findup-sync": { - "version": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", - "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", - "dev": true, - "requires": { - "detect-file": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", - "is-glob": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "micromatch": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "resolve-dir": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz" - } - }, - "fined": { - "version": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz", - "integrity": "sha1-WyhCS3YNdZiWC374SA3/itNmDpc=", - "dev": true, - "requires": { - "expand-tilde": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", - "lodash.assignwith": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", - "lodash.isempty": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz", - "lodash.isplainobject": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "lodash.isstring": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "lodash.pick": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "parse-filepath": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz" - } - }, - "first-chunk-stream": { - "version": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "integrity": "sha1-Wb+1DNkF9g18OUzT2ayqtOatk04=", - "dev": true - }, - "flagged-respawn": { - "version": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz", - "integrity": "sha1-/xke3c1wiKZ1smEP/8l2vpuAdLU=", - "dev": true - }, - "for-in": { - "version": "https://registry.npmjs.org/for-in/-/for-in-0.1.6.tgz", - "integrity": "sha1-yfluib+tGKVFr17D7TUqHZ5bTcg=", - "dev": true - }, - "for-own": { - "version": "https://registry.npmjs.org/for-own/-/for-own-0.1.4.tgz", - "integrity": "sha1-AUm0GjkIjHUV9R6+HBOG1F+TUHI=", - "dev": true, - "requires": { - "for-in": "https://registry.npmjs.org/for-in/-/for-in-0.1.6.tgz" - } - }, - "forever-agent": { - "version": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true - }, - "form-data": { - "version": "https://registry.npmjs.org/form-data/-/form-data-0.2.0.tgz", - "integrity": "sha1-Jvi8JtpkQOKZy9z7aQNcT3em5GY=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.14.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", - "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", - "dev": true - }, - "mime-db": { - "version": "https://registry.npmjs.org/mime-db/-/mime-db-1.12.0.tgz", - "integrity": "sha1-PQxjGA9FjrENMlqqN9fFiuMS6dc=", - "dev": true - }, - "mime-types": { - "version": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.14.tgz", - "integrity": "sha1-MQ4VnbI+B3+Lsit0jav6SVcUCqY=", - "dev": true, - "requires": { - "mime-db": "https://registry.npmjs.org/mime-db/-/mime-db-1.12.0.tgz" - } - } - } - }, - "formatio": { - "version": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", - "integrity": "sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek=", - "dev": true, - "requires": { - "samsam": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz" - } - }, - "fs-access": { - "version": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", - "integrity": "sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o=", - "dev": true, - "requires": { - "null-check": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz" - } - }, - "fs-exists-sync": { - "version": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", - "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", - "dev": true - }, - "fs-extra": { - "version": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "integrity": "sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "jsonfile": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "klaw": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz" - } - }, - "fs.realpath": { - "version": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "gaze": { - "version": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz", - "integrity": "sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8=", - "dev": true, - "requires": { - "globule": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz" - } - }, - "generate-function": { - "version": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", - "dev": true - }, - "generate-object-property": { - "version": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "requires": { - "is-property": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz" - } - }, - "get-pkg-repo": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz", - "integrity": "sha1-xztInAbYDMVTbCyFP54FIyBWly0=", - "dev": true, - "requires": { - "hosted-git-info": "2.5.0", - "meow": "3.7.0", - "normalize-package-data": "2.4.0", - "parse-github-repo-url": "1.4.1", - "through2": "2.0.3" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "get-stdin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", - "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", - "dev": true - }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true - }, - "getpass": { - "version": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz" - }, - "dependencies": { - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - } - } - }, - "git-raw-commits": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/git-raw-commits/-/git-raw-commits-1.3.0.tgz", - "integrity": "sha1-C8hZbpDV/+c29/VUa9LRL3OrqsY=", - "dev": true, - "requires": { - "dargs": "4.1.0", - "lodash.template": "4.4.0", - "meow": "3.7.0", - "split2": "2.2.0", - "through2": "2.0.3" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "git-remote-origin-url": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz", - "integrity": "sha1-UoJlna4hBxRaERJhEq0yFuxfpl8=", - "dev": true, - "requires": { - "gitconfiglocal": "1.0.0", - "pify": "2.3.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - } - } - }, - "git-semver-tags": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-1.2.3.tgz", - "integrity": "sha1-GItFOIK/nXojr9Mbq6U32rc4jV0=", - "dev": true, - "requires": { - "meow": "3.7.0", - "semver": "5.5.0" - }, - "dependencies": { - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true - } - } - }, - "gitconfiglocal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz", - "integrity": "sha1-QdBF84UaXqiPA/JMocYXgRRGS5s=", - "dev": true, - "requires": { - "ini": "1.3.5" - }, - "dependencies": { - "ini": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", - "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", - "dev": true - } - } - }, - "glob": { - "version": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", - "dev": true, - "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", - "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - } - }, - "glob-base": { - "version": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "is-glob": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz" - } - }, - "glob-parent": { - "version": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz" - } - }, - "glob-stream": { - "version": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", - "integrity": "sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs=", - "dev": true, - "requires": { - "glob": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "glob2base": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "ordered-read-streams": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "unique-stream": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz" - }, - "dependencies": { - "glob": { - "version": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz" - } - }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "minimatch": { - "version": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz" - } - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - }, - "through2": { - "version": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - } - } - }, - "glob-watcher": { - "version": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", - "integrity": "sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs=", - "dev": true, - "requires": { - "gaze": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz" - } - }, - "glob2base": { - "version": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "integrity": "sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY=", - "dev": true, - "requires": { - "find-index": "https://registry.npmjs.org/find-index/-/find-index-0.1.1.tgz" - } - }, - "global-dirs": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.0.tgz", - "integrity": "sha1-ENNAOeDfBCcuJizyQiT3IJQ0308=", - "dev": true, - "requires": { - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz" - } - }, - "global-modules": { - "version": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", - "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", - "dev": true, - "requires": { - "global-prefix": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", - "is-windows": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz" - } - }, - "global-prefix": { - "version": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", - "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", - "dev": true, - "requires": { - "homedir-polyfill": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "is-windows": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", - "which": "https://registry.npmjs.org/which/-/which-1.2.12.tgz" - } - }, - "globby": { - "version": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", - "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", - "dev": true, - "requires": { - "array-union": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "arrify": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "pify": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } - }, - "globule": { - "version": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", - "integrity": "sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU=", - "dev": true, - "requires": { - "glob": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz" - }, - "dependencies": { - "glob": { - "version": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", - "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz" - } - }, - "graceful-fs": { - "version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", - "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", - "dev": true - }, - "inherits": { - "version": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", - "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", - "dev": true - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-1.0.2.tgz", - "integrity": "sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE=", - "dev": true - }, - "minimatch": { - "version": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", - "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", - "dev": true, - "requires": { - "lru-cache": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "sigmund": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" - } - } - } - }, - "google-closure-compiler": { - "version": "https://registry.npmjs.org/google-closure-compiler/-/google-closure-compiler-20170409.0.0.tgz", - "integrity": "sha1-3Bvimp9+74YRNkUzsnG5+sdXyXA=", - "dev": true, - "requires": { - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "vinyl": "https://registry.npmjs.org/vinyl/-/vinyl-2.0.2.tgz", - "vinyl-sourcemaps-apply": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "clone-stats": { - "version": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", - "dev": true - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "replace-ext": { - "version": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", - "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", - "dev": true - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "vinyl": { - "version": "https://registry.npmjs.org/vinyl/-/vinyl-2.0.2.tgz", - "integrity": "sha1-CjcT2NTpIhxY8QyhbAEWyeJe2nw=", - "dev": true, - "requires": { - "clone": "https://registry.npmjs.org/clone/-/clone-1.0.2.tgz", - "clone-buffer": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "cloneable-readable": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.0.0.tgz", - "is-stream": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "remove-trailing-separator": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz", - "replace-ext": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz" - } - } - } - }, - "graceful-fs": { - "version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "graceful-readlink": { - "version": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", - "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", - "dev": true - }, - "growl": { - "version": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", - "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", - "dev": true - }, - "gulp": { - "version": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", - "integrity": "sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ=", - "dev": true, - "requires": { - "archy": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "deprecated": "https://registry.npmjs.org/deprecated/-/deprecated-0.0.1.tgz", - "gulp-util": "3.0.8", - "interpret": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz", - "liftoff": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "orchestrator": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", - "pretty-hrtime": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "semver": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "tildify": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", - "v8flags": "https://registry.npmjs.org/v8flags/-/v8flags-2.0.11.tgz", - "vinyl-fs": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "semver": { - "version": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", - "dev": true - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "gulp-clang-format": { - "version": "1.0.25", - "resolved": "https://registry.npmjs.org/gulp-clang-format/-/gulp-clang-format-1.0.25.tgz", - "integrity": "sha512-YSYk3st/ktKrBWfnDSutYZU9pLnCdaeJBTT8YguTJJLkQjSFZjBCBquecSXfoWW+NcVfGuei3N7vs7xuSR+2bg==", - "dev": true, - "requires": { - "clang-format": "https://registry.npmjs.org/clang-format/-/clang-format-1.0.46.tgz", - "gulp-diff": "1.0.0", - "gulp-util": "3.0.8", - "pkginfo": "0.3.1", - "stream-combiner2": "1.1.1", - "stream-equal": "0.1.6", - "through2": "0.6.5" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "cli-color": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-1.2.0.tgz", - "integrity": "sha1-OlrnT9drYmevZm5p4q+70B3vNNE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1", - "d": "1.0.0", - "es5-ext": "0.10.38", - "es6-iterator": "2.0.3", - "memoizee": "0.4.11", - "timers-ext": "0.1.2" - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "d": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", - "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", - "dev": true, - "requires": { - "es5-ext": "0.10.38" - } - }, - "diff": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/diff/-/diff-2.2.3.tgz", - "integrity": "sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k=", - "dev": true - }, - "duplexer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", - "dev": true - }, - "duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", - "dev": true, - "requires": { - "readable-stream": "2.3.3" - } - }, - "es5-ext": { - "version": "0.10.38", - "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.38.tgz", - "integrity": "sha512-jCMyePo7AXbUESwbl8Qi01VSH2piY9s/a3rSU/5w/MlTIx8HPL1xn2InGN8ejt/xulcJgnTO7vqNtOAxzYd2Kg==", - "dev": true, - "requires": { - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1" - } - }, - "es6-iterator": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", - "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.38", - "es6-symbol": "3.1.1" - } - }, - "es6-symbol": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", - "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.38" - } - }, - "es6-weak-map": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", - "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.38", - "es6-iterator": "2.0.3", - "es6-symbol": "3.1.1" - } - }, - "event-emitter": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", - "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.38" - } - }, - "event-stream": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "dev": true, - "requires": { - "duplexer": "0.1.1", - "from": "0.1.7", - "map-stream": "0.1.0", - "pause-stream": "0.0.11", - "split": "0.3.3", - "stream-combiner": "0.0.4", - "through": "2.3.8" - } - }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, - "gulp-diff": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gulp-diff/-/gulp-diff-1.0.0.tgz", - "integrity": "sha1-EBsjcS3WsQe9B9BauI6jrEhf7Xc=", - "dev": true, - "requires": { - "cli-color": "1.2.0", - "diff": "2.2.3", - "event-stream": "3.3.4", - "gulp-util": "3.0.8", - "through2": "2.0.3" - }, - "dependencies": { - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - } - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "lru-queue": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz", - "integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=", - "dev": true, - "requires": { - "es5-ext": "0.10.38" - } - }, - "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", - "dev": true - }, - "memoizee": { - "version": "0.4.11", - "resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.11.tgz", - "integrity": "sha1-vemBdmPJ5A/bKk6hw2cpYIeujI8=", - "dev": true, - "requires": { - "d": "1.0.0", - "es5-ext": "0.10.38", - "es6-weak-map": "2.0.2", - "event-emitter": "0.3.5", - "is-promise": "2.1.0", - "lru-queue": "0.1.0", - "next-tick": "1.0.0", - "timers-ext": "0.1.2" - } - }, - "next-tick": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", - "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", - "dev": true - }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, - "pkginfo": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", - "integrity": "sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", - "dev": true, - "requires": { - "through": "2.3.8" - } - }, - "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", - "dev": true, - "requires": { - "duplexer": "0.1.1" - } - }, - "stream-combiner2": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", - "dev": true, - "requires": { - "duplexer2": "0.1.4", - "readable-stream": "2.3.3" - } - }, - "stream-equal": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/stream-equal/-/stream-equal-0.1.6.tgz", - "integrity": "sha1-zFIvqzhRYBLk1O5HUTsUe3I1kBk=", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "4.0.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, - "timers-ext": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.2.tgz", - "integrity": "sha1-YcxHp2wavTGV8UUn+XjViulMUgQ=", - "dev": true, - "requires": { - "es5-ext": "0.10.38", - "next-tick": "1.0.0" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "gulp-conventional-changelog": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/gulp-conventional-changelog/-/gulp-conventional-changelog-1.1.7.tgz", - "integrity": "sha1-Azf2hLSeKTWOYj4W6UtJ8FotK/E=", - "dev": true, - "requires": { - "add-stream": "1.0.0", - "concat-stream": "1.6.0", - "conventional-changelog": "1.1.7", - "gulp-util": "3.0.8", - "object-assign": "4.1.1", - "through2": "2.0.3" - }, - "dependencies": { - "concat-stream": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", - "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "typedarray": "0.0.6" - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "gulp-rename": { - "version": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-1.2.2.tgz", - "integrity": "sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc=", - "dev": true - }, - "gulp-rollup": { - "version": "2.16.2", - "resolved": "https://registry.npmjs.org/gulp-rollup/-/gulp-rollup-2.16.2.tgz", - "integrity": "sha512-Gs9NYcUl0xXod7qenC1Lm49a/PGllAa5ONyCXu29lXfkP1oJnJzSdPBjopm9RlOVhefadbHlfy9AijovFrqABA==", - "dev": true, - "requires": { - "buffer-from": "0.1.1", - "plugin-error": "1.0.1", - "readable-stream": "2.3.3", - "rollup": "0.54.1", - "rollup-plugin-hypothetical": "2.1.0", - "vinyl": "2.1.0" - }, - "dependencies": { - "clone": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz", - "integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=", - "dev": true - }, - "clone-buffer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz", - "integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=", - "dev": true - }, - "clone-stats": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz", - "integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=", - "dev": true - }, - "cloneable-readable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.0.0.tgz", - "integrity": "sha1-pikNQT8hemEjL5XkWP84QYz7ARc=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "process-nextick-args": "1.0.7", - "through2": "2.0.3" - } - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "replace-ext": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", - "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "vinyl": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.1.0.tgz", - "integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=", - "dev": true, - "requires": { - "clone": "2.1.1", - "clone-buffer": "1.0.0", - "clone-stats": "1.0.0", - "cloneable-readable": "1.0.0", - "remove-trailing-separator": "1.1.0", - "replace-ext": "1.0.0" - } - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "gulp-tsc": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/gulp-tsc/-/gulp-tsc-1.3.2.tgz", - "integrity": "sha1-Wmb4CvOXYAXm9fBrnPzLDm1zmc4=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "byline": "https://registry.npmjs.org/byline/-/byline-4.2.2.tgz", - "gulp-util": "3.0.8", - "lodash": "3.10.1", - "node-version-compare": "https://registry.npmjs.org/node-version-compare/-/node-version-compare-1.0.1.tgz", - "resolve": "1.4.0", - "rimraf": "2.6.2", - "temp": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "vinyl-fs": "1.0.0", - "which": "1.3.0" - }, - "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - }, - "clone": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", - "dev": true - }, - "duplexify": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.5.1.tgz", - "integrity": "sha512-j5goxHTwVED1Fpe5hh3q9R93Kip0Bg2KVAt4f8CEYM3UEwYcPSvWbXaUQOzdX/HtiNomipv+gU7ASQPDbV7pGQ==", - "dev": true, - "requires": { - "end-of-stream": "1.4.0", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "readable-stream": "2.3.3", - "stream-shift": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz" - } - }, - "end-of-stream": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", - "integrity": "sha1-epDYM+/abPpurA9JSduw+tOmMgY=", - "dev": true, - "requires": { - "once": "1.4.0" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - } - }, - "glob-stream": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/glob-stream/-/glob-stream-4.1.1.tgz", - "integrity": "sha1-uELfENaIx+trz869hG84UilrMgA=", - "dev": true, - "requires": { - "glob": "4.5.3", - "glob2base": "https://registry.npmjs.org/glob2base/-/glob2base-0.0.12.tgz", - "minimatch": "2.0.10", - "ordered-read-streams": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "through2": "0.6.5", - "unique-stream": "2.2.1" - }, - "dependencies": { - "glob": { - "version": "4.5.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-4.5.3.tgz", - "integrity": "sha1-xstz0yJsHv7wTePFbQEvAzd+4V8=", - "dev": true, - "requires": { - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "2.0.10", - "once": "1.4.0" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "minimatch": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - } - } - }, - "glob-watcher": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.8.tgz", - "integrity": "sha1-aK62Yefizo02NDgbLsQV8AxrwqQ=", - "dev": true, - "requires": { - "gaze": "https://registry.npmjs.org/gaze/-/gaze-0.5.2.tgz" - } - }, - "graceful-fs": { - "version": "3.0.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "dev": true, - "requires": { - "natives": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" - } - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "object-assign": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", - "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", - "dev": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "1.0.0", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "string_decoder": "1.0.3", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - } - }, - "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" - } - }, - "strip-bom": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", - "dev": true, - "requires": { - "first-chunk-stream": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" - } - }, - "unique-stream": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/unique-stream/-/unique-stream-2.2.1.tgz", - "integrity": "sha1-WqADz76Uxf+GbE59ZouxxNuts2k=", - "dev": true, - "requires": { - "json-stable-stringify": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "through2-filter": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz" - } - }, - "vinyl": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", - "dev": true, - "requires": { - "clone": "0.2.0", - "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" - } - }, - "vinyl-fs": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-1.0.0.tgz", - "integrity": "sha1-0VdS5owtrXQ2Tn6FNHNzU1RpLt8=", - "dev": true, - "requires": { - "duplexify": "3.5.1", - "glob-stream": "4.1.1", - "glob-watcher": "0.0.8", - "graceful-fs": "3.0.11", - "merge-stream": "https://registry.npmjs.org/merge-stream/-/merge-stream-0.1.8.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "object-assign": "2.1.1", - "strip-bom": "1.0.0", - "through2": "0.6.5", - "vinyl": "0.4.6" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "through2": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "1.0.34", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - } - } - }, - "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", - "dev": true, - "requires": { - "isexe": "2.0.0" - } - } - } - }, - "gulp-tslint": { - "version": "https://registry.npmjs.org/gulp-tslint/-/gulp-tslint-7.1.0.tgz", - "integrity": "sha1-m9P/T7wW1MvZq7CP94bbibVj6T0=", - "dev": true, - "requires": { - "gulp-util": "3.0.8", - "map-stream": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "through": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - } - }, - "gulp-uglify": { - "version": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-1.5.4.tgz", - "integrity": "sha1-UkeI2HZm0J+dDCH7IXf5ADmmWMk=", - "dev": true, - "requires": { - "deap": "https://registry.npmjs.org/deap/-/deap-1.0.0.tgz", - "fancy-log": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.0.tgz", - "gulp-util": "3.0.8", - "isobject": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "uglify-js": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", - "uglify-save-license": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz", - "vinyl-sourcemaps-apply": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", - "dev": true - }, - "source-map": { - "version": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "dev": true - }, - "uglify-js": { - "version": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.6.4.tgz", - "integrity": "sha1-ZeovswWck5RpLxX+2HwrNsFrmt8=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", - "source-map": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "uglify-to-browserify": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "yargs": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz" - } - } - } - }, - "gulp-util": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/gulp-util/-/gulp-util-3.0.8.tgz", - "integrity": "sha1-AFTh50RQLifATBh8PsxQXdVLu08=", - "dev": true, - "requires": { - "array-differ": "1.0.0", - "array-uniq": "1.0.3", - "beeper": "1.1.1", - "chalk": "1.1.3", - "dateformat": "2.2.0", - "fancy-log": "1.3.2", - "gulplog": "1.0.0", - "has-gulplog": "0.1.0", - "lodash._reescape": "3.0.0", - "lodash._reevaluate": "3.0.0", - "lodash._reinterpolate": "3.0.0", - "lodash.template": "3.6.2", - "minimist": "1.2.0", - "multipipe": "0.1.2", - "object-assign": "3.0.0", - "replace-ext": "0.0.1", - "through2": "2.0.3", - "vinyl": "0.5.3" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "array-differ": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-1.0.0.tgz", - "integrity": "sha1-7/UuN1gknTO+QCuLuOVkuytdQDE=", - "dev": true - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "beeper": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/beeper/-/beeper-1.1.1.tgz", - "integrity": "sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, - "clone": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", - "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", - "dev": true - }, - "clone-stats": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz", - "integrity": "sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE=", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "dateformat": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-2.2.0.tgz", - "integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=", - "dev": true - }, - "duplexer2": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.0.2.tgz", - "integrity": "sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds=", - "dev": true, - "requires": { - "readable-stream": "1.1.14" - } - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "fancy-log": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/fancy-log/-/fancy-log-1.3.2.tgz", - "integrity": "sha1-9BEl49hPLn2JpD0G2VjI94vha+E=", - "dev": true, - "requires": { - "ansi-gray": "0.1.1", - "color-support": "1.1.3", - "time-stamp": "1.1.0" - } - }, - "glogg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/glogg/-/glogg-1.0.1.tgz", - "integrity": "sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw==", - "dev": true, - "requires": { - "sparkles": "1.0.0" - } - }, - "gulplog": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", - "integrity": "sha1-4oxNRdBey77YGDY86PnFkmIp/+U=", - "dev": true, - "requires": { - "glogg": "1.0.1" - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-gulplog": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", - "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", - "dev": true, - "requires": { - "sparkles": "1.0.0" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "lodash._basecopy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", - "dev": true - }, - "lodash._basetostring": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", - "integrity": "sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U=", - "dev": true - }, - "lodash._basevalues": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz", - "integrity": "sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc=", - "dev": true - }, - "lodash._getnative": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._isiterateecall": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "lodash._reescape": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reescape/-/lodash._reescape-3.0.0.tgz", - "integrity": "sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo=", - "dev": true - }, - "lodash._reevaluate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz", - "integrity": "sha1-WLx0xAZklTrgsSTYBpltrKQx4u0=", - "dev": true - }, - "lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", - "dev": true - }, - "lodash._root": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._root/-/lodash._root-3.0.1.tgz", - "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", - "dev": true - }, - "lodash.escape": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", - "integrity": "sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg=", - "dev": true, - "requires": { - "lodash._root": "3.0.1" - } - }, - "lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, - "lodash.isarray": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" - } - }, - "lodash.restparam": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", - "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", - "dev": true - }, - "lodash.template": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-3.6.2.tgz", - "integrity": "sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8=", - "dev": true, - "requires": { - "lodash._basecopy": "3.0.1", - "lodash._basetostring": "3.0.1", - "lodash._basevalues": "3.0.0", - "lodash._isiterateecall": "3.0.9", - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0", - "lodash.keys": "3.1.2", - "lodash.restparam": "3.6.1", - "lodash.templatesettings": "3.1.1" - } - }, - "lodash.templatesettings": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz", - "integrity": "sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU=", - "dev": true, - "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.escape": "3.2.0" - } - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "multipipe": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/multipipe/-/multipipe-0.1.2.tgz", - "integrity": "sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s=", - "dev": true, - "requires": { - "duplexer2": "0.0.2" - } - }, - "object-assign": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz", - "integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "0.0.1", - "string_decoder": "0.10.31" - } - }, - "replace-ext": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-0.0.1.tgz", - "integrity": "sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ=", - "dev": true - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "sparkles": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.0.tgz", - "integrity": "sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM=", - "dev": true - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - } - } - }, - "time-stamp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.1.0.tgz", - "integrity": "sha1-dkpaEa9QVhkhsTPztE5hhofg9cM=", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "vinyl": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.5.3.tgz", - "integrity": "sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4=", - "dev": true, - "requires": { - "clone": "1.0.3", - "clone-stats": "0.0.1", - "replace-ext": "0.0.1" - } - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "handlebars": { - "version": "4.0.11", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", - "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", - "dev": true, - "requires": { - "async": "1.5.2", - "optimist": "0.6.1", - "source-map": "0.4.4", - "uglify-js": "2.8.29" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, - "minimist": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", - "dev": true - }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "dev": true, - "requires": { - "minimist": "0.0.10", - "wordwrap": "0.0.3" - } - }, - "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", - "dev": true - } - } - }, - "har-schema": { - "version": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", - "dev": true - }, - "har-validator": { - "version": "https://registry.npmjs.org/har-validator/-/har-validator-1.8.0.tgz", - "integrity": "sha1-2DhCsOtMQ1lgrrEIoGejqpTA7rI=", - "dev": true, - "requires": { - "bluebird": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "commander": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", - "is-my-json-valid": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "bluebird": { - "version": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "commander": { - "version": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", - "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", - "dev": true, - "requires": { - "graceful-readlink": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz" - } - }, - "has-binary": { - "version": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", - "integrity": "sha1-aOYesWIQyVRaClzOBqhzkS/h5ow=", - "dev": true, - "requires": { - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } - } - }, - "has-cors": { - "version": "https://registry.npmjs.org/has-cors/-/has-cors-1.1.0.tgz", - "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", - "dev": true - }, - "has-flag": { - "version": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", - "dev": true - }, - "has-own-property-x": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/has-own-property-x/-/has-own-property-x-3.1.1.tgz", - "integrity": "sha512-1L+yagK0h8YedH/bkwoiY+PdCr6SadmjgMudQ2SjiPdxXGdPhFybpln3yJ41EpuETz33ITNxTMHdYfeM79W03Q==", - "dev": true, - "requires": { - "to-object-x": "1.5.0", - "to-property-key-x": "2.0.2" - } - }, - "has-symbol-support-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", - "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", - "dev": true - }, - "has-to-string-tag-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", - "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", - "dev": true, - "requires": { - "has-symbol-support-x": "1.4.1" - } - }, - "hasha": { - "version": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "integrity": "sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE=", - "dev": true, - "requires": { - "is-stream": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } - }, - "hawk": { - "version": "https://registry.npmjs.org/hawk/-/hawk-2.3.1.tgz", - "integrity": "sha1-HnMc45RH+h0PbXB/e87r7A/R7B8=", - "dev": true, - "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" - } - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "hoek": { - "version": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true - }, - "homedir-polyfill": { - "version": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", - "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", - "dev": true, - "requires": { - "parse-passwd": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz" - } - }, - "hosted-git-info": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", - "dev": true - }, - "http-errors": { - "version": "https://registry.npmjs.org/http-errors/-/http-errors-1.5.1.tgz", - "integrity": "sha1-eIwNLB3iyBuebowBhDtrl+uSB1A=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "setprototypeof": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz", - "statuses": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz" - } - }, - "http-proxy": { - "version": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.16.2.tgz", - "integrity": "sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I=", - "dev": true, - "requires": { - "eventemitter3": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.2.0.tgz", - "requires-port": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz" - } - }, - "http-signature": { - "version": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.1.tgz", - "integrity": "sha1-T72sEyVZqoMjEh5UB3nAoBKyfmY=", - "dev": true, - "requires": { - "asn1": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz", - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz", - "ctype": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz" - } - }, - "iconv-lite": { - "version": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", - "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=", - "dev": true - }, - "immediate": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", - "integrity": "sha1-nbHb0Pr43m++D13V5Wu2BigN5ps=", - "dev": true - }, - "import-lazy": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-2.1.0.tgz", - "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", - "dev": true - }, - "imurmurhash": { - "version": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indent-string": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", - "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", - "dev": true, - "requires": { - "repeating": "2.0.1" - }, - "dependencies": { - "is-finite": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", - "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "repeating": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", - "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", - "dev": true, - "requires": { - "is-finite": "1.0.2" - } - } - } - }, - "indexof": { - "version": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", - "dev": true - }, - "infinity-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/infinity-x/-/infinity-x-1.0.0.tgz", - "integrity": "sha512-wjy2TupBtZ+aAniKt+xs/PO0xOkuaL6wBysUKbgD7aL1PMW/qY5xXDG59zXZ7dU+gk3zwXOu4yIEWPCEFBTgHQ==", - "dev": true - }, - "inflight": { - "version": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "inherits": { - "version": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "ini": { - "version": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", - "dev": true - }, - "interpret": { - "version": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz", - "integrity": "sha1-1Xn7f2k7hYAElHrzn6DbSfeVYCw=", - "dev": true - }, - "is-absolute": { - "version": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", - "integrity": "sha1-IN5p89uULvLYe5wto28XIjWxtes=", - "dev": true, - "requires": { - "is-relative": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", - "is-windows": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz" - } - }, - "is-array-buffer-x": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/is-array-buffer-x/-/is-array-buffer-x-1.7.0.tgz", - "integrity": "sha512-ufSZRMY2WZX5xyNvk0NOZAG7cgi35B/sGQDGqv8w0X7MoQ2GC9vedanJhuYTPaC4PUCqLQsda1w7NF+dPZmAJw==", - "dev": true, - "requires": { - "attempt-x": "1.1.1", - "has-to-string-tag-x": "1.4.1", - "is-object-like-x": "1.6.0", - "object-get-own-property-descriptor-x": "3.2.0", - "to-string-tag-x": "1.4.2" - } - }, - "is-binary-path": { - "version": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.8.0.tgz" - } - }, - "is-buffer": { - "version": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.4.tgz", - "integrity": "sha1-z8hszV3FpS+oBIkRHGkgxFfi2Ys=", - "dev": true - }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, - "requires": { - "builtin-modules": "1.1.1" - } - }, - "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true - }, - "is-dotfile": { - "version": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz", - "integrity": "sha1-LBMjg/ORmfjtwmjKAbmwB9IFzE0=", - "dev": true - }, - "is-equal-shallow": { - "version": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz" - } - }, - "is-extendable": { - "version": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-falsey-x": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-falsey-x/-/is-falsey-x-1.0.1.tgz", - "integrity": "sha512-XWNZC4A+3FX1ECoMjspuEFgSdio82IWjqY/suE0gZ10QA7nzHd/KraRq7Tc5VEHtFRgTRyTdY6W+ykPrDnyoAQ==", - "dev": true, - "requires": { - "to-boolean-x": "1.0.1" - } - }, - "is-finite-x": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/is-finite-x/-/is-finite-x-3.0.2.tgz", - "integrity": "sha512-HyFrxJZsgmP5RtR1PVlVvHSP4VslZOqr4uoq4x3rDrSOFaYp4R9tfmiWtAzQxPzixXhac3cYEno3NuVn0OHk2Q==", - "dev": true, - "requires": { - "infinity-x": "1.0.0", - "is-nan-x": "1.0.1" - } - }, - "is-fullwidth-code-point": { - "version": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" - } - }, - "is-function-x": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/is-function-x/-/is-function-x-3.3.0.tgz", - "integrity": "sha512-SreSSU1dlgYaXR5c0mm4qJHKYHIiGiEY+7Cd8/aRLLoMP/VvofD2XcWgBnP833ajpU5XzXbUSpfysnfKZLJFlg==", - "dev": true, - "requires": { - "attempt-x": "1.1.1", - "has-to-string-tag-x": "1.4.1", - "is-falsey-x": "1.0.1", - "is-primitive": "2.0.0", - "normalize-space-x": "3.0.0", - "replace-comments-x": "2.0.0", - "to-boolean-x": "1.0.1", - "to-string-tag-x": "1.4.2" - }, - "dependencies": { - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, - "normalize-space-x": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-space-x/-/normalize-space-x-3.0.0.tgz", - "integrity": "sha512-tbCJerqZCCHPst4rRKgsTanLf45fjOyeAU5zE3mhDxJtFJKt66q39g2XArWhXelgTFVib8mNBUm6Wrd0LxYcfQ==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "trim-x": "3.0.0", - "white-space-x": "3.0.0" - } - }, - "trim-left-x": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/trim-left-x/-/trim-left-x-3.0.0.tgz", - "integrity": "sha512-+m6cqkppI+CxQBTwWEZliOHpOBnCArGyMnS1WCLb6IRgukhTkiQu/TNEN5Lj2eM9jk8ewJsc7WxFZfmwNpRXWQ==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "require-coercible-to-string-x": "1.0.0", - "white-space-x": "3.0.0" - } - }, - "trim-right-x": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/trim-right-x/-/trim-right-x-3.0.0.tgz", - "integrity": "sha512-iIqEsWEbWVodqdixJHi4FoayJkUxhoL4AvSNGp4FF4FfQKRPGizt8++/RnyC9od75y7P/S6EfONoVqP+NddiKA==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "require-coercible-to-string-x": "1.0.0", - "white-space-x": "3.0.0" - } - }, - "trim-x": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/trim-x/-/trim-x-3.0.0.tgz", - "integrity": "sha512-w8s38RAUScQ6t3XqMkS75iz5ZkIYLQpVnv2lp3IuTS36JdlVzC54oe6okOf4Wz3UH4rr3XAb2xR3kR5Xei82fw==", - "dev": true, - "requires": { - "trim-left-x": "3.0.0", - "trim-right-x": "3.0.0" - } - }, - "white-space-x": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/white-space-x/-/white-space-x-3.0.0.tgz", - "integrity": "sha512-nMPVXGMdi/jQepXKryxqzEh/vCwdOYY/u6NZy40glMHvZfEr7/+vQKnDhEq4rZ1nniOFq9GWohQYB30uW/5Olg==", - "dev": true - } - } - }, - "is-glob": { - "version": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz" - } - }, - "is-index-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-index-x/-/is-index-x-1.0.0.tgz", - "integrity": "sha512-BJ7vtw0jvcjBX4UsT7KkpZUliAMX3vJugZimDKy4W6ilGDtvUZ8nYsYnROVrrsjNjg5LJ3MN9NvyRVALfDW/wQ==", - "dev": true, - "requires": { - "math-clamp-x": "1.1.0", - "max-safe-integer": "1.0.1", - "safe-to-string-x": "2.0.3", - "to-integer-x": "2.1.0", - "to-number-x": "1.2.0" - } - }, - "is-installed-globally": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", - "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", - "dev": true, - "requires": { - "global-dirs": "0.1.0", - "is-path-inside": "1.0.0" - }, - "dependencies": { - "is-path-inside": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", - "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", - "dev": true, - "requires": { - "path-is-inside": "1.0.2" - } - }, - "path-is-inside": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - } - } - }, - "is-my-json-valid": { - "version": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz", - "integrity": "sha1-k27do8o8IR/ZjzstPgjaQ/eykVs=", - "dev": true, - "requires": { - "generate-function": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "generate-object-property": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "jsonpointer": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - }, - "is-nan-x": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-nan-x/-/is-nan-x-1.0.1.tgz", - "integrity": "sha512-VfNJgfuT8USqKCYQss8g7sFvCzDnL+OOVMQoXhVoulZAyp0ZTj3oyZaaPrn2dxepAkKSQI2BiKHbBabX1DqVtw==", - "dev": true - }, - "is-nil-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/is-nil-x/-/is-nil-x-1.4.1.tgz", - "integrity": "sha512-cfTKWI5iSR04SSCzzugTH5tS2rYG7kwI8yl/AqWkyuxZ7k55cbA47Y7Lezdg1N9aaELd+UxLg628bdQeNQ6BUw==", - "dev": true, - "requires": { - "lodash.isnull": "3.0.0", - "validate.io-undefined": "1.0.3" - }, - "dependencies": { - "lodash.isnull": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz", - "integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4=", - "dev": true - }, - "validate.io-undefined": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz", - "integrity": "sha1-fif8uzFbhB54JDQxiXZxkp4gt/Q=", - "dev": true - } - } - }, - "is-npm": { - "version": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", - "integrity": "sha1-8vtjpl5JBbQGyGBydloaTceTufQ=", - "dev": true - }, - "is-number": { - "version": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz" - } - }, - "is-obj": { - "version": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true - }, - "is-object-like-x": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/is-object-like-x/-/is-object-like-x-1.6.0.tgz", - "integrity": "sha512-mc3dBMv1jEOdk0f1i2RkJFsZDux0MuHqGwHOoRo770ShUOf4VE6tWThAW8dAZARr9a5RN+iNX1yzMDA5ad1clQ==", - "dev": true, - "requires": { - "is-function-x": "3.3.0", - "is-primitive": "2.0.0" - }, - "dependencies": { - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - } - } - }, - "is-path-cwd": { - "version": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", - "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", - "dev": true - }, - "is-path-in-cwd": { - "version": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", - "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", - "dev": true, - "requires": { - "is-path-inside": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz" - } - }, - "is-path-inside": { - "version": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", - "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", - "dev": true, - "requires": { - "path-is-inside": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz" - } - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } - }, - "is-posix-bracket": { - "version": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, - "is-property": { - "version": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true - }, - "is-redirect": { - "version": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", - "integrity": "sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ=", - "dev": true - }, - "is-relative": { - "version": "https://registry.npmjs.org/is-relative/-/is-relative-0.2.1.tgz", - "integrity": "sha1-0n9MfVFtF1+2ENuEu+7yPDvJeqU=", - "dev": true, - "requires": { - "is-unc-path": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz" - } - }, - "is-retry-allowed": { - "version": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "integrity": "sha1-EaBgVotnM5REAz0BJaYaINVk+zQ=", - "dev": true - }, - "is-stream": { - "version": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, - "is-string": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.4.tgz", - "integrity": "sha1-zDqbaYV9Yh6WNyWiTK7shzuCbmQ=", - "dev": true - }, - "is-subset": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", - "integrity": "sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY=", - "dev": true - }, - "is-symbol": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", - "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", - "dev": true - }, - "is-text-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-text-path/-/is-text-path-1.0.1.tgz", - "integrity": "sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4=", - "dev": true, - "requires": { - "text-extensions": "1.7.0" - } - }, - "is-typedarray": { - "version": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "is-unc-path": { - "version": "https://registry.npmjs.org/is-unc-path/-/is-unc-path-0.1.2.tgz", - "integrity": "sha1-arBTpyVzwQJQ/0FqOBTDUXivObk=", - "dev": true, - "requires": { - "unc-path-regex": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz" - } - }, - "is-utf8": { - "version": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - }, - "is-windows": { - "version": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", - "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", - "dev": true - }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isbinaryfile": { - "version": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", - "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=", - "dev": true - }, - "isexe": { - "version": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz", - "integrity": "sha1-NvPiLmB1CSD15yQaR2qMakInWtA=", - "dev": true - }, - "isobject": { - "version": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz" - } - }, - "isstream": { - "version": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true - }, - "jade": { - "version": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", - "dev": true, - "requires": { - "commander": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz" - }, - "dependencies": { - "commander": { - "version": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", - "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", - "dev": true - }, - "mkdirp": { - "version": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", - "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=", - "dev": true - } - } - }, - "jasmine": { - "version": "2.99.0", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.99.0.tgz", - "integrity": "sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc=", - "dev": true, - "requires": { - "exit": "0.1.2", - "glob": "7.1.2", - "jasmine-core": "2.99.1" - }, - "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.11" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - } - } - }, - "jasmine-core": { - "version": "2.99.1", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.99.1.tgz", - "integrity": "sha1-5kAN8ea1bhMLYcS80JPap/boyhU=", - "dev": true - }, - "jsbn": { - "version": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true - }, - "json-schema": { - "version": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true - }, - "json-stable-stringify": { - "version": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "requires": { - "jsonify": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz" - } - }, - "json-stringify-safe": { - "version": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "json3": { - "version": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", - "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", - "dev": true - }, - "json5": { - "version": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", - "dev": true - }, - "jsonfile": { - "version": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz" - } - }, - "jsonify": { - "version": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "jsonparse": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", - "dev": true - }, - "jsonpointer": { - "version": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true - }, - "jsprim": { - "version": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", - "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "extsprintf": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", - "json-schema": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "verror": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz" - }, - "dependencies": { - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - } - } - }, - "jszip": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.4.tgz", - "integrity": "sha512-z6w8iYIxZ/fcgul0j/OerkYnkomH8BZigvzbxVmr2h5HkZUrPtk2kjYtLkqR9wwQxEP6ecKNoKLsbhd18jfnGA==", - "dev": true, - "requires": { - "core-js": "2.3.0", - "es6-promise": "3.0.2", - "lie": "3.1.1", - "pako": "1.0.6", - "readable-stream": "2.0.6" - }, - "dependencies": { - "core-js": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.3.0.tgz", - "integrity": "sha1-+rg/uwstjchfpjbEudNMdUIMbWU=", - "dev": true - }, - "es6-promise": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.0.2.tgz", - "integrity": "sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "1.0.0", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - } - } - } - }, - "karma": { - "version": "https://registry.npmjs.org/karma/-/karma-0.13.22.tgz", - "integrity": "sha1-B3ULG9Bj1+fnuRvNLmNU2PKqh0Q=", - "dev": true, - "requires": { - "batch": "https://registry.npmjs.org/batch/-/batch-0.5.3.tgz", - "bluebird": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "body-parser": "https://registry.npmjs.org/body-parser/-/body-parser-1.16.0.tgz", - "chokidar": "https://registry.npmjs.org/chokidar/-/chokidar-1.6.1.tgz", - "colors": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "connect": "https://registry.npmjs.org/connect/-/connect-3.5.0.tgz", - "core-js": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz", - "di": "https://registry.npmjs.org/di/-/di-0.0.1.tgz", - "dom-serialize": "https://registry.npmjs.org/dom-serialize/-/dom-serialize-2.2.1.tgz", - "expand-braces": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "http-proxy": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.16.2.tgz", - "isbinaryfile": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "log4js": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", - "mime": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", - "optimist": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", - "socket.io": "https://registry.npmjs.org/socket.io/-/socket.io-1.7.2.tgz", - "source-map": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "useragent": "https://registry.npmjs.org/useragent/-/useragent-2.1.12.tgz" - }, - "dependencies": { - "bluebird": { - "version": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=", - "dev": true - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "source-map": { - "version": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "dev": true - } - } - }, - "karma-chrome-launcher": { - "version": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-0.2.3.tgz", - "integrity": "sha1-TG1wDRY6nTTGGO/YeRi+SeekqMk=", - "dev": true, - "requires": { - "fs-access": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", - "which": "https://registry.npmjs.org/which/-/which-1.2.12.tgz" - } - }, - "karma-firefox-launcher": { - "version": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-0.1.7.tgz", - "integrity": "sha1-wF3YZTNpHmLzGVJZUJjovTV9OfM=", - "dev": true - }, - "karma-jasmine": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-1.1.1.tgz", - "integrity": "sha1-b+hA51oRYAydkehLM8RY4cRqNSk=", - "dev": true - }, - "karma-mocha": { - "version": "https://registry.npmjs.org/karma-mocha/-/karma-mocha-1.3.0.tgz", - "integrity": "sha1-7qrH/8DiAetjxGdEDStpx883eL8=", - "dev": true, - "requires": { - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz" - } - }, - "karma-phantomjs-launcher": { - "version": "https://registry.npmjs.org/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz", - "integrity": "sha1-0jyjSAG9qYY60xjju0vUBisTrNI=", - "dev": true, - "requires": { - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "phantomjs-prebuilt": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.14.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true - }, - "aws-sign2": { - "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true - }, - "caseless": { - "version": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "combined-stream": { - "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "dev": true, - "requires": { - "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" - } - }, - "commander": { - "version": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM=", - "dev": true - }, - "delayed-stream": { - "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "es6-promise": { - "version": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.0.5.tgz", - "integrity": "sha1-eILzCt3lskDM+n99eMVIMwlRrkI=", - "dev": true - }, - "form-data": { - "version": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "dev": true, - "requires": { - "asynckit": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" - } - }, - "har-validator": { - "version": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", - "dev": true, - "requires": { - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "commander": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "is-my-json-valid": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "hawk": { - "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" - } - }, - "http-signature": { - "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "jsprim": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "sshpk": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz" - } - }, - "oauth-sign": { - "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "dev": true - }, - "phantomjs-prebuilt": { - "version": "https://registry.npmjs.org/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.14.tgz", - "integrity": "sha1-1T0xH8+30dCN2yQBRVjxGIxRbaA=", - "dev": true, - "requires": { - "es6-promise": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.0.5.tgz", - "extract-zip": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.5.0.tgz", - "fs-extra": "https://registry.npmjs.org/fs-extra/-/fs-extra-1.0.0.tgz", - "hasha": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "kew": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "progress": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", - "request-progress": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "which": "https://registry.npmjs.org/which/-/which-1.2.12.tgz" - } - }, - "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", - "integrity": "sha1-51vV9uJoEioqDgvaYwslUMFmUCw=", - "dev": true - }, - "request": { - "version": "https://registry.npmjs.org/request/-/request-2.79.0.tgz", - "integrity": "sha1-Tf5b9r6LjNw3/Pk+BLZVd3InEN4=", - "dev": true, - "requires": { - "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "aws4": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "form-data": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "hawk": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "is-typedarray": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-6.3.2.tgz", - "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", - "uuid": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz" - } - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "uuid": { - "version": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", - "dev": true - } - } - }, - "karma-safari-launcher": { - "version": "https://registry.npmjs.org/karma-safari-launcher/-/karma-safari-launcher-0.1.1.tgz", - "integrity": "sha1-pjgKzKtgpYP91iT0G5o/EP30EAg=", - "dev": true - }, - "karma-sauce-launcher": { - "version": "https://registry.npmjs.org/karma-sauce-launcher/-/karma-sauce-launcher-0.2.14.tgz", - "integrity": "sha1-5C5BJRfF9AU0yLun0Uu08Qcntqc=", - "dev": true, - "requires": { - "q": "https://registry.npmjs.org/q/-/q-0.9.7.tgz", - "sauce-connect-launcher": "https://registry.npmjs.org/sauce-connect-launcher/-/sauce-connect-launcher-0.11.1.tgz", - "saucelabs": "https://registry.npmjs.org/saucelabs/-/saucelabs-0.1.1.tgz", - "wd": "https://registry.npmjs.org/wd/-/wd-0.3.12.tgz" - }, - "dependencies": { - "q": { - "version": "https://registry.npmjs.org/q/-/q-0.9.7.tgz", - "integrity": "sha1-TeLmyzspCIyeTLwDv51C+5bOL3U=", - "dev": true - } - } - }, - "karma-sourcemap-loader": { - "version": "https://registry.npmjs.org/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz", - "integrity": "sha1-kTIsd/jxPUb+0GKwQuEAnUxFBdg=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz" - } - }, - "kew": { - "version": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "integrity": "sha1-edk9LTM2PW/dKXCzNdkUGtWR15s=", - "dev": true - }, - "kind-of": { - "version": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz", - "integrity": "sha1-R11pil5J/15T0U4+cyQp3Iv0z0c=", - "dev": true, - "requires": { - "is-buffer": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.4.tgz" - } - }, - "klaw": { - "version": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz" - } - }, - "lazy-cache": { - "version": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true - }, - "lazystream": { - "version": "https://registry.npmjs.org/lazystream/-/lazystream-0.1.0.tgz", - "integrity": "sha1-GyXWPHcqTCDwpe0KnXf0hLbhaSA=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, - "lie": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", - "dev": true, - "requires": { - "immediate": "3.0.6" - } - }, - "liftoff": { - "version": "https://registry.npmjs.org/liftoff/-/liftoff-2.3.0.tgz", - "integrity": "sha1-qY8v9nGD2Lp8+soQVIvX/wVQs4U=", - "dev": true, - "requires": { - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "findup-sync": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", - "fined": "https://registry.npmjs.org/fined/-/fined-1.0.2.tgz", - "flagged-respawn": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.2.tgz", - "lodash.isplainobject": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "lodash.isstring": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "lodash.mapvalues": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", - "rechoir": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "resolve": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz" - } - }, - "load-json-file": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", - "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "parse-json": "2.2.0", - "pify": "2.3.0", - "pinkie-promise": "2.0.1", - "strip-bom": "2.0.0" - }, - "dependencies": { - "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", - "dev": true, - "requires": { - "is-arrayish": "0.2.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true - }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "requires": { - "error-ex": "1.3.1" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "2.0.4" - } - } - } - }, - "loader-utils": { - "version": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.16.tgz", - "integrity": "sha1-8IYyBm7YKCg13/iN+1JwR2Wt7m0=", - "dev": true, - "requires": { - "big.js": "https://registry.npmjs.org/big.js/-/big.js-3.1.3.tgz", - "emojis-list": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "json5": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz" - } - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "lodash._basecopy": { - "version": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", - "dev": true - }, - "lodash._getnative": { - "version": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._isiterateecall": { - "version": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "lodash.assignwith": { - "version": "https://registry.npmjs.org/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz", - "integrity": "sha1-EnqX8CrcQXUalU0ksN4X4QDgOOs=", - "dev": true - }, - "lodash.isarguments": { - "version": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, - "lodash.isarray": { - "version": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.isempty": { - "version": "https://registry.npmjs.org/lodash.isempty/-/lodash.isempty-4.4.0.tgz", - "integrity": "sha1-b4bL7di+TsmHvpqvM8loTbGzHn4=", - "dev": true - }, - "lodash.isnull": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz", - "integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4=", - "dev": true - }, - "lodash.isplainobject": { - "version": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=", - "dev": true - }, - "lodash.isstring": { - "version": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha1-1SfftUVuynzJu5XV2ur4i6VKVFE=", - "dev": true - }, - "lodash.keys": { - "version": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true, - "requires": { - "lodash._getnative": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "lodash.isarguments": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "lodash.isarray": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz" - } - }, - "lodash.mapvalues": { - "version": "https://registry.npmjs.org/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz", - "integrity": "sha1-G6+lAF3p3W9PJmaMMMo3IwzJaJw=", - "dev": true - }, - "lodash.pick": { - "version": "https://registry.npmjs.org/lodash.pick/-/lodash.pick-4.4.0.tgz", - "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", - "dev": true - }, - "lodash.template": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz", - "integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=", - "dev": true, - "requires": { - "lodash._reinterpolate": "3.0.0", - "lodash.templatesettings": "4.1.0" - }, - "dependencies": { - "lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", - "dev": true - } - } - }, - "lodash.templatesettings": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz", - "integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=", - "dev": true, - "requires": { - "lodash._reinterpolate": "3.0.0" - }, - "dependencies": { - "lodash._reinterpolate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz", - "integrity": "sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=", - "dev": true - } - } - }, - "log4js": { - "version": "https://registry.npmjs.org/log4js/-/log4js-0.6.38.tgz", - "integrity": "sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "semver": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - }, - "semver": { - "version": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", - "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", - "dev": true - } - } - }, - "lolex": { - "version": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", - "integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", - "dev": true - }, - "longest": { - "version": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true - }, - "loud-rejection": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", - "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", - "dev": true, - "requires": { - "currently-unhandled": "0.4.1", - "signal-exit": "3.0.2" - }, - "dependencies": { - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - } - } - }, - "lowercase-keys": { - "version": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", - "integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=", - "dev": true - }, - "lru-cache": { - "version": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", - "dev": true - }, - "make-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz", - "integrity": "sha1-l6ARdR6R3YfPre9Ygy67BJNt6Xg=", - "dev": true, - "requires": { - "pify": "2.3.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - } - } - }, - "map-cache": { - "version": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", - "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", - "dev": true - }, - "map-stream": { - "version": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", - "dev": true - }, - "math-clamp-x": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-clamp-x/-/math-clamp-x-1.1.0.tgz", - "integrity": "sha512-c7Hxz6Ji4HtwUSMI1HU3Y7pcWQyuINlnCeE1675ZfNbEELFHeqHnEQXrWB7kLiiNTMi6QM38txFAfKq2IYqZpQ==", - "dev": true, - "requires": { - "to-number-x": "1.2.0" - } - }, - "math-sign-x": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/math-sign-x/-/math-sign-x-2.1.0.tgz", - "integrity": "sha512-3shFG0Ea5vOMCgQCrylyzu3POQRTvvaclb4VArnICToTgshMfA4Dlb9q9lZO1SD/rUD9mOTJZ7dTtlfCq7I91A==", - "dev": true, - "requires": { - "is-nan-x": "1.0.1", - "to-number-x": "1.2.0" - } - }, - "max-safe-integer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/max-safe-integer/-/max-safe-integer-1.0.1.tgz", - "integrity": "sha1-84BgvixWPYwC5tSK85Ei/YO29BA=", - "dev": true - }, - "media-typer": { - "version": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true - }, - "memory-fs": { - "version": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz", - "integrity": "sha1-8rslNovBIeORwlIN6Slpyu4KApA=", - "dev": true - }, - "meow": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", - "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", - "dev": true, - "requires": { - "camelcase-keys": "2.1.0", - "decamelize": "1.2.0", - "loud-rejection": "1.6.0", - "map-obj": "1.0.1", - "minimist": "1.2.0", - "normalize-package-data": "2.4.0", - "object-assign": "4.1.1", - "read-pkg-up": "1.0.1", - "redent": "1.0.0", - "trim-newlines": "1.0.0" - }, - "dependencies": { - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - } - } - }, - "merge-stream": { - "version": "https://registry.npmjs.org/merge-stream/-/merge-stream-0.1.8.tgz", - "integrity": "sha1-SKB7O0oSHXSj7b/c20sIrb8CQLE=", - "dev": true, - "requires": { - "through2": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - }, - "through2": { - "version": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - } - } - }, - "micromatch": { - "version": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "array-unique": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "braces": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "expand-brackets": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "extglob": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "filename-regex": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.0.tgz", - "is-extglob": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "is-glob": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "kind-of": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz", - "normalize-path": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", - "object.omit": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "parse-glob": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "regex-cache": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz" - } - }, - "mime": { - "version": "https://registry.npmjs.org/mime/-/mime-1.3.4.tgz", - "integrity": "sha1-EV+eO2s9rylZmDyzjxSaLUDrXVM=", - "dev": true - }, - "mime-db": { - "version": "https://registry.npmjs.org/mime-db/-/mime-db-1.26.0.tgz", - "integrity": "sha1-6v/NDk/Gk1z4E02iRuLmw1MFrf8=", - "dev": true - }, - "mime-types": { - "version": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "integrity": "sha1-9+99l1g/yvO30oK2+LVnnaselO4=", - "dev": true, - "requires": { - "mime-db": "https://registry.npmjs.org/mime-db/-/mime-db-1.26.0.tgz" - } - }, - "minimatch": { - "version": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", - "integrity": "sha1-Kk5AkLlrLbBqnX3wEFWmKnfJt3Q=", - "dev": true, - "requires": { - "brace-expansion": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz" - } - }, - "minimist": { - "version": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - }, - "mkdirp": { - "version": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz" - }, - "dependencies": { - "minimist": { - "version": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, - "mocha": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", - "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", - "dev": true, - "requires": { - "browser-stdout": "1.3.0", - "commander": "2.9.0", - "debug": "2.6.8", - "diff": "3.2.0", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "glob": "7.1.1", - "growl": "1.9.2", - "he": "1.1.1", - "json3": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", - "lodash.create": "3.1.1", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "supports-color": "3.1.2" - }, - "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - }, - "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", - "dev": true - }, - "commander": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", - "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", - "dev": true, - "requires": { - "graceful-readlink": "1.0.1" - } - }, - "debug": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", - "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "diff": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", - "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", - "dev": true - }, - "glob": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", - "dev": true, - "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - } - }, - "graceful-readlink": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", - "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", - "dev": true - }, - "growl": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", - "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", - "dev": true - }, - "lodash._baseassign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", - "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", - "dev": true, - "requires": { - "lodash._basecopy": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "lodash.keys": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz" - } - }, - "lodash._basecreate": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", - "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", - "dev": true - }, - "lodash.create": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", - "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", - "dev": true, - "requires": { - "lodash._baseassign": "3.2.0", - "lodash._basecreate": "3.0.3", - "lodash._isiterateecall": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "supports-color": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", - "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", - "dev": true, - "requires": { - "has-flag": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz" - } - } - } - }, - "modify-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/modify-values/-/modify-values-1.0.0.tgz", - "integrity": "sha1-4rbN65zhn5kxelNyLz2/XfXqqrI=", - "dev": true - }, - "moment": { - "version": "https://registry.npmjs.org/moment/-/moment-2.17.1.tgz", - "integrity": "sha1-/tlQYGPzaxDwZsi1mhRNf66+HYI=", - "dev": true - }, - "ms": { - "version": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", - "dev": true - }, - "nan-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/nan-x/-/nan-x-1.0.0.tgz", - "integrity": "sha512-yw4Fhe2/UTzanQ4f0yHWkRnfTuHZFAi4GZDjXS4G+qv5BqXTqPJBbSxpa7MyyW9v4Y4ZySZQik1vcbNkhdnIOg==", - "dev": true - }, - "natives": { - "version": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz", - "integrity": "sha1-6f+EFBimsux6SV6TmYT3jxY+bjE=", - "dev": true - }, - "negotiator": { - "version": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", - "dev": true - }, - "node-int64": { - "version": "https://registry.npmjs.org/node-int64/-/node-int64-0.3.3.tgz", - "integrity": "sha1-LW5rLs5d6FiLQ9iNG8QbJs0fqE0=", - "dev": true - }, - "node-uuid": { - "version": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.7.tgz", - "integrity": "sha1-baWhdmjEs91ZYjvaEc9/pMH2Cm8=", - "dev": true - }, - "node-version-compare": { - "version": "https://registry.npmjs.org/node-version-compare/-/node-version-compare-1.0.1.tgz", - "integrity": "sha1-2Fv9IPCsreM1d/VmgscQnDTFUM0=", - "dev": true - }, - "nodejs-websocket": { - "version": "https://registry.npmjs.org/nodejs-websocket/-/nodejs-websocket-1.7.1.tgz", - "integrity": "sha1-zM+7qCO/HPqWgPFoq3q1MSHkhBA=", - "dev": true - }, - "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", - "dev": true, - "requires": { - "hosted-git-info": "2.5.0", - "is-builtin-module": "1.0.0", - "semver": "5.5.0", - "validate-npm-package-license": "3.0.1" - }, - "dependencies": { - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true - } - } - }, - "normalize-path": { - "version": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.0.1.tgz", - "integrity": "sha1-R4hqwWYnYNQmG32XnSQXCdPOP3o=", - "dev": true - }, - "normalize-space-x": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/normalize-space-x/-/normalize-space-x-2.0.0.tgz", - "integrity": "sha512-R3nAbBlbEtn649TVgKzhgALTjilK5bgsbIsbk7+dtiDcEpuVVr7cUezwO7Tnm5e3IgaULi2s+FfVGj9WzVq1WA==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "trim-x": "2.0.2", - "white-space-x": "2.0.3" - } - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "2.0.1" - } - }, - "null-check": { - "version": "https://registry.npmjs.org/null-check/-/null-check-1.0.0.tgz", - "integrity": "sha1-l33/1xdgErnsMNKjnbXPcqBDnt0=", - "dev": true - }, - "number-is-nan": { - "version": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "oauth-sign": { - "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.6.0.tgz", - "integrity": "sha1-fb6uRPbKRU4fFoRR1jB0ZzWBPOM=", - "dev": true - }, - "object-assign": { - "version": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "object-component": { - "version": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", - "integrity": "sha1-8MaapQ78lbhmwYb0AKM3acsvEpE=", - "dev": true - }, - "object-get-own-property-descriptor-x": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/object-get-own-property-descriptor-x/-/object-get-own-property-descriptor-x-3.2.0.tgz", - "integrity": "sha512-Z/0fIrptD9YuzN+SNK/1kxAEaBcPQM4gSrtOSMSi9eplnL/AbyQcAyAlreAoAzmBon+DQ1Z+AdhxyQSvav5Fyg==", - "dev": true, - "requires": { - "attempt-x": "1.1.1", - "has-own-property-x": "3.1.1", - "has-symbol-support-x": "1.4.1", - "is-falsey-x": "1.0.1", - "is-index-x": "1.0.0", - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "is-string": "1.0.4", - "property-is-enumerable-x": "1.1.0", - "to-object-x": "1.5.0", - "to-property-key-x": "2.0.2" - }, - "dependencies": { - "has-symbol-support-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", - "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", - "dev": true - } - } - }, - "object.omit": { - "version": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "https://registry.npmjs.org/for-own/-/for-own-0.1.4.tgz", - "is-extendable": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz" - } - }, - "on-finished": { - "version": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, - "requires": { - "ee-first": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" - } - }, - "once": { - "version": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "optimist": { - "version": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "dev": true, - "requires": { - "minimist": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "wordwrap": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" - }, - "dependencies": { - "minimist": { - "version": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", - "dev": true - } - } - }, - "options": { - "version": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", - "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=", - "dev": true - }, - "orchestrator": { - "version": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz", - "integrity": "sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4=", - "dev": true, - "requires": { - "end-of-stream": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz", - "sequencify": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", - "stream-consume": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz" - } - }, - "ordered-read-streams": { - "version": "https://registry.npmjs.org/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz", - "integrity": "sha1-/VZamvjrRHO6abbtijQ1LLVS8SY=", - "dev": true - }, - "os-homedir": { - "version": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true - }, - "os-tmpdir": { - "version": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", - "dev": true - }, - "parse-filepath": { - "version": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.1.tgz", - "integrity": "sha1-FZ1hVdQ5BNFsEO9piRHaHpGWm3M=", - "dev": true, - "requires": { - "is-absolute": "https://registry.npmjs.org/is-absolute/-/is-absolute-0.2.6.tgz", - "map-cache": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "path-root": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz" - } - }, - "parse-github-repo-url": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz", - "integrity": "sha1-nn2LslKmy2ukJZUGC3v23z28H1A=", - "dev": true - }, - "parse-glob": { - "version": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "is-dotfile": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.2.tgz", - "is-extglob": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "is-glob": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz" - } - }, - "parse-int-x": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/parse-int-x/-/parse-int-x-1.1.0.tgz", - "integrity": "sha512-gEo/Rb66RiK7Ba89Va5JWYrfF2TdIblmawQuJEs4XxHIsTE0wi1ME5M/O21L8JJ9NjOlA+CqHCbkZjHRZnQPrg==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "to-string-x": "1.4.2", - "trim-x": "2.0.2", - "white-space-x": "2.0.3" - } - }, - "parse-passwd": { - "version": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", - "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", - "dev": true - }, - "parsejson": { - "version": "https://registry.npmjs.org/parsejson/-/parsejson-0.0.3.tgz", - "integrity": "sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs=", - "dev": true, - "requires": { - "better-assert": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz" - } - }, - "parseqs": { - "version": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", - "integrity": "sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0=", - "dev": true, - "requires": { - "better-assert": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz" - } - }, - "parseuri": { - "version": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", - "integrity": "sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo=", - "dev": true, - "requires": { - "better-assert": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz" - } - }, - "parseurl": { - "version": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.1.tgz", - "integrity": "sha1-yKuMkiO6NIiKpkopeyiFO+wY2lY=", - "dev": true - }, - "path-exists": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", - "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", - "dev": true, - "requires": { - "pinkie-promise": "2.0.1" - }, - "dependencies": { - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "2.0.4" - } - } - } - }, - "path-is-absolute": { - "version": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-is-inside": { - "version": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", - "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", - "dev": true - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, - "path-root": { - "version": "https://registry.npmjs.org/path-root/-/path-root-0.1.1.tgz", - "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", - "dev": true, - "requires": { - "path-root-regex": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz" - } - }, - "path-root-regex": { - "version": "https://registry.npmjs.org/path-root-regex/-/path-root-regex-0.1.2.tgz", - "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=", - "dev": true - }, - "path-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", - "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "pify": "2.3.0", - "pinkie-promise": "2.0.1" - }, - "dependencies": { - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "2.0.4" - } - } - } - }, - "pend": { - "version": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", - "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", - "dev": true - }, - "performance-now": { - "version": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", - "dev": true - }, - "phantomjs": { - "version": "https://registry.npmjs.org/phantomjs/-/phantomjs-2.1.7.tgz", - "integrity": "sha1-xpEPZ5NcNyhbYRQyn8LyfV8+MTQ=", - "dev": true, - "requires": { - "extract-zip": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.5.0.tgz", - "fs-extra": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", - "hasha": "https://registry.npmjs.org/hasha/-/hasha-2.2.0.tgz", - "kew": "https://registry.npmjs.org/kew/-/kew-0.7.0.tgz", - "progress": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.67.0.tgz", - "request-progress": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "which": "https://registry.npmjs.org/which/-/which-1.2.12.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true - }, - "async": { - "version": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "integrity": "sha512-e+lJAJeNWuPCNyxZKOBdaJGyLGHugXVQtrAwtuAe2vhxTYxFTKE73p8JuTmdH0qdQZtDvI4dhJwjZc5zsfIsYw==", - "dev": true, - "requires": { - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz" - } - }, - "aws-sign2": { - "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true - }, - "bl": { - "version": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz", - "integrity": "sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz" - } - }, - "caseless": { - "version": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "combined-stream": { - "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "dev": true, - "requires": { - "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" - } - }, - "commander": { - "version": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", - "dev": true - }, - "delayed-stream": { - "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "form-data": { - "version": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", - "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", - "dev": true, - "requires": { - "async": "https://registry.npmjs.org/async/-/async-2.5.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" - } - }, - "fs-extra": { - "version": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz", - "integrity": "sha1-muH92UiXeY7at20JGM9C0MMYT6k=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "jsonfile": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "klaw": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz" - } - }, - "har-validator": { - "version": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", - "dev": true, - "requires": { - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "commander": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "is-my-json-valid": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz", - "pinkie-promise": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "hawk": { - "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" - } - }, - "http-signature": { - "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "jsprim": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "sshpk": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz" - } - }, - "oauth-sign": { - "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "dev": true - }, - "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-5.2.1.tgz", - "integrity": "sha1-gB/uAw4LlFDWOFrcSKTMVbRK7fw=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - } - }, - "request": { - "version": "https://registry.npmjs.org/request/-/request-2.67.0.tgz", - "integrity": "sha1-ivdHgOK/EeoK6aqWXBHxGv0nJ0I=", - "dev": true, - "requires": { - "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "bl": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz", - "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "form-data": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", - "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "hawk": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "is-typedarray": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "node-uuid": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.7.tgz", - "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-5.2.1.tgz", - "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", - "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz" - } - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "tough-cookie": { - "version": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", - "integrity": "sha1-yDoYMPTl7wuT7yo0iOck+N4Basc=", - "dev": true - } - } - }, - "pify": { - "version": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz" - } - }, - "plugin-error": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", - "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", - "dev": true, - "requires": { - "ansi-colors": "1.0.1", - "arr-diff": "4.0.0", - "arr-union": "3.1.0", - "extend-shallow": "3.0.2" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - } - } - }, - "prepend-http": { - "version": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true - }, - "preserve": { - "version": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, - "pretty-hrtime": { - "version": "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", - "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=", - "dev": true - }, - "process-nextick-args": { - "version": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "progress": { - "version": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", - "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", - "dev": true - }, - "promises-aplus-tests": { - "version": "https://registry.npmjs.org/promises-aplus-tests/-/promises-aplus-tests-2.1.2.tgz", - "integrity": "sha1-drfFY4locghhlpz7zYeVr9J0iFw=", - "dev": true, - "requires": { - "mocha": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", - "sinon": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", - "underscore": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz" - }, - "dependencies": { - "commander": { - "version": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", - "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=", - "dev": true - }, - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - } - }, - "diff": { - "version": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", - "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", - "dev": true - }, - "escape-string-regexp": { - "version": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", - "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=", - "dev": true - }, - "glob": { - "version": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz" - } - }, - "minimatch": { - "version": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", - "dev": true, - "requires": { - "lru-cache": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", - "sigmund": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz" - } - }, - "mocha": { - "version": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", - "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", - "dev": true, - "requires": { - "commander": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "diff": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "growl": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", - "jade": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", - "to-iso-string": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz" - } - }, - "ms": { - "version": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", - "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=", - "dev": true - } - } - }, - "property-is-enumerable-x": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/property-is-enumerable-x/-/property-is-enumerable-x-1.1.0.tgz", - "integrity": "sha512-22cKy3w3OpRswU6to9iKWDDlg+F9vF2REcwGlGW23jyLjHb1U/jJEWA44sWupOnkhGfDgotU6Lw+N2oyhNi+5A==", - "dev": true, - "requires": { - "to-object-x": "1.5.0", - "to-property-key-x": "2.0.2" - } - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true - }, - "pump": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/pump/-/pump-1.0.3.tgz", - "integrity": "sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw==", - "dev": true, - "requires": { - "end-of-stream": "1.4.1", - "once": "1.4.0" - }, - "dependencies": { - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "dev": true, - "requires": { - "once": "1.4.0" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - } - } - }, - "punycode": { - "version": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - }, - "q": { - "version": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "integrity": "sha1-VXBbzZPF82c1MMLCy8DCs63cKG4=", - "dev": true - }, - "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-6.2.1.tgz", - "integrity": "sha1-zgPF/wk1vB2daanxTL0Y5WjWdiU=", - "dev": true - }, - "randomatic": { - "version": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.6.tgz", - "integrity": "sha1-EQ3Kv/OX6dz/fAeJzMCkmt8exbs=", - "dev": true, - "requires": { - "is-number": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "kind-of": "https://registry.npmjs.org/kind-of/-/kind-of-3.1.0.tgz" - } - }, - "raw-body": { - "version": "https://registry.npmjs.org/raw-body/-/raw-body-2.2.0.tgz", - "integrity": "sha1-mUl2z2pQlqQRYoQEkvC9xdbn+5Y=", - "dev": true, - "requires": { - "bytes": "https://registry.npmjs.org/bytes/-/bytes-2.4.0.tgz", - "iconv-lite": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", - "unpipe": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz" - } - }, - "rc": { - "version": "https://registry.npmjs.org/rc/-/rc-1.1.6.tgz", - "integrity": "sha1-Q2UbdrauU7XIAvEVH6P8OwWZack=", - "dev": true, - "requires": { - "deep-extend": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.1.tgz", - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "strip-json-comments": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz" - } - }, - "read-pkg": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", - "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", - "dev": true, - "requires": { - "load-json-file": "1.1.0", - "normalize-package-data": "2.4.0", - "path-type": "1.1.0" - } - }, - "read-pkg-up": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", - "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", - "dev": true, - "requires": { - "find-up": "1.1.2", - "read-pkg": "1.1.0" - } - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", - "integrity": "sha1-qeb+w8fdqF+LsbO6cChgRVb8gl4=", - "dev": true, - "requires": { - "buffer-shims": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "process-nextick-args": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "util-deprecate": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz" - } - }, - "readdirp": { - "version": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", - "dev": true, - "requires": { - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "minimatch": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", - "set-immediate-shim": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz" - } - }, - "rechoir": { - "version": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz" - } - }, - "redent": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", - "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", - "dev": true, - "requires": { - "indent-string": "2.1.0", - "strip-indent": "1.0.1" - } - }, - "regex-cache": { - "version": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", - "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", - "dev": true, - "requires": { - "is-equal-shallow": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz" - } - }, - "registry-url": { - "version": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", - "integrity": "sha1-PU74cPc93h138M+aOBQyRE4XSUI=", - "dev": true, - "requires": { - "rc": "https://registry.npmjs.org/rc/-/rc-1.1.6.tgz" - } - }, - "remove-trailing-separator": { - "version": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz", - "integrity": "sha1-YV67lq9VlVLUv0BXyENtSGq2PMQ=", - "dev": true - }, - "repeat-element": { - "version": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true - }, - "repeat-string": { - "version": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "replace-comments-x": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/replace-comments-x/-/replace-comments-x-2.0.0.tgz", - "integrity": "sha512-+vMP4jqU+8HboLWms6YMNEiaZG5hh1oR6ENCnGYDF/UQ7aYiJUK/8tcl3+KZAHRCKKa3gqzrfiarlUBHQSgRlg==", - "dev": true, - "requires": { - "require-coercible-to-string-x": "1.0.0", - "to-string-x": "1.4.2" - } - }, - "request": { - "version": "https://registry.npmjs.org/request/-/request-2.55.0.tgz", - "integrity": "sha1-11wc32eddrsQD5v/4f5VG1wk6T0=", - "dev": true, - "requires": { - "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz", - "bl": "https://registry.npmjs.org/bl/-/bl-0.9.5.tgz", - "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.9.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", - "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "form-data": "https://registry.npmjs.org/form-data/-/form-data-0.2.0.tgz", - "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-1.8.0.tgz", - "hawk": "https://registry.npmjs.org/hawk/-/hawk-2.3.1.tgz", - "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.1.tgz", - "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.14.tgz", - "node-uuid": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.7.tgz", - "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.6.0.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-2.4.2.tgz", - "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz" - }, - "dependencies": { - "mime-db": { - "version": "https://registry.npmjs.org/mime-db/-/mime-db-1.12.0.tgz", - "integrity": "sha1-PQxjGA9FjrENMlqqN9fFiuMS6dc=", - "dev": true - }, - "mime-types": { - "version": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.14.tgz", - "integrity": "sha1-MQ4VnbI+B3+Lsit0jav6SVcUCqY=", - "dev": true, - "requires": { - "mime-db": "https://registry.npmjs.org/mime-db/-/mime-db-1.12.0.tgz" - } - }, - "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-2.4.2.tgz", - "integrity": "sha1-9854jld33wtQENp/fE5zujJHD1o=", - "dev": true - } - } - }, - "request-progress": { - "version": "https://registry.npmjs.org/request-progress/-/request-progress-2.0.1.tgz", - "integrity": "sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg=", - "dev": true, - "requires": { - "throttleit": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz" - } - }, - "require-coercible-to-string-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/require-coercible-to-string-x/-/require-coercible-to-string-x-1.0.0.tgz", - "integrity": "sha512-Rpfd4sMdflPAKecdKhfAtQHlZzzle4UMUgxJ01hXtTcNWMV8w9GeZnKhEyrT73kgrflBOP1zg41amUPZGcNspA==", - "dev": true, - "requires": { - "require-object-coercible-x": "1.4.1", - "to-string-x": "1.4.2" - } - }, - "require-object-coercible-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/require-object-coercible-x/-/require-object-coercible-x-1.4.1.tgz", - "integrity": "sha512-0YHa2afepsLfQvwQ1P2XvDZnGOUia5sC07ZijIRU2dnsRxnuilXWF6B2CFaKGDA9eZl39lJHrXCDsnfgroRd6Q==", - "dev": true, - "requires": { - "is-nil-x": "1.4.1" - } - }, - "requires-port": { - "version": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", - "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", - "dev": true - }, - "resolve": { - "version": "https://registry.npmjs.org/resolve/-/resolve-1.2.0.tgz", - "integrity": "sha1-lYnD8vYUnRQXpAvswWY9tuxrwmw=", - "dev": true - }, - "resolve-dir": { - "version": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", - "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", - "dev": true, - "requires": { - "expand-tilde": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", - "global-modules": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz" - } - }, - "right-align": { - "version": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", - "dev": true, - "requires": { - "align-text": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz" - } - }, - "rimraf": { - "version": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", - "integrity": "sha1-loAAk8vxoMhr2VtGJUZ1NcKd+gQ=", - "dev": true, - "requires": { - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz" - } - }, - "rollup": { - "version": "0.54.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.54.1.tgz", - "integrity": "sha512-ebUUgUQ7K/sLn67CtO8Jj8H3RgKAoVWrpiJA7enOkwZPZzTCl8GC8CZ00g5jowjX80KgBmzs4Z1MV6cgglT86A==", - "dev": true - }, - "rollup-plugin-hypothetical": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-hypothetical/-/rollup-plugin-hypothetical-2.1.0.tgz", - "integrity": "sha512-MlxPQTkMtiRUtyhIJ7FpBvTzWtar8eFBA+V7/J6Deg9fSgIIHwL6bJKK1Wl1uWSWtOrWhOmtsMwb9F6aagP/Pg==", - "dev": true - }, - "rx": { - "version": "https://registry.npmjs.org/rx/-/rx-2.3.24.tgz", - "integrity": "sha1-FPlQpCF9fjXapxu8vljv9o6ksrc=", - "dev": true - }, - "rx-lite": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", - "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", - "dev": true - }, - "rx-lite-aggregates": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz", - "integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=", - "dev": true, - "requires": { - "rx-lite": "4.0.8" - } - }, - "rxjs": { - "version": "5.5.6", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz", - "integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==", - "dev": true, - "requires": { - "symbol-observable": "1.0.1" - } - }, - "safe-buffer": { - "version": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "safe-to-string-x": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/safe-to-string-x/-/safe-to-string-x-2.0.3.tgz", - "integrity": "sha512-hbxWZc0a+3VG7SpSKpZbBiXwQOV/bW/hwNvMFRPCL/60Ze/6Y8atHqv/0dWiWc9sHmkFqVCMR5gjmukMzKnA6A==", - "dev": true, - "requires": { - "to-string-symbols-supported-x": "1.0.0" - } - }, - "samsam": { - "version": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", - "integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc=", - "dev": true - }, - "sauce-connect-launcher": { - "version": "https://registry.npmjs.org/sauce-connect-launcher/-/sauce-connect-launcher-0.11.1.tgz", - "integrity": "sha1-ZfUdiJEkn9q6rxdZlzTeGQJHYSk=", - "dev": true, - "requires": { - "adm-zip": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", - "async": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.5.0.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-0.9.0.tgz", - "integrity": "sha1-rDYTsdqb7RtHUQu0ZRuJMeRxRsc=", - "dev": true - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-3.5.0.tgz", - "integrity": "sha1-Gbs/TVEnjwuMgY7RRcdOz5/kDm0=", - "dev": true - }, - "rimraf": { - "version": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz", - "integrity": "sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w=", - "dev": true - } - } - }, - "saucelabs": { - "version": "https://registry.npmjs.org/saucelabs/-/saucelabs-0.1.1.tgz", - "integrity": "sha1-Xg6hzz1zXW6hX96Utb2mvBXSwG0=", - "dev": true - }, - "sax": { - "version": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true - }, - "selenium-webdriver": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-3.6.0.tgz", - "integrity": "sha512-WH7Aldse+2P5bbFBO4Gle/nuQOdVwpHMTL6raL3uuBj/vPG07k6uzt3aiahu352ONBr5xXh0hDlM3LhtXPOC4Q==", - "dev": true, - "requires": { - "jszip": "3.1.4", - "rimraf": "2.6.2", - "tmp": "0.0.30", - "xml2js": "0.4.19" - }, - "dependencies": { - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", - "dev": true - }, - "tmp": { - "version": "0.0.30", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.30.tgz", - "integrity": "sha1-ckGdSovn1s51FI/YsyTlk6cRwu0=", - "dev": true, - "requires": { - "os-tmpdir": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" - } - }, - "xml2js": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", - "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", - "dev": true, - "requires": { - "sax": "1.2.4", - "xmlbuilder": "9.0.4" - } - }, - "xmlbuilder": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.4.tgz", - "integrity": "sha1-UZy0ymhtAFqEINNJbz8MruzKWA8=", - "dev": true - } - } - }, - "semver": { - "version": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", - "dev": true - }, - "semver-diff": { - "version": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", - "integrity": "sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY=", - "dev": true, - "requires": { - "semver": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz" - } - }, - "sequencify": { - "version": "https://registry.npmjs.org/sequencify/-/sequencify-0.0.7.tgz", - "integrity": "sha1-kM/xnQLgcCf9dn9erT57ldHnOAw=", - "dev": true - }, - "set-immediate-shim": { - "version": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, - "setprototypeof": { - "version": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.2.tgz", - "integrity": "sha1-gaVSFB7BBLiOic44MQOtXGZWTQg=", - "dev": true - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "sigmund": { - "version": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true - }, - "sinon": { - "version": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", - "integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", - "dev": true, - "requires": { - "formatio": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz", - "lolex": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", - "samsam": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", - "util": "https://registry.npmjs.org/util/-/util-0.10.3.tgz" - } - }, - "sntp": { - "version": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "dev": true, - "requires": { - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz" - } - }, - "socket.io": { - "version": "https://registry.npmjs.org/socket.io/-/socket.io-1.7.2.tgz", - "integrity": "sha1-g7u98ueSY7N4kA2kA+eEPgXcO3E=", - "dev": true, - "requires": { - "debug": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "engine.io": "https://registry.npmjs.org/engine.io/-/engine.io-1.8.2.tgz", - "has-binary": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "socket.io-adapter": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz", - "socket.io-client": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-1.7.2.tgz", - "socket.io-parser": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz" - }, - "dependencies": { - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - } - }, - "object-assign": { - "version": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=", - "dev": true - } - } - }, - "socket.io-adapter": { - "version": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz", - "integrity": "sha1-y21LuL7IHhB4uZZ3+c7QBGBmu4s=", - "dev": true, - "requires": { - "debug": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "socket.io-parser": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz" - }, - "dependencies": { - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - } - } - } - }, - "socket.io-client": { - "version": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-1.7.2.tgz", - "integrity": "sha1-Of2ww91FDjIbfkDP2DYS7FM91kQ=", - "dev": true, - "requires": { - "backo2": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", - "component-bind": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz", - "component-emitter": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "engine.io-client": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-1.8.2.tgz", - "has-binary": "https://registry.npmjs.org/has-binary/-/has-binary-0.1.7.tgz", - "indexof": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "object-component": "https://registry.npmjs.org/object-component/-/object-component-0.0.3.tgz", - "parseuri": "https://registry.npmjs.org/parseuri/-/parseuri-0.0.5.tgz", - "socket.io-parser": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz", - "to-array": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz" - }, - "dependencies": { - "component-emitter": { - "version": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", - "dev": true - }, - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.3.3.tgz", - "integrity": "sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz" - } - } - } - }, - "socket.io-parser": { - "version": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-2.3.1.tgz", - "integrity": "sha1-3VMgJRA85Clpcya+/WQAX8/ltKA=", - "dev": true, - "requires": { - "component-emitter": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.1.2.tgz", - "debug": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "json3": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz" - }, - "dependencies": { - "debug": { - "version": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - } - }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "ms": { - "version": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", - "dev": true - } - } - }, - "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", - "dev": true, - "requires": { - "amdefine": "1.0.1" - }, - "dependencies": { - "amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true - } - } - }, - "spdx-correct": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", - "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", - "dev": true, - "requires": { - "spdx-license-ids": "1.2.2" - } - }, - "spdx-expression-parse": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", - "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", - "dev": true - }, - "spdx-license-ids": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", - "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", - "dev": true - }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2.3.8" - }, - "dependencies": { - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - } - } - }, - "split2": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/split2/-/split2-2.2.0.tgz", - "integrity": "sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw==", - "dev": true, - "requires": { - "through2": "2.0.3" - }, - "dependencies": { - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - } - } - }, - "sshpk": { - "version": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", - "dev": true, - "requires": { - "asn1": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "bcrypt-pbkdf": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "dashdash": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "ecc-jsbn": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "getpass": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "jsbn": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "tweetnacl": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz" - }, - "dependencies": { - "asn1": { - "version": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", - "dev": true - }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - } - } - }, - "statuses": { - "version": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true - }, - "stream-consume": { - "version": "https://registry.npmjs.org/stream-consume/-/stream-consume-0.1.0.tgz", - "integrity": "sha1-pB6tGm1ggc63n2WwYZAbbY89HQ8=", - "dev": true - }, - "stream-shift": { - "version": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", - "dev": true - }, - "string-width": { - "version": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "is-fullwidth-code-point": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - } - } - }, - "string_decoder": { - "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "stringstream": { - "version": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", - "dev": true - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz" - } - }, - "strip-bom": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", - "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", - "dev": true, - "requires": { - "is-utf8": "0.2.1" - }, - "dependencies": { - "is-utf8": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", - "dev": true - } - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, - "strip-indent": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", - "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", - "dev": true, - "requires": { - "get-stdin": "4.0.1" - } - }, - "strip-json-comments": { - "version": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", - "dev": true - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", - "dev": true - }, - "symbol-observable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", - "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=", - "dev": true - }, - "systemjs": { - "version": "0.19.47", - "resolved": "https://registry.npmjs.org/systemjs/-/systemjs-0.19.47.tgz", - "integrity": "sha1-yMk5NxgPP1SBx2nNJyB2P7SjHG8=", - "dev": true, - "requires": { - "when": "3.7.8" - }, - "dependencies": { - "when": { - "version": "3.7.8", - "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", - "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=", - "dev": true - } - } - }, - "tapable": { - "version": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz", - "integrity": "sha1-KcNXB8K3DlDQdIK10gLo7URtr9Q=", - "dev": true - }, - "tar-stream": { - "version": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.1.5.tgz", - "integrity": "sha1-vpIYwTDCACnhB7D5Z/sj3gV50Tw=", - "dev": true, - "requires": { - "bl": "https://registry.npmjs.org/bl/-/bl-0.9.5.tgz", - "end-of-stream": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.1.0.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - }, - "dependencies": { - "end-of-stream": { - "version": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.1.0.tgz", - "integrity": "sha1-6TUyWLqpEIll78QcsO+K3i88+wc=", - "dev": true, - "requires": { - "once": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" - } - }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "once": { - "version": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", - "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - }, - "temp": { - "version": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", - "integrity": "sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k=", - "dev": true, - "requires": { - "os-tmpdir": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz" - }, - "dependencies": { - "rimraf": { - "version": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", - "dev": true - } - } - }, - "term-size": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/term-size/-/term-size-1.2.0.tgz", - "integrity": "sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk=", - "dev": true, - "requires": { - "execa": "0.7.0" - } - }, - "text-extensions": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/text-extensions/-/text-extensions-1.7.0.tgz", - "integrity": "sha512-AKXZeDq230UaSzaO5s3qQUZOaC7iKbzq0jOFL614R7d9R593HLqAOL0cYoqLdkNrjBSOdmoQI06yigq1TSBXAg==", - "dev": true - }, - "throttleit": { - "version": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz", - "integrity": "sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw=", - "dev": true - }, - "through": { - "version": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "through2": { - "version": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.2.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - }, - "through2-filter": { - "version": "https://registry.npmjs.org/through2-filter/-/through2-filter-2.0.0.tgz", - "integrity": "sha1-YLxVoNrLdghdsfna6Zq0P4PWIuw=", - "dev": true, - "requires": { - "through2": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - }, - "tildify": { - "version": "https://registry.npmjs.org/tildify/-/tildify-1.2.0.tgz", - "integrity": "sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo=", - "dev": true, - "requires": { - "os-homedir": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz" - } - }, - "time-stamp": { - "version": "https://registry.npmjs.org/time-stamp/-/time-stamp-1.0.1.tgz", - "integrity": "sha1-n0vSNVnJNllm8zAtu6KwfGuZsVE=", - "dev": true - }, - "tmp": { - "version": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", - "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", - "dev": true, - "requires": { - "os-tmpdir": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" - } - }, - "to-array": { - "version": "https://registry.npmjs.org/to-array/-/to-array-0.1.4.tgz", - "integrity": "sha1-F+bBH3PdTz10zaek/zI46a2b+JA=", - "dev": true - }, - "to-boolean-x": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/to-boolean-x/-/to-boolean-x-1.0.1.tgz", - "integrity": "sha512-PstxY3K6hVEHnY3FITs8XBoJbt0RI1e4MLIhAL9hWa3BtVLCrb86vU5z6lEKh7uZZjiPiLqIKMmfMro1nNgtXQ==", - "dev": true - }, - "to-integer-x": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/to-integer-x/-/to-integer-x-2.1.0.tgz", - "integrity": "sha512-M9iETTi+xMMZtUC70q4VE63XL2mXmNABxwxsIebOfd8K4ZHKCJLD9GyE6RlEPnbOPZj21QinuoVkqWsBsBknRA==", - "dev": true, - "requires": { - "is-finite-x": "3.0.2", - "is-nan-x": "1.0.1", - "math-sign-x": "2.1.0", - "to-number-x": "1.2.0" - } - }, - "to-iso-string": { - "version": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", - "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=", - "dev": true - }, - "to-number-x": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/to-number-x/-/to-number-x-1.2.0.tgz", - "integrity": "sha512-Pv/VvC0nLIqtEK1FRtmfWCSWE1gliXt0YSjFcjSIy8YMGyIovbUfX2HIgn/KXqtgB7NlqWWKIaj3mFukzPf0ig==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "nan-x": "1.0.0", - "parse-int-x": "1.1.0", - "to-primitive-x": "1.1.0", - "trim-x": "2.0.2" - } - }, - "to-object-x": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/to-object-x/-/to-object-x-1.5.0.tgz", - "integrity": "sha512-AKn5GQcdWky+s20vjWkt+Wa6y3dxQH3yQyMBhOfBOPldUwqwhgvlqcIg5H092ntNc+TX8/Cxzs1kMHH19pyCnA==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "require-object-coercible-x": "1.4.1" - } - }, - "to-primitive-x": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/to-primitive-x/-/to-primitive-x-1.1.0.tgz", - "integrity": "sha512-gyMY0gi3wjK3e4MUBKqv9Zl8QGcWguIkaUr2VJmoBEsOpDcpDZSEyljR773eVG4maS48uX7muLkoQoh/BA82OQ==", - "dev": true, - "requires": { - "has-symbol-support-x": "1.4.1", - "is-date-object": "1.0.1", - "is-function-x": "3.2.0", - "is-nil-x": "1.4.1", - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "is-symbol": "1.0.1", - "require-object-coercible-x": "1.4.1", - "validate.io-undefined": "1.0.3" - }, - "dependencies": { - "has-symbol-support-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", - "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", - "dev": true - }, - "has-to-string-tag-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz", - "integrity": "sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw==", - "dev": true, - "requires": { - "has-symbol-support-x": "1.4.1" - } - }, - "is-function-x": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/is-function-x/-/is-function-x-3.2.0.tgz", - "integrity": "sha512-ANQAythCIUKu0UprLZubZsYwAhYcNoM/FlrQSyFIXDoBzeGcHo6SHNPHCAl/T7UQyNiGzBirfUq0znic8P/Bew==", - "dev": true, - "requires": { - "attempt-x": "1.1.1", - "has-to-string-tag-x": "1.4.1", - "is-falsey-x": "1.0.1", - "is-primitive": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "normalize-space-x": "2.0.0", - "replace-comments-x": "2.0.0", - "to-boolean-x": "1.0.1", - "to-string-tag-x": "1.4.2" - } - }, - "lodash.isnull": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/lodash.isnull/-/lodash.isnull-3.0.0.tgz", - "integrity": "sha1-+vvlnqHcon7teGU0A53YTC4HxW4=", - "dev": true - }, - "to-string-tag-x": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/to-string-tag-x/-/to-string-tag-x-1.4.2.tgz", - "integrity": "sha512-ytO9eLigxsQQLGuab0C1iSSTzKdJNVSlBg0Spg4J/rGAVrQJ5y774mo0SSzgGeTT4RJGGyJNfObXaTMzX0XDOQ==", - "dev": true, - "requires": { - "lodash.isnull": "3.0.0", - "validate.io-undefined": "1.0.3" - } - }, - "validate.io-undefined": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz", - "integrity": "sha1-fif8uzFbhB54JDQxiXZxkp4gt/Q=", - "dev": true - } - } - }, - "to-property-key-x": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/to-property-key-x/-/to-property-key-x-2.0.2.tgz", - "integrity": "sha512-YISLpZFYIazNm0P8hLsKEEUEZ3m8U3+eDysJZqTu3+B9tQp+2TrMpaEGT8Agh4fZ5LSoums60/glNEzk5ozqrg==", - "dev": true, - "requires": { - "has-symbol-support-x": "1.4.1", - "to-primitive-x": "1.1.0", - "to-string-x": "1.4.2" - }, - "dependencies": { - "has-symbol-support-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", - "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", - "dev": true - } - } - }, - "to-string-symbols-supported-x": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/to-string-symbols-supported-x/-/to-string-symbols-supported-x-1.0.0.tgz", - "integrity": "sha512-HbVH673pybrUmhzESGHUm17BBJvqb7BU8HciOvuEYm9ipuDyjmddhvkVqpVW6sM/C5/zhJo17n7O7I/24loJIQ==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "has-symbol-support-x": "1.4.1", - "is-symbol": "1.0.1" - }, - "dependencies": { - "has-symbol-support-x": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz", - "integrity": "sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA==", - "dev": true - } - } - }, - "to-string-tag-x": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/to-string-tag-x/-/to-string-tag-x-1.4.2.tgz", - "integrity": "sha512-ytO9eLigxsQQLGuab0C1iSSTzKdJNVSlBg0Spg4J/rGAVrQJ5y774mo0SSzgGeTT4RJGGyJNfObXaTMzX0XDOQ==", - "dev": true, - "requires": { - "lodash.isnull": "3.0.0", - "validate.io-undefined": "1.0.3" - } - }, - "to-string-x": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/to-string-x/-/to-string-x-1.4.2.tgz", - "integrity": "sha512-/WP5arlwtCpAAexCCHiQBW0eXwse84osWyP1Qtaz71nsYSuUpOkT6tBm8nQ4IIUfSh5hji0hDupUCD2xbbOL6A==", - "dev": true, - "requires": { - "is-symbol": "1.0.1" - } - }, - "tough-cookie": { - "version": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", - "dev": true, - "requires": { - "punycode": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz" - } - }, - "trim-left-x": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/trim-left-x/-/trim-left-x-2.0.1.tgz", - "integrity": "sha512-7JTQAjTmsUB07eDuVoBxAtRbvrC141gYhEnKoP5FHZGc7phaqjbqII7+nFT15gc73F0D7qPb7W+Ny8Im0Kip/Q==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "require-coercible-to-string-x": "1.0.0", - "white-space-x": "2.0.3" - } - }, - "trim-newlines": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", - "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", - "dev": true - }, - "trim-off-newlines": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz", - "integrity": "sha1-n5up2e+odkw4dpi8v+sshI8RrbM=", - "dev": true - }, - "trim-right-x": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/trim-right-x/-/trim-right-x-2.0.1.tgz", - "integrity": "sha512-hdz1fDE/roIkWWNtA43matOTi3dHgLhDkKTo+hFgLwlYSqjNt7Qr0QKZyik8ZDTpjUmrgHtU5/lb+gL/pngWvQ==", - "dev": true, - "requires": { - "cached-constructors-x": "1.0.0", - "require-coercible-to-string-x": "1.0.0", - "white-space-x": "2.0.3" - } - }, - "trim-x": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/trim-x/-/trim-x-2.0.2.tgz", - "integrity": "sha512-FnvMjV360hsj/OQpAaXqAKspNqyawkVe5zkWH/aOVOGcSnbeJYpeOYiaKIZYpu0ZQes3pq7IRm4whHJqAoev7w==", - "dev": true, - "requires": { - "trim-left-x": "2.0.1", - "trim-right-x": "2.0.1" - } - }, - "ts-loader": { - "version": "https://registry.npmjs.org/ts-loader/-/ts-loader-0.6.1.tgz", - "integrity": "sha1-mOKdjD7K2VHVRKTFeTn4CIZvZ6w=", - "dev": true, - "requires": { - "arrify": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", - "colors": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "enhanced-resolve": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz", - "loader-utils": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.16.tgz", - "object-assign": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", - "semver": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz" - }, - "dependencies": { - "object-assign": { - "version": "https://registry.npmjs.org/object-assign/-/object-assign-2.1.1.tgz", - "integrity": "sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo=", - "dev": true - } - } - }, - "tslint": { - "version": "4.5.1", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-4.5.1.tgz", - "integrity": "sha1-BTVocb7yOkNJBnNABvwYgza6gks=", - "dev": true, - "requires": { - "babel-code-frame": "6.26.0", - "colors": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "diff": "3.4.0", - "findup-sync": "0.3.0", - "glob": "7.1.2", - "optimist": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "resolve": "1.4.0", - "tsutils": "1.9.1", - "update-notifier": "2.3.0" - }, - "dependencies": { - "ansi-align": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-2.0.0.tgz", - "integrity": "sha1-w2rsy6VjuJzrVW82kPCx2eNUf38=", - "dev": true, - "requires": { - "string-width": "2.1.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "babel-code-frame": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", - "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", - "dev": true, - "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "boxen": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-1.2.1.tgz", - "integrity": "sha1-DxHn/jRO25OXl3/BPt5/ZNlWSB0=", - "dev": true, - "requires": { - "ansi-align": "2.0.0", - "camelcase": "4.1.0", - "chalk": "2.1.0", - "cli-boxes": "1.0.0", - "string-width": "2.1.1", - "term-size": "1.2.0", - "widest-line": "https://registry.npmjs.org/widest-line/-/widest-line-1.0.0.tgz" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true, - "requires": { - "color-convert": "1.9.0" - } - }, - "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "dev": true, - "requires": { - "ansi-styles": "3.2.0", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "supports-color": "4.4.0" - } - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true, - "requires": { - "has-flag": "2.0.0" - } - } - } - }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" - } - }, - "cli-boxes": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", - "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=", - "dev": true - }, - "configstore": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/configstore/-/configstore-3.1.1.tgz", - "integrity": "sha512-5oNkD/L++l0O6xGXxb1EWS7SivtjfGQlRyxJsYgE0Z495/L81e2h4/d3r969hoPXuFItzNOKMtsXgYG4c7dYvw==", - "dev": true, - "requires": { - "dot-prop": "4.2.0", - "graceful-fs": "4.1.11", - "make-dir": "1.0.0", - "unique-string": "1.0.0", - "write-file-atomic": "2.3.0", - "xdg-basedir": "3.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", - "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", - "dev": true - }, - "diff": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.4.0.tgz", - "integrity": "sha512-QpVuMTEoJMF7cKzi6bvWhRulU1fZqZnvyVQgNhPaxxuTYwyjn/j1v9falseQ/uXWwPnO56RBfwtg4h/EQXmucA==", - "dev": true - }, - "dot-prop": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-4.2.0.tgz", - "integrity": "sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ==", - "dev": true, - "requires": { - "is-obj": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz" - } - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "findup-sync": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", - "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", - "dev": true, - "requires": { - "glob": "5.0.15" - }, - "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - } - } - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "inflight": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz" - } - }, - "got": { - "version": "6.7.1", - "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", - "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", - "dev": true, - "requires": { - "create-error-class": "https://registry.npmjs.org/create-error-class/-/create-error-class-3.0.2.tgz", - "duplexer3": "0.1.4", - "get-stream": "3.0.0", - "is-redirect": "https://registry.npmjs.org/is-redirect/-/is-redirect-1.0.0.tgz", - "is-retry-allowed": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz", - "is-stream": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "lowercase-keys": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "timed-out": "4.0.1", - "unzip-response": "2.0.1", - "url-parse-lax": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, - "latest-version": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/latest-version/-/latest-version-3.1.0.tgz", - "integrity": "sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU=", - "dev": true, - "requires": { - "package-json": "4.0.1" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" - } - }, - "package-json": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/package-json/-/package-json-4.0.1.tgz", - "integrity": "sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0=", - "dev": true, - "requires": { - "got": "6.7.1", - "registry-auth-token": "3.3.1", - "registry-url": "https://registry.npmjs.org/registry-url/-/registry-url-3.1.0.tgz", - "semver": "5.4.1" - } - }, - "rc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", - "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", - "dev": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "strip-json-comments": "2.0.1" - } - }, - "registry-auth-token": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/registry-auth-token/-/registry-auth-token-3.3.1.tgz", - "integrity": "sha1-+w0yie4Nmtosu1KvXf5mywcNMAY=", - "dev": true, - "requires": { - "rc": "1.2.1", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" - } - }, - "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - }, - "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", - "dev": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - } - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "timed-out": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz", - "integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=", - "dev": true - }, - "unzip-response": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unzip-response/-/unzip-response-2.0.1.tgz", - "integrity": "sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c=", - "dev": true - }, - "update-notifier": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-2.3.0.tgz", - "integrity": "sha1-TognpruRUUCrCTVZ1wFOPruDdFE=", - "dev": true, - "requires": { - "boxen": "1.2.1", - "chalk": "2.1.0", - "configstore": "3.1.1", - "import-lazy": "2.1.0", - "is-installed-globally": "0.1.0", - "is-npm": "https://registry.npmjs.org/is-npm/-/is-npm-1.0.0.tgz", - "latest-version": "3.1.0", - "semver-diff": "https://registry.npmjs.org/semver-diff/-/semver-diff-2.1.0.tgz", - "xdg-basedir": "3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true, - "requires": { - "color-convert": "1.9.0" - } - }, - "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "dev": true, - "requires": { - "ansi-styles": "3.2.0", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "supports-color": "4.4.0" - } - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true, - "requires": { - "has-flag": "2.0.0" - } - } - } - }, - "write-file-atomic": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.3.0.tgz", - "integrity": "sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA==", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "imurmurhash": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "signal-exit": "3.0.2" - } - }, - "xdg-basedir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-3.0.0.tgz", - "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", - "dev": true - } - } - }, - "tslint-eslint-rules": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-3.5.1.tgz", - "integrity": "sha1-5D79zddg1ihWAAMXIPlyyS9KBYo=", - "dev": true, - "requires": { - "doctrine": "0.7.2" - }, - "dependencies": { - "doctrine": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", - "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", - "dev": true, - "requires": { - "esutils": "1.1.6", - "isarray": "0.0.1" - } - }, - "esutils": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", - "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=", - "dev": true - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } - } - }, - "tsutils": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz", - "integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=", - "dev": true - }, - "tunnel-agent": { - "version": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", - "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", - "dev": true - }, - "tweetnacl": { - "version": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true - }, - "type-is": { - "version": "https://registry.npmjs.org/type-is/-/type-is-1.6.14.tgz", - "integrity": "sha1-4hljnBfe0coHiQkt1UoDgmuBfLI=", - "dev": true, - "requires": { - "media-typer": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" - } - }, - "typedarray": { - "version": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "typescript": { - "version": "2.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.5.2.tgz", - "integrity": "sha1-A4qV99m7tCCxvzW6MdTFwd0//jQ=", - "dev": true - }, - "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", - "dev": true, - "optional": true, - "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" - }, - "dependencies": { - "align-text": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", - "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", - "dev": true, - "requires": { - "kind-of": "3.2.2", - "longest": "1.0.1", - "repeat-string": "1.6.1" - } - }, - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true, - "optional": true - }, - "center-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", - "dev": true, - "optional": true, - "requires": { - "align-text": "0.1.4", - "lazy-cache": "1.0.4" - } - }, - "cliui": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "optional": true, - "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", - "wordwrap": "0.0.2" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true, - "optional": true - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.6" - } - }, - "lazy-cache": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true, - "optional": true - }, - "longest": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "right-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", - "dev": true, - "optional": true, - "requires": { - "align-text": "0.1.4" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "optional": true - }, - "uglify-to-browserify": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", - "dev": true, - "optional": true - }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true, - "optional": true - }, - "wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true, - "optional": true - }, - "yargs": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "optional": true, - "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", - "window-size": "0.1.0" - } - } - } - }, - "uglify-save-license": { - "version": "https://registry.npmjs.org/uglify-save-license/-/uglify-save-license-0.4.1.tgz", - "integrity": "sha1-lXJsF8xv0XHDYX479NjYKqjEzOE=", - "dev": true - }, - "uglify-to-browserify": { - "version": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", - "dev": true - }, - "ultron": { - "version": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", - "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po=", - "dev": true - }, - "unc-path-regex": { - "version": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", - "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=", - "dev": true - }, - "underscore": { - "version": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", - "dev": true - }, - "underscore.string": { - "version": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.0.3.tgz", - "integrity": "sha1-Rhe4waJQz25QZPu7Nj0PqWzxRVI=", - "dev": true - }, - "unique-stream": { - "version": "https://registry.npmjs.org/unique-stream/-/unique-stream-1.0.0.tgz", - "integrity": "sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs=", - "dev": true - }, - "unique-string": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-1.0.0.tgz", - "integrity": "sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo=", - "dev": true, - "requires": { - "crypto-random-string": "1.0.0" - } - }, - "unpipe": { - "version": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true - }, - "url-parse-lax": { - "version": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", - "dev": true, - "requires": { - "prepend-http": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz" - } - }, - "user-home": { - "version": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", - "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", - "dev": true - }, - "useragent": { - "version": "https://registry.npmjs.org/useragent/-/useragent-2.1.12.tgz", - "integrity": "sha1-qn2mzcSL3De6hnkIcacyHWTtuqI=", - "dev": true, - "requires": { - "lru-cache": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", - "tmp": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz" - }, - "dependencies": { - "lru-cache": { - "version": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", - "integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=", - "dev": true - } - } - }, - "util": { - "version": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "requires": { - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - }, - "dependencies": { - "inherits": { - "version": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - } - } - }, - "util-deprecate": { - "version": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utils-merge": { - "version": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", - "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", - "dev": true - }, - "uuid": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", - "dev": true - }, - "v8flags": { - "version": "https://registry.npmjs.org/v8flags/-/v8flags-2.0.11.tgz", - "integrity": "sha1-vKjzDw1tYGEswsAGQeaWLUKuaIE=", - "dev": true, - "requires": { - "user-home": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz" - } - }, - "validate-npm-package-license": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", - "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", - "dev": true, - "requires": { - "spdx-correct": "1.0.2", - "spdx-expression-parse": "1.0.4" - } - }, - "validate.io-undefined": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz", - "integrity": "sha1-fif8uzFbhB54JDQxiXZxkp4gt/Q=", - "dev": true - }, - "vargs": { - "version": "https://registry.npmjs.org/vargs/-/vargs-0.1.0.tgz", - "integrity": "sha1-a2GE2mUgzDIEzhtAfKwm2SYJ6/8=", - "dev": true - }, - "verror": { - "version": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", - "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", - "dev": true, - "requires": { - "extsprintf": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz" - } - }, - "vinyl-fs": { - "version": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-0.3.14.tgz", - "integrity": "sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY=", - "dev": true, - "requires": { - "defaults": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "glob-stream": "https://registry.npmjs.org/glob-stream/-/glob-stream-3.1.18.tgz", - "glob-watcher": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-0.0.6.tgz", - "graceful-fs": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "strip-bom": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "through2": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "vinyl": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz" - }, - "dependencies": { - "clone": { - "version": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=", - "dev": true - }, - "graceful-fs": { - "version": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.11.tgz", - "integrity": "sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg=", - "dev": true, - "requires": { - "natives": "https://registry.npmjs.org/natives/-/natives-1.1.0.tgz" - } - }, - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - }, - "strip-bom": { - "version": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz", - "integrity": "sha1-hbiGLzhEtabV7IRnqTWYFzo295Q=", - "dev": true, - "requires": { - "first-chunk-stream": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz", - "is-utf8": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz" - } - }, - "through2": { - "version": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz", - "integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=", - "dev": true, - "requires": { - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "xtend": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz" - } - }, - "vinyl": { - "version": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz", - "integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=", - "dev": true, - "requires": { - "clone": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz", - "clone-stats": "https://registry.npmjs.org/clone-stats/-/clone-stats-0.0.1.tgz" - } - } - } - }, - "vinyl-sourcemaps-apply": { - "version": "https://registry.npmjs.org/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz", - "integrity": "sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=", - "dev": true, - "requires": { - "source-map": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz" - }, - "dependencies": { - "source-map": { - "version": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz", - "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=", - "dev": true - } - } - }, - "void-elements": { - "version": "https://registry.npmjs.org/void-elements/-/void-elements-2.0.1.tgz", - "integrity": "sha1-wGavtYK7HLQSjWDqkjkulNXp2+w=", - "dev": true - }, - "vrsource-tslint-rules": { - "version": "https://registry.npmjs.org/vrsource-tslint-rules/-/vrsource-tslint-rules-4.0.1.tgz", - "integrity": "sha1-88+AJuHTqbY9Jj3VkSSNyW3D7Bw=", - "dev": true, - "requires": { - "tslint": "4.5.1" - } - }, - "wd": { - "version": "https://registry.npmjs.org/wd/-/wd-0.3.12.tgz", - "integrity": "sha1-P7Tx11n4yF3eU5PRczT/4D6bsyk=", - "dev": true, - "requires": { - "archiver": "https://registry.npmjs.org/archiver/-/archiver-0.14.4.tgz", - "async": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", - "q": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.55.0.tgz", - "underscore.string": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.0.3.tgz", - "vargs": "https://registry.npmjs.org/vargs/-/vargs-0.1.0.tgz" - }, - "dependencies": { - "async": { - "version": "https://registry.npmjs.org/async/-/async-1.0.0.tgz", - "integrity": "sha1-+PwEyjoTeErenhZBr5hXjPvWR6k=", - "dev": true - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", - "integrity": "sha1-AVnoaDL+/8bWHYUrEqlTuZSWvTI=", - "dev": true - } - } - }, - "webdriver-manager": { - "version": "https://registry.npmjs.org/webdriver-manager/-/webdriver-manager-12.0.6.tgz", - "integrity": "sha1-PfGkgZdwELTL+MnYXHpXeCjA5ws=", - "dev": true, - "requires": { - "adm-zip": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.7.tgz", - "chalk": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "del": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", - "glob": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "ini": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "minimist": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "q": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "request": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "rimraf": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", - "semver": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "xml2js": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz" - }, - "dependencies": { - "ansi-regex": { - "version": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "assert-plus": { - "version": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true - }, - "aws-sign2": { - "version": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true - }, - "caseless": { - "version": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, - "chalk": { - "version": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "escape-string-regexp": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "has-ansi": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "supports-color": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz" - } - }, - "combined-stream": { - "version": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "dev": true, - "requires": { - "delayed-stream": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz" - } - }, - "delayed-stream": { - "version": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "form-data": { - "version": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "dev": true, - "requires": { - "asynckit": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz" - } - }, - "har-validator": { - "version": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "dev": true, - "requires": { - "ajv": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "har-schema": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz" - } - }, - "has-ansi": { - "version": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "hawk": { - "version": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "requires": { - "boom": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "cryptiles": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "hoek": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "sntp": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz" - } - }, - "http-signature": { - "version": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, - "requires": { - "assert-plus": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "jsprim": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "sshpk": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz" - } - }, - "oauth-sign": { - "version": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "dev": true - }, - "qs": { - "version": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", - "dev": true - }, - "request": { - "version": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "dev": true, - "requires": { - "aws-sign2": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "aws4": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "caseless": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "combined-stream": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "extend": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", - "forever-agent": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "form-data": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "har-validator": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "hawk": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "http-signature": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "is-typedarray": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "isstream": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "json-stringify-safe": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "mime-types": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.14.tgz", - "oauth-sign": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "performance-now": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "qs": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "stringstream": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "tough-cookie": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "tunnel-agent": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "uuid": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz" - } - }, - "strip-ansi": { - "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz" - } - }, - "supports-color": { - "version": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - }, - "tunnel-agent": { - "version": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz" - } - }, - "uuid": { - "version": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==", - "dev": true - } - } - }, - "webdriverio": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/webdriverio/-/webdriverio-4.10.1.tgz", - "integrity": "sha1-Qvekh7czebJ0Oi+uULMUJhX2EXA=", - "dev": true, - "requires": { - "archiver": "2.1.1", - "babel-runtime": "6.26.0", - "css-parse": "2.0.0", - "css-value": "0.0.1", - "deepmerge": "2.0.1", - "ejs": "2.5.7", - "gaze": "1.1.2", - "glob": "7.1.2", - "inquirer": "3.3.0", - "json-stringify-safe": "5.0.1", - "mkdirp": "0.5.1", - "npm-install-package": "2.1.0", - "optimist": "0.6.1", - "q": "1.5.1", - "request": "2.83.0", - "rgb2hex": "0.1.0", - "safe-buffer": "5.1.1", - "supports-color": "5.0.1", - "url": "0.11.0", - "validator": "9.1.2", - "wdio-dot-reporter": "0.0.9", - "wgxpath": "1.0.0" - }, - "dependencies": { - "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", - "dev": true, - "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" - } - }, - "amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", - "dev": true - }, - "ansi-escapes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz", - "integrity": "sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ==", - "dev": true - }, - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true, - "requires": { - "color-convert": "1.9.0" - } - }, - "archiver": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/archiver/-/archiver-2.1.1.tgz", - "integrity": "sha1-/2YrSnggFJSj7lRNOjP+dJZQnrw=", - "dev": true, - "requires": { - "archiver-utils": "1.3.0", - "async": "2.6.0", - "buffer-crc32": "0.2.13", - "glob": "7.1.2", - "lodash": "4.17.4", - "readable-stream": "2.3.3", - "tar-stream": "1.5.5", - "zip-stream": "1.2.0" - } - }, - "archiver-utils": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/archiver-utils/-/archiver-utils-1.3.0.tgz", - "integrity": "sha1-5QtMCccL89aA4y/xt5lOn52JUXQ=", - "dev": true, - "requires": { - "glob": "7.1.2", - "graceful-fs": "4.1.11", - "lazystream": "1.0.0", - "lodash": "4.17.4", - "normalize-path": "2.1.1", - "readable-stream": "2.3.3" - } - }, - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", - "dev": true - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true - }, - "async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", - "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", - "dev": true, - "requires": { - "lodash": "4.17.4" - } - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "atob": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/atob/-/atob-1.1.3.tgz", - "integrity": "sha1-lfE2KbEsOlGl0hWr3OKqnzL4B3M=", - "dev": true - }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", - "dev": true - }, - "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", - "dev": true - }, - "babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "dev": true, - "requires": { - "core-js": "2.5.3", - "regenerator-runtime": "0.11.1" - } - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "bl": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", - "integrity": "sha1-ysMo977kVzDUBLaSID/LWQ4XLV4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3" - } - }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "dev": true, - "requires": { - "hoek": "4.2.0" - } - }, - "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "dev": true - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, - "chalk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", - "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", - "dev": true, - "requires": { - "ansi-styles": "3.2.0", - "escape-string-regexp": "1.0.5", - "supports-color": "4.5.0" - }, - "dependencies": { - "supports-color": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", - "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", - "dev": true, - "requires": { - "has-flag": "2.0.0" - } - } - } - }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", - "dev": true, - "requires": { - "restore-cursor": "2.0.0" - } - }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", - "dev": true - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, - "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "dev": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "compress-commons": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.2.tgz", - "integrity": "sha1-UkqfEJA/OoEzibAiXSfEi7dRiQ8=", - "dev": true, - "requires": { - "buffer-crc32": "0.2.13", - "crc32-stream": "2.0.0", - "normalize-path": "2.1.1", - "readable-stream": "2.3.3" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "core-js": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", - "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "crc": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/crc/-/crc-3.5.0.tgz", - "integrity": "sha1-mLi6fUiWZbo5efWbITgTdBAaGWQ=", - "dev": true - }, - "crc32-stream": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-2.0.0.tgz", - "integrity": "sha1-483TtN8xaN10494/u8t7KX/pCPQ=", - "dev": true, - "requires": { - "crc": "3.5.0", - "readable-stream": "2.3.3" - } - }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "dev": true, - "requires": { - "boom": "5.2.0" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "dev": true, - "requires": { - "hoek": "4.2.0" - } - } - } - }, - "css": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/css/-/css-2.2.1.tgz", - "integrity": "sha1-c6TIHehdtmTU7mdPfUcIXjstVdw=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "source-map": "0.1.43", - "source-map-resolve": "0.3.1", - "urix": "0.1.0" - } - }, - "css-parse": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/css-parse/-/css-parse-2.0.0.tgz", - "integrity": "sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q=", - "dev": true, - "requires": { - "css": "2.2.1" - } - }, - "css-value": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/css-value/-/css-value-0.0.1.tgz", - "integrity": "sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo=", - "dev": true - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "requires": { - "assert-plus": "1.0.0" - } - }, - "deepmerge": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-2.0.1.tgz", - "integrity": "sha512-VIPwiMJqJ13ZQfaCsIFnp5Me9tnjURiaIFxfz7EH0Ci0dTSQpZtSLrqOicXqEd/z2r+z+Klk9GzmnRsgpgbOsQ==", - "dev": true - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "ejs": { - "version": "2.5.7", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.5.7.tgz", - "integrity": "sha1-zIcsFoiArjxxiXYv1f/ACJbJUYo=", - "dev": true - }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", - "dev": true, - "requires": { - "once": "1.4.0" - } - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", - "dev": true - }, - "external-editor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", - "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", - "dev": true, - "requires": { - "chardet": "0.4.2", - "iconv-lite": "0.4.19", - "tmp": "0.0.33" - } - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true - }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", - "dev": true, - "requires": { - "escape-string-regexp": "1.0.5" - } - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true - }, - "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", - "dev": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "gaze": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/gaze/-/gaze-1.1.2.tgz", - "integrity": "sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU=", - "dev": true, - "requires": { - "globule": "1.2.0" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "requires": { - "assert-plus": "1.0.0" - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "globule": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/globule/-/globule-1.2.0.tgz", - "integrity": "sha1-HcScaCLdnoovoAuiopUAboZkvQk=", - "dev": true, - "requires": { - "glob": "7.1.2", - "lodash": "4.17.4", - "minimatch": "3.0.4" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "dev": true, - "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" - } - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "dev": true, - "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.0", - "sntp": "2.1.0" - } - }, - "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==", - "dev": true - }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" - } - }, - "iconv-lite": { - "version": "0.4.19", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", - "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "inquirer": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz", - "integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==", - "dev": true, - "requires": { - "ansi-escapes": "3.0.0", - "chalk": "2.3.0", - "cli-cursor": "2.1.0", - "cli-width": "2.2.0", - "external-editor": "2.1.0", - "figures": "2.0.0", - "lodash": "4.17.4", - "mute-stream": "0.0.7", - "run-async": "2.3.0", - "rx-lite": "4.0.8", - "rx-lite-aggregates": "4.0.8", - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "through": "2.3.8" - } - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true - }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, - "lazystream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz", - "integrity": "sha1-9plf4PggOS9hOWvolGJAe7dxaOQ=", - "dev": true, - "requires": { - "readable-stream": "2.3.3" - } - }, - "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true - }, - "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=", - "dev": true - }, - "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", - "dev": true, - "requires": { - "mime-db": "1.30.0" - } - }, - "mimic-fn": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", - "integrity": "sha1-5md4PZLonb00KBi1IwudYqZyrRg=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "1.1.0" - } - }, - "npm-install-package": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/npm-install-package/-/npm-install-package-2.1.0.tgz", - "integrity": "sha1-1+/jz816sAYUuJbqUxGdyaslkSU=", - "dev": true - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "dev": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "1.1.0" - } - }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "dev": true, - "requires": { - "minimist": "0.0.8", - "wordwrap": "0.0.3" - } - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - }, - "q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", - "dev": true - }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==", - "dev": true - }, - "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", - "dev": true - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", - "dev": true, - "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.1", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.2.1" - } - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "2.0.1", - "signal-exit": "3.0.2" - } - }, - "rgb2hex": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/rgb2hex/-/rgb2hex-0.1.0.tgz", - "integrity": "sha1-zNVfhgrgxcTqN1BLlY5ELY0SMls=", - "dev": true - }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "2.1.0" - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "dev": true, - "requires": { - "hoek": "4.2.0" - } - }, - "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", - "dev": true, - "requires": { - "amdefine": "1.0.1" - } - }, - "source-map-resolve": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.3.1.tgz", - "integrity": "sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E=", - "dev": true, - "requires": { - "atob": "1.1.3", - "resolve-url": "0.2.1", - "source-map-url": "0.3.0", - "urix": "0.1.0" - } - }, - "source-map-url": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.3.0.tgz", - "integrity": "sha1-fsrxO1e80J2opAxdJp2zN5nUqvk=", - "dev": true - }, - "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", - "dev": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", - "dev": true - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - }, - "supports-color": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.0.1.tgz", - "integrity": "sha512-7FQGOlSQ+AQxBNXJpVDj8efTA/FtyB5wcNE1omXXJ0cq6jm1jjDwuROlYDbnzHqdNPqliWFhcioCWSyav+xBnA==", - "dev": true, - "requires": { - "has-flag": "2.0.0" - } - }, - "tar-stream": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.5.tgz", - "integrity": "sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg==", - "dev": true, - "requires": { - "bl": "1.2.1", - "end-of-stream": "1.4.1", - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "1.0.2" - } - }, - "tough-cookie": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", - "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", - "dev": true, - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "dev": true, - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "validator": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/validator/-/validator-9.1.2.tgz", - "integrity": "sha512-1Tml6crNdsSC61jHssWksQxq6C7MmSFCCmf99Eb+l/V/cwVlw4/Pg3YXBP1WKcHLsyqe3E+iJXUZgoTTQFcqQg==", - "dev": true - }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "dev": true, - "requires": { - "assert-plus": "1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "1.3.0" - } - }, - "wdio-dot-reporter": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/wdio-dot-reporter/-/wdio-dot-reporter-0.0.9.tgz", - "integrity": "sha1-kpsq2v1J1rBTT9oGjocxm0fjj+U=", - "dev": true - }, - "wgxpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wgxpath/-/wgxpath-1.0.0.tgz", - "integrity": "sha1-7vikudVYzEla06mit1FZfs2a9pA=", - "dev": true - }, - "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - }, - "zip-stream": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-1.2.0.tgz", - "integrity": "sha1-qLxF9MG0lpnGuQGYuqyqzbzUugQ=", - "dev": true, - "requires": { - "archiver-utils": "1.3.0", - "compress-commons": "1.2.2", - "lodash": "4.17.4", - "readable-stream": "2.3.3" - } - } - } - }, - "whatwg-fetch": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", - "integrity": "sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=", - "dev": true - }, - "which": { - "version": "https://registry.npmjs.org/which/-/which-1.2.12.tgz", - "integrity": "sha1-3me15FAmnxlJCe8j7OTr5Bb6EZI=", - "dev": true, - "requires": { - "isexe": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz" - } - }, - "white-space-x": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/white-space-x/-/white-space-x-2.0.3.tgz", - "integrity": "sha512-An6uHDfZizY0t7x8iyY8nLej1lnqyaFSyTKjwwqS0VIhvV4tof6a+Et4uJVFlZh7HUAOgKoZfm5hFzl/D4xDgw==", - "dev": true - }, - "widest-line": { - "version": "https://registry.npmjs.org/widest-line/-/widest-line-1.0.0.tgz", - "integrity": "sha1-DAnIXCqUaD0Nfq+O4JfVZL8OEFw=", - "dev": true, - "requires": { - "string-width": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz" - } - }, - "window-size": { - "version": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true - }, - "wordwrap": { - "version": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", - "dev": true - }, - "wrappy": { - "version": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "ws": { - "version": "https://registry.npmjs.org/ws/-/ws-1.1.1.tgz", - "integrity": "sha1-CC3bbGQehdS7RR8D1S8G6r2x8Bg=", - "dev": true, - "requires": { - "options": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", - "ultron": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz" - } - }, - "wtf-8": { - "version": "https://registry.npmjs.org/wtf-8/-/wtf-8-1.0.0.tgz", - "integrity": "sha1-OS2LotDxw00e4tYw8V0O+2jhBIo=", - "dev": true - }, - "xml2js": { - "version": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.17.tgz", - "integrity": "sha1-F76T6q4/O3eTWceVtBlwWogX6Gg=", - "dev": true, - "requires": { - "sax": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "xmlbuilder": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz" - } - }, - "xmlbuilder": { - "version": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-4.2.1.tgz", - "integrity": "sha1-qlijBBoGb5DqoWwvU4n/GfP0YaU=", - "dev": true, - "requires": { - "lodash": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz" - } - }, - "xmlhttprequest-ssl": { - "version": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz", - "integrity": "sha1-GFqIjATspGw+QHDZn3tJ3jUomS0=", - "dev": true - }, - "xtend": { - "version": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", - "dev": true - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true - }, - "yargs": { - "version": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "requires": { - "camelcase": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "cliui": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "decamelize": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "window-size": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz" - }, - "dependencies": { - "camelcase": { - "version": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true - } - } - }, - "yauzl": { - "version": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", - "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", - "dev": true, - "requires": { - "fd-slicer": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz" - } - }, - "yeast": { - "version": "https://registry.npmjs.org/yeast/-/yeast-0.1.2.tgz", - "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=", - "dev": true - }, - "zip-stream": { - "version": "https://registry.npmjs.org/zip-stream/-/zip-stream-0.5.2.tgz", - "integrity": "sha1-Mty8UG0Nq00hNyYlvX66rDwv/1Y=", - "dev": true, - "requires": { - "compress-commons": "https://registry.npmjs.org/compress-commons/-/compress-commons-0.2.9.tgz", - "lodash": "https://registry.npmjs.org/lodash/-/lodash-3.2.0.tgz", - "readable-stream": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz" - }, - "dependencies": { - "isarray": { - "version": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "lodash": { - "version": "https://registry.npmjs.org/lodash/-/lodash-3.2.0.tgz", - "integrity": "sha1-S/UKMkP5rrC6xBpV09WZBnWkYvs=", - "dev": true - }, - "readable-stream": { - "version": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "inherits": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "isarray": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "string_decoder": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - } - } - } - } - } -} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..75219d5ad --- /dev/null +++ b/yarn.lock @@ -0,0 +1,5963 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/jasmine@2.2.33": + version "2.2.33" + resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.2.33.tgz#4715cfd2ca7fbd632fc7f1784f13e637bed028c5" + +"@types/node@^6.0.96": + version "6.0.101" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.101.tgz#0c5911cfb434af4a51c0a499931fe6423207d921" + +"@types/systemjs@^0.19.30": + version "0.19.33" + resolved "https://registry.yarnpkg.com/@types/systemjs/-/systemjs-0.19.33.tgz#47c47e7639867b6694beb3f60c4f53ad55eb1b13" + +JSONStream@^1.0.4: + version "1.3.2" + resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea" + dependencies: + jsonparse "^1.2.0" + through ">=2.2.7 <3" + +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + +accepts@1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca" + dependencies: + mime-types "~2.1.11" + negotiator "0.6.1" + +add-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" + +adm-zip@^0.4.7, adm-zip@~0.4.3: + version "0.4.7" + resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.7.tgz#8606c2cbf1c426ce8c8ec00174447fd49b6eafc1" + +after@0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" + +ajv@^4.9.1: + version "4.11.8" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + +ajv@^5.1.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + +align-text@^0.1.1, align-text@^0.1.3: + version "0.1.4" + resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + dependencies: + kind-of "^3.0.2" + longest "^1.0.1" + repeat-string "^1.5.2" + +amdefine@>=0.0.4: + version "1.0.1" + resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + +ansi-align@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" + dependencies: + string-width "^2.0.0" + +ansi-colors@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-1.1.0.tgz#6374b4dd5d4718ff3ce27a671a3b1cad077132a9" + dependencies: + ansi-wrap "^0.1.0" + +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + +ansi-gray@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251" + dependencies: + ansi-wrap "0.1.0" + +ansi-regex@^0.2.0, ansi-regex@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" + +ansi-regex@^2.0.0, ansi-regex@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + +ansi-styles@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +ansi-styles@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" + dependencies: + color-convert "^1.9.0" + +ansi-wrap@0.1.0, ansi-wrap@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" + +anymatch@^1.3.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" + dependencies: + micromatch "^2.1.5" + normalize-path "^2.0.0" + +aproba@^1.0.3: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + +archiver-utils@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/archiver-utils/-/archiver-utils-1.3.0.tgz#e50b4c09c70bf3d680e32ff1b7994e9f9d895174" + dependencies: + glob "^7.0.0" + graceful-fs "^4.1.0" + lazystream "^1.0.0" + lodash "^4.8.0" + normalize-path "^2.0.0" + readable-stream "^2.0.0" + +archiver@~0.14.0: + version "0.14.4" + resolved "https://registry.yarnpkg.com/archiver/-/archiver-0.14.4.tgz#5b9ddb9f5ee1ceef21cb8f3b020e6240ecb4315c" + dependencies: + async "~0.9.0" + buffer-crc32 "~0.2.1" + glob "~4.3.0" + lazystream "~0.1.0" + lodash "~3.2.0" + readable-stream "~1.0.26" + tar-stream "~1.1.0" + zip-stream "~0.5.0" + +archiver@~2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/archiver/-/archiver-2.1.1.tgz#ff662b4a78201494a3ee544d3a33fe7496509ebc" + dependencies: + archiver-utils "^1.3.0" + async "^2.0.0" + buffer-crc32 "^0.2.1" + glob "^7.0.0" + lodash "^4.8.0" + readable-stream "^2.0.0" + tar-stream "^1.5.0" + zip-stream "^1.2.0" + +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + +are-we-there-yet@~1.1.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.6" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + +arr-flatten@^1.0.1, arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + +array-differ@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" + +array-each@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +array-ify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" + +array-slice@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" + +array-slice@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-1.1.0.tgz#e368ea15f89bc7069f7ffb89aec3a6c7d4ac22d4" + +array-union@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + dependencies: + array-uniq "^1.0.1" + +array-uniq@^1.0.1, array-uniq@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + +arraybuffer.slice@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@0.1.11: + version "0.1.11" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.1.11.tgz#559be18376d08a4ec4dbe80877d27818639b2df7" + +asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@1.0.0, assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +assert-plus@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.1.5.tgz#ee74009413002d84cec7219c6ac811812e723160" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +assert@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" + dependencies: + util "0.10.3" + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +async@0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.0.tgz#ac3613b1da9bed1b47510bb4651b8931e47146c7" + +async@^1.4.0, async@^1.4.2, async@^1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + +async@^2.0.0, async@^2.0.1: + version "2.6.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" + dependencies: + lodash "^4.14.0" + +async@~0.2.6: + version "0.2.10" + resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + +async@~0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + +async@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +atob@^2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.0.3.tgz#19c7a760473774468f20b2d2d03372ad7d4cbf5d" + +atob@~1.1.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/atob/-/atob-1.1.3.tgz#95f13629b12c3a51a5d215abdce2aa9f32f80773" + +attempt-x@^1.1.0, attempt-x@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/attempt-x/-/attempt-x-1.1.1.tgz#fba64e96ce03c3e0bd92c92622061c4df387cb76" + +aws-sign2@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.5.0.tgz#c57103f7a17fc037f02d7c2e64b602ea223f7d63" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws-sign2@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + +aws4@^1.2.1, aws4@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + +babel-code-frame@^6.20.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +backo2@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + +base64-arraybuffer@0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" + +base64id@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +batch@^0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.5.3.tgz#3f3414f380321743bfc1042f9a83ff1d5824d464" + +bcrypt-pbkdf@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + dependencies: + tweetnacl "^0.14.3" + +beeper@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" + +better-assert@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" + dependencies: + callsite "1.0.0" + +big.js@^3.1.3: + version "3.2.0" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" + +binary-extensions@^1.0.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" + +bl@^0.9.0, bl@~0.9.0: + version "0.9.5" + resolved "https://registry.yarnpkg.com/bl/-/bl-0.9.5.tgz#c06b797af085ea00bc527afc8efcf11de2232054" + dependencies: + readable-stream "~1.0.26" + +bl@^1.0.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.1.tgz#cac328f7bee45730d404b692203fcb590e172d5e" + dependencies: + readable-stream "^2.0.5" + +bl@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/bl/-/bl-1.0.3.tgz#fc5421a28fd4226036c3b3891a66a25bc64d226e" + dependencies: + readable-stream "~2.0.5" + +blob@0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" + +block-stream@*: + version "0.0.9" + resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +bluebird@2.9.6: + version "2.9.6" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.9.6.tgz#1fc3a6b1685267dc121b5ec89b32ce069d81ab7d" + +bluebird@^2.9.27, bluebird@^2.9.30: + version "2.11.0" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" + +body-parser@^1.12.4: + version "1.18.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.1" + http-errors "~1.6.2" + iconv-lite "0.4.19" + on-finished "~2.3.0" + qs "6.5.1" + raw-body "2.3.2" + type-is "~1.6.15" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +boom@4.x.x: + version "4.3.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + dependencies: + hoek "4.x.x" + +boom@5.x.x: + version "5.2.0" + resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + dependencies: + hoek "4.x.x" + +boxen@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" + dependencies: + ansi-align "^2.0.0" + camelcase "^4.0.0" + chalk "^2.0.1" + cli-boxes "^1.0.0" + string-width "^2.0.0" + term-size "^1.2.0" + widest-line "^2.0.0" + +brace-expansion@^1.0.0, brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^0.1.2: + version "0.1.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-0.1.5.tgz#c085711085291d8b75fdd74eab0f8597280711e6" + dependencies: + expand-range "^0.1.0" + +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +braces@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.1.tgz#7086c913b4e5a08dbe37ac0ee6a2500c4ba691bb" + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + define-property "^1.0.0" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + kind-of "^6.0.2" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +browser-stdout@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + +buffer-crc32@^0.2.1, buffer-crc32@~0.2.1: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + +buffer-from@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-0.1.1.tgz#57b18b1da0a19ec06f33837a5275a242351bd75e" + dependencies: + is-array-buffer-x "^1.0.13" + +builtin-modules@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +byline@^4.1.1: + version "4.2.2" + resolved "https://registry.yarnpkg.com/byline/-/byline-4.2.2.tgz#c203a98a5b0290822a9386a78eda2cbd5bcdb32f" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +cached-constructors-x@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cached-constructors-x/-/cached-constructors-x-1.0.0.tgz#c421e3892a4b6f7794434bdcffd1299b330c181b" + +callsite@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^1.0.2: + version "1.2.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +camelcase@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + +capture-stack-trace@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + +caseless@~0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.9.0.tgz#b7b65ce6bf1413886539cfd533f0b30effa9cf88" + +center-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + dependencies: + align-text "^0.1.3" + lazy-cache "^1.0.3" + +chalk@0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174" + dependencies: + ansi-styles "^1.1.0" + escape-string-regexp "^1.0.0" + has-ansi "^0.1.0" + strip-ansi "^0.3.0" + supports-color "^0.2.0" + +chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chalk@^2.0.0, chalk@^2.0.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796" + dependencies: + ansi-styles "^3.2.0" + escape-string-regexp "^1.0.5" + supports-color "^5.2.0" + +chardet@^0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + +chokidar@^1.4.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +clang-format@1.0.46: + version "1.0.46" + resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.0.46.tgz#f69de49cd50909b3149c9053c9240defd5135114" + dependencies: + async "^1.5.2" + glob "^7.0.0" + resolve "^1.1.6" + +clang-format@^1.0.32: + version "1.2.2" + resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.2.tgz#a7277a03fce9aa4e387ddaa83b60d99dab115737" + dependencies: + async "^1.5.2" + glob "^7.0.0" + resolve "^1.1.6" + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +cli-boxes@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" + +cli-color@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-1.2.0.tgz#3a5ae74fd76b6267af666e69e2afbbd01def34d1" + dependencies: + ansi-regex "^2.1.1" + d "1" + es5-ext "^0.10.12" + es6-iterator "2" + memoizee "^0.4.3" + timers-ext "0.1" + +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" + dependencies: + restore-cursor "^2.0.0" + +cli-width@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" + +cliui@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + dependencies: + center-align "^0.1.1" + right-align "^0.1.1" + wordwrap "0.0.2" + +clone-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" + +clone-stats@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" + +clone-stats@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" + +clone@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" + +clone@^1.0.0, clone@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.3.tgz#298d7e2231660f40c003c2ed3140decf3f53085f" + +clone@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb" + +cloneable-readable@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.0.0.tgz#a6290d413f217a61232f95e458ff38418cfb0117" + dependencies: + inherits "^2.0.1" + process-nextick-args "^1.0.6" + through2 "^2.0.1" + +co@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + +code-point-at@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-convert@^1.9.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed" + dependencies: + color-name "^1.1.1" + +color-name@^1.1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + +color-support@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" + +colors@^1.0.3, colors@^1.1.0, colors@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + +combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + dependencies: + delayed-stream "~1.0.0" + +combined-stream@~0.0.4, combined-stream@~0.0.5: + version "0.0.7" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-0.0.7.tgz#0137e657baa5a7541c57ac37ac5fc07d73b4dc1f" + dependencies: + delayed-stream "0.0.5" + +commander@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" + +commander@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" + +commander@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.6.0.tgz#9df7e52fb2a0cb0fb89058ee80c3104225f37e1d" + +commander@2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +commander@^2.8.1, commander@^2.9.0: + version "2.14.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" + +compare-func@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" + dependencies: + array-ify "^1.0.0" + dot-prop "^3.0.0" + +component-bind@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" + +component-emitter@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.1.2.tgz#296594f2753daa63996d2af08d15a95116c9aec3" + +component-emitter@1.2.1, component-emitter@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" + +component-inherit@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" + +compress-commons@^1.2.0: + version "1.2.2" + resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-1.2.2.tgz#524a9f10903f3a813389b0225d27c48bb751890f" + dependencies: + buffer-crc32 "^0.2.1" + crc32-stream "^2.0.0" + normalize-path "^2.0.0" + readable-stream "^2.0.0" + +compress-commons@~0.2.0: + version "0.2.9" + resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-0.2.9.tgz#422d927430c01abd06cd455b6dfc04cb4cf8003c" + dependencies: + buffer-crc32 "~0.2.1" + crc32-stream "~0.3.1" + node-int64 "~0.3.0" + readable-stream "~1.0.26" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.0.tgz#53f7d43c51c5e43f81c8fdd03321c631be68d611" + dependencies: + inherits "~2.0.1" + readable-stream "~2.0.0" + typedarray "~0.0.5" + +concat-stream@1.6.0, concat-stream@^1.5.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" + dependencies: + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +concurrently@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-2.2.0.tgz#bad248e0bb129fb1621768903a6311d45d56895a" + dependencies: + bluebird "2.9.6" + chalk "0.5.1" + commander "2.6.0" + cross-spawn "^0.2.9" + lodash "^4.5.1" + moment "^2.11.2" + rx "2.3.24" + +configstore@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.1.tgz#094ee662ab83fad9917678de114faaea8fcdca90" + dependencies: + dot-prop "^4.1.0" + graceful-fs "^4.1.2" + make-dir "^1.0.0" + unique-string "^1.0.0" + write-file-atomic "^2.0.0" + xdg-basedir "^3.0.0" + +connect@^3.3.5: + version "3.6.6" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" + dependencies: + debug "2.6.9" + finalhandler "1.1.0" + parseurl "~1.3.2" + utils-merge "1.0.1" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + +conventional-changelog-angular@^1.6.5: + version "1.6.5" + resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.5.tgz#936249e897501affdffc6043da45cab59d6f0907" + dependencies: + compare-func "^1.3.1" + q "^1.4.1" + +conventional-changelog-atom@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-0.2.3.tgz#117d024e5cf9e28dcbd0575981105395be1bca74" + dependencies: + q "^1.4.1" + +conventional-changelog-codemirror@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.3.tgz#e1ec78e77e7fe26a2bd18e32f02523527916a07b" + dependencies: + q "^1.4.1" + +conventional-changelog-core@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-2.0.4.tgz#bbc476109c6b28ba6328b0b417f5ab5bfc7ca28a" + dependencies: + conventional-changelog-writer "^3.0.3" + conventional-commits-parser "^2.1.4" + dateformat "^1.0.12" + get-pkg-repo "^1.0.0" + git-raw-commits "^1.3.3" + git-remote-origin-url "^2.0.0" + git-semver-tags "^1.3.3" + lodash "^4.0.0" + normalize-package-data "^2.3.5" + q "^1.4.1" + read-pkg "^1.1.0" + read-pkg-up "^1.0.1" + through2 "^2.0.0" + +conventional-changelog-ember@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-0.3.5.tgz#db9a23f01103c6a0446ed2077ed5c87656d0571a" + dependencies: + q "^1.4.1" + +conventional-changelog-eslint@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.3.tgz#023002a3f776266c501e4d4def7b0bb24130f29d" + dependencies: + q "^1.4.1" + +conventional-changelog-express@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-0.3.3.tgz#25aef42a30b5457f97681a94f2ac9b0ee515484a" + dependencies: + q "^1.4.1" + +conventional-changelog-jquery@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz#0208397162e3846986e71273b6c79c5b5f80f510" + dependencies: + q "^1.4.1" + +conventional-changelog-jscs@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz#0479eb443cc7d72c58bf0bcf0ef1d444a92f0e5c" + dependencies: + q "^1.4.1" + +conventional-changelog-jshint@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.3.tgz#28b6fe4d41fb945f38c6c31cd195fe37594f0007" + dependencies: + compare-func "^1.3.1" + q "^1.4.1" + +conventional-changelog-preset-loader@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.5.tgz#d5af525d7ad81179d9b54137284d74d665997fa7" + +conventional-changelog-writer@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-3.0.3.tgz#2faa65739370769639fff1c0008722162936d46c" + dependencies: + compare-func "^1.3.1" + conventional-commits-filter "^1.1.4" + dateformat "^1.0.11" + handlebars "^4.0.2" + json-stringify-safe "^5.0.1" + lodash "^4.0.0" + meow "^3.3.0" + semver "^5.0.1" + split "^1.0.0" + through2 "^2.0.0" + +conventional-changelog@^1.1.16, conventional-changelog@^1.1.7: + version "1.1.16" + resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.16.tgz#fa78386c831f5b1ae45f60391ef015c2a4a400b9" + dependencies: + conventional-changelog-angular "^1.6.5" + conventional-changelog-atom "^0.2.3" + conventional-changelog-codemirror "^0.3.3" + conventional-changelog-core "^2.0.4" + conventional-changelog-ember "^0.3.5" + conventional-changelog-eslint "^1.0.3" + conventional-changelog-express "^0.3.3" + conventional-changelog-jquery "^0.1.0" + conventional-changelog-jscs "^0.1.0" + conventional-changelog-jshint "^0.3.3" + conventional-changelog-preset-loader "^1.1.5" + +conventional-commits-filter@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-1.1.4.tgz#8b5be3979c372e4f7440180d5c655a94ac5a134a" + dependencies: + is-subset "^0.1.1" + modify-values "^1.0.0" + +conventional-commits-parser@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.1.4.tgz#86d2c21029268d99543c4ebda37d76fe5c44d8d1" + dependencies: + JSONStream "^1.0.4" + is-text-path "^1.0.0" + lodash "^4.2.1" + meow "^3.3.0" + split2 "^2.0.0" + through2 "^2.0.0" + trim-off-newlines "^1.0.0" + +cookie@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + +core-js@^2.1.0, core-js@^2.4.0: + version "2.5.3" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" + +core-js@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.3.0.tgz#fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65" + +core-util-is@1.0.2, core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +crc32-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-2.0.0.tgz#e3cdd3b4df3168dd74e3de3fbbcb7b297fe908f4" + dependencies: + crc "^3.4.4" + readable-stream "^2.0.0" + +crc32-stream@~0.3.1: + version "0.3.4" + resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-0.3.4.tgz#73bc25b45fac1db6632231a7bfce8927e9f06552" + dependencies: + buffer-crc32 "~0.2.1" + readable-stream "~1.0.24" + +crc@^3.4.4: + version "3.5.0" + resolved "https://registry.yarnpkg.com/crc/-/crc-3.5.0.tgz#98b8ba7d489665ba3979f59b21381374101a1964" + +create-error-class@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" + dependencies: + capture-stack-trace "^1.0.0" + +cross-spawn@^0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-0.2.9.tgz#bd67f96c07efb6303b7fe94c1e979f88478e0a39" + dependencies: + lru-cache "^2.5.0" + +cross-spawn@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + dependencies: + lru-cache "^4.0.1" + shebang-command "^1.2.0" + which "^1.2.9" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +cryptiles@3.x.x: + version "3.1.2" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + dependencies: + boom "5.x.x" + +crypto-random-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" + +css-parse@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/css-parse/-/css-parse-2.0.0.tgz#a468ee667c16d81ccf05c58c38d2a97c780dbfd4" + dependencies: + css "^2.0.0" + +css-value@~0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/css-value/-/css-value-0.0.1.tgz#5efd6c2eea5ea1fd6b6ac57ec0427b18452424ea" + +css@^2.0.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/css/-/css-2.2.1.tgz#73a4c81de85db664d4ee674f7d47085e3b2d55dc" + dependencies: + inherits "^2.0.1" + source-map "^0.1.38" + source-map-resolve "^0.3.0" + urix "^0.1.0" + +ctype@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/ctype/-/ctype-0.5.3.tgz#82c18c2461f74114ef16c135224ad0b9144ca12f" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +custom-event@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + +d@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + dependencies: + es5-ext "^0.10.9" + +dargs@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" + dependencies: + number-is-nan "^1.0.0" + +dashdash@^1.12.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + dependencies: + assert-plus "^1.0.0" + +dateformat@^1.0.11, dateformat@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + dependencies: + get-stdin "^4.0.1" + meow "^3.3.0" + +dateformat@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.2.0.tgz#4065e2013cf9fb916ddfd82efb506ad4c6769062" + +deap@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/deap/-/deap-1.0.0.tgz#b148bf82430a27699b7483a03eb6b67585bfc888" + +debug@0.7.4: + version "0.7.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" + +debug@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +debug@2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" + dependencies: + ms "0.7.2" + +debug@2.6.8: + version "2.6.8" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + dependencies: + ms "2.0.0" + +debug@2.6.9, debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + +decamelize@^1.0.0, decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + +deep-extend@~0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" + +deepmerge@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.0.1.tgz#25c1c24f110fb914f80001b925264dd77f3f4312" + +defaults@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" + dependencies: + clone "^1.0.2" + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +del@^2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + dependencies: + globby "^5.0.0" + is-path-cwd "^1.0.0" + is-path-in-cwd "^1.0.0" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + rimraf "^2.2.8" + +delayed-stream@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-0.0.5.tgz#d4b1f43a93e8296dfe02694f4680bc37a313c73f" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +depd@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + +depd@~1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + +deprecated@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19" + +detect-file@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" + +detect-libc@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + +di@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" + +diff@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + +diff@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + +diff@^2.0.2: + version "2.2.3" + resolved "https://registry.yarnpkg.com/diff/-/diff-2.2.3.tgz#60eafd0d28ee906e4e8ff0a52c1229521033bf99" + +diff@^3.0.1: + version "3.4.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c" + +doctrine@^0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523" + dependencies: + esutils "^1.1.6" + isarray "0.0.1" + +dom-serialize@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" + dependencies: + custom-event "~1.0.0" + ent "~2.2.0" + extend "^3.0.0" + void-elements "^2.0.0" + +dot-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" + dependencies: + is-obj "^1.0.0" + +dot-prop@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" + dependencies: + is-obj "^1.0.0" + +duplexer2@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" + dependencies: + readable-stream "~1.1.9" + +duplexer2@~0.1.0: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" + dependencies: + readable-stream "^2.0.2" + +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + +duplexer@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + +duplexify@^3.2.0: + version "3.5.3" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.3.tgz#8b5818800df92fd0125b27ab896491912858243e" + dependencies: + end-of-stream "^1.0.0" + inherits "^2.0.1" + readable-stream "^2.0.0" + stream-shift "^1.0.0" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + +ejs@~2.5.6: + version "2.5.7" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" + +emojis-list@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" + +encodeurl@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" + dependencies: + once "^1.4.0" + +end-of-stream@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf" + dependencies: + once "~1.3.0" + +engine.io-client@~1.8.4: + version "1.8.5" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.5.tgz#fe7fb60cb0dcf2fa2859489329cb5968dedeb11f" + dependencies: + component-emitter "1.2.1" + component-inherit "0.0.3" + debug "2.3.3" + engine.io-parser "1.3.2" + has-cors "1.1.0" + indexof "0.0.1" + parsejson "0.0.3" + parseqs "0.0.5" + parseuri "0.0.5" + ws "~1.1.5" + xmlhttprequest-ssl "1.5.3" + yeast "0.1.2" + +engine.io-parser@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-1.3.2.tgz#937b079f0007d0893ec56d46cb220b8cb435220a" + dependencies: + after "0.8.2" + arraybuffer.slice "0.0.6" + base64-arraybuffer "0.1.5" + blob "0.0.4" + has-binary "0.1.7" + wtf-8 "1.0.0" + +engine.io@~1.8.4: + version "1.8.5" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.5.tgz#4ebe5e75c6dc123dee4afdce6e5fdced21eb93f6" + dependencies: + accepts "1.3.3" + base64id "1.0.0" + cookie "0.3.1" + debug "2.3.3" + engine.io-parser "1.3.2" + ws "~1.1.5" + +enhanced-resolve@^0.9.0: + version "0.9.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" + dependencies: + graceful-fs "^4.1.2" + memory-fs "^0.2.0" + tapable "^0.1.8" + +ent@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + +error-ex@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" + dependencies: + is-arrayish "^0.2.1" + +es5-ext@^0.10.12, es5-ext@^0.10.14, es5-ext@^0.10.30, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: + version "0.10.39" + resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.39.tgz#fca21b67559277ca4ac1a1ed7048b107b6f76d87" + dependencies: + es6-iterator "~2.0.3" + es6-symbol "~3.1.1" + +es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + dependencies: + d "1" + es5-ext "^0.10.35" + es6-symbol "^3.1.1" + +es6-promise@^3.0.2: + version "3.3.1" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613" + +es6-promise@^4.0.3: + version "4.2.4" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29" + +es6-promise@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.0.2.tgz#010d5858423a5f118979665f46486a95c6ee2bb6" + +es6-symbol@^3.1.1, es6-symbol@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + dependencies: + d "1" + es5-ext "~0.10.14" + +es6-weak-map@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + dependencies: + d "1" + es5-ext "^0.10.14" + es6-iterator "^2.0.1" + es6-symbol "^3.1.1" + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + +escape-string-regexp@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" + +escape-string-regexp@1.0.5, escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esutils@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +event-emitter@^0.3.5: + version "0.3.5" + resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + dependencies: + d "1" + es5-ext "~0.10.14" + +event-stream@^3.1.5: + version "3.3.4" + resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" + dependencies: + duplexer "~0.1.1" + from "~0" + map-stream "~0.1.0" + pause-stream "0.0.11" + split "0.3" + stream-combiner "~0.0.4" + through "~2.3.1" + +eventemitter3@1.x.x: + version "1.2.0" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" + +execa@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +exit@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + +expand-braces@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" + dependencies: + array-slice "^0.2.3" + array-unique "^0.2.1" + braces "^0.1.2" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +expand-range@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-0.1.1.tgz#4cb8eda0993ca56fa4f41fc42f3cbb4ccadff044" + dependencies: + is-number "^0.1.1" + repeat-string "^0.2.2" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +expand-tilde@^2.0.0, expand-tilde@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" + dependencies: + homedir-polyfill "^1.0.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + +external-editor@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" + dependencies: + chardet "^0.4.0" + iconv-lite "^0.4.17" + tmp "^0.0.33" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +extract-zip@^1.6.5: + version "1.6.6" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.6.tgz#1290ede8d20d0872b429fd3f351ca128ec5ef85c" + dependencies: + concat-stream "1.6.0" + debug "2.6.9" + mkdirp "0.5.0" + yauzl "2.4.1" + +extract-zip@~1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.5.0.tgz#92ccf6d81ef70a9fa4c1747114ccef6d8688a6c4" + dependencies: + concat-stream "1.5.0" + debug "0.7.4" + mkdirp "0.5.0" + yauzl "2.4.1" + +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + +fancy-log@^1.0.0, fancy-log@^1.1.0, fancy-log@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.2.tgz#f41125e3d84f2e7d89a43d06d958c8f78be16be1" + dependencies: + ansi-gray "^0.1.1" + color-support "^1.1.3" + time-stamp "^1.0.0" + +fast-deep-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" + +fast-json-stable-stringify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + +fd-slicer@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" + dependencies: + pend "~1.2.0" + +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + dependencies: + escape-string-regexp "^1.0.5" + +filename-regex@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +finalhandler@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + dependencies: + debug "2.6.9" + encodeurl "~1.0.1" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.2" + statuses "~1.3.1" + unpipe "~1.0.0" + +find-index@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +findup-sync@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" + dependencies: + detect-file "^1.0.0" + is-glob "^3.1.0" + micromatch "^3.0.4" + resolve-dir "^1.0.1" + +findup-sync@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" + dependencies: + glob "~5.0.0" + +fined@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fined/-/fined-1.1.0.tgz#b37dc844b76a2f5e7081e884f7c0ae344f153476" + dependencies: + expand-tilde "^2.0.2" + is-plain-object "^2.0.3" + object.defaults "^1.1.0" + object.pick "^1.2.0" + parse-filepath "^1.0.1" + +first-chunk-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" + +flagged-respawn@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.0.tgz#4e79ae9b2eb38bf86b3bb56bf3e0a56aa5fcabd7" + +for-in@^1.0.1, for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + +for-own@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + dependencies: + for-in "^1.0.1" + +for-own@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-1.0.0.tgz#c63332f415cedc4b04dbfe70cf836494c53cb44b" + dependencies: + for-in "^1.0.1" + +forever-agent@~0.6.0, forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-0.2.0.tgz#26f8bc26da6440e299cbdcfb69035c4f77a6e466" + dependencies: + async "~0.9.0" + combined-stream "~0.0.4" + mime-types "~2.0.3" + +form-data@~1.0.0-rc3: + version "1.0.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.1.tgz#ae315db9a4907fa065502304a66d7733475ee37c" + dependencies: + async "^2.0.1" + combined-stream "^1.0.5" + mime-types "^2.1.11" + +form-data@~2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +form-data@~2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" + dependencies: + asynckit "^0.4.0" + combined-stream "1.0.6" + mime-types "^2.1.12" + +formatio@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" + dependencies: + samsam "~1.1" + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + dependencies: + map-cache "^0.2.2" + +from@~0: + version "0.1.7" + resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" + +fs-access@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" + dependencies: + null-check "^1.0.0" + +fs-extra@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + +fs-extra@~0.26.4: + version "0.26.7" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^2.1.0" + klaw "^1.0.0" + path-is-absolute "^1.0.0" + rimraf "^2.2.8" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.1.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.3.tgz#11f82318f5fe7bb2cd22965a108e9306208216d8" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.39" + +fstream-ignore@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: + version "1.0.11" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +gauge@~2.7.3: + version "2.7.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +gaze@^0.5.1: + version "0.5.2" + resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" + dependencies: + globule "~0.1.0" + +gaze@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/gaze/-/gaze-1.1.2.tgz#847224677adb8870d679257ed3388fdb61e40105" + dependencies: + globule "^1.0.0" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +get-pkg-repo@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" + dependencies: + hosted-git-info "^2.1.4" + meow "^3.3.0" + normalize-package-data "^2.3.0" + parse-github-repo-url "^1.3.0" + through2 "^2.0.0" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + +getpass@^0.1.1: + version "0.1.7" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + dependencies: + assert-plus "^1.0.0" + +git-raw-commits@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-1.3.3.tgz#464f9aa14c4e78235e98654f0da467f3702590f9" + dependencies: + dargs "^4.0.1" + lodash.template "^4.0.2" + meow "^3.3.0" + split2 "^2.0.0" + through2 "^2.0.0" + +git-remote-origin-url@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f" + dependencies: + gitconfiglocal "^1.0.0" + pify "^2.3.0" + +git-semver-tags@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.3.3.tgz#0b0416c43285adfdc93a8038ea25502a09319245" + dependencies: + meow "^3.3.0" + semver "^5.0.1" + +gitconfiglocal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" + dependencies: + ini "^1.3.2" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob-stream@^3.1.5: + version "3.1.18" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" + dependencies: + glob "^4.3.1" + glob2base "^0.0.12" + minimatch "^2.0.1" + ordered-read-streams "^0.1.0" + through2 "^0.6.1" + unique-stream "^1.0.0" + +glob-stream@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-4.1.1.tgz#b842df10d688c7eb6bcfcebd846f3852296b3200" + dependencies: + glob "^4.3.1" + glob2base "^0.0.12" + minimatch "^2.0.1" + ordered-read-streams "^0.1.0" + through2 "^0.6.1" + unique-stream "^2.0.2" + +glob-watcher@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" + dependencies: + gaze "^0.5.1" + +glob-watcher@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.8.tgz#68aeb661e7e2ce8d3634381b2ec415f00c6bc2a4" + dependencies: + gaze "^0.5.1" + +glob2base@^0.0.12: + version "0.0.12" + resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" + dependencies: + find-index "^0.1.1" + +glob@3.2.11: + version "3.2.11" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" + dependencies: + inherits "2" + minimatch "0.3" + +glob@7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^4.3.1: + version "4.5.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "^2.0.1" + once "^1.3.0" + +glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@~7.1.1: + version "7.1.2" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~3.1.21: + version "3.1.21" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" + dependencies: + graceful-fs "~1.2.0" + inherits "1" + minimatch "~0.2.11" + +glob@~4.3.0: + version "4.3.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-4.3.5.tgz#80fbb08ca540f238acce5d11d1e9bc41e75173d3" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "^2.0.1" + once "^1.3.0" + +glob@~5.0.0: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +global-dirs@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" + dependencies: + ini "^1.3.4" + +global-modules@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea" + dependencies: + global-prefix "^1.0.1" + is-windows "^1.0.1" + resolve-dir "^1.0.0" + +global-prefix@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" + dependencies: + expand-tilde "^2.0.2" + homedir-polyfill "^1.0.1" + ini "^1.3.4" + is-windows "^1.0.1" + which "^1.2.14" + +globby@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + dependencies: + array-union "^1.0.1" + arrify "^1.0.0" + glob "^7.0.3" + object-assign "^4.0.1" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +globule@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/globule/-/globule-1.2.0.tgz#1dc49c6822dd9e8a2fa00ba2a295006e8664bd09" + dependencies: + glob "~7.1.1" + lodash "~4.17.4" + minimatch "~3.0.2" + +globule@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" + dependencies: + glob "~3.1.21" + lodash "~1.0.1" + minimatch "~0.2.11" + +glogg@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.1.tgz#dcf758e44789cc3f3d32c1f3562a3676e6a34810" + dependencies: + sparkles "^1.0.0" + +google-closure-compiler@^20170409.0.0: + version "20170409.0.0" + resolved "https://registry.yarnpkg.com/google-closure-compiler/-/google-closure-compiler-20170409.0.0.tgz#dc1be29a9f7eef8611364533b271b9fac757c970" + dependencies: + chalk "^1.0.0" + vinyl "^2.0.1" + vinyl-sourcemaps-apply "^0.2.0" + +got@^6.7.1: + version "6.7.1" + resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" + dependencies: + create-error-class "^3.0.0" + duplexer3 "^0.1.4" + get-stream "^3.0.0" + is-redirect "^1.0.0" + is-retry-allowed "^1.0.0" + is-stream "^1.0.0" + lowercase-keys "^1.0.0" + safe-buffer "^5.0.1" + timed-out "^4.0.0" + unzip-response "^2.0.1" + url-parse-lax "^1.0.0" + +graceful-fs@^3.0.0: + version "3.0.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" + dependencies: + natives "^1.1.0" + +graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: + version "4.1.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + +graceful-fs@~1.2.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +growl@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + +gulp-clang-format@^1.0.25: + version "1.0.25" + resolved "https://registry.yarnpkg.com/gulp-clang-format/-/gulp-clang-format-1.0.25.tgz#5176567b9f72067bfb55c9204c8ef03115c3ff49" + dependencies: + clang-format "^1.0.32" + gulp-diff "^1.0.0" + gulp-util "^3.0.4" + pkginfo "^0.3.0" + stream-combiner2 "^1.1.1" + stream-equal "0.1.6" + through2 "^0.6.3" + +gulp-conventional-changelog@^1.1.7: + version "1.1.16" + resolved "https://registry.yarnpkg.com/gulp-conventional-changelog/-/gulp-conventional-changelog-1.1.16.tgz#c1b4295a7e340afec441b47f8a8fce7eea12cd13" + dependencies: + add-stream "^1.0.0" + concat-stream "^1.5.0" + conventional-changelog "^1.1.16" + fancy-log "^1.3.2" + object-assign "^4.0.1" + plugin-error "^1.0.1" + through2 "^2.0.0" + +gulp-diff@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gulp-diff/-/gulp-diff-1.0.0.tgz#101b23712dd6b107bd07d05ab88ea3ac485fed77" + dependencies: + cli-color "^1.0.0" + diff "^2.0.2" + event-stream "^3.1.5" + gulp-util "^3.0.6" + through2 "^2.0.0" + +gulp-rename@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.2.2.tgz#3ad4428763f05e2764dec1c67d868db275687817" + +gulp-rollup@^2.16.1: + version "2.16.2" + resolved "https://registry.yarnpkg.com/gulp-rollup/-/gulp-rollup-2.16.2.tgz#1f805d3a3d808679fb545a683697eead73a93731" + dependencies: + buffer-from "^0.1.1" + plugin-error "^1.0.0" + readable-stream "^2.3.3" + rollup "^0.54.1" + rollup-plugin-hypothetical "^2.0.0" + vinyl "^2.1.0" + +gulp-tsc@^1.1.4: + version "1.3.2" + resolved "https://registry.yarnpkg.com/gulp-tsc/-/gulp-tsc-1.3.2.tgz#5a66f80af3976005e6f5f06b9cfccb0e6d7399ce" + dependencies: + async "^1.4.2" + byline "^4.1.1" + gulp-util "^3.0.1" + lodash "^3.2.0" + node-version-compare "^1.0.1" + resolve "^1.0.0" + rimraf "^2.2.6" + temp "^0.8.1" + through2 "^2.0.0" + vinyl-fs "^1.0.0" + which "^1.0.5" + +gulp-tslint@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/gulp-tslint/-/gulp-tslint-7.1.0.tgz#9bd3ff4fbc16d4cbd9abb08ff786db89b563e93d" + dependencies: + gulp-util "~3.0.8" + map-stream "~0.1.0" + through "~2.3.8" + +gulp-uglify@^1.2.0: + version "1.5.4" + resolved "https://registry.yarnpkg.com/gulp-uglify/-/gulp-uglify-1.5.4.tgz#524788d87666d09f9d0c21fb2177f90039a658c9" + dependencies: + deap "^1.0.0" + fancy-log "^1.0.0" + gulp-util "^3.0.0" + isobject "^2.0.0" + through2 "^2.0.0" + uglify-js "2.6.4" + uglify-save-license "^0.4.1" + vinyl-sourcemaps-apply "^0.2.0" + +gulp-util@^3.0.0, gulp-util@^3.0.1, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-util@^3.0.7, gulp-util@~3.0.8: + version "3.0.8" + resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" + dependencies: + array-differ "^1.0.0" + array-uniq "^1.0.2" + beeper "^1.0.0" + chalk "^1.0.0" + dateformat "^2.0.0" + fancy-log "^1.1.0" + gulplog "^1.0.0" + has-gulplog "^0.1.0" + lodash._reescape "^3.0.0" + lodash._reevaluate "^3.0.0" + lodash._reinterpolate "^3.0.0" + lodash.template "^3.0.0" + minimist "^1.1.0" + multipipe "^0.1.2" + object-assign "^3.0.0" + replace-ext "0.0.1" + through2 "^2.0.0" + vinyl "^0.5.0" + +gulp@^3.8.11: + version "3.9.1" + resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" + dependencies: + archy "^1.0.0" + chalk "^1.0.0" + deprecated "^0.0.1" + gulp-util "^3.0.0" + interpret "^1.0.0" + liftoff "^2.1.0" + minimist "^1.1.0" + orchestrator "^0.3.0" + pretty-hrtime "^1.0.0" + semver "^4.1.0" + tildify "^1.0.0" + v8flags "^2.0.2" + vinyl-fs "^0.3.0" + +gulplog@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gulplog/-/gulplog-1.0.0.tgz#e28c4d45d05ecbbed818363ce8f9c5926229ffe5" + dependencies: + glogg "^1.0.0" + +handlebars@^4.0.2: + version "4.0.11" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" + dependencies: + async "^1.4.0" + optimist "^0.6.1" + source-map "^0.4.4" + optionalDependencies: + uglify-js "^2.6" + +har-schema@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + +har-schema@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + +har-validator@^1.4.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-1.8.0.tgz#d83842b0eb4c435960aeb108a067a3aa94c0eeb2" + dependencies: + bluebird "^2.9.30" + chalk "^1.0.0" + commander "^2.8.1" + is-my-json-valid "^2.12.0" + +har-validator@~2.0.2: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +har-validator@~4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + dependencies: + ajv "^4.9.1" + har-schema "^1.0.5" + +har-validator@~5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + dependencies: + ajv "^5.1.0" + har-schema "^2.0.0" + +has-ansi@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" + dependencies: + ansi-regex "^0.2.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-binary@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/has-binary/-/has-binary-0.1.7.tgz#68e61eb16210c9545a0a5cce06a873912fe1e68c" + dependencies: + isarray "0.0.1" + +has-cors@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" + +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + +has-flag@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + +has-gulplog@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" + dependencies: + sparkles "^1.0.0" + +has-own-property-x@^3.1.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/has-own-property-x/-/has-own-property-x-3.2.0.tgz#1c4b112a577c8cb5805469556e54b6e959e4ded9" + dependencies: + cached-constructors-x "^1.0.0" + to-object-x "^1.5.0" + to-property-key-x "^2.0.2" + +has-symbol-support-x@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz#66ec2e377e0c7d7ccedb07a3a84d77510ff1bc4c" + +has-to-string-tag-x@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + dependencies: + has-symbol-support-x "^1.4.1" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +hasha@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" + dependencies: + is-stream "^1.0.1" + pinkie-promise "^2.0.0" + +hawk@3.1.3, hawk@~3.1.0, hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hawk@~2.3.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-2.3.1.tgz#1e731ce39447fa1d0f6d707f7bceebec0fd1ec1f" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hawk@~6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + dependencies: + boom "4.x.x" + cryptiles "3.x.x" + hoek "4.x.x" + sntp "2.x.x" + +he@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +hoek@4.x.x: + version "4.2.1" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb" + +homedir-polyfill@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc" + dependencies: + parse-passwd "^1.0.0" + +hosted-git-info@^2.1.4: + version "2.5.0" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" + +http-errors@1.6.2, http-errors@~1.6.2: + version "1.6.2" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + dependencies: + depd "1.1.1" + inherits "2.0.3" + setprototypeof "1.0.3" + statuses ">= 1.3.1 < 2" + +http-proxy@^1.13.0: + version "1.16.2" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742" + dependencies: + eventemitter3 "1.x.x" + requires-port "1.x.x" + +http-signature@~0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-0.10.1.tgz#4fbdac132559aa8323121e540779c0a012b27e66" + dependencies: + asn1 "0.1.11" + assert-plus "^0.1.5" + ctype "0.5.3" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +http-signature@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + dependencies: + assert-plus "^1.0.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +iconv-lite@0.4.19, iconv-lite@^0.4.17: + version "0.4.19" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + +import-lazy@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +indexof@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" + +infinity-x@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/infinity-x/-/infinity-x-1.0.0.tgz#cea2d75181d820961b0f72d78e7c4e06fdd55a07" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" + +inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + +ini@^1.3.2, ini@^1.3.4, ini@~1.3.0: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + +inquirer@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^2.0.4" + figures "^2.0.0" + lodash "^4.3.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" + through "^2.3.6" + +interpret@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" + +is-absolute@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" + dependencies: + is-relative "^1.0.0" + is-windows "^1.0.1" + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + dependencies: + kind-of "^6.0.0" + +is-array-buffer-x@^1.0.13: + version "1.7.0" + resolved "https://registry.yarnpkg.com/is-array-buffer-x/-/is-array-buffer-x-1.7.0.tgz#4b0b10427b64aa3437767adf4fc07702c59b2371" + dependencies: + attempt-x "^1.1.0" + has-to-string-tag-x "^1.4.1" + is-object-like-x "^1.5.1" + object-get-own-property-descriptor-x "^3.2.0" + to-string-tag-x "^1.4.1" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + dependencies: + kind-of "^6.0.0" + +is-date-object@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-dotfile@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-extglob@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + +is-falsey-x@^1.0.0, is-falsey-x@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-falsey-x/-/is-falsey-x-1.0.1.tgz#c469951adc95b8b3fdbf90929b335a7de937d17f" + dependencies: + to-boolean-x "^1.0.1" + +is-finite-x@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/is-finite-x/-/is-finite-x-3.0.2.tgz#a6ec683cfb2bc1a918a1ff59d178edbcea54f7a6" + dependencies: + infinity-x "^1.0.0" + is-nan-x "^1.0.1" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + +is-function-x@^3.2.0, is-function-x@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/is-function-x/-/is-function-x-3.3.0.tgz#7d16bc113853db206d5e40a8b32caf99bd4ff7c0" + dependencies: + attempt-x "^1.1.1" + has-to-string-tag-x "^1.4.1" + is-falsey-x "^1.0.1" + is-primitive "^2.0.0" + normalize-space-x "^3.0.0" + replace-comments-x "^2.0.0" + to-boolean-x "^1.0.1" + to-string-tag-x "^1.4.2" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + dependencies: + is-extglob "^2.1.0" + +is-index-x@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-index-x/-/is-index-x-1.1.0.tgz#43dac97b3a04f30191530833f45ac35001682ee2" + dependencies: + math-clamp-x "^1.2.0" + max-safe-integer "^1.0.1" + to-integer-x "^3.0.0" + to-number-x "^2.0.0" + to-string-symbols-supported-x "^1.0.0" + +is-installed-globally@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" + dependencies: + global-dirs "^0.1.0" + is-path-inside "^1.0.0" + +is-my-ip-valid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" + +is-my-json-valid@^2.12.0, is-my-json-valid@^2.12.4: + version "2.17.2" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz#6b2103a288e94ef3de5cf15d29dd85fc4b78d65c" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + is-my-ip-valid "^1.0.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-nan-x@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-nan-x/-/is-nan-x-1.0.1.tgz#de747ebcc8bddeb66f367c17caca7eba843855c0" + +is-nil-x@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/is-nil-x/-/is-nil-x-1.4.1.tgz#bd9e7b08b4cd732f9dcbde13d93291bb2ec2e248" + dependencies: + lodash.isnull "^3.0.0" + validate.io-undefined "^1.0.3" + +is-npm@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" + +is-number@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" + +is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + +is-number@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff" + +is-obj@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + +is-object-like-x@^1.5.1: + version "1.6.0" + resolved "https://registry.yarnpkg.com/is-object-like-x/-/is-object-like-x-1.6.0.tgz#a8c4a95bd6b95db174e0e4730171a160ec73be82" + dependencies: + is-function-x "^3.3.0" + is-primitive "^2.0.0" + +is-odd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-2.0.0.tgz#7646624671fd7ea558ccd9a2795182f2958f1b24" + dependencies: + is-number "^4.0.0" + +is-path-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + +is-path-in-cwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" + dependencies: + is-path-inside "^1.0.0" + +is-path-inside@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" + dependencies: + path-is-inside "^1.0.1" + +is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + dependencies: + isobject "^3.0.1" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-promise@^2.1, is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-redirect@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" + +is-relative@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d" + dependencies: + is-unc-path "^1.0.0" + +is-retry-allowed@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" + +is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-string@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.4.tgz#cc3a9b69857d621e963725a24caeec873b826e64" + +is-subset@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" + +is-symbol@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + +is-text-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" + dependencies: + text-extensions "^1.0.0" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-unc-path@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-1.0.0.tgz#d731e8898ed090a12c352ad2eaed5095ad322c9d" + dependencies: + unc-path-regex "^0.1.2" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +is-windows@^1.0.1, is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isarray@1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isbinaryfile@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.2.tgz#4a3e974ec0cba9004d3fc6cde7209ea69368a621" + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + +isstream@~0.1.1, isstream@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jade@0.26.3: + version "0.26.3" + resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" + dependencies: + commander "0.6.1" + mkdirp "0.3.0" + +jasmine-core@^2.9.1, jasmine-core@~2.99.0: + version "2.99.1" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15" + +jasmine@^2.9.1: + version "2.99.0" + resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.99.0.tgz#8ca72d102e639b867c6489856e0e18a9c7aa42b7" + dependencies: + exit "^0.1.2" + glob "^7.0.6" + jasmine-core "~2.99.0" + +js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + +jsbn@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + +json-schema-traverse@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.0, json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json3@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + +json5@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + +jsonfile@^2.1.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + optionalDependencies: + graceful-fs "^4.1.6" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonparse@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + +jsonpointer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + +jsprim@^1.2.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + dependencies: + assert-plus "1.0.0" + extsprintf "1.3.0" + json-schema "0.2.3" + verror "1.10.0" + +jszip@^3.1.3: + version "3.1.5" + resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.1.5.tgz#e3c2a6c6d706ac6e603314036d43cd40beefdf37" + dependencies: + core-js "~2.3.0" + es6-promise "~3.0.2" + lie "~3.1.0" + pako "~1.0.2" + readable-stream "~2.0.6" + +karma-chrome-launcher@^0.2.1: + version "0.2.3" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-0.2.3.tgz#4c6d700d163a9d34c618efd87918be49e7a4a8c9" + dependencies: + fs-access "^1.0.0" + which "^1.2.1" + +karma-firefox-launcher@^0.1.4: + version "0.1.7" + resolved "https://registry.yarnpkg.com/karma-firefox-launcher/-/karma-firefox-launcher-0.1.7.tgz#c05dd86533691e62f31952595098e8bd357d39f3" + +karma-jasmine@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.1.tgz#6fe840e75a11600c9d91e84b33c458e1c46a3529" + +karma-mocha@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-1.3.0.tgz#eeaac7ffc0e201eb63c467440d2b69c7cf3778bf" + dependencies: + minimist "1.2.0" + +karma-phantomjs-launcher@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2" + dependencies: + lodash "^4.0.1" + phantomjs-prebuilt "^2.1.7" + +karma-safari-launcher@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/karma-safari-launcher/-/karma-safari-launcher-0.1.1.tgz#a6380accab60a583fdd624f41b9a3f10fdf41008" + +karma-sauce-launcher@^0.2.10: + version "0.2.14" + resolved "https://registry.yarnpkg.com/karma-sauce-launcher/-/karma-sauce-launcher-0.2.14.tgz#e42e412517c5f40534c8bba7d14bb4f10727b6a7" + dependencies: + q "~0.9.6" + sauce-connect-launcher "~0.11.1" + saucelabs "~0.1.0" + wd "~0.3.4" + +karma-sourcemap-loader@^0.3.6: + version "0.3.7" + resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz#91322c77f8f13d46fed062b042e1009d4c4505d8" + dependencies: + graceful-fs "^4.1.2" + +karma@^0.13.14: + version "0.13.22" + resolved "https://registry.yarnpkg.com/karma/-/karma-0.13.22.tgz#07750b1bd063d7e7e7b91bcd2e6354d8f2aa8744" + dependencies: + batch "^0.5.3" + bluebird "^2.9.27" + body-parser "^1.12.4" + chokidar "^1.4.1" + colors "^1.1.0" + connect "^3.3.5" + core-js "^2.1.0" + di "^0.0.1" + dom-serialize "^2.2.0" + expand-braces "^0.1.1" + glob "^7.0.0" + graceful-fs "^4.1.2" + http-proxy "^1.13.0" + isbinaryfile "^3.0.0" + lodash "^3.8.0" + log4js "^0.6.31" + mime "^1.3.4" + minimatch "^3.0.0" + optimist "^0.6.1" + rimraf "^2.3.3" + socket.io "^1.4.5" + source-map "^0.5.3" + useragent "^2.1.6" + +kew@^0.7.0, kew@~0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" + +klaw@^1.0.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + optionalDependencies: + graceful-fs "^4.1.9" + +latest-version@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" + dependencies: + package-json "^4.0.0" + +lazy-cache@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + +lazy-cache@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-2.0.2.tgz#b9190a4f913354694840859f8a8f7084d8822264" + dependencies: + set-getter "^0.1.0" + +lazystream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" + dependencies: + readable-stream "^2.0.5" + +lazystream@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-0.1.0.tgz#1b25d63c772a4c20f0a5ed0a9d77f484b6e16920" + dependencies: + readable-stream "~1.0.2" + +lie@~3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + dependencies: + immediate "~3.0.5" + +liftoff@^2.1.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.5.0.tgz#2009291bb31cea861bbf10a7c15a28caf75c31ec" + dependencies: + extend "^3.0.0" + findup-sync "^2.0.0" + fined "^1.0.1" + flagged-respawn "^1.0.0" + is-plain-object "^2.0.4" + object.map "^1.0.0" + rechoir "^0.6.2" + resolve "^1.1.7" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +loader-utils@^0.2.6: + version "0.2.17" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" + dependencies: + big.js "^3.1.3" + emojis-list "^2.0.0" + json5 "^0.5.0" + object-assign "^4.0.1" + +lodash._baseassign@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + dependencies: + lodash._basecopy "^3.0.0" + lodash.keys "^3.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basecreate@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + +lodash._basetostring@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" + +lodash._basevalues@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash._reescape@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reescape/-/lodash._reescape-3.0.0.tgz#2b1d6f5dfe07c8a355753e5f27fac7f1cde1616a" + +lodash._reevaluate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz#58bc74c40664953ae0b124d806996daca431e2ed" + +lodash._reinterpolate@^3.0.0, lodash._reinterpolate@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + +lodash._root@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" + +lodash.create@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" + dependencies: + lodash._baseassign "^3.0.0" + lodash._basecreate "^3.0.0" + lodash._isiterateecall "^3.0.0" + +lodash.escape@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-3.2.0.tgz#995ee0dc18c1b48cc92effae71a10aab5b487698" + dependencies: + lodash._root "^3.0.0" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.isnull@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash.isnull/-/lodash.isnull-3.0.0.tgz#fafbe59ea1dca27eed786534039dd84c2e07c56e" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.restparam@^3.0.0: + version "3.6.1" + resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + +lodash.template@^3.0.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-3.6.2.tgz#f8cdecc6169a255be9098ae8b0c53d378931d14f" + dependencies: + lodash._basecopy "^3.0.0" + lodash._basetostring "^3.0.0" + lodash._basevalues "^3.0.0" + lodash._isiterateecall "^3.0.0" + lodash._reinterpolate "^3.0.0" + lodash.escape "^3.0.0" + lodash.keys "^3.0.0" + lodash.restparam "^3.0.0" + lodash.templatesettings "^3.0.0" + +lodash.template@^4.0.2: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" + dependencies: + lodash._reinterpolate "~3.0.0" + lodash.templatesettings "^4.0.0" + +lodash.templatesettings@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz#fb307844753b66b9f1afa54e262c745307dba8e5" + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.escape "^3.0.0" + +lodash.templatesettings@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" + dependencies: + lodash._reinterpolate "~3.0.0" + +lodash@3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.5.0.tgz#19bb3f4d51278f0b8c818ed145c74ecf9fe40e6d" + +lodash@^3.2.0, lodash@^3.8.0: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + +lodash@^4.0.0, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.8.0, lodash@~4.17.4: + version "4.17.5" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" + +lodash@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" + +lodash@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.2.0.tgz#4bf50a3243f9aeb0bac41a55d3d5990675a462fb" + +lodash@~3.9.3: + version "3.9.3" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.9.3.tgz#0159e86832feffc6d61d852b12a953b99496bd32" + +log4js@^0.6.31: + version "0.6.38" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-0.6.38.tgz#2c494116695d6fb25480943d3fc872e662a522fd" + dependencies: + readable-stream "~1.0.2" + semver "~4.3.3" + +lolex@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" + +longest@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +lowercase-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" + +lru-cache@2, lru-cache@^2.5.0: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + +lru-cache@4.1.x, lru-cache@^4.0.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" + dependencies: + pseudomap "^1.0.2" + yallist "^2.1.2" + +lru-queue@0.1: + version "0.1.0" + resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + dependencies: + es5-ext "~0.10.2" + +make-dir@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.2.0.tgz#6d6a49eead4aae296c53bbf3a1a008bd6c89469b" + dependencies: + pify "^3.0.0" + +make-iterator@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-1.0.0.tgz#57bef5dc85d23923ba23767324d8e8f8f3d9694b" + dependencies: + kind-of "^3.1.0" + +map-cache@^0.2.0, map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +map-stream@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + dependencies: + object-visit "^1.0.0" + +math-clamp-x@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/math-clamp-x/-/math-clamp-x-1.2.0.tgz#8b537be0645bbba7ee73ee16091e7d6018c5edcf" + dependencies: + to-number-x "^2.0.0" + +math-sign-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/math-sign-x/-/math-sign-x-3.0.0.tgz#d5286022b48e150c384729a86042e0835264c3ed" + dependencies: + is-nan-x "^1.0.1" + to-number-x "^2.0.0" + +max-safe-integer@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/max-safe-integer/-/max-safe-integer-1.0.1.tgz#f38060be2c563d8c02e6d48af39122fd83b6f410" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + +memoizee@^0.4.3: + version "0.4.11" + resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.11.tgz#bde9817663c9e40fdb2a4ea1c367296087ae8c8f" + dependencies: + d "1" + es5-ext "^0.10.30" + es6-weak-map "^2.0.2" + event-emitter "^0.3.5" + is-promise "^2.1" + lru-queue "0.1" + next-tick "1" + timers-ext "^0.1.2" + +memory-fs@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" + +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +merge-stream@^0.1.7: + version "0.1.8" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-0.1.8.tgz#48a07b3b4a121d74a3edbfdcdb4b08adbf0240b1" + dependencies: + through2 "^0.6.1" + +micromatch@^2.1.5: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +micromatch@^3.0.4: + version "3.1.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.8.tgz#5c8caa008de588eebb395e8c0ad12c128f25fff1" + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +mime-db@~1.12.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.12.0.tgz#3d0c63180f458eb10d325aaa37d7c58ae312e9d7" + +mime-db@~1.33.0: + version "1.33.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" + +mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.7: + version "2.1.18" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" + dependencies: + mime-db "~1.33.0" + +mime-types@~2.0.1, mime-types@~2.0.3: + version "2.0.14" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.0.14.tgz#310e159db23e077f8bb22b748dabfa4957140aa6" + dependencies: + mime-db "~1.12.0" + +mime@^1.3.4: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + +mimic-fn@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + +minimatch@0.3: + version "0.3.0" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + dependencies: + brace-expansion "^1.1.7" + +minimatch@^2.0.1: + version "2.0.10" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" + dependencies: + brace-expansion "^1.0.0" + +minimatch@~0.2.11: + version "0.2.14" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@~0.0.1: + version "0.0.10" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + +mixin-deep@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" + +mkdirp@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" + dependencies: + minimist "0.0.8" + +mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +mocha@^2.5.3: + version "2.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58" + dependencies: + commander "2.3.0" + debug "2.2.0" + diff "1.4.0" + escape-string-regexp "1.0.2" + glob "3.2.11" + growl "1.9.2" + jade "0.26.3" + mkdirp "0.5.1" + supports-color "1.2.0" + to-iso-string "0.0.2" + +mocha@^3.1.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.3.tgz#1e0480fe36d2da5858d1eb6acc38418b26eaa20d" + dependencies: + browser-stdout "1.3.0" + commander "2.9.0" + debug "2.6.8" + diff "3.2.0" + escape-string-regexp "1.0.5" + glob "7.1.1" + growl "1.9.2" + he "1.1.1" + json3 "3.3.2" + lodash.create "3.1.1" + mkdirp "0.5.1" + supports-color "3.1.2" + +modify-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.0.tgz#e2b6cdeb9ce19f99317a53722f3dbf5df5eaaab2" + +moment@^2.11.2: + version "2.20.1" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +ms@0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + +multipipe@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-0.1.2.tgz#2a8f2ddf70eed564dff2d57f1e1a137d9f05078b" + dependencies: + duplexer2 "0.0.2" + +mute-stream@0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" + +nan-x@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/nan-x/-/nan-x-1.0.0.tgz#0ee78e8d1cd0592d5b4260a5940154545c61c121" + +nan@^2.3.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" + +nanomatch@^1.2.9: + version "1.2.9" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.9.tgz#879f7150cb2dab7a471259066c104eee6e0fa7c2" + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-odd "^2.0.0" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +natives@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.1.tgz#011acce1f7cbd87f7ba6b3093d6cd9392be1c574" + +negotiator@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + +next-tick@1: + version "1.0.0" + resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + +node-int64@~0.3.0: + version "0.3.3" + resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.3.3.tgz#2d6e6b2ece5de8588b43d88d1bc41b26cd1fa84d" + +node-pre-gyp@^0.6.39: + version "0.6.39" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" + dependencies: + detect-libc "^1.0.2" + hawk "3.1.3" + mkdirp "^0.5.1" + nopt "^4.0.1" + npmlog "^4.0.2" + rc "^1.1.7" + request "2.81.0" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^2.2.1" + tar-pack "^3.4.0" + +node-uuid@~1.4.0, node-uuid@~1.4.7: + version "1.4.8" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + +node-version-compare@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/node-version-compare/-/node-version-compare-1.0.1.tgz#d85bfd20f0acade33577f56682c7109c34c550cd" + +nodejs-websocket@^1.2.0: + version "1.7.1" + resolved "https://registry.yarnpkg.com/nodejs-websocket/-/nodejs-websocket-1.7.1.tgz#cccfbba823bf1cfa9680f168ab7ab53121e48410" + +nopt@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + dependencies: + abbrev "1" + osenv "^0.1.4" + +normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5: + version "2.4.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^2.0.0, normalize-path@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + dependencies: + remove-trailing-separator "^1.0.1" + +normalize-space-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-space-x/-/normalize-space-x-3.0.0.tgz#17907d6c7c724a4f9567471cbb319553bc0f8882" + dependencies: + cached-constructors-x "^1.0.0" + trim-x "^3.0.0" + white-space-x "^3.0.0" + +npm-install-package@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/npm-install-package/-/npm-install-package-2.1.0.tgz#d7efe3cfcd7ab00614b896ea53119dc9ab259125" + +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + dependencies: + path-key "^2.0.0" + +npmlog@^4.0.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.7.3" + set-blocking "~2.0.0" + +null-check@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.6.0.tgz#7dbeae44f6ca454e1f168451d630746735813ce3" + +oauth-sign@~0.8.0, oauth-sign@~0.8.1, oauth-sign@~0.8.2: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + +object-assign@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa" + +object-assign@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" + +object-assign@^4.0.1, object-assign@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + +object-component@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-get-own-property-descriptor-x@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/object-get-own-property-descriptor-x/-/object-get-own-property-descriptor-x-3.2.0.tgz#464585ad03e66108ed166c99325b8d2c5ba93712" + dependencies: + attempt-x "^1.1.0" + has-own-property-x "^3.1.1" + has-symbol-support-x "^1.4.1" + is-falsey-x "^1.0.0" + is-index-x "^1.0.0" + is-primitive "^2.0.0" + is-string "^1.0.4" + property-is-enumerable-x "^1.1.0" + to-object-x "^1.4.1" + to-property-key-x "^2.0.1" + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + dependencies: + isobject "^3.0.0" + +object.defaults@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/object.defaults/-/object.defaults-1.1.0.tgz#3a7f868334b407dea06da16d88d5cd29e435fecf" + dependencies: + array-each "^1.0.1" + array-slice "^1.0.0" + for-own "^1.0.0" + isobject "^3.0.0" + +object.map@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object.map/-/object.map-1.0.1.tgz#cf83e59dc8fcc0ad5f4250e1f78b3b81bd801d37" + dependencies: + for-own "^1.0.0" + make-iterator "^1.0.0" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +object.pick@^1.2.0, object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + dependencies: + isobject "^3.0.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + dependencies: + ee-first "1.1.1" + +once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +once@~1.3.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + dependencies: + wrappy "1" + +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + dependencies: + mimic-fn "^1.0.0" + +optimist@^0.6.1, optimist@~0.6.0, optimist@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + dependencies: + minimist "~0.0.1" + wordwrap "~0.0.2" + +options@>=0.0.5: + version "0.0.6" + resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" + +orchestrator@^0.3.0: + version "0.3.8" + resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e" + dependencies: + end-of-stream "~0.1.5" + sequencify "~0.0.7" + stream-consume "~0.1.0" + +ordered-read-streams@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" + +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-tmpdir@^1.0.0, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + +package-json@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" + dependencies: + got "^6.7.1" + registry-auth-token "^3.0.1" + registry-url "^3.0.3" + semver "^5.1.0" + +pako@~1.0.2: + version "1.0.6" + resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" + +parse-filepath@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.2.tgz#a632127f53aaf3d15876f5872f3ffac763d6c891" + dependencies: + is-absolute "^1.0.0" + map-cache "^0.2.0" + path-root "^0.1.1" + +parse-github-repo-url@^1.3.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +parse-int-x@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/parse-int-x/-/parse-int-x-2.0.0.tgz#9f979d4115930df2f4706a41810b9c712405552f" + dependencies: + cached-constructors-x "^1.0.0" + nan-x "^1.0.0" + to-string-x "^1.4.2" + trim-left-x "^3.0.0" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +parse-passwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" + +parsejson@0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/parsejson/-/parsejson-0.0.3.tgz#ab7e3759f209ece99437973f7d0f1f64ae0e64ab" + dependencies: + better-assert "~1.0.0" + +parseqs@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" + dependencies: + better-assert "~1.0.0" + +parseuri@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" + dependencies: + better-assert "~1.0.0" + +parseurl@~1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-is-inside@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + +path-root-regex@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" + +path-root@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7" + dependencies: + path-root-regex "^0.1.0" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +pause-stream@0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" + dependencies: + through "~2.3" + +pend@~1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + +performance-now@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + +performance-now@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + +phantomjs-prebuilt@^2.1.7: + version "2.1.16" + resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" + dependencies: + es6-promise "^4.0.3" + extract-zip "^1.6.5" + fs-extra "^1.0.0" + hasha "^2.2.0" + kew "^0.7.0" + progress "^1.1.8" + request "^2.81.0" + request-progress "^2.0.1" + which "^1.2.10" + +phantomjs@^2.1.7: + version "2.1.7" + resolved "https://registry.yarnpkg.com/phantomjs/-/phantomjs-2.1.7.tgz#c6910f67935c37285b6114329fc2f27d5f3e3134" + dependencies: + extract-zip "~1.5.0" + fs-extra "~0.26.4" + hasha "^2.2.0" + kew "~0.7.0" + progress "~1.1.8" + request "~2.67.0" + request-progress "~2.0.1" + which "~1.2.2" + +pify@^2.0.0, pify@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +pkginfo@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21" + +plugin-error@^1.0.0, plugin-error@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c" + dependencies: + ansi-colors "^1.0.1" + arr-diff "^4.0.0" + arr-union "^3.1.0" + extend-shallow "^3.0.2" + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + +prepend-http@^1.0.1: + version "1.0.4" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +pretty-hrtime@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" + +process-nextick-args@^1.0.6, process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + +progress@^1.1.8, progress@~1.1.8: + version "1.1.8" + resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + +promises-aplus-tests@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/promises-aplus-tests/-/promises-aplus-tests-2.1.2.tgz#76b7c5638968720861969cfbcd8795afd274885c" + dependencies: + mocha "^2.5.3" + sinon "^1.10.3" + underscore "~1.8.3" + +property-is-enumerable-x@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/property-is-enumerable-x/-/property-is-enumerable-x-1.1.0.tgz#7ca48917476cd0914b37809bfd05776a0d942f6f" + dependencies: + to-object-x "^1.4.1" + to-property-key-x "^2.0.1" + +pseudomap@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + +pump@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +q@^1.4.1, q@~1.5.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" + +q@~0.9.6: + version "0.9.7" + resolved "https://registry.yarnpkg.com/q/-/q-0.9.7.tgz#4de2e6cb3b29088c9e4cbc03bf9d42fb96ce2f75" + +q@~1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e" + +qs@6.5.1, qs@~6.5.1: + version "6.5.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + +qs@~2.4.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-2.4.2.tgz#f7ce788e5777df0b5010da7f7c4e73ba32470f5a" + +qs@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.1.tgz#801fee030e0b9450d6385adc48a4cc55b44aedfc" + +qs@~6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + +randomatic@^1.1.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +raw-body@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + dependencies: + bytes "3.0.0" + http-errors "1.6.2" + iconv-lite "0.4.19" + unpipe "1.0.0" + +rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: + version "1.2.5" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.5.tgz#275cd687f6e3b36cc756baa26dfee80a790301fd" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0, read-pkg@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.2, readable-stream@~1.0.24, readable-stream@~1.0.26, readable-stream@~1.0.33: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3: + version "2.3.4" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.4.tgz#c946c3f47fa7d8eabc0b6150f4a12f69a4574071" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.0.3" + util-deprecate "~1.0.1" + +readable-stream@~1.1.9: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@~2.0.0, readable-stream@~2.0.5, readable-stream@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +regex-cache@^0.4.2: + version "0.4.4" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" + dependencies: + is-equal-shallow "^0.1.3" + +regex-not@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +registry-auth-token@^3.0.1: + version "3.3.2" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.2.tgz#851fd49038eecb586911115af845260eec983f20" + dependencies: + rc "^1.1.6" + safe-buffer "^5.0.1" + +registry-url@^3.0.3: + version "3.1.0" + resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" + dependencies: + rc "^1.0.1" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-0.2.2.tgz#c7a8d3236068362059a7e4651fc6884e8b1fb4ae" + +repeat-string@^1.5.2, repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +replace-comments-x@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/replace-comments-x/-/replace-comments-x-2.0.0.tgz#a5cec18efd912aad78a7c3c4b69d01768556d140" + dependencies: + require-coercible-to-string-x "^1.0.0" + to-string-x "^1.4.2" + +replace-ext@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" + +replace-ext@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" + +request-progress@^2.0.1, request-progress@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08" + dependencies: + throttleit "^1.0.0" + +request@2.81.0: + version "2.81.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~4.2.1" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + qs "~6.4.0" + safe-buffer "^5.0.1" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + +request@^2.78.0, request@^2.81.0, request@~2.83.0: + version "2.83.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + dependencies: + aws-sign2 "~0.7.0" + aws4 "^1.6.0" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.1" + forever-agent "~0.6.1" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" + tunnel-agent "^0.6.0" + uuid "^3.1.0" + +request@~2.55.0: + version "2.55.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.55.0.tgz#d75c1cdf679d76bb100f9bffe1fe551b5c24e93d" + dependencies: + aws-sign2 "~0.5.0" + bl "~0.9.0" + caseless "~0.9.0" + combined-stream "~0.0.5" + forever-agent "~0.6.0" + form-data "~0.2.0" + har-validator "^1.4.0" + hawk "~2.3.0" + http-signature "~0.10.0" + isstream "~0.1.1" + json-stringify-safe "~5.0.0" + mime-types "~2.0.1" + node-uuid "~1.4.0" + oauth-sign "~0.6.0" + qs "~2.4.0" + stringstream "~0.0.4" + tough-cookie ">=0.12.0" + tunnel-agent "~0.4.0" + +request@~2.67.0: + version "2.67.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.67.0.tgz#8af74780e2bf11ea0ae9aa965c11f11afd272742" + dependencies: + aws-sign2 "~0.6.0" + bl "~1.0.0" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~1.0.0-rc3" + har-validator "~2.0.2" + hawk "~3.1.0" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + node-uuid "~1.4.7" + oauth-sign "~0.8.0" + qs "~5.2.0" + stringstream "~0.0.4" + tough-cookie "~2.2.0" + tunnel-agent "~0.4.1" + +require-coercible-to-string-x@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/require-coercible-to-string-x/-/require-coercible-to-string-x-1.0.0.tgz#367b3e9ca67e00324c411b0b498453a74cd5569e" + dependencies: + require-object-coercible-x "^1.4.1" + to-string-x "^1.4.2" + +require-object-coercible-x@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/require-object-coercible-x/-/require-object-coercible-x-1.4.1.tgz#75b9fb5bda2d15cf705a5714f108e8b40ca3eb2e" + dependencies: + is-nil-x "^1.4.1" + +requires-port@1.x.x: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + +resolve-dir@^1.0.0, resolve-dir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-1.0.1.tgz#79a40644c362be82f26effe739c9bb5382046f43" + dependencies: + expand-tilde "^2.0.0" + global-modules "^1.0.0" + +resolve-url@^0.2.1, resolve-url@~0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + +resolve@^1.0.0, resolve@^1.1.6, resolve@^1.1.7: + version "1.5.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" + dependencies: + path-parse "^1.0.5" + +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" + dependencies: + onetime "^2.0.0" + signal-exit "^3.0.2" + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + +rgb2hex@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/rgb2hex/-/rgb2hex-0.1.0.tgz#ccd55f860ae0c5c4ea37504b958e442d8d12325b" + +right-align@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + dependencies: + align-text "^0.1.1" + +rimraf@2, rimraf@^2.2.6, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + dependencies: + glob "^7.0.5" + +rimraf@2.2.6: + version "2.2.6" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.6.tgz#c59597569b14d956ad29cacc42bdddf5f0ea4f4c" + +rimraf@~2.2.6: + version "2.2.8" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" + +rollup-plugin-hypothetical@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-hypothetical/-/rollup-plugin-hypothetical-2.1.0.tgz#7fec9a865ed7d0eac14ca6ee2b2c4088acdb1955" + +rollup@^0.54.1: + version "0.54.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.54.1.tgz#415a5d999421502646cf54b873fc4ce1a7393970" + +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" + dependencies: + is-promise "^2.1.0" + +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" + +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + +rx@2.3.24: + version "2.3.24" + resolved "https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7" + +rxjs@^5.5.3: + version "5.5.6" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.6.tgz#e31fb96d6fd2ff1fd84bcea8ae9c02d007179c02" + dependencies: + symbol-observable "1.0.1" + +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + dependencies: + ret "~0.1.10" + +samsam@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" + +samsam@~1.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.3.tgz#9f5087419b4d091f232571e7fa52e90b0f552621" + +sauce-connect-launcher@~0.11.1: + version "0.11.1" + resolved "https://registry.yarnpkg.com/sauce-connect-launcher/-/sauce-connect-launcher-0.11.1.tgz#65f51d8891249fdabaaf17599734de1902476129" + dependencies: + adm-zip "~0.4.3" + async "0.9.0" + lodash "3.5.0" + rimraf "2.2.6" + +saucelabs@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-0.1.1.tgz#5e0ea1cf3d735d6ea15fde94b5bda6bc15d2c06d" + +sax@>=0.6.0: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + +selenium-webdriver@^3.4.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-3.6.0.tgz#2ba87a1662c020b8988c981ae62cb2a01298eafc" + dependencies: + jszip "^3.1.3" + rimraf "^2.5.4" + tmp "0.0.30" + xml2js "^0.4.17" + +semver-diff@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" + dependencies: + semver "^5.0.3" + +"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + +semver@^4.1.0, semver@~4.3.3: + version "4.3.6" + resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" + +sequencify@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-getter@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/set-getter/-/set-getter-0.1.0.tgz#d769c182c9d5a51f409145f2fba82e5e86e80376" + dependencies: + to-object-path "^0.3.0" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +set-value@^0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.1" + to-object-path "^0.3.0" + +set-value@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +setprototypeof@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + +sigmund@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + +signal-exit@^3.0.0, signal-exit@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + +sinon@^1.10.3: + version "1.17.7" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" + dependencies: + formatio "1.1.1" + lolex "1.3.2" + samsam "1.1.2" + util ">=0.10.3 <1" + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.1" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.1.tgz#e12b5487faded3e3dea0ac91e9400bf75b401370" + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^2.0.0" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +sntp@2.x.x: + version "2.1.0" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" + dependencies: + hoek "4.x.x" + +socket.io-adapter@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz#cb6d4bb8bec81e1078b99677f9ced0046066bb8b" + dependencies: + debug "2.3.3" + socket.io-parser "2.3.1" + +socket.io-client@1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.4.tgz#ec9f820356ed99ef6d357f0756d648717bdd4281" + dependencies: + backo2 "1.0.2" + component-bind "1.0.0" + component-emitter "1.2.1" + debug "2.3.3" + engine.io-client "~1.8.4" + has-binary "0.1.7" + indexof "0.0.1" + object-component "0.0.3" + parseuri "0.0.5" + socket.io-parser "2.3.1" + to-array "0.1.4" + +socket.io-parser@2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-2.3.1.tgz#dd532025103ce429697326befd64005fcfe5b4a0" + dependencies: + component-emitter "1.1.2" + debug "2.2.0" + isarray "0.0.1" + json3 "3.3.2" + +socket.io@^1.4.5: + version "1.7.4" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.4.tgz#2f7ecedc3391bf2d5c73e291fe233e6e34d4dd00" + dependencies: + debug "2.3.3" + engine.io "~1.8.4" + has-binary "0.1.7" + object-assign "4.1.0" + socket.io-adapter "0.5.0" + socket.io-client "1.7.4" + socket.io-parser "2.3.1" + +source-map-resolve@^0.3.0: + version "0.3.1" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.3.1.tgz#610f6122a445b8dd51535a2a71b783dfc1248761" + dependencies: + atob "~1.1.0" + resolve-url "~0.2.1" + source-map-url "~0.3.0" + urix "~0.1.0" + +source-map-resolve@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.1.tgz#7ad0f593f2281598e854df80f19aae4b92d7a11a" + dependencies: + atob "^2.0.0" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + +source-map-url@~0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.3.0.tgz#7ecaf13b57bcd09da8a40c5d269db33799d4aaf9" + +source-map@^0.1.38: + version "0.1.43" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" + dependencies: + amdefine ">=0.0.4" + +source-map@^0.4.4: + version "0.4.4" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + dependencies: + amdefine ">=0.0.4" + +source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +sparkles@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" + +spdx-correct@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + dependencies: + spdx-license-ids "^1.0.2" + +spdx-expression-parse@~1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + +spdx-license-ids@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + dependencies: + extend-shallow "^3.0.0" + +split2@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/split2/-/split2-2.2.0.tgz#186b2575bcf83e85b7d18465756238ee4ee42493" + dependencies: + through2 "^2.0.2" + +split@0.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + dependencies: + through "2" + +split@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" + dependencies: + through "2" + +sshpk@^1.7.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +"statuses@>= 1.3.1 < 2": + version "1.4.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + +statuses@~1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + +stream-combiner2@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.1.1.tgz#fb4d8a1420ea362764e21ad4780397bebcb41cbe" + dependencies: + duplexer2 "~0.1.0" + readable-stream "^2.0.2" + +stream-combiner@~0.0.4: + version "0.0.4" + resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" + dependencies: + duplexer "~0.1.1" + +stream-consume@~0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.1.tgz#d3bdb598c2bd0ae82b8cac7ac50b1107a7996c48" + +stream-equal@0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/stream-equal/-/stream-equal-0.1.6.tgz#cc522fab38516012e4d4ee47513b147b72359019" + +stream-shift@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" + +string-width@^1.0.1, string-width@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + dependencies: + is-fullwidth-code-point "^2.0.0" + strip-ansi "^4.0.0" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string_decoder@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + dependencies: + safe-buffer "~5.1.0" + +stringstream@~0.0.4, stringstream@~0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220" + dependencies: + ansi-regex "^0.2.1" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + dependencies: + ansi-regex "^3.0.0" + +strip-bom@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" + dependencies: + first-chunk-stream "^1.0.0" + is-utf8 "^0.2.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + +supports-color@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" + +supports-color@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + dependencies: + has-flag "^1.0.0" + +supports-color@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +supports-color@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.2.0.tgz#b0d5333b1184dd3666cbe5aa0b45c5ac7ac17a4a" + dependencies: + has-flag "^3.0.0" + +supports-color@~5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.0.1.tgz#1c5331f22250c84202805b2f17adf16699f3a39a" + dependencies: + has-flag "^2.0.0" + +symbol-observable@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" + +systemjs@^0.19.37: + version "0.19.47" + resolved "https://registry.yarnpkg.com/systemjs/-/systemjs-0.19.47.tgz#c8c93937180f3f5481c769cd2720763fb4a31c6f" + dependencies: + when "^3.7.5" + +tapable@^0.1.8: + version "0.1.10" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" + +tar-pack@^3.4.0: + version "3.4.1" + resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" + dependencies: + debug "^2.2.0" + fstream "^1.0.10" + fstream-ignore "^1.0.5" + once "^1.3.3" + readable-stream "^2.1.4" + rimraf "^2.5.1" + tar "^2.2.1" + uid-number "^0.0.6" + +tar-stream@^1.5.0: + version "1.5.5" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.5.5.tgz#5cad84779f45c83b1f2508d96b09d88c7218af55" + dependencies: + bl "^1.0.0" + end-of-stream "^1.0.0" + readable-stream "^2.0.0" + xtend "^4.0.0" + +tar-stream@~1.1.0: + version "1.1.5" + resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.1.5.tgz#be9218c130c20029e107b0f967fb23de0579d13c" + dependencies: + bl "^0.9.0" + end-of-stream "^1.0.0" + readable-stream "~1.0.33" + xtend "^4.0.0" + +tar@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +temp@^0.8.1: + version "0.8.3" + resolved "https://registry.yarnpkg.com/temp/-/temp-0.8.3.tgz#e0c6bc4d26b903124410e4fed81103014dfc1f59" + dependencies: + os-tmpdir "^1.0.0" + rimraf "~2.2.6" + +term-size@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69" + dependencies: + execa "^0.7.0" + +text-extensions@^1.0.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39" + +throttleit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" + +through2-filter@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec" + dependencies: + through2 "~2.0.0" + xtend "~4.0.0" + +through2@^0.6.1, through2@^0.6.3: + version "0.6.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + dependencies: + readable-stream ">=1.0.33-1 <1.1.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through2@^2.0.0, through2@^2.0.1, through2@^2.0.2, through2@~2.0.0: + version "2.0.3" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" + dependencies: + readable-stream "^2.1.5" + xtend "~4.0.1" + +through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3, through@~2.3.1, through@~2.3.8: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +tildify@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" + dependencies: + os-homedir "^1.0.0" + +time-stamp@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" + +timed-out@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + +timers-ext@0.1, timers-ext@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.2.tgz#61cc47a76c1abd3195f14527f978d58ae94c5204" + dependencies: + es5-ext "~0.10.14" + next-tick "1" + +tmp@0.0.30: + version "0.0.30" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.30.tgz#72419d4a8be7d6ce75148fd8b324e593a711c2ed" + dependencies: + os-tmpdir "~1.0.1" + +tmp@0.0.x, tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + +to-array@0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" + +to-boolean-x@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/to-boolean-x/-/to-boolean-x-1.0.1.tgz#724128dacc5bea75a93ad471be7ee9277561b2c1" + +to-integer-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/to-integer-x/-/to-integer-x-3.0.0.tgz#9f3b80e668c7f0ae45e6926b40d95f52c1addc74" + dependencies: + is-finite-x "^3.0.2" + is-nan-x "^1.0.1" + math-sign-x "^3.0.0" + to-number-x "^2.0.0" + +to-iso-string@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" + +to-number-x@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-number-x/-/to-number-x-2.0.0.tgz#c9099d7ded8fd327132a2987df2dcc8baf36df4d" + dependencies: + cached-constructors-x "^1.0.0" + nan-x "^1.0.0" + parse-int-x "^2.0.0" + to-primitive-x "^1.1.0" + trim-x "^3.0.0" + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + dependencies: + kind-of "^3.0.2" + +to-object-x@^1.4.1, to-object-x@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/to-object-x/-/to-object-x-1.5.0.tgz#bd69dd4e104d77acc0cc0d84f5ac48f630aebe3c" + dependencies: + cached-constructors-x "^1.0.0" + require-object-coercible-x "^1.4.1" + +to-primitive-x@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/to-primitive-x/-/to-primitive-x-1.1.0.tgz#41ce2c13e3e246e0e5d0a8829a0567c6015833f8" + dependencies: + has-symbol-support-x "^1.4.1" + is-date-object "^1.0.1" + is-function-x "^3.2.0" + is-nil-x "^1.4.1" + is-primitive "^2.0.0" + is-symbol "^1.0.1" + require-object-coercible-x "^1.4.1" + validate.io-undefined "^1.0.3" + +to-property-key-x@^2.0.1, to-property-key-x@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/to-property-key-x/-/to-property-key-x-2.0.2.tgz#b19aa8e22faa0ff7d1c102cfbc657af73413cfa1" + dependencies: + has-symbol-support-x "^1.4.1" + to-primitive-x "^1.1.0" + to-string-x "^1.4.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.1.tgz#15358bee4a2c83bd76377ba1dc049d0f18837aae" + dependencies: + define-property "^0.2.5" + extend-shallow "^2.0.1" + regex-not "^1.0.0" + +to-string-symbols-supported-x@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-string-symbols-supported-x/-/to-string-symbols-supported-x-1.0.0.tgz#d435eb72312fe885b18047a96d59c75641476872" + dependencies: + cached-constructors-x "^1.0.0" + has-symbol-support-x "^1.4.1" + is-symbol "^1.0.1" + +to-string-tag-x@^1.4.1, to-string-tag-x@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/to-string-tag-x/-/to-string-tag-x-1.4.2.tgz#916a0c72d2f93dc27fccfe0ea0ce26cd78be21de" + dependencies: + lodash.isnull "^3.0.0" + validate.io-undefined "^1.0.3" + +to-string-x@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/to-string-x/-/to-string-x-1.4.2.tgz#7d9a2528e159a9214e668137c1e10a045abe6279" + dependencies: + is-symbol "^1.0.1" + +tough-cookie@>=0.12.0, tough-cookie@~2.3.0, tough-cookie@~2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" + dependencies: + punycode "^1.4.1" + +tough-cookie@~2.2.0: + version "2.2.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.2.2.tgz#c83a1830f4e5ef0b93ef2a3488e724f8de016ac7" + +trim-left-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/trim-left-x/-/trim-left-x-3.0.0.tgz#356cf055896726b9754425e841398842e90b4cdf" + dependencies: + cached-constructors-x "^1.0.0" + require-coercible-to-string-x "^1.0.0" + white-space-x "^3.0.0" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +trim-off-newlines@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" + +trim-right-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/trim-right-x/-/trim-right-x-3.0.0.tgz#28c4cd37d5981f50ace9b52e3ce9106f4d2d22c0" + dependencies: + cached-constructors-x "^1.0.0" + require-coercible-to-string-x "^1.0.0" + white-space-x "^3.0.0" + +trim-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/trim-x/-/trim-x-3.0.0.tgz#24efdcd027b748bbfc246a0139ad1749befef024" + dependencies: + trim-left-x "^3.0.0" + trim-right-x "^3.0.0" + +ts-loader@^0.6.0: + version "0.6.1" + resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-0.6.1.tgz#98e29d8c3ecad951d544a4c57939f808866f67ac" + dependencies: + arrify "^1.0.0" + colors "^1.0.3" + enhanced-resolve "^0.9.0" + loader-utils "^0.2.6" + object-assign "^2.0.0" + semver "^5.0.1" + +tslint-eslint-rules@^3.1.0: + version "3.5.1" + resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-3.5.1.tgz#e43efdcdd760d6285600031720f972c92f4a058a" + dependencies: + doctrine "^0.7.2" + +tslint@^4.1.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-4.5.1.tgz#05356871bef23a434906734006fc188336ba824b" + dependencies: + babel-code-frame "^6.20.0" + colors "^1.1.2" + diff "^3.0.1" + findup-sync "~0.3.0" + glob "^7.1.1" + optimist "~0.6.0" + resolve "^1.1.7" + tsutils "^1.1.0" + update-notifier "^2.0.0" + +tsutils@^1.1.0: + version "1.9.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0" + +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + +tunnel-agent@~0.4.0, tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.5" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + +type-is@~1.6.15: + version "1.6.16" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" + dependencies: + media-typer "0.3.0" + mime-types "~2.1.18" + +typedarray@^0.0.6, typedarray@~0.0.5: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +typescript@2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.2.tgz#038a95f7d9bbb420b1bf35ba31d4c5c1dd3ffe34" + +uglify-js@2.6.4: + version "2.6.4" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.6.4.tgz#65ea2fb3059c9394692f15fed87c2b36c16b9adf" + dependencies: + async "~0.2.6" + source-map "~0.5.1" + uglify-to-browserify "~1.0.0" + yargs "~3.10.0" + +uglify-js@^2.6: + version "2.8.29" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + dependencies: + source-map "~0.5.1" + yargs "~3.10.0" + optionalDependencies: + uglify-to-browserify "~1.0.0" + +uglify-save-license@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/uglify-save-license/-/uglify-save-license-0.4.1.tgz#95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1" + +uglify-to-browserify@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + +uid-number@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +ultron@1.0.x: + version "1.0.2" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" + +unc-path-regex@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" + +underscore.string@~3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.0.3.tgz#4617b8c1a250cf6e5064fbbb363d0fa96cf14552" + +underscore@~1.8.3: + version "1.8.3" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + +union-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^0.4.3" + +unique-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" + +unique-stream@^2.0.2: + version "2.2.1" + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369" + dependencies: + json-stable-stringify "^1.0.0" + through2-filter "^2.0.0" + +unique-string@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" + dependencies: + crypto-random-string "^1.0.0" + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +unzip-response@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" + +update-notifier@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.3.0.tgz#4e8827a6bb915140ab093559d7014e3ebb837451" + dependencies: + boxen "^1.2.1" + chalk "^2.0.1" + configstore "^3.0.0" + import-lazy "^2.1.0" + is-installed-globally "^0.1.0" + is-npm "^1.0.0" + latest-version "^3.0.0" + semver-diff "^2.0.0" + xdg-basedir "^3.0.0" + +urix@^0.1.0, urix@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + +url-parse-lax@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + dependencies: + prepend-http "^1.0.1" + +url@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +use@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/use/-/use-2.0.2.tgz#ae28a0d72f93bf22422a18a2e379993112dec8e8" + dependencies: + define-property "^0.2.5" + isobject "^3.0.0" + lazy-cache "^2.0.2" + +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + +useragent@^2.1.6: + version "2.3.0" + resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972" + dependencies: + lru-cache "4.1.x" + tmp "0.0.x" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +util@0.10.3, "util@>=0.10.3 <1": + version "0.10.3" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + dependencies: + inherits "2.0.1" + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + +uuid@^3.0.0, uuid@^3.1.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" + +v8flags@^2.0.2: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + dependencies: + user-home "^1.1.1" + +validate-npm-package-license@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + dependencies: + spdx-correct "~1.0.0" + spdx-expression-parse "~1.0.0" + +validate.io-undefined@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz#7e27fcbb315b841e78243431897671929e20b7f4" + +validator@~9.1.1: + version "9.1.2" + resolved "https://registry.yarnpkg.com/validator/-/validator-9.1.2.tgz#5711b6413f78bd9d56003130c81b47c39e86546c" + +vargs@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/vargs/-/vargs-0.1.0.tgz#6b6184da6520cc3204ce1b407cac26d92609ebff" + +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + dependencies: + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" + +vinyl-fs@^0.3.0: + version "0.3.14" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" + dependencies: + defaults "^1.0.0" + glob-stream "^3.1.5" + glob-watcher "^0.0.6" + graceful-fs "^3.0.0" + mkdirp "^0.5.0" + strip-bom "^1.0.0" + through2 "^0.6.1" + vinyl "^0.4.0" + +vinyl-fs@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-1.0.0.tgz#d15752e68c2dad74364e7e853473735354692edf" + dependencies: + duplexify "^3.2.0" + glob-stream "^4.0.1" + glob-watcher "^0.0.8" + graceful-fs "^3.0.0" + merge-stream "^0.1.7" + mkdirp "^0.5.0" + object-assign "^2.0.0" + strip-bom "^1.0.0" + through2 "^0.6.1" + vinyl "^0.4.0" + +vinyl-sourcemaps-apply@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" + dependencies: + source-map "^0.5.1" + +vinyl@^0.4.0: + version "0.4.6" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" + dependencies: + clone "^0.2.0" + clone-stats "^0.0.1" + +vinyl@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.5.3.tgz#b0455b38fc5e0cf30d4325132e461970c2091cde" + dependencies: + clone "^1.0.0" + clone-stats "^0.0.1" + replace-ext "0.0.1" + +vinyl@^2.0.1, vinyl@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.1.0.tgz#021f9c2cf951d6b939943c89eb5ee5add4fd924c" + dependencies: + clone "^2.1.1" + clone-buffer "^1.0.0" + clone-stats "^1.0.0" + cloneable-readable "^1.0.0" + remove-trailing-separator "^1.0.1" + replace-ext "^1.0.0" + +void-elements@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" + +vrsource-tslint-rules@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/vrsource-tslint-rules/-/vrsource-tslint-rules-4.0.1.tgz#f3cf8026e1d3a9b63d263dd591248dc96dc3ec1c" + dependencies: + tslint "^4.1.1" + +wd@~0.3.4: + version "0.3.12" + resolved "https://registry.yarnpkg.com/wd/-/wd-0.3.12.tgz#3fb4f1d759f8c85dde5393d17334ffe03e9bb329" + dependencies: + archiver "~0.14.0" + async "~1.0.0" + lodash "~3.9.3" + q "~1.4.1" + request "~2.55.0" + underscore.string "~3.0.3" + vargs "~0.1.0" + +wdio-dot-reporter@~0.0.8: + version "0.0.9" + resolved "https://registry.yarnpkg.com/wdio-dot-reporter/-/wdio-dot-reporter-0.0.9.tgz#929b2adafd49d6b0534fda068e87319b47e38fe5" + +webdriver-manager@^12.0.6: + version "12.0.6" + resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.0.6.tgz#3df1a481977010b4cbf8c9d85c7a577828c0e70b" + dependencies: + adm-zip "^0.4.7" + chalk "^1.1.1" + del "^2.2.0" + glob "^7.0.3" + ini "^1.3.4" + minimist "^1.2.0" + q "^1.4.1" + request "^2.78.0" + rimraf "^2.5.2" + semver "^5.3.0" + xml2js "^0.4.17" + +webdriverio@^4.8.0: + version "4.10.2" + resolved "https://registry.yarnpkg.com/webdriverio/-/webdriverio-4.10.2.tgz#0d28622802c966015afe34b3ac566dc339f22e43" + dependencies: + archiver "~2.1.0" + babel-runtime "^6.26.0" + css-parse "~2.0.0" + css-value "~0.0.1" + deepmerge "~2.0.1" + ejs "~2.5.6" + gaze "~1.1.2" + glob "~7.1.1" + inquirer "~3.3.0" + json-stringify-safe "~5.0.1" + mkdirp "~0.5.1" + npm-install-package "~2.1.0" + optimist "~0.6.1" + q "~1.5.0" + request "~2.83.0" + rgb2hex "~0.1.0" + safe-buffer "~5.1.1" + supports-color "~5.0.0" + url "~0.11.0" + validator "~9.1.1" + wdio-dot-reporter "~0.0.8" + wgxpath "~1.0.0" + +wgxpath@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wgxpath/-/wgxpath-1.0.0.tgz#eef8a4b9d558cc495ad3a9a2b751597ecd9af690" + +whatwg-fetch@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" + +when@^3.7.5: + version "3.7.8" + resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82" + +which@^1.0.5, which@^1.2.1, which@^1.2.10, which@^1.2.14, which@^1.2.9: + version "1.3.0" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" + dependencies: + isexe "^2.0.0" + +which@~1.2.2: + version "1.2.14" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" + dependencies: + isexe "^2.0.0" + +white-space-x@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/white-space-x/-/white-space-x-3.0.0.tgz#c8e31ed4fecf4f3feebe6532e6046008a666a3e1" + +wide-align@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" + dependencies: + string-width "^1.0.2" + +widest-line@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.0.tgz#0142a4e8a243f8882c0233aa0e0281aa76152273" + dependencies: + string-width "^2.1.1" + +window-size@0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + +wordwrap@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + +wordwrap@~0.0.2: + version "0.0.3" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +write-file-atomic@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + +ws@~1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.5.tgz#cbd9e6e75e09fc5d2c90015f21f0c40875e0dd51" + dependencies: + options ">=0.0.5" + ultron "1.0.x" + +wtf-8@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a" + +xdg-basedir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" + +xml2js@^0.4.17: + version "0.4.19" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7" + dependencies: + sax ">=0.6.0" + xmlbuilder "~9.0.1" + +xmlbuilder@~9.0.1: + version "9.0.7" + resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" + +xmlhttprequest-ssl@1.5.3: + version "1.5.3" + resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" + +"xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + +yallist@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + +yargs@~3.10.0: + version "3.10.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + dependencies: + camelcase "^1.0.2" + cliui "^2.1.0" + decamelize "^1.0.0" + window-size "0.1.0" + +yauzl@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" + dependencies: + fd-slicer "~1.0.1" + +yeast@0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" + +zip-stream@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-1.2.0.tgz#a8bc45f4c1b49699c6b90198baacaacdbcd4ba04" + dependencies: + archiver-utils "^1.3.0" + compress-commons "^1.2.0" + lodash "^4.8.0" + readable-stream "^2.0.0" + +zip-stream@~0.5.0: + version "0.5.2" + resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-0.5.2.tgz#32dcbc506d0dab4d21372625bd7ebaac3c2fff56" + dependencies: + compress-commons "~0.2.0" + lodash "~3.2.0" + readable-stream "~1.0.26" From eefe98362410a9ebf34283d592746b8788669aa3 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 28 Feb 2018 08:42:15 +0900 Subject: [PATCH 025/106] fix(testing): fix #1032, fakeAsync should pass parameters correctly (#1033) --- lib/zone-spec/fake-async-test.ts | 6 +++--- test/zone-spec/fake-async-test.spec.ts | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 4e61c04b9..9b2fc55d7 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -294,7 +294,7 @@ this._scheduler.removeScheduledFunctionWithId(id); } - private _setInterval(fn: Function, interval: number, ...args: any[]): number { + private _setInterval(fn: Function, interval: number, args: any[]): number { let id = this._scheduler.nextId; let completers = {onSuccess: null as Function, onError: this._dequeuePeriodicTimer(id)}; let cb = this._fnAndFlush(fn, completers); @@ -410,11 +410,11 @@ switch (task.source) { case 'setTimeout': task.data['handleId'] = - this._setTimeout(task.invoke, task.data['delay'], (task.data as any)['args']); + this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call((task.data as any)['args'], 2)); break; case 'setInterval': task.data['handleId'] = - this._setInterval(task.invoke, task.data['delay'], (task.data as any)['args']); + this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call((task.data as any)['args'], 2)); break; case 'XMLHttpRequest.send': throw new Error( diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index d9d3434ac..cb23a340d 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -206,6 +206,18 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); + it('should pass arguments to times', () => { + fakeAsyncTestZone.run(() => { + let value = 'genuine value'; + let id = setTimeout((arg1, arg2) => { + value = arg1 + arg2; + }, 0, 'expected', ' value'); + + testZoneSpec.tick(); + expect(value).toEqual('expected value'); + }); + }); + it('should run periodic timers', () => { fakeAsyncTestZone.run(() => { let cycles = 0; @@ -227,6 +239,18 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); + it('should pass arguments to periodic timers', () => { + fakeAsyncTestZone.run(() => { + let value = 'genuine value'; + let id = setInterval((arg1, arg2) => { + value = arg1 + arg2; + }, 10, 'expected', ' value'); + + testZoneSpec.tick(10); + expect(value).toEqual('expected value'); + }); + }); + it('should not run cancelled periodic timer', () => { fakeAsyncTestZone.run(() => { let ran = false; From ab72df6fe403a8205e5cfab60fe2e01ef23bd53c Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 14 Mar 2018 12:13:52 +0900 Subject: [PATCH 026/106] fix(event): fix #1021, removeListener/removeAllListeners should return eventEmitter (#1022) --- lib/common/events.ts | 7 +++++++ test/node/events.spec.ts | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/common/events.ts b/lib/common/events.ts index 49bc6fe16..ecc80122f 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -497,6 +497,9 @@ export function patchEventTarget( target[symbolEventName] = null; } existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } return; } } @@ -571,6 +574,10 @@ export function patchEventTarget( } } } + + if (returnTarget) { + return this; + } }; // for native toString patch diff --git a/test/node/events.spec.ts b/test/node/events.spec.ts index 4bee40b59..758128e76 100644 --- a/test/node/events.spec.ts +++ b/test/node/events.spec.ts @@ -66,6 +66,13 @@ describe('nodejs EventEmitter', () => { emitter.emit('test2', 'test value'); }); }); + it('remove listener should return event emitter', () => { + zoneA.run(() => { + emitter.on('test', shouldNotRun); + expect(emitter.removeListener('test', shouldNotRun)).toEqual(emitter); + emitter.emit('test', 'test value'); + }); + }); it('should return all listeners for an event', () => { zoneA.run(() => { emitter.on('test', expectZoneA); @@ -106,6 +113,14 @@ describe('nodejs EventEmitter', () => { expect(emitter.listeners('test').length).toEqual(0); }); }); + it('remove All listeners should return event emitter', () => { + zoneA.run(() => { + emitter.on('test', expectZoneA); + emitter.on('test', expectZoneA); + expect(emitter.removeAllListeners('test')).toEqual(emitter); + expect(emitter.listeners('test').length).toEqual(0); + }); + }); it('should remove All listeners properly even without a type parameter', () => { zoneA.run(() => { emitter.on('test', shouldNotRun); From c554e9fa05d41e6fb7eb1181d9b2af27aea03afc Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 14 Mar 2018 12:16:19 +0900 Subject: [PATCH 027/106] fix(test): fix mocha compatible issue (#1028) --- .travis.yml | 3 +- karma-build-sauce-selenium3-mocha.conf.js | 2 +- lib/mocha/mocha.ts | 3 -- test/zone-spec/async-test.spec.ts | 48 +++++++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97d706205..21504c57e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,8 @@ script: - node_modules/.bin/gulp test/node - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js - - yarn add jasmine@3.0.0 jasmine-core@3.0.0 + - yarn add jasmine@3.0.0 jasmine-core@3.0.0 mocha@5.0.1 - yarn test:phantomjs-single - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run + - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node diff --git a/karma-build-sauce-selenium3-mocha.conf.js b/karma-build-sauce-selenium3-mocha.conf.js index 6eb77e97a..d23462147 100644 --- a/karma-build-sauce-selenium3-mocha.conf.js +++ b/karma-build-sauce-selenium3-mocha.conf.js @@ -8,5 +8,5 @@ module.exports = function (config) { require('./karma-dist-mocha.conf.js')(config); - require('./sauce-selenium3.conf')(config); + require('./sauce-selenium3.conf')(config, ['SL_IE9']); }; diff --git a/lib/mocha/mocha.ts b/lib/mocha/mocha.ts index f04fe5a8b..10156a82f 100644 --- a/lib/mocha/mocha.ts +++ b/lib/mocha/mocha.ts @@ -158,9 +158,6 @@ Mocha.Runner.prototype.run = function(fn: Function) { this.on('test', (e: any) => { - if (Zone.current !== rootZone) { - throw new Error('Unexpected zone: ' + Zone.current.name); - } testZone = rootZone.fork(new ProxyZoneSpec()); }); diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index 8d0f59e5e..9050a2a56 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -547,4 +547,52 @@ describe('AsyncTestZoneSpec', function() { })); }); }); + + describe('should be able to handle async for both beforeEach and it', () => { + let log: string[]; + const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; + + function asyncTest(testBody: () => void, finishCallback: Function, failCallback: Function) { + return function() { + const proxyZoneSpec = Zone.current.get('ProxyZoneSpec'); + if (!proxyZoneSpec) { + throw new Error('ProxyZone not found!'); + } + const lastDelegate = proxyZoneSpec.getDelegate(); + // construct AsyncTestZoneSpec in parent zone + // to prevent infinite loop + Zone.current.parent.run(() => { + proxyZoneSpec.setDelegate(new AsyncTestZoneSpec(() => { + proxyZoneSpec.setDelegate(lastDelegate); + finishCallback(); + }, () => { + proxyZoneSpec.setDelegate(lastDelegate); + failCallback(); + }), 'async'); + }); + testBody.apply(this, arguments); + }; + } + + beforeEach(asyncTest(() => { + log = []; + setTimeout(() => { + log.push('beforeEach'); + }, 50); + }, () => { + expect(log).toEqual(['beforeEach']); + }, () => { + fail('should not fail'); + })); + + it('should support asyncTest with an async beforeEach', asyncTest(() => { + setTimeout(() => { + log.push('timeout'); + }, 50); + }, () => { + expect(log).toEqual(['beforeEach', 'timeout']); + }, () => { + fail('should not fail'); + })); + }); }); From 9fceb07c52a187daa616f616f0dc9ac465565255 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 14 Mar 2018 12:16:38 +0900 Subject: [PATCH 028/106] test: add test cases for returning promise (#1036) --- test/jasmine-patch.spec.ts | 21 ++++++++++++++++++++- test/mocha-patch.spec.ts | 19 +++++++++++++++++++ test/zone-spec/async-test.spec.ts | 14 ++++++++++++++ test/zone-spec/fake-async-test.spec.ts | 20 ++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/test/jasmine-patch.spec.ts b/test/jasmine-patch.spec.ts index 0b2671ddb..c7fc9be7d 100644 --- a/test/jasmine-patch.spec.ts +++ b/test/jasmine-patch.spec.ts @@ -44,9 +44,28 @@ ifEnvSupports(supportJasmineSpec, () => { afterEach(() => { let zone = Zone.current; expect(zone.name).toEqual('ProxyZone'); - expect(beforeEachZone).toBe(zone); + expect(beforeEachZone.name).toEqual(zone.name); expect(itZone).toBe(zone); }); + }); + + describe('return promise', () => { + let log: string[]; + beforeEach(() => { + log = []; + }); + it('should wait for promise to resolve', () => { + return new Promise((res, _) => { + setTimeout(() => { + log.push('resolved'); + res(); + }, 100); + }); + }); + + afterEach(() => { + expect(log).toEqual(['resolved']); + }); }); })(); diff --git a/test/mocha-patch.spec.ts b/test/mocha-patch.spec.ts index 01ec59ba1..54c47bcd0 100644 --- a/test/mocha-patch.spec.ts +++ b/test/mocha-patch.spec.ts @@ -98,4 +98,23 @@ ifEnvSupports('Mocha', function() { }); + describe('return promise', () => { + let log: string[]; + beforeEach(() => { + log = []; + }); + + it('should wait for promise to resolve', () => { + return new Promise((res, _) => { + setTimeout(() => { + log.push('resolved'); + res(); + }, 100); + }); + }); + + afterEach(() => { + expect(log).toEqual(['resolved']); + }); + }); })(); \ No newline at end of file diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index 9050a2a56..98610da00 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -546,6 +546,20 @@ describe('AsyncTestZoneSpec', function() { expect(logs).toEqual(['beforeEach', 'timeout']); })); }); + + describe('return promise', () => { + let value = 'init'; + it('should only call finish once', testAsync(() => { + return new Promise((resolve, _) => { + setTimeout(() => { + value = 'timeout'; + resolve(); + }, 100); + }); + }, () => { + expect(value).toEqual('timeout'); + })); + }); }); describe('should be able to handle async for both beforeEach and it', () => { diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index cb23a340d..9889cff39 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -833,6 +833,26 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); + describe('return promise', () => { + let log: string[]; + beforeEach(() => { + log = []; + }); + + it('should wait for promise to resolve', () => { + return new Promise((res, _) => { + setTimeout(() => { + log.push('resolved'); + res(); + }, 100); + }); + }); + + afterEach(() => { + expect(log).toEqual(['resolved']); + }); + }); + describe('fakeAsyncTest should patch Date', () => { let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; let testZoneSpec: any; From 438210c2bd5787a464cc3d2fb45b298cc8285bb0 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 14 Mar 2018 12:17:23 +0900 Subject: [PATCH 029/106] feat(bluebird): fix #921, #977, support bluebird (#1039) --- .travis.yml | 1 + gulpfile.js | 14 ++- lib/extra/bluebird.ts | 26 ++++- package.json | 2 + test/extra/bluebird.spec.ts | 161 ++++++++++++++++++------------ test/node_bluebird_entry_point.ts | 32 ++++++ test/node_tests.ts | 4 - yarn.lock | 4 + 8 files changed, 169 insertions(+), 75 deletions(-) create mode 100644 test/node_bluebird_entry_point.ts diff --git a/.travis.yml b/.travis.yml index 21504c57e..93c1c1f27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ script: - node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node + - node_modules/.bin/gulp test/bluebird - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js - yarn add jasmine@3.0.0 jasmine-core@3.0.0 mocha@5.0.1 diff --git a/gulpfile.js b/gulpfile.js index b3f63b29a..2bab13d6f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -391,12 +391,10 @@ gulp.task('build', [ 'build/closure.js' ]); -gulp.task('test/node', ['compile-node'], function(cb) { +function nodeTest(specFiles, cb) { var JasmineRunner = require('jasmine'); var jrunner = new JasmineRunner(); - var specFiles = ['build/test/node_entry_point.js']; - jrunner.configureDefaultReporter({showColors: true}); jrunner.onComplete(function(passed) { @@ -417,6 +415,16 @@ gulp.task('test/node', ['compile-node'], function(cb) { jrunner.specDir = ''; jrunner.addSpecFiles(specFiles); jrunner.execute(); +} + +gulp.task('test/node', ['compile-node'], function(cb) { + var specFiles = ['build/test/node_entry_point.js']; + nodeTest(specFiles, cb); +}); + +gulp.task('test/bluebird', ['compile-node'], function(cb) { + var specFiles = ['build/test/node_bluebird_entry_point.js']; + nodeTest(specFiles, cb); }); // Check the coding standards and programming errors diff --git a/lib/extra/bluebird.ts b/lib/extra/bluebird.ts index dd7f27743..13a0496ea 100644 --- a/lib/extra/bluebird.ts +++ b/lib/extra/bluebird.ts @@ -5,7 +5,7 @@ * 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.__load_patch('bluebird', (global: any, Zone: ZoneType) => { +Zone.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // TODO: @JiaLiPassion, we can automatically patch bluebird // if global.Promise = Bluebird, but sometimes in nodejs, // global.Promise is not Bluebird, and Bluebird is just be @@ -13,8 +13,28 @@ Zone.__load_patch('bluebird', (global: any, Zone: ZoneType) => { // safe to just expose a method to patch Bluebird explicitly const BLUEBIRD = 'bluebird'; (Zone as any)[Zone.__symbol__(BLUEBIRD)] = function patchBluebird(Bluebird: any) { - Bluebird.setScheduler((fn: Function) => { - Zone.current.scheduleMicroTask(BLUEBIRD, fn); + // patch method of Bluebird.prototype which not using `then` internally + const bluebirdApis: string[] = ['then', 'spread', 'finally']; + bluebirdApis.forEach(bapi => { + api.patchMethod(Bluebird.prototype, bapi, (delegate: Function) => (self: any, args: any[]) => { + const zone = Zone.current; + for (let i = 0; i < args.length; i ++) { + const func = args[i]; + if (typeof func === 'function') { + args[i] = function() { + const argSelf: any = this; + const argArgs: any = arguments; + zone.scheduleMicroTask('Promise.then', () => { + return func.apply(argSelf, argArgs); + }); + }; + } + } + return delegate.apply(self, args); + }); }); + + // override global promise + global[api.symbol('ZoneAwarePromise')] = Bluebird; }; }); diff --git a/package.json b/package.json index 28ad61e49..33ea7d8e6 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"", "test-dist": "concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-dist-jasmine.conf.js\"", "test-node": "gulp test/node", + "test-bluebird": "gulp test/bluebird", "test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"", "serve": "python -m SimpleHTTPServer 8000" }, @@ -61,6 +62,7 @@ "@types/node": "^6.0.96", "@types/systemjs": "^0.19.30", "assert": "^1.4.1", + "bluebird": "^3.5.1", "clang-format": "1.0.46", "concurrently": "^2.2.0", "conventional-changelog": "^1.1.7", diff --git a/test/extra/bluebird.spec.ts b/test/extra/bluebird.spec.ts index 81a5437de..b86ceac15 100644 --- a/test/extra/bluebird.spec.ts +++ b/test/extra/bluebird.spec.ts @@ -47,8 +47,8 @@ describe('bluebird promise', () => { }); p.then(() => { expect(Zone.current.name).toEqual('bluebird'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -62,8 +62,8 @@ describe('bluebird promise', () => { }, 0); }); p.catch(() => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -76,8 +76,8 @@ describe('bluebird promise', () => { .spread((r1: string, r2: string) => { expect(r1).toEqual('test1'); expect(r2).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -92,8 +92,8 @@ describe('bluebird promise', () => { }, 0); }); p.finally(() => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -112,8 +112,8 @@ describe('bluebird promise', () => { }) .then(() => { expect(Zone.current.name).toEqual('bluebird'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -126,8 +126,8 @@ describe('bluebird promise', () => { throw new Error('promise error'); }) .catch((err: Error) => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(err.message).toEqual('promise error'); done(); @@ -142,8 +142,8 @@ describe('bluebird promise', () => { return 'test'; })() .then((result: string) => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(result).toEqual('test'); done(); @@ -154,8 +154,8 @@ describe('bluebird promise', () => { it('bluebird promise resolve method should be in zone', (done) => { zone.run(() => { BluebirdPromise.resolve('test').then((result: string) => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(result).toEqual('test'); done(); @@ -166,8 +166,8 @@ describe('bluebird promise', () => { it('bluebird promise reject method should be in zone', (done) => { zone.run(() => { BluebirdPromise.reject('error').catch((error: Error) => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(error).toEqual('error'); done(); @@ -181,8 +181,8 @@ describe('bluebird promise', () => { .then((r: string[]) => { expect(r[0]).toEqual('test1'); expect(r[1]).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -196,8 +196,8 @@ describe('bluebird promise', () => { .then((r: any) => { expect(r.test1).toEqual('test1'); expect(r.test2).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -209,8 +209,8 @@ describe('bluebird promise', () => { BluebirdPromise.any([BluebirdPromise.resolve('test1'), BluebirdPromise.resolve('test2')]) .then((r: any) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -223,8 +223,8 @@ describe('bluebird promise', () => { .then((r: any) => { expect(r.length).toBe(1); expect(r[0]).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -243,8 +243,8 @@ describe('bluebird promise', () => { expect(r.length).toBe(2); expect(r[0]).toEqual('test1'); expect(r[1]).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -261,9 +261,9 @@ describe('bluebird promise', () => { }) .then((r: number) => { expect(r).toBe(3); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length) + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length) + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) .toBeTruthy(); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -282,8 +282,8 @@ describe('bluebird promise', () => { }) .then((r: number[]) => { expect(r[0]).toBe(2); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -297,9 +297,11 @@ describe('bluebird promise', () => { BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), (r: number[], idx: number) => { expect(r[idx] === arr[idx]); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length) + expect(Zone.current.name).toEqual('bluebird'); + }).then((r: any) => { + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length) + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) .toBeTruthy(); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -314,13 +316,15 @@ describe('bluebird promise', () => { BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), (r: number[], idx: number) => { expect(r[idx] === arr[idx]); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length) + expect(Zone.current.name).toEqual('bluebird'); + }).then((r: any) => { + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length) + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) .toBeTruthy(); expect(Zone.current.name).toEqual('bluebird'); done(); - }); + });; }); }); @@ -329,8 +333,8 @@ describe('bluebird promise', () => { BluebirdPromise.race([BluebirdPromise.resolve('test1'), BluebirdPromise.resolve('test2')]) .then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -358,8 +362,8 @@ describe('bluebird promise', () => { expect(Zone.current.name).toEqual('bluebird'); expect(p.leakObj).toBe(null); // using will generate several promise inside bluebird - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBeTruthy(); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBeTruthy(); done(); }); }); @@ -377,8 +381,8 @@ describe('bluebird promise', () => { promiseFunc().then((r: string) => { expect(Zone.current.name).toEqual('bluebird'); expect(r).toBe('test'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -406,8 +410,8 @@ describe('bluebird promise', () => { expect(r[0]).toBe('test1'); expect(r[1]).toBe('test2'); // using will generate several promise inside - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(2); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(2); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -424,8 +428,8 @@ describe('bluebird promise', () => { BluebirdPromise.fromCallback(resolver).then((r: string) => { expect(Zone.current.name).toEqual('bluebird'); expect(r).toBe('test'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -446,8 +450,8 @@ describe('bluebird promise', () => { BluebirdPromise.resolve('test').delay(10).then((r: string) => { expect(Zone.current.name).toEqual('bluebird'); expect(r).toBe('test'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(2); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(2); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -464,8 +468,8 @@ describe('bluebird promise', () => { .then((r: string) => { expect(Zone.current.name).toEqual('bluebird'); expect(r).toBe('test'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); }); @@ -479,8 +483,10 @@ describe('bluebird promise', () => { }, 0); }); p.tap(() => { - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(Zone.current.name).toEqual('bluebird'); + }).then(() => { + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -502,8 +508,8 @@ describe('bluebird promise', () => { }) .then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -514,8 +520,8 @@ describe('bluebird promise', () => { zone.run(() => { BluebirdPromise.resolve(['test1', 'test2']).get(-1).then((r: string) => { expect(r).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -526,8 +532,8 @@ describe('bluebird promise', () => { zone.run(() => { BluebirdPromise.resolve().return ('test1').then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -538,8 +544,8 @@ describe('bluebird promise', () => { zone.run(() => { BluebirdPromise.resolve().throw('test1').catch((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -550,8 +556,8 @@ describe('bluebird promise', () => { zone.run(() => { BluebirdPromise.reject().catchReturn('test1').then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -562,8 +568,8 @@ describe('bluebird promise', () => { zone.run(() => { BluebirdPromise.reject().catchThrow('test1').catch((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task bluebird').length).toBe(1); - expect(log.filter(item => item === 'invoke bluebird task bluebird').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); }); @@ -588,4 +594,29 @@ describe('bluebird promise', () => { }); }); }); + + it('bluebird should be able to run into different zone', (done: Function) => { + Zone.current.fork({ + name: 'zone_A' + }).run(() => { + new BluebirdPromise((resolve: any, reject: any) => { + expect(Zone.current.name).toEqual('zone_A'); + resolve(1); + }).then((r: any) => { + expect(Zone.current.name).toEqual('zone_A'); + }); + }); + + Zone.current.fork({ + name: 'zone_B' + }).run(() => { + new BluebirdPromise((resolve: any, reject: any) => { + expect(Zone.current.name).toEqual('zone_B'); + resolve(2); + }).then((r: any) => { + expect(Zone.current.name).toEqual('zone_B'); + done(); + }); + }); + }); }); diff --git a/test/node_bluebird_entry_point.ts b/test/node_bluebird_entry_point.ts new file mode 100644 index 000000000..8c5a86f65 --- /dev/null +++ b/test/node_bluebird_entry_point.ts @@ -0,0 +1,32 @@ +/** + * @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 + */ + +// Must be loaded before zone loads, so that zone can detect WTF. +import './wtf_mock'; +import './test_fake_polyfill'; + +// Setup tests for Zone without microtask support +import '../lib/zone'; +import '../lib/common/promise'; +import '../lib/common/to-string'; +import '../lib/node/node'; +import '../lib/zone-spec/async-test'; +import '../lib/zone-spec/fake-async-test'; +import '../lib/zone-spec/long-stack-trace'; +import '../lib/zone-spec/proxy'; +import '../lib/zone-spec/sync-test'; +import '../lib/zone-spec/task-tracking'; +import '../lib/zone-spec/wtf'; +import '../lib/rxjs/rxjs'; + +import '../lib/testing/promise-testing'; +// Setup test environment +import './test-env-setup-jasmine'; + +// List all tests here: +import './extra/bluebird.spec'; \ No newline at end of file diff --git a/test/node_tests.ts b/test/node_tests.ts index f674f198a..0fcc9b6aa 100644 --- a/test/node_tests.ts +++ b/test/node_tests.ts @@ -13,7 +13,3 @@ import './node/Error.spec'; import './node/crypto.spec'; import './node/http.spec'; import './node/console.spec'; - -// before test bluebird, must run npm install bluebird first. -// then remove the comment below -// import './extra/bluebird.spec'; diff --git a/yarn.lock b/yarn.lock index 75219d5ad..a26216695 100644 --- a/yarn.lock +++ b/yarn.lock @@ -450,6 +450,10 @@ bluebird@^2.9.27, bluebird@^2.9.30: version "2.11.0" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" +bluebird@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" + body-parser@^1.12.4: version "1.18.2" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" From 7f178b1526ec17dfc99cb71730b207d05f0ee802 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 14 Mar 2018 12:17:46 +0900 Subject: [PATCH 030/106] feat(core): fix #996, expose UncaughtPromiseError (#1040) --- lib/common/promise.ts | 7 ------- lib/zone.ts | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/common/promise.ts b/lib/common/promise.ts index bb34f5a20..90a68633c 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -22,13 +22,6 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr return obj ? obj.toString() : Object.prototype.toString.call(obj); } - interface UncaughtPromiseError extends Error { - zone: AmbientZone; - task: Task; - promise: ZoneAwarePromise; - rejection: any; - } - const __symbol__ = api.symbol; const _uncaughtPromiseErrors: UncaughtPromiseError[] = []; const symbolPromise = __symbol__('Promise'); diff --git a/lib/zone.ts b/lib/zone.ts index 76efc031a..9cbd04fdc 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -336,6 +336,13 @@ interface _ZoneFrame { zone: Zone; } +interface UncaughtPromiseError extends Error { + zone: Zone; + task: Task; + promise: Promise; + rejection: any; +} + /** * Provides a way to configure the interception of zone events. * From c8c599073b87025d44a4b7d6e2efea9cedfbd3e2 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 14 Mar 2018 12:18:37 +0900 Subject: [PATCH 031/106] fix(core): fix #946, don't patch promise if it is not writable (#1041) --- lib/common/promise.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 90a68633c..876d964bb 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -431,17 +431,18 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr function patchThen(Ctor: Function) { const proto = Ctor.prototype; + + const prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } + const originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we have to make it to be true. - const prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); - if (prop && prop.writable === false && prop.configurable) { - ObjectDefineProperty(Ctor.prototype, 'then', {writable: true}); - } - Ctor.prototype.then = function(onResolve: any, onReject: any) { const wrapped = new ZoneAwarePromise((resolve, reject) => { originalThen.call(this, resolve, reject); From 57bc80ce9570639dbb7fb2b52c9af8736ebc2d8e Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 31 Mar 2018 05:15:13 +0900 Subject: [PATCH 032/106] feat(testing): can display pending tasks info when test timeout in jasmine/mocha (#1038) --- lib/jasmine/jasmine.ts | 111 ++++++++++++++++-------------------- lib/mocha/mocha.ts | 7 +++ lib/zone-spec/async-test.ts | 10 +--- lib/zone-spec/proxy.ts | 43 +++++++++++++- 4 files changed, 102 insertions(+), 69 deletions(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 47f44c8c1..566c30f9e 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -9,16 +9,15 @@ 'use strict'; (() => { const __extends = function(d: any, b: any) { - for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + for (const 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 (__ as any)()); + d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new (__ as any)()); }; - const _global: any = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; + const _global: any = + typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; // 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'); @@ -27,10 +26,8 @@ throw new Error(`'jasmine' has already been patched with 'Zone'.`); (jasmine as any)['__zone_patch__'] = true; - const SyncTestZoneSpec: { new (name: string): ZoneSpec } = (Zone as any)[ - 'SyncTestZoneSpec' - ]; - const ProxyZoneSpec: { new (): ZoneSpec } = (Zone as any)['ProxyZoneSpec']; + const SyncTestZoneSpec: {new (name: string): ZoneSpec} = (Zone as any)['SyncTestZoneSpec']; + const ProxyZoneSpec: {new (): ZoneSpec} = (Zone as any)['ProxyZoneSpec']; if (!SyncTestZoneSpec) throw new Error('Missing: SyncTestZoneSpec'); if (!ProxyZoneSpec) throw new Error('Missing: ProxyZoneSpec'); @@ -46,25 +43,15 @@ const jasmineEnv: any = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; - jasmineEnv[methodName] = function( - description: string, - specDefinitions: Function - ) { - return originalJasmineFn.call( - this, - description, - wrapDescribeInZone(specDefinitions) - ); + jasmineEnv[methodName] = function(description: string, specDefinitions: Function) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); }; }); ['it', 'xit', 'fit'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function( - description: string, - specDefinitions: Function, - timeout: number - ) { + description: string, specDefinitions: Function, timeout: number) { arguments[1] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; @@ -72,16 +59,12 @@ ['beforeEach', 'afterEach'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function( - specDefinitions: Function, - timeout: number - ) { + jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { arguments[0] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); - const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = - jasmine['clock']); + const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); (jasmine as any)['clock'] = function() { const clock = originalClockFn.apply(this, arguments); const originalTick = (clock[symbol('tick')] = clock.tick); @@ -98,17 +81,13 @@ if (fakeAsyncZoneSpec) { const dateTime = arguments[0]; return fakeAsyncZoneSpec.setCurrentRealTime.apply( - fakeAsyncZoneSpec, - dateTime && typeof dateTime.getTime === 'function' - ? [dateTime.getTime()] - : arguments - ); + fakeAsyncZoneSpec, + dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); } return originalMockDate.apply(this, arguments); }; ['install', 'uninstall'].forEach(methodName => { - const originalClockFn: Function = (clock[symbol(methodName)] = - clock[methodName]); + const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); clock[methodName] = function() { const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; if (FakeAsyncTestZoneSpec) { @@ -131,11 +110,7 @@ }; } - function runInTestZone( - testBody: Function, - queueRunner: any, - done?: Function - ) { + function runInTestZone(testBody: Function, queueRunner: any, done?: Function) { const isClockInstalled = !!(jasmine as any)[symbol('clockInstalled')]; const testProxyZoneSpec = queueRunner.testProxyZoneSpec; const testProxyZone = queueRunner.testProxyZone; @@ -170,28 +145,23 @@ // The `done` callback is only passed through if the function expects at least one argument. // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. - return ( - testBody && - (testBody.length - ? function(done: Function) { - return runInTestZone(testBody, this.queueRunner, done); - } - : function() { - return runInTestZone(testBody, this.queueRunner); - }) - ); + return (testBody && (testBody.length ? function(done: Function) { + return runInTestZone(testBody, this.queueRunner, done); + } : function() { + return runInTestZone(testBody, this.queueRunner); + })); } interface QueueRunner { execute(): void; } interface QueueRunnerAttrs { - queueableFns: { fn: Function }[]; + queueableFns: {fn: Function}[]; onComplete: () => void; clearStack: (fn: any) => void; onException: (error: any) => void; catchException: () => boolean; userContext: any; - timeout: { setTimeout: Function; clearTimeout: Function }; + timeout: {setTimeout: Function; clearTimeout: Function}; fail: () => void; } @@ -201,9 +171,9 @@ (jasmine as any).QueueRunner = (function(_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(attrs: { - onComplete: Function; - userContext?: any; - timeout?: { setTimeout: Function; clearTimeout: Function }; + onComplete: Function; userContext?: any; + timeout?: {setTimeout: Function; clearTimeout: Function}; + onException?: (error: any) => void; }) { attrs.onComplete = (fn => () => { // All functions are done, clear the test zone. @@ -221,6 +191,7 @@ clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout }; } + // create a userContext to hold the queueRunner itself // so we can access the testProxy in it/xit/beforeEach ... if ((jasmine as any).UserContext) { @@ -234,6 +205,26 @@ } attrs.userContext.queueRunner = this; } + + // patch attrs.onException + const onException = attrs.onException; + attrs.onException = function(error: any) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + const proxyZoneSpec: any = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + const pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + error.message += pendingTasksInfo; + } + } + if (onException) { + onException.call(this, error); + } + }; + _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function() { @@ -247,8 +238,7 @@ zone = zone.parent; } - if (!isChildOfAmbientZone) - throw new Error('Unexpected Zone: ' + Zone.current.name); + if (!isChildOfAmbientZone) throw new Error('Unexpected Zone: ' + Zone.current.name); // This is the zone which will be used for running individual tests. // It will be a proxy zone, so that the tests function can retroactively install @@ -268,9 +258,8 @@ // addEventListener callback would think that it is the top most task and would // drain the microtask queue on element.click() which would be incorrect. // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask('jasmine.execute().forceTask', () => - QueueRunner.prototype.execute.call(this) - ); + Zone.current.scheduleMicroTask( + 'jasmine.execute().forceTask', () => QueueRunner.prototype.execute.call(this)); } else { _super.prototype.execute.call(this); } diff --git a/lib/mocha/mocha.ts b/lib/mocha/mocha.ts index 10156a82f..f36f76a4a 100644 --- a/lib/mocha/mocha.ts +++ b/lib/mocha/mocha.ts @@ -161,6 +161,13 @@ testZone = rootZone.fork(new ProxyZoneSpec()); }); + this.on('fail', (test:any, err: any) => { + const proxyZoneSpec = testZone && testZone.get('ProxyZoneSpec'); + if (proxyZoneSpec && err) { + err.message += proxyZoneSpec.getAndClearPendingTasksInfo(); + } + }); + return originalRun.call(this, fn); }; diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index f6935de0e..ee1bf9c5c 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -9,8 +9,6 @@ class AsyncTestZoneSpec implements ZoneSpec { static symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); - _finishCallback: Function; - _failCallback: Function; _pendingMicroTasks: boolean = false; _pendingMacroTasks: boolean = false; _alreadyErrored: boolean = false; @@ -18,9 +16,7 @@ class AsyncTestZoneSpec implements ZoneSpec { runZone = Zone.current; unresolvedChainedPromiseCount = 0; - constructor(finishCallback: Function, failCallback: Function, namePrefix: string) { - this._finishCallback = finishCallback; - this._failCallback = failCallback; + constructor(private finishCallback: Function, private failCallback: Function, namePrefix: string) { this.name = 'asyncTestZone for ' + namePrefix; this.properties = { 'AsyncTestZoneSpec': this @@ -33,7 +29,7 @@ class AsyncTestZoneSpec implements ZoneSpec { this.runZone.run(() => { setTimeout(() => { if (!this._alreadyErrored && !(this._pendingMicroTasks || this._pendingMacroTasks)) { - this._finishCallback(); + this.finishCallback(); } }, 0); }); @@ -115,7 +111,7 @@ class AsyncTestZoneSpec implements ZoneSpec { // Let the parent try to handle the error. const result = parentZoneDelegate.handleError(targetZone, error); if (result) { - this._failCallback(error); + this.failCallback(error); this._alreadyErrored = true; } return false; diff --git a/lib/zone-spec/proxy.ts b/lib/zone-spec/proxy.ts index 81c3110f3..e591be318 100644 --- a/lib/zone-spec/proxy.ts +++ b/lib/zone-spec/proxy.ts @@ -17,6 +17,8 @@ class ProxyZoneSpec implements ZoneSpec { lastTaskState: HasTaskState = null; isNeedToTriggerHasTask = false; + private tasks: Task[] = []; + static get(): ProxyZoneSpec { return Zone.current.get('ProxyZoneSpec'); } @@ -36,7 +38,6 @@ class ProxyZoneSpec implements ZoneSpec { this.setDelegate(defaultSpecDelegate); } - setDelegate(delegateSpec: ZoneSpec) { const isNewDelegate = this._delegateSpec !== delegateSpec; this._delegateSpec = delegateSpec; @@ -72,6 +73,37 @@ class ProxyZoneSpec implements ZoneSpec { } } + removeFromTasks(task: Task) { + if (!this.tasks) { + return; + } + for (let i = 0; i < this.tasks.length; i ++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; + } + } + } + + getAndClearPendingTasksInfo() { + if (this.tasks.length === 0) { + return ''; + } + const taskInfo = this.tasks.map((task: Task) => { + const dataInfo = task.data && + Object.keys(task.data) + .map((key: string) => { + return key + ':' + (task.data as any)[key]; + }) + .join(','); + return `type: ${task.type}, source: ${task.source}, args: {${dataInfo}}`; + }); + const pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + + return pendingTasksInfo; + } onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, zoneSpec: ZoneSpec): Zone { @@ -118,6 +150,9 @@ class ProxyZoneSpec implements ZoneSpec { onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): Task { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } if (this._delegateSpec && this._delegateSpec.onScheduleTask) { return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); } else { @@ -128,6 +163,9 @@ class ProxyZoneSpec implements ZoneSpec { onInvokeTask( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, applyThis: any, applyArgs: any): any { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onInvokeTask) { return this._delegateSpec.onInvokeTask( @@ -139,6 +177,9 @@ class ProxyZoneSpec implements ZoneSpec { onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onCancelTask) { return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); From a4b42cdf08f11ad236f2ab04597b0fd3b79a9557 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 31 Mar 2018 05:16:39 +0900 Subject: [PATCH 033/106] feat(test): move async/fakeAsync from angular to zone.js (#1048) --- gulpfile.js | 23 +- karma-dist.conf.js | 3 +- lib/testing/async-testing.ts | 102 +++++ lib/testing/fake-async.ts | 150 +++++++ lib/testing/zone-testing.ts | 4 +- lib/zone-spec/proxy.ts | 5 +- sauce.conf.js | 112 ++---- test/zone-spec/async-test.spec.ts | 361 +++++++---------- test/zone-spec/fake-async-test.spec.ts | 520 ++++++++++++++++++++++--- test/zone-spec/proxy.spec.ts | 16 +- test/zone-spec/sync-test.spec.ts | 1 - test/zone-spec/task-tracking.spec.ts | 2 - 12 files changed, 922 insertions(+), 377 deletions(-) create mode 100644 lib/testing/async-testing.ts create mode 100644 lib/testing/fake-async.ts diff --git a/gulpfile.js b/gulpfile.js index 2bab13d6f..f870a0929 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,6 +31,7 @@ function generateScript(inFile, outFile, minify, callback) { }, output: { format: 'umd', + name: 'zone', banner: '/**\n' + '* @license\n' + '* Copyright Google Inc. All Rights Reserved.\n' + @@ -221,19 +222,23 @@ gulp.task('build/zone-patch-socket-io.min.js', ['compile-esm'], function(cb) { }); gulp.task('build/zone-patch-promise-testing.js', ['compile-esm'], function(cb) { - return generateScript('./lib/testing/promise-testing.ts', 'zone-patch-promise-test.js', false, cb); + return generateScript( + './lib/testing/promise-testing.ts', 'zone-patch-promise-test.js', false, cb); }); gulp.task('build/zone-patch-promise-testing.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/testing/promise-testing.ts', 'zone-patch-promise-test.min.js', true, cb); + return generateScript( + './lib/testing/promise-testing.ts', 'zone-patch-promise-test.min.js', true, cb); }); gulp.task('build/zone-patch-resize-observer.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-resize-observer.ts', 'zone-patch-resize-observer.js', false, cb); + return generateScript( + './lib/browser/webapis-resize-observer.ts', 'zone-patch-resize-observer.js', false, cb); }); gulp.task('build/zone-patch-resize-observer.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/webapis-resize-observer.ts', 'zone-patch-resize-observer.min.js', true, cb); + return generateScript( + './lib/browser/webapis-resize-observer.ts', 'zone-patch-resize-observer.min.js', true, cb); }); gulp.task('build/bluebird.js', ['compile-esm'], function(cb) { @@ -245,11 +250,11 @@ gulp.task('build/bluebird.min.js', ['compile-esm'], function(cb) { }); gulp.task('build/zone-patch-jsonp.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/jsonp.ts', 'zone-patch-jsonp.js', false, cb); + return generateScript('./lib/extra/jsonp.ts', 'zone-patch-jsonp.js', false, cb); }); gulp.task('build/zone-patch-jsonp.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/extra/jsonp.ts', 'zone-patch-jsonp.min.js', true, cb); + return generateScript('./lib/extra/jsonp.ts', 'zone-patch-jsonp.min.js', true, cb); }); gulp.task('build/jasmine-patch.js', ['compile-esm'], function(cb) { @@ -323,11 +328,13 @@ gulp.task('build/rxjs.min.js', ['compile-esm'], function(cb) { }); gulp.task('build/rxjs-fake-async.js', ['compile-esm'], function(cb) { - return generateScript('./lib/rxjs/rxjs-fake-async.ts', 'zone-patch-rxjs-fake-async.js', false, cb); + return generateScript( + './lib/rxjs/rxjs-fake-async.ts', 'zone-patch-rxjs-fake-async.js', false, cb); }); gulp.task('build/rxjs-fake-async.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/rxjs/rxjs-fake-async.ts', 'zone-patch-rxjs-fake-async.min.js', true, cb); + return generateScript( + './lib/rxjs/rxjs-fake-async.ts', 'zone-patch-rxjs-fake-async.min.js', true, cb); }); gulp.task('build/closure.js', function() { diff --git a/karma-dist.conf.js b/karma-dist.conf.js index a96fe0993..c7946e144 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -6,13 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { +module.exports = function(config) { require('./karma-base.conf.js')(config); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); config.files.push('dist/zone.js'); config.files.push('dist/zone-patch-user-media.js'); + config.files.push('dist/zone-patch-resize-observer.js'); config.files.push('dist/async-test.js'); config.files.push('dist/fake-async-test.js'); config.files.push('dist/long-stack-trace-zone.js'); diff --git a/lib/testing/async-testing.ts b/lib/testing/async-testing.ts new file mode 100644 index 000000000..6ad4f608e --- /dev/null +++ b/lib/testing/async-testing.ts @@ -0,0 +1,102 @@ +/** + * @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 _global: any = + typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; + +/** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ +export function asyncTest(fn: Function): (done: any) => any { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (_global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function(done: any) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function() {}; + done.fail = function(e: any) { + throw e; + }; + } + runInTestZone(fn, this, done, (err: any) => { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function() { + return new Promise((finishCallback, failCallback) => { + runInTestZone(fn, this, finishCallback, failCallback); + }); + }; +} + +function runInTestZone( + fn: Function, context: any, finishCallback: Function, failCallback: Function) { + const currentZone = Zone.current; + const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error( + 'AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + const ProxyZoneSpec = (Zone as any)['ProxyZoneSpec'] as { + get(): {setDelegate(spec: ZoneSpec): void; getDelegate(): ZoneSpec;}; + assertPresent: () => void; + }; + if (ProxyZoneSpec === undefined) { + throw new Error( + 'ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + const proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + const previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(() => { + const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec( + () => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(() => { + finishCallback(); + }); + }, + (error: any) => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(() => { + failCallback(error); + }); + }, + 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); +} diff --git a/lib/testing/fake-async.ts b/lib/testing/fake-async.ts new file mode 100644 index 000000000..7690f26aa --- /dev/null +++ b/lib/testing/fake-async.ts @@ -0,0 +1,150 @@ +/** + * @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 FakeAsyncTestZoneSpec = Zone && (Zone as any)['FakeAsyncTestZoneSpec']; +type ProxyZoneSpec = { + setDelegate(delegateSpec: ZoneSpec): void; getDelegate(): ZoneSpec; resetDelegate(): void; +}; +const ProxyZoneSpec: {get(): ProxyZoneSpec; assertPresent: () => ProxyZoneSpec} = + Zone && (Zone as any)['ProxyZoneSpec']; + +let _fakeAsyncTestZoneSpec: any = null; + +/** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ +export function resetFakeAsyncZone() { + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); +} + +let _inFakeAsyncCall = false; + +/** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ +export function fakeAsync(fn: Function): (...args: any[]) => any { + // Not using an arrow function to preserve context passed from call site + return function(...args: any[]) { + const proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (_inFakeAsyncCall) { + throw new Error('fakeAsync() calls can not be nested'); + } + _inFakeAsyncCall = true; + try { + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + + let res: any; + const lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error( + `${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` + + `periodic timer(s) still in the queue.`); + } + + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error( + `${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`); + } + return res; + } finally { + _inFakeAsyncCall = false; + resetFakeAsyncZone(); + } + }; +} + +function _getFakeAsyncZoneSpec(): any { + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + return _fakeAsyncTestZoneSpec; +} + +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ +export function tick(millis: number = 0): void { + _getFakeAsyncZoneSpec().tick(millis); +} + +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ +export function flush(maxTurns?: number): number { + return _getFakeAsyncZoneSpec().flush(maxTurns); +} + +/** + * Discard all remaining periodic tasks. + * + * @experimental + */ +export function discardPeriodicTasks(): void { + const zoneSpec = _getFakeAsyncZoneSpec(); + const pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; +} + +/** + * Flush any pending microtasks. + * + * @experimental + */ +export function flushMicrotasks(): void { + _getFakeAsyncZoneSpec().flushMicrotasks(); +} diff --git a/lib/testing/zone-testing.ts b/lib/testing/zone-testing.ts index 51218110e..c566694b9 100644 --- a/lib/testing/zone-testing.ts +++ b/lib/testing/zone-testing.ts @@ -13,4 +13,6 @@ import '../zone-spec/sync-test'; import '../jasmine/jasmine'; import '../zone-spec/async-test'; import '../zone-spec/fake-async-test'; -import './promise-testing'; \ No newline at end of file +import './promise-testing'; +export * from './async-testing'; +export * from './fake-async'; \ No newline at end of file diff --git a/lib/zone-spec/proxy.ts b/lib/zone-spec/proxy.ts index e591be318..385129766 100644 --- a/lib/zone-spec/proxy.ts +++ b/lib/zone-spec/proxy.ts @@ -5,7 +5,6 @@ * 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 { name: string = 'ProxyZone'; @@ -28,7 +27,7 @@ class ProxyZoneSpec implements ZoneSpec { } static assertPresent(): ProxyZoneSpec { - if (!this.isLoaded()) { + if (!ProxyZoneSpec.isLoaded()) { throw new Error(`Expected to be running in 'ProxyZone', but it was not found.`); } return ProxyZoneSpec.get(); @@ -69,7 +68,7 @@ class ProxyZoneSpec implements ZoneSpec { // last delegateSpec has microTask or macroTask // should call onHasTask in current delegateSpec this.isNeedToTriggerHasTask = false; - this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); } } diff --git a/sauce.conf.js b/sauce.conf.js index a6026ad50..1aac560bd 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -1,54 +1,26 @@ // Sauce configuration -module.exports = function (config, ignoredLaunchers) { +module.exports = function(config, ignoredLaunchers) { // The WS server is not available with Sauce config.files.unshift('test/saucelabs.js'); var basicLaunchers = { - 'SL_CHROME': { - base: 'SauceLabs', - browserName: 'chrome', - version: '48' - }, - 'SL_CHROME_60': { - base: 'SauceLabs', - browserName: 'chrome', - version: '60' - }, - 'SL_FIREFOX': { - base: 'SauceLabs', - browserName: 'firefox', - version: '52' - }, - 'SL_FIREFOX_54': { - base: 'SauceLabs', - browserName: 'firefox', - version: '54' - }, + 'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '48'}, + 'SL_CHROME_60': {base: 'SauceLabs', browserName: 'chrome', version: '60'}, + 'SL_FIREFOX': {base: 'SauceLabs', browserName: 'firefox', version: '52'}, + 'SL_FIREFOX_54': {base: 'SauceLabs', browserName: 'firefox', version: '54'}, /*'SL_SAFARI7': { base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.9', version: '7.0' },*/ - 'SL_SAFARI8': { - base: 'SauceLabs', - browserName: 'safari', - platform: 'OS X 10.10', - version: '8.0' - }, - 'SL_SAFARI9': { - base: 'SauceLabs', - browserName: 'safari', - platform: 'OS X 10.11', - version: '9.0' - }, - 'SL_SAFARI10': { - base: 'SauceLabs', - browserName: 'safari', - platform: 'OS X 10.11', - version: '10.0' - }, + 'SL_SAFARI8': + {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.10', version: '8.0'}, + 'SL_SAFARI9': + {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.11', version: '9.0'}, + 'SL_SAFARI10': + {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.11', version: '10.0'}, /* no longer supported in SauceLabs 'SL_IOS7': { @@ -57,24 +29,14 @@ module.exports = function (config, ignoredLaunchers) { platform: 'OS X 10.10', version: '7.1' },*/ - 'SL_IOS8': { + /*'SL_IOS8': { base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '8.4' - }, - 'SL_IOS9': { - base: 'SauceLabs', - browserName: 'iphone', - platform: 'OS X 10.10', - version: '9.3' - }, - 'SL_IOS10': { - base: 'SauceLabs', - browserName: 'iphone', - platform: 'OS X 10.10', - version: '10.2' - }, + },*/ + 'SL_IOS9': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'}, + 'SL_IOS10': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '10.2'}, 'SL_IE9': { base: 'SauceLabs', browserName: 'internet explorer', @@ -125,24 +87,9 @@ module.exports = function (config, ignoredLaunchers) { platform: 'Linux', version: '4.3' },*/ - 'SL_ANDROID4.4': { - base: 'SauceLabs', - browserName: 'android', - platform: 'Linux', - version: '4.4' - }, - 'SL_ANDROID5.1': { - base: 'SauceLabs', - browserName: 'android', - platform: 'Linux', - version: '5.1' - }, - 'SL_ANDROID6.0': { - base: 'SauceLabs', - browserName: 'android', - platform: 'Linux', - version: '6.0' - }, + 'SL_ANDROID4.4': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '4.4'}, + 'SL_ANDROID5.1': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '5.1'}, + 'SL_ANDROID6.0': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '6.0'}, 'SL_ANDROID7.1': { base: 'SauceLabs', browserName: 'Chrome', @@ -158,7 +105,11 @@ module.exports = function (config, ignoredLaunchers) { customLaunchers = basicLaunchers; } else { Object.keys(basicLaunchers).forEach(function(key) { - if (ignoredLaunchers.filter(function(ignore) {return ignore === key;}).length === 0) { + if (ignoredLaunchers + .filter(function(ignore) { + return ignore === key; + }) + .length === 0) { customLaunchers[key] = basicLaunchers[key]; } }); @@ -173,11 +124,11 @@ module.exports = function (config, ignoredLaunchers) { startConnect: false, recordVideo: false, recordScreenshots: false, - options: { - 'selenium-version': '2.53.0', - 'command-timeout': 600, - 'idle-timeout': 600, - 'max-duration': 5400 + options: { + 'selenium-version': '2.53.0', + 'command-timeout': 600, + 'idle-timeout': 600, + 'max-duration': 5400 } }, @@ -189,13 +140,12 @@ module.exports = function (config, ignoredLaunchers) { singleRun: true, - plugins: [ - 'karma-*' - ] + plugins: ['karma-*'] }); if (process.env.TRAVIS) { - config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; + config.sauceLabs.build = + 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index 98610da00..95918ff25 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/zone-spec/async-test'; +import {asyncTest} from '../../lib/testing/async-testing'; import {ifEnvSupports} from '../test-util'; describe('AsyncTestZoneSpec', function() { @@ -345,268 +345,189 @@ describe('AsyncTestZoneSpec', function() { }); }); - describe('ProxyZone with AsyncTestZoneSpec', () => { - const ProxyZoneSpec = (Zone as any)['ProxyZoneSpec']; - const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; - - function testAsync(fn: Function, doneFn?: Function) { - return function(done: any) { - runInTestZone(fn, this, function() { - if (doneFn) { - doneFn(); - } - done(); - }, (err: any) => { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } else { - done.fail(err); - } - }); - }; - } - - function runInTestZone( - fn: Function, context: any, finishCallback: Function, failCallback: Function) { - const currentZone = Zone.current; - const proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - const previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(() => { - const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec( - () => { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(() => { - finishCallback(); - }); - }, - (error: any) => { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(() => { - failCallback(error); - }); - }, - 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); - } + function wrapAsyncTest(fn: Function, doneFn?: Function) { + return function(done: Function) { + const asyncWrapper = asyncTest(fn); + return asyncWrapper.apply(this, [function() { + if (doneFn) { + doneFn(); + } + return done.apply(this, arguments); + }]); + }; + } + describe('async', () => { describe('test without beforeEach', () => { const logs: string[] = []; - it('should automatically done after async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['timeout']); - logs.splice(0); - })); - - it('should automatically done after all nested async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - setTimeout(() => { - logs.push('nested timeout'); - }, 100); - }, 100); - }, () => { - expect(logs).toEqual(['timeout', 'nested timeout']); - logs.splice(0); - })); - - it('should automatically done after multiple async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('1st timeout'); - }, 100); - - setTimeout(() => { - logs.push('2nd timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['1st timeout', '2nd timeout']); - logs.splice(0); - })); + it('should automatically done after async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['timeout']); + logs.splice(0); + })); + + it('should automatically done after all nested async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + setTimeout(() => { + logs.push('nested timeout'); + }, 100); + }, 100); + }, + () => { + expect(logs).toEqual(['timeout', 'nested timeout']); + logs.splice(0); + })); + + it('should automatically done after multiple async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('1st timeout'); + }, 100); + + setTimeout(() => { + logs.push('2nd timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['1st timeout', '2nd timeout']); + logs.splice(0); + })); }); - + describe('test with sync beforeEach', () => { const logs: string[] = []; - + beforeEach(() => { logs.splice(0); logs.push('beforeEach'); }); - - it('should automatically done after async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['beforeEach', 'timeout']); - })); + + it('should automatically done after async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); }); - + describe('test with async beforeEach', () => { const logs: string[] = []; - - beforeEach(testAsync(() => { + + beforeEach(wrapAsyncTest(() => { setTimeout(() => { logs.splice(0); logs.push('beforeEach'); }, 100); })); - - it('should automatically done after async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['beforeEach', 'timeout']); - })); - - it('should automatically done after all nested async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - setTimeout(() => { - logs.push('nested timeout'); - }, 100); - }, 100); - }, () => { - expect(logs).toEqual(['beforeEach', 'timeout', 'nested timeout']); - })); - - it('should automatically done after multiple async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('1st timeout'); - }, 100); - - setTimeout(() => { - logs.push('2nd timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['beforeEach', '1st timeout', '2nd timeout']); - })); + + it('should automatically done after async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); + + it('should automatically done after all nested async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + setTimeout(() => { + logs.push('nested timeout'); + }, 100); + }, 100); + }, + () => { + expect(logs).toEqual(['beforeEach', 'timeout', 'nested timeout']); + })); + + it('should automatically done after multiple async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('1st timeout'); + }, 100); + + setTimeout(() => { + logs.push('2nd timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['beforeEach', '1st timeout', '2nd timeout']); + })); }); - + describe('test with async beforeEach and sync afterEach', () => { const logs: string[] = []; - - beforeEach(testAsync(() => { + + beforeEach(wrapAsyncTest(() => { setTimeout(() => { expect(logs).toEqual([]); logs.push('beforeEach'); }, 100); })); - + afterEach(() => { logs.splice(0); }); - - it('should automatically done after async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['beforeEach', 'timeout']); - })); + + it('should automatically done after async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); }); - + describe('test with async beforeEach and async afterEach', () => { const logs: string[] = []; - - beforeEach(testAsync(() => { + + beforeEach(wrapAsyncTest(() => { setTimeout(() => { expect(logs).toEqual([]); logs.push('beforeEach'); }, 100); })); - - afterEach(testAsync(() => { + + afterEach(wrapAsyncTest(() => { setTimeout(() => { logs.splice(0); }, 100); })); - - it('should automatically done after async tasks finished', testAsync(() => { - setTimeout(() => { - logs.push('timeout'); - }, 100); - }, () => { - expect(logs).toEqual(['beforeEach', 'timeout']); - })); - }); - describe('return promise', () => { - let value = 'init'; - it('should only call finish once', testAsync(() => { - return new Promise((resolve, _) => { - setTimeout(() => { - value = 'timeout'; - resolve(); - }, 100); - }); - }, () => { - expect(value).toEqual('timeout'); - })); + it('should automatically done after async tasks finished', + wrapAsyncTest( + () => { + setTimeout(() => { + logs.push('timeout'); + }, 100); + }, + () => { + expect(logs).toEqual(['beforeEach', 'timeout']); + })); }); }); - describe('should be able to handle async for both beforeEach and it', () => { - let log: string[]; - const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; - - function asyncTest(testBody: () => void, finishCallback: Function, failCallback: Function) { - return function() { - const proxyZoneSpec = Zone.current.get('ProxyZoneSpec'); - if (!proxyZoneSpec) { - throw new Error('ProxyZone not found!'); - } - const lastDelegate = proxyZoneSpec.getDelegate(); - // construct AsyncTestZoneSpec in parent zone - // to prevent infinite loop - Zone.current.parent.run(() => { - proxyZoneSpec.setDelegate(new AsyncTestZoneSpec(() => { - proxyZoneSpec.setDelegate(lastDelegate); - finishCallback(); - }, () => { - proxyZoneSpec.setDelegate(lastDelegate); - failCallback(); - }), 'async'); - }); - testBody.apply(this, arguments); - }; - } - - beforeEach(asyncTest(() => { - log = []; - setTimeout(() => { - log.push('beforeEach'); - }, 50); - }, () => { - expect(log).toEqual(['beforeEach']); - }, () => { - fail('should not fail'); - })); - - it('should support asyncTest with an async beforeEach', asyncTest(() => { - setTimeout(() => { - log.push('timeout'); - }, 50); - }, () => { - expect(log).toEqual(['beforeEach', 'timeout']); - }, () => { - fail('should not fail'); - })); - }); }); diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 9889cff39..f1e23abb8 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -6,13 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/zone-spec/fake-async-test'; +import 'rxjs/add/operator/delay'; +import '../../lib/rxjs/rxjs-fake-async'; + +import {Observable} from 'rxjs/Observable'; import {isNode, patchMacroTask} from '../../lib/common/utils'; +import {discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, tick} from '../../lib/testing/fake-async'; import {ifEnvSupports} from '../test-util'; -import {Observable} from 'rxjs/Observable'; -import 'rxjs/add/operator/delay'; -import '../../lib/rxjs/rxjs-fake-async'; function supportNode() { return isNode; @@ -212,7 +213,7 @@ describe('FakeAsyncTestZoneSpec', () => { let id = setTimeout((arg1, arg2) => { value = arg1 + arg2; }, 0, 'expected', ' value'); - + testZoneSpec.tick(); expect(value).toEqual('expected value'); }); @@ -245,7 +246,7 @@ describe('FakeAsyncTestZoneSpec', () => { let id = setInterval((arg1, arg2) => { value = arg1 + arg2; }, 10, 'expected', ' value'); - + testZoneSpec.tick(10); expect(value).toEqual('expected value'); }); @@ -859,8 +860,7 @@ describe('FakeAsyncTestZoneSpec', () => { let fakeAsyncTestZone: Zone; beforeEach(() => { - testZoneSpec = new FakeAsyncTestZoneSpec( - 'name', false); + testZoneSpec = new FakeAsyncTestZoneSpec('name', false); fakeAsyncTestZone = Zone.current.fork(testZoneSpec); }); @@ -874,46 +874,50 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); - describe('fakeAsyncTest should patch jasmine.clock', ifEnvSupports(() => { - return typeof jasmine.clock === 'function'; - }, () => { - beforeEach(() => { - jasmine.clock().install(); - }); + describe( + 'fakeAsyncTest should patch jasmine.clock', + ifEnvSupports( + () => { + return typeof jasmine.clock === 'function'; + }, + () => { + beforeEach(() => { + jasmine.clock().install(); + }); - afterEach(() => { - jasmine.clock().uninstall(); - }); + afterEach(() => { + jasmine.clock().uninstall(); + }); - it('should get date diff correctly', () => { - const start = Date.now(); - jasmine.clock().tick(100); - const end = Date.now(); - expect(end - start).toBe(100); - }); - - it('should mock date correctly', () => { - const baseTime = new Date(2013, 9, 23); - jasmine.clock().mockDate(baseTime); - const start = Date.now(); - expect(start).toBe(baseTime.getTime()); - jasmine.clock().tick(100); - const end = Date.now(); - expect(end - start).toBe(100); - expect(end).toBe(baseTime.getTime() + 100); - }); - - it('should handle new Date correctly', () => { - const baseTime = new Date(2013, 9, 23); - jasmine.clock().mockDate(baseTime); - const start = new Date(); - expect(start.getTime()).toBe(baseTime.getTime()); - jasmine.clock().tick(100); - const end = new Date(); - expect(end.getTime() - start.getTime()).toBe(100); - expect(end.getTime()).toBe(baseTime.getTime() + 100); - }); - })); + it('should get date diff correctly', () => { + const start = Date.now(); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + }); + + it('should mock date correctly', () => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = Date.now(); + expect(start).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + expect(end).toBe(baseTime.getTime() + 100); + }); + + it('should handle new Date correctly', () => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = new Date(); + expect(start.getTime()).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = new Date(); + expect(end.getTime() - start.getTime()).toBe(100); + expect(end.getTime()).toBe(baseTime.getTime() + 100); + }); + })); describe('fakeAsyncTest should patch rxjs scheduler', () => { let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; @@ -921,8 +925,7 @@ describe('FakeAsyncTestZoneSpec', () => { let fakeAsyncTestZone: Zone; beforeEach(() => { - testZoneSpec = new FakeAsyncTestZoneSpec( - 'name', false); + testZoneSpec = new FakeAsyncTestZoneSpec('name', false); fakeAsyncTestZone = Zone.current.fork(testZoneSpec); }); @@ -944,3 +947,424 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); }); + +class Log { + logItems: any[]; + + constructor() { + this.logItems = []; + } + + add(value: any /** TODO #9100 */): void { + this.logItems.push(value); + } + + fn(value: any /** TODO #9100 */) { + return (a1: any = null, a2: any = null, a3: any = null, a4: any = null, a5: any = null) => { + this.logItems.push(value); + }; + } + + clear(): void { + this.logItems = []; + } + + result(): string { + return this.logItems.join('; '); + } +} + +const resolvedPromise = Promise.resolve(null); +const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec']; + +{ + describe('fake async', () => { + it('should run synchronous code', () => { + let ran = false; + fakeAsync(() => { + ran = true; + })(); + + expect(ran).toEqual(true); + }); + + it('should pass arguments to the wrapped function', () => { + fakeAsync((foo: any /** TODO #9100 */, bar: any /** TODO #9100 */) => { + expect(foo).toEqual('foo'); + expect(bar).toEqual('bar'); + })('foo', 'bar'); + }); + + + it('should throw on nested calls', () => { + expect(() => { + fakeAsync(() => { + fakeAsync((): any /** TODO #9100 */ => null)(); + })(); + }).toThrowError('fakeAsync() calls can not be nested'); + }); + + it('should flush microtasks before returning', () => { + let thenRan = false; + + fakeAsync(() => { + resolvedPromise.then(_ => { + thenRan = true; + }); + })(); + + expect(thenRan).toEqual(true); + }); + + + it('should propagate the return value', () => { + expect(fakeAsync(() => 'foo')()).toEqual('foo'); + }); + + describe('Promise', () => { + it('should run asynchronous code', fakeAsync(() => { + let thenRan = false; + resolvedPromise.then((_) => { + thenRan = true; + }); + + expect(thenRan).toEqual(false); + + flushMicrotasks(); + expect(thenRan).toEqual(true); + })); + + it('should run chained thens', fakeAsync(() => { + const log = new Log(); + + resolvedPromise.then((_) => log.add(1)).then((_) => log.add(2)); + + expect(log.result()).toEqual(''); + + flushMicrotasks(); + expect(log.result()).toEqual('1; 2'); + })); + + it('should run Promise created in Promise', fakeAsync(() => { + const log = new Log(); + + resolvedPromise.then((_) => { + log.add(1); + resolvedPromise.then((_) => log.add(2)); + }); + + expect(log.result()).toEqual(''); + + flushMicrotasks(); + expect(log.result()).toEqual('1; 2'); + })); + + it('should complain if the test throws an exception during async calls', () => { + expect(() => { + fakeAsync(() => { + resolvedPromise.then((_) => { + throw new Error('async'); + }); + flushMicrotasks(); + })(); + }).toThrowError(/Uncaught \(in promise\): Error: async/); + }); + + it('should complain if a test throws an exception', () => { + expect(() => { + fakeAsync(() => { + throw new Error('sync'); + })(); + }).toThrowError('sync'); + }); + + }); + + describe('timers', () => { + it('should run queued zero duration timer on zero tick', fakeAsync(() => { + let ran = false; + setTimeout(() => { + ran = true; + }, 0); + + expect(ran).toEqual(false); + + tick(); + expect(ran).toEqual(true); + })); + + + it('should run queued timer after sufficient clock ticks', fakeAsync(() => { + let ran = false; + setTimeout(() => { + ran = true; + }, 10); + + tick(6); + expect(ran).toEqual(false); + + tick(6); + expect(ran).toEqual(true); + })); + + it('should run queued timer only once', fakeAsync(() => { + let cycles = 0; + setTimeout(() => { + cycles++; + }, 10); + + tick(10); + expect(cycles).toEqual(1); + + tick(10); + expect(cycles).toEqual(1); + + tick(10); + expect(cycles).toEqual(1); + })); + + it('should not run cancelled timer', fakeAsync(() => { + let ran = false; + const id = setTimeout(() => { + ran = true; + }, 10); + clearTimeout(id); + + tick(10); + expect(ran).toEqual(false); + })); + + it('should throw an error on dangling timers', () => { + expect(() => { + fakeAsync(() => { + setTimeout(() => {}, 10); + })(); + }).toThrowError('1 timer(s) still in the queue.'); + }); + + it('should throw an error on dangling periodic timers', () => { + expect(() => { + fakeAsync(() => { + setInterval(() => {}, 10); + })(); + }).toThrowError('1 periodic timer(s) still in the queue.'); + }); + + it('should run periodic timers', fakeAsync(() => { + let cycles = 0; + const id = setInterval(() => { + cycles++; + }, 10); + + tick(10); + expect(cycles).toEqual(1); + + tick(10); + expect(cycles).toEqual(2); + + tick(10); + expect(cycles).toEqual(3); + clearInterval(id); + })); + + it('should not run cancelled periodic timer', fakeAsync(() => { + let ran = false; + const id = setInterval(() => { + ran = true; + }, 10); + clearInterval(id); + + tick(10); + expect(ran).toEqual(false); + })); + + it('should be able to cancel periodic timers from a callback', fakeAsync(() => { + let cycles = 0; + let id: any /** TODO #9100 */; + + id = setInterval(() => { + cycles++; + clearInterval(id); + }, 10); + + tick(10); + expect(cycles).toEqual(1); + + tick(10); + expect(cycles).toEqual(1); + })); + + it('should clear periodic timers', fakeAsync(() => { + let cycles = 0; + const id = setInterval(() => { + cycles++; + }, 10); + + tick(10); + expect(cycles).toEqual(1); + + discardPeriodicTasks(); + + // Tick once to clear out the timer which already started. + tick(10); + expect(cycles).toEqual(2); + + tick(10); + // Nothing should change + expect(cycles).toEqual(2); + })); + + it('should process microtasks before timers', fakeAsync(() => { + const log = new Log(); + + resolvedPromise.then((_) => log.add('microtask')); + + setTimeout(() => log.add('timer'), 9); + + const id = setInterval(() => log.add('periodic timer'), 10); + + expect(log.result()).toEqual(''); + + tick(10); + expect(log.result()).toEqual('microtask; timer; periodic timer'); + clearInterval(id); + })); + + it('should process micro-tasks created in timers before next timers', fakeAsync(() => { + const log = new Log(); + + resolvedPromise.then((_) => log.add('microtask')); + + setTimeout(() => { + log.add('timer'); + resolvedPromise.then((_) => log.add('t microtask')); + }, 9); + + const id = setInterval(() => { + log.add('periodic timer'); + resolvedPromise.then((_) => log.add('pt microtask')); + }, 10); + + tick(10); + expect(log.result()) + .toEqual('microtask; timer; t microtask; periodic timer; pt microtask'); + + tick(10); + expect(log.result()) + .toEqual( + 'microtask; timer; t microtask; periodic timer; pt microtask; periodic timer; pt microtask'); + clearInterval(id); + })); + + it('should flush tasks', fakeAsync(() => { + let ran = false; + setTimeout(() => { + ran = true; + }, 10); + + flush(); + expect(ran).toEqual(true); + })); + + it('should flush multiple tasks', fakeAsync(() => { + let ran = false; + let ran2 = false; + setTimeout(() => { + ran = true; + }, 10); + setTimeout(() => { + ran2 = true; + }, 30); + + let elapsed = flush(); + + expect(ran).toEqual(true); + expect(ran2).toEqual(true); + expect(elapsed).toEqual(30); + })); + + it('should move periodic tasks', fakeAsync(() => { + let ran = false; + let count = 0; + setInterval(() => { + count++; + }, 10); + setTimeout(() => { + ran = true; + }, 35); + + let elapsed = flush(); + + expect(count).toEqual(3); + expect(ran).toEqual(true); + expect(elapsed).toEqual(35); + + discardPeriodicTasks(); + })); + }); + + describe('outside of the fakeAsync zone', () => { + it('calling flushMicrotasks should throw', () => { + expect(() => { + flushMicrotasks(); + }).toThrowError('The code should be running in the fakeAsync zone to call this function'); + }); + + it('calling tick should throw', () => { + expect(() => { + tick(); + }).toThrowError('The code should be running in the fakeAsync zone to call this function'); + }); + + it('calling flush should throw', () => { + expect(() => { + flush(); + }).toThrowError('The code should be running in the fakeAsync zone to call this function'); + }); + + it('calling discardPeriodicTasks should throw', () => { + expect(() => { + discardPeriodicTasks(); + }).toThrowError('The code should be running in the fakeAsync zone to call this function'); + }); + }); + + describe('only one `fakeAsync` zone per test', () => { + let zoneInBeforeEach: Zone; + let zoneInTest1: Zone; + beforeEach(fakeAsync(() => { + zoneInBeforeEach = Zone.current; + })); + + it('should use the same zone as in beforeEach', fakeAsync(() => { + zoneInTest1 = Zone.current; + expect(zoneInTest1).toBe(zoneInBeforeEach); + })); + }); + }); + + describe('ProxyZone', () => { + beforeEach(() => { + ProxyZoneSpec.assertPresent(); + }); + + afterEach(() => { + ProxyZoneSpec.assertPresent(); + }); + + it('should allow fakeAsync zone to retroactively set a zoneSpec outside of fakeAsync', () => { + ProxyZoneSpec.assertPresent(); + let state: string = 'not run'; + const testZone = Zone.current.fork({name: 'test-zone'}); + (fakeAsync(() => { + testZone.run(() => { + Promise.resolve('works').then((v) => state = v); + expect(state).toEqual('not run'); + flushMicrotasks(); + expect(state).toEqual('works'); + }); + }))(); + expect(state).toEqual('works'); + }); + }); +} \ No newline at end of file diff --git a/test/zone-spec/proxy.spec.ts b/test/zone-spec/proxy.spec.ts index d815ce631..950353fef 100644 --- a/test/zone-spec/proxy.spec.ts +++ b/test/zone-spec/proxy.spec.ts @@ -6,8 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/zone-spec/proxy'; - describe('ProxySpec', () => { let ProxyZoneSpec: any; let delegate: ZoneSpec; @@ -192,16 +190,10 @@ describe('ProxySpec', () => { setTimeout(() => { expect(log).toEqual([ - 'zoneSpec1 hasTask: false,true', - 'zoneSpec2 hasTask: false,true', - 'zoneSpec2 hasTask: true,true', - 'zoneSpec2 hasTask: true,true', - 'then in zoneSpec2', - 'then in zoneSpec2', - 'zoneSpec2 hasTask: false,true', - 'timeout in zoneSpec1', - 'timeout in null spec', - 'zoneSpec2 hasTask: false,false' + 'zoneSpec1 hasTask: false,true', 'zoneSpec2 hasTask: false,true', + 'zoneSpec2 hasTask: true,true', 'zoneSpec2 hasTask: true,true', 'then in zoneSpec2', + 'then in zoneSpec2', 'zoneSpec2 hasTask: false,true', 'timeout in zoneSpec1', + 'timeout in null spec', 'zoneSpec2 hasTask: false,false' ]); done(); }, 300); diff --git a/test/zone-spec/sync-test.spec.ts b/test/zone-spec/sync-test.spec.ts index 2dbe9cb1b..d51dff686 100644 --- a/test/zone-spec/sync-test.spec.ts +++ b/test/zone-spec/sync-test.spec.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/zone-spec/sync-test'; import {ifEnvSupports} from '../test-util'; describe('SyncTestZoneSpec', () => { diff --git a/test/zone-spec/task-tracking.spec.ts b/test/zone-spec/task-tracking.spec.ts index e9537579c..1c7115d2a 100644 --- a/test/zone-spec/task-tracking.spec.ts +++ b/test/zone-spec/task-tracking.spec.ts @@ -6,8 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/zone-spec/task-tracking'; - import {supportPatchXHROnProperty} from '../test-util'; declare const global: any; From 68682cd6233a66cb5e964ef36f7e063adba6efca Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 31 Mar 2018 06:07:41 +0900 Subject: [PATCH 034/106] fix(fakeAsync): fix #1056, fakeAsync timerId should not be zero (#1057) --- lib/zone-spec/fake-async-test.ts | 16 ++++++++++------ test/test-env-setup-mocha.ts | 5 +++++ test/zone-spec/fake-async-test.spec.ts | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 9b2fc55d7..fdc17d5d7 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -56,7 +56,7 @@ class Scheduler { // Next scheduler id. - public nextId: number = 0; + public nextId: number = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. private _schedulerQueue: ScheduledFunction[] = []; @@ -409,12 +409,14 @@ case 'macroTask': switch (task.source) { case 'setTimeout': - task.data['handleId'] = - this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call((task.data as any)['args'], 2)); + task.data['handleId'] = this._setTimeout( + task.invoke, task.data['delay'], + Array.prototype.slice.call((task.data as any)['args'], 2)); break; case 'setInterval': - task.data['handleId'] = - this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call((task.data as any)['args'], 2)); + task.data['handleId'] = this._setInterval( + task.invoke, task.data['delay'], + Array.prototype.slice.call((task.data as any)['args'], 2)); break; case 'XMLHttpRequest.send': throw new Error( @@ -480,7 +482,9 @@ } } - onInvoke(delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string): any { + onInvoke( + delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, + applyArgs: any[], source: string): any { try { FakeAsyncTestZoneSpec.patchDate(); return delegate.invoke(target, callback, applyThis, applyArgs, source); diff --git a/test/test-env-setup-mocha.ts b/test/test-env-setup-mocha.ts index b4bfec037..bf2129452 100644 --- a/test/test-env-setup-mocha.ts +++ b/test/test-env-setup-mocha.ts @@ -76,6 +76,11 @@ declare const global: any; throw new Error(`Expected ${expected} to be ${actual}`); } }, + toBeGreaterThan: function(actual: number) { + if (expected <= actual) { + throw new Error(`Expected ${expected} to be greater than ${actual}`); + } + }, toBeDefined: function() { if (!expected) { throw new Error(`Expected ${expected} to be defined`); diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index f1e23abb8..bb40a84b3 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -226,6 +226,8 @@ describe('FakeAsyncTestZoneSpec', () => { cycles++; }, 10); + expect(id).toBeGreaterThan(0); + testZoneSpec.tick(10); expect(cycles).toEqual(1); From 6654b6900a88aec9e5eeacaedcf46517b26c73a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Fri, 30 Mar 2018 14:13:08 -0700 Subject: [PATCH 035/106] chore: release v0.8.21 --- CHANGELOG.md | 35 ++ dist/async-test.js | 65 ++- dist/fake-async-test.js | 81 +++- dist/jasmine-patch.js | 156 ++++++- dist/jasmine-patch.min.js | 2 +- dist/long-stack-trace-zone.js | 2 +- dist/mocha-patch.js | 9 +- dist/mocha-patch.min.js | 2 +- dist/proxy.js | 66 ++- dist/proxy.min.js | 2 +- dist/sync-test.js | 2 +- dist/task-tracking.js | 2 +- dist/webapis-media-query.js | 61 ++- dist/webapis-media-query.min.js | 2 +- dist/wtf.js | 12 +- dist/wtf.min.js | 2 +- dist/zone-bluebird.js | 28 +- dist/zone-bluebird.min.js | 2 +- dist/zone-mix.js | 98 +++-- dist/zone-node.js | 95 +++-- dist/zone-patch-rxjs.js | 52 +-- dist/zone-testing-bundle.js | 623 ++++++++++++++++++++++++---- dist/zone-testing-node-bundle.js | 620 ++++++++++++++++++++++++---- dist/zone-testing.js | 686 ++++++++++++++++++++++++++++--- dist/zone.js | 98 +++-- dist/zone.js.d.ts | 6 + dist/zone.min.js | 4 +- package.json | 2 +- 28 files changed, 2414 insertions(+), 401 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 896989b7a..1869ed0ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ + +## [0.8.21](https://github.com/angular/zone.js/compare/v0.8.20...0.8.21) (2018-03-30) + + +### Bug Fixes + +* add OriginalDelegate prop to Function::toString ([#993](https://github.com/angular/zone.js/issues/993)) ([2dc7e5c](https://github.com/angular/zone.js/commit/2dc7e5c)) +* **core:** fix [#1000](https://github.com/angular/zone.js/issues/1000), check target is null or not when patchOnProperty ([#1004](https://github.com/angular/zone.js/issues/1004)) ([5c139e5](https://github.com/angular/zone.js/commit/5c139e5)) +* **core:** fix [#946](https://github.com/angular/zone.js/issues/946), don't patch promise if it is not writable ([#1041](https://github.com/angular/zone.js/issues/1041)) ([c8c5990](https://github.com/angular/zone.js/commit/c8c5990)) +* **event:** fix [#1021](https://github.com/angular/zone.js/issues/1021), removeListener/removeAllListeners should return eventEmitter ([#1022](https://github.com/angular/zone.js/issues/1022)) ([ab72df6](https://github.com/angular/zone.js/commit/ab72df6)) +* **fakeAsync:** fix [#1056](https://github.com/angular/zone.js/issues/1056), fakeAsync timerId should not be zero ([#1057](https://github.com/angular/zone.js/issues/1057)) ([68682cd](https://github.com/angular/zone.js/commit/68682cd)) +* **jasmine:** fix [#1015](https://github.com/angular/zone.js/issues/1015), make jasmine patch compatible to jasmine 3.x ([#1016](https://github.com/angular/zone.js/issues/1016)) ([e1df4bc](https://github.com/angular/zone.js/commit/e1df4bc)) +* **patch:** fix [#998](https://github.com/angular/zone.js/issues/998), patch mediaQuery for new Safari ([#1003](https://github.com/angular/zone.js/issues/1003)) ([c7c7db5](https://github.com/angular/zone.js/commit/c7c7db5)) +* **proxy:** proxyZone should call onHasTask when change delegate ([#1030](https://github.com/angular/zone.js/issues/1030)) ([40b110d](https://github.com/angular/zone.js/commit/40b110d)) +* **test:** fix mocha compatible issue ([#1028](https://github.com/angular/zone.js/issues/1028)) ([c554e9f](https://github.com/angular/zone.js/commit/c554e9f)) +* **testing:** fix [#1032](https://github.com/angular/zone.js/issues/1032), fakeAsync should pass parameters correctly ([#1033](https://github.com/angular/zone.js/issues/1033)) ([eefe983](https://github.com/angular/zone.js/commit/eefe983)) + + +### Features + +* **bluebird:** fix [#921](https://github.com/angular/zone.js/issues/921), [#977](https://github.com/angular/zone.js/issues/977), support bluebird ([#1039](https://github.com/angular/zone.js/issues/1039)) ([438210c](https://github.com/angular/zone.js/commit/438210c)) +* **build:** use yarn instead of npm ([#1025](https://github.com/angular/zone.js/issues/1025)) ([ebd348c](https://github.com/angular/zone.js/commit/ebd348c)) +* **core:** fix [#996](https://github.com/angular/zone.js/issues/996), expose UncaughtPromiseError ([#1040](https://github.com/angular/zone.js/issues/1040)) ([7f178b1](https://github.com/angular/zone.js/commit/7f178b1)) +* **jasmine:** support Date.now in fakeAsyncTest ([#1009](https://github.com/angular/zone.js/issues/1009)) ([f22065e](https://github.com/angular/zone.js/commit/f22065e)) +* **jsonp:** provide a help method to patch jsonp ([#997](https://github.com/angular/zone.js/issues/997)) ([008fd43](https://github.com/angular/zone.js/commit/008fd43)) +* **patch:** fix [#1011](https://github.com/angular/zone.js/issues/1011), patch ResizeObserver ([#1012](https://github.com/angular/zone.js/issues/1012)) ([8ee88da](https://github.com/angular/zone.js/commit/8ee88da)) +* **patch:** fix [#828](https://github.com/angular/zone.js/issues/828), patch socket.io client ([b3db9f4](https://github.com/angular/zone.js/commit/b3db9f4)) +* **promise:** support Promise.prototype.finally ([#1005](https://github.com/angular/zone.js/issues/1005)) ([6a1a830](https://github.com/angular/zone.js/commit/6a1a830)) +* **rollup:** use new rollup config to prevent warning ([#1006](https://github.com/angular/zone.js/issues/1006)) ([6b6b38a](https://github.com/angular/zone.js/commit/6b6b38a)) +* **test:** can handle non zone aware task in promise ([#1014](https://github.com/angular/zone.js/issues/1014)) ([6852f1d](https://github.com/angular/zone.js/commit/6852f1d)) +* **test:** move async/fakeAsync from angular to zone.js ([#1048](https://github.com/angular/zone.js/issues/1048)) ([a4b42cd](https://github.com/angular/zone.js/commit/a4b42cd)) +* **testing:** can display pending tasks info when test timeout in jasmine/mocha ([#1038](https://github.com/angular/zone.js/issues/1038)) ([57bc80c](https://github.com/angular/zone.js/commit/57bc80c)) + + + ## [0.8.20](https://github.com/angular/zone.js/compare/v0.8.19...0.8.20) (2018-01-10) diff --git a/dist/async-test.js b/dist/async-test.js index a417d8c6c..952c5f77a 100644 --- a/dist/async-test.js +++ b/dist/async-test.js @@ -18,45 +18,95 @@ * 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 () { +var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; this._pendingMicroTasks = false; this._pendingMacroTasks = false; this._alreadyErrored = false; + this._isSync = false; this.runZone = Zone.current; - this._finishCallback = finishCallback; - this._failCallback = failCallback; + this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { + 'AsyncTestZoneSpec': this + }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this._finishCallback(); + _this.finishCallback(); } }, 0); }); } }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; + } + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { + this.patchPromiseForTest(); + this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this._finishCallbackIfDone(); + this.unPatchPromiseForTest(); + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } } }; AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { // Let the parent try to handle the error. var result = parentZoneDelegate.handleError(targetZone, error); if (result) { - this._failCallback(error); + this.failCallback(error); this._alreadyErrored = true; } return false; @@ -72,6 +122,7 @@ var AsyncTestZoneSpec = (function () { this._finishCallbackIfDone(); } }; + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); return AsyncTestZoneSpec; }()); // Export the class so that new instances can be created with proper diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index fb5c807a8..32c0f215b 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -19,15 +19,48 @@ * found in the LICENSE file at https://angular.io/license */ (function (global) { - var Scheduler = (function () { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + var d = new OriginalDate(); + d.setTime(global.Date.now()); + return d; + } + FakeDate.UTC = function () { + return OriginalDate.UTC(); + }; + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + FakeDate.parse = function () { + return OriginalDate.parse(); + }; + return FakeDate; + }()); + var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. - this.nextId = 0; + this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = Date.now(); } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { if (args === void 0) { args = []; } if (isPeriodic === void 0) { isPeriodic = false; } @@ -148,7 +181,7 @@ }; return Scheduler; }()); - var FakeAsyncTestZoneSpec = (function () { + var FakeAsyncTestZoneSpec = /** @class */ (function () { function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; @@ -238,11 +271,7 @@ FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); this._scheduler.removeScheduledFunctionWithId(id); }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { var id = this._scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); @@ -263,6 +292,27 @@ this._lastError = null; throw error; }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + }; + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -319,12 +369,10 @@ case 'macroTask': switch (task.source) { case 'setTimeout': - task.data['handleId'] = - this._setTimeout(task.invoke, task.data['delay'], task.data['args']); + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; case 'setInterval': - task.data['handleId'] = - this._setInterval(task.invoke, task.data['delay'], task.data['args']); + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; case 'XMLHttpRequest.send': throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + @@ -385,6 +433,15 @@ return delegate.cancelTask(target, task); } }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + FakeAsyncTestZoneSpec.resetDate(); + } + }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { if (!this.macroTaskOptions) { return null; diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 673ae9b4f..493d91a95 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -28,6 +28,7 @@ } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; + var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; // 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) @@ -35,7 +36,7 @@ if (typeof jasmine == 'undefined') 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; var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; var ProxyZoneSpec = Zone['ProxyZoneSpec']; @@ -48,16 +49,7 @@ // error if any asynchronous operations are attempted inside of a `describe` but outside of // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - var testProxyZone = null; + var symbol = Zone.__symbol__; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -68,7 +60,7 @@ }); ['it', 'xit', 'fit'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (description, specDefinitions, timeout) { arguments[1] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); @@ -76,12 +68,45 @@ }); ['beforeEach', 'afterEach'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { arguments[0] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); + }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -91,6 +116,33 @@ return syncZone.run(describeBody, this, arguments); }; } + function runInTestZone(testBody, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + var lastDelegate; + if (isClockInstalled) { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + lastDelegate = testProxyZoneSpec.getDelegate(); + testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + } + } + try { + if (done) { + return testProxyZone.run(testBody, this, [done]); + } + else { + return testProxyZone.run(testBody, this); + } + } + finally { + if (isClockInstalled) { + testProxyZoneSpec.setDelegate(lastDelegate); + } + } + } /** * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to * execute in a ProxyZone zone. @@ -100,28 +152,90 @@ // The `done` callback is only passed through if the function expects at least one argument. // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. - return testBody && (testBody.length ? function (done) { - return testProxyZone.run(testBody, this, [done]); + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this.queueRunner, done); } : function () { - return testProxyZone.run(testBody, this); - }); + return runInTestZone(testBody, this.queueRunner); + })); } var QueueRunner = jasmine.QueueRunner; jasmine.QueueRunner = (function (_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(attrs) { + var _this = this; attrs.onComplete = (function (fn) { return function () { // All functions are done, clear the test zone. - testProxyZone = null; + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; ambientZone.scheduleMicroTask('jasmine.onComplete', fn); }; })(attrs.onComplete); + var nativeSetTimeout = _global['__zone_symbol__setTimeout']; + var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + error.message += pendingTasksInfo; + } + } + if (onException) { + onException.call(this, error); + } + }; _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function () { var _this = this; - if (Zone.current !== ambientZone) + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) throw new Error('Unexpected Zone: ' + Zone.current.name); - testProxyZone = ambientZone.fork(new ProxyZoneSpec()); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); if (!Zone.currentTask) { // if we are not running in a task then if someone would register a // element.addEventListener and then calling element.click() the @@ -135,7 +249,7 @@ } }; return ZoneQueueRunner; - }(QueueRunner)); + })(QueueRunner); })(); }))); diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index 8489eb952..dd0f2ef54 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!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 e&&(e.length?function(n){return u.run(e,this,[n])}:function(){return u.run(e,this)})}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[Zone.__symbol__(e)]=r,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[Zone.__symbol__(e)]=r,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)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return u.run(e,this,arguments)}}function n(e,n,t){var o,r=!!jasmine[a("clockInstalled")],i=n.testProxyZoneSpec,s=n.testProxyZone;if(r){var c=Zone.FakeAsyncTestZoneSpec;if(c){var u=new c;o=i.getDelegate(),i.setDelegate(u)}}try{return t?s.run(e,this,[t]):s.run(e,this)}finally{r&&i.setDelegate(o)}}function t(e){return e&&(e.length?function(t){return n(e,this.queueRunner,t)}:function(){return n(e,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,u=c.fork(new i("jasmine.describe")),a=Zone.__symbol__,f=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=f[n];f[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=f[e];f[a(e)]=n,f[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=f[e];f[a(e)]=n,f[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[a("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments),n=e[a("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[a("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[a(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[a("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e};var p=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(n)})},n}(p)}()}); \ No newline at end of file diff --git a/dist/long-stack-trace-zone.js b/dist/long-stack-trace-zone.js index 4dadb8b36..4f3f2f047 100644 --- a/dist/long-stack-trace-zone.js +++ b/dist/long-stack-trace-zone.js @@ -28,7 +28,7 @@ var creationTrace = '__creationTrace__'; var ERROR_TAG = 'STACKTRACE TRACKING'; var SEP_TAG = '__SEP_TAG__'; var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = (function () { +var LongStackTrace = /** @class */ (function () { function LongStackTrace() { this.error = getStacktrace(); this.timestamp = new Date(); diff --git a/dist/mocha-patch.js b/dist/mocha-patch.js index b0be0a8fd..4090eb0e2 100644 --- a/dist/mocha-patch.js +++ b/dist/mocha-patch.js @@ -142,11 +142,14 @@ }; Mocha.Runner.prototype.run = function (fn) { this.on('test', function (e) { - if (Zone.current !== rootZone) { - throw new Error('Unexpected zone: ' + Zone.current.name); - } testZone = rootZone.fork(new ProxyZoneSpec()); }); + this.on('fail', function (test, err) { + var proxyZoneSpec = testZone && testZone.get('ProxyZoneSpec'); + if (proxyZoneSpec && err) { + err.message += proxyZoneSpec.getAndClearPendingTasksInfo(); + } + }); return originalRun.call(this, fn); }; })(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run); diff --git a/dist/mocha-patch.min.js b/dist/mocha-patch.min.js index 6c9e8e075..96960a153 100644 --- a/dist/mocha-patch.min.js +++ b/dist/mocha-patch.min.js @@ -1 +1 @@ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(this,function(){"use strict";!function(n){function e(n,e,t){for(var r=function(r){var o=n[r];"function"==typeof o&&(n[r]=0===o.length?e(o):t(o),n[r].toString=function(){return o.toString()})},o=0;o 0 ? args[0] : null; + if (typeof callback === 'function') { + var wrapperedCallback = Zone.current.wrap(callback, 'MediaQuery'); + callback[api.symbol('mediaQueryCallback')] = wrapperedCallback; + return delegate.call(self, wrapperedCallback); + } + else { + return delegate.apply(self, args); + } + }; }); + } + function patchRemoveListener(proto) { + api.patchMethod(proto, 'removeListener', function (delegate) { return function (self, args) { + var callback = args.length > 0 ? args[0] : null; + if (typeof callback === 'function') { + var wrapperedCallback = callback[api.symbol('mediaQueryCallback')]; + if (wrapperedCallback) { + return delegate.call(self, wrapperedCallback); + } + else { + return delegate.apply(self, args); + } + } + else { + return delegate.apply(self, args); + } + }; }); + } + if (global['MediaQueryList']) { + var proto = global['MediaQueryList'].prototype; + patchAddListener(proto); + patchRemoveListener(proto); + } + else if (global['matchMedia']) { + api.patchMethod(global, 'matchMedia', function (delegate) { return function (self, args) { + var mql = delegate.apply(self, args); + if (mql) { + // try to patch MediaQueryList.prototype + var proto = Object.getPrototypeOf(mql); + if (proto && proto['addListener']) { + // try to patch proto, don't need to worry about patch + // multiple times, because, api.patchEventTarget will check it + patchAddListener(proto); + patchRemoveListener(proto); + patchAddListener(mql); + patchRemoveListener(mql); + } + else if (mql['addListener']) { + // proto not exists, or proto has no addListener method + // try to patch mql instance + patchAddListener(mql); + patchRemoveListener(mql); + } + } + return mql; + }; }); } - api.patchEventTarget(global, [global['MediaQueryList'].prototype], { add: 'addListener', rm: 'removeListener' }); }); }))); diff --git a/dist/webapis-media-query.min.js b/dist/webapis-media-query.min.js index 075a3d5bd..5767a6799 100644 --- a/dist/webapis-media-query.min.js +++ b/dist/webapis-media-query.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("mediaQuery",function(e,t,i){e.MediaQueryList&&i.patchEventTarget(e,[e.MediaQueryList.prototype],{add:"addListener",rm:"removeListener"})})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("mediaQuery",function(e,t,n){function r(e){n.patchMethod(e,"addListener",function(e){return function(r,i){var a=i.length>0?i[0]:null;if("function"==typeof a){var o=t.current.wrap(a,"MediaQuery");return a[n.symbol("mediaQueryCallback")]=o,e.call(r,o)}return e.apply(r,i)}})}function i(e){n.patchMethod(e,"removeListener",function(e){return function(t,r){var i=r.length>0?r[0]:null;if("function"==typeof i){var a=i[n.symbol("mediaQueryCallback")];return a?e.call(t,a):e.apply(t,r)}return e.apply(t,r)}})}if(e.MediaQueryList){var a=e.MediaQueryList.prototype;r(a),i(a)}else e.matchMedia&&n.patchMethod(e,"matchMedia",function(e){return function(t,n){var a=e.apply(t,n);if(a){var o=Object.getPrototypeOf(a);o&&o.addListener?(r(o),i(o),r(a),i(a)):a.addListener&&(r(a),i(a))}return a}})})}); \ No newline at end of file diff --git a/dist/wtf.js b/dist/wtf.js index 7926359a9..9b4968279 100644 --- a/dist/wtf.js +++ b/dist/wtf.js @@ -37,7 +37,7 @@ } return false; })(); - var WtfZoneSpec = (function () { + var WtfZoneSpec = /** @class */ (function () { function WtfZoneSpec() { this.name = 'WTF'; } @@ -88,13 +88,13 @@ instance(zonePathName(targetZone), shallowObj(task.data, 2)); return retValue; }; + WtfZoneSpec.forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); + WtfZoneSpec.scheduleInstance = {}; + WtfZoneSpec.cancelInstance = {}; + WtfZoneSpec.invokeScope = {}; + WtfZoneSpec.invokeTaskScope = {}; return WtfZoneSpec; }()); - WtfZoneSpec.forkInstance = wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); - WtfZoneSpec.scheduleInstance = {}; - WtfZoneSpec.cancelInstance = {}; - WtfZoneSpec.invokeScope = {}; - WtfZoneSpec.invokeTaskScope = {}; function shallowObj(obj, depth) { if (!depth) return null; diff --git a/dist/wtf.min.js b/dist/wtf.min.js index b835d0ef4..32c1f633e 100644 --- a/dist/wtf.min.js +++ b/dist/wtf.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(e){function n(e,o){if(!o)return null;var t={};for(var c in e)if(e.hasOwnProperty(c)){var a=e[c];switch(typeof a){case"object":var r=a&&a.constructor&&a.constructor.name;a=r==Object.name?n(a,o-1):r;break;case"function":a=a.name||void 0}t[c]=a}return t}function o(e){var n=e.name;for(e=e.parent;null!=e;)n=e.name+"::"+n,e=e.parent;return n}var t=null,c=null,a=function(){var n=e.wtf;return!(!n||!(t=n.trace))&&(c=t.events,!0)}(),r=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,t,c,a){var r=n.fork(c,a);return e.forkInstance(o(c),r.name),r},e.prototype.onInvoke=function(n,a,r,i,s,u,f){var p=e.invokeScope[f];return p||(p=e.invokeScope[f]=c.createScope("Zone:invoke:"+f+"(ascii zone)")),t.leaveScope(p(o(r)),n.invoke(r,i,s,u,f))},e.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},e.prototype.onScheduleTask=function(t,a,r,i){var s=i.type+":"+i.source,u=e.scheduleInstance[s];u||(u=e.scheduleInstance[s]=c.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var f=t.scheduleTask(r,i);return u(o(r),n(i.data,2)),f},e.prototype.onInvokeTask=function(n,a,r,i,s,u){var f=i.source,p=e.invokeTaskScope[f];return p||(p=e.invokeTaskScope[f]=c.createScope("Zone:invokeTask:"+f+"(ascii zone)")),t.leaveScope(p(o(r)),n.invokeTask(r,i,s,u))},e.prototype.onCancelTask=function(t,a,r,i){var s=i.source,u=e.cancelInstance[s];u||(u=e.cancelInstance[s]=c.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var f=t.cancelTask(r,i);return u(o(r),n(i.data,2)),f},e}();r.forkInstance=a&&c.createInstance("Zone:fork(ascii zone, ascii newZone)"),r.scheduleInstance={},r.cancelInstance={},r.invokeScope={},r.invokeTaskScope={},Zone.wtfZoneSpec=a?new r:null}("object"==typeof window&&window||"object"==typeof self&&self||global)}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(e){function n(e,o){if(!o)return null;var t={};for(var c in e)if(e.hasOwnProperty(c)){var a=e[c];switch(typeof a){case"object":var r=a&&a.constructor&&a.constructor.name;a=r==Object.name?n(a,o-1):r;break;case"function":a=a.name||void 0}t[c]=a}return t}function o(e){var n=e.name;for(e=e.parent;null!=e;)n=e.name+"::"+n,e=e.parent;return n}var t=null,c=null,a=function(){var n=e.wtf;return!(!n||!(t=n.trace))&&(c=t.events,!0)}(),r=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,t,c,a){var r=n.fork(c,a);return e.forkInstance(o(c),r.name),r},e.prototype.onInvoke=function(n,a,r,i,s,u,f){var p=e.invokeScope[f];return p||(p=e.invokeScope[f]=c.createScope("Zone:invoke:"+f+"(ascii zone)")),t.leaveScope(p(o(r)),n.invoke(r,i,s,u,f))},e.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},e.prototype.onScheduleTask=function(t,a,r,i){var s=i.type+":"+i.source,u=e.scheduleInstance[s];u||(u=e.scheduleInstance[s]=c.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var f=t.scheduleTask(r,i);return u(o(r),n(i.data,2)),f},e.prototype.onInvokeTask=function(n,a,r,i,s,u){var f=i.source,p=e.invokeTaskScope[f];return p||(p=e.invokeTaskScope[f]=c.createScope("Zone:invokeTask:"+f+"(ascii zone)")),t.leaveScope(p(o(r)),n.invokeTask(r,i,s,u))},e.prototype.onCancelTask=function(t,a,r,i){var s=i.source,u=e.cancelInstance[s];u||(u=e.cancelInstance[s]=c.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var f=t.cancelTask(r,i);return u(o(r),n(i.data,2)),f},e.forkInstance=a&&c.createInstance("Zone:fork(ascii zone, ascii newZone)"),e.scheduleInstance={},e.cancelInstance={},e.invokeScope={},e.invokeTaskScope={},e}();Zone.wtfZoneSpec=a?new r:null}("object"==typeof window&&window||"object"==typeof self&&self||global)}); \ No newline at end of file diff --git a/dist/zone-bluebird.js b/dist/zone-bluebird.js index 4b5b0c797..a6e118a2e 100644 --- a/dist/zone-bluebird.js +++ b/dist/zone-bluebird.js @@ -18,7 +18,7 @@ * 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.__load_patch('bluebird', function (global, Zone) { +Zone.__load_patch('bluebird', function (global, Zone, api) { // TODO: @JiaLiPassion, we can automatically patch bluebird // if global.Promise = Bluebird, but sometimes in nodejs, // global.Promise is not Bluebird, and Bluebird is just be @@ -26,9 +26,31 @@ Zone.__load_patch('bluebird', function (global, Zone) { // safe to just expose a method to patch Bluebird explicitly var BLUEBIRD = 'bluebird'; Zone[Zone.__symbol__(BLUEBIRD)] = function patchBluebird(Bluebird) { - Bluebird.setScheduler(function (fn) { - Zone.current.scheduleMicroTask(BLUEBIRD, fn); + // patch method of Bluebird.prototype which not using `then` internally + var bluebirdApis = ['then', 'spread', 'finally']; + bluebirdApis.forEach(function (bapi) { + api.patchMethod(Bluebird.prototype, bapi, function (delegate) { return function (self, args) { + var zone = Zone.current; + var _loop_1 = function (i) { + var func = args[i]; + if (typeof func === 'function') { + args[i] = function () { + var argSelf = this; + var argArgs = arguments; + zone.scheduleMicroTask('Promise.then', function () { + return func.apply(argSelf, argArgs); + }); + }; + } + }; + for (var i = 0; i < args.length; i++) { + _loop_1(i); + } + return delegate.apply(self, args); + }; }); }); + // override global promise + global[api.symbol('ZoneAwarePromise')] = Bluebird; }; }); diff --git a/dist/zone-bluebird.min.js b/dist/zone-bluebird.min.js index ad38e5632..9b3350fa9 100644 --- a/dist/zone-bluebird.min.js +++ b/dist/zone-bluebird.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("bluebird",function(e,n){var t="bluebird";n[n.__symbol__(t)]=function(e){e.setScheduler(function(e){n.current.scheduleMicroTask(t,e)})}})}); \ No newline at end of file +!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e():"function"==typeof define&&define.amd?define(e):e()}(this,function(){"use strict";Zone.__load_patch("bluebird",function(n,e,t){var o="bluebird";e[e.__symbol__(o)]=function(o){var i=["then","spread","finally"];i.forEach(function(n){t.patchMethod(o.prototype,n,function(n){return function(t,o){for(var i=e.current,r=function(n){var e=o[n];"function"==typeof e&&(o[n]=function(){var n=this,t=arguments;i.scheduleMicroTask("Promise.then",function(){return e.apply(n,t)})})},f=0;f { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ +Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; +}); + +/** + * @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 + */ +/** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + +/** + * @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 FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; +var ProxyZoneSpec$1 = Zone && Zone['ProxyZoneSpec']; +/** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + +/** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + +/** + * Discard all remaining periodic tasks. + * + * @experimental + */ + +/** + * Flush any pending microtasks. + * + * @experimental + */ + /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index cd1f3f47b..9e9605547 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -31,7 +31,7 @@ var Zone$1 = (function (global) { if (global['Zone']) { throw new Error('Zone already loaded.'); } - var Zone = (function () { + var Zone = /** @class */ (function () { function Zone(parent, zoneSpec) { this._properties = null; this._parent = parent; @@ -285,9 +285,9 @@ var Zone$1 = (function (global) { zoneDelegates[i]._updateTaskCount(task.type, count); } }; + Zone.__symbol__ = __symbol__; return Zone; }()); - Zone.__symbol__ = __symbol__; var DELEGATE_ZS = { name: '', onHasTask: function (delegate, _, target, hasTaskState) { @@ -301,7 +301,7 @@ var Zone$1 = (function (global) { return delegate.cancelTask(target, task); } }; - var ZoneDelegate = (function () { + var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; this.zone = zone; @@ -463,7 +463,7 @@ var Zone$1 = (function (global) { }; return ZoneDelegate; }()); - var ZoneTask = (function () { + var ZoneTask = /** @class */ (function () { function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { this._zone = null; this.runCount = 0; @@ -653,13 +653,6 @@ var __values = (undefined && undefined.__values) || function (o) { } }; }; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -727,6 +720,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } var symbolState = __symbol__('state'); var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); var source = 'Promise.then'; var UNRESOLVED = null; var RESOLVED = true; @@ -798,6 +794,15 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { promise[symbolState] = state; var queue = promise[symbolValue]; promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } // record task information in value when error occurs, so we can // do some additional work such as render longStackTrace if (state === REJECTED && value instanceof Error) { @@ -860,20 +865,31 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { clearRejectedNoCatch(promise); - var delegate = promise[symbolState] ? + var promiseState = promise[symbolState]; + var delegate = promiseState ? (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, function () { try { - resolvePromise(chainPromise, true, zone.run(delegate, undefined, [promise[symbolValue]])); + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + resolvePromise(chainPromise, true, value); } catch (error) { + // if error occurs, should always return this error resolvePromise(chainPromise, false, error); } - }); + }, chainPromise); } var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = (function () { + var ZoneAwarePromise = /** @class */ (function () { function ZoneAwarePromise(executor) { var promise = this; if (!(promise instanceof ZoneAwarePromise)) { @@ -980,6 +996,18 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { ZoneAwarePromise.prototype.catch = function (onRejected) { return this.then(null, onRejected); }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + }; return ZoneAwarePromise; }()); // Protect against aggressive optimizers dropping seemingly unused properties. @@ -1029,15 +1057,15 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var symbolThenPatched = __symbol__('thenPatched'); function patchThen(Ctor) { var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } var originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we have to make it to be true. - var prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); - if (prop && prop.writable === false && prop.configurable) { - ObjectDefineProperty(Ctor.prototype, 'then', { writable: true }); - } Ctor.prototype.then = function (onResolve, onReject) { var _this = this; var wrapped = new ZoneAwarePromise(function (resolve, reject) { @@ -1086,13 +1114,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { */ // issue #989, to reduce bundle size, use short name /** Object.getOwnPropertyDescriptor */ -/** - * @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 ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; /** Object.defineProperty */ var ObjectDefineProperty = Object.defineProperty; /** Object.getPrototypeOf */ @@ -1150,7 +1172,7 @@ var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof W // this code. var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && {}.toString.call(_global.process) === '[object process]'); - +var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); // we are in electron of nw, so we are both browser and nodejs // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify // this code. @@ -1372,14 +1394,13 @@ function attachOriginToPatched(patched, original) { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone) { +Zone.__load_patch('toString', function (global) { // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Zone['__zone_symbol__originalToString'] = - Function.prototype.toString; + var originalFunctionToString = Function.prototype.toString; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); - Function.prototype.toString = function () { + var newFunctionToString = function toString() { if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { @@ -1405,6 +1426,8 @@ Zone.__load_patch('toString', function (global, Zone) { } return originalFunctionToString.apply(this, arguments); }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; // patch Object.prototype.toString to let them look like native var originalObjectToString = Object.prototype.toString; var PROMISE_OBJECT_TO_STRING = '[object Promise]'; @@ -1829,6 +1852,9 @@ function patchEventTarget(_global, apis, patchOptions) { target[symbolEventName] = null; } existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } return; } } @@ -1896,6 +1922,9 @@ function patchEventTarget(_global, apis, patchOptions) { } } } + if (returnTarget) { + return this; + } }; // for native toString patch attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); @@ -2313,7 +2342,7 @@ var creationTrace = '__creationTrace__'; var ERROR_TAG = 'STACKTRACE TRACKING'; var SEP_TAG = '__SEP_TAG__'; var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = (function () { +var LongStackTrace = /** @class */ (function () { function LongStackTrace() { this.error = getStacktrace(); this.timestamp = new Date(); @@ -2333,9 +2362,9 @@ function getStacktraceWithCaughtError() { } // Some implementations of exception handling don't create a stack trace if the exception // isn't thrown, however it's faster not to actually throw the exception. -var error$1 = getStacktraceWithUncaughtError(); +var error = getStacktraceWithUncaughtError(); var caughtError = getStacktraceWithCaughtError(); -var getStacktrace = error$1.stack ? +var getStacktrace = error.stack ? getStacktraceWithUncaughtError : (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); function getFrames(error) { @@ -2463,13 +2492,16 @@ computeIgnoreFrames(); * 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 () { +var ProxyZoneSpec = /** @class */ (function () { function ProxyZoneSpec(defaultSpecDelegate) { if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } this.defaultSpecDelegate = defaultSpecDelegate; this.name = 'ProxyZone'; this.properties = { 'ProxyZoneSpec': this }; this.propertyKeys = null; + this.lastTaskState = null; + this.isNeedToTriggerHasTask = false; + this.tasks = []; this.setDelegate(defaultSpecDelegate); } ProxyZoneSpec.get = function () { @@ -2479,13 +2511,14 @@ var ProxyZoneSpec = (function () { return ProxyZoneSpec.get() instanceof ProxyZoneSpec; }; ProxyZoneSpec.assertPresent = function () { - if (!this.isLoaded()) { + if (!ProxyZoneSpec.isLoaded()) { throw new Error("Expected to be running in 'ProxyZone', but it was not found."); } return ProxyZoneSpec.get(); }; ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { var _this = this; + var isNewDelegate = this._delegateSpec !== delegateSpec; this._delegateSpec = delegateSpec; this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); this.propertyKeys = null; @@ -2493,6 +2526,12 @@ var ProxyZoneSpec = (function () { this.propertyKeys = Object.keys(delegateSpec.properties); this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } }; ProxyZoneSpec.prototype.getDelegate = function () { return this._delegateSpec; @@ -2500,6 +2539,43 @@ var ProxyZoneSpec = (function () { ProxyZoneSpec.prototype.resetDelegate = function () { this.setDelegate(this.defaultSpecDelegate); }; + ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + }; + ProxyZoneSpec.prototype.removeFromTasks = function (task) { + if (!this.tasks) { + return; + } + for (var i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; + } + } + }; + ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { + if (this.tasks.length === 0) { + return ''; + } + var taskInfo = this.tasks.map(function (task) { + var dataInfo = task.data && + Object.keys(task.data) + .map(function (key) { + return key + ':' + task.data[key]; + }) + .join(','); + return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; + }); + var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; + }; ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { if (this._delegateSpec && this._delegateSpec.onFork) { return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); @@ -2517,6 +2593,7 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onInvoke) { return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); } @@ -2533,6 +2610,9 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } if (this._delegateSpec && this._delegateSpec.onScheduleTask) { return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); } @@ -2541,7 +2621,11 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (this._delegateSpec && this._delegateSpec.onFork) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); } else { @@ -2549,6 +2633,10 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onCancelTask) { return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); } @@ -2557,6 +2645,7 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; if (this._delegateSpec && this._delegateSpec.onHasTask) { this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); } @@ -2577,7 +2666,7 @@ Zone['ProxyZoneSpec'] = ProxyZoneSpec; * 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 () { +var SyncTestZoneSpec = /** @class */ (function () { function SyncTestZoneSpec(namePrefix) { this.runZone = Zone.current; this.name = 'syncTestZone for ' + namePrefix; @@ -2616,6 +2705,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; + var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; // 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) @@ -2623,7 +2713,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; if (typeof jasmine == 'undefined') 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; var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; var ProxyZoneSpec = Zone['ProxyZoneSpec']; @@ -2636,16 +2726,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // error if any asynchronous operations are attempted inside of a `describe` but outside of // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - var testProxyZone = null; + var symbol = Zone.__symbol__; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -2656,7 +2737,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; }); ['it', 'xit', 'fit'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (description, specDefinitions, timeout) { arguments[1] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); @@ -2664,12 +2745,45 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; }); ['beforeEach', 'afterEach'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { arguments[0] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); + }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -2679,6 +2793,33 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return syncZone.run(describeBody, this, arguments); }; } + function runInTestZone(testBody, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + var lastDelegate; + if (isClockInstalled) { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + lastDelegate = testProxyZoneSpec.getDelegate(); + testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + } + } + try { + if (done) { + return testProxyZone.run(testBody, this, [done]); + } + else { + return testProxyZone.run(testBody, this); + } + } + finally { + if (isClockInstalled) { + testProxyZoneSpec.setDelegate(lastDelegate); + } + } + } /** * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to * execute in a ProxyZone zone. @@ -2688,28 +2829,90 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // The `done` callback is only passed through if the function expects at least one argument. // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. - return testBody && (testBody.length ? function (done) { - return testProxyZone.run(testBody, this, [done]); + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this.queueRunner, done); } : function () { - return testProxyZone.run(testBody, this); - }); + return runInTestZone(testBody, this.queueRunner); + })); } var QueueRunner = jasmine.QueueRunner; jasmine.QueueRunner = (function (_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(attrs) { + var _this = this; attrs.onComplete = (function (fn) { return function () { // All functions are done, clear the test zone. - testProxyZone = null; + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; ambientZone.scheduleMicroTask('jasmine.onComplete', fn); }; })(attrs.onComplete); + var nativeSetTimeout = _global['__zone_symbol__setTimeout']; + var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + error.message += pendingTasksInfo; + } + } + if (onException) { + onException.call(this, error); + } + }; _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function () { var _this = this; - if (Zone.current !== ambientZone) + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) throw new Error('Unexpected Zone: ' + Zone.current.name); - testProxyZone = ambientZone.fork(new ProxyZoneSpec()); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); if (!Zone.currentTask) { // if we are not running in a task then if someone would register a // element.addEventListener and then calling element.click() the @@ -2723,7 +2926,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; } }; return ZoneQueueRunner; - }(QueueRunner)); + })(QueueRunner); })(); /** @@ -2733,45 +2936,95 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; * 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 () { +var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; this._pendingMicroTasks = false; this._pendingMacroTasks = false; this._alreadyErrored = false; + this._isSync = false; this.runZone = Zone.current; - this._finishCallback = finishCallback; - this._failCallback = failCallback; + this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { + 'AsyncTestZoneSpec': this + }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this._finishCallback(); + _this.finishCallback(); } }, 0); }); } }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; + } + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { + this.patchPromiseForTest(); + this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this._finishCallbackIfDone(); + this.unPatchPromiseForTest(); + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } } }; AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { // Let the parent try to handle the error. var result = parentZoneDelegate.handleError(targetZone, error); if (result) { - this._failCallback(error); + this.failCallback(error); this._alreadyErrored = true; } return false; @@ -2787,6 +3040,7 @@ var AsyncTestZoneSpec = (function () { this._finishCallbackIfDone(); } }; + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); return AsyncTestZoneSpec; }()); // Export the class so that new instances can be created with proper @@ -2801,15 +3055,48 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; * found in the LICENSE file at https://angular.io/license */ (function (global) { - var Scheduler = (function () { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + var d = new OriginalDate(); + d.setTime(global.Date.now()); + return d; + } + FakeDate.UTC = function () { + return OriginalDate.UTC(); + }; + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + FakeDate.parse = function () { + return OriginalDate.parse(); + }; + return FakeDate; + }()); + var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. - this.nextId = 0; + this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = Date.now(); } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { if (args === void 0) { args = []; } if (isPeriodic === void 0) { isPeriodic = false; } @@ -2930,7 +3217,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; }; return Scheduler; }()); - var FakeAsyncTestZoneSpec = (function () { + var FakeAsyncTestZoneSpec = /** @class */ (function () { function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; @@ -3020,11 +3307,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); this._scheduler.removeScheduledFunctionWithId(id); }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { var id = this._scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); @@ -3045,6 +3328,27 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this._lastError = null; throw error; }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + }; + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -3101,12 +3405,10 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; case 'macroTask': switch (task.source) { case 'setTimeout': - task.data['handleId'] = - this._setTimeout(task.invoke, task.data['delay'], task.data['args']); + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; case 'setInterval': - task.data['handleId'] = - this._setInterval(task.invoke, task.data['delay'], task.data['args']); + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; case 'XMLHttpRequest.send': throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + @@ -3167,6 +3469,15 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return delegate.cancelTask(target, task); } }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + FakeAsyncTestZoneSpec.resetDate(); + } + }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { if (!this.macroTaskOptions) { return null; @@ -3190,6 +3501,155 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); +/** + * @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 + */ +/** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ +Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; +}); + +/** + * @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 + */ +/** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + +/** + * @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 FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; +var ProxyZoneSpec$1 = Zone && Zone['ProxyZoneSpec']; +/** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + +/** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + +/** + * Discard all remaining periodic tasks. + * + * @experimental + */ + +/** + * Flush any pending microtasks. + * + * @experimental + */ + /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 1bdcad041..2e6d244d6 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.zone = {}))); +}(this, (function (exports) { 'use strict'; /** * @license @@ -28,7 +28,7 @@ var creationTrace = '__creationTrace__'; var ERROR_TAG = 'STACKTRACE TRACKING'; var SEP_TAG = '__SEP_TAG__'; var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = (function () { +var LongStackTrace = /** @class */ (function () { function LongStackTrace() { this.error = getStacktrace(); this.timestamp = new Date(); @@ -178,13 +178,16 @@ computeIgnoreFrames(); * 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 () { +var ProxyZoneSpec = /** @class */ (function () { function ProxyZoneSpec(defaultSpecDelegate) { if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } this.defaultSpecDelegate = defaultSpecDelegate; this.name = 'ProxyZone'; this.properties = { 'ProxyZoneSpec': this }; this.propertyKeys = null; + this.lastTaskState = null; + this.isNeedToTriggerHasTask = false; + this.tasks = []; this.setDelegate(defaultSpecDelegate); } ProxyZoneSpec.get = function () { @@ -194,13 +197,14 @@ var ProxyZoneSpec = (function () { return ProxyZoneSpec.get() instanceof ProxyZoneSpec; }; ProxyZoneSpec.assertPresent = function () { - if (!this.isLoaded()) { + if (!ProxyZoneSpec.isLoaded()) { throw new Error("Expected to be running in 'ProxyZone', but it was not found."); } return ProxyZoneSpec.get(); }; ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { var _this = this; + var isNewDelegate = this._delegateSpec !== delegateSpec; this._delegateSpec = delegateSpec; this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); this.propertyKeys = null; @@ -208,6 +212,12 @@ var ProxyZoneSpec = (function () { this.propertyKeys = Object.keys(delegateSpec.properties); this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } }; ProxyZoneSpec.prototype.getDelegate = function () { return this._delegateSpec; @@ -215,6 +225,43 @@ var ProxyZoneSpec = (function () { ProxyZoneSpec.prototype.resetDelegate = function () { this.setDelegate(this.defaultSpecDelegate); }; + ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + }; + ProxyZoneSpec.prototype.removeFromTasks = function (task) { + if (!this.tasks) { + return; + } + for (var i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; + } + } + }; + ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { + if (this.tasks.length === 0) { + return ''; + } + var taskInfo = this.tasks.map(function (task) { + var dataInfo = task.data && + Object.keys(task.data) + .map(function (key) { + return key + ':' + task.data[key]; + }) + .join(','); + return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; + }); + var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; + }; ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { if (this._delegateSpec && this._delegateSpec.onFork) { return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); @@ -232,6 +279,7 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onInvoke) { return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); } @@ -248,6 +296,9 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } if (this._delegateSpec && this._delegateSpec.onScheduleTask) { return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); } @@ -256,7 +307,11 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (this._delegateSpec && this._delegateSpec.onFork) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); } else { @@ -264,6 +319,10 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onCancelTask) { return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); } @@ -272,6 +331,7 @@ var ProxyZoneSpec = (function () { } }; ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; if (this._delegateSpec && this._delegateSpec.onHasTask) { this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); } @@ -292,7 +352,7 @@ Zone['ProxyZoneSpec'] = ProxyZoneSpec; * 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 () { +var SyncTestZoneSpec = /** @class */ (function () { function SyncTestZoneSpec(namePrefix) { this.runZone = Zone.current; this.name = 'syncTestZone for ' + namePrefix; @@ -331,6 +391,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; + var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; // 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) @@ -338,7 +399,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; if (typeof jasmine == 'undefined') 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; var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; var ProxyZoneSpec = Zone['ProxyZoneSpec']; @@ -351,16 +412,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // error if any asynchronous operations are attempted inside of a `describe` but outside of // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - var testProxyZone = null; + var symbol = Zone.__symbol__; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -371,7 +423,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; }); ['it', 'xit', 'fit'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (description, specDefinitions, timeout) { arguments[1] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); @@ -379,12 +431,45 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; }); ['beforeEach', 'afterEach'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[Zone.__symbol__(methodName)] = originalJasmineFn; + jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { arguments[0] = wrapTestInZone(specDefinitions); return originalJasmineFn.apply(this, arguments); }; }); + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); + }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -394,6 +479,33 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return syncZone.run(describeBody, this, arguments); }; } + function runInTestZone(testBody, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + var lastDelegate; + if (isClockInstalled) { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + lastDelegate = testProxyZoneSpec.getDelegate(); + testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + } + } + try { + if (done) { + return testProxyZone.run(testBody, this, [done]); + } + else { + return testProxyZone.run(testBody, this); + } + } + finally { + if (isClockInstalled) { + testProxyZoneSpec.setDelegate(lastDelegate); + } + } + } /** * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to * execute in a ProxyZone zone. @@ -403,28 +515,90 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // The `done` callback is only passed through if the function expects at least one argument. // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. - return testBody && (testBody.length ? function (done) { - return testProxyZone.run(testBody, this, [done]); + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this.queueRunner, done); } : function () { - return testProxyZone.run(testBody, this); - }); + return runInTestZone(testBody, this.queueRunner); + })); } var QueueRunner = jasmine.QueueRunner; jasmine.QueueRunner = (function (_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(attrs) { + var _this = this; attrs.onComplete = (function (fn) { return function () { // All functions are done, clear the test zone. - testProxyZone = null; + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; ambientZone.scheduleMicroTask('jasmine.onComplete', fn); }; })(attrs.onComplete); + var nativeSetTimeout = _global['__zone_symbol__setTimeout']; + var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + error.message += pendingTasksInfo; + } + } + if (onException) { + onException.call(this, error); + } + }; _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function () { var _this = this; - if (Zone.current !== ambientZone) + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) throw new Error('Unexpected Zone: ' + Zone.current.name); - testProxyZone = ambientZone.fork(new ProxyZoneSpec()); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); if (!Zone.currentTask) { // if we are not running in a task then if someone would register a // element.addEventListener and then calling element.click() the @@ -438,7 +612,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; } }; return ZoneQueueRunner; - }(QueueRunner)); + })(QueueRunner); })(); /** @@ -448,45 +622,95 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; * 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 () { +var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; this._pendingMicroTasks = false; this._pendingMacroTasks = false; this._alreadyErrored = false; + this._isSync = false; this.runZone = Zone.current; - this._finishCallback = finishCallback; - this._failCallback = failCallback; + this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { + 'AsyncTestZoneSpec': this + }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this._finishCallback(); + _this.finishCallback(); } }, 0); }); } }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; + } + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { + this.patchPromiseForTest(); + this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this._finishCallbackIfDone(); + this.unPatchPromiseForTest(); + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } } }; AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { // Let the parent try to handle the error. var result = parentZoneDelegate.handleError(targetZone, error); if (result) { - this._failCallback(error); + this.failCallback(error); this._alreadyErrored = true; } return false; @@ -502,6 +726,7 @@ var AsyncTestZoneSpec = (function () { this._finishCallbackIfDone(); } }; + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); return AsyncTestZoneSpec; }()); // Export the class so that new instances can be created with proper @@ -516,15 +741,48 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; * found in the LICENSE file at https://angular.io/license */ (function (global) { - var Scheduler = (function () { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + var d = new OriginalDate(); + d.setTime(global.Date.now()); + return d; + } + FakeDate.UTC = function () { + return OriginalDate.UTC(); + }; + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + FakeDate.parse = function () { + return OriginalDate.parse(); + }; + return FakeDate; + }()); + var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. - this.nextId = 0; + this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = Date.now(); } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { if (args === void 0) { args = []; } if (isPeriodic === void 0) { isPeriodic = false; } @@ -645,7 +903,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; }; return Scheduler; }()); - var FakeAsyncTestZoneSpec = (function () { + var FakeAsyncTestZoneSpec = /** @class */ (function () { function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; @@ -735,11 +993,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); this._scheduler.removeScheduledFunctionWithId(id); }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval) { - var args = []; - for (var _i = 2; _i < arguments.length; _i++) { - args[_i - 2] = arguments[_i]; - } + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { var id = this._scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); @@ -760,6 +1014,27 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this._lastError = null; throw error; }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + }; + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -816,12 +1091,10 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; case 'macroTask': switch (task.source) { case 'setTimeout': - task.data['handleId'] = - this._setTimeout(task.invoke, task.data['delay'], task.data['args']); + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; case 'setInterval': - task.data['handleId'] = - this._setInterval(task.invoke, task.data['delay'], task.data['args']); + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; case 'XMLHttpRequest.send': throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + @@ -882,6 +1155,15 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return delegate.cancelTask(target, task); } }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + FakeAsyncTestZoneSpec.resetDate(); + } + }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { if (!this.macroTaskOptions) { return null; @@ -905,6 +1187,302 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); +/** + * @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 + */ +/** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ +Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; +}); + +/** + * @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 _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; +/** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ +function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (_global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; +} +function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); +} + +/** + * @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 FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; +var ProxyZoneSpec$1 = Zone && Zone['ProxyZoneSpec']; +var _fakeAsyncTestZoneSpec = null; +/** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ +function resetFakeAsyncZone() { + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec$1 && ProxyZoneSpec$1.assertPresent().resetDelegate(); +} +var _inFakeAsyncCall = false; +/** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ +function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec$1.assertPresent(); + if (_inFakeAsyncCall) { + throw new Error('fakeAsync() calls can not be nested'); + } + _inFakeAsyncCall = true; + try { + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + _inFakeAsyncCall = false; + resetFakeAsyncZone(); + } + }; +} +function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + return _fakeAsyncTestZoneSpec; +} +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ +function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); +} +/** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ +function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); +} +/** + * Discard all remaining periodic tasks. + * + * @experimental + */ +function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; +} +/** + * Flush any pending microtasks. + * + * @experimental + */ +function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); +} + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -914,4 +1492,14 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; */ // load test related files into bundle in correct order +exports.asyncTest = asyncTest; +exports.resetFakeAsyncZone = resetFakeAsyncZone; +exports.fakeAsync = fakeAsync; +exports.tick = tick; +exports.flush = flush; +exports.discardPeriodicTasks = discardPeriodicTasks; +exports.flushMicrotasks = flushMicrotasks; + +Object.defineProperty(exports, '__esModule', { value: true }); + }))); diff --git a/dist/zone.js b/dist/zone.js index 651ac6966..2cd0134c8 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -31,7 +31,7 @@ var Zone$1 = (function (global) { if (global['Zone']) { throw new Error('Zone already loaded.'); } - var Zone = (function () { + var Zone = /** @class */ (function () { function Zone(parent, zoneSpec) { this._properties = null; this._parent = parent; @@ -285,9 +285,9 @@ var Zone$1 = (function (global) { zoneDelegates[i]._updateTaskCount(task.type, count); } }; + Zone.__symbol__ = __symbol__; return Zone; }()); - Zone.__symbol__ = __symbol__; var DELEGATE_ZS = { name: '', onHasTask: function (delegate, _, target, hasTaskState) { @@ -301,7 +301,7 @@ var Zone$1 = (function (global) { return delegate.cancelTask(target, task); } }; - var ZoneDelegate = (function () { + var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; this.zone = zone; @@ -463,7 +463,7 @@ var Zone$1 = (function (global) { }; return ZoneDelegate; }()); - var ZoneTask = (function () { + var ZoneTask = /** @class */ (function () { function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { this._zone = null; this.runCount = 0; @@ -653,13 +653,6 @@ var __values = (undefined && undefined.__values) || function (o) { } }; }; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -727,6 +720,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } var symbolState = __symbol__('state'); var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); var source = 'Promise.then'; var UNRESOLVED = null; var RESOLVED = true; @@ -798,6 +794,15 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { promise[symbolState] = state; var queue = promise[symbolValue]; promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } // record task information in value when error occurs, so we can // do some additional work such as render longStackTrace if (state === REJECTED && value instanceof Error) { @@ -860,20 +865,31 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { clearRejectedNoCatch(promise); - var delegate = promise[symbolState] ? + var promiseState = promise[symbolState]; + var delegate = promiseState ? (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : (typeof onRejected === 'function') ? onRejected : forwardRejection; zone.scheduleMicroTask(source, function () { try { - resolvePromise(chainPromise, true, zone.run(delegate, undefined, [promise[symbolValue]])); + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + resolvePromise(chainPromise, true, value); } catch (error) { + // if error occurs, should always return this error resolvePromise(chainPromise, false, error); } - }); + }, chainPromise); } var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = (function () { + var ZoneAwarePromise = /** @class */ (function () { function ZoneAwarePromise(executor) { var promise = this; if (!(promise instanceof ZoneAwarePromise)) { @@ -980,6 +996,18 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { ZoneAwarePromise.prototype.catch = function (onRejected) { return this.then(null, onRejected); }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + }; return ZoneAwarePromise; }()); // Protect against aggressive optimizers dropping seemingly unused properties. @@ -1029,15 +1057,15 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var symbolThenPatched = __symbol__('thenPatched'); function patchThen(Ctor) { var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } var originalThen = proto.then; // Keep a reference to the original method. proto[symbolThen] = originalThen; - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we have to make it to be true. - var prop = ObjectGetOwnPropertyDescriptor(Ctor.prototype, 'then'); - if (prop && prop.writable === false && prop.configurable) { - ObjectDefineProperty(Ctor.prototype, 'then', { writable: true }); - } Ctor.prototype.then = function (onResolve, onReject) { var _this = this; var wrapped = new ZoneAwarePromise(function (resolve, reject) { @@ -1086,13 +1114,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { */ // issue #989, to reduce bundle size, use short name /** Object.getOwnPropertyDescriptor */ -/** - * @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 ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; /** Object.defineProperty */ var ObjectDefineProperty = Object.defineProperty; /** Object.getPrototypeOf */ @@ -1459,14 +1481,13 @@ function isIEOrEdge() { */ // override Function.prototype.toString to make zone.js patched function // look like native function -Zone.__load_patch('toString', function (global, Zone) { +Zone.__load_patch('toString', function (global) { // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Zone['__zone_symbol__originalToString'] = - Function.prototype.toString; + var originalFunctionToString = Function.prototype.toString; var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); var PROMISE_SYMBOL = zoneSymbol('Promise'); var ERROR_SYMBOL = zoneSymbol('Error'); - Function.prototype.toString = function () { + var newFunctionToString = function toString() { if (typeof this === 'function') { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { @@ -1492,6 +1513,8 @@ Zone.__load_patch('toString', function (global, Zone) { } return originalFunctionToString.apply(this, arguments); }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; // patch Object.prototype.toString to let them look like native var originalObjectToString = Object.prototype.toString; var PROMISE_OBJECT_TO_STRING = '[object Promise]'; @@ -1916,6 +1939,9 @@ function patchEventTarget(_global, apis, patchOptions) { target[symbolEventName] = null; } existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } return; } } @@ -1983,6 +2009,9 @@ function patchEventTarget(_global, apis, patchOptions) { } } } + if (returnTarget) { + return this; + } }; // for native toString patch attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); @@ -2554,6 +2583,11 @@ function filterProperties(target, onProperties, ignoreProperties) { return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); } function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } var filteredProperties = filterProperties(target, onProperties, ignoreProperties); patchOnProperties(target, filteredProperties, prototype); } diff --git a/dist/zone.js.d.ts b/dist/zone.js.d.ts index 91c692d20..ac7ddcdb4 100644 --- a/dist/zone.js.d.ts +++ b/dist/zone.js.d.ts @@ -285,6 +285,12 @@ interface ZoneType { */ root: Zone; } +interface UncaughtPromiseError extends Error { + zone: Zone; + task: Task; + promise: Promise; + rejection: any; +} /** * Provides a way to configure the interception of zone events. * diff --git a/dist/zone.min.js b/dist/zone.min.js index 9c6bff9af..7d809e8d1 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=j(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[N("OriginalDelegate")]=t}function f(){if(ne)return re;ne=!0;try{var e=X.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(re=!0),re}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=I(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[N(a)]=k[a],E=k[N(i)]=k[i],S=k[N(s)]=k[s];n&&n.prepend&&(_=k[N(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=ae[e.eventName],n=void 0;t&&(n=t[e.capture?q:A]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=j(a,"onmessage");return s&&s.configurable===!1?(r=L(a),o=a,[R,x,"send","close"].forEach(function(e){r[e]=function(){var t=M.call(arguments);if(e===R||e===x){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){var o=T(e,t,n);i(e,o,r)}function E(e,t){if(!J||Q){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(Y){var o=window;w(o,Pe.concat(["messageerror"]),r,I(o)),w(Document.prototype,Pe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Pe,r),w(Element.prototype,Pe,r),w(HTMLElement.prototype,Pe,r),w(HTMLMediaElement.prototype,me,r),w(HTMLFrameSetElement.prototype,ge.concat(Ee),r),w(HTMLBodyElement.prototype,ge.concat(Ee),r),w(HTMLFrameElement.prototype,we,r),w(HTMLIFrameElement.prototype,we,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Se,r);var i=o.Worker;i&&w(i.prototype,Oe,r)}w(XMLHttpRequest.prototype,De,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,De,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ze,r),w(IDBRequest.prototype,Ze,r),w(IDBOpenDBRequest.prototype,Ze,r),w(IDBDatabase.prototype,Ze,r),w(IDBTransaction.prototype,Ze,r),w(IDBCursor.prototype,Ze,r)),n&&w(WebSocket.prototype,ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((Y||Q)&&!j(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=j(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=j(n,t);if(r){C(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return C(n,t,r||{}),a}var i=N("fake");C(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Pe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][je]&&(n=e(a[r],o),n[je]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!u[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(l=e.resolve(0))}},j={parent:null,zone:new u(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=u}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return M.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=O();if(e===a)throw new TypeError(j);if(e[T]===S){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==Z&&a instanceof M&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==S)l(a),u(e,a[T],a[w]);else if(o!==Z&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,o===Z&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,C,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=j(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[N("OriginalDelegate")]=t}function f(){if(ne)return re;ne=!0;try{var e=X.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(re=!0),re}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=I(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[N(a)]=k[a],E=k[N(i)]=k[i],S=k[N(s)]=k[s];n&&n.prepend&&(_=k[N(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=ae[e.eventName],n=void 0;t&&(n=t[e.capture?q:A]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=j(a,"onmessage");return s&&s.configurable===!1?(r=L(a),o=a,[R,x,"send","close"].forEach(function(e){r[e]=function(){var t=M.call(arguments);if(e===R||e===x){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!J||Q){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(Y){var o=window;w(o,Pe.concat(["messageerror"]),r,I(o)),w(Document.prototype,Pe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Pe,r),w(Element.prototype,Pe,r),w(HTMLElement.prototype,Pe,r),w(HTMLMediaElement.prototype,me,r),w(HTMLFrameSetElement.prototype,ge.concat(Ee),r),w(HTMLBodyElement.prototype,ge.concat(Ee),r),w(HTMLFrameElement.prototype,we,r),w(HTMLIFrameElement.prototype,we,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Se,r);var i=o.Worker;i&&w(i.prototype,Oe,r)}w(XMLHttpRequest.prototype,De,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,De,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ze,r),w(IDBRequest.prototype,Ze,r),w(IDBOpenDBRequest.prototype,Ze,r),w(IDBDatabase.prototype,Ze,r),w(IDBTransaction.prototype,Ze,r),w(IDBCursor.prototype,Ze,r)),n&&w(WebSocket.prototype,ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((Y||Q)&&!j(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=j(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=j(n,t);if(r){C(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return C(n,t,r||{}),a}var i=N("fake");C(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Pe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][je]&&(n=e(a[r],o),n[je]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=I();if(e===a)throw new TypeError(L);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==j&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==j&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===j&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,M,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g Date: Sun, 1 Apr 2018 01:01:14 +0900 Subject: [PATCH 036/106] fix(fakeAsync): fix #1050, should only reset patched Date.now until fakeAsync exit (#1051) * chore: release v0.8.21 * fix(fakeAsync): fix #1050, work with fakeAsync --- gulpfile.js | 10 + karma-dist.conf.js | 4 +- lib/jasmine/jasmine.ts | 15 +- lib/testing/async-testing.ts | 175 +++++++++-------- lib/testing/fake-async.ts | 258 +++++++++++++------------ lib/testing/zone-testing.ts | 4 +- lib/zone-spec/async-test.ts | 21 +- lib/zone-spec/fake-async-test.ts | 16 +- lib/zone-spec/proxy.ts | 3 +- test/browser-zone-setup.ts | 2 + test/node_entry_point.ts | 2 + test/zone-spec/async-test.spec.ts | 48 ++--- test/zone-spec/fake-async-test.spec.ts | 15 +- 13 files changed, 311 insertions(+), 262 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f870a0929..54134987a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -319,6 +319,14 @@ gulp.task('build/sync-test.js', ['compile-esm'], function(cb) { return generateScript('./lib/zone-spec/sync-test.ts', 'sync-test.js', false, cb); }); +gulp.task('build/zone-async-testing.js', ['compile-esm'], function(cb) { + return generateScript('./lib/testing/async-testing.ts', 'zone-async-testing.js', false, cb); +}); + +gulp.task('build/zone-fake-async.js', ['compile-esm'], function(cb) { + return generateScript('./lib/testing/fake-async.ts', 'zone-fake-async.js', false, cb); +}); + gulp.task('build/rxjs.js', ['compile-esm'], function(cb) { return generateScript('./lib/rxjs/rxjs.ts', 'zone-patch-rxjs.js', false, cb); }); @@ -391,6 +399,8 @@ gulp.task('build', [ 'build/async-test.js', 'build/fake-async-test.js', 'build/sync-test.js', + 'build/zone-async-testing.js', + 'build/zone-fake-async.js', 'build/rxjs.js', 'build/rxjs.min.js', 'build/rxjs-fake-async.js', diff --git a/karma-dist.conf.js b/karma-dist.conf.js index c7946e144..73ee8a788 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -20,7 +20,9 @@ module.exports = function(config) { config.files.push('dist/proxy.js'); config.files.push('dist/sync-test.js'); config.files.push('dist/task-tracking.js'); - config.files.push('dist/wtf.js'); + config.files.push('dist/zone-async-testing.js'); + config.files.push('dist/zone-fake-async.js'); config.files.push('dist/zone-patch-promise-test.js'); + config.files.push('dist/wtf.js'); config.files.push('build/test/main.js'); }; diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 566c30f9e..1d4912460 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -110,7 +110,7 @@ }; } - function runInTestZone(testBody: Function, queueRunner: any, done?: Function) { + function runInTestZone(testBody: Function, applyThis: any, queueRunner: any, done?: Function) { const isClockInstalled = !!(jasmine as any)[symbol('clockInstalled')]; const testProxyZoneSpec = queueRunner.testProxyZoneSpec; const testProxyZone = queueRunner.testProxyZone; @@ -121,16 +121,21 @@ const _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); lastDelegate = (testProxyZoneSpec as any).getDelegate(); (testProxyZoneSpec as any).setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); } } try { if (done) { - return testProxyZone.run(testBody, this, [done]); + return testProxyZone.run(testBody, applyThis, [done]); } else { - return testProxyZone.run(testBody, this); + return testProxyZone.run(testBody, applyThis); } } finally { if (isClockInstalled) { + const _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } (testProxyZoneSpec as any).setDelegate(lastDelegate); } } @@ -146,9 +151,9 @@ // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. return (testBody && (testBody.length ? function(done: Function) { - return runInTestZone(testBody, this.queueRunner, done); + return runInTestZone(testBody, this, this.queueRunner, done); } : function() { - return runInTestZone(testBody, this.queueRunner); + return runInTestZone(testBody, this, this.queueRunner); })); } interface QueueRunner { diff --git a/lib/testing/async-testing.ts b/lib/testing/async-testing.ts index 6ad4f608e..e51ca365b 100644 --- a/lib/testing/async-testing.ts +++ b/lib/testing/async-testing.ts @@ -6,97 +6,96 @@ * found in the LICENSE file at https://angular.io/license */ -const _global: any = - typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; - -/** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ -export function asyncTest(fn: Function): (done: any) => any { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (_global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function(done: any) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function() {}; - done.fail = function(e: any) { - throw e; - }; - } - runInTestZone(fn, this, done, (err: any) => { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } else { - done.fail(err); +Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + (Zone as any)[api.symbol('asyncTest')] = function asyncTest(fn: Function): (done: any) => any { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function(done: any) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function() {}; + done.fail = function(e: any) { + throw e; + }; } + runInTestZone(fn, this, done, (err: any) => { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function() { + return new Promise((finishCallback, failCallback) => { + runInTestZone(fn, this, finishCallback, failCallback); }); }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function() { - return new Promise((finishCallback, failCallback) => { - runInTestZone(fn, this, finishCallback, failCallback); - }); }; -} -function runInTestZone( - fn: Function, context: any, finishCallback: Function, failCallback: Function) { - const currentZone = Zone.current; - const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error( - 'AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - const ProxyZoneSpec = (Zone as any)['ProxyZoneSpec'] as { - get(): {setDelegate(spec: ZoneSpec): void; getDelegate(): ZoneSpec;}; - assertPresent: () => void; - }; - if (ProxyZoneSpec === undefined) { - throw new Error( - 'ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); + function runInTestZone( + fn: Function, context: any, finishCallback: Function, failCallback: Function) { + const currentZone = Zone.current; + const AsyncTestZoneSpec = (Zone as any)['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error( + 'AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + const ProxyZoneSpec = (Zone as any)['ProxyZoneSpec'] as { + get(): {setDelegate(spec: ZoneSpec): void; getDelegate(): ZoneSpec;}; + assertPresent: () => void; + }; + if (ProxyZoneSpec === undefined) { + throw new Error( + 'ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + const proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + const previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(() => { + const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec( + () => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(() => { + finishCallback(); + }); + }, + (error: any) => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(() => { + failCallback(error); + }); + }, + 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); } - const proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - const previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(() => { - const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec( - () => { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(() => { - finishCallback(); - }); - }, - (error: any) => { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(() => { - failCallback(error); - }); - }, - 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); -} +}); \ No newline at end of file diff --git a/lib/testing/fake-async.ts b/lib/testing/fake-async.ts index 7690f26aa..948f80f88 100644 --- a/lib/testing/fake-async.ts +++ b/lib/testing/fake-async.ts @@ -6,145 +6,153 @@ * found in the LICENSE file at https://angular.io/license */ -const FakeAsyncTestZoneSpec = Zone && (Zone as any)['FakeAsyncTestZoneSpec']; -type ProxyZoneSpec = { - setDelegate(delegateSpec: ZoneSpec): void; getDelegate(): ZoneSpec; resetDelegate(): void; -}; -const ProxyZoneSpec: {get(): ProxyZoneSpec; assertPresent: () => ProxyZoneSpec} = - Zone && (Zone as any)['ProxyZoneSpec']; +Zone.__load_patch('fakeasync', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const FakeAsyncTestZoneSpec = Zone && (Zone as any)['FakeAsyncTestZoneSpec']; + type ProxyZoneSpec = { + setDelegate(delegateSpec: ZoneSpec): void; getDelegate(): ZoneSpec; resetDelegate(): void; + }; + const ProxyZoneSpec: {get(): ProxyZoneSpec; assertPresent: () => ProxyZoneSpec} = + Zone && (Zone as any)['ProxyZoneSpec']; -let _fakeAsyncTestZoneSpec: any = null; + let _fakeAsyncTestZoneSpec: any = null; -/** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ -export function resetFakeAsyncZone() { - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); -} + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } -let _inFakeAsyncCall = false; + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn: Function): (...args: any[]) => any { + // Not using an arrow function to preserve context passed from call site + return function(...args: any[]) { + const proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } -/** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ -export function fakeAsync(fn: Function): (...args: any[]) => any { - // Not using an arrow function to preserve context passed from call site - return function(...args: any[]) { - const proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (_inFakeAsyncCall) { - throw new Error('fakeAsync() calls can not be nested'); - } - _inFakeAsyncCall = true; - try { - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - } + let res: any; + const lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } - let res: any; - const lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - try { - res = fn.apply(this, args); - flushMicrotasks(); - } finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error( + `${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` + + `periodic timer(s) still in the queue.`); + } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error( - `${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` + - `periodic timer(s) still in the queue.`); + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error( + `${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`); + } + return res; + } finally { + resetFakeAsyncZone(); } + }; + } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error( - `${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`); + function _getFakeAsyncZoneSpec(): any { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); } - return res; - } finally { - _inFakeAsyncCall = false; - resetFakeAsyncZone(); } - }; -} - -function _getFakeAsyncZoneSpec(): any { - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); + return _fakeAsyncTestZoneSpec; } - return _fakeAsyncTestZoneSpec; -} -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ -export function tick(millis: number = 0): void { - _getFakeAsyncZoneSpec().tick(millis); -} + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis: number = 0): void { + _getFakeAsyncZoneSpec().tick(millis); + } -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ -export function flush(maxTurns?: number): number { - return _getFakeAsyncZoneSpec().flush(maxTurns); -} + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns?: number): number { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } -/** - * Discard all remaining periodic tasks. - * - * @experimental - */ -export function discardPeriodicTasks(): void { - const zoneSpec = _getFakeAsyncZoneSpec(); - const pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; -} + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks(): void { + const zoneSpec = _getFakeAsyncZoneSpec(); + const pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } -/** - * Flush any pending microtasks. - * - * @experimental - */ -export function flushMicrotasks(): void { - _getFakeAsyncZoneSpec().flushMicrotasks(); -} + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks(): void { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + (Zone as any)[api.symbol('fakeAsyncTest')] = + {resetFakeAsyncZone, flushMicrotasks, discardPeriodicTasks, tick, flush, fakeAsync}; +}); \ No newline at end of file diff --git a/lib/testing/zone-testing.ts b/lib/testing/zone-testing.ts index c566694b9..ea88b7596 100644 --- a/lib/testing/zone-testing.ts +++ b/lib/testing/zone-testing.ts @@ -14,5 +14,5 @@ import '../jasmine/jasmine'; import '../zone-spec/async-test'; import '../zone-spec/fake-async-test'; import './promise-testing'; -export * from './async-testing'; -export * from './fake-async'; \ No newline at end of file +import './async-testing'; +import './fake-async'; \ No newline at end of file diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index ee1bf9c5c..31e178cb0 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -16,15 +16,14 @@ class AsyncTestZoneSpec implements ZoneSpec { runZone = Zone.current; unresolvedChainedPromiseCount = 0; - constructor(private finishCallback: Function, private failCallback: Function, namePrefix: string) { + constructor( + private finishCallback: Function, private failCallback: Function, namePrefix: string) { this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { - 'AsyncTestZoneSpec': this - }; + this.properties = {'AsyncTestZoneSpec': this}; } _finishCallbackIfDone() { - if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(() => { setTimeout(() => { @@ -61,16 +60,18 @@ class AsyncTestZoneSpec implements ZoneSpec { this._isSync = false; } if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise + // check whether the promise is a chained promise if ((task.data as any)[AsyncTestZoneSpec.symbolParentUnresolved] === true) { // chained promise is being scheduled - this.unresolvedChainedPromiseCount --; + this.unresolvedChainedPromiseCount--; } - } + } return delegate.scheduleTask(target, task); } - onInvokeTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, applyThis: any, applyArgs: any) { + onInvokeTask( + delegate: ZoneDelegate, current: Zone, target: Zone, task: Task, applyThis: any, + applyArgs: any) { if (task.type !== 'eventTask') { this._isSync = false; } @@ -94,11 +95,9 @@ class AsyncTestZoneSpec implements ZoneSpec { applyThis: any, applyArgs: any[], source: string): any { let previousTaskCounts: any = null; try { - this.patchPromiseForTest(); this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this.unPatchPromiseForTest(); const afterTaskCounts: any = (parentZoneDelegate as any)._taskCounts; if (this._isSync) { this._finishCallbackIfDone(); diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index fdc17d5d7..0479b7eb5 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -217,6 +217,8 @@ pendingPeriodicTimers: number[] = []; pendingTimers: number[] = []; + private patchDateLocked = false; + constructor( namePrefix: string, private trackPendingRequestAnimationFrame = false, private macroTaskOptions?: MacroTaskOptions[]) { @@ -338,6 +340,7 @@ return; } global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; } static resetDate() { @@ -346,6 +349,15 @@ } } + lockDatePatch() { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + } + unlockDatePatch() { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + } + tick(millis: number = 0, doTick?: (elapsed: number) => void): void { FakeAsyncTestZoneSpec.assertInZone(); this.flushMicrotasks(); @@ -489,7 +501,9 @@ FakeAsyncTestZoneSpec.patchDate(); return delegate.invoke(target, callback, applyThis, applyArgs, source); } finally { - FakeAsyncTestZoneSpec.resetDate(); + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } } } diff --git a/lib/zone-spec/proxy.ts b/lib/zone-spec/proxy.ts index 385129766..abe03d6dd 100644 --- a/lib/zone-spec/proxy.ts +++ b/lib/zone-spec/proxy.ts @@ -60,6 +60,7 @@ class ProxyZoneSpec implements ZoneSpec { resetDelegate() { + const delegateSpec = this.getDelegate(); this.setDelegate(this.defaultSpecDelegate); } @@ -76,7 +77,7 @@ class ProxyZoneSpec implements ZoneSpec { if (!this.tasks) { return; } - for (let i = 0; i < this.tasks.length; i ++) { + for (let i = 0; i < this.tasks.length; i++) { if (this.tasks[i] === task) { this.tasks.splice(i, 1); return; diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 476ffdb0d..334834acc 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -20,4 +20,6 @@ import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/extra/cordova'; import '../lib/testing/promise-testing'; +import '../lib/testing/async-testing'; +import '../lib/testing/fake-async'; import '../lib/browser/webapis-resize-observer'; diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index 27ba367ca..b58ffc8c1 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -25,6 +25,8 @@ import '../lib/zone-spec/wtf'; import '../lib/rxjs/rxjs'; import '../lib/testing/promise-testing'; +import '../lib/testing/async-testing'; +import '../lib/testing/fake-async'; // Setup test environment import './test-env-setup-jasmine'; diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index 95918ff25..b5aeb491e 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {asyncTest} from '../../lib/testing/async-testing'; import {ifEnvSupports} from '../test-util'; describe('AsyncTestZoneSpec', function() { @@ -318,32 +317,7 @@ describe('AsyncTestZoneSpec', function() { }); - describe('non zone aware async task in promise should be detected', () => { - it('should be able to detect non zone aware async task in promise', (done) => { - let finished = false; - - const testZoneSpec = new AsyncTestZoneSpec( - () => { - expect(finished).toBe(true); - done(); - }, - () => { - done.fail('async zone called failCallback unexpectedly'); - }, - 'name'); - - const atz = Zone.current.fork(testZoneSpec); - - atz.run(() => { - new Promise((res, rej) => { - const g: any = typeof window === 'undefined' ? global : window; - g[Zone.__symbol__('setTimeout')](res, 100); - }).then(() => { - finished = true; - }); - }); - }); - }); + const asyncTest: any = (Zone as any)[Zone.__symbol__('asyncTest')]; function wrapAsyncTest(fn: Function, doneFn?: Function) { return function(done: Function) { @@ -358,6 +332,26 @@ describe('AsyncTestZoneSpec', function() { } describe('async', () => { + // TODO: @JiaLiPassion, get this feature back when all tests pass + // in angular + xdescribe('non zone aware async task in promise should be detected', () => { + let finished = false; + it('should be able to detect non zone aware async task in promise', + wrapAsyncTest( + () => { + new Promise((res, rej) => { + const g: any = typeof window === 'undefined' ? global : window; + g[Zone.__symbol__('setTimeout')](res, 100); + }).then(() => { + finished = true; + }); + }, + () => { + expect(finished).toBe(true); + })); + }); + + describe('test without beforeEach', () => { const logs: string[] = []; it('should automatically done after async tasks finished', diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index bb40a84b3..b56acfccb 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -12,7 +12,6 @@ import '../../lib/rxjs/rxjs-fake-async'; import {Observable} from 'rxjs/Observable'; import {isNode, patchMacroTask} from '../../lib/common/utils'; -import {discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, tick} from '../../lib/testing/fake-async'; import {ifEnvSupports} from '../test-util'; function supportNode() { @@ -874,6 +873,13 @@ describe('FakeAsyncTestZoneSpec', () => { expect(end - start).toBe(100); }); }); + + it('should check date type correctly', () => { + fakeAsyncTestZone.run(() => { + const d: any = new Date(); + expect(d instanceof Date).toBe(true); + }); + }); }); describe( @@ -891,6 +897,11 @@ describe('FakeAsyncTestZoneSpec', () => { jasmine.clock().uninstall(); }); + it('should check date type correctly', () => { + const d: any = new Date(); + expect(d instanceof Date).toBe(true); + }); + it('should get date diff correctly', () => { const start = Date.now(); jasmine.clock().tick(100); @@ -978,6 +989,8 @@ class Log { const resolvedPromise = Promise.resolve(null); const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec']; +const fakeAsyncTestModule = (Zone as any)[Zone.__symbol__('fakeAsyncTest')]; +const {fakeAsync, tick, discardPeriodicTasks, flush, flushMicrotasks} = fakeAsyncTestModule; { describe('fake async', () => { From 66c6f97472c24e323db57d125194c18762d6fdfe Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sat, 31 Mar 2018 06:56:46 +0900 Subject: [PATCH 037/106] fix(fakeAsyncTest): fix #1061, fakeAsync should support setImmediate (#1062) Closes #1062 --- lib/zone-spec/fake-async-test.ts | 4 ++++ test/zone-spec/fake-async-test.spec.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 0479b7eb5..c85205047 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -425,6 +425,10 @@ task.invoke, task.data['delay'], Array.prototype.slice.call((task.data as any)['args'], 2)); break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout( + task.invoke, 0, Array.prototype.slice.call((task.data as any)['args'], 1)); + break; case 'setInterval': task.data['handleId'] = this._setInterval( task.invoke, task.data['delay'], diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index b56acfccb..a04ceccd6 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -136,6 +136,20 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); + it('should run queued immediate timer on zero tick', () => { + fakeAsyncTestZone.run(() => { + let ran = false; + setImmediate(() => { + ran = true; + }); + + expect(ran).toEqual(false); + + testZoneSpec.tick(); + expect(ran).toEqual(true); + }); + }); + it('should run queued timer after sufficient clock ticks', () => { fakeAsyncTestZone.run(() => { let ran = false; @@ -218,6 +232,18 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); + it('should pass arguments to setImmediate', () => { + fakeAsyncTestZone.run(() => { + let value = 'genuine value'; + let id = setImmediate((arg1, arg2) => { + value = arg1 + arg2; + }, 'expected', ' value'); + + testZoneSpec.tick(); + expect(value).toEqual('expected value'); + }); + }); + it('should run periodic timers', () => { fakeAsyncTestZone.run(() => { let cycles = 0; From ac4ceb336a0e680fe36e0d8392ce8c616c852979 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 31 Mar 2018 09:17:18 -0700 Subject: [PATCH 038/106] chore: release v0.8.22 --- CHANGELOG.md | 11 + dist/async-test.js | 10 +- dist/fake-async-test.js | 17 +- dist/jasmine-patch.js | 15 +- dist/jasmine-patch.min.js | 2 +- dist/proxy.js | 1 + dist/proxy.min.js | 2 +- dist/zone-async-testing.js | 107 ++++++ dist/zone-fake-async.js | 161 +++++++++ dist/zone-mix.js | 64 +--- dist/zone-node.js | 64 +--- dist/zone-patch-jsonp.js | 81 +++++ dist/zone-patch-jsonp.min.js | 1 + dist/zone-patch-promise-test.js | 80 +++++ dist/zone-patch-promise-test.min.js | 1 + dist/zone-patch-resize-observer.js | 99 ++++++ dist/zone-patch-resize-observer.min.js | 1 + dist/zone-patch-rxjs-fake-async.js | 33 ++ dist/zone-patch-rxjs-fake-async.min.js | 1 + dist/zone-patch-socket-io.js | 39 ++ dist/zone-patch-socket-io.min.js | 1 + dist/zone-testing-bundle.js | 398 ++++++++++++++------- dist/zone-testing-node-bundle.js | 398 ++++++++++++++------- dist/zone-testing.js | 471 +++++++++++++------------ dist/zone.js | 64 +--- dist/zone.min.js | 4 +- package.json | 2 +- 27 files changed, 1488 insertions(+), 640 deletions(-) create mode 100644 dist/zone-async-testing.js create mode 100644 dist/zone-fake-async.js create mode 100644 dist/zone-patch-jsonp.js create mode 100644 dist/zone-patch-jsonp.min.js create mode 100644 dist/zone-patch-promise-test.js create mode 100644 dist/zone-patch-promise-test.min.js create mode 100644 dist/zone-patch-resize-observer.js create mode 100644 dist/zone-patch-resize-observer.min.js create mode 100644 dist/zone-patch-rxjs-fake-async.js create mode 100644 dist/zone-patch-rxjs-fake-async.min.js create mode 100644 dist/zone-patch-socket-io.js create mode 100644 dist/zone-patch-socket-io.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 1869ed0ca..2b8bd0278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [0.8.22](https://github.com/angular/zone.js/compare/v0.8.21...0.8.22) (2018-03-31) + + +### Bug Fixes + +* **fakeAsync:** fix [#1050](https://github.com/angular/zone.js/issues/1050), should only reset patched Date.now until fakeAsync exit ([#1051](https://github.com/angular/zone.js/issues/1051)) ([e15d735](https://github.com/angular/zone.js/commit/e15d735)) +* **fakeAsyncTest:** fix [#1061](https://github.com/angular/zone.js/issues/1061), fakeAsync should support setImmediate ([#1062](https://github.com/angular/zone.js/issues/1062)) ([66c6f97](https://github.com/angular/zone.js/commit/66c6f97)) + + + ## [0.8.21](https://github.com/angular/zone.js/compare/v0.8.20...0.8.21) (2018-03-30) diff --git a/dist/async-test.js b/dist/async-test.js index 952c5f77a..35c77f4ef 100644 --- a/dist/async-test.js +++ b/dist/async-test.js @@ -29,13 +29,11 @@ var AsyncTestZoneSpec = /** @class */ (function () { this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { - 'AsyncTestZoneSpec': this - }; + this.properties = { 'AsyncTestZoneSpec': this }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -63,7 +61,7 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; } if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise + // check whether the promise is a chained promise if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { // chained promise is being scheduled this.unresolvedChainedPromiseCount--; @@ -90,12 +88,10 @@ var AsyncTestZoneSpec = /** @class */ (function () { // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { - this.patchPromiseForTest(); this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this.unPatchPromiseForTest(); var afterTaskCounts = parentZoneDelegate._taskCounts; if (this._isSync) { this._finishCallbackIfDone(); diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index 32c0f215b..6fd9aa285 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -192,6 +192,7 @@ this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; this.pendingPeriodicTimers = []; this.pendingTimers = []; + this.patchDateLocked = false; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; // in case user can't access the construction of FakeAsyncTestSpec @@ -307,12 +308,21 @@ return; } global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -371,6 +381,9 @@ case 'setTimeout': task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; case 'setInterval': task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; @@ -439,7 +452,9 @@ return delegate.invoke(target, callback, applyThis, applyArgs, source); } finally { - FakeAsyncTestZoneSpec.resetDate(); + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } } }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 493d91a95..78cf8115b 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -116,7 +116,7 @@ return syncZone.run(describeBody, this, arguments); }; } - function runInTestZone(testBody, queueRunner, done) { + function runInTestZone(testBody, applyThis, queueRunner, done) { var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; @@ -127,18 +127,23 @@ var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); lastDelegate = testProxyZoneSpec.getDelegate(); testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); } } try { if (done) { - return testProxyZone.run(testBody, this, [done]); + return testProxyZone.run(testBody, applyThis, [done]); } else { - return testProxyZone.run(testBody, this); + return testProxyZone.run(testBody, applyThis); } } finally { if (isClockInstalled) { + var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } testProxyZoneSpec.setDelegate(lastDelegate); } } @@ -153,9 +158,9 @@ // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this.queueRunner, done); + return runInTestZone(testBody, this, this.queueRunner, done); } : function () { - return runInTestZone(testBody, this.queueRunner); + return runInTestZone(testBody, this, this.queueRunner); })); } var QueueRunner = jasmine.QueueRunner; diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index dd0f2ef54..c9796219e 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!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 u.run(e,this,arguments)}}function n(e,n,t){var o,r=!!jasmine[a("clockInstalled")],i=n.testProxyZoneSpec,s=n.testProxyZone;if(r){var c=Zone.FakeAsyncTestZoneSpec;if(c){var u=new c;o=i.getDelegate(),i.setDelegate(u)}}try{return t?s.run(e,this,[t]):s.run(e,this)}finally{r&&i.setDelegate(o)}}function t(e){return e&&(e.length?function(t){return n(e,this.queueRunner,t)}:function(){return n(e,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,u=c.fork(new i("jasmine.describe")),a=Zone.__symbol__,f=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=f[n];f[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=f[e];f[a(e)]=n,f[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=f[e];f[a(e)]=n,f[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[a("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments),n=e[a("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[a("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[a(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[a("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e};var p=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(n)})},n}(p)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return a.run(e,this,arguments)}}function n(e,n,t,o){var r,i=!!jasmine[u("clockInstalled")],s=t.testProxyZoneSpec,c=t.testProxyZone;if(i){var a=Zone.FakeAsyncTestZoneSpec;if(a){var f=new a;r=s.getDelegate(),s.setDelegate(f),f.lockDatePatch()}}try{return o?c.run(e,n,[o]):c.run(e,n)}finally{if(i){var f=s.getDelegate();f&&f.unlockDatePatch(),s.setDelegate(r)}}}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,a=c.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=f[n];f[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=f[e];f[u(e)]=n,f[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=f[e];f[u(e)]=n,f[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments),n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e};var p=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(n)})},n}(p)}()}); \ No newline at end of file diff --git a/dist/proxy.js b/dist/proxy.js index be3c426bb..5766ee978 100644 --- a/dist/proxy.js +++ b/dist/proxy.js @@ -63,6 +63,7 @@ var ProxyZoneSpec = /** @class */ (function () { return this._delegateSpec; }; ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); this.setDelegate(this.defaultSpecDelegate); }; ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { diff --git a/dist/proxy.min.js b/dist/proxy.min.js index 5f73c04aa..c0c44d725 100644 --- a/dist/proxy.min.js +++ b/dist/proxy.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";var e=function(){function e(e){void 0===e&&(e=null),this.defaultSpecDelegate=e,this.name="ProxyZone",this.properties={ProxyZoneSpec:this},this.propertyKeys=null,this.lastTaskState=null,this.isNeedToTriggerHasTask=!1,this.tasks=[],this.setDelegate(e)}return e.get=function(){return Zone.current.get("ProxyZoneSpec")},e.isLoaded=function(){return e.get()instanceof e},e.assertPresent=function(){if(!e.isLoaded())throw new Error("Expected to be running in 'ProxyZone', but it was not found.");return e.get()},e.prototype.setDelegate=function(e){var t=this,s=this._delegateSpec!==e;this._delegateSpec=e,this.propertyKeys&&this.propertyKeys.forEach(function(e){return delete t.properties[e]}),this.propertyKeys=null,e&&e.properties&&(this.propertyKeys=Object.keys(e.properties),this.propertyKeys.forEach(function(s){return t.properties[s]=e.properties[s]})),s&&this.lastTaskState&&(this.lastTaskState.macroTask||this.lastTaskState.microTask)&&(this.isNeedToTriggerHasTask=!0)},e.prototype.getDelegate=function(){return this._delegateSpec},e.prototype.resetDelegate=function(){this.setDelegate(this.defaultSpecDelegate)},e.prototype.tryTriggerHasTask=function(e,t,s){this.isNeedToTriggerHasTask&&this.lastTaskState&&(this.isNeedToTriggerHasTask=!1,this.onHasTask(e,t,s,this.lastTaskState))},e.prototype.removeFromTasks=function(e){if(this.tasks)for(var t=0;t 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); + +}))); diff --git a/dist/zone-mix.js b/dist/zone-mix.js index 4b59965e3..23a6e068f 100644 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-node.js b/dist/zone-node.js index dc55a8875..c857c893c 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-patch-jsonp.js b/dist/zone-patch-jsonp.js new file mode 100644 index 000000000..4dcf57382 --- /dev/null +++ b/dist/zone-patch-jsonp.js @@ -0,0 +1,81 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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.__load_patch('jsonp', function (global, Zone, api) { + Zone[Zone.__symbol__('jsonp')] = function patchJsonp(options) { + if (!options || !options.jsonp || !options.sendFuncName) { + return; + } + var noop = function () { }; + [options.successFuncName, options.failedFuncName].forEach(function (methodName) { + if (!methodName) { + return; + } + var oriFunc = global[methodName]; + if (oriFunc) { + api.patchMethod(global, methodName, function (delegate) { return function (self, args) { + var task = global[api.symbol('jsonTask')]; + if (task) { + task.callback = delegate; + return task.invoke.apply(self, args); + } + else { + return delegate.apply(self, args); + } + }; }); + } + else { + Object.defineProperty(global, methodName, { + configurable: true, + enumerable: true, + get: function () { + return function () { + var task = global[api.symbol('jsonpTask')]; + var delegate = global[api.symbol("jsonp" + methodName + "callback")]; + if (task) { + if (delegate) { + task.callback = delegate; + } + global[api.symbol('jsonpTask')] = undefined; + return task.invoke.apply(this, arguments); + } + else { + if (delegate) { + return delegate.apply(this, arguments); + } + } + return null; + }; + }, + set: function (callback) { + this[api.symbol("jsonp" + methodName + "callback")] = callback; + } + }); + } + }); + api.patchMethod(options.jsonp, options.sendFuncName, function (delegate) { return function (self, args) { + global[api.symbol('jsonpTask')] = Zone.current.scheduleMacroTask('jsonp', noop, {}, function (task) { + return delegate.apply(self, args); + }, noop); + }; }); + }; +}); + +}))); diff --git a/dist/zone-patch-jsonp.min.js b/dist/zone-patch-jsonp.min.js new file mode 100644 index 000000000..6d8881776 --- /dev/null +++ b/dist/zone-patch-jsonp.min.js @@ -0,0 +1 @@ +!function(n,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("jsonp",function(n,o,e){o[o.__symbol__("jsonp")]=function(t){if(t&&t.jsonp&&t.sendFuncName){var c=function(){};[t.successFuncName,t.failedFuncName].forEach(function(o){if(o){var t=n[o];t?e.patchMethod(n,o,function(o){return function(t,c){var s=n[e.symbol("jsonTask")];return s?(s.callback=o,s.invoke.apply(t,c)):o.apply(t,c)}}):Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:function(){return function(){var t=n[e.symbol("jsonpTask")],c=n[e.symbol("jsonp"+o+"callback")];return t?(c&&(t.callback=c),n[e.symbol("jsonpTask")]=void 0,t.invoke.apply(this,arguments)):c?c.apply(this,arguments):null}},set:function(n){this[e.symbol("jsonp"+o+"callback")]=n}})}}),e.patchMethod(t.jsonp,t.sendFuncName,function(t){return function(s,a){n[e.symbol("jsonpTask")]=o.current.scheduleMacroTask("jsonp",c,{},function(n){return t.apply(s,a)},c)}})}}})}); \ No newline at end of file diff --git a/dist/zone-patch-promise-test.js b/dist/zone-patch-promise-test.js new file mode 100644 index 000000000..45a7db12d --- /dev/null +++ b/dist/zone-patch-promise-test.js @@ -0,0 +1,80 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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 + */ +/** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ +Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; +}); + +}))); diff --git a/dist/zone-patch-promise-test.min.js b/dist/zone-patch-promise-test.min.js new file mode 100644 index 000000000..55ac90a8c --- /dev/null +++ b/dist/zone-patch-promise-test.min.js @@ -0,0 +1 @@ +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("promisefortest",function(e,o,n){var t=n.symbol("state"),s=null,r=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e||(e=Promise[o.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var n=e.apply(this,arguments);if(this[t]===s){var i=o.current.get("AsyncTestZoneSpec");i&&(i.unresolvedChainedPromiseCount++,n[r]=!0)}return n})},Promise[n.symbol("unPatchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e&&(Promise.prototype.then=e,Promise[o.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone-patch-resize-observer.js b/dist/zone-patch-resize-observer.js new file mode 100644 index 000000000..b0cabc088 --- /dev/null +++ b/dist/zone-patch-resize-observer.js @@ -0,0 +1,99 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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.__load_patch('ResizeObserver', function (global, Zone, api) { + var ResizeObserver = global['ResizeObserver']; + if (!ResizeObserver) { + return; + } + var resizeObserverSymbol = api.symbol('ResizeObserver'); + api.patchMethod(global, 'ResizeObserver', function (delegate) { return function (self, args) { + var callback = args.length > 0 ? args[0] : null; + if (callback) { + args[0] = function (entries, observer) { + var _this = this; + var zones = {}; + var currZone = Zone.current; + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; + var zone = entry.target[resizeObserverSymbol]; + if (!zone) { + zone = currZone; + } + var zoneEntriesInfo = zones[zone.name]; + if (!zoneEntriesInfo) { + zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; + } + zoneEntriesInfo.entries.push(entry); + } + Object.keys(zones).forEach(function (zoneName) { + var zoneEntriesInfo = zones[zoneName]; + if (zoneEntriesInfo.zone !== Zone.current) { + zoneEntriesInfo.zone.run(callback, _this, [zoneEntriesInfo.entries, observer], 'ResizeObserver'); + } + else { + callback.call(_this, zoneEntriesInfo.entries, observer); + } + }); + }; + } + return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); + }; }); + api.patchMethod(ResizeObserver.prototype, 'observe', function (delegate) { return function (self, args) { + var target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + var targets = self[resizeObserverSymbol]; + if (!targets) { + targets = self[resizeObserverSymbol] = []; + } + targets.push(target); + target[resizeObserverSymbol] = Zone.current; + return delegate.apply(self, args); + }; }); + api.patchMethod(ResizeObserver.prototype, 'unobserve', function (delegate) { return function (self, args) { + var target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + var targets = self[resizeObserverSymbol]; + if (targets) { + for (var i = 0; i < targets.length; i++) { + if (targets[i] === target) { + targets.splice(i, 1); + break; + } + } + } + target[resizeObserverSymbol] = undefined; + return delegate.apply(self, args); + }; }); + api.patchMethod(ResizeObserver.prototype, 'disconnect', function (delegate) { return function (self, args) { + var targets = self[resizeObserverSymbol]; + if (targets) { + targets.forEach(function (target) { target[resizeObserverSymbol] = undefined; }); + self[resizeObserverSymbol] = undefined; + } + return delegate.apply(self, args); + }; }); +}); + +}))); diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js new file mode 100644 index 000000000..bffe2a10a --- /dev/null +++ b/dist/zone-patch-resize-observer.min.js @@ -0,0 +1 @@ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("ResizeObserver",function(e,n,r){var t=e.ResizeObserver;if(t){var o=r.symbol("ResizeObserver");r.patchMethod(e,"ResizeObserver",function(e){return function(e,r){var i=r.length>0?r[0]:null;return i&&(r[0]=function(e,r){for(var t=this,u={},a=n.current,c=0,f=e;c0?new t(r[0]):new t}}),r.patchMethod(t.prototype,"observe",function(e){return function(r,t){var i=t.length>0?t[0]:null;if(!i)return e.apply(r,t);var u=r[o];return u||(u=r[o]=[]),u.push(i),i[o]=n.current,e.apply(r,t)}}),r.patchMethod(t.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var i=n[o];if(i)for(var u=0;u= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); - } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_2) throw e_2.error; } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); @@ -3299,6 +3269,7 @@ var ProxyZoneSpec = /** @class */ (function () { return this._delegateSpec; }; ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); this.setDelegate(this.defaultSpecDelegate); }; ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { @@ -3555,7 +3526,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return syncZone.run(describeBody, this, arguments); }; } - function runInTestZone(testBody, queueRunner, done) { + function runInTestZone(testBody, applyThis, queueRunner, done) { var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; @@ -3566,18 +3537,23 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); lastDelegate = testProxyZoneSpec.getDelegate(); testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); } } try { if (done) { - return testProxyZone.run(testBody, this, [done]); + return testProxyZone.run(testBody, applyThis, [done]); } else { - return testProxyZone.run(testBody, this); + return testProxyZone.run(testBody, applyThis); } } finally { if (isClockInstalled) { + var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } testProxyZoneSpec.setDelegate(lastDelegate); } } @@ -3592,9 +3568,9 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this.queueRunner, done); + return runInTestZone(testBody, this, this.queueRunner, done); } : function () { - return runInTestZone(testBody, this.queueRunner); + return runInTestZone(testBody, this, this.queueRunner); })); } var QueueRunner = jasmine.QueueRunner; @@ -3709,13 +3685,11 @@ var AsyncTestZoneSpec = /** @class */ (function () { this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { - 'AsyncTestZoneSpec': this - }; + this.properties = { 'AsyncTestZoneSpec': this }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -3743,7 +3717,7 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; } if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise + // check whether the promise is a chained promise if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { // chained promise is being scheduled this.unresolvedChainedPromiseCount--; @@ -3770,12 +3744,10 @@ var AsyncTestZoneSpec = /** @class */ (function () { // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { - this.patchPromiseForTest(); this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this.unPatchPromiseForTest(); var afterTaskCounts = parentZoneDelegate._taskCounts; if (this._isSync) { this._finishCallbackIfDone(); @@ -3990,6 +3962,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; this.pendingPeriodicTimers = []; this.pendingTimers = []; + this.patchDateLocked = false; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; // in case user can't access the construction of FakeAsyncTestSpec @@ -4105,12 +4078,21 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return; } global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -4169,6 +4151,9 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; case 'setTimeout': task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; case 'setInterval': task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; @@ -4237,7 +4222,9 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return delegate.invoke(target, callback, applyThis, applyArgs, source); } finally { - FakeAsyncTestZoneSpec.resetDate(); + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } } }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { @@ -4336,10 +4323,91 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { * 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 */ -/** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ +Zone.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); + } +}); /** * @license @@ -4348,69 +4416,145 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { * 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 FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; -var ProxyZoneSpec$1 = Zone && Zone['ProxyZoneSpec']; -/** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - -/** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - -/** - * Discard all remaining periodic tasks. - * - * @experimental - */ - -/** - * Flush any pending microtasks. - * - * @experimental - */ +Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); /** * @license diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 9e9605547..85de0f422 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); @@ -2537,6 +2507,7 @@ var ProxyZoneSpec = /** @class */ (function () { return this._delegateSpec; }; ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); this.setDelegate(this.defaultSpecDelegate); }; ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { @@ -2793,7 +2764,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return syncZone.run(describeBody, this, arguments); }; } - function runInTestZone(testBody, queueRunner, done) { + function runInTestZone(testBody, applyThis, queueRunner, done) { var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; @@ -2804,18 +2775,23 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); lastDelegate = testProxyZoneSpec.getDelegate(); testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); } } try { if (done) { - return testProxyZone.run(testBody, this, [done]); + return testProxyZone.run(testBody, applyThis, [done]); } else { - return testProxyZone.run(testBody, this); + return testProxyZone.run(testBody, applyThis); } } finally { if (isClockInstalled) { + var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } testProxyZoneSpec.setDelegate(lastDelegate); } } @@ -2830,9 +2806,9 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this.queueRunner, done); + return runInTestZone(testBody, this, this.queueRunner, done); } : function () { - return runInTestZone(testBody, this.queueRunner); + return runInTestZone(testBody, this, this.queueRunner); })); } var QueueRunner = jasmine.QueueRunner; @@ -2947,13 +2923,11 @@ var AsyncTestZoneSpec = /** @class */ (function () { this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { - 'AsyncTestZoneSpec': this - }; + this.properties = { 'AsyncTestZoneSpec': this }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -2981,7 +2955,7 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; } if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise + // check whether the promise is a chained promise if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { // chained promise is being scheduled this.unresolvedChainedPromiseCount--; @@ -3008,12 +2982,10 @@ var AsyncTestZoneSpec = /** @class */ (function () { // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { - this.patchPromiseForTest(); this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this.unPatchPromiseForTest(); var afterTaskCounts = parentZoneDelegate._taskCounts; if (this._isSync) { this._finishCallbackIfDone(); @@ -3228,6 +3200,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; this.pendingPeriodicTimers = []; this.pendingTimers = []; + this.patchDateLocked = false; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; // in case user can't access the construction of FakeAsyncTestSpec @@ -3343,12 +3316,21 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return; } global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -3407,6 +3389,9 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; case 'setTimeout': task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; case 'setInterval': task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; @@ -3475,7 +3460,9 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return delegate.invoke(target, callback, applyThis, applyArgs, source); } finally { - FakeAsyncTestZoneSpec.resetDate(); + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } } }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { @@ -3574,10 +3561,91 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { * 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 */ -/** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ +Zone.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); + } +}); /** * @license @@ -3586,69 +3654,145 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { * 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 FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; -var ProxyZoneSpec$1 = Zone && Zone['ProxyZoneSpec']; -/** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - -/** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - -/** - * Discard all remaining periodic tasks. - * - * @experimental - */ - -/** - * Flush any pending microtasks. - * - * @experimental - */ +Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); /** * @license diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 2e6d244d6..5ea69eca1 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.zone = {}))); -}(this, (function (exports) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; /** * @license @@ -223,6 +223,7 @@ var ProxyZoneSpec = /** @class */ (function () { return this._delegateSpec; }; ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); this.setDelegate(this.defaultSpecDelegate); }; ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { @@ -479,7 +480,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return syncZone.run(describeBody, this, arguments); }; } - function runInTestZone(testBody, queueRunner, done) { + function runInTestZone(testBody, applyThis, queueRunner, done) { var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; @@ -490,18 +491,23 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); lastDelegate = testProxyZoneSpec.getDelegate(); testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); } } try { if (done) { - return testProxyZone.run(testBody, this, [done]); + return testProxyZone.run(testBody, applyThis, [done]); } else { - return testProxyZone.run(testBody, this); + return testProxyZone.run(testBody, applyThis); } } finally { if (isClockInstalled) { + var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } testProxyZoneSpec.setDelegate(lastDelegate); } } @@ -516,9 +522,9 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // Note we have to make a function with correct number of arguments, otherwise jasmine will // think that all functions are sync or async. return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this.queueRunner, done); + return runInTestZone(testBody, this, this.queueRunner, done); } : function () { - return runInTestZone(testBody, this.queueRunner); + return runInTestZone(testBody, this, this.queueRunner); })); } var QueueRunner = jasmine.QueueRunner; @@ -633,13 +639,11 @@ var AsyncTestZoneSpec = /** @class */ (function () { this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { - 'AsyncTestZoneSpec': this - }; + this.properties = { 'AsyncTestZoneSpec': this }; } AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || this.unresolvedChainedPromiseCount !== 0)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -667,7 +671,7 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; } if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise + // check whether the promise is a chained promise if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { // chained promise is being scheduled this.unresolvedChainedPromiseCount--; @@ -694,12 +698,10 @@ var AsyncTestZoneSpec = /** @class */ (function () { // was scheduled/invoked/canceled. AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { - this.patchPromiseForTest(); this._isSync = true; return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - this.unPatchPromiseForTest(); var afterTaskCounts = parentZoneDelegate._taskCounts; if (this._isSync) { this._finishCallbackIfDone(); @@ -914,6 +916,7 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; this.pendingPeriodicTimers = []; this.pendingTimers = []; + this.patchDateLocked = false; this.properties = { 'FakeAsyncTestZoneSpec': this }; this.name = 'fakeAsyncTestZone for ' + namePrefix; // in case user can't access the construction of FakeAsyncTestSpec @@ -1029,12 +1032,21 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return; } global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { if (millis === void 0) { millis = 0; } FakeAsyncTestZoneSpec.assertInZone(); @@ -1093,6 +1105,9 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; case 'setTimeout': task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; case 'setInterval': task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); break; @@ -1161,7 +1176,9 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; return delegate.invoke(target, callback, applyThis, applyArgs, source); } finally { - FakeAsyncTestZoneSpec.resetDate(); + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } } }; FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { @@ -1260,90 +1277,91 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { * 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 _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; -/** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ -function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (_global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); +Zone.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); }); }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); }; -} -function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + }); + return Zone.current.runGuarded(fn, context); } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); -} +}); /** * @license @@ -1352,136 +1370,145 @@ function runInTestZone(fn, context, finishCallback, failCallback) { * 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 FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; -var ProxyZoneSpec$1 = Zone && Zone['ProxyZoneSpec']; -var _fakeAsyncTestZoneSpec = null; -/** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ -function resetFakeAsyncZone() { - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec$1 && ProxyZoneSpec$1.assertPresent().resetDelegate(); -} -var _inFakeAsyncCall = false; -/** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ -function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec$1.assertPresent(); - if (_inFakeAsyncCall) { - throw new Error('fakeAsync() calls can not be nested'); +Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); } - _inFakeAsyncCall = true; - try { - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); try { - res = fn.apply(this, args); - flushMicrotasks(); + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; } finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); + resetFakeAsyncZone(); } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); } - return res; - } - finally { - _inFakeAsyncCall = false; - resetFakeAsyncZone(); } - }; -} -function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); + return _fakeAsyncTestZoneSpec; } - return _fakeAsyncTestZoneSpec; -} -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ -function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); -} -/** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ -function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); -} -/** - * Discard all remaining periodic tasks. - * - * @experimental - */ -function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; -} -/** - * Flush any pending microtasks. - * - * @experimental - */ -function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); -} + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); /** * @license @@ -1492,14 +1519,4 @@ function flushMicrotasks() { */ // load test related files into bundle in correct order -exports.asyncTest = asyncTest; -exports.resetFakeAsyncZone = resetFakeAsyncZone; -exports.fakeAsync = fakeAsync; -exports.tick = tick; -exports.flush = flush; -exports.discardPeriodicTasks = discardPeriodicTasks; -exports.flushMicrotasks = flushMicrotasks; - -Object.defineProperty(exports, '__esModule', { value: true }); - }))); diff --git a/dist/zone.js b/dist/zone.js index 2cd0134c8..e15c127cf 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone.min.js b/dist/zone.min.js index 7d809e8d1..b95e78412 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=j(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[N("OriginalDelegate")]=t}function f(){if(ne)return re;ne=!0;try{var e=X.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(re=!0),re}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=I(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[N(a)]=k[a],E=k[N(i)]=k[i],S=k[N(s)]=k[s];n&&n.prepend&&(_=k[N(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=ae[e.eventName],n=void 0;t&&(n=t[e.capture?q:A]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=j(a,"onmessage");return s&&s.configurable===!1?(r=L(a),o=a,[R,x,"send","close"].forEach(function(e){r[e]=function(){var t=M.call(arguments);if(e===R||e===x){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!J||Q){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(Y){var o=window;w(o,Pe.concat(["messageerror"]),r,I(o)),w(Document.prototype,Pe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Pe,r),w(Element.prototype,Pe,r),w(HTMLElement.prototype,Pe,r),w(HTMLMediaElement.prototype,me,r),w(HTMLFrameSetElement.prototype,ge.concat(Ee),r),w(HTMLBodyElement.prototype,ge.concat(Ee),r),w(HTMLFrameElement.prototype,we,r),w(HTMLIFrameElement.prototype,we,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Se,r);var i=o.Worker;i&&w(i.prototype,Oe,r)}w(XMLHttpRequest.prototype,De,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,De,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ze,r),w(IDBRequest.prototype,Ze,r),w(IDBOpenDBRequest.prototype,Ze,r),w(IDBDatabase.prototype,Ze,r),w(IDBTransaction.prototype,Ze,r),w(IDBCursor.prototype,Ze,r)),n&&w(WebSocket.prototype,ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((Y||Q)&&!j(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=j(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=j(n,t);if(r){C(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return C(n,t,r||{}),a}var i=N("fake");C(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Pe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][je]&&(n=e(a[r],o),n[je]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=I();if(e===a)throw new TypeError(L);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==j&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==j&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===j&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,M,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=P(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[B("OriginalDelegate")]=t}function f(){if(te)return ne;te=!0;try{var e=W.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ne=!0),ne}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=C(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[B(a)]=k[a],E=k[B(i)]=k[i],S=k[B(s)]=k[s];n&&n.prepend&&(_=k[B(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=oe[e.eventName],n=void 0;t&&(n=t[e.capture?F:q]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=P(a,"onmessage");return s&&s.configurable===!1?(r=I(a),o=a,[M,R,"send","close"].forEach(function(e){r[e]=function(){var t=L.call(arguments);if(e===M||e===R){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!K||Y){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(J){var o=window;w(o,Oe.concat(["messageerror"]),r,C(o)),w(Document.prototype,Oe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Oe,r),w(Element.prototype,Oe,r),w(HTMLElement.prototype,Oe,r),w(HTMLMediaElement.prototype,ye,r),w(HTMLFrameSetElement.prototype,ve.concat(we),r),w(HTMLBodyElement.prototype,ve.concat(we),r),w(HTMLFrameElement.prototype,Te,r),w(HTMLIFrameElement.prototype,Te,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Ee,r);var i=o.Worker;i&&w(i.prototype,ze,r)}w(XMLHttpRequest.prototype,Se,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,Se,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,De,r),w(IDBRequest.prototype,De,r),w(IDBOpenDBRequest.prototype,De,r),w(IDBDatabase.prototype,De,r),w(IDBTransaction.prototype,De,r),w(IDBCursor.prototype,De,r)),n&&w(WebSocket.prototype,Ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((J||Y)&&!P(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=P(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=P(n,t);if(r){j(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return j(n,t,r||{}),a}var i=B("fake");j(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Oe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Pe]&&(n=e(a[r],o),n[Pe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l})("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(I);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==P&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==P&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===P&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,L,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g Date: Sun, 1 Apr 2018 01:55:52 +0900 Subject: [PATCH 039/106] fix(test): check setImmediate supports --- test/zone-spec/fake-async-test.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index a04ceccd6..340245760 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -136,7 +136,7 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); - it('should run queued immediate timer on zero tick', () => { + it('should run queued immediate timer on zero tick', ifEnvSupports('setImmediate', () => { fakeAsyncTestZone.run(() => { let ran = false; setImmediate(() => { @@ -148,7 +148,7 @@ describe('FakeAsyncTestZoneSpec', () => { testZoneSpec.tick(); expect(ran).toEqual(true); }); - }); + })); it('should run queued timer after sufficient clock ticks', () => { fakeAsyncTestZone.run(() => { @@ -232,7 +232,7 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); - it('should pass arguments to setImmediate', () => { + it('should pass arguments to setImmediate', ifEnvSupports('setImmediate', () => { fakeAsyncTestZone.run(() => { let value = 'genuine value'; let id = setImmediate((arg1, arg2) => { @@ -242,7 +242,7 @@ describe('FakeAsyncTestZoneSpec', () => { testZoneSpec.tick(); expect(value).toEqual('expected value'); }); - }); + })); it('should run periodic timers', () => { fakeAsyncTestZone.run(() => { From 7aebdbd1f62c21e2aa38034d0e5d59635d7a06ae Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 31 Mar 2018 17:52:13 -0700 Subject: [PATCH 040/106] chore: release v0.8.23 --- CHANGELOG.md | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b8bd0278..f82b8adc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [0.8.23](https://github.com/angular/zone.js/compare/v0.8.22...0.8.23) (2018-04-01) + + +### Bug Fixes + +* **test:** check setImmediate supports ([6c7e45b](https://github.com/angular/zone.js/commit/6c7e45b)) + + + ## [0.8.22](https://github.com/angular/zone.js/compare/v0.8.21...0.8.22) (2018-03-31) diff --git a/package.json b/package.json index 6eef8f154..98d1b21ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zone.js", - "version": "0.8.22", + "version": "0.8.23", "description": "Zones for JavaScript", "main": "dist/zone-node.js", "browser": "dist/zone.js", From 389762ca48f8850a42825a38ca871934fd65fd46 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 3 Apr 2018 03:29:16 +0900 Subject: [PATCH 041/106] fix(test): add flag to patch jasmine.clock, move fakeAsync/async into original bundle (#1067) --- .travis.yml | 2 + dist/zone-async-testing.js | 107 ------------ dist/zone-fake-async.js | 161 ----------------- dist/zone-mix.js | 64 +++++-- dist/zone-node.js | 64 +++++-- dist/zone-patch-resize-observer.js | 38 +++- dist/zone-patch-resize-observer.min.js | 2 +- dist/zone-testing-bundle.js | 64 +++++-- dist/zone-testing-node-bundle.js | 64 +++++-- dist/zone.js | 64 +++++-- dist/zone.min.js | 4 +- gulpfile.js | 22 ++- karma-base.conf.js | 2 +- karma-dist.conf.js | 6 +- lib/jasmine/jasmine.ts | 102 +++++------ lib/testing/async-testing.ts | 4 + lib/testing/fake-async.ts | 1 + lib/testing/zone-testing.ts | 4 +- lib/zone-spec/async-test.ts | 20 ++- test/browser-zone-setup.ts | 7 +- test/node_entry_point.ts | 14 +- test/test-env-setup-jasmine-no-patch-clock.ts | 8 + test/zone-spec/async-test.spec.ts | 12 +- test/zone-spec/fake-async-test.spec.ts | 165 +++++++++++------- 24 files changed, 483 insertions(+), 518 deletions(-) delete mode 100644 dist/zone-async-testing.js delete mode 100644 dist/zone-fake-async.js create mode 100644 test/test-env-setup-jasmine-no-patch-clock.ts diff --git a/.travis.yml b/.travis.yml index 93c1c1f27..3ec8c6596 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ script: - node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node + - node_modules/.bin/gulp test/node -no-patch-clock - node_modules/.bin/gulp test/bluebird - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js @@ -48,3 +49,4 @@ script: - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node + - node_modules/.bin/gulp test/node -no-patch-clock diff --git a/dist/zone-async-testing.js b/dist/zone-async-testing.js deleted file mode 100644 index 9d6f52df8..000000000 --- a/dist/zone-async-testing.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license -* Copyright Google Inc. All Rights Reserved. -* -* Use of this source code is governed by an MIT-style license that can be -* found in the LICENSE file at https://angular.io/license -*/ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { - /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ - Zone[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); - } - }); - }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); - }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -}))); diff --git a/dist/zone-fake-async.js b/dist/zone-fake-async.js deleted file mode 100644 index 8ae013811..000000000 --- a/dist/zone-fake-async.js +++ /dev/null @@ -1,161 +0,0 @@ -/** -* @license -* Copyright Google Inc. All Rights Reserved. -* -* Use of this source code is governed by an MIT-style license that can be -* found in the LICENSE file at https://angular.io/license -*/ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); - try { - res = fn.apply(this, args); - flushMicrotasks(); - } - finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - } - return _fakeAsyncTestZoneSpec; - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } - /** - * Discard all remaining periodic tasks. - * - * @experimental - */ - function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } - /** - * Flush any pending microtasks. - * - * @experimental - */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - -}))); diff --git a/dist/zone-mix.js b/dist/zone-mix.js index 23a6e068f..4b59965e3 100644 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -643,6 +643,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -916,14 +926,24 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; + var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -934,23 +954,33 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + if (!isThenable(value)) { + value = this.resolve(value); } - }; })(count), reject); - count++; + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } } if (!count) resolve(resolvedValues); return promise; + var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-node.js b/dist/zone-node.js index c857c893c..dc55a8875 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -643,6 +643,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -916,14 +926,24 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; + var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -934,23 +954,33 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + if (!isThenable(value)) { + value = this.resolve(value); } - }; })(count), reject); - count++; + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } } if (!count) resolve(resolvedValues); return promise; + var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-patch-resize-observer.js b/dist/zone-patch-resize-observer.js index b0cabc088..e80c32588 100644 --- a/dist/zone-patch-resize-observer.js +++ b/dist/zone-patch-resize-observer.js @@ -11,6 +11,16 @@ (factory()); }(this, (function () { 'use strict'; +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; /** * @license * Copyright Google Inc. All Rights Reserved. @@ -31,17 +41,26 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { var _this = this; var zones = {}; var currZone = Zone.current; - for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { - var entry = entries_1[_i]; - var zone = entry.target[resizeObserverSymbol]; - if (!zone) { - zone = currZone; + try { + for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { + var entry = entries_1_1.value; + var zone = entry.target[resizeObserverSymbol]; + if (!zone) { + zone = currZone; + } + var zoneEntriesInfo = zones[zone.name]; + if (!zoneEntriesInfo) { + zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; + } + zoneEntriesInfo.entries.push(entry); } - var zoneEntriesInfo = zones[zone.name]; - if (!zoneEntriesInfo) { - zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); } - zoneEntriesInfo.entries.push(entry); + finally { if (e_1) throw e_1.error; } } Object.keys(zones).forEach(function (zoneName) { var zoneEntriesInfo = zones[zoneName]; @@ -52,6 +71,7 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { callback.call(_this, zoneEntriesInfo.entries, observer); } }); + var e_1, _a; }; } return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js index bffe2a10a..4e3ef0583 100644 --- a/dist/zone-patch-resize-observer.min.js +++ b/dist/zone-patch-resize-observer.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("ResizeObserver",function(e,n,r){var t=e.ResizeObserver;if(t){var o=r.symbol("ResizeObserver");r.patchMethod(e,"ResizeObserver",function(e){return function(e,r){var i=r.length>0?r[0]:null;return i&&(r[0]=function(e,r){for(var t=this,u={},a=n.current,c=0,f=e;c0?new t(r[0]):new t}}),r.patchMethod(t.prototype,"observe",function(e){return function(r,t){var i=t.length>0?t[0]:null;if(!i)return e.apply(r,t);var u=r[o];return u||(u=r[o]=[]),u.push(i),i[o]=n.current,e.apply(r,t)}}),r.patchMethod(t.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var i=n[o];if(i)for(var u=0;u=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o=this,a={},c=r.current;try{for(var f=e(n),l=f.next();!l.done;l=f.next()){var v=l.value,p=v.target[i];p||(p=c);var s=a[p.name];s||(a[p.name]=s={entries:[],zone:p}),s.entries.push(v)}}catch(h){d={error:h}}finally{try{l&&!l.done&&(y=f["return"])&&y.call(f)}finally{if(d)throw d.error}}Object.keys(a).forEach(function(e){var n=a[e];n.zone!==r.current?n.zone.run(u,o,[n.entries,t],"ResizeObserver"):u.call(o,n.entries,t)});var d,y}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -916,14 +926,24 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; + var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -934,23 +954,33 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + if (!isThenable(value)) { + value = this.resolve(value); } - }; })(count), reject); - count++; + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } } if (!count) resolve(resolvedValues); return promise; + var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 85de0f422..71a8528ed 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -643,6 +643,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -916,14 +926,24 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; + var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -934,23 +954,33 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + if (!isThenable(value)) { + value = this.resolve(value); } - }; })(count), reject); - count++; + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } } if (!count) resolve(resolvedValues); return promise; + var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone.js b/dist/zone.js index e15c127cf..2cd0134c8 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -643,6 +643,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -916,14 +926,24 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; + var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -934,23 +954,33 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + if (!isThenable(value)) { + value = this.resolve(value); } - }; })(count), reject); - count++; + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } } if (!count) resolve(resolvedValues); return promise; + var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone.min.js b/dist/zone.min.js index b95e78412..7d809e8d1 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=P(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[B("OriginalDelegate")]=t}function f(){if(te)return ne;te=!0;try{var e=W.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ne=!0),ne}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=C(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[B(a)]=k[a],E=k[B(i)]=k[i],S=k[B(s)]=k[s];n&&n.prepend&&(_=k[B(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=oe[e.eventName],n=void 0;t&&(n=t[e.capture?F:q]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=P(a,"onmessage");return s&&s.configurable===!1?(r=I(a),o=a,[M,R,"send","close"].forEach(function(e){r[e]=function(){var t=L.call(arguments);if(e===M||e===R){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!K||Y){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(J){var o=window;w(o,Oe.concat(["messageerror"]),r,C(o)),w(Document.prototype,Oe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Oe,r),w(Element.prototype,Oe,r),w(HTMLElement.prototype,Oe,r),w(HTMLMediaElement.prototype,ye,r),w(HTMLFrameSetElement.prototype,ve.concat(we),r),w(HTMLBodyElement.prototype,ve.concat(we),r),w(HTMLFrameElement.prototype,Te,r),w(HTMLIFrameElement.prototype,Te,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Ee,r);var i=o.Worker;i&&w(i.prototype,ze,r)}w(XMLHttpRequest.prototype,Se,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,Se,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,De,r),w(IDBRequest.prototype,De,r),w(IDBOpenDBRequest.prototype,De,r),w(IDBDatabase.prototype,De,r),w(IDBTransaction.prototype,De,r),w(IDBCursor.prototype,De,r)),n&&w(WebSocket.prototype,Ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((J||Y)&&!P(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=P(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=P(n,t);if(r){j(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return j(n,t,r||{}),a}var i=B("fake");j(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Oe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Pe]&&(n=e(a[r],o),n[Pe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l})("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(I);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==P&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==P&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===P&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,L,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=j(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[N("OriginalDelegate")]=t}function f(){if(ne)return re;ne=!0;try{var e=X.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(re=!0),re}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=I(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[N(a)]=k[a],E=k[N(i)]=k[i],S=k[N(s)]=k[s];n&&n.prepend&&(_=k[N(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=ae[e.eventName],n=void 0;t&&(n=t[e.capture?q:A]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=j(a,"onmessage");return s&&s.configurable===!1?(r=L(a),o=a,[R,x,"send","close"].forEach(function(e){r[e]=function(){var t=M.call(arguments);if(e===R||e===x){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!J||Q){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(Y){var o=window;w(o,Pe.concat(["messageerror"]),r,I(o)),w(Document.prototype,Pe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Pe,r),w(Element.prototype,Pe,r),w(HTMLElement.prototype,Pe,r),w(HTMLMediaElement.prototype,me,r),w(HTMLFrameSetElement.prototype,ge.concat(Ee),r),w(HTMLBodyElement.prototype,ge.concat(Ee),r),w(HTMLFrameElement.prototype,we,r),w(HTMLIFrameElement.prototype,we,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Se,r);var i=o.Worker;i&&w(i.prototype,Oe,r)}w(XMLHttpRequest.prototype,De,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,De,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ze,r),w(IDBRequest.prototype,Ze,r),w(IDBOpenDBRequest.prototype,Ze,r),w(IDBDatabase.prototype,Ze,r),w(IDBTransaction.prototype,Ze,r),w(IDBCursor.prototype,Ze,r)),n&&w(WebSocket.prototype,ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((Y||Q)&&!j(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=j(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=j(n,t);if(r){C(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return C(n,t,r||{}),a}var i=N("fake");C(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Pe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][je]&&(n=e(a[r],o),n[je]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=I();if(e===a)throw new TypeError(L);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==j&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==j&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===j&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,M,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g 3) { + require('./build/test/test-env-setup-jasmine' + args[3]); + } + var JasmineRunner = require('jasmine'); var JasmineRunner = require('jasmine'); var jrunner = new JasmineRunner(); diff --git a/karma-base.conf.js b/karma-base.conf.js index 26ffa771a..0778ebe2e 100644 --- a/karma-base.conf.js +++ b/karma-base.conf.js @@ -29,7 +29,7 @@ module.exports = function (config) { require('karma-sourcemap-loader') ], - preprocessors: { + preprocessors: { '**/*.js': ['sourcemap'] }, diff --git a/karma-dist.conf.js b/karma-dist.conf.js index 73ee8a788..204225c4d 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -14,14 +14,12 @@ module.exports = function(config) { config.files.push('dist/zone.js'); config.files.push('dist/zone-patch-user-media.js'); config.files.push('dist/zone-patch-resize-observer.js'); - config.files.push('dist/async-test.js'); - config.files.push('dist/fake-async-test.js'); config.files.push('dist/long-stack-trace-zone.js'); config.files.push('dist/proxy.js'); config.files.push('dist/sync-test.js'); + config.files.push('dist/async-test.js'); + config.files.push('dist/fake-async-test.js'); config.files.push('dist/task-tracking.js'); - config.files.push('dist/zone-async-testing.js'); - config.files.push('dist/zone-fake-async.js'); config.files.push('dist/zone-patch-promise-test.js'); config.files.push('dist/wtf.js'); config.files.push('build/test/main.js'); diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 1d4912460..4ff7762f7 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -39,6 +39,9 @@ const symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + const enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. const jasmineEnv: any = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(methodName => { @@ -64,41 +67,44 @@ return originalJasmineFn.apply(this, arguments); }; }); - const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); - (jasmine as any)['clock'] = function() { - const clock = originalClockFn.apply(this, arguments); - const originalTick = (clock[symbol('tick')] = clock.tick); - clock.tick = function() { - const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick.apply(this, arguments); - }; - const originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function() { - const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - const dateTime = arguments[0]; - return fakeAsyncZoneSpec.setCurrentRealTime.apply( - fakeAsyncZoneSpec, - dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); - } - return originalMockDate.apply(this, arguments); - }; - ['install', 'uninstall'].forEach(methodName => { - const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function() { - const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; - return; + if (enableClockPatch) { + const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); + (jasmine as any)['clock'] = function() { + const clock = originalClockFn.apply(this, arguments); + const originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function() { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalClockFn.apply(this, arguments); + return originalTick.apply(this, arguments); }; - }); - return clock; - }; + const originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function() { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + const dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply( + fakeAsyncZoneSpec, + dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(methodName => { + const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function() { + const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a @@ -115,29 +121,17 @@ const testProxyZoneSpec = queueRunner.testProxyZoneSpec; const testProxyZone = queueRunner.testProxyZone; let lastDelegate; - if (isClockInstalled) { - const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - const _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - lastDelegate = (testProxyZoneSpec as any).getDelegate(); - (testProxyZoneSpec as any).setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); + if (isClockInstalled && enableClockPatch) { + // auto run a fakeAsync + const fakeAsyncModule = (Zone as any)[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } } - try { - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } else { - return testProxyZone.run(testBody, applyThis); - } - } finally { - if (isClockInstalled) { - const _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - (testProxyZoneSpec as any).setDelegate(lastDelegate); - } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); + } else { + return testProxyZone.run(testBody, applyThis); } } diff --git a/lib/testing/async-testing.ts b/lib/testing/async-testing.ts index e51ca365b..1e3c3ab4a 100644 --- a/lib/testing/async-testing.ts +++ b/lib/testing/async-testing.ts @@ -5,6 +5,7 @@ * 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-spec/async-test'; Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate) => { /** @@ -79,6 +80,7 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate) // it's OK. proxyZoneSpec.setDelegate(previousDelegate); } + (testZoneSpec as any).unPatchPromiseForTest(); currentZone.run(() => { finishCallback(); }); @@ -89,12 +91,14 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate) // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. proxyZoneSpec.setDelegate(previousDelegate); } + (testZoneSpec as any).unPatchPromiseForTest(); currentZone.run(() => { failCallback(error); }); }, 'test'); proxyZoneSpec.setDelegate(testZoneSpec); + (testZoneSpec as any).patchPromiseForTest(); }); return Zone.current.runGuarded(fn, context); } diff --git a/lib/testing/fake-async.ts b/lib/testing/fake-async.ts index 948f80f88..72e934f02 100644 --- a/lib/testing/fake-async.ts +++ b/lib/testing/fake-async.ts @@ -5,6 +5,7 @@ * 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-spec/fake-async-test'; Zone.__load_patch('fakeasync', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const FakeAsyncTestZoneSpec = Zone && (Zone as any)['FakeAsyncTestZoneSpec']; diff --git a/lib/testing/zone-testing.ts b/lib/testing/zone-testing.ts index ea88b7596..51218110e 100644 --- a/lib/testing/zone-testing.ts +++ b/lib/testing/zone-testing.ts @@ -13,6 +13,4 @@ import '../zone-spec/sync-test'; import '../jasmine/jasmine'; import '../zone-spec/async-test'; import '../zone-spec/fake-async-test'; -import './promise-testing'; -import './async-testing'; -import './fake-async'; \ No newline at end of file +import './promise-testing'; \ No newline at end of file diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index 31e178cb0..328585123 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -5,7 +5,8 @@ * 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 _global: any = + typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; class AsyncTestZoneSpec implements ZoneSpec { static symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); @@ -16,14 +17,23 @@ class AsyncTestZoneSpec implements ZoneSpec { runZone = Zone.current; unresolvedChainedPromiseCount = 0; + supportWaitUnresolvedChainedPromise = false; + constructor( private finishCallback: Function, private failCallback: Function, namePrefix: string) { this.name = 'asyncTestZone for ' + namePrefix; this.properties = {'AsyncTestZoneSpec': this}; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; + } + + isUnresolvedChainedPromisePending() { + return this.unresolvedChainedPromiseCount > 0; } _finishCallbackIfDone() { - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(() => { setTimeout(() => { @@ -36,6 +46,9 @@ class AsyncTestZoneSpec implements ZoneSpec { } patchPromiseForTest() { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } const patchPromiseForTest = (Promise as any)[Zone.__symbol__('patchPromiseForTest')]; if (patchPromiseForTest) { patchPromiseForTest(); @@ -43,6 +56,9 @@ class AsyncTestZoneSpec implements ZoneSpec { } unPatchPromiseForTest() { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } const unPatchPromiseForTest = (Promise as any)[Zone.__symbol__('unPatchPromiseForTest')]; if (unPatchPromiseForTest) { unPatchPromiseForTest(); diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 334834acc..8b812dc1c 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -7,15 +7,12 @@ */ if (typeof window !== 'undefined') { (window as any)['__Zone_enable_cross_context_check'] = true; + (window as any)['__zone_symbol__fakeAsyncPatchLock'] = true; } import '../lib/common/to-string'; import '../lib/browser/browser'; import '../lib/browser/webapis-user-media'; -import '../lib/zone-spec/async-test'; -import '../lib/zone-spec/fake-async-test'; -import '../lib/zone-spec/long-stack-trace'; -import '../lib/zone-spec/proxy'; -import '../lib/zone-spec/sync-test'; +import '../lib/testing/zone-testing'; import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/extra/cordova'; diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index b58ffc8c1..fd521eb92 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -7,19 +7,15 @@ */ // Must be loaded before zone loads, so that zone can detect WTF. +if (typeof global !== 'undefined' && + (global as any)['__zone_symbol__fakeAsyncPatchLock'] !== false) { + (global as any)['__zone_symbol__fakeAsyncPatchLock'] = true; +} import './wtf_mock'; import './test_fake_polyfill'; // Setup tests for Zone without microtask support -import '../lib/zone'; -import '../lib/common/promise'; -import '../lib/common/to-string'; -import '../lib/node/node'; -import '../lib/zone-spec/async-test'; -import '../lib/zone-spec/fake-async-test'; -import '../lib/zone-spec/long-stack-trace'; -import '../lib/zone-spec/proxy'; -import '../lib/zone-spec/sync-test'; +import '../lib/testing/zone-testing'; import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/rxjs/rxjs'; diff --git a/test/test-env-setup-jasmine-no-patch-clock.ts b/test/test-env-setup-jasmine-no-patch-clock.ts new file mode 100644 index 000000000..8c06e92c1 --- /dev/null +++ b/test/test-env-setup-jasmine-no-patch-clock.ts @@ -0,0 +1,8 @@ +/** + * @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 + */ +(global as any)['__zone_symbol__fakeAsyncPatchLock'] = false; diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index b5aeb491e..71cc26fcc 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -332,10 +332,16 @@ describe('AsyncTestZoneSpec', function() { } describe('async', () => { - // TODO: @JiaLiPassion, get this feature back when all tests pass - // in angular - xdescribe('non zone aware async task in promise should be detected', () => { + describe('non zone aware async task in promise should be detected', () => { let finished = false; + const _global: any = + typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; + beforeEach(() => { + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] = true; + }); + afterEach(() => { + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] = false; + }); it('should be able to detect non zone aware async task in promise', wrapAsyncTest( () => { diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 340245760..b64bda8fa 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -20,6 +20,13 @@ function supportNode() { (supportNode as any).message = 'support node'; +function supportClock() { + const _global: any = typeof window === 'undefined' ? global : window; + return typeof jasmine.clock === 'function' && _global['__zone_symbol__fakeAsyncPatchLock']; +} + +(supportClock as any).message = 'support patch clock'; + describe('FakeAsyncTestZoneSpec', () => { let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; let testZoneSpec: any; @@ -137,18 +144,18 @@ describe('FakeAsyncTestZoneSpec', () => { }); it('should run queued immediate timer on zero tick', ifEnvSupports('setImmediate', () => { - fakeAsyncTestZone.run(() => { - let ran = false; - setImmediate(() => { - ran = true; - }); + fakeAsyncTestZone.run(() => { + let ran = false; + setImmediate(() => { + ran = true; + }); - expect(ran).toEqual(false); + expect(ran).toEqual(false); - testZoneSpec.tick(); - expect(ran).toEqual(true); - }); - })); + testZoneSpec.tick(); + expect(ran).toEqual(true); + }); + })); it('should run queued timer after sufficient clock ticks', () => { fakeAsyncTestZone.run(() => { @@ -233,16 +240,16 @@ describe('FakeAsyncTestZoneSpec', () => { }); it('should pass arguments to setImmediate', ifEnvSupports('setImmediate', () => { - fakeAsyncTestZone.run(() => { - let value = 'genuine value'; - let id = setImmediate((arg1, arg2) => { - value = arg1 + arg2; - }, 'expected', ' value'); + fakeAsyncTestZone.run(() => { + let value = 'genuine value'; + let id = setImmediate((arg1, arg2) => { + value = arg1 + arg2; + }, 'expected', ' value'); - testZoneSpec.tick(); - expect(value).toEqual('expected value'); - }); - })); + testZoneSpec.tick(); + expect(value).toEqual('expected value'); + }); + })); it('should run periodic timers', () => { fakeAsyncTestZone.run(() => { @@ -909,12 +916,13 @@ describe('FakeAsyncTestZoneSpec', () => { }); describe( - 'fakeAsyncTest should patch jasmine.clock', + 'fakeAsyncTest should work without jasmine.clock', ifEnvSupports( () => { - return typeof jasmine.clock === 'function'; + return !supportClock() && supportNode(); }, () => { + const fakeAsync = (Zone as any)[Zone.__symbol__('fakeAsyncTest')].fakeAsync; beforeEach(() => { jasmine.clock().install(); }); @@ -923,19 +931,12 @@ describe('FakeAsyncTestZoneSpec', () => { jasmine.clock().uninstall(); }); - it('should check date type correctly', () => { + it('should check date type correctly', fakeAsync(() => { const d: any = new Date(); expect(d instanceof Date).toBe(true); - }); + })); - it('should get date diff correctly', () => { - const start = Date.now(); - jasmine.clock().tick(100); - const end = Date.now(); - expect(end - start).toBe(100); - }); - - it('should mock date correctly', () => { + it('should mock date correctly', fakeAsync(() => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); const start = Date.now(); @@ -944,9 +945,9 @@ describe('FakeAsyncTestZoneSpec', () => { const end = Date.now(); expect(end - start).toBe(100); expect(end).toBe(baseTime.getTime() + 100); - }); + })); - it('should handle new Date correctly', () => { + it('should handle new Date correctly', fakeAsync(() => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); const start = new Date(); @@ -955,36 +956,80 @@ describe('FakeAsyncTestZoneSpec', () => { const end = new Date(); expect(end.getTime() - start.getTime()).toBe(100); expect(end.getTime()).toBe(baseTime.getTime() + 100); - }); + })); })); - describe('fakeAsyncTest should patch rxjs scheduler', () => { - let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; - let testZoneSpec: any; - let fakeAsyncTestZone: Zone; + describe('fakeAsyncTest should patch jasmine.clock', ifEnvSupports(supportClock, () => { + beforeEach(() => { + jasmine.clock().install(); + }); - beforeEach(() => { - testZoneSpec = new FakeAsyncTestZoneSpec('name', false); - fakeAsyncTestZone = Zone.current.fork(testZoneSpec); - }); + afterEach(() => { + jasmine.clock().uninstall(); + }); - it('should get date diff correctly', (done) => { - fakeAsyncTestZone.run(() => { - let result = null; - const observable = new Observable((subscribe: any) => { - subscribe.next('hello'); - subscribe.complete(); - }); - observable.delay(1000).subscribe(v => { - result = v; - }); - expect(result).toBe(null); - testZoneSpec.tick(1000); - expect(result).toBe('hello'); - done(); - }); - }); - }); + it('should check date type correctly', () => { + const d: any = new Date(); + expect(d instanceof Date).toBe(true); + }); + + it('should get date diff correctly', () => { + const start = Date.now(); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + }); + + it('should mock date correctly', () => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = Date.now(); + expect(start).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + expect(end).toBe(baseTime.getTime() + 100); + }); + + it('should handle new Date correctly', () => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = new Date(); + expect(start.getTime()).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = new Date(); + expect(end.getTime() - start.getTime()).toBe(100); + expect(end.getTime()).toBe(baseTime.getTime() + 100); + }); + })); + + describe('fakeAsyncTest should patch rxjs scheduler', ifEnvSupports(supportClock, () => { + let FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + let testZoneSpec: any; + let fakeAsyncTestZone: Zone; + + beforeEach(() => { + testZoneSpec = new FakeAsyncTestZoneSpec('name', false); + fakeAsyncTestZone = Zone.current.fork(testZoneSpec); + }); + + it('should get date diff correctly', (done) => { + fakeAsyncTestZone.run(() => { + let result = null; + const observable = new Observable((subscribe: any) => { + subscribe.next('hello'); + subscribe.complete(); + }); + observable.delay(1000).subscribe(v => { + result = v; + }); + expect(result).toBe(null); + testZoneSpec.tick(1000); + expect(result).toBe('hello'); + done(); + }); + }); + })); }); class Log { @@ -1408,4 +1453,4 @@ const {fakeAsync, tick, discardPeriodicTasks, flush, flushMicrotasks} = fakeAsyn expect(state).toEqual('works'); }); }); -} \ No newline at end of file +} From e4755f769150f2be394df7296fed85d12346559b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Mon, 2 Apr 2018 11:31:38 -0700 Subject: [PATCH 042/106] chore: release v0.8.24 --- CHANGELOG.md | 20 ++ dist/async-test.js | 112 +++++++++- dist/fake-async-test.js | 147 +++++++++++++ dist/jasmine-patch.js | 99 ++++----- dist/jasmine-patch.min.js | 2 +- dist/zone-testing-bundle.js | 355 ++++++------------------------ dist/zone-testing-node-bundle.js | 357 ++++++------------------------- dist/zone-testing.js | 355 ++++++------------------------ package.json | 2 +- 9 files changed, 506 insertions(+), 943 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f82b8adc8..424df2188 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ + +## [0.8.24](https://github.com/angular/zone.js/compare/v0.8.23...0.8.24) (2018-04-02) + + +### Bug Fixes + +* **test:** add flag to patch jasmine.clock, move fakeAsync/async into original bundle ([#1067](https://github.com/angular/zone.js/issues/1067)) ([389762c](https://github.com/angular/zone.js/commit/389762c)) + + + + +## [0.8.24](https://github.com/angular/zone.js/compare/v0.8.23...0.8.24) (2018-04-02) + + +### Bug Fixes + +* **test:** add flag to patch jasmine.clock, move fakeAsync/async into original bundle ([#1067](https://github.com/angular/zone.js/issues/1067)) ([389762c](https://github.com/angular/zone.js/commit/389762c)) + + + ## [0.8.23](https://github.com/angular/zone.js/compare/v0.8.22...0.8.23) (2018-04-01) diff --git a/dist/async-test.js b/dist/async-test.js index 35c77f4ef..8c1b26d48 100644 --- a/dist/async-test.js +++ b/dist/async-test.js @@ -18,6 +18,7 @@ * 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 _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { this.finishCallback = finishCallback; @@ -28,12 +29,19 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; this.name = 'asyncTestZone for ' + namePrefix; this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -45,12 +53,18 @@ var AsyncTestZoneSpec = /** @class */ (function () { } }; AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; if (patchPromiseForTest) { patchPromiseForTest(); } }; AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; if (unPatchPromiseForTest) { unPatchPromiseForTest(); @@ -125,4 +139,100 @@ var AsyncTestZoneSpec = /** @class */ (function () { // constructor params. Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; +/** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } +}); + }))); diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index 6fd9aa285..c9893b691 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -480,4 +480,151 @@ Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); +/** + * @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.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); + }))); diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 78cf8115b..2b69773c8 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -50,6 +50,8 @@ // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -74,39 +76,42 @@ return originalJasmineFn.apply(this, arguments); }; }); - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick.apply(this, arguments); - }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); - } - return originalMockDate.apply(this, arguments); - }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; + if (enableClockPatch) { + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalClockFn.apply(this, arguments); + return originalTick.apply(this, arguments); }; - }); - return clock; - }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -120,32 +125,18 @@ var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - var lastDelegate; - if (isClockInstalled) { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - lastDelegate = testProxyZoneSpec.getDelegate(); - testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); + if (isClockInstalled && enableClockPatch) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } } - try { - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } - finally { - if (isClockInstalled) { - var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - testProxyZoneSpec.setDelegate(lastDelegate); - } + else { + return testProxyZone.run(testBody, applyThis); } } /** diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index c9796219e..8af9c4493 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!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 a.run(e,this,arguments)}}function n(e,n,t,o){var r,i=!!jasmine[u("clockInstalled")],s=t.testProxyZoneSpec,c=t.testProxyZone;if(i){var a=Zone.FakeAsyncTestZoneSpec;if(a){var f=new a;r=s.getDelegate(),s.setDelegate(f),f.lockDatePatch()}}try{return o?c.run(e,n,[o]):c.run(e,n)}finally{if(i){var f=s.getDelegate();f&&f.unlockDatePatch(),s.setDelegate(r)}}}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,a=c.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=f[n];f[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=f[e];f[u(e)]=n,f[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=f[e];f[u(e)]=n,f[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments),n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e};var p=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(n)})},n}(p)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return u.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[a("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var s=Zone[Zone.__symbol__("fakeAsyncTest")];s&&"function"==typeof s.fakeAsync&&(e=s.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,u=c.fork(new i("jasmine.describe")),a=Zone.__symbol__,f=r[a("fakeAsyncPatchLock")]===!0,l=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(function(n){var t=l[n];l[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=l[e];l[a(e)]=n,l[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=l[e];l[a(e)]=n,l[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}}),f){var p=jasmine[a("clock")]=jasmine.clock;jasmine.clock=function(){var e=p.apply(this,arguments),n=e[a("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[a("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[a(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[a("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e}}var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); \ No newline at end of file diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index 455698cc1..0da204d74 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -3490,6 +3490,8 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -3514,39 +3516,42 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick.apply(this, arguments); - }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); - } - return originalMockDate.apply(this, arguments); - }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; + if (enableClockPatch) { + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalClockFn.apply(this, arguments); + return originalTick.apply(this, arguments); }; - }); - return clock; - }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -3560,32 +3565,18 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - var lastDelegate; - if (isClockInstalled) { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - lastDelegate = testProxyZoneSpec.getDelegate(); - testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); + if (isClockInstalled && enableClockPatch) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } } - try { - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } - finally { - if (isClockInstalled) { - var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - testProxyZoneSpec.setDelegate(lastDelegate); - } + else { + return testProxyZone.run(testBody, applyThis); } } /** @@ -3704,6 +3695,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; * 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 _global$1 = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { this.finishCallback = finishCallback; @@ -3714,12 +3706,19 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; this.name = 'asyncTestZone for ' + namePrefix; this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global$1[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -3731,12 +3730,18 @@ var AsyncTestZoneSpec = /** @class */ (function () { } }; AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; if (patchPromiseForTest) { patchPromiseForTest(); } }; AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; if (unPatchPromiseForTest) { unPatchPromiseForTest(); @@ -4346,246 +4351,6 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { }; }); -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { - /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ - Zone[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); - } - }); - }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); - }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); - try { - res = fn.apply(this, args); - flushMicrotasks(); - } - finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - } - return _fakeAsyncTestZoneSpec; - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } - /** - * Discard all remaining periodic tasks. - * - * @experimental - */ - function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } - /** - * Flush any pending microtasks. - * - * @experimental - */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 71a8528ed..95125445a 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -2728,6 +2728,8 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -2752,39 +2754,42 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick.apply(this, arguments); - }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); - } - return originalMockDate.apply(this, arguments); - }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); + if (enableClockPatch) { + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); }; - }); - return clock; - }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -2798,32 +2803,18 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - var lastDelegate; - if (isClockInstalled) { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - lastDelegate = testProxyZoneSpec.getDelegate(); - testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); + if (isClockInstalled && enableClockPatch) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } } - try { - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } - finally { - if (isClockInstalled) { - var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - testProxyZoneSpec.setDelegate(lastDelegate); - } + else { + return testProxyZone.run(testBody, applyThis); } } /** @@ -2942,6 +2933,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; * 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 _global$1 = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { this.finishCallback = finishCallback; @@ -2952,12 +2944,19 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; this.name = 'asyncTestZone for ' + namePrefix; this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global$1[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -2969,12 +2968,18 @@ var AsyncTestZoneSpec = /** @class */ (function () { } }; AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; if (patchPromiseForTest) { patchPromiseForTest(); } }; AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; if (unPatchPromiseForTest) { unPatchPromiseForTest(); @@ -3584,246 +3589,6 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { }; }); -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { - /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ - Zone[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); - } - }); - }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); - }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); - try { - res = fn.apply(this, args); - flushMicrotasks(); - } - finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - } - return _fakeAsyncTestZoneSpec; - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } - /** - * Discard all remaining periodic tasks. - * - * @experimental - */ - function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } - /** - * Flush any pending microtasks. - * - * @experimental - */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 5ea69eca1..318f2bc19 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -414,6 +414,8 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; // a `beforeEach` or `it`. var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -438,39 +440,42 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick.apply(this, arguments); - }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); - } - return originalMockDate.apply(this, arguments); - }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; + if (enableClockPatch) { + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + var originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalClockFn.apply(this, arguments); + return originalTick.apply(this, arguments); }; - }); - return clock; - }; + var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments[0]; + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -484,32 +489,18 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - var lastDelegate; - if (isClockInstalled) { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - var _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - lastDelegate = testProxyZoneSpec.getDelegate(); - testProxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); + if (isClockInstalled && enableClockPatch) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } } - try { - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } - finally { - if (isClockInstalled) { - var _fakeAsyncTestZoneSpec = testProxyZoneSpec.getDelegate(); - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - testProxyZoneSpec.setDelegate(lastDelegate); - } + else { + return testProxyZone.run(testBody, applyThis); } } /** @@ -628,6 +619,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; * 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 _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; var AsyncTestZoneSpec = /** @class */ (function () { function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { this.finishCallback = finishCallback; @@ -638,12 +630,19 @@ var AsyncTestZoneSpec = /** @class */ (function () { this._isSync = false; this.runZone = Zone.current; this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; this.name = 'asyncTestZone for ' + namePrefix; this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks)) { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { // We do this because we would like to catch unhandled rejected promises. this.runZone.run(function () { setTimeout(function () { @@ -655,12 +654,18 @@ var AsyncTestZoneSpec = /** @class */ (function () { } }; AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; if (patchPromiseForTest) { patchPromiseForTest(); } }; AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; if (unPatchPromiseForTest) { unPatchPromiseForTest(); @@ -1270,246 +1275,6 @@ Zone.__load_patch('promisefortest', function (global, Zone, api) { }; }); -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { - /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ - Zone[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); - } - }); - }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); - }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); - try { - res = fn.apply(this, args); - flushMicrotasks(); - } - finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - } - return _fakeAsyncTestZoneSpec; - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } - /** - * Discard all remaining periodic tasks. - * - * @experimental - */ - function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } - /** - * Flush any pending microtasks. - * - * @experimental - */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/package.json b/package.json index 98d1b21ca..80f393ef0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zone.js", - "version": "0.8.23", + "version": "0.8.24", "description": "Zones for JavaScript", "main": "dist/zone-node.js", "browser": "dist/zone.js", From 3bdfdad80539f2b2250f0a7f2efc5a516926f268 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 3 Apr 2018 12:31:33 +0900 Subject: [PATCH 043/106] fix(test): add async/fakeAsync into zone-testing bundle (#1068) --- lib/testing/zone-testing.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/testing/zone-testing.ts b/lib/testing/zone-testing.ts index 51218110e..c5ebd1ad3 100644 --- a/lib/testing/zone-testing.ts +++ b/lib/testing/zone-testing.ts @@ -11,6 +11,6 @@ import '../zone-spec/long-stack-trace'; import '../zone-spec/proxy'; import '../zone-spec/sync-test'; import '../jasmine/jasmine'; -import '../zone-spec/async-test'; -import '../zone-spec/fake-async-test'; +import './async-testing'; +import './fake-async'; import './promise-testing'; \ No newline at end of file From a86bddb21112383087f52d18b85b8595a2761092 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 3 Apr 2018 18:07:07 -0700 Subject: [PATCH 044/106] chore: release v0.8.25 --- CHANGELOG.md | 10 + dist/zone-mix.js | 64 ++---- dist/zone-node.js | 64 ++---- dist/zone-patch-resize-observer.js | 38 +-- dist/zone-patch-resize-observer.min.js | 2 +- dist/zone-testing-bundle.js | 307 +++++++++++++++++++++---- dist/zone-testing-node-bundle.js | 307 +++++++++++++++++++++---- dist/zone-testing.js | 243 +++++++++++++++++++ dist/zone.js | 64 ++---- dist/zone.min.js | 4 +- package.json | 2 +- 11 files changed, 837 insertions(+), 268 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 424df2188..d7bf54d21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [0.8.25](https://github.com/angular/zone.js/compare/v0.8.24...0.8.25) (2018-04-04) + + +### Bug Fixes + +* **test:** add async/fakeAsync into zone-testing bundle ([#1068](https://github.com/angular/zone.js/issues/1068)) ([3bdfdad](https://github.com/angular/zone.js/commit/3bdfdad)) + + + ## [0.8.24](https://github.com/angular/zone.js/compare/v0.8.23...0.8.24) (2018-04-02) diff --git a/dist/zone-mix.js b/dist/zone-mix.js index 4b59965e3..23a6e068f 100644 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-node.js b/dist/zone-node.js index dc55a8875..c857c893c 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone-patch-resize-observer.js b/dist/zone-patch-resize-observer.js index e80c32588..b0cabc088 100644 --- a/dist/zone-patch-resize-observer.js +++ b/dist/zone-patch-resize-observer.js @@ -11,16 +11,6 @@ (factory()); }(this, (function () { 'use strict'; -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; /** * @license * Copyright Google Inc. All Rights Reserved. @@ -41,26 +31,17 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { var _this = this; var zones = {}; var currZone = Zone.current; - try { - for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { - var entry = entries_1_1.value; - var zone = entry.target[resizeObserverSymbol]; - if (!zone) { - zone = currZone; - } - var zoneEntriesInfo = zones[zone.name]; - if (!zoneEntriesInfo) { - zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; - } - zoneEntriesInfo.entries.push(entry); + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; + var zone = entry.target[resizeObserverSymbol]; + if (!zone) { + zone = currZone; } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); + var zoneEntriesInfo = zones[zone.name]; + if (!zoneEntriesInfo) { + zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; } - finally { if (e_1) throw e_1.error; } + zoneEntriesInfo.entries.push(entry); } Object.keys(zones).forEach(function (zoneName) { var zoneEntriesInfo = zones[zoneName]; @@ -71,7 +52,6 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { callback.call(_this, zoneEntriesInfo.entries, observer); } }); - var e_1, _a; }; } return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js index 4e3ef0583..bffe2a10a 100644 --- a/dist/zone-patch-resize-observer.min.js +++ b/dist/zone-patch-resize-observer.min.js @@ -1 +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){var n="function"==typeof Symbol&&e[Symbol.iterator],r=0;return n?n.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o=this,a={},c=r.current;try{for(var f=e(n),l=f.next();!l.done;l=f.next()){var v=l.value,p=v.target[i];p||(p=c);var s=a[p.name];s||(a[p.name]=s={entries:[],zone:p}),s.entries.push(v)}}catch(h){d={error:h}}finally{try{l&&!l.done&&(y=f["return"])&&y.call(f)}finally{if(d)throw d.error}}Object.keys(a).forEach(function(e){var n=a[e];n.zone!==r.current?n.zone.run(u,o,[n.entries,t],"ResizeObserver"):u.call(o,n.entries,t)});var d,y}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u0?r[0]:null;return i&&(r[0]=function(e,r){for(var t=this,u={},a=n.current,c=0,f=e;c0?new t(r[0]):new t}}),r.patchMethod(t.prototype,"observe",function(e){return function(r,t){var i=t.length>0?t[0]:null;if(!i)return e.apply(r,t);var u=r[o];return u||(u=r[o]=[]),u.push(i),i[o]=n.current,e.apply(r,t)}}),r.patchMethod(t.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var i=n[o];if(i)for(var u=0;u= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); + } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); @@ -3816,6 +3786,102 @@ var AsyncTestZoneSpec = /** @class */ (function () { // constructor params. Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; +/** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -4285,6 +4351,153 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); +/** + * @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.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); + /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 95125445a..5460dfc8c 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); - } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); @@ -3054,6 +3024,102 @@ var AsyncTestZoneSpec = /** @class */ (function () { // constructor params. Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; +/** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -3523,6 +3589,153 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); +/** + * @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.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); + /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 318f2bc19..06e1596c4 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -740,6 +740,102 @@ var AsyncTestZoneSpec = /** @class */ (function () { // constructor params. Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; +/** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1209,6 +1305,153 @@ Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); +/** + * @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.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); + /** * @license * Copyright Google Inc. All Rights Reserved. diff --git a/dist/zone.js b/dist/zone.js index 2cd0134c8..e15c127cf 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -643,16 +643,6 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -926,24 +916,14 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } - finally { if (e_1) throw e_1.error; } + value.then(onResolve, onReject); } return promise; - var e_1, _a; }; ZoneAwarePromise.all = function (values) { var resolve; @@ -954,33 +934,23 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }); var count = 0; var resolvedValues = []; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then((function (index) { return function (value) { + resolvedValues[index] = value; + count--; + if (!count) { + resolve(resolvedValues); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - }; })(count), reject); - count++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + }; })(count), reject); + count++; } if (!count) resolve(resolvedValues); return promise; - var e_2, _a; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); diff --git a/dist/zone.min.js b/dist/zone.min.js index 7d809e8d1..b95e78412 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=j(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[N("OriginalDelegate")]=t}function f(){if(ne)return re;ne=!0;try{var e=X.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(re=!0),re}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=I(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[N(a)]=k[a],E=k[N(i)]=k[i],S=k[N(s)]=k[s];n&&n.prepend&&(_=k[N(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=ae[e.eventName],n=void 0;t&&(n=t[e.capture?q:A]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=j(a,"onmessage");return s&&s.configurable===!1?(r=L(a),o=a,[R,x,"send","close"].forEach(function(e){r[e]=function(){var t=M.call(arguments);if(e===R||e===x){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!J||Q){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(Y){var o=window;w(o,Pe.concat(["messageerror"]),r,I(o)),w(Document.prototype,Pe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Pe,r),w(Element.prototype,Pe,r),w(HTMLElement.prototype,Pe,r),w(HTMLMediaElement.prototype,me,r),w(HTMLFrameSetElement.prototype,ge.concat(Ee),r),w(HTMLBodyElement.prototype,ge.concat(Ee),r),w(HTMLFrameElement.prototype,we,r),w(HTMLIFrameElement.prototype,we,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Se,r);var i=o.Worker;i&&w(i.prototype,Oe,r)}w(XMLHttpRequest.prototype,De,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,De,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,Ze,r),w(IDBRequest.prototype,Ze,r),w(IDBOpenDBRequest.prototype,Ze,r),w(IDBDatabase.prototype,Ze,r),w(IDBTransaction.prototype,Ze,r),w(IDBCursor.prototype,Ze,r)),n&&w(WebSocket.prototype,ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((Y||Q)&&!j(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=j(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=j(n,t);if(r){C(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return C(n,t,r||{}),a}var i=N("fake");C(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Pe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][je]&&(n=e(a[r],o),n[je]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=I();if(e===a)throw new TypeError(L);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==j&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==j&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===j&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,M,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=P(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[B("OriginalDelegate")]=t}function f(){if(te)return ne;te=!0;try{var e=W.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ne=!0),ne}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=C(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[B(a)]=k[a],E=k[B(i)]=k[i],S=k[B(s)]=k[s];n&&n.prepend&&(_=k[B(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=oe[e.eventName],n=void 0;t&&(n=t[e.capture?F:q]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=P(a,"onmessage");return s&&s.configurable===!1?(r=I(a),o=a,[M,R,"send","close"].forEach(function(e){r[e]=function(){var t=L.call(arguments);if(e===M||e===R){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!K||Y){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(J){var o=window;w(o,Oe.concat(["messageerror"]),r,C(o)),w(Document.prototype,Oe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Oe,r),w(Element.prototype,Oe,r),w(HTMLElement.prototype,Oe,r),w(HTMLMediaElement.prototype,ye,r),w(HTMLFrameSetElement.prototype,ve.concat(we),r),w(HTMLBodyElement.prototype,ve.concat(we),r),w(HTMLFrameElement.prototype,Te,r),w(HTMLIFrameElement.prototype,Te,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Ee,r);var i=o.Worker;i&&w(i.prototype,ze,r)}w(XMLHttpRequest.prototype,Se,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,Se,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,De,r),w(IDBRequest.prototype,De,r),w(IDBOpenDBRequest.prototype,De,r),w(IDBDatabase.prototype,De,r),w(IDBTransaction.prototype,De,r),w(IDBCursor.prototype,De,r)),n&&w(WebSocket.prototype,Ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((J||Y)&&!P(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=P(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=P(n,t);if(r){j(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return j(n,t,r||{}),a}var i=B("fake");j(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Oe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Pe]&&(n=e(a[r],o),n[Pe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l})("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(I);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==P&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==P&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===P&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,L,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g Date: Sat, 7 Apr 2018 00:52:27 +0900 Subject: [PATCH 045/106] fix(test): fix #1069, FakeDate should handle constructor parameter (#1070) --- lib/jasmine/jasmine.ts | 45 ++++--- lib/zone-spec/fake-async-test.ts | 48 ++++++-- test/test-env-setup-mocha.ts | 16 ++- test/zone-spec/fake-async-test.spec.ts | 155 ++++++++++++++++++++++++- 4 files changed, 228 insertions(+), 36 deletions(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 4ff7762f7..5d279ab36 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -67,10 +67,14 @@ return originalJasmineFn.apply(this, arguments); }; }); - if (enableClockPatch) { - const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); - (jasmine as any)['clock'] = function() { - const clock = originalClockFn.apply(this, arguments); + + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); + (jasmine as any)['clock'] = function() { + const clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); const originalTick = (clock[symbol('tick')] = clock.tick); clock.tick = function() { const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); @@ -83,7 +87,7 @@ clock.mockDate = function() { const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { - const dateTime = arguments[0]; + const dateTime = arguments.length > 0 ? arguments[0] : new Date(); return fakeAsyncZoneSpec.setCurrentRealTime.apply( fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : @@ -91,20 +95,23 @@ } return originalMockDate.apply(this, arguments); }; - ['install', 'uninstall'].forEach(methodName => { - const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function() { - const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - return clock; - }; - } + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableClockPatch) { + ['install', 'uninstall'].forEach(methodName => { + const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function() { + const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index c85205047..278cc1f52 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -32,13 +32,14 @@ const OriginalDate = global.Date; class FakeDate { constructor() { - const d = new OriginalDate(); - d.setTime(global.Date.now()); - return d; - } - - static UTC() { - return OriginalDate.UTC(); + if (arguments.length === 0) { + const d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } else { + const args = Array.prototype.slice.call(arguments); + return new OriginalDate(...args); + } } static now() { @@ -48,12 +49,19 @@ } return OriginalDate.now.apply(this, arguments); } - - static parse() { - return OriginalDate.parse(); - } } + (FakeDate as any).UTC = OriginalDate.UTC; + (FakeDate as any).parse = OriginalDate.parse; + + // keep a reference for zone patched timer function + const timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; + class Scheduler { // Next scheduler id. public nextId: number = 1; @@ -63,7 +71,7 @@ // Current simulated time in millis. private _currentTime: number = 0; // Current real time in millis. - private _currentRealTime: number = Date.now(); + private _currentRealTime: number = OriginalDate.now(); constructor() {} @@ -341,6 +349,11 @@ } global['Date'] = FakeDate; FakeDate.prototype = OriginalDate.prototype; + + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); } static resetDate() { @@ -349,6 +362,17 @@ } } + static checkTimerPatch() { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + } + lockDatePatch() { this.patchDateLocked = true; FakeAsyncTestZoneSpec.patchDate(); diff --git a/test/test-env-setup-mocha.ts b/test/test-env-setup-mocha.ts index bf2129452..96058a0c4 100644 --- a/test/test-env-setup-mocha.ts +++ b/test/test-env-setup-mocha.ts @@ -81,6 +81,11 @@ declare const global: any; throw new Error(`Expected ${expected} to be greater than ${actual}`); } }, + toBeLessThan: function(actual: number) { + if (expected >= actual) { + throw new Error(`Expected ${expected} to be lesser than ${actual}`); + } + }, toBeDefined: function() { if (!expected) { throw new Error(`Expected ${expected} to be defined`); @@ -109,6 +114,11 @@ declare const global: any; throw new Error(`Expected ${expected} to be truthy`); } }, + toBeFalsy: function(actual: any) { + if (!!actual) { + throw new Error(`Expected ${actual} to be falsy`); + } + }, toContain: function(actual: any) { if (expected.indexOf(actual) === -1) { throw new Error(`Expected ${expected} to contain ${actual}`); @@ -159,7 +169,11 @@ declare const global: any; if (expected > actual) { throw new Error(`Expected ${expected} not to be greater than ${actual}`); } - + }, + toBeLessThan: function(actual: number) { + if (expected < actual) { + throw new Error(`Expected ${expected} not to be lesser than ${actual}`); + } }, toHaveBeenCalledWith: function(params: any[]) { if (!eq(expected.callArgs, params)) { diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index b64bda8fa..f92f1b96b 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -913,17 +913,51 @@ describe('FakeAsyncTestZoneSpec', () => { expect(d instanceof Date).toBe(true); }); }); + + it('should new Date with parameter correctly', () => { + fakeAsyncTestZone.run(() => { + const d: Date = new Date(0); + expect(d.getFullYear()).toBeLessThan(1971); + const d1: Date = new Date('December 17, 1995 03:24:00'); + expect(d1.getFullYear()).toEqual(1995); + const d2: Date = new Date(1995, 11, 17, 3, 24, 0); + expect(d2.getFullYear()).toEqual(1995); + + d2.setFullYear(1985); + expect(isNaN(d2.getTime())).toBeFalsy(); + expect(d2.getFullYear()).toBe(1985); + expect(d2.getMonth()).toBe(11); + expect(d2.getDate()).toBe(17); + }); + }); + + it('should get Date.UTC() correctly', () => { + fakeAsyncTestZone.run(() => { + const utcDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0)); + expect(utcDate.getFullYear()).toBe(1996); + }); + }); + + it('should call Date.parse() correctly', () => { + fakeAsyncTestZone.run(() => { + const unixTimeZero = Date.parse('01 Jan 1970 00:00:00 GMT'); + expect(unixTimeZero).toBe(0); + }); + }); + }); describe( - 'fakeAsyncTest should work without jasmine.clock', + 'fakeAsyncTest should work without patch jasmine.clock', ifEnvSupports( () => { return !supportClock() && supportNode(); }, () => { const fakeAsync = (Zone as any)[Zone.__symbol__('fakeAsyncTest')].fakeAsync; + let spy: any; beforeEach(() => { + spy = jasmine.createSpy('timer'); jasmine.clock().install(); }); @@ -932,11 +966,44 @@ describe('FakeAsyncTestZoneSpec', () => { }); it('should check date type correctly', fakeAsync(() => { + const d: any = new Date(); + expect(d instanceof Date).toBe(true); + })); + + it('should check date type correctly without fakeAsync', () => { const d: any = new Date(); expect(d instanceof Date).toBe(true); - })); + }); + + it('should tick correctly', fakeAsync(() => { + jasmine.clock().mockDate(); + const start = Date.now(); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + })); + + it('should tick correctly without fakeAsync', () => { + jasmine.clock().mockDate(); + const start = Date.now(); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + }); it('should mock date correctly', fakeAsync(() => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = Date.now(); + expect(start).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + expect(end).toBe(baseTime.getTime() + 100); + expect(new Date().getFullYear()).toEqual(2013); + })); + + it('should mock date correctly without fakeAsync', () => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); const start = Date.now(); @@ -945,9 +1012,21 @@ describe('FakeAsyncTestZoneSpec', () => { const end = Date.now(); expect(end - start).toBe(100); expect(end).toBe(baseTime.getTime() + 100); - })); + expect(new Date().getFullYear()).toEqual(2013); + }); it('should handle new Date correctly', fakeAsync(() => { + const baseTime = new Date(2013, 9, 23); + jasmine.clock().mockDate(baseTime); + const start = new Date(); + expect(start.getTime()).toBe(baseTime.getTime()); + jasmine.clock().tick(100); + const end = new Date(); + expect(end.getTime() - start.getTime()).toBe(100); + expect(end.getTime()).toBe(baseTime.getTime() + 100); + })); + + it('should handle new Date correctly without fakeAsync', () => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); const start = new Date(); @@ -956,11 +1035,27 @@ describe('FakeAsyncTestZoneSpec', () => { const end = new Date(); expect(end.getTime() - start.getTime()).toBe(100); expect(end.getTime()).toBe(baseTime.getTime() + 100); - })); + }); + + it('should handle setTimeout correctly', fakeAsync(() => { + setTimeout(spy, 100); + expect(spy).not.toHaveBeenCalled(); + jasmine.clock().tick(100); + expect(spy).toHaveBeenCalled(); + })); + + it('should handle setTimeout correctly without fakeAsync', () => { + setTimeout(spy, 100); + expect(spy).not.toHaveBeenCalled(); + jasmine.clock().tick(100); + expect(spy).toHaveBeenCalled(); + }); })); describe('fakeAsyncTest should patch jasmine.clock', ifEnvSupports(supportClock, () => { + let spy: any; beforeEach(() => { + spy = jasmine.createSpy('timer'); jasmine.clock().install(); }); @@ -980,6 +1075,13 @@ describe('FakeAsyncTestZoneSpec', () => { expect(end - start).toBe(100); }); + it('should tick correctly', () => { + const start = Date.now(); + jasmine.clock().tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + }); + it('should mock date correctly', () => { const baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); @@ -1001,6 +1103,13 @@ describe('FakeAsyncTestZoneSpec', () => { expect(end.getTime() - start.getTime()).toBe(100); expect(end.getTime()).toBe(baseTime.getTime() + 100); }); + + it('should handle setTimeout correctly', () => { + setTimeout(spy, 100); + expect(spy).not.toHaveBeenCalled(); + jasmine.clock().tick(100); + expect(spy).toHaveBeenCalled(); + }); })); describe('fakeAsyncTest should patch rxjs scheduler', ifEnvSupports(supportClock, () => { @@ -1427,6 +1536,44 @@ const {fakeAsync, tick, discardPeriodicTasks, flush, flushMicrotasks} = fakeAsyn expect(zoneInTest1).toBe(zoneInBeforeEach); })); }); + + describe('fakeAsync should work with Date', () => { + it('should get date diff correctly', fakeAsync(() => { + const start = Date.now(); + tick(100); + const end = Date.now(); + expect(end - start).toBe(100); + })); + + it('should check date type correctly', fakeAsync(() => { + const d: any = new Date(); + expect(d instanceof Date).toBe(true); + })); + + it('should new Date with parameter correctly', fakeAsync(() => { + const d: Date = new Date(0); + expect(d.getFullYear()).toBeLessThan(1971); + const d1: Date = new Date('December 17, 1995 03:24:00'); + expect(d1.getFullYear()).toEqual(1995); + const d2: Date = new Date(1995, 11, 17, 3, 24, 0); + expect(isNaN(d2.getTime())).toBeFalsy(); + expect(d2.getFullYear()).toEqual(1995); + d2.setFullYear(1985); + expect(d2.getFullYear()).toBe(1985); + expect(d2.getMonth()).toBe(11); + expect(d2.getDate()).toBe(17); + })); + + it('should get Date.UTC() correctly', fakeAsync(() => { + const utcDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0)); + expect(utcDate.getFullYear()).toBe(1996); + })); + + it('should call Date.parse() correctly', fakeAsync(() => { + const unixTimeZero = Date.parse('01 Jan 1970 00:00:00 GMT'); + expect(unixTimeZero).toBe(0); + })); + }); }); describe('ProxyZone', () => { From 1ba851989ccb6907df49bba37ee24ab60adf13a9 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 7 Apr 2018 20:32:28 -0700 Subject: [PATCH 046/106] chare: release v0.8.26 --- CHANGELOG.md | 10 +++ dist/fake-async-test.js | 63 +++++++++++--- dist/jasmine-patch.js | 52 ++++++----- dist/jasmine-patch.min.js | 2 +- dist/zone-patch-resize-observer.js | 38 ++++++-- dist/zone-patch-resize-observer.min.js | 2 +- dist/zone-testing-bundle.js | 115 ++++++++++++++++++------- dist/zone-testing-node-bundle.js | 115 ++++++++++++++++++------- dist/zone-testing.js | 115 ++++++++++++++++++------- package.json | 2 +- 10 files changed, 370 insertions(+), 144 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7bf54d21..a8d1cb7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [0.8.26](https://github.com/angular/zone.js/compare/v0.8.25...0.8.26) (2018-04-08) + + +### Bug Fixes + +* **test:** fix [#1069](https://github.com/angular/zone.js/issues/1069), FakeDate should handle constructor parameter ([#1070](https://github.com/angular/zone.js/issues/1070)) ([b3fdd7e](https://github.com/angular/zone.js/commit/b3fdd7e)) + + + ## [0.8.25](https://github.com/angular/zone.js/compare/v0.8.24...0.8.25) (2018-04-04) diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index c9893b691..9bc27674e 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -18,17 +18,40 @@ * 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 __read = (undefined && undefined.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (undefined && undefined.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; (function (global) { var OriginalDate = global.Date; var FakeDate = /** @class */ (function () { function FakeDate() { - var d = new OriginalDate(); - d.setTime(global.Date.now()); - return d; + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); + } } - FakeDate.UTC = function () { - return OriginalDate.UTC(); - }; FakeDate.now = function () { var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncTestZoneSpec) { @@ -36,11 +59,17 @@ } return OriginalDate.now.apply(this, arguments); }; - FakeDate.parse = function () { - return OriginalDate.parse(); - }; return FakeDate; }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. @@ -50,7 +79,7 @@ // Current simulated time in millis. this._currentTime = 0; // Current real time in millis. - this._currentRealTime = Date.now(); + this._currentRealTime = OriginalDate.now(); } Scheduler.prototype.getCurrentTime = function () { return this._currentTime; @@ -309,12 +338,26 @@ } global['Date'] = FakeDate; FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { this.patchDateLocked = true; FakeAsyncTestZoneSpec.patchDate(); diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 2b69773c8..33e809a72 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -76,42 +76,48 @@ return originalJasmineFn.apply(this, arguments); }; }); - if (enableClockPatch) { - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); clock.tick = function () { var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalTick.apply(this, arguments); + return originalTick_1.apply(this, arguments); }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); clock.mockDate = function () { var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); } - return originalMockDate.apply(this, arguments); + return originalMockDate_1.apply(this, arguments); }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - return clock; - }; - } + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableClockPatch) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index 8af9c4493..e78cb748a 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!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 u.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[a("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var s=Zone[Zone.__symbol__("fakeAsyncTest")];s&&"function"==typeof s.fakeAsync&&(e=s.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,s=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!s)throw new Error("Missing: ProxyZoneSpec");var c=Zone.current,u=c.fork(new i("jasmine.describe")),a=Zone.__symbol__,f=r[a("fakeAsyncPatchLock")]===!0,l=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(function(n){var t=l[n];l[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=l[e];l[a(e)]=n,l[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=l[e];l[a(e)]=n,l[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}}),f){var p=jasmine[a("clock")]=jasmine.clock;jasmine.clock=function(){var e=p.apply(this,arguments),n=e[a("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[a("mockDate")]=e.mockDate;return e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments[0];return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},["install","uninstall"].forEach(function(n){var t=e[a(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[a("clockInstalled")]="install"===n):t.apply(this,arguments)}}),e}}var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,c.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var s=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}s&&s.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===c){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new s,this.testProxyZone=c.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return a.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[u("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,c=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!c)throw new Error("Missing: ProxyZoneSpec");var s=Zone.current,a=s.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=r[u("fakeAsyncPatchLock")]===!0,p=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=p[n];p[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=p[e];p[u(e)]=n,p[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=p[e];p[u(e)]=n,p[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments);if(!e[u("patched")]){e[u("patched")]=u("patched");var n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},f&&["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}})}return e};var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,s.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}c&&c.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===s){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new c,this.testProxyZone=s.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); \ No newline at end of file diff --git a/dist/zone-patch-resize-observer.js b/dist/zone-patch-resize-observer.js index b0cabc088..e80c32588 100644 --- a/dist/zone-patch-resize-observer.js +++ b/dist/zone-patch-resize-observer.js @@ -11,6 +11,16 @@ (factory()); }(this, (function () { 'use strict'; +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; /** * @license * Copyright Google Inc. All Rights Reserved. @@ -31,17 +41,26 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { var _this = this; var zones = {}; var currZone = Zone.current; - for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { - var entry = entries_1[_i]; - var zone = entry.target[resizeObserverSymbol]; - if (!zone) { - zone = currZone; + try { + for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { + var entry = entries_1_1.value; + var zone = entry.target[resizeObserverSymbol]; + if (!zone) { + zone = currZone; + } + var zoneEntriesInfo = zones[zone.name]; + if (!zoneEntriesInfo) { + zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; + } + zoneEntriesInfo.entries.push(entry); } - var zoneEntriesInfo = zones[zone.name]; - if (!zoneEntriesInfo) { - zones[zone.name] = zoneEntriesInfo = { entries: [], zone: zone }; + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); } - zoneEntriesInfo.entries.push(entry); + finally { if (e_1) throw e_1.error; } } Object.keys(zones).forEach(function (zoneName) { var zoneEntriesInfo = zones[zoneName]; @@ -52,6 +71,7 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { callback.call(_this, zoneEntriesInfo.entries, observer); } }); + var e_1, _a; }; } return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js index bffe2a10a..4e3ef0583 100644 --- a/dist/zone-patch-resize-observer.min.js +++ b/dist/zone-patch-resize-observer.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";Zone.__load_patch("ResizeObserver",function(e,n,r){var t=e.ResizeObserver;if(t){var o=r.symbol("ResizeObserver");r.patchMethod(e,"ResizeObserver",function(e){return function(e,r){var i=r.length>0?r[0]:null;return i&&(r[0]=function(e,r){for(var t=this,u={},a=n.current,c=0,f=e;c0?new t(r[0]):new t}}),r.patchMethod(t.prototype,"observe",function(e){return function(r,t){var i=t.length>0?t[0]:null;if(!i)return e.apply(r,t);var u=r[o];return u||(u=r[o]=[]),u.push(i),i[o]=n.current,e.apply(r,t)}}),r.patchMethod(t.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var i=n[o];if(i)for(var u=0;u=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o=this,a={},c=r.current;try{for(var f=e(n),l=f.next();!l.done;l=f.next()){var v=l.value,p=v.target[i];p||(p=c);var s=a[p.name];s||(a[p.name]=s={entries:[],zone:p}),s.entries.push(v)}}catch(h){d={error:h}}finally{try{l&&!l.done&&(y=f["return"])&&y.call(f)}finally{if(d)throw d.error}}Object.keys(a).forEach(function(e){var n=a[e];n.zone!==r.current?n.zone.run(u,o,[n.entries,t],"ResizeObserver"):u.call(o,n.entries,t)});var d,y}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u 0 ? arguments[0] : new Date(); return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); } - return originalMockDate.apply(this, arguments); + return originalMockDate_1.apply(this, arguments); }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - return clock; - }; - } + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableClockPatch) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -3889,17 +3895,40 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { * 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 __read = (undefined && undefined.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (undefined && undefined.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; (function (global) { var OriginalDate = global.Date; var FakeDate = /** @class */ (function () { function FakeDate() { - var d = new OriginalDate(); - d.setTime(global.Date.now()); - return d; + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); + } } - FakeDate.UTC = function () { - return OriginalDate.UTC(); - }; FakeDate.now = function () { var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncTestZoneSpec) { @@ -3907,11 +3936,17 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { } return OriginalDate.now.apply(this, arguments); }; - FakeDate.parse = function () { - return OriginalDate.parse(); - }; return FakeDate; }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. @@ -3921,7 +3956,7 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { // Current simulated time in millis. this._currentTime = 0; // Current real time in millis. - this._currentRealTime = Date.now(); + this._currentRealTime = OriginalDate.now(); } Scheduler.prototype.getCurrentTime = function () { return this._currentTime; @@ -4180,12 +4215,26 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { } global['Date'] = FakeDate; FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { this.patchDateLocked = true; FakeAsyncTestZoneSpec.patchDate(); diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 5460dfc8c..a95fbf996 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -2724,42 +2724,48 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - if (enableClockPatch) { - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); clock.tick = function () { var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalTick.apply(this, arguments); + return originalTick_1.apply(this, arguments); }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); clock.mockDate = function () { var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); } - return originalMockDate.apply(this, arguments); + return originalMockDate_1.apply(this, arguments); }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - return clock; - }; - } + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableClockPatch) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -3127,17 +3133,40 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { * 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 __read = (undefined && undefined.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (undefined && undefined.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; (function (global) { var OriginalDate = global.Date; var FakeDate = /** @class */ (function () { function FakeDate() { - var d = new OriginalDate(); - d.setTime(global.Date.now()); - return d; + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); + } } - FakeDate.UTC = function () { - return OriginalDate.UTC(); - }; FakeDate.now = function () { var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncTestZoneSpec) { @@ -3145,11 +3174,17 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { } return OriginalDate.now.apply(this, arguments); }; - FakeDate.parse = function () { - return OriginalDate.parse(); - }; return FakeDate; }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. @@ -3159,7 +3194,7 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { // Current simulated time in millis. this._currentTime = 0; // Current real time in millis. - this._currentRealTime = Date.now(); + this._currentRealTime = OriginalDate.now(); } Scheduler.prototype.getCurrentTime = function () { return this._currentTime; @@ -3418,12 +3453,26 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { } global['Date'] = FakeDate; FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { this.patchDateLocked = true; FakeAsyncTestZoneSpec.patchDate(); diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 06e1596c4..aa2bbb2f2 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -440,42 +440,48 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - if (enableClockPatch) { - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - var originalTick = (clock[symbol('tick')] = clock.tick); + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); clock.tick = function () { var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return originalTick.apply(this, arguments); + return originalTick_1.apply(this, arguments); }; - var originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); clock.mockDate = function () { var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncZoneSpec) { - var dateTime = arguments[0]; + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : arguments); } - return originalMockDate.apply(this, arguments); + return originalMockDate_1.apply(this, arguments); }; - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - return clock; - }; - } + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableClockPatch) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -843,17 +849,40 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { * 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 __read = (undefined && undefined.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (undefined && undefined.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; (function (global) { var OriginalDate = global.Date; var FakeDate = /** @class */ (function () { function FakeDate() { - var d = new OriginalDate(); - d.setTime(global.Date.now()); - return d; + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); + } } - FakeDate.UTC = function () { - return OriginalDate.UTC(); - }; FakeDate.now = function () { var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); if (fakeAsyncTestZoneSpec) { @@ -861,11 +890,17 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { } return OriginalDate.now.apply(this, arguments); }; - FakeDate.parse = function () { - return OriginalDate.parse(); - }; return FakeDate; }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; var Scheduler = /** @class */ (function () { function Scheduler() { // Next scheduler id. @@ -875,7 +910,7 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { // Current simulated time in millis. this._currentTime = 0; // Current real time in millis. - this._currentRealTime = Date.now(); + this._currentRealTime = OriginalDate.now(); } Scheduler.prototype.getCurrentTime = function () { return this._currentTime; @@ -1134,12 +1169,26 @@ Zone.__load_patch('asynctest', function (global, Zone, api) { } global['Date'] = FakeDate; FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; FakeAsyncTestZoneSpec.resetDate = function () { if (global['Date'] === FakeDate) { global['Date'] = OriginalDate; } }; + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { this.patchDateLocked = true; FakeAsyncTestZoneSpec.patchDate(); diff --git a/package.json b/package.json index ee5c972e9..b93ffc01b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zone.js", - "version": "0.8.25", + "version": "0.8.26", "description": "Zones for JavaScript", "main": "dist/zone-node.js", "browser": "dist/zone.js", From 915042d065bb0f870913fdb0132633e1ced48cb0 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Sun, 11 Mar 2018 01:18:39 +0900 Subject: [PATCH 047/106] fix(tsc): tsconfig.json strict:true --- lib/browser/browser.ts | 22 +- lib/browser/define-property.ts | 4 +- lib/browser/property-descriptor.ts | 2 +- lib/common/error-rewrite.ts | 8 +- lib/common/events.ts | 2 +- lib/common/promise.ts | 30 +- lib/common/timers.ts | 16 +- lib/common/utils.ts | 25 +- lib/extra/cordova.ts | 4 +- lib/extra/electron.ts | 2 +- lib/jasmine/jasmine.ts | 2 +- lib/mocha/mocha.ts | 8 +- lib/testing/async-testing.ts | 2 +- lib/zone-spec/async-test.ts | 2 +- lib/zone-spec/fake-async-test.ts | 40 +-- lib/zone-spec/long-stack-trace.ts | 23 +- lib/zone-spec/proxy.ts | 14 +- lib/zone-spec/wtf.ts | 41 +-- lib/zone.ts | 277 +++++++++--------- test/browser/HTMLImports.spec.ts | 6 +- test/browser/MutationObserver.spec.ts | 4 +- test/browser/WebSocket.spec.ts | 2 +- test/browser/XMLHttpRequest.spec.ts | 12 +- test/browser/browser.spec.ts | 123 ++++---- test/browser/element.spec.ts | 10 +- test/closure/zone.closure.ts | 16 +- test/common/Error.spec.ts | 38 +-- test/common/Promise.spec.ts | 56 ++-- test/common/microtasks.spec.ts | 10 +- test/common/setInterval.spec.ts | 2 +- test/common/setTimeout.spec.ts | 4 +- test/common/task.spec.ts | 110 +++---- test/common/util.spec.ts | 12 +- test/common/zone.spec.ts | 27 +- test/jasmine-patch.spec.ts | 8 +- test/mocha-patch.spec.ts | 14 +- .../rxjs/rxjs.Observable.notification.spec.ts | 2 +- test/rxjs/rxjs.bindCallback.spec.ts | 2 +- test/rxjs/rxjs.bindNodeCallback.spec.ts | 2 +- test/test-util.ts | 2 +- test/zone-spec/long-stack-trace-zone.spec.ts | 8 +- test/zone-spec/proxy.spec.ts | 2 +- test/zone-spec/task-tracking.spec.ts | 36 +-- tsconfig-esm-node.json | 9 +- tsconfig-esm.json | 9 +- tsconfig-node.json | 9 +- tsconfig.json | 9 +- 47 files changed, 549 insertions(+), 519 deletions(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index bba9994d7..9b72338bd 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -154,7 +154,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { if (!storedTask) { target[XHR_TASK] = task; } - sendNative.apply(target, data.args); + sendNative!.apply(target, data.args); (XMLHttpRequest as any)[XHR_SCHEDULED] = true; return task; } @@ -166,31 +166,25 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { // Note - ideally, we would call data.target.removeEventListener here, but it's too late // to prevent it from firing. So instead, we store info for the event listener. data.aborted = true; - return abortNative.apply(data.target, data.args); + return abortNative!.apply(data.target, data.args); } - const openNative: Function = + const openNative = patchMethod(XMLHttpRequestPrototype, 'open', () => function(self: any, args: any[]) { self[XHR_SYNC] = args[2] == false; self[XHR_URL] = args[1]; - return openNative.apply(self, args); + return openNative!.apply(self, args); }); const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - const sendNative: Function = + const sendNative = patchMethod(XMLHttpRequestPrototype, 'send', () => function(self: any, args: any[]) { if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. - return sendNative.apply(self, args); + return sendNative!.apply(self, args); } else { - const options: XHROptions = { - target: self, - url: self[XHR_URL], - isPeriodic: false, - delay: null, - args: args, - aborted: false - }; + const options: XHROptions = + {target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false}; return scheduleMacroTaskWithCurrentZone( XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); } diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index 00193832e..daffc6d12 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -48,7 +48,7 @@ export function propertyPatch() { Object.getOwnPropertyDescriptor = function(obj, prop) { const desc = _getOwnPropertyDescriptor(obj, prop); - if (isUnconfigurable(obj, prop)) { + if (desc && isUnconfigurable(obj, prop)) { desc.configurable = false; } return desc; @@ -97,7 +97,7 @@ function _tryDefineProperty(obj: any, prop: string, desc: any, originalConfigura try { return _defineProperty(obj, prop, desc); } catch (error) { - let descJson: string = null; + let descJson: string|null = null; try { descJson = JSON.stringify(desc); } catch (error) { diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 221962802..b302eaad5 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -384,7 +384,7 @@ function canPatchViaPropertyDescriptor() { const detectFunc = () => {}; req.onreadystatechange = detectFunc; const result = (req as any)[SYMBOL_FAKE_ONREADYSTATECHANGE] === detectFunc; - req.onreadystatechange = null; + req.onreadystatechange = null as any; return result; } } diff --git a/lib/common/error-rewrite.ts b/lib/common/error-rewrite.ts index dcd5b3970..dc9a48918 100644 --- a/lib/common/error-rewrite.ts +++ b/lib/common/error-rewrite.ts @@ -63,7 +63,7 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // Process the stack trace and rewrite the frames. if ((ZoneAwareError as any)[stackRewrite] && originalStack) { let frames: string[] = originalStack.split('\n'); - let zoneFrame = api.currentZoneFrame(); + let zoneFrame: _ZoneFrame|null = api.currentZoneFrame(); let i = 0; // Find the first frame while (!(frames[i] === zoneAwareFrame1 || frames[i] === zoneAwareFrame2) && @@ -295,20 +295,20 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { () => { throw new (ZoneAwareError as any)(ZoneAwareError, NativeError); }, - null, + undefined, (t: Task) => { (t as any)._transitionTo = fakeTransitionTo; t.invoke(); }); }, - null, + undefined, (t) => { (t as any)._transitionTo = fakeTransitionTo; t.invoke(); }, () => {}); }, - null, + undefined, (t) => { (t as any)._transitionTo = fakeTransitionTo; t.invoke(); diff --git a/lib/common/events.ts b/lib/common/events.ts index ecc80122f..e3078529d 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -398,7 +398,7 @@ export function patchEventTarget( taskData.eventName = eventName; taskData.isExisting = isExisting; - const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; + const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 876d964bb..35eccc1f1 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -46,7 +46,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr api.microtaskDrainDone = () => { while (_uncaughtPromiseErrors.length) { while (_uncaughtPromiseErrors.length) { - const uncaughtPromiseError: UncaughtPromiseError = _uncaughtPromiseErrors.shift(); + const uncaughtPromiseError: UncaughtPromiseError = _uncaughtPromiseErrors.shift()!; try { uncaughtPromiseError.zone.runGuarded(() => { throw uncaughtPromiseError; @@ -164,7 +164,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr (promise as any)[symbolValue] = value; if ((promise as any)[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally + // the promise is generated by Promise.prototype.finally if (state === RESOLVED) { // the state is resolved, should ignore the value // and use parent promise value @@ -202,7 +202,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr error.rejection = value; error.promise = promise; error.zone = Zone.current; - error.task = Zone.currentTask; + error.task = Zone.currentTask!; _uncaughtPromiseErrors.push(error); api.scheduleMicroTask(); // to make sure that it is running } @@ -239,7 +239,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr function scheduleResolveOrReject( promise: ZoneAwarePromise, zone: AmbientZone, chainPromise: ZoneAwarePromise, - onFulfilled?: (value: R) => U1, onRejected?: (error: any) => U2): void { + onFulfilled?: ((value: R) => U1) | null | undefined, + onRejected?: ((error: any) => U2) | null | undefined): void { clearRejectedNoCatch(promise); const promiseState = (promise as any)[symbolState]; const delegate = promiseState ? @@ -248,14 +249,19 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr zone.scheduleMicroTask(source, () => { try { const parentPromiseValue = (promise as any)[symbolValue]; - const isFinallyPromise = chainPromise && symbolFinally === (chainPromise as any)[symbolFinally]; + const isFinallyPromise = + chainPromise && symbolFinally === (chainPromise as any)[symbolFinally]; if (isFinallyPromise) { // if the promise is generated from finally call, keep parent promise's state and value (chainPromise as any)[symbolParentPromiseValue] = parentPromiseValue; (chainPromise as any)[symbolParentPromiseState] = promiseState; } // should not pass value to finally callback - const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + const value = zone.run( + delegate, undefined, + isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); resolvePromise(chainPromise, true, value); } catch (error) { // if error occurs, should always return this error @@ -272,11 +278,11 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr } static resolve(value: R): Promise { - return resolvePromise(>new this(null), RESOLVED, value); + return resolvePromise(>new this(null as any), RESOLVED, value); } static reject(error: U): Promise { - return resolvePromise(>new this(null), REJECTED, error); + return resolvePromise(>new this(null as any), REJECTED, error); } static race(values: PromiseLike[]): Promise { @@ -323,10 +329,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr resolve(resolvedValues); } })(count), - reject); + reject!); count++; } - if (!count) resolve(resolvedValues); + if (!count) resolve!(resolvedValues); return promise; } @@ -351,7 +357,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr onRejected?: ((reason: any) => TResult2 | PromiseLike)|undefined| null): Promise { const chainPromise: Promise = - new (this.constructor as typeof ZoneAwarePromise)(null); + new (this.constructor as typeof ZoneAwarePromise)(null as any); const zone = Zone.current; if ((this as any)[symbolState] == UNRESOLVED) { ((this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected); @@ -368,7 +374,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr finally(onFinally?: () => U | PromiseLike): Promise { const chainPromise: Promise = - new (this.constructor as typeof ZoneAwarePromise)(null); + new (this.constructor as typeof ZoneAwarePromise)(null as any); (chainPromise as any)[symbolFinally] = symbolFinally; const zone = Zone.current; if ((this as any)[symbolState] == UNRESOLVED) { diff --git a/lib/common/timers.ts b/lib/common/timers.ts index bdec80baf..ccf53aaba 100644 --- a/lib/common/timers.ts +++ b/lib/common/timers.ts @@ -15,13 +15,13 @@ import {patchMethod, scheduleMacroTaskWithCurrentZone, zoneSymbol} from './utils const taskSymbol = zoneSymbol('zoneTask'); interface TimerOptions extends TaskData { - handleId: number; + handleId?: number; args: any[]; } export function patchTimer(window: any, setName: string, cancelName: string, nameSuffix: string) { - let setNative: Function = null; - let clearNative: Function = null; + let setNative: Function|null = null; + let clearNative: Function|null = null; setName += nameSuffix; cancelName += nameSuffix; @@ -50,21 +50,21 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam } } data.args[0] = timer; - data.handleId = setNative.apply(window, data.args); + data.handleId = setNative!.apply(window, data.args); return task; } function clearTask(task: Task) { - return clearNative((task.data).handleId); + return clearNative!((task.data).handleId); } setNative = patchMethod(window, setName, (delegate: Function) => function(self: any, args: any[]) { if (typeof args[0] === 'function') { const options: TimerOptions = { - handleId: null, isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, args: args }; const task = @@ -118,7 +118,7 @@ export function patchTimer(window: any, setName: string, cancelName: string, nam } if (task && typeof task.type === 'string') { if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + (task.cancelFn && task.data!.isPeriodic || task.runCount === 0)) { if (typeof id === 'number') { delete tasksByHandleId[id]; } else if (id) { diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 958bd863d..2f5b40f39 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -43,8 +43,8 @@ export function wrapWithCurrentZone(callback: T, source: str } export function scheduleMacroTaskWithCurrentZone( - source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, - customCancel: (task: Task) => void): MacroTask { + source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, + customCancel?: (task: Task) => void): MacroTask { return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); } @@ -229,7 +229,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { // so we should use original native get to retrieve the handler let value = originalDescGet && originalDescGet.call(this); if (value) { - desc.set.call(this, value); + desc!.set!.call(this, value); if (typeof target[REMOVE_ATTRIBUTE] === 'function') { target.removeAttribute(prop); } @@ -242,7 +242,7 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { ObjectDefineProperty(obj, prop, desc); } -export function patchOnProperties(obj: any, properties: string[], prototype?: any) { +export function patchOnProperties(obj: any, properties: string[]|null, prototype?: any) { if (properties) { for (let i = 0; i < properties.length; i++) { patchProperty(obj, 'on' + properties[i], prototype); @@ -337,7 +337,7 @@ export function patchClass(className: string) { export function patchMethod( target: any, name: string, patchFn: (delegate: Function, delegateName: string, name: string) => (self: any, args: any[]) => - any): Function { + any): Function|null { let proto = target; while (proto && !proto.hasOwnProperty(name)) { proto = ObjectGetPrototypeOf(proto); @@ -348,14 +348,14 @@ export function patchMethod( } const delegateName = zoneSymbol(name); - let delegate: Function; + let delegate: Function|null = null; if (proto && !(delegate = proto[delegateName])) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); if (isPropertyWritable(desc)) { - const patchDelegate = patchFn(delegate, delegateName, name); + const patchDelegate = patchFn(delegate!, delegateName, name); proto[name] = function() { return patchDelegate(this, arguments as any); }; @@ -375,22 +375,21 @@ export interface MacroTaskMeta extends TaskData { // TODO: @JiaLiPassion, support cancel task later if necessary export function patchMacroTask( obj: any, funcName: string, metaCreator: (self: any, args: any[]) => MacroTaskMeta) { - let setNative: Function = null; + let setNative: Function|null = null; function scheduleTask(task: Task) { const data = task.data; data.args[data.cbIdx] = function() { task.invoke.apply(this, arguments); }; - setNative.apply(data.target, data.args); + setNative!.apply(data.target, data.args); return task; } setNative = patchMethod(obj, funcName, (delegate: Function) => function(self: any, args: any[]) { const meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone( - meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. return delegate.apply(self, args); @@ -407,14 +406,14 @@ export interface MicroTaskMeta extends TaskData { export function patchMicroTask( obj: any, funcName: string, metaCreator: (self: any, args: any[]) => MicroTaskMeta) { - let setNative: Function = null; + let setNative: Function|null = null; function scheduleTask(task: Task) { const data = task.data; data.args[data.cbIdx] = function() { task.invoke.apply(this, arguments); }; - setNative.apply(data.target, data.args); + setNative!.apply(data.target, data.args); return task; } diff --git a/lib/extra/cordova.ts b/lib/extra/cordova.ts index 0365248ec..c37938889 100644 --- a/lib/extra/cordova.ts +++ b/lib/extra/cordova.ts @@ -10,7 +10,7 @@ Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => const SUCCESS_SOURCE = 'cordova.exec.success'; const ERROR_SOURCE = 'cordova.exec.error'; const FUNCTION = 'function'; - const nativeExec: Function = + const nativeExec: Function|null = api.patchMethod(global.cordova, 'exec', () => function(self: any, args: any[]) { if (args.length > 0 && typeof args[0] === FUNCTION) { args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE); @@ -18,7 +18,7 @@ Zone.__load_patch('cordova', (global: any, Zone: ZoneType, api: _ZonePrivate) => if (args.length > 1 && typeof args[1] === FUNCTION) { args[1] = Zone.current.wrap(args[1], ERROR_SOURCE); } - return nativeExec.apply(self, args); + return nativeExec!.apply(self, args); }); } }); diff --git a/lib/extra/electron.ts b/lib/extra/electron.ts index eee5b552b..73693eaab 100644 --- a/lib/extra/electron.ts +++ b/lib/extra/electron.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ Zone.__load_patch('electron', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - function patchArguments(target: any, name: string, source: string): Function { + function patchArguments(target: any, name: string, source: string): Function|null { return api.patchMethod(target, name, (delegate: Function) => (self: any, args: any[]) => { return delegate && delegate.apply(self, api.bindArguments(args, source)); }); diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 5d279ab36..bbf68bc2c 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -234,7 +234,7 @@ _super.call(this, attrs); } ZoneQueueRunner.prototype.execute = function() { - let zone: Zone = Zone.current; + let zone: Zone|null = Zone.current; let isChildOfAmbientZone = false; while (zone) { if (zone === ambientZone) { diff --git a/lib/mocha/mocha.ts b/lib/mocha/mocha.ts index f36f76a4a..2b99a66c1 100644 --- a/lib/mocha/mocha.ts +++ b/lib/mocha/mocha.ts @@ -34,7 +34,7 @@ const rootZone = Zone.current; const syncZone = rootZone.fork(new SyncTestZoneSpec('Mocha.describe')); - let testZone: Zone = null; + let testZone: Zone|null = null; const suiteZone = rootZone.fork(new ProxyZoneSpec()); const mochaOriginal = { @@ -55,7 +55,7 @@ // Note we have to make a function with correct number of arguments, // otherwise mocha will // think that all functions are sync or async. - args[i] = (arg.length === 0) ? syncTest(arg) : asyncTest(arg); + args[i] = (arg.length === 0) ? syncTest(arg) : asyncTest!(arg); // Mocha uses toString to view the test body in the result list, make sure we return the // correct function body args[i].toString = function() { @@ -80,13 +80,13 @@ function wrapTestInZone(args: IArguments): any[] { const asyncTest = function(fn: Function) { return function(done: Function) { - return testZone.run(fn, this, [done]); + return testZone!.run(fn, this, [done]); }; }; const syncTest: any = function(fn: Function) { return function() { - return testZone.run(fn, this); + return testZone!.run(fn, this); }; }; diff --git a/lib/testing/async-testing.ts b/lib/testing/async-testing.ts index 1e3c3ab4a..c629ab6ca 100644 --- a/lib/testing/async-testing.ts +++ b/lib/testing/async-testing.ts @@ -70,7 +70,7 @@ Zone.__load_patch('asynctest', (global: any, Zone: ZoneType, api: _ZonePrivate) // If we do it in ProxyZone then we will get to infinite recursion. const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); const previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(() => { + proxyZone!.parent!.run(() => { const testZoneSpec: ZoneSpec = new AsyncTestZoneSpec( () => { // Need to restore the original zone. diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index 328585123..86ed4b190 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -108,7 +108,7 @@ class AsyncTestZoneSpec implements ZoneSpec { // was scheduled/invoked/canceled. onInvoke( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, - applyThis: any, applyArgs: any[], source: string): any { + applyThis: any, applyArgs?: any[], source?: string): any { let previousTaskCounts: any = null; try { this._isSync = true; diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 278cc1f52..bdf7187c9 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -19,7 +19,7 @@ interface MicroTaskScheduledFunction { func: Function; - args: any[]; + args?: any[]; target: any; } @@ -137,7 +137,7 @@ break; } else { // Time to run scheduled function. Remove it from the head of queue. - let current = this._schedulerQueue.shift(); + let current = this._schedulerQueue.shift()!; lastCurrentTime = this._currentTime; this._currentTime = current.endTime; if (doTick) { @@ -192,7 +192,7 @@ break; } - const current = this._schedulerQueue.shift(); + const current = this._schedulerQueue.shift()!; lastCurrentTime = this._currentTime; this._currentTime = current.endTime; if (doTick) { @@ -218,7 +218,7 @@ private _scheduler: Scheduler = new Scheduler(); private _microtasks: MicroTaskScheduledFunction[] = []; - private _lastError: Error = null; + private _lastError: Error|null = null; private _uncaughtPromiseErrors: {rejection: any}[] = (Promise as any)[(Zone as any).__symbol__('uncaughtPromiseErrors')]; @@ -306,7 +306,7 @@ private _setInterval(fn: Function, interval: number, args: any[]): number { let id = this._scheduler.nextId; - let completers = {onSuccess: null as Function, onError: this._dequeuePeriodicTimer(id)}; + let completers = {onSuccess: null as any, onError: this._dequeuePeriodicTimer(id)}; let cb = this._fnAndFlush(fn, completers); // Use the callback created above to requeue on success. @@ -400,7 +400,7 @@ } }; while (this._microtasks.length > 0) { - let microtask = this._microtasks.shift(); + let microtask = this._microtasks.shift()!; microtask.func.apply(microtask.target, microtask.args); } flushErrors(); @@ -429,7 +429,7 @@ // should pass additional arguments to callback if have any // currently we know process.nextTick will have such additional // arguments - let additionalArgs: any[]; + let additionalArgs: any[]|undefined; if (args) { let callbackIndex = (task.data as any).cbIdx; if (typeof args.length === 'number' && args.length > callbackIndex + 1) { @@ -445,17 +445,17 @@ case 'macroTask': switch (task.source) { case 'setTimeout': - task.data['handleId'] = this._setTimeout( - task.invoke, task.data['delay'], + task.data!['handleId'] = this._setTimeout( + task.invoke, task.data!['delay']!, Array.prototype.slice.call((task.data as any)['args'], 2)); break; case 'setImmediate': - task.data['handleId'] = this._setTimeout( + task.data!['handleId'] = this._setTimeout( task.invoke, 0, Array.prototype.slice.call((task.data as any)['args'], 1)); break; case 'setInterval': - task.data['handleId'] = this._setInterval( - task.invoke, task.data['delay'], + task.data!['handleId'] = this._setInterval( + task.invoke, task.data!['delay']!, Array.prototype.slice.call((task.data as any)['args'], 2)); break; case 'XMLHttpRequest.send': @@ -467,7 +467,7 @@ case 'mozRequestAnimationFrame': // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. // (60 frames per second) - task.data['handleId'] = this._setTimeout( + task.data!['handleId'] = this._setTimeout( task.invoke, 16, (task.data as any)['args'], this.trackPendingRequestAnimationFrame); break; @@ -482,11 +482,11 @@ macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args; if (!!macroTaskOption.isPeriodic) { // periodic macroTask, use setInterval to simulate - task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data.isPeriodic = true; + task.data!['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data!.isPeriodic = true; } else { // not periodic, use setTimeout to simulate - task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + task.data!['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } break; } @@ -506,15 +506,15 @@ case 'requestAnimationFrame': case 'webkitRequestAnimationFrame': case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data['handleId']); + return this._clearTimeout(task.data!['handleId']); case 'setInterval': - return this._clearInterval(task.data['handleId']); + return this._clearInterval(task.data!['handleId']); default: // user can define which macroTask they want to support by passing // macroTaskOptions const macroTaskOption = this.findMacroTaskOption(task); if (macroTaskOption) { - const handleId = task.data['handleId']; + const handleId: number = task.data!['handleId']; return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : this._clearTimeout(handleId); } @@ -524,7 +524,7 @@ onInvoke( delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, - applyArgs: any[], source: string): any { + applyArgs?: any[], source?: string): any { try { FakeAsyncTestZoneSpec.patchDate(); return delegate.invoke(target, callback, applyThis, applyArgs, source); diff --git a/lib/zone-spec/long-stack-trace.ts b/lib/zone-spec/long-stack-trace.ts index df42499e5..7ffa807d6 100644 --- a/lib/zone-spec/long-stack-trace.ts +++ b/lib/zone-spec/long-stack-trace.ts @@ -57,7 +57,7 @@ function addErrorStack(lines: string[], error: Error): void { } } -function renderLongStackTrace(frames: LongStackTrace[], stack: string): string { +function renderLongStackTrace(frames: LongStackTrace[], stack?: string): string { const longTrace: string[] = [stack ? stack.trim() : '']; if (frames) { @@ -83,16 +83,17 @@ function renderLongStackTrace(frames: LongStackTrace[], stack: string): string { longStackTraceLimit: 10, // Max number of task to keep the stack trace for. // add a getLongStackTrace method in spec to // handle handled reject promise error. - getLongStackTrace: function(error: Error): string { - if (!error) { - return undefined; - } - const trace = (error as any)[(Zone as any).__symbol__('currentTaskTrace')]; - if (!trace) { - return error.stack; - } - return renderLongStackTrace(trace, error.stack); - }, + getLongStackTrace: function(error: Error): string | + undefined { + if (!error) { + return undefined; + } + const trace = (error as any)[(Zone as any).__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; + } + return renderLongStackTrace(trace, error.stack); + }, onScheduleTask: function( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any { diff --git a/lib/zone-spec/proxy.ts b/lib/zone-spec/proxy.ts index abe03d6dd..16fbf213c 100644 --- a/lib/zone-spec/proxy.ts +++ b/lib/zone-spec/proxy.ts @@ -8,12 +8,12 @@ class ProxyZoneSpec implements ZoneSpec { name: string = 'ProxyZone'; - private _delegateSpec: ZoneSpec; + private _delegateSpec: ZoneSpec|null = null; properties: {[k: string]: any} = {'ProxyZoneSpec': this}; - propertyKeys: string[] = null; + propertyKeys: string[]|null = null; - lastTaskState: HasTaskState = null; + lastTaskState: HasTaskState|null = null; isNeedToTriggerHasTask = false; private tasks: Task[] = []; @@ -33,18 +33,18 @@ class ProxyZoneSpec implements ZoneSpec { return ProxyZoneSpec.get(); } - constructor(private defaultSpecDelegate: ZoneSpec = null) { + constructor(private defaultSpecDelegate: ZoneSpec|null = null) { this.setDelegate(defaultSpecDelegate); } - setDelegate(delegateSpec: ZoneSpec) { + setDelegate(delegateSpec: ZoneSpec|null) { const isNewDelegate = this._delegateSpec !== delegateSpec; this._delegateSpec = delegateSpec; this.propertyKeys && this.propertyKeys.forEach((key) => delete this.properties[key]); this.propertyKeys = null; if (delegateSpec && delegateSpec.properties) { this.propertyKeys = Object.keys(delegateSpec.properties); - this.propertyKeys.forEach((k) => this.properties[k] = delegateSpec.properties[k]); + this.propertyKeys.forEach((k) => this.properties[k] = delegateSpec.properties![k]); } // if set a new delegateSpec, shoulde check whether need to // trigger hasTask or not @@ -129,7 +129,7 @@ class ProxyZoneSpec implements ZoneSpec { onInvoke( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, - applyThis: any, applyArgs: any[], source: string): any { + applyThis: any, applyArgs?: any[], source?: string): any { this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); if (this._delegateSpec && this._delegateSpec.onInvoke) { return this._delegateSpec.onInvoke( diff --git a/lib/zone-spec/wtf.ts b/lib/zone-spec/wtf.ts index d56fc10a4..4a6c6694c 100644 --- a/lib/zone-spec/wtf.ts +++ b/lib/zone-spec/wtf.ts @@ -31,8 +31,8 @@ type WtfEventFn = (...args: any[]) => any; // Detect and setup WTF. - let wtfTrace: WtfTrace = null; - let wtfEvents: WtfEvents = null; + let wtfTrace: WtfTrace|null = null; + let wtfEvents: WtfEvents|null = null; const wtfEnabled: boolean = (function(): boolean { const wtf: Wtf = global['wtf']; if (wtf) { @@ -49,7 +49,7 @@ name: string = 'WTF'; static forkInstance = - wtfEnabled && wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)'); + wtfEnabled ? wtfEvents!.createInstance('Zone:fork(ascii zone, ascii newZone)') : null; static scheduleInstance: {[key: string]: WtfEventFn} = {}; static cancelInstance: {[key: string]: WtfEventFn} = {}; static invokeScope: {[key: string]: WtfEventFn} = {}; @@ -59,19 +59,20 @@ parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, zoneSpec: ZoneSpec): Zone { const retValue = parentZoneDelegate.fork(targetZone, zoneSpec); - WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); + WtfZoneSpec.forkInstance!(zonePathName(targetZone), retValue.name); return retValue; } onInvoke( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, - applyThis: any, applyArgs: any[], source: string): any { - let scope = WtfZoneSpec.invokeScope[source]; + applyThis: any, applyArgs?: any[], source?: string): any { + const src = source || 'unknown'; + let scope = WtfZoneSpec.invokeScope[src]; if (!scope) { - scope = WtfZoneSpec.invokeScope[source] = - wtfEvents.createScope(`Zone:invoke:${source}(ascii zone)`); + scope = WtfZoneSpec.invokeScope[src] = + wtfEvents!.createScope(`Zone:invoke:${source}(ascii zone)`); } - return wtfTrace.leaveScope( + return wtfTrace!.leaveScope( scope(zonePathName(targetZone)), parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); } @@ -89,7 +90,7 @@ let instance = WtfZoneSpec.scheduleInstance[key]; if (!instance) { instance = WtfZoneSpec.scheduleInstance[key] = - wtfEvents.createInstance(`Zone:schedule:${key}(ascii zone, any data)`); + wtfEvents!.createInstance(`Zone:schedule:${key}(ascii zone, any data)`); } const retValue = parentZoneDelegate.scheduleTask(targetZone, task); instance(zonePathName(targetZone), shallowObj(task.data, 2)); @@ -99,14 +100,14 @@ onInvokeTask( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, - applyThis: any, applyArgs: any[]): any { + 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)`); + wtfEvents!.createScope(`Zone:invokeTask:${source}(ascii zone)`); } - return wtfTrace.leaveScope( + return wtfTrace!.leaveScope( scope(zonePathName(targetZone)), parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); } @@ -117,7 +118,7 @@ let instance = WtfZoneSpec.cancelInstance[key]; if (!instance) { instance = WtfZoneSpec.cancelInstance[key] = - wtfEvents.createInstance(`Zone:cancel:${key}(ascii zone, any options)`); + wtfEvents!.createInstance(`Zone:cancel:${key}(ascii zone, any options)`); } const retValue = parentZoneDelegate.cancelTask(targetZone, task); instance(zonePathName(targetZone), shallowObj(task.data, 2)); @@ -125,8 +126,8 @@ } } - function shallowObj(obj: {[k: string]: any}, depth: number): any { - if (!depth) return null; + function shallowObj(obj: {[k: string]: any}|undefined, depth: number): any { + if (!obj || !depth) return null; const out: {[k: string]: any} = {}; for (const key in obj) { if (obj.hasOwnProperty(key)) { @@ -148,10 +149,10 @@ function zonePathName(zone: Zone) { let name: string = zone.name; - zone = zone.parent; - while (zone != null) { - name = zone.name + '::' + name; - zone = zone.parent; + let localZone = zone.parent; + while (localZone != null) { + name = localZone.name + '::' + name; + localZone = localZone.parent; } return name; } diff --git a/lib/zone.ts b/lib/zone.ts index 9cbd04fdc..c8dc24f4b 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -138,7 +138,7 @@ interface Zone { * * @returns {Zone} The parent Zone. */ - parent: Zone; + parent: Zone|null; /** * @returns {string} The Zone name (useful for debugging) */ @@ -162,7 +162,7 @@ interface Zone { * @param key The key to use for identification of the returned zone. * @returns {Zone} The Zone which defines the `key`, `null` if not found. */ - getZoneWith(key: string): Zone; + getZoneWith(key: string): Zone|null; /** * Used to create a child zone. * @@ -243,8 +243,8 @@ interface Zone { * @param customCancel */ scheduleMacroTask( - source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, - customCancel: (task: Task) => void): MacroTask; + source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, + customCancel?: (task: Task) => void): MacroTask; /** * Schedule an EventTask. @@ -256,8 +256,8 @@ interface Zone { * @param customCancel */ scheduleEventTask( - source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, - customCancel: (task: Task) => void): EventTask; + source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, + customCancel?: (task: Task) => void): EventTask; /** * Schedule an existing Task. @@ -290,7 +290,7 @@ interface ZoneType { /** * @returns {Task} The task associated with the current execution. */ - currentTask: Task; + currentTask: Task|null; /** * Verify that Zone has been correctly patched. Specifically that Promise is zone aware. @@ -321,18 +321,18 @@ interface _ZonePrivate { microtaskDrainDone: () => void; showUncaughtError: () => boolean; patchEventTarget: (global: any, apis: any[], options?: any) => boolean[]; - patchOnProperties: (obj: any, properties: string[]) => void; + patchOnProperties: (obj: any, properties: string[]|null) => void; setNativePromise: (nativePromise: any) => void; patchMethod: (target: any, name: string, patchFn: (delegate: Function, delegateName: string, name: string) => - (self: any, args: any[]) => any) => Function; + (self: any, args: any[]) => any) => Function | null; bindArguments: (args: any[], source: string) => any[]; } /** @internal */ interface _ZoneFrame { - parent: _ZoneFrame; + parent: _ZoneFrame|null; zone: Zone; } @@ -399,7 +399,7 @@ interface ZoneSpec { */ onInvoke?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, - applyThis: any, applyArgs: any[], source: string) => any; + applyThis: any, applyArgs?: any[], source?: string) => any; /** * Allows interception of the error handling. @@ -426,7 +426,7 @@ interface ZoneSpec { onInvokeTask?: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, - applyThis: any, applyArgs: any) => any; + applyThis: any, applyArgs?: any[]) => any; /** * Allows interception of task cancellation. @@ -488,11 +488,11 @@ interface ZoneDelegate { zone: Zone; fork(targetZone: Zone, zoneSpec: ZoneSpec): Zone; intercept(targetZone: Zone, callback: Function, source: string): Function; - invoke(targetZone: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string): + invoke(targetZone: Zone, callback: Function, applyThis?: any, applyArgs?: any[], source?: string): any; handleError(targetZone: Zone, error: any): boolean; scheduleTask(targetZone: Zone, task: Task): Task; - invokeTask(targetZone: Zone, task: Task, applyThis: any, applyArgs: any): any; + invokeTask(targetZone: Zone, task: Task, applyThis?: any, applyArgs?: any[]): any; cancelTask(targetZone: Zone, task: Task): any; hasTask(targetZone: Zone, isEmpty: HasTaskState): void; } @@ -579,14 +579,14 @@ interface Task { /** * Task specific options associated with the current task. This is passed to the `scheduleFn`. */ - data: TaskData; + data?: TaskData; /** * Represents the default work which needs to be done to schedule the Task by the VM. * * A zone may choose to intercept this function and perform its own scheduling. */ - scheduleFn: (task: Task) => void; + scheduleFn?: (task: Task) => void; /** * Represents the default work which needs to be done to un-schedule the Task from the VM. Not all @@ -594,7 +594,7 @@ interface Task { * * A zone may chose to intercept this function and perform its own un-scheduling. */ - cancelFn: (task: Task) => void; + cancelFn?: (task: Task) => void; /** * @type {Zone} The zone which will be used to invoke the `callback`. The Zone is captured @@ -633,8 +633,6 @@ type AmbientZone = Zone; type AmbientZoneDelegate = ZoneDelegate; const Zone: ZoneType = (function(global: any) { - const FUNCTION = 'function'; - const performance: {mark(name: string): void; measure(name: string, label: string): void;} = global['performance']; function mark(name: string) { @@ -674,7 +672,7 @@ const Zone: ZoneType = (function(global: any) { return _currentZoneFrame.zone; } - static get currentTask(): Task { + static get currentTask(): Task|null { return _currentTask; } @@ -689,7 +687,7 @@ const Zone: ZoneType = (function(global: any) { } } - public get parent(): AmbientZone { + public get parent(): AmbientZone|null { return this._parent; } @@ -698,12 +696,12 @@ const Zone: ZoneType = (function(global: any) { } - private _parent: Zone; + private _parent: Zone|null; private _name: string; - private _properties: {[key: string]: any} = null; + private _properties: {[key: string]: any}; private _zoneDelegate: ZoneDelegate; - constructor(parent: Zone, zoneSpec: ZoneSpec) { + constructor(parent: Zone|null, zoneSpec: ZoneSpec|null) { this._parent = parent; this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; this._properties = zoneSpec && zoneSpec.properties || {}; @@ -716,8 +714,8 @@ const Zone: ZoneType = (function(global: any) { if (zone) return zone._properties[key]; } - public getZoneWith(key: string): AmbientZone { - let current: Zone = this; + public getZoneWith(key: string): AmbientZone|null { + let current: Zone|null = this; while (current) { if (current._properties.hasOwnProperty(key)) { return current; @@ -733,32 +731,31 @@ const Zone: ZoneType = (function(global: any) { } public wrap(callback: T, source: string): T { - if (typeof callback !== FUNCTION) { + if (typeof callback !== 'function') { throw new Error('Expecting function got: ' + callback); } const _callback = this._zoneDelegate.intercept(this, callback, source); const zone: Zone = this; return function() { - return zone.runGuarded(_callback, this, arguments, source); + return zone.runGuarded(_callback, (this as any), arguments, source); } as any as T; } public run(callback: Function, applyThis?: any, applyArgs?: any[], source?: string): any; public run( - callback: (...args: any[]) => T, applyThis: any = undefined, applyArgs: any[] = null, - source: string = null): T { + callback: (...args: any[]) => T, applyThis?: any, applyArgs?: any[], source?: string): T { _currentZoneFrame = {parent: _currentZoneFrame, zone: this}; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); } finally { - _currentZoneFrame = _currentZoneFrame.parent; + _currentZoneFrame = _currentZoneFrame.parent!; } } public runGuarded(callback: Function, applyThis?: any, applyArgs?: any[], source?: string): any; public runGuarded( - callback: (...args: any[]) => T, applyThis: any = null, applyArgs: any[] = null, - source: string = null) { + callback: (...args: any[]) => T, applyThis: any = null, applyArgs?: any[], + source?: string) { _currentZoneFrame = {parent: _currentZoneFrame, zone: this}; try { try { @@ -769,7 +766,7 @@ const Zone: ZoneType = (function(global: any) { } } } finally { - _currentZoneFrame = _currentZoneFrame.parent; + _currentZoneFrame = _currentZoneFrame.parent!; } } @@ -784,10 +781,7 @@ const Zone: ZoneType = (function(global: any) { // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - // we have to define an variable here, if not - // typescript compiler will complain below - const isNotScheduled = task.state === notScheduled; - if (isNotScheduled && task.type === eventTask) { + if (task.state === notScheduled && task.type === eventTask) { return; } @@ -799,7 +793,7 @@ const Zone: ZoneType = (function(global: any) { _currentZoneFrame = {parent: _currentZoneFrame, zone: this}; try { if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = null; + task.cancelFn = undefined; } try { return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); @@ -821,7 +815,7 @@ const Zone: ZoneType = (function(global: any) { (task as ZoneTask)._transitionTo(notScheduled, running, notScheduled); } } - _currentZoneFrame = _currentZoneFrame.parent; + _currentZoneFrame = _currentZoneFrame.parent!; _currentTask = previousTask; } } @@ -867,19 +861,19 @@ const Zone: ZoneType = (function(global: any) { source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void): MicroTask { return this.scheduleTask( - new ZoneTask(microTask, source, callback, data, customSchedule, null)); + new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); } scheduleMacroTask( - source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, - customCancel: (task: Task) => void): MacroTask { + source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, + customCancel?: (task: Task) => void): MacroTask { return this.scheduleTask( new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); } scheduleEventTask( - source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, - customCancel: (task: Task) => void): EventTask { + source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, + customCancel?: (task: Task) => void): EventTask { return this.scheduleTask( new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); } @@ -905,7 +899,7 @@ const Zone: ZoneType = (function(global: any) { } private _updateTaskCount(task: ZoneTask, count: number) { - const zoneDelegates = task._zoneDelegates; + const zoneDelegates = task._zoneDelegates!; if (count == -1) { task._zoneDelegates = null; } @@ -917,14 +911,15 @@ const Zone: ZoneType = (function(global: any) { const DELEGATE_ZS: ZoneSpec = { name: '', - onHasTask: (delegate: ZoneDelegate, _: Zone, target: Zone, hasTaskState: HasTaskState): void => - delegate.hasTask(target, hasTaskState), - onScheduleTask: (delegate: ZoneDelegate, _: Zone, target: Zone, task: Task): Task => - delegate.scheduleTask(target, task), - onInvokeTask: (delegate: ZoneDelegate, _: Zone, target: Zone, task: Task, applyThis: any, - applyArgs: any): any => delegate.invokeTask(target, task, applyThis, applyArgs), - onCancelTask: (delegate: ZoneDelegate, _: Zone, target: Zone, task: Task): any => - delegate.cancelTask(target, task) + onHasTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, + hasTaskState: HasTaskState): void => delegate.hasTask(target, hasTaskState), + onScheduleTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, + task: Task): Task => delegate.scheduleTask(target, task), + onInvokeTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, task: Task, + applyThis: any, applyArgs: any): any => + delegate.invokeTask(target, task, applyThis, applyArgs), + onCancelTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, task: Task): + any => delegate.cancelTask(target, task) }; class ZoneDelegate implements AmbientZoneDelegate { @@ -934,88 +929,88 @@ const Zone: ZoneType = (function(global: any) { macroTask: number, eventTask: number} = {'microTask': 0, 'macroTask': 0, 'eventTask': 0}; - private _parentDelegate: ZoneDelegate; + private _parentDelegate: ZoneDelegate|null; - private _forkDlgt: ZoneDelegate; - private _forkZS: ZoneSpec; - private _forkCurrZone: Zone; + private _forkDlgt: ZoneDelegate|null; + private _forkZS: ZoneSpec|null; + private _forkCurrZone: Zone|null; - private _interceptDlgt: ZoneDelegate; - private _interceptZS: ZoneSpec; - private _interceptCurrZone: Zone; + private _interceptDlgt: ZoneDelegate|null; + private _interceptZS: ZoneSpec|null; + private _interceptCurrZone: Zone|null; - private _invokeDlgt: ZoneDelegate; - private _invokeZS: ZoneSpec; - private _invokeCurrZone: Zone; + private _invokeDlgt: ZoneDelegate|null; + private _invokeZS: ZoneSpec|null; + private _invokeCurrZone: Zone|null; - private _handleErrorDlgt: ZoneDelegate; - private _handleErrorZS: ZoneSpec; - private _handleErrorCurrZone: Zone; + private _handleErrorDlgt: ZoneDelegate|null; + private _handleErrorZS: ZoneSpec|null; + private _handleErrorCurrZone: Zone|null; - private _scheduleTaskDlgt: ZoneDelegate; - private _scheduleTaskZS: ZoneSpec; - private _scheduleTaskCurrZone: Zone; + private _scheduleTaskDlgt: ZoneDelegate|null; + private _scheduleTaskZS: ZoneSpec|null; + private _scheduleTaskCurrZone: Zone|null; - private _invokeTaskDlgt: ZoneDelegate; - private _invokeTaskZS: ZoneSpec; - private _invokeTaskCurrZone: Zone; + private _invokeTaskDlgt: ZoneDelegate|null; + private _invokeTaskZS: ZoneSpec|null; + private _invokeTaskCurrZone: Zone|null; - private _cancelTaskDlgt: ZoneDelegate; - private _cancelTaskZS: ZoneSpec; - private _cancelTaskCurrZone: Zone; + private _cancelTaskDlgt: ZoneDelegate|null; + private _cancelTaskZS: ZoneSpec|null; + private _cancelTaskCurrZone: Zone|null; - private _hasTaskDlgt: ZoneDelegate; - private _hasTaskDlgtOwner: ZoneDelegate; - private _hasTaskZS: ZoneSpec; - private _hasTaskCurrZone: Zone; + private _hasTaskDlgt: ZoneDelegate|null; + private _hasTaskDlgtOwner: ZoneDelegate|null; + private _hasTaskZS: ZoneSpec|null; + private _hasTaskCurrZone: Zone|null; - constructor(zone: Zone, parentDelegate: ZoneDelegate, zoneSpec: ZoneSpec) { + constructor(zone: Zone, parentDelegate: ZoneDelegate|null, zoneSpec: ZoneSpec|null) { this.zone = zone; this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate!._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate!._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate!.zone); this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate!._interceptZS); this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate!._interceptDlgt); this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate!.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate!._invokeZS); this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + zoneSpec && (zoneSpec.onInvoke ? parentDelegate! : parentDelegate!._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate!.zone); this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate!._handleErrorZS); this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + zoneSpec && (zoneSpec.onHandleError ? parentDelegate! : parentDelegate!._handleErrorDlgt); this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate!.zone); this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = - zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate!._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate! : parentDelegate!._scheduleTaskDlgt); this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate!.zone); this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate!._invokeTaskZS); this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate! : parentDelegate!._invokeTaskDlgt); this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate!.zone); this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate!._cancelTaskZS); this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate! : parentDelegate!._cancelTaskDlgt); this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate!.zone); this._hasTaskZS = null; this._hasTaskDlgt = null; @@ -1031,49 +1026,50 @@ const Zone: ZoneType = (function(global: any) { this._hasTaskDlgt = parentDelegate; this._hasTaskDlgtOwner = this; this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { + if (!zoneSpec!.onScheduleTask) { this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskDlgt = parentDelegate!; this._scheduleTaskCurrZone = this.zone; } - if (!zoneSpec.onInvokeTask) { + if (!zoneSpec!.onInvokeTask) { this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; + this._invokeTaskDlgt = parentDelegate!; this._invokeTaskCurrZone = this.zone; } - if (!zoneSpec.onCancelTask) { + if (!zoneSpec!.onCancelTask) { this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; + this._cancelTaskDlgt = parentDelegate!; this._cancelTaskCurrZone = this.zone; } } } fork(targetZone: Zone, zoneSpec: ZoneSpec): AmbientZone { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.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._interceptCurrZone, targetZone, callback, source) : + this._interceptZS.onIntercept!( + this._interceptDlgt!, this._interceptCurrZone!, targetZone, callback, source) : callback; } - invoke(targetZone: Zone, callback: Function, applyThis: any, applyArgs: any[], source: string): - any { + invoke( + targetZone: Zone, callback: Function, applyThis: any, applyArgs?: any[], + source?: string): any { return this._invokeZS ? - this._invokeZS.onInvoke( - this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, + this._invokeZS.onInvoke!( + this._invokeDlgt!, this._invokeCurrZone!, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs); } handleError(targetZone: Zone, error: any): boolean { return this._handleErrorZS ? - this._handleErrorZS.onHandleError( - this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + this._handleErrorZS.onHandleError!( + this._handleErrorDlgt!, this._handleErrorCurrZone!, targetZone, error) : true; } @@ -1081,10 +1077,11 @@ const Zone: ZoneType = (function(global: any) { let returnTask: ZoneTask = task as ZoneTask; if (this._scheduleTaskZS) { if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + returnTask._zoneDelegates!.push(this._hasTaskDlgtOwner!); } - returnTask = this._scheduleTaskZS.onScheduleTask( - this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task) as ZoneTask; + returnTask = this._scheduleTaskZS.onScheduleTask!( + this._scheduleTaskDlgt!, this._scheduleTaskCurrZone!, targetZone, + task) as ZoneTask; if (!returnTask) returnTask = task as ZoneTask; } else { if (task.scheduleFn) { @@ -1098,10 +1095,10 @@ const Zone: ZoneType = (function(global: any) { return returnTask; } - invokeTask(targetZone: Zone, task: Task, applyThis: any, applyArgs: any): any { + invokeTask(targetZone: Zone, task: Task, applyThis: any, applyArgs?: any[]): any { return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask( - this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, + this._invokeTaskZS.onInvokeTask!( + this._invokeTaskDlgt!, this._invokeTaskCurrZone!, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs); } @@ -1109,8 +1106,8 @@ const Zone: ZoneType = (function(global: any) { cancelTask(targetZone: Zone, task: Task): any { let value: any; if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask( - this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + value = this._cancelTaskZS.onCancelTask!( + this._cancelTaskDlgt!, this._cancelTaskCurrZone!, targetZone, task); } else { if (!task.cancelFn) { throw Error('Task is not cancelable'); @@ -1124,9 +1121,9 @@ const Zone: ZoneType = (function(global: any) { // hasTask should not throw error so other ZoneDelegate // can still trigger hasTask callback try { - return this._hasTaskZS && - this._hasTaskZS.onHasTask( - this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + this._hasTaskZS && + this._hasTaskZS.onHasTask!( + this._hasTaskDlgt!, this._hasTaskCurrZone!, targetZone, isEmpty); } catch (err) { this.handleError(targetZone, err); } @@ -1156,17 +1153,17 @@ const Zone: ZoneType = (function(global: any) { public source: string; public invoke: Function; public callback: Function; - public data: TaskData; - public scheduleFn: (task: Task) => void; - public cancelFn: (task: Task) => void; - _zone: Zone = null; + public data: TaskData|undefined; + public scheduleFn: ((task: Task) => void)|undefined; + public cancelFn: ((task: Task) => void)|undefined; + _zone: Zone|null = null; public runCount: number = 0; - _zoneDelegates: ZoneDelegate[] = null; + _zoneDelegates: ZoneDelegate[]|null = null; _state: TaskState = 'notScheduled'; constructor( - type: T, source: string, callback: Function, options: TaskData, - scheduleFn: (task: Task) => void, cancelFn: (task: Task) => void) { + type: T, source: string, callback: Function, options: TaskData|undefined, + scheduleFn: ((task: Task) => void)|undefined, cancelFn: ((task: Task) => void)|undefined) { this.type = type; this.source = source; this.data = options; @@ -1201,7 +1198,7 @@ const Zone: ZoneType = (function(global: any) { } get zone(): Zone { - return this._zone; + return this._zone!; } get state(): TaskState { @@ -1325,18 +1322,18 @@ const Zone: ZoneType = (function(global: any) { patchEventTarget: () => [], patchOnProperties: noop, patchMethod: () => noop, - bindArguments: () => null, + bindArguments: () => (null as any), setNativePromise: (NativePromise: any) => { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === FUNCTION) { + if (NativePromise && typeof NativePromise.resolve === 'function') { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, }; let _currentZoneFrame: _ZoneFrame = {parent: null, zone: new Zone(null, null)}; - let _currentTask: Task = null; + let _currentTask: Task|null = null; let _numberOfNestedTaskFrames = 0; function noop() {} diff --git a/test/browser/HTMLImports.spec.ts b/test/browser/HTMLImports.spec.ts index 8fc399936..8d22557dc 100644 --- a/test/browser/HTMLImports.spec.ts +++ b/test/browser/HTMLImports.spec.ts @@ -30,7 +30,7 @@ describe('HTML Imports', ifEnvSupports(supportsImports, function() { }); }); - document.head.appendChild(link); + document.head.appendChild(link!); }); function supportsOnEvents() { @@ -56,7 +56,7 @@ describe('HTML Imports', ifEnvSupports(supportsImports, function() { }; }); - document.head.appendChild(link); + document.head.appendChild(link!); }); it('should work with onload', function(done) { @@ -73,7 +73,7 @@ describe('HTML Imports', ifEnvSupports(supportsImports, function() { }; }); - document.head.appendChild(link); + document.head.appendChild(link!); }); }); diff --git a/test/browser/MutationObserver.spec.ts b/test/browser/MutationObserver.spec.ts index 15b2da37a..e7bf3056b 100644 --- a/test/browser/MutationObserver.spec.ts +++ b/test/browser/MutationObserver.spec.ts @@ -48,7 +48,7 @@ describe('MutationObserver', ifEnvSupports('MutationObserver', function() { ob = new MutationObserver(function() {}); }); - ob.disconnect(); + ob!.disconnect(); expect(flag).toBe(false); }); })); @@ -70,6 +70,6 @@ describe('WebKitMutationObserver', ifEnvSupports('WebKitMutationObserver', funct ob.observe(elt, {childList: true}); }); - elt.innerHTML = '

hey

'; + elt!.innerHTML = '

hey

'; }); })); diff --git a/test/browser/WebSocket.spec.ts b/test/browser/WebSocket.spec.ts index 1ee4b39d8..82c51c321 100644 --- a/test/browser/WebSocket.spec.ts +++ b/test/browser/WebSocket.spec.ts @@ -121,7 +121,7 @@ if (!window['saucelabs']) { log += 'a'; }; - socket.onmessage = null; + socket.onmessage = null as any; socket.send('hi'); diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/browser/XMLHttpRequest.spec.ts index e6f9a705a..49121396a 100644 --- a/test/browser/XMLHttpRequest.spec.ts +++ b/test/browser/XMLHttpRequest.spec.ts @@ -41,7 +41,7 @@ describe('XMLHttpRequest', function() { req.send(); const lastScheduled = wtfMock.log[wtfMock.log.length - 1]; expect(lastScheduled).toMatch('# Zone:schedule:macroTask:XMLHttpRequest.send'); - }, null, null, 'unit-test'); + }, null, undefined, 'unit-test'); }); it('should not trigger Zone callback of internal onreadystatechange', function(done) { @@ -77,14 +77,14 @@ describe('XMLHttpRequest', function() { req = new XMLHttpRequest(); req.onreadystatechange = function() { // Make sure that the wrapCallback will only be called once - req.onreadystatechange = null; + req.onreadystatechange = null as any; expect(Zone.current).toBe(testZone); done(); }; req.open('get', '/', true); }); - req.send(); + req!.send(); }); it('should return null when access ontimeout first time without error', function() { @@ -105,14 +105,14 @@ describe('XMLHttpRequest', function() { req = new XMLHttpRequest(); req.onprogress = function() { // Make sure that the wrapCallback will only be called once - req.onprogress = null; + req.onprogress = null as any; expect(Zone.current).toBe(testZone); done(); }; req.open('get', '/', true); }); - req.send(); + req!.send(); }); it('should allow canceling of an XMLHttpRequest', function(done) { @@ -222,7 +222,7 @@ describe('XMLHttpRequest', function() { req.open('get', '/', true); req.send(); req.onload = function() { - req.onload = null; + req.onload = null as any; req.open('get', '/', true); req.onload = function() { done(); diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 9b013d70c..58899a4a9 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -47,8 +47,8 @@ try { supportsPassive = true; } }); - window.addEventListener('test', null, opts); - window.removeEventListener('test', null, opts); + window.addEventListener('test', null as any, opts); + window.removeEventListener('test', null as any, opts); } catch (e) { } @@ -89,7 +89,8 @@ describe('Zone', function() { const myZone = Zone.current.fork({ name: 'spy', onInvoke: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - callback: Function, applyThis: any, applyArgs: any[], source: string): any => { + callback: Function, applyThis?: any, applyArgs?: any[], + source?: string): any => { if (source) { spies[source].apply(null, applyArgs); } else { @@ -336,11 +337,11 @@ describe('Zone', function() { span.onmousedown = listener1; }); - expect(handler1).toBe(handler2); + expect(handler1!).toBe(handler2!); - handler1.apply(undefined, [{type: 'click', target: span}]); + handler1!.apply(undefined, [{type: 'click', target: span}]); - handler2.apply(undefined, [{type: 'mousedown', target: span}]); + handler2!.apply(undefined, [{type: 'mousedown', target: span}]); expect(hookSpy).toHaveBeenCalled(); expect(logs).toEqual(['listener1', 'listener2']); @@ -1070,7 +1071,7 @@ describe('Zone', function() { }); let listeners = (button as any).eventListeners('click'); expect(listeners.length).toBe(1); - eventTask.zone.cancelTask(eventTask); + eventTask!.zone.cancelTask(eventTask!); listeners = (button as any).eventListeners('click'); button.dispatchEvent(clickEvent); @@ -1098,7 +1099,7 @@ describe('Zone', function() { }); let listeners = (button as any).eventListeners('click'); expect(listeners.length).toBe(1); - eventTask.zone.cancelTask(eventTask); + eventTask!.zone.cancelTask(eventTask!); listeners = (button as any).eventListeners('click'); button.dispatchEvent(clickEvent); @@ -1133,7 +1134,7 @@ describe('Zone', function() { button.dispatchEvent(clickEvent); expect(logs.length).toBe(2); expect(logs).toEqual(['click1', 'click2']); - eventTask.zone.cancelTask(eventTask); + eventTask!.zone.cancelTask(eventTask!); logs = []; listeners = (button as any).eventListeners('click'); @@ -1170,7 +1171,7 @@ describe('Zone', function() { button.dispatchEvent(clickEvent); expect(logs.length).toBe(2); expect(logs).toEqual(['click1', 'click2']); - eventTask.zone.cancelTask(eventTask); + eventTask!.zone.cancelTask(eventTask!); logs = []; listeners = (button as any).eventListeners('click'); @@ -1207,7 +1208,7 @@ describe('Zone', function() { button.dispatchEvent(clickEvent); expect(logs.length).toBe(2); expect(logs).toEqual(['click1', 'click2']); - eventTask.zone.cancelTask(eventTask); + eventTask!.zone.cancelTask(eventTask!); logs = []; listeners = (button as any).eventListeners('click'); @@ -2436,7 +2437,7 @@ describe('Zone', function() { ifEnvSupportsWithDone(supportCanvasTest, (done: Function) => { const canvas = document.createElement('canvas'); const d = canvas.width; - const ctx = canvas.getContext('2d'); + const ctx = canvas.getContext('2d')!; ctx.beginPath(); ctx.moveTo(d / 2, 0); ctx.lineTo(d, d); @@ -2462,7 +2463,7 @@ describe('Zone', function() { expect(scheduleSpy).toHaveBeenCalled(); const reader = new FileReader(); - reader.readAsDataURL(blob); + reader.readAsDataURL(blob!); reader.onloadend = function() { const base64data = reader.result; expect(base64data).toEqual(canvasData); @@ -2472,61 +2473,59 @@ describe('Zone', function() { }); })); - describe('ResizeObserver', ifEnvSupports('ResizeObserver', () => { - it('ResizeObserver callback should be in zone', (done) => { - const ResizeObserver = (window as any)['ResizeObserver']; - const div = document.createElement('div'); - const zone = Zone.current.fork({ - name: 'observer' - }); - const observer = new ResizeObserver((entries: any, ob: any) => { - expect(Zone.current.name).toEqual(zone.name); - - expect(entries.length).toBe(1); - expect(entries[0].target).toBe(div); - done(); - }); - - zone.run(() => { - observer.observe(div); - }); + describe( + 'ResizeObserver', ifEnvSupports('ResizeObserver', () => { + it('ResizeObserver callback should be in zone', (done) => { + const ResizeObserver = (window as any)['ResizeObserver']; + const div = document.createElement('div'); + const zone = Zone.current.fork({name: 'observer'}); + const observer = new ResizeObserver((entries: any, ob: any) => { + expect(Zone.current.name).toEqual(zone.name); - document.body.appendChild(div); - }); + expect(entries.length).toBe(1); + expect(entries[0].target).toBe(div); + done(); + }); - it('ResizeObserver callback should be able to in different zones which when they were observed', (done) => { - const ResizeObserver = (window as any)['ResizeObserver']; - const div1 = document.createElement('div'); - const div2 = document.createElement('div'); - const zone = Zone.current.fork({ - name: 'observer' - }); - let count = 0; - const observer = new ResizeObserver((entries: any, ob: any) => { - entries.forEach((entry: any) => { - if (entry.target === div1) { - expect(Zone.current.name).toEqual(zone.name); - } else { - expect(Zone.current.name).toEqual(''); - } + zone.run(() => { + observer.observe(div); }); - count ++; - if (count === 2) { - done(); - } - }); - zone.run(() => { - observer.observe(div1); - }); - Zone.root.run(() => { - observer.observe(div2); + document.body.appendChild(div); }); - document.body.appendChild(div1); - document.body.appendChild(div2); - }); - })); + it('ResizeObserver callback should be able to in different zones which when they were observed', + (done) => { + const ResizeObserver = (window as any)['ResizeObserver']; + const div1 = document.createElement('div'); + const div2 = document.createElement('div'); + const zone = Zone.current.fork({name: 'observer'}); + let count = 0; + const observer = new ResizeObserver((entries: any, ob: any) => { + entries.forEach((entry: any) => { + if (entry.target === div1) { + expect(Zone.current.name).toEqual(zone.name); + } else { + expect(Zone.current.name).toEqual(''); + } + }); + count++; + if (count === 2) { + done(); + } + }); + + zone.run(() => { + observer.observe(div1); + }); + Zone.root.run(() => { + observer.observe(div2); + }); + + document.body.appendChild(div1); + document.body.appendChild(div2); + }); + })); xdescribe('getUserMedia', () => { it('navigator.mediaDevices.getUserMedia should in zone', diff --git a/test/browser/element.spec.ts b/test/browser/element.spec.ts index 4b7e50d1b..ad9a34adc 100644 --- a/test/browser/element.spec.ts +++ b/test/browser/element.spec.ts @@ -161,8 +161,8 @@ describe('element', function() { Zone.current.fork({name: 'eventListenerZone', onScheduleTask: onAddEventListenerSpy}); expect(function() { eventListenerZone.run(function() { - button.addEventListener('click', null); - button.addEventListener('click', undefined); + button.addEventListener('click', null as any); + button.addEventListener('click', undefined as any); }); }).not.toThrowError(); expect(onAddEventListenerSpy).not.toHaveBeenCalledWith(); @@ -174,8 +174,8 @@ describe('element', function() { Zone.current.fork({name: 'eventListenerZone', onScheduleTask: onAddEventListenerSpy}); expect(function() { eventListenerZone.run(function() { - button.removeEventListener('click', null); - button.removeEventListener('click', undefined); + button.removeEventListener('click', null as any); + button.removeEventListener('click', undefined as any); }); }).not.toThrowError(); expect(onAddEventListenerSpy).not.toHaveBeenCalledWith(); @@ -294,7 +294,7 @@ describe('element', function() { button.onclick = function() { log += 'a'; }; - button.onclick = null; + button.onclick = null as any; button.click(); expect(log).toEqual(''); diff --git a/test/closure/zone.closure.ts b/test/closure/zone.closure.ts index b065efde1..facfc4719 100644 --- a/test/closure/zone.closure.ts +++ b/test/closure/zone.closure.ts @@ -18,13 +18,13 @@ const testClosureFunction = () => { }, onIntercept: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - delegate: Function, source?: string) => { + delegate: Function, source: string) => { return parentZoneDelegate.intercept(targetZone, delegate, source); }, onInvoke: function( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, - applyThis: any, applyArgs: any[], source: string) { + applyThis?: any, applyArgs?: any[], source?: string) { return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); }, @@ -40,7 +40,7 @@ const testClosureFunction = () => { onInvokeTask: function( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, - applyThis: any, applyArgs: any[]) { + applyThis?: any, applyArgs?: any[]) { return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); }, @@ -59,13 +59,13 @@ const testClosureFunction = () => { testZone.runGuarded(() => { testZone.run(() => { const properties = testZoneSpec.properties; - properties['key'] = 'value'; + properties!['key'] = 'value'; const keyZone = Zone.current.getZoneWith('key'); logs.push('current' + Zone.current.name); - logs.push('parent' + Zone.current.parent.name); - logs.push('getZoneWith' + keyZone.name); - logs.push('get' + keyZone.get('key')); + logs.push('parent' + Zone.current.parent!.name); + logs.push('getZoneWith' + keyZone!.name); + logs.push('get' + keyZone!.get('key')); logs.push('root' + Zone.root.name); Object.keys((Zone as any).prototype).forEach(key => { logs.push(key); @@ -74,7 +74,7 @@ const testClosureFunction = () => { logs.push(key); }); - const task = Zone.current.scheduleMicroTask('testTask', () => {}, null, () => {}); + const task = Zone.current.scheduleMicroTask('testTask', () => {}, undefined, () => {}); Object.keys(task).forEach(key => { logs.push(key); }); diff --git a/test/common/Error.spec.ts b/test/common/Error.spec.ts index 1f4727b8d..9a9812439 100644 --- a/test/common/Error.spec.ts +++ b/test/common/Error.spec.ts @@ -175,8 +175,8 @@ describe('ZoneAwareError', () => { // there event without throw const error = new Error('test'); const errorWithoutNew = Error('test'); - expect(error.stack.split('\n').length > 0).toBeTruthy(); - expect(errorWithoutNew.stack.split('\n').length > 0).toBeTruthy(); + expect(error.stack!.split('\n').length > 0).toBeTruthy(); + expect(errorWithoutNew.stack!.split('\n').length > 0).toBeTruthy(); }); it('should show zone names in stack frames and remove extra frames', () => { @@ -214,14 +214,14 @@ describe('ZoneAwareError', () => { expect(outside.stack).toEqual(outside.zoneAwareStack); expect(outsideWithoutNew.stack).toEqual(outsideWithoutNew.zoneAwareStack); - expect(inside.stack).toEqual(inside.zoneAwareStack); - expect(insideWithoutNew.stack).toEqual(insideWithoutNew.zoneAwareStack); - expect(typeof inside.originalStack).toEqual('string'); - expect(typeof insideWithoutNew.originalStack).toEqual('string'); - const outsideFrames = outside.stack.split(/\n/); - const insideFrames = inside.stack.split(/\n/); - const outsideWithoutNewFrames = outsideWithoutNew.stack.split(/\n/); - const insideWithoutNewFrames = insideWithoutNew.stack.split(/\n/); + expect(inside!.stack).toEqual(inside!.zoneAwareStack); + expect(insideWithoutNew!.stack).toEqual(insideWithoutNew!.zoneAwareStack); + expect(typeof inside!.originalStack).toEqual('string'); + expect(typeof insideWithoutNew!.originalStack).toEqual('string'); + const outsideFrames = outside.stack!.split(/\n/); + const insideFrames = inside!.stack!.split(/\n/); + const outsideWithoutNewFrames = outsideWithoutNew!.stack!.split(/\n/); + const insideWithoutNewFrames = insideWithoutNew!.stack!.split(/\n/); // throw away first line if it contains the error if (/Outside/.test(outsideFrames[0])) { @@ -271,7 +271,7 @@ describe('ZoneAwareError', () => { ]; function assertStackDoesNotContainZoneFrames(err: Error) { - const frames = err.stack.split('\n'); + const frames = err.stack!.split('\n'); for (let i = 0; i < frames.length; i++) { expect(zoneAwareFrames.filter(f => frames[i].indexOf(f) !== -1)).toEqual([]); } @@ -279,7 +279,7 @@ describe('ZoneAwareError', () => { const errorZoneSpec = { name: 'errorZone', - done: <() => void>null, + done: <(() => void)|null>null, onHandleError: (parentDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => { assertStackDoesNotContainZoneFrames(error); @@ -340,7 +340,7 @@ describe('ZoneAwareError', () => { assertStackDoesNotContainZoneFramesTest(() => { const task = Zone.current.scheduleEventTask('errorEvent', () => { throw new Error('test error'); - }, null, () => null, null); + }, undefined, () => null, undefined); task.invoke(); })); @@ -348,7 +348,7 @@ describe('ZoneAwareError', () => { assertStackDoesNotContainZoneFramesTest(() => { const task = Zone.current.scheduleEventTask('errorEvent', () => { throw Error('test error'); - }, null, () => null, null); + }, undefined, () => null, undefined); task.invoke(); })); @@ -357,7 +357,7 @@ describe('ZoneAwareError', () => { const task = Zone.current.fork((Zone as any)['longStackTraceZoneSpec']) .scheduleEventTask('errorEvent', () => { throw new Error('test error'); - }, null, () => null, null); + }, undefined, () => null, undefined); task.invoke(); })); @@ -366,7 +366,7 @@ describe('ZoneAwareError', () => { const task = Zone.current.fork((Zone as any)['longStackTraceZoneSpec']) .scheduleEventTask('errorEvent', () => { throw Error('test error'); - }, null, () => null, null); + }, undefined, () => null, undefined); task.invoke(); })); @@ -388,7 +388,7 @@ describe('ZoneAwareError', () => { }) .scheduleEventTask('errorEvent', () => { throw new Error('test error'); - }, null, () => null, null); + }, undefined, () => null, undefined); task.invoke(); })); @@ -398,9 +398,9 @@ describe('ZoneAwareError', () => { const NativeError = _global['__zone_symbol__Error']; const desc = Object.getOwnPropertyDescriptor(NativeError.prototype, 'stack'); if (desc) { - const originalSet: (value: any) => void = desc.set; + const originalSet: ((value: any) => void)|undefined = desc.set; // make stack readonly - desc.set = null; + desc.set = null as any; try { const error = new Error('test error'); diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index d6a803b72..90f69be6a 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -19,13 +19,12 @@ class MicroTaskQueueZoneSpec implements ZoneSpec { flush() { while (this.queue.length) { const task = this.queue.shift(); - task.invoke(); + task!.invoke(); } } - onScheduleTask(delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: MicroTask): - any { - this.queue.push(task); + onScheduleTask(delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any { + this.queue.push(task as MicroTask); } } @@ -34,8 +33,8 @@ function flushMicrotasks() { } class TestRejection { - prop1: string; - prop2: string; + prop1?: string; + prop2?: string; } describe( @@ -52,7 +51,7 @@ describe( pZone = Zone.current.fork({ name: 'promise-zone', onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: MicroTask): any => { + task: Task): any => { log.push('scheduleTask'); parentZoneDelegate.scheduleTask(targetZone, task); } @@ -185,7 +184,7 @@ describe( describe('Promise API', function() { it('should work with .then', function(done) { - let resolve: Function = null; + let resolve: Function|null = null; testZone.run(function() { new Promise(function(resolveFn) { @@ -196,11 +195,11 @@ describe( }); }); - resolve(); + resolve!(); }); it('should work with .catch', function(done) { - let reject: () => void = null; + let reject: (() => void)|null = null; testZone.run(function() { new Promise(function(resolveFn, rejectFn) { @@ -212,11 +211,11 @@ describe( }); - expect(reject()).toBe(undefined); + expect(reject!()).toBe(undefined); }); it('should work with .finally with resolved promise', function(done) { - let resolve: Function = null; + let resolve: Function|null = null; testZone.run(function() { new Promise(function(resolveFn) { @@ -228,11 +227,11 @@ describe( }); }); - resolve('value'); + resolve!('value'); }); it('should work with .finally with rejected promise', function(done) { - let reject: Function = null; + let reject: Function|null = null; testZone.run(function() { new Promise(function(_, rejectFn) { @@ -244,7 +243,7 @@ describe( }); }); - reject('error'); + reject!('error'); }); it('should work with Promise.resolve', () => { @@ -344,10 +343,10 @@ describe( }); it('should notify Zone.onHandleError if no one catches promise', (done) => { - let promiseError: Error = null; - let zone: Zone = null; - let task: Task = null; - let error: Error = null; + let promiseError: Error|null = null; + let zone: Zone|null = null; + let task: Task|null = null; + let error: Error|null = null; queueZone .fork({ name: 'promise-error', @@ -370,11 +369,12 @@ describe( Promise.reject(error); expect(promiseError).toBe(null); }); - setTimeout((): void => null); + setTimeout((): any => null); setTimeout(() => { - expect(promiseError.message) + expect(promiseError!.message) .toBe( - 'Uncaught (in promise): ' + error + (error.stack ? '\n' + error.stack : '')); + 'Uncaught (in promise): ' + error + + (error!.stack ? '\n' + error!.stack : '')); expect((promiseError as any)['rejection']).toBe(error); expect((promiseError as any)['zone']).toBe(zone); expect((promiseError as any)['task']).toBe(task); @@ -383,9 +383,9 @@ describe( }); it('should print readable information when throw a not error object', (done) => { - let promiseError: Error = null; - let zone: Zone = null; - let task: Task = null; + let promiseError: Error|null = null; + let zone: Zone|null = null; + let task: Task|null = null; let rejectObj: TestRejection; queueZone .fork({ @@ -406,9 +406,9 @@ describe( Promise.reject(rejectObj); expect(promiseError).toBe(null); }); - setTimeout((): void => null); + setTimeout((): any => null); setTimeout(() => { - expect(promiseError.message) + expect(promiseError!.message) .toMatch(/Uncaught \(in promise\):.*: {"prop1":"value1","prop2":"value2"}/); done(); }); @@ -540,7 +540,7 @@ describe( expect(result).toBe('foo'); done && done(); }); - } + } it('should resolve if the Promise subclass resolves', jasmine ? function(done) { testPromiseSubClass(done); diff --git a/test/common/microtasks.spec.ts b/test/common/microtasks.spec.ts index 87f512012..332b27b06 100644 --- a/test/common/microtasks.spec.ts +++ b/test/common/microtasks.spec.ts @@ -16,9 +16,9 @@ describe('Microtasks', function() { it('should execute microtasks enqueued in the root zone', function(done) { const log: number[] = []; - Zone.current.scheduleMicroTask('test', () => log.push(1), null, scheduleFn); - Zone.current.scheduleMicroTask('test', () => log.push(2), null, scheduleFn); - Zone.current.scheduleMicroTask('test', () => log.push(3), null, scheduleFn); + Zone.current.scheduleMicroTask('test', () => log.push(1), undefined, scheduleFn); + Zone.current.scheduleMicroTask('test', () => log.push(2), undefined, scheduleFn); + Zone.current.scheduleMicroTask('test', () => log.push(3), undefined, scheduleFn); setTimeout(function() { expect(log).toEqual([1, 2, 3]); @@ -29,11 +29,11 @@ describe('Microtasks', function() { it('should correctly scheduleMacroTask microtasks vs macrotasks', function(done) { const log = ['+root']; - Zone.current.scheduleMicroTask('test', () => log.push('root.mit'), null, scheduleFn); + Zone.current.scheduleMicroTask('test', () => log.push('root.mit'), undefined, scheduleFn); setTimeout(function() { log.push('+mat1'); - Zone.current.scheduleMicroTask('test', () => log.push('mat1.mit'), null, scheduleFn); + Zone.current.scheduleMicroTask('test', () => log.push('mat1.mit'), undefined, scheduleFn); log.push('-mat1'); }, 10); diff --git a/test/common/setInterval.spec.ts b/test/common/setInterval.spec.ts index 42aaac7b0..fc41c306f 100644 --- a/test/common/setInterval.spec.ts +++ b/test/common/setInterval.spec.ts @@ -57,7 +57,7 @@ describe('setInterval', function() { expect(wtfMock.log[1]).toEqual('> Zone:invoke:unit-test("::ProxyZone::WTF::TestZone")'); expect(wtfMock.log[2]) .toContain('# Zone:schedule:macroTask:setInterval("::ProxyZone::WTF::TestZone"'); - }, null, null, 'unit-test'); + }, null, undefined, 'unit-test'); }); it('should not cancel the task after invoke the setInterval callback', (done) => { diff --git a/test/common/setTimeout.spec.ts b/test/common/setTimeout.spec.ts index c71ab4d5f..0b868836d 100644 --- a/test/common/setTimeout.spec.ts +++ b/test/common/setTimeout.spec.ts @@ -39,7 +39,7 @@ describe('setTimeout', function() { expect(wtfMock.log[1]).toEqual('> Zone:invoke:unit-test("::ProxyZone::WTF::TestZone")'); expect(wtfMock.log[2]) .toContain('# Zone:schedule:macroTask:setTimeout("::ProxyZone::WTF::TestZone"'); - }, null, null, 'unit-test'); + }, null, undefined, 'unit-test'); }); it('should allow canceling of fns registered with setTimeout', function(done) { @@ -116,7 +116,7 @@ describe('setTimeout', function() { }); it('should pass invalid values through', function() { - clearTimeout(null); + clearTimeout(null as any); clearTimeout({}); }); diff --git a/test/common/task.spec.ts b/test/common/task.spec.ts index da1286244..6cac1f41c 100644 --- a/test/common/task.spec.ts +++ b/test/common/task.spec.ts @@ -9,7 +9,7 @@ const noop = function() {}; let log: {zone: string, taskZone: undefined | string, toState: TaskState, fromState: TaskState}[] = []; -const detectTask = Zone.current.scheduleMacroTask('detectTask', noop, null, noop, noop); +const detectTask = Zone.current.scheduleMacroTask('detectTask', noop, undefined, noop, noop); const originalTransitionTo = detectTask.constructor.prototype._transitionTo; // patch _transitionTo of ZoneTask to add log for test const logTransitionTo: Function = function( @@ -40,7 +40,7 @@ describe('task lifecycle', () => { it('task should transit from notScheduled to scheduling then to scheduled state when scheduleTask', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { - Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); }); expect(log.map(item => { return {toState: item.toState, fromState: item.fromState}; @@ -62,7 +62,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); } catch (err) { } }); @@ -78,7 +78,8 @@ describe('task lifecycle', () => { it('task should transit from scheduled to running when task is invoked then from running to scheduled after invoke', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { - const task = Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + const task = + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); task.invoke(); }); expect(log.map(item => { @@ -95,7 +96,8 @@ describe('task lifecycle', () => { it('task should transit from scheduled to canceling then from canceling to notScheduled when task is canceled before running', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { - const task = Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + const task = + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); Zone.current.cancelTask(task); }); expect(log.map(item => { @@ -114,7 +116,7 @@ describe('task lifecycle', () => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { const task = Zone.current.scheduleEventTask('testEventTask', () => { Zone.current.cancelTask(task); - }, null, noop, noop); + }, undefined, noop, noop); task.invoke(); }); expect(log.map(item => { @@ -134,7 +136,7 @@ describe('task lifecycle', () => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { const task = Zone.current.scheduleEventTask('testEventTask', () => { throw Error('invoke error'); - }, null, noop, noop); + }, undefined, noop, noop); try { task.invoke(); } catch (err) { @@ -154,9 +156,10 @@ describe('task lifecycle', () => { it('task should transit from canceling to unknown when zoneSpec.onCancelTask throw error before task running', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { - const task = Zone.current.scheduleEventTask('testEventTask', noop, null, noop, () => { - throw Error('cancel task'); - }); + const task = + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, () => { + throw Error('cancel task'); + }); try { Zone.current.cancelTask(task); } catch (err) { @@ -176,9 +179,10 @@ describe('task lifecycle', () => { it('task should transit from canceling to unknown when zoneSpec.onCancelTask throw error in running state', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testEventTaskZone'}).run(() => { - const task = Zone.current.scheduleEventTask('testEventTask', noop, null, noop, () => { - throw Error('cancel task'); - }); + const task = + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, () => { + throw Error('cancel task'); + }); try { Zone.current.cancelTask(task); } catch (err) { @@ -206,7 +210,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); } catch (err) { } }); @@ -233,7 +237,8 @@ describe('task lifecycle', () => { }) .run(() => { try { - task = Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + task = + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); Zone.current.cancelTask(task); } catch (err) { } @@ -258,7 +263,7 @@ describe('task lifecycle', () => { it('task should transit from notScheduled to scheduling then to scheduled state when scheduleTask', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { - Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, noop); + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, noop); }); expect(log.map(item => { return {toState: item.toState, fromState: item.fromState}; @@ -280,7 +285,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, noop); + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, noop); } catch (err) { } }); @@ -296,7 +301,8 @@ describe('task lifecycle', () => { it('task should transit from scheduled to running when task is invoked then from running to noScheduled after invoke', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { - const task = Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, noop); + const task = + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, noop); task.invoke(); }); expect(log.map(item => { @@ -313,7 +319,8 @@ describe('task lifecycle', () => { it('task should transit from scheduled to canceling then from canceling to notScheduled when task is canceled before running', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { - const task = Zone.current.scheduleMacroTask('testMacrotask', noop, null, noop, noop); + const task = + Zone.current.scheduleMacroTask('testMacrotask', noop, undefined, noop, noop); Zone.current.cancelTask(task); }); expect(log.map(item => { @@ -332,7 +339,7 @@ describe('task lifecycle', () => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { const task = Zone.current.scheduleMacroTask('testMacroTask', () => { Zone.current.cancelTask(task); - }, null, noop, noop); + }, undefined, noop, noop); task.invoke(); }); expect(log.map(item => { @@ -352,7 +359,7 @@ describe('task lifecycle', () => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { const task = Zone.current.scheduleMacroTask('testMacroTask', () => { throw Error('invoke error'); - }, null, noop, noop); + }, undefined, noop, noop); try { task.invoke(); } catch (err) { @@ -372,9 +379,10 @@ describe('task lifecycle', () => { it('task should transit from canceling to unknown when zoneSpec.onCancelTask throw error before task running', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { - const task = Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, () => { - throw Error('cancel task'); - }); + const task = + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, () => { + throw Error('cancel task'); + }); try { Zone.current.cancelTask(task); } catch (err) { @@ -394,9 +402,10 @@ describe('task lifecycle', () => { it('task should transit from canceling to unknown when zoneSpec.onCancelTask throw error in running state', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMacroTaskZone'}).run(() => { - const task = Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, () => { - throw Error('cancel task'); - }); + const task = + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, () => { + throw Error('cancel task'); + }); try { Zone.current.cancelTask(task); } catch (err) { @@ -424,7 +433,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, noop); + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, noop); } catch (err) { } }); @@ -451,7 +460,8 @@ describe('task lifecycle', () => { }) .run(() => { try { - task = Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, noop); + task = + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, noop); task.invoke(); } catch (err) { } @@ -481,7 +491,8 @@ describe('task lifecycle', () => { }) .run(() => { try { - task = Zone.current.scheduleMacroTask('testMacroTask', noop, null, noop, noop); + task = + Zone.current.scheduleMacroTask('testMacroTask', noop, undefined, noop, noop); Zone.current.cancelTask(task); } catch (err) { } @@ -499,7 +510,7 @@ describe('task lifecycle', () => { }); describe('periodical macroTask lifecycle', () => { - let task: Task; + let task: Task|null; beforeEach(() => { log = []; task = null; @@ -589,7 +600,7 @@ describe('task lifecycle', () => { testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testPeriodicalTaskZone'}).run(() => { task = Zone.current.scheduleMacroTask('testPeriodicalTask', () => { - Zone.current.cancelTask(task); + Zone.current.cancelTask(task!); }, {isPeriodic: true}, noop, noop); task.invoke(); }); @@ -737,7 +748,7 @@ describe('task lifecycle', () => { it('task should transit from notScheduled to scheduling then to scheduled state when scheduleTask', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMicroTaskZone'}).run(() => { - Zone.current.scheduleMicroTask('testMicroTask', noop, null, noop); + Zone.current.scheduleMicroTask('testMicroTask', noop, undefined, noop); }); expect(log.map(item => { return {toState: item.toState, fromState: item.fromState}; @@ -759,7 +770,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - Zone.current.scheduleMicroTask('testMicroTask', noop, null, noop); + Zone.current.scheduleMicroTask('testMicroTask', noop, undefined, noop); } catch (err) { } }); @@ -775,7 +786,7 @@ describe('task lifecycle', () => { it('task should transit from scheduled to running when task is invoked then from running to noScheduled after invoke', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMicroTaskZone'}).run(() => { - const task = Zone.current.scheduleMicroTask('testMicroTask', noop, null, noop); + const task = Zone.current.scheduleMicroTask('testMicroTask', noop, undefined, noop); task.invoke(); }); expect(log.map(item => { @@ -791,7 +802,7 @@ describe('task lifecycle', () => { it('should throw error when try to cancel a microTask', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'testMicroTaskZone'}).run(() => { - const task = Zone.current.scheduleMicroTask('testMicroTask', () => {}, null, noop); + const task = Zone.current.scheduleMicroTask('testMicroTask', () => {}, undefined, noop); expect(() => { Zone.current.cancelTask(task); }).toThrowError('Task is not cancelable'); @@ -803,7 +814,7 @@ describe('task lifecycle', () => { Zone.current.fork({name: 'testMicroTaskZone'}).run(() => { const task = Zone.current.scheduleMicroTask('testMicroTask', () => { throw Error('invoke error'); - }, null, noop); + }, undefined, noop); try { task.invoke(); } catch (err) { @@ -831,7 +842,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - Zone.current.scheduleMicroTask('testMicroTask', noop, null, noop); + Zone.current.scheduleMicroTask('testMicroTask', noop, undefined, noop); } catch (err) { } }); @@ -858,7 +869,7 @@ describe('task lifecycle', () => { }) .run(() => { try { - task = Zone.current.scheduleMicroTask('testMicroTask', noop, null, noop); + task = Zone.current.scheduleMicroTask('testMicroTask', noop, undefined, noop); task.invoke(); } catch (err) { } @@ -878,7 +889,8 @@ describe('task lifecycle', () => { testFnWithLoggedTransitionTo(() => { let task: Task; Zone.current.fork({name: 'testCancelZone'}).run(() => { - const task = Zone.current.scheduleEventTask('testEventTask', noop, null, noop, noop); + const task = + Zone.current.scheduleEventTask('testEventTask', noop, undefined, noop, noop); Zone.current.cancelTask(task); task.invoke(); }); @@ -955,8 +967,8 @@ describe('task lifecycle', () => { it('should be able to reschedule zone when in scheduling state, after that, task will completely go to new zone, has nothing to do with original one', testFnWithLoggedTransitionTo(() => { zone.run(() => { - const t = - Zone.current.scheduleMacroTask('testRescheduleZoneTask', noop, null, noop, noop); + const t = Zone.current.scheduleMacroTask( + 'testRescheduleZoneTask', noop, undefined, noop, noop); t.invoke(); }); @@ -978,8 +990,8 @@ describe('task lifecycle', () => { it('should not be able to reschedule task in notScheduled / running / canceling state', testFnWithLoggedTransitionTo(() => { Zone.current.fork({name: 'rescheduleNotScheduled'}).run(() => { - const t = - Zone.current.scheduleMacroTask('testRescheduleZoneTask', noop, null, noop, noop); + const t = Zone.current.scheduleMacroTask( + 'testRescheduleZoneTask', noop, undefined, noop, noop); Zone.current.cancelTask(t); expect(() => { t.cancelScheduleRequest(); @@ -1002,8 +1014,8 @@ describe('task lifecycle', () => { } }) .run(() => { - const t = - Zone.current.scheduleMacroTask('testRescheduleZoneTask', noop, null, noop, noop); + const t = Zone.current.scheduleMacroTask( + 'testRescheduleZoneTask', noop, undefined, noop, noop); t.invoke(); }); @@ -1020,8 +1032,8 @@ describe('task lifecycle', () => { } }) .run(() => { - const t = - Zone.current.scheduleMacroTask('testRescheduleZoneTask', noop, null, noop, noop); + const t = Zone.current.scheduleMacroTask( + 'testRescheduleZoneTask', noop, undefined, noop, noop); Zone.current.cancelTask(t); }); })); @@ -1051,7 +1063,7 @@ describe('task lifecycle', () => { const rescheduleZone = originalZone.fork({name: 'rescheduleZone'}); expect(() => { originalZone.run(() => { - Zone.current.scheduleMacroTask('testRescheduleZoneTask', noop, null, noop, noop); + Zone.current.scheduleMacroTask('testRescheduleZoneTask', noop, undefined, noop, noop); }); }) .toThrowError( diff --git a/test/common/util.spec.ts b/test/common/util.spec.ts index b6b122d10..605a21248 100644 --- a/test/common/util.spec.ts +++ b/test/common/util.spec.ts @@ -33,14 +33,14 @@ describe('utils', function() { return function(self, args) { return delegate.apply(self, ['patch', args[0]]); }; - })).toBe(delegateMethod); + })).toBe(delegateMethod!); expect(instance.method('a0')).toEqual('OK'); expect(args).toEqual(['patch', 'a0']); expect(self).toBe(instance); - expect(delegateMethod).toBe(method); - expect(delegateSymbol).toEqual(zoneSymbol('method')); - expect((Type.prototype as any)[delegateSymbol]).toBe(method); + expect(delegateMethod!).toBe(method); + expect(delegateSymbol!).toEqual(zoneSymbol('method')); + expect((Type.prototype as any)[delegateSymbol!]).toBe(method); }); it('should not double patch', () => { @@ -75,8 +75,8 @@ describe('utils', function() { } patchProperty(TestType.prototype, 'nonConfigurableProperty'); const desc = Object.getOwnPropertyDescriptor(TestType.prototype, 'nonConfigurableProperty'); - expect(desc.writable).toBeTruthy(); - expect(!desc.get).toBeTruthy(); + expect(desc!.writable).toBeTruthy(); + expect(!desc!.get).toBeTruthy(); }); }); diff --git a/test/common/zone.spec.ts b/test/common/zone.spec.ts index f969df913..3b9b79bd1 100644 --- a/test/common/zone.spec.ts +++ b/test/common/zone.spec.ts @@ -101,7 +101,7 @@ describe('Zone', function() { Zone.current.fork({name: 'testZone'}).run(function() { Zone.root.fork({name: 'newTestZone'}).run(() => { expect(Zone.current.name).toEqual('newTestZone'); - expect(Zone.current.parent.name).toEqual(''); + expect(Zone.current.parent!.name).toEqual(''); }); }); }); @@ -143,7 +143,7 @@ describe('Zone', function() { it('task can only run in the zone of creation', () => { const task = - zone.fork({name: 'createZone'}).scheduleMacroTask('test', noop, null, noop, noop); + zone.fork({name: 'createZone'}).scheduleMacroTask('test', noop, undefined, noop, noop); expect(() => { Zone.current.fork({name: 'anotherZone'}).runTask(task); }) @@ -154,7 +154,7 @@ describe('Zone', function() { it('task can only cancel in the zone of creation', () => { const task = - zone.fork({name: 'createZone'}).scheduleMacroTask('test', noop, null, noop, noop); + zone.fork({name: 'createZone'}).scheduleMacroTask('test', noop, undefined, noop, noop); expect(() => { Zone.current.fork({name: 'anotherZone'}).cancelTask(task); }) @@ -164,7 +164,8 @@ describe('Zone', function() { }); it('should prevent double cancellation', () => { - const task = zone.scheduleMacroTask('test', () => log.push('macroTask'), null, noop, noop); + const task = + zone.scheduleMacroTask('test', () => log.push('macroTask'), undefined, noop, noop); zone.cancelTask(task); try { zone.cancelTask(task); @@ -198,8 +199,10 @@ describe('Zone', function() { zone.run(() => { const z = Zone.current; z.runTask(z.scheduleMicroTask('test', () => log.push('microTask'))); - z.cancelTask(z.scheduleMacroTask('test', () => log.push('macroTask'), null, noop, noop)); - z.cancelTask(z.scheduleEventTask('test', () => log.push('eventTask'), null, noop, noop)); + z.cancelTask( + z.scheduleMacroTask('test', () => log.push('macroTask'), undefined, noop, noop)); + z.cancelTask( + z.scheduleEventTask('test', () => log.push('eventTask'), undefined, noop, noop)); }); expect(log).toEqual([ {microTask: true, macroTask: false, eventTask: false, change: 'microTask', zone: 'parent'}, @@ -316,7 +319,7 @@ describe('Zone', function() { const task = zone.scheduleEventTask('testEventTask', () => { zone.cancelTask(task); - }, null, () => {}, () => {}); + }, undefined, () => {}, () => {}); task.invoke(); expect(task.state).toBe('notScheduled'); @@ -361,7 +364,7 @@ describe('Zone', function() { it('should not drain the microtask queue too early', () => { const z = Zone.current; - const event = z.scheduleEventTask('test', () => log.push('eventTask'), null, noop, noop); + const event = z.scheduleEventTask('test', () => log.push('eventTask'), undefined, noop, noop); z.scheduleMicroTask('test', () => log.push('microTask')); @@ -369,16 +372,16 @@ describe('Zone', function() { event.invoke(); // At this point, we should not have invoked the microtask. expect(log).toEqual(['eventTask']); - }, null, noop, noop); + }, undefined, noop, noop); macro.invoke(); }); it('should convert task to json without cyclic error', () => { const z = Zone.current; - const event = z.scheduleEventTask('test', () => {}, null, noop, noop); + const event = z.scheduleEventTask('test', () => {}, undefined, noop, noop); const micro = z.scheduleMicroTask('test', () => {}); - const macro = z.scheduleMacroTask('test', () => {}, null, noop, noop); + const macro = z.scheduleMacroTask('test', () => {}, undefined, noop, noop); expect(function() { JSON.stringify(event); }).not.toThrow(); @@ -405,7 +408,7 @@ describe('Zone', function() { } }); - const microTask = hasTaskZone.scheduleMicroTask('test', () => {}, null, () => {}); + const microTask = hasTaskZone.scheduleMicroTask('test', () => {}, undefined, () => {}); expect(spy).toHaveBeenCalledWith('onHasTask Error'); }); }); diff --git a/test/jasmine-patch.spec.ts b/test/jasmine-patch.spec.ts index c7fc9be7d..71ecf240f 100644 --- a/test/jasmine-patch.spec.ts +++ b/test/jasmine-patch.spec.ts @@ -22,11 +22,11 @@ ifEnvSupports(supportJasmineSpec, () => { describe('jasmine', () => { let throwOnAsync = false; - let beforeEachZone: Zone = null; - let itZone: Zone = null; + let beforeEachZone: Zone|null = null; + let itZone: Zone|null = null; const syncZone = Zone.current; try { - Zone.current.scheduleMicroTask('dontallow', () => null as void); + Zone.current.scheduleMicroTask('dontallow', (): any => null); } catch (e) { throwOnAsync = true; } @@ -44,7 +44,7 @@ ifEnvSupports(supportJasmineSpec, () => { afterEach(() => { let zone = Zone.current; expect(zone.name).toEqual('ProxyZone'); - expect(beforeEachZone.name).toEqual(zone.name); + expect(beforeEachZone!.name).toEqual(zone.name); expect(itZone).toBe(zone); }); }); diff --git a/test/mocha-patch.spec.ts b/test/mocha-patch.spec.ts index 54c47bcd0..1a583ab8d 100644 --- a/test/mocha-patch.spec.ts +++ b/test/mocha-patch.spec.ts @@ -25,17 +25,17 @@ ifEnvSupports('Mocha', function() { describe('Mocha BDD-style', () => { let throwOnAsync = false; - let beforeEachZone: Zone = null; - let itZone: Zone = null; + let beforeEachZone: Zone|null = null; + let itZone: Zone|null = null; const syncZone = Zone.current; - let beforeZone: Zone = null; + let beforeZone: Zone|null = null; before(() => { beforeZone = Zone.current; }); try { - Zone.current.scheduleMicroTask('dontallow', () => null as void); + Zone.current.scheduleMicroTask('dontallow', (): any => null); } catch (e) { throwOnAsync = true; } @@ -62,9 +62,9 @@ ifEnvSupports('Mocha', function() { }); suite('Mocha TDD-style', () => { - let testZone: Zone = null; - let beforeEachZone: Zone = null; - let suiteSetupZone: Zone = null; + let testZone: Zone|null = null; + let beforeEachZone: Zone|null = null; + let suiteSetupZone: Zone|null = null; suiteSetup(() => { suiteSetupZone = Zone.current; diff --git a/test/rxjs/rxjs.Observable.notification.spec.ts b/test/rxjs/rxjs.Observable.notification.spec.ts index 6bc561005..c87ffb5fd 100644 --- a/test/rxjs/rxjs.Observable.notification.spec.ts +++ b/test/rxjs/rxjs.Observable.notification.spec.ts @@ -30,7 +30,7 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => { const notifA = new Rx.Notification('N', 'A'); const notifB = new Rx.Notification('N', 'B'); const notifE = new Rx.Notification('E', void 0, error); - const materialized = Rx.Observable.of(notifA, notifB, notifE); + const materialized = Rx.Observable.of(notifA, notifB, notifE as any); return materialized.dematerialize(); }); diff --git a/test/rxjs/rxjs.bindCallback.spec.ts b/test/rxjs/rxjs.bindCallback.spec.ts index fb52dea78..ca0cb708e 100644 --- a/test/rxjs/rxjs.bindCallback.spec.ts +++ b/test/rxjs/rxjs.bindCallback.spec.ts @@ -70,7 +70,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func, null, Rx.Scheduler.asap); + boundFunc = Rx.Observable.bindCallback(func, undefined, Rx.Scheduler.asap); observable = boundFunc('test'); }); diff --git a/test/rxjs/rxjs.bindNodeCallback.spec.ts b/test/rxjs/rxjs.bindNodeCallback.spec.ts index 90c8002f8..5bcc0b023 100644 --- a/test/rxjs/rxjs.bindNodeCallback.spec.ts +++ b/test/rxjs/rxjs.bindNodeCallback.spec.ts @@ -70,7 +70,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindCallback(func, null, Rx.Scheduler.asap); + boundFunc = Rx.Observable.bindCallback(func, undefined, Rx.Scheduler.asap); observable = boundFunc('test'); }); diff --git a/test/test-util.ts b/test/test-util.ts index 77907f522..5a58cf8bd 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -42,7 +42,7 @@ function _ifEnvSupports(test: any, block: Function, withDone = false) { } } -function _runTest(test: any, block: Function, done: Function) { +function _runTest(test: any, block: Function, done?: Function) { const message = (test.message || test.name || test); if (typeof test === 'string' ? !!global[test] : test()) { if (done) { diff --git a/test/zone-spec/long-stack-trace-zone.spec.ts b/test/zone-spec/long-stack-trace-zone.spec.ts index 4515c2965..779fba53e 100644 --- a/test/zone-spec/long-stack-trace-zone.spec.ts +++ b/test/zone-spec/long-stack-trace-zone.spec.ts @@ -54,7 +54,7 @@ describe( setTimeout(function() { setTimeout(function() { setTimeout(function() { - expectElapsed(log[0].stack, 3); + expectElapsed(log[0].stack!, 3); done(); }, 0); throw new Error('Hello'); @@ -72,7 +72,7 @@ describe( document.body.appendChild(button); button.addEventListener('click', function() { - expectElapsed(log[0].stack, 1); + expectElapsed(log[0].stack!, 1); }); button.dispatchEvent(clickEvent); @@ -116,7 +116,7 @@ describe( fail('should not get here'); }); setTimeout(function() { - expectElapsed(log[0].stack, 5); + expectElapsed(log[0].stack!, 5); done(); }, 0); }, 0); @@ -155,7 +155,7 @@ describe( setTimeout(function() { setTimeout(function() { if (log[0].stack) { - expectElapsed(log[0].stack, 1); + expectElapsed(log[0].stack!, 1); } Error.stackTraceLimit = originalStackTraceLimit; done(); diff --git a/test/zone-spec/proxy.spec.ts b/test/zone-spec/proxy.spec.ts index 950353fef..2285855fb 100644 --- a/test/zone-spec/proxy.spec.ts +++ b/test/zone-spec/proxy.spec.ts @@ -136,7 +136,7 @@ describe('ProxySpec', () => { }); it('should Task', () => { - const fn = () => null as void; + const fn = (): any => null; const task = proxyZone.scheduleMacroTask('test', fn, {}, () => null, () => null); expect(task.source).toEqual('test'); proxyZone.cancelTask(task); diff --git a/test/zone-spec/task-tracking.spec.ts b/test/zone-spec/task-tracking.spec.ts index 1c7115d2a..9c824bfe7 100644 --- a/test/zone-spec/task-tracking.spec.ts +++ b/test/zone-spec/task-tracking.spec.ts @@ -12,7 +12,7 @@ declare const global: any; describe('TaskTrackingZone', function() { let _TaskTrackingZoneSpec: typeof TaskTrackingZoneSpec = (Zone as any)['TaskTrackingZoneSpec']; - let taskTrackingZoneSpec: TaskTrackingZoneSpec = null; + let taskTrackingZoneSpec: TaskTrackingZoneSpec|null = null; let taskTrackingZone: Zone; beforeEach(() => { @@ -23,19 +23,19 @@ describe('TaskTrackingZone', function() { it('should track tasks', (done: Function) => { taskTrackingZone.run(() => { taskTrackingZone.scheduleMicroTask('test1', () => {}); - expect(taskTrackingZoneSpec.microTasks.length).toBe(1); - expect(taskTrackingZoneSpec.microTasks[0].source).toBe('test1'); + expect(taskTrackingZoneSpec!.microTasks.length).toBe(1); + expect(taskTrackingZoneSpec!.microTasks[0].source).toBe('test1'); setTimeout(() => {}); - expect(taskTrackingZoneSpec.macroTasks.length).toBe(1); - expect(taskTrackingZoneSpec.macroTasks[0].source).toBe('setTimeout'); - taskTrackingZone.cancelTask(taskTrackingZoneSpec.macroTasks[0]); - expect(taskTrackingZoneSpec.macroTasks.length).toBe(0); + expect(taskTrackingZoneSpec!.macroTasks.length).toBe(1); + expect(taskTrackingZoneSpec!.macroTasks[0].source).toBe('setTimeout'); + taskTrackingZone.cancelTask(taskTrackingZoneSpec!.macroTasks[0]); + expect(taskTrackingZoneSpec!.macroTasks.length).toBe(0); setTimeout(() => { // assert on execution it is null - expect(taskTrackingZoneSpec.macroTasks.length).toBe(0); - expect(taskTrackingZoneSpec.microTasks.length).toBe(0); + expect(taskTrackingZoneSpec!.macroTasks.length).toBe(0); + expect(taskTrackingZoneSpec!.microTasks.length).toBe(0); // If a browser does not have XMLHttpRequest, then end test here. if (typeof global['XMLHttpRequest'] == 'undefined') return done(); @@ -45,22 +45,22 @@ describe('TaskTrackingZone', function() { if (xhr.readyState == 4) { // clear current event tasks using setTimeout setTimeout(() => { - expect(taskTrackingZoneSpec.macroTasks.length).toBe(0); - expect(taskTrackingZoneSpec.microTasks.length).toBe(0); + expect(taskTrackingZoneSpec!.macroTasks.length).toBe(0); + expect(taskTrackingZoneSpec!.microTasks.length).toBe(0); if (supportPatchXHROnProperty()) { - expect(taskTrackingZoneSpec.eventTasks.length).not.toBe(0); + expect(taskTrackingZoneSpec!.eventTasks.length).not.toBe(0); } - taskTrackingZoneSpec.clearEvents(); - expect(taskTrackingZoneSpec.eventTasks.length).toBe(0); + taskTrackingZoneSpec!.clearEvents(); + expect(taskTrackingZoneSpec!.eventTasks.length).toBe(0); done(); }); } }; xhr.send(); - expect(taskTrackingZoneSpec.macroTasks.length).toBe(1); - expect(taskTrackingZoneSpec.macroTasks[0].source).toBe('XMLHttpRequest.send'); + expect(taskTrackingZoneSpec!.macroTasks.length).toBe(1); + expect(taskTrackingZoneSpec!.macroTasks[0].source).toBe('XMLHttpRequest.send'); if (supportPatchXHROnProperty()) { - expect(taskTrackingZoneSpec.eventTasks[0].source) + expect(taskTrackingZoneSpec!.eventTasks[0].source) .toMatch(/\.addEventListener:readystatechange/); } }); @@ -72,7 +72,7 @@ describe('TaskTrackingZone', function() { setTimeout(() => { done(); }); - expect((taskTrackingZoneSpec.macroTasks[0] as any)['creationLocation']).toBeTruthy(); + expect((taskTrackingZoneSpec!.macroTasks[0] as any)['creationLocation']).toBeTruthy(); }); }); }); diff --git a/tsconfig-esm-node.json b/tsconfig-esm-node.json index 8aecae97e..8a79dc143 100644 --- a/tsconfig-esm-node.json +++ b/tsconfig-esm-node.json @@ -14,7 +14,12 @@ "sourceMap": true, "downlevelIteration": true, "moduleResolution": "node", - "lib": ["es5", "dom", "es2015.promise"] + "strict": true, + "lib": [ + "es5", + "dom", + "es2015.promise" + ] }, "exclude": [ "node_modules", @@ -23,4 +28,4 @@ "dist", "lib/closure" ] -} +} \ No newline at end of file diff --git a/tsconfig-esm.json b/tsconfig-esm.json index 5dbdd52d2..ab2416b2d 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -14,7 +14,12 @@ "stripInternal": true, "sourceMap": true, "moduleResolution": "node", - "lib": ["es5", "dom", "es2015.promise"] + "strict": true, + "lib": [ + "es5", + "dom", + "es2015.promise" + ] }, "exclude": [ "node_modules", @@ -23,4 +28,4 @@ "dist", "lib/closure" ] -} +} \ No newline at end of file diff --git a/tsconfig-node.json b/tsconfig-node.json index 4e5512c20..eca611773 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -12,7 +12,12 @@ "downlevelIteration": true, "noEmitOnError": false, "stripInternal": false, - "lib": ["es5", "dom", "es2015.promise"] + "strict": true, + "lib": [ + "es5", + "dom", + "es2015.promise" + ] }, "exclude": [ "node_modules", @@ -21,4 +26,4 @@ "dist", "lib/closure" ] -} +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7303adf3a..ec1d893a9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,9 +11,12 @@ "declaration": false, "noEmitOnError": false, "stripInternal": false, - // TODO: turn this on. - "strict": false, - "lib": ["es5", "dom", "es2015.promise"] + "strict": true, + "lib": [ + "es5", + "dom", + "es2015.promise" + ] }, "exclude": [ "node_modules", From f238908c9e7a9739e2d2b03348feb5b500823e24 Mon Sep 17 00:00:00 2001 From: "JiaLi.Passion" Date: Thu, 3 May 2018 15:12:23 +0800 Subject: [PATCH 048/106] fix(format): update clang-format to 1.2.3 --- lib/browser/define-property.ts | 4 +- lib/browser/webapis-media-query.ts | 2 +- lib/browser/webapis-resize-observer.ts | 79 +- lib/common/events.ts | 1 - lib/common/promise.ts | 10 +- lib/extra/bluebird.ts | 33 +- lib/extra/jsonp.ts | 12 +- lib/jasmine/jasmine.ts | 3 +- lib/mocha/mocha.ts | 5 +- lib/node/node.ts | 1 - lib/rxjs/rxjs-fake-async.ts | 2 +- lib/rxjs/rxjs.ts | 6 +- lib/testing/fake-async.ts | 34 +- lib/testing/promise-testing.ts | 46 +- lib/zone-spec/fake-async-test.ts | 925 +++++++++---------- lib/zone-spec/wtf.ts | 254 +++-- lib/zone.ts | 72 +- package.json | 2 +- test/browser/HTMLImports.spec.ts | 1 - test/browser/XMLHttpRequest.spec.ts | 15 +- test/browser/browser.spec.ts | 297 +++--- test/browser/define-property.spec.ts | 2 - test/browser/element.spec.ts | 2 - test/browser/registerElement.spec.ts | 16 +- test/browser/requestAnimationFrame.spec.ts | 90 +- test/closure/zone.closure.ts | 18 +- test/common/Error.spec.ts | 2 +- test/common/Promise.spec.ts | 74 +- test/common/setInterval.spec.ts | 2 - test/common/setTimeout.spec.ts | 1 - test/common/task.spec.ts | 3 +- test/common/toString.spec.ts | 3 +- test/common/util.spec.ts | 1 - test/common/zone.spec.ts | 18 +- test/extra/bluebird.spec.ts | 95 +- test/main.ts | 2 +- test/mocha-patch.spec.ts | 24 +- test/node/crypto.spec.ts | 12 +- test/node/fs.spec.ts | 12 +- test/node/http.spec.ts | 6 +- test/node/process.spec.ts | 22 +- test/rxjs/rxjs.Observable.merge.spec.ts | 2 +- test/rxjs/rxjs.fromEvent.spec.ts | 154 ++- test/test-env-setup-mocha.ts | 4 +- test/test_fake_polyfill.ts | 116 +-- test/ws-webworker-context.ts | 6 +- test/wtf_mock.ts | 138 +-- test/zone-spec/async-test.spec.ts | 2 - test/zone-spec/fake-async-test.spec.ts | 9 +- test/zone-spec/long-stack-trace-zone.spec.ts | 13 +- test/zone-spec/proxy.spec.ts | 44 +- yarn.lock | 12 +- 52 files changed, 1359 insertions(+), 1350 deletions(-) diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index daffc6d12..872e86ea9 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -103,8 +103,8 @@ function _tryDefineProperty(obj: any, prop: string, desc: any, originalConfigura } catch (error) { descJson = desc.toString(); } - console.log(`Attempting to configure '${prop}' with descriptor '${descJson - }' on object '${obj}' and got error, giving up: ${error}`); + console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${ + obj}' and got error, giving up: ${error}`); } } else { throw error; diff --git a/lib/browser/webapis-media-query.ts b/lib/browser/webapis-media-query.ts index 8db02cd0b..7ca46e171 100644 --- a/lib/browser/webapis-media-query.ts +++ b/lib/browser/webapis-media-query.ts @@ -53,7 +53,7 @@ Zone.__load_patch('mediaQuery', (global: any, Zone: ZoneType, api: _ZonePrivate) patchAddListener(mql); patchRemoveListener(mql); } else if (mql['addListener']) { - // proto not exists, or proto has no addListener method + // proto not exists, or proto has no addListener method // try to patch mql instance patchAddListener(mql); patchRemoveListener(mql); diff --git a/lib/browser/webapis-resize-observer.ts b/lib/browser/webapis-resize-observer.ts index cfaa70f0b..8e7f73643 100644 --- a/lib/browser/webapis-resize-observer.ts +++ b/lib/browser/webapis-resize-observer.ts @@ -45,44 +45,49 @@ Zone.__load_patch('ResizeObserver', (global: any, Zone: any, api: _ZonePrivate) return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); }); - api.patchMethod(ResizeObserver.prototype, 'observe', (delegate: Function) => (self: any, args: any[]) => { - const target = args.length > 0 ? args[0] : null; - if (!target) { - return delegate.apply(self, args); - } - let targets = self[resizeObserverSymbol]; - if (!targets) { - targets = self[resizeObserverSymbol] = []; - } - targets.push(target); - target[resizeObserverSymbol] = Zone.current; - return delegate.apply(self, args); - }); + api.patchMethod( + ResizeObserver.prototype, 'observe', (delegate: Function) => (self: any, args: any[]) => { + const target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + let targets = self[resizeObserverSymbol]; + if (!targets) { + targets = self[resizeObserverSymbol] = []; + } + targets.push(target); + target[resizeObserverSymbol] = Zone.current; + return delegate.apply(self, args); + }); - api.patchMethod(ResizeObserver.prototype, 'unobserve', (delegate: Function) => (self: any, args: any[]) => { - const target = args.length > 0 ? args[0] : null; - if (!target) { - return delegate.apply(self, args); - } - let targets = self[resizeObserverSymbol]; - if (targets) { - for (let i = 0; i < targets.length; i ++) { - if (targets[i] === target) { - targets.splice(i, 1); - break; + api.patchMethod( + ResizeObserver.prototype, 'unobserve', (delegate: Function) => (self: any, args: any[]) => { + const target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); } - } - } - target[resizeObserverSymbol] = undefined; - return delegate.apply(self, args); - }); + let targets = self[resizeObserverSymbol]; + if (targets) { + for (let i = 0; i < targets.length; i++) { + if (targets[i] === target) { + targets.splice(i, 1); + break; + } + } + } + target[resizeObserverSymbol] = undefined; + return delegate.apply(self, args); + }); - api.patchMethod(ResizeObserver.prototype, 'disconnect', (delegate: Function) => (self: any, args: any[]) => { - const targets = self[resizeObserverSymbol]; - if (targets) { - targets.forEach((target: any) => {target[resizeObserverSymbol] = undefined;}); - self[resizeObserverSymbol] = undefined; - } - return delegate.apply(self, args); - }); + api.patchMethod( + ResizeObserver.prototype, 'disconnect', (delegate: Function) => (self: any, args: any[]) => { + const targets = self[resizeObserverSymbol]; + if (targets) { + targets.forEach((target: any) => { + target[resizeObserverSymbol] = undefined; + }); + self[resizeObserverSymbol] = undefined; + } + return delegate.apply(self, args); + }); }); diff --git a/lib/common/events.ts b/lib/common/events.ts index e3078529d..b2e7074f6 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -285,7 +285,6 @@ export function patchEventTarget( const typeOfDelegate = typeof delegate; return (typeOfDelegate === 'function' && task.callback === delegate) || (typeOfDelegate === 'object' && task.originalDelegate === delegate); - }; const compare = diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 35eccc1f1..c59dffdd2 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -34,9 +34,9 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if (rejection) { console.error( 'Unhandled Promise rejection:', - rejection instanceof Error ? rejection.message : rejection, '; Zone:', - (e.zone).name, '; Task:', e.task && (e.task).source, '; Value:', rejection, - rejection instanceof Error ? rejection.stack : undefined); + rejection instanceof Error ? rejection.message : rejection, + '; Zone:', (e.zone).name, '; Task:', e.task && (e.task).source, + '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); } else { console.error(e); } @@ -239,8 +239,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr function scheduleResolveOrReject( promise: ZoneAwarePromise, zone: AmbientZone, chainPromise: ZoneAwarePromise, - onFulfilled?: ((value: R) => U1) | null | undefined, - onRejected?: ((error: any) => U2) | null | undefined): void { + onFulfilled?: ((value: R) => U1)|null|undefined, + onRejected?: ((error: any) => U2)|null|undefined): void { clearRejectedNoCatch(promise); const promiseState = (promise as any)[symbolState]; const delegate = promiseState ? diff --git a/lib/extra/bluebird.ts b/lib/extra/bluebird.ts index 13a0496ea..5fd00d3b6 100644 --- a/lib/extra/bluebird.ts +++ b/lib/extra/bluebird.ts @@ -16,22 +16,23 @@ Zone.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) = // patch method of Bluebird.prototype which not using `then` internally const bluebirdApis: string[] = ['then', 'spread', 'finally']; bluebirdApis.forEach(bapi => { - api.patchMethod(Bluebird.prototype, bapi, (delegate: Function) => (self: any, args: any[]) => { - const zone = Zone.current; - for (let i = 0; i < args.length; i ++) { - const func = args[i]; - if (typeof func === 'function') { - args[i] = function() { - const argSelf: any = this; - const argArgs: any = arguments; - zone.scheduleMicroTask('Promise.then', () => { - return func.apply(argSelf, argArgs); - }); - }; - } - } - return delegate.apply(self, args); - }); + api.patchMethod( + Bluebird.prototype, bapi, (delegate: Function) => (self: any, args: any[]) => { + const zone = Zone.current; + for (let i = 0; i < args.length; i++) { + const func = args[i]; + if (typeof func === 'function') { + args[i] = function() { + const argSelf: any = this; + const argArgs: any = arguments; + zone.scheduleMicroTask('Promise.then', () => { + return func.apply(argSelf, argArgs); + }); + }; + } + } + return delegate.apply(self, args); + }); }); // override global promise diff --git a/lib/extra/jsonp.ts b/lib/extra/jsonp.ts index 3b2166081..95532ce17 100644 --- a/lib/extra/jsonp.ts +++ b/lib/extra/jsonp.ts @@ -68,10 +68,12 @@ Zone.__load_patch('jsonp', (global: any, Zone: ZoneType, api: _ZonePrivate) => { } }); - api.patchMethod(options.jsonp, options.sendFuncName, (delegate: Function) => (self: any, args: any[]) => { - global[api.symbol('jsonpTask')] = Zone.current.scheduleMacroTask('jsonp', noop, {}, (task: Task) => { - return delegate.apply(self, args); - }, noop); - }); + api.patchMethod( + options.jsonp, options.sendFuncName, (delegate: Function) => (self: any, args: any[]) => { + global[api.symbol('jsonpTask')] = + Zone.current.scheduleMacroTask('jsonp', noop, {}, (task: Task) => { + return delegate.apply(self, args); + }, noop); + }); }; }); diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index bbf68bc2c..33b0654c7 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -177,7 +177,8 @@ (jasmine as any).QueueRunner = (function(_super) { __extends(ZoneQueueRunner, _super); function ZoneQueueRunner(attrs: { - onComplete: Function; userContext?: any; + onComplete: Function; + userContext?: any; timeout?: {setTimeout: Function; clearTimeout: Function}; onException?: (error: any) => void; }) { diff --git a/lib/mocha/mocha.ts b/lib/mocha/mocha.ts index 2b99a66c1..c5ccd19cc 100644 --- a/lib/mocha/mocha.ts +++ b/lib/mocha/mocha.ts @@ -161,7 +161,7 @@ testZone = rootZone.fork(new ProxyZoneSpec()); }); - this.on('fail', (test:any, err: any) => { + this.on('fail', (test: any, err: any) => { const proxyZoneSpec = testZone && testZone.get('ProxyZoneSpec'); if (proxyZoneSpec && err) { err.message += proxyZoneSpec.getAndClearPendingTasksInfo(); @@ -170,8 +170,5 @@ return originalRun.call(this, fn); }; - - })(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run); - })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/lib/node/node.ts b/lib/node/node.ts index b4ab2f9e6..fcb35edc6 100644 --- a/lib/node/node.ts +++ b/lib/node/node.ts @@ -111,7 +111,6 @@ Zone.__load_patch( }); }; } - }); diff --git a/lib/rxjs/rxjs-fake-async.ts b/lib/rxjs/rxjs-fake-async.ts index b5bb44bd9..85ef31dc7 100644 --- a/lib/rxjs/rxjs-fake-async.ts +++ b/lib/rxjs/rxjs-fake-async.ts @@ -7,8 +7,8 @@ */ import {Scheduler} from 'rxjs/Scheduler'; -import {async} from 'rxjs/scheduler/async'; import {asap} from 'rxjs/scheduler/asap'; +import {async} from 'rxjs/scheduler/async'; Zone.__load_patch('rxjs.Scheduler.now', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchMethod(Scheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { diff --git a/lib/rxjs/rxjs.ts b/lib/rxjs/rxjs.ts index 71344a460..b8e5340a1 100644 --- a/lib/rxjs/rxjs.ts +++ b/lib/rxjs/rxjs.ts @@ -30,8 +30,10 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; const empty = { closed: true, next(value: any): void{}, - error(err: any): void{throw err;}, - complete(): void{} + error(err: any): void { + throw err; + }, + complete(): void {} }; function toSubscriber( diff --git a/lib/testing/fake-async.ts b/lib/testing/fake-async.ts index 72e934f02..b240e1c0d 100644 --- a/lib/testing/fake-async.ts +++ b/lib/testing/fake-async.ts @@ -33,23 +33,23 @@ Zone.__load_patch('fakeasync', (global: any, Zone: ZoneType, api: _ZonePrivate) } /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ function fakeAsync(fn: Function): (...args: any[]) => any { // Not using an arrow function to preserve context passed from call site return function(...args: any[]) { diff --git a/lib/testing/promise-testing.ts b/lib/testing/promise-testing.ts index f16a7120f..e37ab6e88 100644 --- a/lib/testing/promise-testing.ts +++ b/lib/testing/promise-testing.ts @@ -6,30 +6,30 @@ * found in the LICENSE file at https://angular.io/license */ - /** - * Promise for async/fakeAsync zoneSpec test - * can support async operation which not supported by zone.js - * such as - * it ('test jsonp in AsyncZone', async() => { - * new Promise(res => { - * jsonp(url, (data) => { - * // success callback - * res(data); - * }); - * }).then((jsonpResult) => { - * // get jsonp result. - * - * // user will expect AsyncZoneSpec wait for - * // then, but because jsonp is not zone aware - * // AsyncZone will finish before then is called. - * }); - * }); - */ +/** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ Zone.__load_patch('promisefortest', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const symbolState: string = api.symbol('state'); const UNRESOLVED: null = null; const symbolParentUnresolved = api.symbol('parentUnresolved'); - + // patch Promise.prototype.then to keep an internal // number for tracking unresolved chained promise // we will decrease this number when the parent promise @@ -44,15 +44,15 @@ Zone.__load_patch('promisefortest', (global: any, Zone: ZoneType, api: _ZonePriv } oriThen = (Promise as any)[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; Promise.prototype.then = function() { - const chained = oriThen.apply(this, arguments); + const chained = oriThen.apply(this, arguments); if (this[symbolState] === UNRESOLVED) { // parent promise is unresolved. const asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); if (asyncTestZoneSpec) { - asyncTestZoneSpec.unresolvedChainedPromiseCount ++; + asyncTestZoneSpec.unresolvedChainedPromiseCount++; chained[symbolParentUnresolved] = true; } - } + } return chained; }; }; diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index bdf7187c9..724ce68fa 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -7,556 +7,553 @@ */ (function(global: any) { - interface ScheduledFunction { - endTime: number; - id: number; - func: Function; - args: any[]; - delay: number; - isPeriodic: boolean; - isRequestAnimationFrame: boolean; - } - - interface MicroTaskScheduledFunction { - func: Function; - args?: any[]; - target: any; - } - - interface MacroTaskOptions { - source: string; - isPeriodic?: boolean; - callbackArgs?: any; - } - - const OriginalDate = global.Date; - class FakeDate { - constructor() { - if (arguments.length === 0) { - const d = new OriginalDate(); - d.setTime(FakeDate.now()); - return d; - } else { - const args = Array.prototype.slice.call(arguments); - return new OriginalDate(...args); - } - } - - static now() { - const fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncTestZoneSpec) { - return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); - } - return OriginalDate.now.apply(this, arguments); +interface ScheduledFunction { + endTime: number; + id: number; + func: Function; + args: any[]; + delay: number; + isPeriodic: boolean; + isRequestAnimationFrame: boolean; +} + +interface MicroTaskScheduledFunction { + func: Function; + args?: any[]; + target: any; +} + +interface MacroTaskOptions { + source: string; + isPeriodic?: boolean; + callbackArgs?: any; +} + +const OriginalDate = global.Date; +class FakeDate { + constructor() { + if (arguments.length === 0) { + const d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } else { + const args = Array.prototype.slice.call(arguments); + return new OriginalDate(...args); } } - (FakeDate as any).UTC = OriginalDate.UTC; - (FakeDate as any).parse = OriginalDate.parse; - - // keep a reference for zone patched timer function - const timers = { - setTimeout: global.setTimeout, - setInterval: global.setInterval, - clearTimeout: global.clearTimeout, - clearInterval: global.clearInterval - }; - - class Scheduler { - // Next scheduler id. - public nextId: number = 1; - - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - private _schedulerQueue: ScheduledFunction[] = []; - // Current simulated time in millis. - private _currentTime: number = 0; - // Current real time in millis. - private _currentRealTime: number = OriginalDate.now(); - - constructor() {} - - getCurrentTime() { - return this._currentTime; - } - - getCurrentRealTime() { - return this._currentRealTime; + static now() { + const fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); } + return OriginalDate.now.apply(this, arguments); + } +} + +(FakeDate as any).UTC = OriginalDate.UTC; +(FakeDate as any).parse = OriginalDate.parse; + +// keep a reference for zone patched timer function +const timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval +}; + +class Scheduler { + // Next scheduler id. + public nextId: number = 1; + + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + private _schedulerQueue: ScheduledFunction[] = []; + // Current simulated time in millis. + private _currentTime: number = 0; + // Current real time in millis. + private _currentRealTime: number = OriginalDate.now(); + + constructor() {} + + getCurrentTime() { + return this._currentTime; + } - setCurrentRealTime(realTime: number) { - this._currentRealTime = realTime; - } + getCurrentRealTime() { + return this._currentRealTime; + } - scheduleFunction( - cb: Function, delay: number, args: any[] = [], isPeriodic: boolean = false, - isRequestAnimationFrame: boolean = false, 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, - isPeriodic: isPeriodic, - isRequestAnimationFrame: isRequestAnimationFrame - }; - let i = 0; - for (; i < this._schedulerQueue.length; i++) { - let currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; - } - } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - } + setCurrentRealTime(realTime: number) { + this._currentRealTime = realTime; + } - removeScheduledFunctionWithId(id: number): void { - for (let i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; - } + scheduleFunction( + cb: Function, delay: number, args: any[] = [], isPeriodic: boolean = false, + isRequestAnimationFrame: boolean = false, 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, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + let i = 0; + for (; i < this._schedulerQueue.length; i++) { + let currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; } } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + } - tick(millis: number = 0, doTick?: (elapsed: number) => void): void { - let finalTime = this._currentTime + millis; - let lastCurrentTime = 0; - if (this._schedulerQueue.length === 0 && doTick) { - doTick(millis); - return; - } - while (this._schedulerQueue.length > 0) { - let current = this._schedulerQueue[0]; - if (finalTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. - break; - } else { - // Time to run scheduled function. Remove it from the head of queue. - let current = this._schedulerQueue.shift()!; - lastCurrentTime = this._currentTime; - this._currentTime = current.endTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - let retval = current.func.apply(global, current.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } + removeScheduledFunctionWithId(id: number): void { + for (let i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; } - this._currentTime = finalTime; } + } - flush(limit = 20, flushPeriodic = false, doTick?: (elapsed: number) => void): number { - if (flushPeriodic) { - return this.flushPeriodic(doTick); + tick(millis: number = 0, doTick?: (elapsed: number) => void): void { + let finalTime = this._currentTime + millis; + let lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + let current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; } else { - return this.flushNonPeriodic(limit, doTick); - } - } - - private flushPeriodic(doTick?: (elapsed: number) => void): number { - if (this._schedulerQueue.length === 0) { - return 0; - } - // Find the last task currently queued in the scheduler queue and tick - // till that time. - const startTime = this._currentTime; - const lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; - this.tick(lastTask.endTime - startTime, doTick); - return this._currentTime - startTime; - } - - private flushNonPeriodic(limit: number, doTick?: (elapsed: number) => void): number { - const startTime = this._currentTime; - let lastCurrentTime = 0; - let count = 0; - while (this._schedulerQueue.length > 0) { - count++; - if (count > limit) { - throw new Error( - 'flush failed after reaching the limit of ' + limit + - ' tasks. Does your code use a polling timeout?'); - } - - // flush only non-periodic timers. - // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. - if (this._schedulerQueue.filter(task => !task.isPeriodic && !task.isRequestAnimationFrame) - .length === 0) { - break; - } - - const current = this._schedulerQueue.shift()!; + // Time to run scheduled function. Remove it from the head of queue. + let current = this._schedulerQueue.shift()!; lastCurrentTime = this._currentTime; this._currentTime = current.endTime; if (doTick) { - // Update any secondary schedulers like Jasmine mock Date. doTick(this._currentTime - lastCurrentTime); } - const retval = current.func.apply(global, current.args); + let retval = current.func.apply(global, current.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; } } - return this._currentTime - startTime; } + this._currentTime = finalTime; } - class FakeAsyncTestZoneSpec implements ZoneSpec { - static assertInZone(): void { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } + flush(limit = 20, flushPeriodic = false, doTick?: (elapsed: number) => void): number { + if (flushPeriodic) { + return this.flushPeriodic(doTick); + } else { + return this.flushNonPeriodic(limit, doTick); } + } - private _scheduler: Scheduler = new Scheduler(); - private _microtasks: MicroTaskScheduledFunction[] = []; - private _lastError: Error|null = null; - private _uncaughtPromiseErrors: {rejection: any}[] = - (Promise as any)[(Zone as any).__symbol__('uncaughtPromiseErrors')]; - - pendingPeriodicTimers: number[] = []; - pendingTimers: number[] = []; - - private patchDateLocked = false; - - constructor( - namePrefix: string, private trackPendingRequestAnimationFrame = false, - private macroTaskOptions?: MacroTaskOptions[]) { - this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakeAsyncTestSpec - // user can also define macroTaskOptions by define a global variable. - if (!this.macroTaskOptions) { - this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; - } + private flushPeriodic(doTick?: (elapsed: number) => void): number { + if (this._schedulerQueue.length === 0) { + return 0; } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + const startTime = this._currentTime; + const lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + } - private _fnAndFlush(fn: Function, completers: {onSuccess?: Function, onError?: Function}): - Function { - return (...args: any[]): boolean => { - fn.apply(global, args); + private flushNonPeriodic(limit: number, doTick?: (elapsed: number) => void): number { + const startTime = this._currentTime; + let lastCurrentTime = 0; + let count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error( + 'flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } - if (this._lastError === null) { // Success - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); - } - // Flush microtasks only on success. - this.flushMicrotasks(); - } else { // Failure - if (completers.onError != null) { - completers.onError.apply(global); - } - } - // Return true if there were no errors, false otherwise. - return this._lastError === null; - }; - } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(task => !task.isPeriodic && !task.isRequestAnimationFrame) + .length === 0) { + break; + } - private static _removeTimer(timers: number[], id: number): void { - let index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); + const current = this._schedulerQueue.shift()!; + lastCurrentTime = this._currentTime; + this._currentTime = current.endTime; + if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. + doTick(this._currentTime - lastCurrentTime); + } + const retval = current.func.apply(global, current.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; } } + return this._currentTime - startTime; + } +} - private _dequeueTimer(id: number): Function { - return () => { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - }; +class FakeAsyncTestZoneSpec implements ZoneSpec { + static assertInZone(): void { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); } + } - private _requeuePeriodicTimer(fn: Function, interval: number, args: any[], id: number): - Function { - return () => { - // Requeue the timer callback if it's not been canceled. - if (this.pendingPeriodicTimers.indexOf(id) !== -1) { - this._scheduler.scheduleFunction(fn, interval, args, true, false, id); - } - }; - } + private _scheduler: Scheduler = new Scheduler(); + private _microtasks: MicroTaskScheduledFunction[] = []; + private _lastError: Error|null = null; + private _uncaughtPromiseErrors: {rejection: any}[] = + (Promise as any)[(Zone as any).__symbol__('uncaughtPromiseErrors')]; + + pendingPeriodicTimers: number[] = []; + pendingTimers: number[] = []; + + private patchDateLocked = false; - private _dequeuePeriodicTimer(id: number): Function { - return () => { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - }; + constructor( + namePrefix: string, private trackPendingRequestAnimationFrame = false, + private macroTaskOptions?: MacroTaskOptions[]) { + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; } + } + + private _fnAndFlush(fn: Function, completers: {onSuccess?: Function, onError?: Function}): + Function { + return (...args: any[]): boolean => { + fn.apply(global, args); - private _setTimeout(fn: Function, delay: number, args: any[], isTimer = true): number { - let removeTimerFn = this._dequeueTimer(this._scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - let cb = this._fnAndFlush(fn, {onSuccess: removeTimerFn, onError: removeTimerFn}); - let id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); - if (isTimer) { - this.pendingTimers.push(id); + if (this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + this.flushMicrotasks(); + } else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } } - return id; + // Return true if there were no errors, false otherwise. + return this._lastError === null; + }; + } + + private static _removeTimer(timers: number[], id: number): void { + let index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); } + } - private _clearTimeout(id: number): void { + private _dequeueTimer(id: number): Function { + return () => { FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - } + }; + } - private _setInterval(fn: Function, interval: number, args: any[]): number { - let id = this._scheduler.nextId; - let completers = {onSuccess: null as any, onError: this._dequeuePeriodicTimer(id)}; - let cb = this._fnAndFlush(fn, completers); + private _requeuePeriodicTimer(fn: Function, interval: number, args: any[], id: number): Function { + return () => { + // Requeue the timer callback if it's not been canceled. + if (this.pendingPeriodicTimers.indexOf(id) !== -1) { + this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + } + }; + } - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + private _dequeuePeriodicTimer(id: number): Function { + return () => { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + }; + } - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args, true); - this.pendingPeriodicTimers.push(id); - return id; + private _setTimeout(fn: Function, delay: number, args: any[], isTimer = true): number { + let removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + let cb = this._fnAndFlush(fn, {onSuccess: removeTimerFn, onError: removeTimerFn}); + let id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); } + return id; + } - private _clearInterval(id: number): void { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - } + private _clearTimeout(id: number): void { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + } - private _resetLastErrorAndThrow(): void { - let error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - } + private _setInterval(fn: Function, interval: number, args: any[]): number { + let id = this._scheduler.nextId; + let completers = {onSuccess: null as any, onError: this._dequeuePeriodicTimer(id)}; + let cb = this._fnAndFlush(fn, completers); - getCurrentTime() { - return this._scheduler.getCurrentTime(); - } + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - getCurrentRealTime() { - return this._scheduler.getCurrentRealTime(); - } + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + } - setCurrentRealTime(realTime: number) { - this._scheduler.setCurrentRealTime(realTime); - } + private _clearInterval(id: number): void { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + } - static patchDate() { - if (global['Date'] === FakeDate) { - // already patched - return; - } - global['Date'] = FakeDate; - FakeDate.prototype = OriginalDate.prototype; + private _resetLastErrorAndThrow(): void { + let error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + } - // try check and reset timers - // because jasmine.clock().install() may - // have replaced the global timer - FakeAsyncTestZoneSpec.checkTimerPatch(); - } + getCurrentTime() { + return this._scheduler.getCurrentTime(); + } - static resetDate() { - if (global['Date'] === FakeDate) { - global['Date'] = OriginalDate; - } + getCurrentRealTime() { + return this._scheduler.getCurrentRealTime(); + } + + setCurrentRealTime(realTime: number) { + this._scheduler.setCurrentRealTime(realTime); + } + + static patchDate() { + if (global['Date'] === FakeDate) { + // already patched + return; } + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; - static checkTimerPatch() { - if (global.setTimeout !== timers.setTimeout) { - global.setTimeout = timers.setTimeout; - global.clearTimeout = timers.clearTimeout; - } - if (global.setInterval !== timers.setInterval) { - global.setInterval = timers.setInterval; - global.clearInterval = timers.clearInterval; - } + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); + } + + static resetDate() { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; } + } - lockDatePatch() { - this.patchDateLocked = true; - FakeAsyncTestZoneSpec.patchDate(); + static checkTimerPatch() { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; } - unlockDatePatch() { - this.patchDateLocked = false; - FakeAsyncTestZoneSpec.resetDate(); + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; } + } - tick(millis: number = 0, doTick?: (elapsed: number) => void): void { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - } + lockDatePatch() { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + } + unlockDatePatch() { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + } - flushMicrotasks(): void { - FakeAsyncTestZoneSpec.assertInZone(); - const flushErrors = () => { - if (this._lastError !== null || this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - this._resetLastErrorAndThrow(); - } - }; - while (this._microtasks.length > 0) { - let microtask = this._microtasks.shift()!; - microtask.func.apply(microtask.target, microtask.args); - } - flushErrors(); + tick(millis: number = 0, doTick?: (elapsed: number) => void): void { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); } + } - flush(limit?: number, flushPeriodic?: boolean, doTick?: (elapsed: number) => void): number { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - const elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); - if (this._lastError !== null) { + flushMicrotasks(): void { + FakeAsyncTestZoneSpec.assertInZone(); + const flushErrors = () => { + if (this._lastError !== null || this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. this._resetLastErrorAndThrow(); } - return elapsed; + }; + while (this._microtasks.length > 0) { + let microtask = this._microtasks.shift()!; + microtask.func.apply(microtask.target, microtask.args); } + flushErrors(); + } - // ZoneSpec implementation below. + flush(limit?: number, flushPeriodic?: boolean, doTick?: (elapsed: number) => void): number { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + const elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + } - name: string; + // ZoneSpec implementation below. - properties: {[key: string]: any} = {'FakeAsyncTestZoneSpec': this}; + name: string; - onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task { - switch (task.type) { - case 'microTask': - let args = task.data && (task.data as any).args; - // should pass additional arguments to callback if have any - // currently we know process.nextTick will have such additional - // arguments - let additionalArgs: any[]|undefined; - if (args) { - let callbackIndex = (task.data as any).cbIdx; - if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); - } + properties: {[key: string]: any} = {'FakeAsyncTestZoneSpec': this}; + + onScheduleTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): Task { + switch (task.type) { + case 'microTask': + let args = task.data && (task.data as any).args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + let additionalArgs: any[]|undefined; + if (args) { + let callbackIndex = (task.data as any).cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } - this._microtasks.push({ - func: task.invoke, - args: additionalArgs, - target: task.data && (task.data as any).target - }); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data!['handleId'] = this._setTimeout( - task.invoke, task.data!['delay']!, - Array.prototype.slice.call((task.data as any)['args'], 2)); - break; - case 'setImmediate': - task.data!['handleId'] = this._setTimeout( - task.invoke, 0, Array.prototype.slice.call((task.data as any)['args'], 1)); - break; - case 'setInterval': - task.data!['handleId'] = this._setInterval( - task.invoke, task.data!['delay']!, - Array.prototype.slice.call((task.data as any)['args'], 2)); - break; - case 'XMLHttpRequest.send': - throw new Error( - 'Cannot make XHRs from within a fake async test. Request URL: ' + - (task.data as any)['url']); - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. - // (60 frames per second) - task.data!['handleId'] = this._setTimeout( - task.invoke, 16, (task.data as any)['args'], - this.trackPendingRequestAnimationFrame); - break; - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - const macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - const args = task.data && (task.data as any)['args']; - const delay = args && args.length > 1 ? args[1] : 0; - let callbackArgs = - macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args; - if (!!macroTaskOption.isPeriodic) { - // periodic macroTask, use setInterval to simulate - task.data!['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data!.isPeriodic = true; - } else { - // not periodic, use setTimeout to simulate - task.data!['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); - } - break; + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && (task.data as any).target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data!['handleId'] = this._setTimeout( + task.invoke, task.data!['delay']!, + Array.prototype.slice.call((task.data as any)['args'], 2)); + break; + case 'setImmediate': + task.data!['handleId'] = this._setTimeout( + task.invoke, 0, Array.prototype.slice.call((task.data as any)['args'], 1)); + break; + case 'setInterval': + task.data!['handleId'] = this._setInterval( + task.invoke, task.data!['delay']!, + Array.prototype.slice.call((task.data as any)['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error( + 'Cannot make XHRs from within a fake async test. Request URL: ' + + (task.data as any)['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data!['handleId'] = this._setTimeout( + task.invoke, 16, (task.data as any)['args'], + this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + const macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + const args = task.data && (task.data as any)['args']; + const delay = args && args.length > 1 ? args[1] : 0; + let callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data!['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data!.isPeriodic = true; + } else { + // not periodic, use setTimeout to simulate + task.data!['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); } - throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); - } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; } + return task; + } - onCancelTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): any { - switch (task.source) { - case 'setTimeout': - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data!['handleId']); - case 'setInterval': - return this._clearInterval(task.data!['handleId']); - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - const macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - const handleId: number = task.data!['handleId']; - return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : - this._clearTimeout(handleId); - } - return delegate.cancelTask(target, task); - } + onCancelTask(delegate: ZoneDelegate, current: Zone, target: Zone, task: Task): any { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data!['handleId']); + case 'setInterval': + return this._clearInterval(task.data!['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + const macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + const handleId: number = task.data!['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); } + } - onInvoke( - delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, - applyArgs?: any[], source?: string): any { - try { - FakeAsyncTestZoneSpec.patchDate(); - return delegate.invoke(target, callback, applyThis, applyArgs, source); - } finally { - if (!this.patchDateLocked) { - FakeAsyncTestZoneSpec.resetDate(); - } + onInvoke( + delegate: ZoneDelegate, current: Zone, target: Zone, callback: Function, applyThis: any, + applyArgs?: any[], source?: string): any { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); } } + } - findMacroTaskOption(task: Task) { - if (!this.macroTaskOptions) { - return null; - } - for (let i = 0; i < this.macroTaskOptions.length; i++) { - const macroTaskOption = this.macroTaskOptions[i]; - if (macroTaskOption.source === task.source) { - return macroTaskOption; - } - } + findMacroTaskOption(task: Task) { + if (!this.macroTaskOptions) { return null; } - - onHandleError( - parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - error: any): boolean { - this._lastError = error; - return false; // Don't propagate error to parent zone. + for (let i = 0; i < this.macroTaskOptions.length; i++) { + const macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; + } } + return null; + } + + onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): + boolean { + this._lastError = error; + return false; // Don't propagate error to parent zone. } +} - // Export the class so that new instances can be created with proper - // constructor params. - (Zone as any)['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; +// Export the class so that new instances can be created with proper +// constructor params. +(Zone as any)['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; })(typeof window === 'object' && window || typeof self === 'object' && self || global); diff --git a/lib/zone-spec/wtf.ts b/lib/zone-spec/wtf.ts index 4a6c6694c..2053cdb75 100644 --- a/lib/zone-spec/wtf.ts +++ b/lib/zone-spec/wtf.ts @@ -11,151 +11,149 @@ */ (function(global: any) { - interface Wtf { - trace: WtfTrace; - } - interface WtfScope {} - interface WtfRange {} - interface WtfTrace { - events: WtfEvents; - leaveScope(scope: WtfScope, returnValue?: any): void; - beginTimeRange(rangeType: string, action: string): WtfRange; - endTimeRange(range: WtfRange): void; +interface Wtf { + trace: WtfTrace; +} +interface WtfScope {} +interface WtfRange {} +interface WtfTrace { + events: WtfEvents; + leaveScope(scope: WtfScope, returnValue?: any): void; + beginTimeRange(rangeType: string, action: string): WtfRange; + endTimeRange(range: WtfRange): void; +} +interface WtfEvents { + createScope(signature: string, flags?: any): WtfScopeFn; + createInstance(signature: string, flags?: any): WtfEventFn; +} + +type WtfScopeFn = (...args: any[]) => WtfScope; +type WtfEventFn = (...args: any[]) => any; + +// Detect and setup WTF. +let wtfTrace: WtfTrace|null = null; +let wtfEvents: WtfEvents|null = null; +const wtfEnabled: boolean = (function(): boolean { + const wtf: Wtf = global['wtf']; + if (wtf) { + wtfTrace = wtf.trace; + if (wtfTrace) { + wtfEvents = wtfTrace.events; + return true; + } } - interface WtfEvents { - createScope(signature: string, flags?: any): WtfScopeFn; - createInstance(signature: string, flags?: any): WtfEventFn; + return false; +})(); + +class WtfZoneSpec implements ZoneSpec { + name: string = 'WTF'; + + static forkInstance = + wtfEnabled ? wtfEvents!.createInstance('Zone:fork(ascii zone, ascii newZone)') : null; + static scheduleInstance: {[key: string]: WtfEventFn} = {}; + static cancelInstance: {[key: string]: WtfEventFn} = {}; + static invokeScope: {[key: string]: WtfEventFn} = {}; + static invokeTaskScope: {[key: string]: WtfEventFn} = {}; + + onFork(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, zoneSpec: ZoneSpec): + Zone { + const retValue = parentZoneDelegate.fork(targetZone, zoneSpec); + WtfZoneSpec.forkInstance!(zonePathName(targetZone), retValue.name); + return retValue; } - type WtfScopeFn = (...args: any[]) => WtfScope; - type WtfEventFn = (...args: any[]) => any; - - // Detect and setup WTF. - let wtfTrace: WtfTrace|null = null; - let wtfEvents: WtfEvents|null = null; - const wtfEnabled: boolean = (function(): boolean { - const wtf: Wtf = global['wtf']; - if (wtf) { - wtfTrace = wtf.trace; - if (wtfTrace) { - wtfEvents = wtfTrace.events; - return true; - } - } - return false; - })(); - - class WtfZoneSpec implements ZoneSpec { - name: string = 'WTF'; - - static forkInstance = - wtfEnabled ? wtfEvents!.createInstance('Zone:fork(ascii zone, ascii newZone)') : null; - static scheduleInstance: {[key: string]: WtfEventFn} = {}; - static cancelInstance: {[key: string]: WtfEventFn} = {}; - static invokeScope: {[key: string]: WtfEventFn} = {}; - static invokeTaskScope: {[key: string]: WtfEventFn} = {}; - - onFork( - parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - zoneSpec: ZoneSpec): Zone { - const retValue = parentZoneDelegate.fork(targetZone, zoneSpec); - WtfZoneSpec.forkInstance!(zonePathName(targetZone), retValue.name); - return retValue; - } - - onInvoke( - parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, - applyThis: any, applyArgs?: any[], source?: string): any { - const src = source || 'unknown'; - let scope = WtfZoneSpec.invokeScope[src]; - if (!scope) { - scope = WtfZoneSpec.invokeScope[src] = - wtfEvents!.createScope(`Zone:invoke:${source}(ascii zone)`); - } - return wtfTrace!.leaveScope( - scope(zonePathName(targetZone)), - parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); + onInvoke( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, + applyThis: any, applyArgs?: any[], source?: string): any { + const src = source || 'unknown'; + let scope = WtfZoneSpec.invokeScope[src]; + if (!scope) { + scope = WtfZoneSpec.invokeScope[src] = + wtfEvents!.createScope(`Zone:invoke:${source}(ascii zone)`); } + return wtfTrace!.leaveScope( + scope(zonePathName(targetZone)), + parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); + } - onHandleError( - parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - error: any): boolean { - return parentZoneDelegate.handleError(targetZone, error); - } + onHandleError(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): + boolean { + return parentZoneDelegate.handleError(targetZone, error); + } - onScheduleTask( - parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): any { - const key = task.type + ':' + task.source; - let instance = WtfZoneSpec.scheduleInstance[key]; - if (!instance) { - instance = WtfZoneSpec.scheduleInstance[key] = - wtfEvents!.createInstance(`Zone:schedule:${key}(ascii zone, any data)`); - } - const retValue = parentZoneDelegate.scheduleTask(targetZone, task); - instance(zonePathName(targetZone), shallowObj(task.data, 2)); - return retValue; + onScheduleTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any { + const key = task.type + ':' + task.source; + let instance = WtfZoneSpec.scheduleInstance[key]; + if (!instance) { + instance = WtfZoneSpec.scheduleInstance[key] = + wtfEvents!.createInstance(`Zone:schedule:${key}(ascii zone, any data)`); } + const retValue = parentZoneDelegate.scheduleTask(targetZone, task); + instance(zonePathName(targetZone), shallowObj(task.data, 2)); + return retValue; + } - onInvokeTask( - parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, - applyThis?: any, applyArgs?: any[]): any { - const source = task.source; - let scope = WtfZoneSpec.invokeTaskScope[source]; - if (!scope) { - scope = WtfZoneSpec.invokeTaskScope[source] = - wtfEvents!.createScope(`Zone:invokeTask:${source}(ascii zone)`); - } - return wtfTrace!.leaveScope( - scope(zonePathName(targetZone)), - parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); + onInvokeTask( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, + applyThis?: any, applyArgs?: any[]): any { + const source = task.source; + let scope = WtfZoneSpec.invokeTaskScope[source]; + if (!scope) { + scope = WtfZoneSpec.invokeTaskScope[source] = + wtfEvents!.createScope(`Zone:invokeTask:${source}(ascii zone)`); } + return wtfTrace!.leaveScope( + scope(zonePathName(targetZone)), + parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); + } - onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): - any { - const key = task.source; - let instance = WtfZoneSpec.cancelInstance[key]; - if (!instance) { - instance = WtfZoneSpec.cancelInstance[key] = - wtfEvents!.createInstance(`Zone:cancel:${key}(ascii zone, any options)`); - } - const retValue = parentZoneDelegate.cancelTask(targetZone, task); - instance(zonePathName(targetZone), shallowObj(task.data, 2)); - return retValue; + onCancelTask(parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any { + const key = task.source; + let instance = WtfZoneSpec.cancelInstance[key]; + if (!instance) { + instance = WtfZoneSpec.cancelInstance[key] = + wtfEvents!.createInstance(`Zone:cancel:${key}(ascii zone, any options)`); } + const retValue = parentZoneDelegate.cancelTask(targetZone, task); + instance(zonePathName(targetZone), shallowObj(task.data, 2)); + return retValue; } - - function shallowObj(obj: {[k: string]: any}|undefined, depth: number): any { - if (!obj || !depth) return null; - const out: {[k: string]: any} = {}; - for (const key in obj) { - if (obj.hasOwnProperty(key)) { - let value = obj[key]; - switch (typeof value) { - case 'object': - const name = value && value.constructor && (value.constructor).name; - value = name == (Object).name ? shallowObj(value, depth - 1) : name; - break; - case 'function': - value = value.name || undefined; - break; - } - out[key] = value; +} + +function shallowObj(obj: {[k: string]: any}|undefined, depth: number): any { + if (!obj || !depth) return null; + const out: {[k: string]: any} = {}; + for (const key in obj) { + if (obj.hasOwnProperty(key)) { + let value = obj[key]; + switch (typeof value) { + case 'object': + const name = value && value.constructor && (value.constructor).name; + value = name == (Object).name ? shallowObj(value, depth - 1) : name; + break; + case 'function': + value = value.name || undefined; + break; } + out[key] = value; } - return out; } - - function zonePathName(zone: Zone) { - let name: string = zone.name; - let localZone = zone.parent; - while (localZone != null) { - name = localZone.name + '::' + name; - localZone = localZone.parent; - } - return name; + return out; +} + +function zonePathName(zone: Zone) { + let name: string = zone.name; + let localZone = zone.parent; + while (localZone != null) { + name = localZone.name + '::' + name; + localZone = localZone.parent; } + return name; +} - (Zone as any)['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); +(Zone as any)['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); })(typeof window === 'object' && window || typeof self === 'object' && self || global); diff --git a/lib/zone.ts b/lib/zone.ts index c8dc24f4b..dba7b1ee8 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -827,8 +827,8 @@ const Zone: ZoneType = (function(global: any) { let newZone: any = this; while (newZone) { if (newZone === task.zone) { - throw Error(`can not reschedule task to ${this - .name} which is descendants of the original zone ${task.zone.name}`); + throw Error(`can not reschedule task to ${ + this.name} which is descendants of the original zone ${task.zone.name}`); } newZone = newZone.parent; } @@ -911,15 +911,18 @@ const Zone: ZoneType = (function(global: any) { const DELEGATE_ZS: ZoneSpec = { name: '', - onHasTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, - hasTaskState: HasTaskState): void => delegate.hasTask(target, hasTaskState), - onScheduleTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, - task: Task): Task => delegate.scheduleTask(target, task), - onInvokeTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, task: Task, - applyThis: any, applyArgs: any): any => - delegate.invokeTask(target, task, applyThis, applyArgs), + onHasTask: + (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, + hasTaskState: HasTaskState): void => delegate.hasTask(target, hasTaskState), + onScheduleTask: + (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, task: Task): Task => + delegate.scheduleTask(target, task), + onInvokeTask: + (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, task: Task, + applyThis: any, applyArgs: any): any => + delegate.invokeTask(target, task, applyThis, applyArgs), onCancelTask: (delegate: AmbientZoneDelegate, _: AmbientZone, target: AmbientZone, task: Task): - any => delegate.cancelTask(target, task) + any => delegate.cancelTask(target, task) }; class ZoneDelegate implements AmbientZoneDelegate { @@ -1051,25 +1054,24 @@ const Zone: ZoneType = (function(global: any) { intercept(targetZone: Zone, callback: Function, source: string): Function { return this._interceptZS ? - this._interceptZS.onIntercept!( - this._interceptDlgt!, this._interceptCurrZone!, targetZone, callback, source) : + this._interceptZS.onIntercept! + (this._interceptDlgt!, this._interceptCurrZone!, 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._invokeCurrZone!, targetZone, callback, applyThis, applyArgs, - source) : - callback.apply(applyThis, applyArgs); + return this._invokeZS ? this._invokeZS.onInvoke! + (this._invokeDlgt!, this._invokeCurrZone!, targetZone, callback, + applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); } handleError(targetZone: Zone, error: any): boolean { return this._handleErrorZS ? - this._handleErrorZS.onHandleError!( - this._handleErrorDlgt!, this._handleErrorCurrZone!, targetZone, error) : + this._handleErrorZS.onHandleError! + (this._handleErrorDlgt!, this._handleErrorCurrZone!, targetZone, error) : true; } @@ -1079,9 +1081,9 @@ const Zone: ZoneType = (function(global: any) { if (this._hasTaskZS) { returnTask._zoneDelegates!.push(this._hasTaskDlgtOwner!); } - returnTask = this._scheduleTaskZS.onScheduleTask!( - this._scheduleTaskDlgt!, this._scheduleTaskCurrZone!, targetZone, - task) as ZoneTask; + returnTask = this._scheduleTaskZS.onScheduleTask! + (this._scheduleTaskDlgt!, this._scheduleTaskCurrZone!, targetZone, task) as + ZoneTask; if (!returnTask) returnTask = task as ZoneTask; } else { if (task.scheduleFn) { @@ -1096,18 +1098,17 @@ const Zone: ZoneType = (function(global: any) { } invokeTask(targetZone: Zone, task: Task, applyThis: any, applyArgs?: any[]): any { - return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask!( - this._invokeTaskDlgt!, this._invokeTaskCurrZone!, targetZone, task, applyThis, - applyArgs) : - task.callback.apply(applyThis, applyArgs); + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask! + (this._invokeTaskDlgt!, this._invokeTaskCurrZone!, targetZone, + task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); } cancelTask(targetZone: Zone, task: Task): any { let value: any; if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask!( - this._cancelTaskDlgt!, this._cancelTaskCurrZone!, targetZone, task); + value = this._cancelTaskZS.onCancelTask! + (this._cancelTaskDlgt!, this._cancelTaskCurrZone!, targetZone, task); } else { if (!task.cancelFn) { throw Error('Task is not cancelable'); @@ -1122,8 +1123,8 @@ const Zone: ZoneType = (function(global: any) { // can still trigger hasTask callback try { this._hasTaskZS && - this._hasTaskZS.onHasTask!( - this._hasTaskDlgt!, this._hasTaskCurrZone!, targetZone, isEmpty); + this._hasTaskZS.onHasTask! + (this._hasTaskDlgt!, this._hasTaskCurrZone!, targetZone, isEmpty); } catch (err) { this.handleError(targetZone, err); } @@ -1216,12 +1217,9 @@ const Zone: ZoneType = (function(global: any) { this._zoneDelegates = null; } } else { - throw new Error( - `${this.type} '${this.source}': can not transition to '${toState - }', expecting state '${fromState1}'${fromState2 ? - ' or \'' + fromState2 + '\'' : - '' - }, was '${this._state}'.`); + throw new Error(`${this.type} '${this.source}': can not transition to '${ + toState}', expecting state '${fromState1}'${ + fromState2 ? ' or \'' + fromState2 + '\'' : ''}, was '${this._state}'.`); } } diff --git a/package.json b/package.json index b93ffc01b..15f16822b 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "@types/systemjs": "^0.19.30", "assert": "^1.4.1", "bluebird": "^3.5.1", - "clang-format": "1.0.46", + "clang-format": "^1.2.3", "concurrently": "^2.2.0", "conventional-changelog": "^1.1.7", "es6-promise": "^3.0.2", diff --git a/test/browser/HTMLImports.spec.ts b/test/browser/HTMLImports.spec.ts index 8d22557dc..657f8bd35 100644 --- a/test/browser/HTMLImports.spec.ts +++ b/test/browser/HTMLImports.spec.ts @@ -76,5 +76,4 @@ describe('HTML Imports', ifEnvSupports(supportsImports, function() { document.head.appendChild(link!); }); }); - })); diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/browser/XMLHttpRequest.spec.ts index 49121396a..0e34ccc74 100644 --- a/test/browser/XMLHttpRequest.spec.ts +++ b/test/browser/XMLHttpRequest.spec.ts @@ -122,13 +122,14 @@ describe('XMLHttpRequest', function() { const trackingTestZone = Zone.current.fork({ name: 'tracking test zone', - onHasTask: (delegate: ZoneDelegate, current: Zone, target: Zone, - hasTaskState: HasTaskState) => { - if (hasTaskState.change == 'macroTask') { - pending = hasTaskState.macroTask; - } - delegate.hasTask(target, hasTaskState); - } + onHasTask: + (delegate: ZoneDelegate, current: Zone, target: Zone, + hasTaskState: HasTaskState) => { + if (hasTaskState.change == 'macroTask') { + pending = hasTaskState.macroTask; + } + delegate.hasTask(target, hasTaskState); + } }); trackingTestZone.run(function() { diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 58899a4a9..6afa1cfe4 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -84,13 +84,13 @@ describe('Zone', function() { const alertSpy = jasmine.createSpy('alert'); const promptSpy = jasmine.createSpy('prompt'); const confirmSpy = jasmine.createSpy('confirm'); - const spies: {[k: string]: - Function} = {'alert': alertSpy, 'prompt': promptSpy, 'confirm': confirmSpy}; + const spies: + {[k: string]: Function} = {'alert': alertSpy, 'prompt': promptSpy, 'confirm': confirmSpy}; const myZone = Zone.current.fork({ name: 'spy', - onInvoke: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - callback: Function, applyThis?: any, applyArgs?: any[], - source?: string): any => { + onInvoke: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + callback: Function, applyThis?: any, applyArgs?: any[], source?: string): any => { if (source) { spies[source].apply(null, applyArgs); } else { @@ -117,11 +117,12 @@ describe('Zone', function() { let hookSpy: Spy, eventListenerSpy: Spy; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); beforeEach(function() { @@ -381,7 +382,6 @@ describe('Zone', function() { }; expect(testFn).not.toThrow(); })); - })); describe('eventListener hooks', function() { @@ -404,11 +404,12 @@ describe('Zone', function() { const eventListenerSpy = jasmine.createSpy('eventListener'); const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(function() { @@ -430,15 +431,16 @@ describe('Zone', function() { let scheduleTask; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - scheduleButton = (task.data as any).taskData.target; - scheduleEventName = (task.data as any).taskData.eventName; - scheduleCapture = (task.data as any).taskData.capture; - scheduleTask = task; - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + scheduleButton = (task.data as any).taskData.target; + scheduleEventName = (task.data as any).taskData.eventName; + scheduleCapture = (task.data as any).taskData.capture; + scheduleTask = task; + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(function() { @@ -460,11 +462,12 @@ describe('Zone', function() { const eventListenerSpy = jasmine.createSpy('eventListener'); const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(function() { @@ -482,11 +485,12 @@ describe('Zone', function() { const eventListenerSpy = jasmine.createSpy('eventListener'); const zone = rootZone.fork({ name: 'spy', - onCancelTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.cancelTask(targetZone, task); - } + onCancelTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.cancelTask(targetZone, task); + } }); zone.run(function() { @@ -508,16 +512,18 @@ describe('Zone', function() { let logs: string[]; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, - targetZone: Zone, task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onCancelTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - cancelSpy(); - return parentZoneDelegate.cancelTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onCancelTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + cancelSpy(); + return parentZoneDelegate.cancelTask(targetZone, task); + } }); const docListener = () => { @@ -573,7 +579,6 @@ describe('Zone', function() { button.dispatchEvent(clickEvent); expect(logs).toEqual([]); }); - })); describe( @@ -584,16 +589,18 @@ describe('Zone', function() { let logs: string[]; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, - targetZone: Zone, task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onCancelTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - cancelSpy(); - return parentZoneDelegate.cancelTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onCancelTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + cancelSpy(); + return parentZoneDelegate.cancelTask(targetZone, task); + } }); const docListener = () => { @@ -658,16 +665,18 @@ describe('Zone', function() { let logs: string[]; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, - targetZone: Zone, task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onCancelTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - cancelSpy(); - return parentZoneDelegate.cancelTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onCancelTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + cancelSpy(); + return parentZoneDelegate.cancelTask(targetZone, task); + } }); const docListener = () => { @@ -817,11 +826,12 @@ describe('Zone', function() { let logs: string[] = []; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(function() { @@ -847,11 +857,12 @@ describe('Zone', function() { let logs: string[] = []; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(function() { @@ -991,11 +1002,12 @@ describe('Zone', function() { const logs: string[] = []; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); const listener = (e: Event) => { @@ -1022,11 +1034,12 @@ describe('Zone', function() { const logs: string[] = []; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); const listener1 = (e: Event) => { @@ -1057,11 +1070,12 @@ describe('Zone', function() { let eventTask: Task; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - eventTask = task; - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + eventTask = task; + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(() => { @@ -1085,11 +1099,12 @@ describe('Zone', function() { let eventTask: Task; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - eventTask = task; - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + eventTask = task; + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(() => { @@ -1113,11 +1128,12 @@ describe('Zone', function() { let eventTask: Task; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - eventTask = task; - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + eventTask = task; + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(() => { @@ -1150,11 +1166,12 @@ describe('Zone', function() { let eventTask: Task; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - eventTask = task; - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + eventTask = task; + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(() => { @@ -1187,11 +1204,12 @@ describe('Zone', function() { let eventTask: Task; const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - eventTask = task; - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + eventTask = task; + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(() => { @@ -1229,17 +1247,18 @@ describe('Zone', function() { }; const zone1 = Zone.current.fork({ name: 'zone1', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - if ((task.type === 'eventTask' || task.type === 'macroTask') && - isBlacklistedEvent(task.source)) { - task.cancelScheduleRequest(); - - return zone2.scheduleTask(task); - } else { - return parentZoneDelegate.scheduleTask(targetZone, task); - } - }, + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + if ((task.type === 'eventTask' || task.type === 'macroTask') && + isBlacklistedEvent(task.source)) { + task.cancelScheduleRequest(); + + return zone2.scheduleTask(task); + } else { + return parentZoneDelegate.scheduleTask(targetZone, task); + } + }, onInvokeTask( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, applyThis: any, applyArgs: any) { @@ -1249,11 +1268,12 @@ describe('Zone', function() { }); const zone2 = Zone.current.fork({ name: 'zone2', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy2(); - return parentZoneDelegate.scheduleTask(targetZone, task); - }, + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy2(); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, onInvokeTask( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, applyThis: any, applyArgs: any) { @@ -1298,11 +1318,12 @@ describe('Zone', function() { const hookSpy = jasmine.createSpy('hook'); const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); zone.run(function() { @@ -2282,11 +2303,12 @@ describe('Zone', function() { const hookSpy = jasmine.createSpy('hook'); const zone = rootZone.fork({ name: 'spy', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - hookSpy(); - return parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } }); let logs: string[] = []; @@ -2573,7 +2595,6 @@ describe('Zone', function() { }); }); })); - }); }); }); diff --git a/test/browser/define-property.spec.ts b/test/browser/define-property.spec.ts index fb11387c8..f9032fa10 100644 --- a/test/browser/define-property.spec.ts +++ b/test/browser/define-property.spec.ts @@ -7,7 +7,6 @@ */ describe('defineProperty', function() { - it('should not throw when defining length on an array', function() { const someArray: any[] = []; expect(() => Object.defineProperty(someArray, 'length', {value: 2, writable: false})) @@ -25,5 +24,4 @@ describe('defineProperty', function() { Object.freeze(obj); Object.defineProperty(obj, 'prop', {configurable: true, writable: true, value: 'value'}); }); - }); \ No newline at end of file diff --git a/test/browser/element.spec.ts b/test/browser/element.spec.ts index ad9a34adc..c91c3bf5f 100644 --- a/test/browser/element.spec.ts +++ b/test/browser/element.spec.ts @@ -251,7 +251,6 @@ describe('element', function() { }); describe('onclick', function() { - function supportsOnClick() { const div = document.createElement('div'); const clickPropDesc = Object.getOwnPropertyDescriptor(div, 'onclick'); @@ -336,5 +335,4 @@ describe('element', function() { expect(checkbox.checked).toBe(true); }); }); - }); diff --git a/test/browser/registerElement.spec.ts b/test/browser/registerElement.spec.ts index cc625b32a..6145533b5 100644 --- a/test/browser/registerElement.spec.ts +++ b/test/browser/registerElement.spec.ts @@ -20,7 +20,6 @@ function registerElement() { describe( 'document.registerElement', ifEnvSupports(registerElement, function() { - // register a custom element for each callback const callbackNames = ['created', 'attached', 'detached', 'attributeChanged']; const callbacks: any = {}; @@ -111,9 +110,11 @@ describe( testZone.run(function() { const proto = Object.create(HTMLElement.prototype); - Object.defineProperties( - proto, - {createdCallback: {writable: false, configurable: false, value: checkZone}}); + Object.defineProperties(proto, { + createdCallback: { + writable: false, configurable: false, value: checkZone + } + }); (document).registerElement('x-props-desc', {prototype: proto}); @@ -128,10 +129,10 @@ describe( it('should not throw with frozen prototypes ', function() { testZone.run(function() { - const proto = Object.create(HTMLElement.prototype, Object.freeze({ - createdCallback: - {value: () => {}, writable: true, configurable: true} + createdCallback: { + value: () => {}, writable: true, configurable: true + } })); Object.defineProperty( @@ -169,5 +170,4 @@ describe( (document).registerElement('x-no-opts'); }).not.toThrow(); }); - })); diff --git a/test/browser/requestAnimationFrame.spec.ts b/test/browser/requestAnimationFrame.spec.ts index 2df631e9d..42a771ed7 100644 --- a/test/browser/requestAnimationFrame.spec.ts +++ b/test/browser/requestAnimationFrame.spec.ts @@ -10,55 +10,49 @@ import {ifEnvSupports} from '../test-util'; declare const window: any; describe('requestAnimationFrame', function() { - const functions = [ - 'requestAnimationFrame', - 'webkitRequestAnimationFrame', - 'mozRequestAnimationFrame' - ]; + const functions = + ['requestAnimationFrame', 'webkitRequestAnimationFrame', 'mozRequestAnimationFrame']; functions.forEach(function(fnName) { - describe( - fnName, - ifEnvSupports(fnName, function() { - const originalTimeout: number = (jasmine).DEFAULT_TIMEOUT_INTERVAL; - beforeEach(() => { - (jasmine).DEFAULT_TIMEOUT_INTERVAL = 10000; - }); - - afterEach(() => { - (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - }); - const rAF = window[fnName]; - - it('should be tolerant of invalid arguments', function() { - // rAF throws an error on invalid arguments, so expect that. - expect(function() { - rAF(null); - }).toThrow(); - }); - - it('should bind to same zone when called recursively', function(done) { - Zone.current.fork({ name: 'TestZone' }).run(() => { - let frames = 0; - let previousTimeStamp = 0; - - function frameCallback(timestamp: number) { - expect(timestamp).toMatch(/^[\d.]+$/); - // expect previous <= current - expect(previousTimeStamp).not.toBeGreaterThan(timestamp); - previousTimeStamp = timestamp; - - if (frames++ > 15) { - (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - return done(); - } - rAF(frameCallback); - } - - rAF(frameCallback); - }); - }); - }) - ); + describe(fnName, ifEnvSupports(fnName, function() { + const originalTimeout: number = (jasmine).DEFAULT_TIMEOUT_INTERVAL; + beforeEach(() => { + (jasmine).DEFAULT_TIMEOUT_INTERVAL = 10000; + }); + + afterEach(() => { + (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + }); + const rAF = window[fnName]; + + it('should be tolerant of invalid arguments', function() { + // rAF throws an error on invalid arguments, so expect that. + expect(function() { + rAF(null); + }).toThrow(); + }); + + it('should bind to same zone when called recursively', function(done) { + Zone.current.fork({name: 'TestZone'}).run(() => { + let frames = 0; + let previousTimeStamp = 0; + + function frameCallback(timestamp: number) { + expect(timestamp).toMatch(/^[\d.]+$/); + // expect previous <= current + expect(previousTimeStamp).not.toBeGreaterThan(timestamp); + previousTimeStamp = timestamp; + + if (frames++ > 15) { + (jasmine).DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + return done(); + } + rAF(frameCallback); + } + + rAF(frameCallback); + }); + }); + })); }); }); diff --git a/test/closure/zone.closure.ts b/test/closure/zone.closure.ts index facfc4719..70b2c853b 100644 --- a/test/closure/zone.closure.ts +++ b/test/closure/zone.closure.ts @@ -12,15 +12,17 @@ const testClosureFunction = () => { const testZoneSpec: ZoneSpec = { name: 'closure', properties: {}, - onFork: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - zoneSpec: ZoneSpec) => { - return parentZoneDelegate.fork(targetZone, zoneSpec); - }, + onFork: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + zoneSpec: ZoneSpec) => { + return parentZoneDelegate.fork(targetZone, zoneSpec); + }, - onIntercept: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - delegate: Function, source: string) => { - return parentZoneDelegate.intercept(targetZone, delegate, source); - }, + onIntercept: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, + source: string) => { + return parentZoneDelegate.intercept(targetZone, delegate, source); + }, onInvoke: function( parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, delegate: Function, diff --git a/test/common/Error.spec.ts b/test/common/Error.spec.ts index 9a9812439..540faf82f 100644 --- a/test/common/Error.spec.ts +++ b/test/common/Error.spec.ts @@ -164,7 +164,7 @@ describe('ZoneAwareError', () => { spy(args); }; expect((Error as any)['customProperty']).toBe('customProperty'); - expect(typeof(Error as any)['customFunction']).toBe('function'); + expect(typeof (Error as any)['customFunction']).toBe('function'); (Error as any)['customFunction']('test'); expect(spy).toHaveBeenCalledWith('test'); }); diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 90f69be6a..e3f3b070b 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -50,11 +50,12 @@ describe( pZone = Zone.current.fork({ name: 'promise-zone', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): any => { - log.push('scheduleTask'); - parentZoneDelegate.scheduleTask(targetZone, task); - } + onScheduleTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + any => { + log.push('scheduleTask'); + parentZoneDelegate.scheduleTask(targetZone, task); + } }); queueZone = Zone.current.fork(new MicroTaskQueueZoneSpec()); @@ -351,11 +352,11 @@ describe( .fork({ name: 'promise-error', onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): - boolean => { - promiseError = error; - delegate.handleError(target, error); - return false; - } + boolean => { + promiseError = error; + delegate.handleError(target, error); + return false; + } }) .run(() => { zone = Zone.current; @@ -391,11 +392,11 @@ describe( .fork({ name: 'promise-error', onHandleError: (delegate: ZoneDelegate, current: Zone, target: Zone, error: any): - boolean => { - promiseError = error; - delegate.handleError(target, error); - return false; - } + boolean => { + promiseError = error; + delegate.handleError(target, error); + return false; + } }) .run(() => { zone = Zone.current; @@ -462,27 +463,27 @@ describe( }); }); - it('should resolve generators', ifEnvSupports( - () => { - return isNode; - }, - () => { - const generators: any = function*() { - yield Promise.resolve(1); - yield Promise.resolve(2); - return; - }; - queueZone.run(() => { - let value = null; - Promise.all(generators()).then(val => { - value = val; - }); - // expect(Zone.current.get('queue').length).toEqual(2); - flushMicrotasks(); - expect(value).toEqual([1, 2]); - }); - - })); + it('should resolve generators', + ifEnvSupports( + () => { + return isNode; + }, + () => { + const generators: any = function*() { + yield Promise.resolve(1); + yield Promise.resolve(2); + return; + }; + queueZone.run(() => { + let value = null; + Promise.all(generators()).then(val => { + value = val; + }); + // expect(Zone.current.get('queue').length).toEqual(2); + flushMicrotasks(); + expect(value).toEqual([1, 2]); + }); + })); }); }); @@ -619,6 +620,5 @@ describe( }); }); }); - })); })); diff --git a/test/common/setInterval.spec.ts b/test/common/setInterval.spec.ts index fc41c306f..edc5f4df6 100644 --- a/test/common/setInterval.spec.ts +++ b/test/common/setInterval.spec.ts @@ -11,7 +11,6 @@ import {isNode, zoneSymbol} from '../../lib/common/utils'; declare const global: any; describe('setInterval', function() { - it('should work with setInterval', function(done) { let cancelId: any; const testZone = Zone.current.fork((Zone as any)['wtfZoneSpec']).fork({name: 'TestZone'}); @@ -86,5 +85,4 @@ describe('setInterval', function() { }, 300); }); }); - }); diff --git a/test/common/setTimeout.spec.ts b/test/common/setTimeout.spec.ts index 0b868836d..b9683d7f4 100644 --- a/test/common/setTimeout.spec.ts +++ b/test/common/setTimeout.spec.ts @@ -119,5 +119,4 @@ describe('setTimeout', function() { clearTimeout(null as any); clearTimeout({}); }); - }); diff --git a/test/common/task.spec.ts b/test/common/task.spec.ts index 6cac1f41c..db2fe5d2b 100644 --- a/test/common/task.spec.ts +++ b/test/common/task.spec.ts @@ -7,7 +7,7 @@ */ const noop = function() {}; -let log: {zone: string, taskZone: undefined | string, toState: TaskState, fromState: TaskState}[] = +let log: {zone: string, taskZone: undefined|string, toState: TaskState, fromState: TaskState}[] = []; const detectTask = Zone.current.scheduleMacroTask('detectTask', noop, undefined, noop, noop); const originalTransitionTo = detectTask.constructor.prototype._transitionTo; @@ -904,7 +904,6 @@ describe('task lifecycle', () => { {toState: 'notScheduled', fromState: 'canceling'} ]); })); - }); describe('reschedule zone', () => { diff --git a/test/common/toString.spec.ts b/test/common/toString.spec.ts index 1eb33c839..9d9b57090 100644 --- a/test/common/toString.spec.ts +++ b/test/common/toString.spec.ts @@ -37,7 +37,8 @@ describe('global function patch', () => { }); it('Function toString should look like native', () => { - expect(Function.prototype.toString.call(Function.prototype.toString)).toContain('[native code]'); + expect(Function.prototype.toString.call(Function.prototype.toString)) + .toContain('[native code]'); }); it('EventTarget addEventListener should look like native', ifEnvSupports('HTMLElement', () => { diff --git a/test/common/util.spec.ts b/test/common/util.spec.ts index 605a21248..449d9b247 100644 --- a/test/common/util.spec.ts +++ b/test/common/util.spec.ts @@ -9,7 +9,6 @@ import {patchMethod, patchProperty, patchPrototype, zoneSymbol} from '../../lib/common/utils'; describe('utils', function() { - describe('patchMethod', () => { it('should patch target where the method is defined', () => { let args; diff --git a/test/common/zone.spec.ts b/test/common/zone.spec.ts index 3b9b79bd1..eef428caf 100644 --- a/test/common/zone.spec.ts +++ b/test/common/zone.spec.ts @@ -15,7 +15,6 @@ describe('Zone', function() { }); describe('hooks', function() { - it('should throw if onError is not defined', function() { expect(function() { Zone.current.run(throwError); @@ -126,10 +125,10 @@ describe('Zone', function() { const zone: Zone = Zone.current.fork({ name: 'parent', onHasTask: (delegate: ZoneDelegate, current: Zone, target: Zone, hasTaskState: HasTaskState): - void => { - (hasTaskState as any)['zone'] = target.name; - log.push(hasTaskState); - }, + void => { + (hasTaskState as any)['zone'] = target.name; + log.push(hasTaskState); + }, onScheduleTask: (delegate: ZoneDelegate, current: Zone, target: Zone, task: Task) => { // Do nothing to prevent tasks from being run on VM turn; // Tests run task explicitly. @@ -397,10 +396,11 @@ describe('Zone', function() { const spy = jasmine.createSpy('error'); const hasTaskZone = Zone.current.fork({ name: 'hasTask', - onHasTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - hasTasState: HasTaskState) => { - throw new Error('onHasTask Error'); - }, + onHasTask: + (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + hasTasState: HasTaskState) => { + throw new Error('onHasTask Error'); + }, onHandleError: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => { spy(error.message); diff --git a/test/extra/bluebird.spec.ts b/test/extra/bluebird.spec.ts index b86ceac15..5e2e6eed7 100644 --- a/test/extra/bluebird.spec.ts +++ b/test/extra/bluebird.spec.ts @@ -76,7 +76,8 @@ describe('bluebird promise', () => { .spread((r1: string, r2: string) => { expect(r1).toEqual('test1'); expect(r2).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -112,7 +113,8 @@ describe('bluebird promise', () => { }) .then(() => { expect(Zone.current.name).toEqual('bluebird'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); @@ -126,7 +128,8 @@ describe('bluebird promise', () => { throw new Error('promise error'); }) .catch((err: Error) => { - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(err.message).toEqual('promise error'); @@ -142,7 +145,8 @@ describe('bluebird promise', () => { return 'test'; })() .then((result: string) => { - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); expect(result).toEqual('test'); @@ -181,7 +185,8 @@ describe('bluebird promise', () => { .then((r: string[]) => { expect(r[0]).toEqual('test1'); expect(r[1]).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -196,7 +201,8 @@ describe('bluebird promise', () => { .then((r: any) => { expect(r.test1).toEqual('test1'); expect(r.test2).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -209,7 +215,8 @@ describe('bluebird promise', () => { BluebirdPromise.any([BluebirdPromise.resolve('test1'), BluebirdPromise.resolve('test2')]) .then((r: any) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -223,7 +230,8 @@ describe('bluebird promise', () => { .then((r: any) => { expect(r.length).toBe(1); expect(r[0]).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -243,7 +251,8 @@ describe('bluebird promise', () => { expect(r.length).toBe(2); expect(r[0]).toEqual('test1'); expect(r[1]).toEqual('test2'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -282,7 +291,8 @@ describe('bluebird promise', () => { }) .then((r: number[]) => { expect(r[0]).toBe(2); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -293,12 +303,14 @@ describe('bluebird promise', () => { it('bluebird promise each method should be in zone', (done) => { zone.run(() => { const arr = [1, 2, 3]; - BluebirdPromise.each( - BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), - (r: number[], idx: number) => { - expect(r[idx] === arr[idx]); - expect(Zone.current.name).toEqual('bluebird'); - }).then((r: any) => { + BluebirdPromise + .each( + BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), + (r: number[], idx: number) => { + expect(r[idx] === arr[idx]); + expect(Zone.current.name).toEqual('bluebird'); + }) + .then((r: any) => { expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) @@ -312,19 +324,22 @@ describe('bluebird promise', () => { it('bluebird promise mapSeries method should be in zone', (done) => { zone.run(() => { const arr = [1, 2, 3]; - BluebirdPromise.mapSeries( - BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), - (r: number[], idx: number) => { - expect(r[idx] === arr[idx]); - expect(Zone.current.name).toEqual('bluebird'); - }).then((r: any) => { + BluebirdPromise + .mapSeries( + BluebirdPromise.map(arr, (item: number) => BluebirdPromise.resolve(item)), + (r: number[], idx: number) => { + expect(r[idx] === arr[idx]); + expect(Zone.current.name).toEqual('bluebird'); + }) + .then((r: any) => { expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) .toBeTruthy(); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) .toBeTruthy(); expect(Zone.current.name).toEqual('bluebird'); done(); - });; + }); + ; }); }); @@ -333,7 +348,8 @@ describe('bluebird promise', () => { BluebirdPromise.race([BluebirdPromise.resolve('test1'), BluebirdPromise.resolve('test2')]) .then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -362,8 +378,10 @@ describe('bluebird promise', () => { expect(Zone.current.name).toEqual('bluebird'); expect(p.leakObj).toBe(null); // using will generate several promise inside bluebird - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBeTruthy(); - expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBeTruthy(); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBeTruthy(); + expect(log.filter(item => item === 'invoke bluebird task Promise.then').length) + .toBeTruthy(); done(); }); }); @@ -410,7 +428,8 @@ describe('bluebird promise', () => { expect(r[0]).toBe('test1'); expect(r[1]).toBe('test2'); // using will generate several promise inside - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); @@ -468,7 +487,8 @@ describe('bluebird promise', () => { .then((r: string) => { expect(Zone.current.name).toEqual('bluebird'); expect(r).toBe('test'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); done(); }); @@ -483,8 +503,8 @@ describe('bluebird promise', () => { }, 0); }); p.tap(() => { - expect(Zone.current.name).toEqual('bluebird'); - }).then(() => { + expect(Zone.current.name).toEqual('bluebird'); + }).then(() => { expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); @@ -508,7 +528,8 @@ describe('bluebird promise', () => { }) .then((r: string) => { expect(r).toEqual('test1'); - expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); + expect(log.filter(item => item === 'schedule bluebird task Promise.then').length) + .toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); expect(Zone.current.name).toEqual('bluebird'); done(); @@ -530,7 +551,7 @@ describe('bluebird promise', () => { it('bluebird promise return method should be in zone', (done) => { zone.run(() => { - BluebirdPromise.resolve().return ('test1').then((r: string) => { + BluebirdPromise.resolve().return('test1').then((r: string) => { expect(r).toEqual('test1'); expect(log.filter(item => item === 'schedule bluebird task Promise.then').length).toBe(1); expect(log.filter(item => item === 'invoke bluebird task Promise.then').length).toBe(1); @@ -596,9 +617,7 @@ describe('bluebird promise', () => { }); it('bluebird should be able to run into different zone', (done: Function) => { - Zone.current.fork({ - name: 'zone_A' - }).run(() => { + Zone.current.fork({name: 'zone_A'}).run(() => { new BluebirdPromise((resolve: any, reject: any) => { expect(Zone.current.name).toEqual('zone_A'); resolve(1); @@ -606,10 +625,8 @@ describe('bluebird promise', () => { expect(Zone.current.name).toEqual('zone_A'); }); }); - - Zone.current.fork({ - name: 'zone_B' - }).run(() => { + + Zone.current.fork({name: 'zone_B'}).run(() => { new BluebirdPromise((resolve: any, reject: any) => { expect(Zone.current.name).toEqual('zone_B'); resolve(2); diff --git a/test/main.ts b/test/main.ts index f8c33f3ea..b59e5fc6a 100644 --- a/test/main.ts +++ b/test/main.ts @@ -32,7 +32,7 @@ if ((window as any)[(Zone as any).__symbol__('setTimeout')]) { } browserPatchedPromise.then(() => { - let testFrameworkPatch = typeof(window as any).Mocha !== 'undefined' ? + let testFrameworkPatch = typeof (window as any).Mocha !== 'undefined' ? '/base/build/test/test-env-setup-mocha' : '/base/build/test/test-env-setup-jasmine'; // Setup test environment diff --git a/test/mocha-patch.spec.ts b/test/mocha-patch.spec.ts index 1a583ab8d..50f84d00e 100644 --- a/test/mocha-patch.spec.ts +++ b/test/mocha-patch.spec.ts @@ -9,20 +9,19 @@ // Extra Mocha-specific typings to make sure typescript compiler is happy // Didn't want to add @types/mocha because of duplication in typings-file with @types/jasmine declare function suite(description: string, suiteFn: () => void): void; - declare function test(description: string, testFn: () => void): void; - declare function specify(description: string, testFn: () => void): void; - declare function setup(fn: () => void): void; declare function teardown(fn: () => void): void; - declare function suiteSetup(fn: () => void): void; - declare function suiteTeardown(fn: () => void): void; - declare function before(fn: () => void): void; declare function after(fn: () => void): void; - // - - import { - ifEnvSupports - } from './test-util'; +declare function test(description: string, testFn: () => void): void; +declare function specify(description: string, testFn: () => void): void; +declare function setup(fn: () => void): void; +declare function teardown(fn: () => void): void; +declare function suiteSetup(fn: () => void): void; +declare function suiteTeardown(fn: () => void): void; +declare function before(fn: () => void): void; +declare function after(fn: () => void): void; +// + +import {ifEnvSupports} from './test-util'; ifEnvSupports('Mocha', function() { - describe('Mocha BDD-style', () => { let throwOnAsync = false; let beforeEachZone: Zone|null = null; @@ -95,7 +94,6 @@ ifEnvSupports('Mocha', function() { suiteTeardown(() => { expect(suiteSetupZone).toBe(Zone.current); }); - }); describe('return promise', () => { diff --git a/test/node/crypto.spec.ts b/test/node/crypto.spec.ts index e89f87363..0c26e4f29 100644 --- a/test/node/crypto.spec.ts +++ b/test/node/crypto.spec.ts @@ -21,9 +21,9 @@ describe('crypto test', () => { const zoneASpec = { name: 'A', onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): - Task => { - return delegate.scheduleTask(targetZone, task); - } + Task => { + return delegate.scheduleTask(targetZone, task); + } }; const zoneA = Zone.current.fork(zoneASpec); spyOn(zoneASpec, 'onScheduleTask').and.callThrough(); @@ -46,9 +46,9 @@ describe('crypto test', () => { const zoneASpec: ZoneSpec = { name: 'A', onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): - Task => { - return delegate.scheduleTask(targetZone, task); - } + Task => { + return delegate.scheduleTask(targetZone, task); + } }; const zoneA = Zone.current.fork(zoneASpec); spyOn(zoneASpec, 'onScheduleTask').and.callThrough(); diff --git a/test/node/fs.spec.ts b/test/node/fs.spec.ts index e52d317ed..22790d31a 100644 --- a/test/node/fs.spec.ts +++ b/test/node/fs.spec.ts @@ -24,9 +24,9 @@ describe('nodejs file system', () => { const zoneASpec = { name: 'A', onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): - Task => { - return delegate.scheduleTask(targetZone, task); - } + Task => { + return delegate.scheduleTask(targetZone, task); + } }; const zoneA = Zone.current.fork(zoneASpec); spyOn(zoneASpec, 'onScheduleTask').and.callThrough(); @@ -43,9 +43,9 @@ describe('nodejs file system', () => { const zoneASpec = { name: 'A', onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): - Task => { - return delegate.scheduleTask(targetZone, task); - } + Task => { + return delegate.scheduleTask(targetZone, task); + } }; it('fs.watch has been patched as eventTask', (done) => { diff --git a/test/node/http.spec.ts b/test/node/http.spec.ts index 4588a638c..b031b3227 100644 --- a/test/node/http.spec.ts +++ b/test/node/http.spec.ts @@ -15,9 +15,9 @@ describe('http test', () => { const zoneASpec = { name: 'A', onScheduleTask: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): - Task => { - return delegate.scheduleTask(targetZone, task); - } + Task => { + return delegate.scheduleTask(targetZone, task); + } }; const zoneA = Zone.current.fork(zoneASpec); spyOn(zoneASpec, 'onScheduleTask').and.callThrough(); diff --git a/test/node/process.spec.ts b/test/node/process.spec.ts index 761eba652..642efb126 100644 --- a/test/node/process.spec.ts +++ b/test/node/process.spec.ts @@ -39,16 +39,18 @@ describe('process related test', () => { it('process.nextTick should be treated as microTask', (done) => { let zoneTick = Zone.current.fork({ name: 'zoneTick', - onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task): Task => { - result.push({callback: 'scheduleTask', targetZone: targetZone.name, task: task.source}); - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onInvokeTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - task: Task, applyThis?: any, applyArgs?: any): any => { - result.push({callback: 'invokeTask', targetZone: targetZone.name, task: task.source}); - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } + onScheduleTask: ( + parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): + Task => { + result.push({callback: 'scheduleTask', targetZone: targetZone.name, task: task.source}); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onInvokeTask: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task, + applyThis?: any, applyArgs?: any): any => { + result.push({callback: 'invokeTask', targetZone: targetZone.name, task: task.source}); + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } }); zoneTick.run(() => { process.nextTick(() => { diff --git a/test/rxjs/rxjs.Observable.merge.spec.ts b/test/rxjs/rxjs.Observable.merge.spec.ts index 9f1528009..0f4f51da3 100644 --- a/test/rxjs/rxjs.Observable.merge.spec.ts +++ b/test/rxjs/rxjs.Observable.merge.spec.ts @@ -174,7 +174,7 @@ describe('Observable.merge', () => { .map(function(x: any) { return Rx.Observable.range(x, 3); }) - .switch (); + .switch(); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.fromEvent.spec.ts b/test/rxjs/rxjs.fromEvent.spec.ts index 6020ee795..e7cb8272e 100644 --- a/test/rxjs/rxjs.fromEvent.spec.ts +++ b/test/rxjs/rxjs.fromEvent.spec.ts @@ -19,103 +19,87 @@ function isEventTarget() { describe('Observable.fromEvent', () => { let log: string[]; - const constructorZone1: Zone = Zone.current.fork({ - name: 'Constructor Zone1' - }); - const subscriptionZone: Zone = Zone.current.fork({ - name: 'Subscription Zone' - }); - const triggerZone: Zone = Zone.current.fork({ name: 'Trigger Zone' }); + const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); + const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); + const triggerZone: Zone = Zone.current.fork({name: 'Trigger Zone'}); let observable1: any; beforeEach(() => { log = []; }); - it( - 'fromEvent EventTarget func callback should run in the correct zone', - ifEnvSupports(isEventTarget, () => { - observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEvent(document, 'click'); - }); + it('fromEvent EventTarget func callback should run in the correct zone', + ifEnvSupports(isEventTarget, () => { + observable1 = constructorZone1.run(() => { + return Rx.Observable.fromEvent(document, 'click'); + }); - const clickEvent = document.createEvent('Event'); - clickEvent.initEvent('click', true, true); + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', true, true); - subscriptionZone.run(() => { - observable1.subscribe( - (result: any) => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push(result); - }, - () => { - fail('should not call error'); - }, - () => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push('completed'); - } - ); - }); + subscriptionZone.run(() => { + observable1.subscribe( + (result: any) => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push(result); + }, + () => { + fail('should not call error'); + }, + () => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push('completed'); + }); + }); - triggerZone.run(() => { - document.dispatchEvent(clickEvent); - }); + triggerZone.run(() => { + document.dispatchEvent(clickEvent); + }); - expect(log).toEqual([clickEvent]); - }) - ); + expect(log).toEqual([clickEvent]); + })); - it( - 'fromEventPattern EventTarget func callback should run in the correct zone', - ifEnvSupports(isEventTarget, () => { - const button = document.createElement('button'); - document.body.appendChild(button); - observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEventPattern( - (handler: any) => { - expect(Zone.current.name).toEqual(constructorZone1.name); - button.addEventListener('click', handler); - log.push('addListener'); - }, - (handler: any) => { - expect(Zone.current.name).toEqual(constructorZone1.name); - button.removeEventListener('click', handler); - document.body.removeChild(button); - log.push('removeListener'); - } - ); - }); + it('fromEventPattern EventTarget func callback should run in the correct zone', + ifEnvSupports(isEventTarget, () => { + const button = document.createElement('button'); + document.body.appendChild(button); + observable1 = constructorZone1.run(() => { + return Rx.Observable.fromEventPattern( + (handler: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + button.addEventListener('click', handler); + log.push('addListener'); + }, + (handler: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + button.removeEventListener('click', handler); + document.body.removeChild(button); + log.push('removeListener'); + }); + }); - const clickEvent = document.createEvent('Event'); - clickEvent.initEvent('click', false, false); + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', false, false); - const subscriper: any = subscriptionZone.run(() => { - return observable1.subscribe( - (result: any) => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push(result); - }, - () => { - fail('should not call error'); - }, - () => { - expect(Zone.current.name).toEqual(subscriptionZone.name); - log.push('completed'); - } - ); - }); + const subscriper: any = subscriptionZone.run(() => { + return observable1.subscribe( + (result: any) => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push(result); + }, + () => { + fail('should not call error'); + }, + () => { + expect(Zone.current.name).toEqual(subscriptionZone.name); + log.push('completed'); + }); + }); - triggerZone.run(() => { - button.dispatchEvent(clickEvent); - subscriper.complete(); - }); - expect(log).toEqual([ - 'addListener', - clickEvent, - 'completed', - 'removeListener' - ]); - }) - ); + triggerZone.run(() => { + button.dispatchEvent(clickEvent); + subscriper.complete(); + }); + expect(log).toEqual(['addListener', clickEvent, 'completed', 'removeListener']); + })); }); diff --git a/test/test-env-setup-mocha.ts b/test/test-env-setup-mocha.ts index 96058a0c4..173820aaf 100644 --- a/test/test-env-setup-mocha.ts +++ b/test/test-env-setup-mocha.ts @@ -131,8 +131,8 @@ declare const global: any; }, toHaveBeenCalledWith: function(...params: any[]) { if (!eq(expected.callArgs, params)) { - throw new Error(`Expected ${expected} to been called with ${expected.callArgs - }, called with: ${params}`); + throw new Error(`Expected ${expected} to been called with ${ + expected.callArgs}, called with: ${params}`); } }, toMatch: function(actual: any) { diff --git a/test/test_fake_polyfill.ts b/test/test_fake_polyfill.ts index e5e92c4f0..6e59a9e0a 100644 --- a/test/test_fake_polyfill.ts +++ b/test/test_fake_polyfill.ts @@ -8,72 +8,72 @@ 'use strict'; (function(global: any) { - // add custom properties to Native Error - const NativeError = global['Error']; - NativeError.customProperty = 'customProperty'; - NativeError.customFunction = function() {}; +// add custom properties to Native Error +const NativeError = global['Error']; +NativeError.customProperty = 'customProperty'; +NativeError.customFunction = function() {}; - // add fake cordova polyfill for test - const fakeCordova = function() {}; +// add fake cordova polyfill for test +const fakeCordova = function() {}; - (fakeCordova as any).exec = function( - success: Function, error: Function, service: string, action: string, args: any[]) { - if (action === 'successAction') { - success(); - } else { - error(); - } - }; +(fakeCordova as any).exec = function( + success: Function, error: Function, service: string, action: string, args: any[]) { + if (action === 'successAction') { + success(); + } else { + error(); + } +}; - global.cordova = fakeCordova; +global.cordova = fakeCordova; - const TestTarget = global.TestTarget = function() {}; +const TestTarget = global.TestTarget = function() {}; - Object.defineProperties(TestTarget.prototype, { - 'onprop1': {configurable: true, writable: true}, - 'onprop2': {configurable: true, writable: true}, - 'onprop3': { - configurable: true, - get: function() { - return this._onprop3; - }, - set: function(_value) { - this._onprop3 = _value; - } - }, - '_onprop3': {configurable: true, writable: true, value: function() {}}, - 'addEventListener': { - configurable: true, - writable: true, - value: function(eventName: string, callback: Function) { - if (!this.events) { - this.events = {}; - } - this.events.eventName = {zone: Zone.current, callback: callback}; - } +Object.defineProperties(TestTarget.prototype, { + 'onprop1': {configurable: true, writable: true}, + 'onprop2': {configurable: true, writable: true}, + 'onprop3': { + configurable: true, + get: function() { + return this._onprop3; }, - 'removeEventListener': { - configurable: true, - writable: true, - value: function(eventName: string, callback: Function) { - if (!this.events) { - return; - } - this.events.eventName = null; + set: function(_value) { + this._onprop3 = _value; + } + }, + '_onprop3': {configurable: true, writable: true, value: function() {}}, + 'addEventListener': { + configurable: true, + writable: true, + value: function(eventName: string, callback: Function) { + if (!this.events) { + this.events = {}; } - }, - 'dispatchEvent': { - configurable: true, - writable: true, - value: function(eventName: string) { - const zoneCallback = this.events && this.events.eventName; - zoneCallback && zoneCallback.zone.run(zoneCallback.callback, this, [{type: eventName}]); + this.events.eventName = {zone: Zone.current, callback: callback}; + } + }, + 'removeEventListener': { + configurable: true, + writable: true, + value: function(eventName: string, callback: Function) { + if (!this.events) { + return; } + this.events.eventName = null; + } + }, + 'dispatchEvent': { + configurable: true, + writable: true, + value: function(eventName: string) { + const zoneCallback = this.events && this.events.eventName; + zoneCallback && zoneCallback.zone.run(zoneCallback.callback, this, [{type: eventName}]); } - }); + } +}); - global['__Zone_ignore_on_properties'] = - [{target: TestTarget.prototype, ignoreProperties: ['prop1']}]; - global['__zone_symbol__FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}]; - global['__zone_symbol__BLACK_LISTED_EVENTS'] = ['scroll']; +global['__Zone_ignore_on_properties'] = + [{target: TestTarget.prototype, ignoreProperties: ['prop1']}]; +global['__zone_symbol__FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}]; +global['__zone_symbol__BLACK_LISTED_EVENTS'] = ['scroll']; })(typeof window === 'object' && window || typeof self === 'object' && self || global); diff --git a/test/ws-webworker-context.ts b/test/ws-webworker-context.ts index b52632ea4..87a70a0a4 100644 --- a/test/ws-webworker-context.ts +++ b/test/ws-webworker-context.ts @@ -8,6 +8,6 @@ declare function importScripts(path: string): void; - importScripts('/base/build/lib/zone.js'); - importScripts('/base/node_modules/systemjs/dist/system.src.js'); - importScripts('/base/build/test/zone_worker_entry_point.js'); +importScripts('/base/build/lib/zone.js'); +importScripts('/base/node_modules/systemjs/dist/system.src.js'); +importScripts('/base/build/test/zone_worker_entry_point.js'); diff --git a/test/wtf_mock.ts b/test/wtf_mock.ts index 39d30ef78..f34e11e54 100644 --- a/test/wtf_mock.ts +++ b/test/wtf_mock.ts @@ -8,86 +8,86 @@ 'use strict'; (function(global) { - const log: string[] = []; - const logArgs: any[][] = []; - const wtfMock = { - log: log, - logArgs: logArgs, - reset: function() { - log.length = 0; - logArgs.length = 0; +const log: string[] = []; +const logArgs: any[][] = []; +const wtfMock = { + log: log, + logArgs: logArgs, + reset: function() { + log.length = 0; + logArgs.length = 0; + }, + trace: { + leaveScope: function(scope: any, returnValue: any) { + return scope(returnValue); }, - trace: { - leaveScope: function(scope: any, returnValue: any) { - return scope(returnValue); - }, - beginTimeRange: function(type: any, action: any) { + beginTimeRange: function(type: any, action: any) { + logArgs.push([]); + log.push('>>> ' + type + '[' + action + ']'); + return function() { logArgs.push([]); - log.push('>>> ' + type + '[' + action + ']'); - return function() { - logArgs.push([]); - log.push('<<< ' + type); - }; - }, - endTimeRange: function(range: Function) { - range(); - }, - events: { - createScope: function(signature: string, flags: any) { - const parts = signature.split('('); - const name = parts[0]; - return function scopeFn() { - const args = []; - for (let i = arguments.length - 1; i >= 0; i--) { - const arg = arguments[i]; - if (arg !== undefined) { - args.unshift(__stringify(arg)); - } + log.push('<<< ' + type); + }; + }, + endTimeRange: function(range: Function) { + range(); + }, + events: { + createScope: function(signature: string, flags: any) { + const parts = signature.split('('); + const name = parts[0]; + return function scopeFn() { + const args = []; + for (let i = arguments.length - 1; i >= 0; i--) { + const arg = arguments[i]; + if (arg !== undefined) { + args.unshift(__stringify(arg)); } - log.push('> ' + name + '(' + args.join(', ') + ')'); - logArgs.push(args); - return function(retValue: any) { - log.push('< ' + name + (retValue == undefined ? '' : ' => ' + retValue)); - logArgs.push(retValue); - return retValue; - }; + } + log.push('> ' + name + '(' + args.join(', ') + ')'); + logArgs.push(args); + return function(retValue: any) { + log.push('< ' + name + (retValue == undefined ? '' : ' => ' + retValue)); + logArgs.push(retValue); + return retValue; }; - }, - createInstance: function(signature: string, flags: any) { - const parts = signature.split('('); - const name = parts[0]; - return function eventFn() { - const args = []; - for (let i = arguments.length - 1; i >= 0; i--) { - const arg = arguments[i]; - if (arg !== undefined) { - args.unshift(__stringify(arg)); - } + }; + }, + createInstance: function(signature: string, flags: any) { + const parts = signature.split('('); + const name = parts[0]; + return function eventFn() { + const args = []; + for (let i = arguments.length - 1; i >= 0; i--) { + const arg = arguments[i]; + if (arg !== undefined) { + args.unshift(__stringify(arg)); } - log.push('# ' + name + '(' + args.join(', ') + ')'); - logArgs.push(args); - }; - } + } + log.push('# ' + name + '(' + args.join(', ') + ')'); + logArgs.push(args); + }; } } - }; + } +}; - function __stringify(obj: any): string { - let str = typeof obj == 'string' || !obj ? JSON.stringify(obj) : obj.toString(); - if (str == '[object Arguments]') { - str = JSON.stringify(Array.prototype.slice.call(obj)); - } else if (str == '[object Object]') { - str = JSON.stringify(obj); - } - return str; +function __stringify(obj: any): string { + let str = typeof obj == 'string' || !obj ? JSON.stringify(obj) : obj.toString(); + if (str == '[object Arguments]') { + str = JSON.stringify(Array.prototype.slice.call(obj)); + } else if (str == '[object Object]') { + str = JSON.stringify(obj); } + return str; +} - beforeEach(function() { - wtfMock.reset(); - }); +beforeEach(function() { + wtfMock.reset(); +}); - (global).wtfMock = wtfMock; - (global).wtf = wtfMock; +(global).wtfMock = wtfMock; +(global).wtf = wtfMock; })(typeof window === 'object' && window || typeof self === 'object' && self || global); declare const wtfMock: any; diff --git a/test/zone-spec/async-test.spec.ts b/test/zone-spec/async-test.spec.ts index 71cc26fcc..53cadecc3 100644 --- a/test/zone-spec/async-test.spec.ts +++ b/test/zone-spec/async-test.spec.ts @@ -314,7 +314,6 @@ describe('AsyncTestZoneSpec', function() { atz.run(function() { Promise.reject('my reason'); }); - }); const asyncTest: any = (Zone as any)[Zone.__symbol__('asyncTest')]; @@ -529,5 +528,4 @@ describe('AsyncTestZoneSpec', function() { })); }); }); - }); diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index f92f1b96b..af2473765 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -309,9 +309,9 @@ describe('FakeAsyncTestZoneSpec', () => { let id: number; id = setInterval(() => { - cycles++; - clearInterval(id); - }, 10) as any as number; + cycles++; + clearInterval(id); + }, 10) as any as number; testZoneSpec.tick(10); expect(cycles).toEqual(1); @@ -774,7 +774,6 @@ describe('FakeAsyncTestZoneSpec', () => { expect(tickRun).toEqual(true); expect(cbArgRun).toEqual(true); }); - }); })); @@ -944,7 +943,6 @@ describe('FakeAsyncTestZoneSpec', () => { expect(unixTimeZero).toBe(0); }); }); - }); describe( @@ -1272,7 +1270,6 @@ const {fakeAsync, tick, discardPeriodicTasks, flush, flushMicrotasks} = fakeAsyn })(); }).toThrowError('sync'); }); - }); describe('timers', () => { diff --git a/test/zone-spec/long-stack-trace-zone.spec.ts b/test/zone-spec/long-stack-trace-zone.spec.ts index 779fba53e..5178f88b0 100644 --- a/test/zone-spec/long-stack-trace-zone.spec.ts +++ b/test/zone-spec/long-stack-trace-zone.spec.ts @@ -21,12 +21,13 @@ describe( beforeEach(function() { lstz = Zone.current.fork(longStackTraceZoneSpec).fork({ name: 'long-stack-trace-zone-test', - onHandleError: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - error: any): boolean => { - parentZoneDelegate.handleError(targetZone, error); - log.push(error); - return false; - } + onHandleError: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): + boolean => { + parentZoneDelegate.handleError(targetZone, error); + log.push(error); + return false; + } }); log = []; diff --git a/test/zone-spec/proxy.spec.ts b/test/zone-spec/proxy.spec.ts index 2285855fb..b877665e0 100644 --- a/test/zone-spec/proxy.spec.ts +++ b/test/zone-spec/proxy.spec.ts @@ -80,12 +80,13 @@ describe('ProxySpec', () => { let called = false; proxyZoneSpec.setDelegate({ name: '.', - onFork: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - zoneSpec: ZoneSpec) => { - expect(currentZone).toBe(proxyZone); - expect(targetZone).toBe(proxyZone), expect(zoneSpec.name).toBe('fork2'); - called = true; - } + onFork: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + zoneSpec: ZoneSpec) => { + expect(currentZone).toBe(proxyZone); + expect(targetZone).toBe(proxyZone), expect(zoneSpec.name).toBe('fork2'); + called = true; + } }); proxyZone.fork({name: 'fork2'}); expect(called).toBe(true); @@ -96,10 +97,11 @@ describe('ProxySpec', () => { expect(proxyZone.wrap(fn, 'test')('works')).toEqual('works'); proxyZoneSpec.setDelegate({ name: '.', - onIntercept: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - delegate: Function, source: string): Function => { - return () => '(works)'; - } + onIntercept: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + delegate: Function, source: string): Function => { + return () => '(works)'; + } }); expect(proxyZone.wrap(fn, 'test')('works')).toEqual('(works)'); }); @@ -109,11 +111,12 @@ describe('ProxySpec', () => { expect(proxyZone.run(fn)).toEqual('works'); proxyZoneSpec.setDelegate({ name: '.', - onInvoke: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - delegate: Function, applyThis: any, applyArgs: any[], source: string) => { - return `(${parentZoneDelegate.invoke( - targetZone, delegate, applyThis, applyArgs, source)})`; - } + onInvoke: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + delegate: Function, applyThis: any, applyArgs: any[], source: string) => { + return `(${ + parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)})`; + } }); expect(proxyZone.run(fn)).toEqual('(works)'); }); @@ -126,11 +129,12 @@ describe('ProxySpec', () => { expect(() => proxyZone.run(fn)).toThrow(error); proxyZoneSpec.setDelegate({ name: '.', - onHandleError: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, - error: any): boolean => { - expect(error).toEqual(error); - return false; - } + onHandleError: + (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: any): + boolean => { + expect(error).toEqual(error); + return false; + } }); expect(() => proxyZone.runGuarded(fn)).not.toThrow(); }); diff --git a/yarn.lock b/yarn.lock index a26216695..7b8a66fec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -674,17 +674,17 @@ chokidar@^1.4.1: optionalDependencies: fsevents "^1.0.0" -clang-format@1.0.46: - version "1.0.46" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.0.46.tgz#f69de49cd50909b3149c9053c9240defd5135114" +clang-format@^1.0.32: + version "1.2.2" + resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.2.tgz#a7277a03fce9aa4e387ddaa83b60d99dab115737" dependencies: async "^1.5.2" glob "^7.0.0" resolve "^1.1.6" -clang-format@^1.0.32: - version "1.2.2" - resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.2.tgz#a7277a03fce9aa4e387ddaa83b60d99dab115737" +clang-format@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.3.tgz#2763561aa7449c43737480f8df3a2b5b66e6cf37" dependencies: async "^1.5.2" glob "^7.0.0" From 0720d79d306494191442d10de7ae9f91cc4d143f Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 19 Jun 2018 01:53:27 +0900 Subject: [PATCH 049/106] fix(test): karma-dist should test bundle under dist (#1049) --- gulpfile.js | 6 +- karma-base.conf.js | 30 ++-- karma-dist-mocha.conf.js | 17 ++- karma-dist.conf.js | 9 +- sauce-selenium3.conf.js | 29 ++-- sauce.conf.js | 4 +- test/browser-zone-setup.ts | 2 + test/browser/MediaQuery.spec.ts | 2 - test/browser/Notification.spec.ts | 2 - test/main.ts | 7 +- test/node_entry_point.ts | 6 +- test/test-env-setup-jasmine.ts | 1 - test/test-env-setup-mocha.ts | 4 +- test/webdriver/test.sauce.js | 224 +++++++++++++----------------- 14 files changed, 158 insertions(+), 185 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index dc0490804..385bcdde7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,7 +43,9 @@ function generateScript(inFile, outFile, minify, callback) { 'rxjs/Observable': 'Rx', 'rxjs/Subscriber': 'Rx', 'rxjs/Subscription': 'Rx', + 'rxjs/Scheduler': 'Rx.Scheduler', 'rxjs/scheduler/asap': 'Rx.Scheduler', + 'rxjs/scheduler/async': 'Rx.Scheduler', 'rxjs/symbol/rxSubscriber': 'Rx.Symbol' } }, @@ -404,9 +406,9 @@ function nodeTest(specFiles, cb) { require('./build/lib/node/rollup-main'); var args = process.argv; if (args.length > 3) { - require('./build/test/test-env-setup-jasmine' + args[3]); + require('./build/test/test-env-setup-jasmine' + args[3]); } - var JasmineRunner = require('jasmine'); + var JasmineRunner = require('jasmine'); var JasmineRunner = require('jasmine'); var jrunner = new JasmineRunner(); diff --git a/karma-base.conf.js b/karma-base.conf.js index 0778ebe2e..d31a4310f 100644 --- a/karma-base.conf.js +++ b/karma-base.conf.js @@ -6,45 +6,39 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { +module.exports = function(config) { config.set({ basePath: '', files: [ - 'node_modules/systemjs/dist/system-polyfills.js', - 'node_modules/systemjs/dist/system.src.js', + 'node_modules/systemjs/dist/system-polyfills.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/whatwg-fetch/fetch.js', - {pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false }, - {pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false }, - {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, - {pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false }, - {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, + {pattern: 'node_modules/rxjs/**/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false}, {pattern: 'test/assets/**/*.*', watched: true, served: true, included: false}, {pattern: 'build/**/*.js.map', watched: true, served: true, included: false}, {pattern: 'build/**/*.js', watched: true, served: true, included: false} ], plugins: [ - require('karma-chrome-launcher'), - require('karma-firefox-launcher'), + require('karma-chrome-launcher'), require('karma-firefox-launcher'), require('karma-sourcemap-loader') ], - preprocessors: { - '**/*.js': ['sourcemap'] - }, + preprocessors: {'**/*.js': ['sourcemap']}, - exclude: [ - 'test/microtasks.spec.ts' - ], + exclude: ['test/microtasks.spec.ts'], reporters: ['progress'], - //port: 9876, + // port: 9876, colors: true, logLevel: config.LOG_INFO, - browsers: ['Firefox'], + browsers: ['Chrome'], captureTimeout: 60000, diff --git a/karma-dist-mocha.conf.js b/karma-dist-mocha.conf.js index 6f9ac7324..a7dcf6c7e 100644 --- a/karma-dist-mocha.conf.js +++ b/karma-dist-mocha.conf.js @@ -1,10 +1,23 @@ -module.exports = function (config) { +module.exports = function(config) { require('./karma-dist.conf.js')(config); + for (let i = 0; i < config.files.length; i++) { + if (config.files[i] === 'dist/zone-testing.js') { + config.files.splice(i, 1); + break; + } + } + config.files.push('dist/long-stack-trace-zone.js'); + config.files.push('dist/proxy.js'); + config.files.push('dist/sync-test.js'); + config.files.push('dist/async-test.js'); + config.files.push('dist/fake-async-test.js'); + config.files.push('dist/zone-patch-promise-test.js'); config.plugins.push(require('karma-mocha')); config.frameworks.push('mocha'); config.client.mocha = { - timeout: 5000 // copied timeout for Jasmine in WebSocket.spec (otherwise Mochas default timeout at 2 sec is to low for the tests) + timeout: 5000 // copied timeout for Jasmine in WebSocket.spec (otherwise Mochas default timeout + // at 2 sec is to low for the tests) }; }; diff --git a/karma-dist.conf.js b/karma-dist.conf.js index 204225c4d..8d45297f2 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -12,15 +12,12 @@ module.exports = function(config) { config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); config.files.push('dist/zone.js'); + config.files.push('dist/webapis-media-query.js'); + config.files.push('dist/webapis-notification.js'); config.files.push('dist/zone-patch-user-media.js'); config.files.push('dist/zone-patch-resize-observer.js'); - config.files.push('dist/long-stack-trace-zone.js'); - config.files.push('dist/proxy.js'); - config.files.push('dist/sync-test.js'); - config.files.push('dist/async-test.js'); - config.files.push('dist/fake-async-test.js'); config.files.push('dist/task-tracking.js'); - config.files.push('dist/zone-patch-promise-test.js'); config.files.push('dist/wtf.js'); + config.files.push('dist/zone-testing.js'); config.files.push('build/test/main.js'); }; diff --git a/sauce-selenium3.conf.js b/sauce-selenium3.conf.js index 4c4b7322e..d06a50258 100644 --- a/sauce-selenium3.conf.js +++ b/sauce-selenium3.conf.js @@ -1,16 +1,14 @@ // Sauce configuration with Welenium drivers 3+ -module.exports = function (config) { +module.exports = function(config) { // The WS server is not available with Sauce config.files.unshift('test/saucelabs.js'); var customLaunchers = { - 'SL_CHROME60': { - base: 'SauceLabs', - browserName: 'Chrome', - platform: 'Windows 10', - version: '60.0' - } + 'SL_CHROME60': + {base: 'SauceLabs', browserName: 'Chrome', platform: 'Windows 10', version: '60.0'}, + 'SL_SAFARI11': + {base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.0'}, }; config.set({ @@ -22,11 +20,11 @@ module.exports = function (config) { startConnect: false, recordVideo: false, recordScreenshots: false, - options: { - 'selenium-version': '3.5.0', - 'command-timeout': 600, - 'idle-timeout': 600, - 'max-duration': 5400 + options: { + 'selenium-version': '3.5.0', + 'command-timeout': 600, + 'idle-timeout': 600, + 'max-duration': 5400 } }, @@ -38,13 +36,12 @@ module.exports = function (config) { singleRun: true, - plugins: [ - 'karma-*' - ] + plugins: ['karma-*'] }); if (process.env.TRAVIS) { - config.sauceLabs.build = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; + config.sauceLabs.build = + 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); diff --git a/sauce.conf.js b/sauce.conf.js index 1aac560bd..8a1c8a53a 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -6,9 +6,9 @@ module.exports = function(config, ignoredLaunchers) { var basicLaunchers = { 'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '48'}, - 'SL_CHROME_60': {base: 'SauceLabs', browserName: 'chrome', version: '60'}, + 'SL_CHROME_65': {base: 'SauceLabs', browserName: 'chrome', version: '60'}, 'SL_FIREFOX': {base: 'SauceLabs', browserName: 'firefox', version: '52'}, - 'SL_FIREFOX_54': {base: 'SauceLabs', browserName: 'firefox', version: '54'}, + 'SL_FIREFOX_59': {base: 'SauceLabs', browserName: 'firefox', version: '54'}, /*'SL_SAFARI7': { base: 'SauceLabs', browserName: 'safari', diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 8b812dc1c..7fb70d1cf 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -12,6 +12,7 @@ if (typeof window !== 'undefined') { import '../lib/common/to-string'; import '../lib/browser/browser'; import '../lib/browser/webapis-user-media'; +import '../lib/browser/webapis-media-query'; import '../lib/testing/zone-testing'; import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; @@ -20,3 +21,4 @@ import '../lib/testing/promise-testing'; import '../lib/testing/async-testing'; import '../lib/testing/fake-async'; import '../lib/browser/webapis-resize-observer'; +import '../lib/rxjs/rxjs-fake-async'; diff --git a/test/browser/MediaQuery.spec.ts b/test/browser/MediaQuery.spec.ts index 465d23102..fcb6dfb39 100644 --- a/test/browser/MediaQuery.spec.ts +++ b/test/browser/MediaQuery.spec.ts @@ -6,8 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/browser/webapis-media-query'; - import {zoneSymbol} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; declare const global: any; diff --git a/test/browser/Notification.spec.ts b/test/browser/Notification.spec.ts index 5c23fccab..8e0273991 100644 --- a/test/browser/Notification.spec.ts +++ b/test/browser/Notification.spec.ts @@ -6,8 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import '../../lib/browser/webapis-notification'; - import {zoneSymbol} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; declare const window: any; diff --git a/test/main.ts b/test/main.ts index b59e5fc6a..69514966d 100644 --- a/test/main.ts +++ b/test/main.ts @@ -28,7 +28,12 @@ if ((window as any)[(Zone as any).__symbol__('setTimeout')]) { } else { // this means that Zone has not patched the browser yet, which means we must be running in // build mode and need to load the browser patch. - browserPatchedPromise = System.import('/base/build/test/browser-zone-setup'); + browserPatchedPromise = System.import('/base/build/test/browser-zone-setup').then(() => { + let testFrameworkPatch = typeof(window as any).Mocha !== 'undefined' ? + '/base/build/lib/mocha/mocha' : + '/base/build/lib/jasmine/jasmine'; + return System.import(testFrameworkPatch); + }); } browserPatchedPromise.then(() => { diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index fd521eb92..a98cb3a7c 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -19,11 +19,9 @@ import '../lib/testing/zone-testing'; import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/rxjs/rxjs'; - -import '../lib/testing/promise-testing'; -import '../lib/testing/async-testing'; -import '../lib/testing/fake-async'; +import '../lib/rxjs/rxjs-fake-async'; // Setup test environment +import '../lib/jasmine/jasmine'; import './test-env-setup-jasmine'; // List all tests here: diff --git a/test/test-env-setup-jasmine.ts b/test/test-env-setup-jasmine.ts index 8cee81df5..85ea4d9d9 100644 --- a/test/test-env-setup-jasmine.ts +++ b/test/test-env-setup-jasmine.ts @@ -7,4 +7,3 @@ */ (jasmine).DEFAULT_TIMEOUT_INTERVAL = 5000; -import '../lib/jasmine/jasmine'; diff --git a/test/test-env-setup-mocha.ts b/test/test-env-setup-mocha.ts index 173820aaf..b3fa41cdc 100644 --- a/test/test-env-setup-mocha.ts +++ b/test/test-env-setup-mocha.ts @@ -10,7 +10,7 @@ import '../lib/mocha/mocha'; declare const global: any; ((context: any) => { - context['jasmine'] = global['jasmine'] || {}; + context['jasmine'] = context['jasmine'] || {}; context['jasmine'].createSpy = function(spyName: string) { let spy: any = function(...params: any[]) { spy.countCall++; @@ -183,4 +183,4 @@ declare const global: any; } }; }; -})(window); \ No newline at end of file +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); \ No newline at end of file diff --git a/test/webdriver/test.sauce.js b/test/webdriver/test.sauce.js index 7ca9de2ef..13c7e80d1 100644 --- a/test/webdriver/test.sauce.js +++ b/test/webdriver/test.sauce.js @@ -8,83 +8,50 @@ const webdriverio = require('webdriverio'); const desiredCapabilities = { - firefox52Win7: { - browserName: 'firefox', - platform: 'Windows 7', - version: '52' - }, - firefox53Win7: { - browserName: 'firefox', - platform: 'Windows 7', - version: '53' - }, - edge14: { - browserName: 'MicrosoftEdge', - platform: 'Windows 10', - version: '14.14393' - }, - /*edge15: { - browserName: 'Edge', - platform: 'Windows 10', - version: '15.15063' - },*/ - chrome48: { - browserName: 'chrome', - version: '48' - }, - safari8: { - browserName: 'safari', - platform: 'OS X 10.10', - version: '8.0' - }, - safari9: { - browserName: 'safari', - platform: 'OS X 10.11', - version: '9.0' - }, - /* - ios84: { - browserName: 'iphone', - platform: 'OS X 10.10', - version: '8.4' - },*/ - ios93: { - browserName: 'iphone', - platform: 'OS X 10.10', - version: '9.3' - }, - ios10: { - browserName: 'iphone', - platform: 'OS X 10.10', - version: '10.2' - }, - /* - ie9: { - browserName: 'internet explorer', - platform: 'Windows 2008', - version: '9' - },*/ - /* - ie10: { - browserName: 'internet explorer', - platform: 'Windows 2012', - version: '10' - },*/ - ie11: { - browserName: 'internet explorer', - platform: 'Windows 10', - version: '11' - }, - andriod44: { - browserName: 'android', - platform: 'Linux', - version: '4.4' - }, - android51: { - browserName: 'android', - platform: 'Linux', - version: '5.1' - } + firefox52Win7: {browserName: 'firefox', platform: 'Windows 7', version: '52'}, + firefox53Win7: {browserName: 'firefox', platform: 'Windows 7', version: '53'}, + edge14: {browserName: 'MicrosoftEdge', platform: 'Windows 10', version: '14.14393'}, + edge15: {browserName: 'MicrosoftEdge', platform: 'Windows 10', version: '15.15063'}, + chrome48: {browserName: 'chrome', version: '48'}, + safari8: {browserName: 'safari', platform: 'OS X 10.10', version: '8.0'}, + safari9: {browserName: 'safari', platform: 'OS X 10.11', version: '9.0'}, + safari10: {browserName: 'safari', platform: 'OS X 10.11', version: '10.0'}, + safari11: {browserName: 'safari', platform: 'macOS 10.13', version: '11.0'}, + /*ios84: {browserName: 'iphone', platform: 'OS X 10.10', version: '8.4'},*/ + ios93: {browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'}, + ios10: {browserName: 'iphone', platform: 'OS X 10.10', version: '10.2'}, + ios11: {browserName: 'iphone', platform: 'OS X 10.12', version: '11.2'}, + /* + ie9: { + browserName: 'internet explorer', + platform: 'Windows 2008', + version: '9' + },*/ + /* + ie10: { + browserName: 'internet explorer', + platform: 'Windows 2012', + version: '10' + },*/ + ie11: {browserName: 'internet explorer', platform: 'Windows 10', version: '11'}, + andriod44: {browserName: 'android', platform: 'Linux', version: '4.4'}, + android51: {browserName: 'android', platform: 'Linux', version: '5.1'}, + android60: { + deviceName: 'Android GoogleAPI Emulator', + browserName: 'Chrome', + platformName: 'Android', + platformVersion: '6.0', + deviceOrientation: 'portrait', + appiumVersion: '1.7.2' + }, + android71: { + deviceName: 'Android GoogleAPI Emulator', + browserName: 'Chrome', + platformName: 'Android', + platformVersion: '7.1', + deviceOrientation: 'portrait', + appiumVersion: '1.7.2' + } }; const errors = []; @@ -104,64 +71,67 @@ Object.keys(desiredCapabilities).forEach(key => { key: process.env.SAUCE_ACCESS_KEY, host: 'localhost', port: 4445, - desiredCapabilities: desiredCapabilities[key] + desiredCapabilities: desiredCapabilities[key] }); - const p = client - .init() - .timeouts('script', 60000) - .url('http://localhost:8080/test/webdriver/test.html') - .executeAsync(function(done) { window.setTimeout(done,1000) }) - .execute(function() - { - const elem = document.getElementById('thetext'); - const zone = window['Zone'] ? Zone.current.fork({name: 'webdriver'}) : null; - if (zone) { - zone.run(function() { - elem.addEventListener('click', function(e) { - e.target.innerText = 'clicked' + Zone.current.name; - }); - }); - } else { - elem.addEventListener('click', function(e) { - e.target.innerText = 'clicked'; - }); - } - }) - .click('#thetext') - .getText('#thetext') - .then((text => { - if (text !== 'clickedwebdriver') { - errors.push(`Env: ${key}, expected clickedwebdriver, get ${text}`); - }}), (error) => { - errors.push(`Env: ${key}, error occurs: ${error}`); - }) - .end(); - tasks.push(p); + const p = client.init() + .timeouts('script', 60000) + .url('http://localhost:8080/test/webdriver/test.html') + .executeAsync(function(done) { + window.setTimeout(done, 1000) + }) + .execute(function() { + const elem = document.getElementById('thetext'); + const zone = window['Zone'] ? Zone.current.fork({name: 'webdriver'}) : null; + if (zone) { + zone.run(function() { + elem.addEventListener('click', function(e) { + e.target.innerText = 'clicked' + Zone.current.name; + }); + }); + } else { + elem.addEventListener('click', function(e) { + e.target.innerText = 'clicked'; + }); + } + }) + .click('#thetext') + .getText('#thetext') + .then( + (text => { + if (text !== 'clickedwebdriver') { + errors.push(`Env: ${key}, expected clickedwebdriver, get ${text}`); + } + }), + (error) => { + errors.push(`Env: ${key}, error occurs: ${error}`); + }) + .end(); + tasks.push(p); }); function exit(exitCode) { - const http = require('http'); - http.get('http://localhost:8080/close', () => { - process.exit(exitCode); - }); + const http = require('http'); + http.get('http://localhost:8080/close', () => { + process.exit(exitCode); + }); } Promise.all(tasks).then(() => { - if (errors.length > 0) { - let nonTimeoutError = false; - errors.forEach(error => { - console.log(error); - if (error.toString().lastIndexOf('timeout') === -1) { - nonTimeoutError = true; - } - }); - if (nonTimeoutError) { - exit(1); - } else { - exit(0); - } + if (errors.length > 0) { + let nonTimeoutError = false; + errors.forEach(error => { + console.log(error); + if (error.toString().lastIndexOf('timeout') === -1) { + nonTimeoutError = true; + } + }); + if (nonTimeoutError) { + exit(1); } else { - exit(0); + exit(0); } + } else { + exit(0); + } }); \ No newline at end of file From e9536ec7d724e21473496c090378d6635944c798 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 19 Jun 2018 01:56:47 +0900 Subject: [PATCH 050/106] fix(event): should pass boolean to addEventListener if not support passive (#1053) --- lib/common/events.ts | 41 ++++++++++++++++++++++++++-- test/browser/browser.spec.ts | 52 ++++++++++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 4 deletions(-) diff --git a/lib/common/events.ts b/lib/common/events.ts index b2e7074f6..4d404b427 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -18,6 +18,23 @@ interface EventTaskData extends TaskData { readonly useG?: boolean; } +let passiveSupported = false; + +if (typeof window !== 'undefined') { + try { + const options = Object.defineProperty({}, 'passive', { + get: function() { + passiveSupported = true; + } + }); + + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } catch (err) { + passiveSupported = false; + } +} + // an identifier to tell ZoneTask do not create a new invoke closure const OPTIMIZED_ZONE_EVENT_TASK_DATA: EventTaskData = { useG: true @@ -50,6 +67,8 @@ export interface PatchEventTargetOptions { rt?: boolean; // event compare handler diff?: (task: any, delegate: any) => boolean; + // support passive or not + supportPassive?: boolean; } export function patchEventTarget( @@ -212,12 +231,25 @@ export function patchEventTarget( proto[patchOptions.prepend]; } - const customScheduleGlobal = function() { + function checkIsPassive(task: Task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + (task as any).options = !!taskData.options.capture; + taskData.options = (task as any).options; + } + } + + const customScheduleGlobal = function(task: Task) { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } + checkIsPassive(task); return nativeAddEventListener.call( taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, @@ -265,6 +297,7 @@ export function patchEventTarget( }; const customScheduleNonGlobal = function(task: Task) { + checkIsPassive(task); return nativeAddEventListener.call( taskData.target, taskData.eventName, task.invoke, taskData.options); }; @@ -421,7 +454,11 @@ export function patchEventTarget( if (once) { options.once = true; } - task.options = options; + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } task.target = target; task.capture = capture; task.eventName = eventName; diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 6afa1cfe4..0ca232fb3 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -47,8 +47,8 @@ try { supportsPassive = true; } }); - window.addEventListener('test', null as any, opts); - window.removeEventListener('test', null as any, opts); + window.addEventListener('test', opts as any, opts); + window.removeEventListener('test', opts as any, opts); } catch (e) { } @@ -75,6 +75,14 @@ function ieOrEdge() { (ieOrEdge as any).message = 'IE/Edge Test'; +class TestEventListener { + logs: string[] = []; + addEventListener(eventName: string, listener: any, options: any) { + this.logs.push(options); + } + removeEventListener(eventName: string, listener: any, options: any) {} +} + describe('Zone', function() { const rootZone = Zone.current; (Zone as any)[zoneSymbol('ignoreConsoleErrorUncaughtError')] = true; @@ -996,6 +1004,46 @@ describe('Zone', function() { expect(logs).toEqual(['click']); })); + it('should change options to boolean if not support passive', () => { + patchEventTarget(window, [TestEventListener.prototype]); + const testEventListener = new TestEventListener(); + + const listener = function() {}; + testEventListener.addEventListener('test', listener, {passive: true}); + testEventListener.addEventListener('test1', listener, {once: true}); + testEventListener.addEventListener('test2', listener, {capture: true}); + testEventListener.addEventListener('test3', listener, {passive: false}); + testEventListener.addEventListener('test4', listener, {once: false}); + testEventListener.addEventListener('test5', listener, {capture: false}); + if (!supportsPassive) { + expect(testEventListener.logs).toEqual([false, false, true, false, false, false]); + } else { + expect(testEventListener.logs).toEqual([ + {passive: true}, {once: true}, {capture: true}, {passive: false}, {once: false}, + {capture: false} + ]); + } + }); + + it('should change options to boolean if not support passive on HTMLElement', () => { + const logs: string[] = []; + const listener = (e: Event) => { + logs.push('clicked'); + }; + + (button as any).addEventListener('click', listener, {once: true}); + button.dispatchEvent(clickEvent); + expect(logs).toEqual(['clicked']); + button.dispatchEvent(clickEvent); + if (supportsPassive) { + expect(logs).toEqual(['clicked']); + } else { + expect(logs).toEqual(['clicked', 'clicked']); + } + + button.removeEventListener('click', listener); + }); + it('should support addEventListener with AddEventListenerOptions passive setting', ifEnvSupports(supportEventListenerOptions, function() { const hookSpy = jasmine.createSpy('hook'); From 2aab9c816bc5764fdfe16dbd3b9385c1c7c3d0b9 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 19 Jun 2018 01:57:38 +0900 Subject: [PATCH 051/106] fix(xhr): should invoke xhr task after onload is triggered (#1055) --- lib/browser/browser.ts | 24 ++++++++++++++++++++++- test/browser/XMLHttpRequest.spec.ts | 30 +++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 9b72338bd..d4873797a 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -144,7 +144,29 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with // readyState=4 multiple times, so we need to check task state here if (!data.aborted && (XMLHttpRequest as any)[XHR_SCHEDULED] && task.state === SCHEDULED) { - task.invoke(); + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + const loadTasks = target['__zone_symbol__loadfalse']; + if (loadTasks && loadTasks.length > 0) { + const oriInvoke = task.invoke; + task.invoke = function() { + // need to load the tasks again, because in other + // load listener, they may remove themselves + const loadTasks = target['__zone_symbol__loadfalse']; + for (let i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke.call(task); + } + }; + loadTasks.push(task); + } else { + task.invoke(); + } } } }; diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/browser/XMLHttpRequest.spec.ts index 0e34ccc74..a1b59cff0 100644 --- a/test/browser/XMLHttpRequest.spec.ts +++ b/test/browser/XMLHttpRequest.spec.ts @@ -17,23 +17,37 @@ describe('XMLHttpRequest', function() { it('should intercept XHRs and treat them as MacroTasks', function(done) { let req: XMLHttpRequest; - const testZoneWithWtf = - Zone.current.fork((Zone as any)['wtfZoneSpec']).fork({name: 'TestZone'}); + let onStable: any; + const testZoneWithWtf = Zone.current.fork((Zone as any)['wtfZoneSpec']).fork({ + name: 'TestZone', + onHasTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, hasTask: HasTaskState) => { + if (!hasTask.macroTask) { + onStable && onStable(); + } + } + }); testZoneWithWtf.run(() => { req = new XMLHttpRequest(); + const logs: string[] = []; req.onload = () => { - // The last entry in the log should be the invocation for the current onload, - // which will vary depending on browser environment. The prior entries - // should be the invocation of the send macrotask. - expect(wtfMock.log[wtfMock.log.length - 3]) - .toEqual('> Zone:invokeTask:XMLHttpRequest.send("::ProxyZone::WTF::TestZone")'); + logs.push('onload'); + }; + onStable = function() { expect(wtfMock.log[wtfMock.log.length - 2]) + .toEqual('> Zone:invokeTask:XMLHttpRequest.send("::ProxyZone::WTF::TestZone")'); + expect(wtfMock.log[wtfMock.log.length - 1]) .toEqual('< Zone:invokeTask:XMLHttpRequest.send'); if (supportPatchXHROnProperty()) { - expect(wtfMock.log[wtfMock.log.length - 1]) + expect(wtfMock.log[wtfMock.log.length - 3]) + .toMatch(/\< Zone\:invokeTask.*addEventListener\:load/); + expect(wtfMock.log[wtfMock.log.length - 4]) .toMatch(/\> Zone\:invokeTask.*addEventListener\:load/); } + // if browser can patch onload + if ((req as any)['__zone_symbol__loadfalse']) { + expect(logs).toEqual(['onload']); + } done(); }; From 14cfc680d7d388aa5161e93fdff65e7b3394f119 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 19 Jun 2018 01:57:58 +0900 Subject: [PATCH 052/106] doc(sample): add samples to stackblitz (#1059) --- README.md | 4 ++++ SAMPLE.md | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 SAMPLE.md diff --git a/README.md b/README.md index a9f854ce8..07ab1c9c1 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ zone.js patched most standard web APIs (such as DOM events, `XMLHttpRequest`, .. We are adding support to some nonstandard APIs, such as MediaQuery and Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details. +## Examples + +You can find some samples to describe how to use zone.js in [SAMPLE.md](SAMPLE.md). + ## Modules zone.js patches the async APIs described above, but those patches will have some overhead. diff --git a/SAMPLE.md b/SAMPLE.md new file mode 100644 index 000000000..c4b9d463c --- /dev/null +++ b/SAMPLE.md @@ -0,0 +1,23 @@ +# Sample + +### Basic Sample + +use `zone.js` and `long-stack-trace-zone.js` to display longStackTrace information in html. +[basic](https://stackblitz.com/edit/zonejs-basic?file=index.js) + +### Async Task Counting Sample + +use `zone.js` to monitor async tasks and print the count info. +[counting](https://stackblitz.com/edit/zonejs-counting?file=index.js) + +### Profiling Sample + +use `zone.js` to profiling sort algorithm. +[profiling](https://stackblitz.com/edit/zonejs-profiling?file=index.js) + +### Throttle with longStackTrace + +use `long-stack-trace-zone` to display full flow of complex async operations such as throttle XHR requests. +[throttle](https://stackblitz.com/edit/zonejs-throttle?file=index.js) + + From d7e0a3111a3e7a6c1c5b81547c1525dcf0b3a36b Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 19 Jun 2018 02:01:27 +0900 Subject: [PATCH 053/106] fix(core): use then directly when promise is not patchable (#1079) --- lib/zone.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/zone.ts b/lib/zone.ts index dba7b1ee8..a71617a3a 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -1267,7 +1267,13 @@ const Zone: ZoneType = (function(global: any) { } } if (nativeMicroTaskQueuePromise) { - nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue); + let nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); } else { global[symbolSetTimeout](drainMicroTaskQueue, 0); } From 0a2f6ffdd814ccb20f21578b1159fa82b90fb4fd Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 19 Jun 2018 02:02:04 +0900 Subject: [PATCH 054/106] fix(node): node patched method should copy original delegate's symbol properties (#1095) --- .travis.yml | 2 +- lib/common/utils.ts | 33 +++++++++++++++++++++++ lib/node/node.ts | 9 ++----- lib/node/node_util.ts | 16 +++++++++++ package.json | 2 +- test/node/fs.spec.ts | 59 ++++++++++++++++++++++++++++++++++++++++- test/node/timer.spec.ts | 30 +++++++++++++++++++++ test/node_tests.ts | 1 + yarn.lock | 6 ++--- 9 files changed, 145 insertions(+), 13 deletions(-) create mode 100644 lib/node/node_util.ts create mode 100644 test/node/timer.spec.ts diff --git a/.travis.yml b/.travis.yml index 3ec8c6596..802a256f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false dist: trusty cache: yarn node_js: - - 6 + - 8 env: global: - BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 2f5b40f39..e7bbed307 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -334,6 +334,36 @@ export function patchClass(className: string) { } } +export function copySymbolProperties(src: any, dest: any) { + if (typeof (Object as any).getOwnPropertySymbols !== 'function') { + return; + } + const symbols: any = (Object as any).getOwnPropertySymbols(src); + symbols.forEach((symbol: any) => { + const desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value: any) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} + +let shouldCopySymbolProperties = false; + +export function setShouldCopySymbolProperties(flag: boolean) { + shouldCopySymbolProperties = flag; +} + export function patchMethod( target: any, name: string, patchFn: (delegate: Function, delegateName: string, name: string) => (self: any, args: any[]) => @@ -360,6 +390,9 @@ export function patchMethod( return patchDelegate(this, arguments as any); }; attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } } } return delegate; diff --git a/lib/node/node.ts b/lib/node/node.ts index fcb35edc6..94ef7fb05 100644 --- a/lib/node/node.ts +++ b/lib/node/node.ts @@ -6,22 +6,17 @@ * found in the LICENSE file at https://angular.io/license */ +import './node_util'; import './events'; import './fs'; import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {ArraySlice, bindArguments, isMix, patchMacroTask, patchMethod, patchMicroTask, patchOnProperties} from '../common/utils'; +import {ArraySlice, isMix, patchMacroTask, patchMicroTask} from '../common/utils'; const set = 'set'; const clear = 'clear'; -Zone.__load_patch('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; -}); - Zone.__load_patch('node_timers', (global: any, Zone: ZoneType) => { // Timers let globalUseTimeoutFromTimer = false; diff --git a/lib/node/node_util.ts b/lib/node/node_util.ts new file mode 100644 index 000000000..d37aa4aa0 --- /dev/null +++ b/lib/node/node_util.ts @@ -0,0 +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 {setShouldCopySymbolProperties, patchOnProperties, patchMethod, bindArguments} from '../common/utils'; + +Zone.__load_patch('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + setShouldCopySymbolProperties(true); +}); diff --git a/package.json b/package.json index 15f16822b..edcf64c43 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "dependencies": {}, "devDependencies": { "@types/jasmine": "2.2.33", - "@types/node": "^6.0.96", + "@types/node": "^8.10.17", "@types/systemjs": "^0.19.30", "assert": "^1.4.1", "bluebird": "^3.5.1", diff --git a/test/node/fs.spec.ts b/test/node/fs.spec.ts index 22790d31a..1ba819dd7 100644 --- a/test/node/fs.spec.ts +++ b/test/node/fs.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {exists, unlink, unwatchFile, watch, watchFile, writeFile} from 'fs'; +import {exists, read, unlink, unwatchFile, watch, write, watchFile, writeFile, openSync, fstatSync, closeSync, unlinkSync} from 'fs'; +import * as util from 'util'; describe('nodejs file system', () => { describe('async method patch test', () => { @@ -88,4 +89,60 @@ describe('nodejs file system', () => { }); }); }); +}); + +describe('util.promisify', () => { + it('fs.exists should work with util.promisify', (done: DoneFn) => { + const promisifyExists = util.promisify(exists); + promisifyExists(__filename).then(r => { + expect(r).toBe(true); + done(); + }, err => { + fail(`should not be here with error: ${err}`); + }); + }); + + it('fs.read should work with util.promisify', (done: DoneFn) => { + const promisifyRead = util.promisify(read); + const fd = openSync(__filename, 'r'); + const stats = fstatSync(fd); + const bufferSize = stats.size; + const chunkSize = 512; + const buffer = new Buffer(bufferSize); + let bytesRead = 0; + // fd, buffer, offset, length, position, callback + promisifyRead(fd, buffer, bytesRead, chunkSize, bytesRead).then( + (value) => { + expect(value.bytesRead).toBe(chunkSize); + closeSync(fd); + done(); + }, err => { + closeSync(fd); + fail(`should not be here with error: ${error}.`); + }); + }); + + it('fs.write should work with util.promisify', (done: DoneFn) => { + const promisifyWrite = util.promisify(write); + const dest = __filename + 'write'; + const fd = openSync(dest, 'a'); + const stats = fstatSync(fd); + const chunkSize = 512; + const buffer = new Buffer(chunkSize); + for (let i = 0; i < chunkSize; i++) { + buffer[i] = 0; + } + // fd, buffer, offset, length, position, callback + promisifyWrite(fd, buffer, 0, chunkSize, 0).then( + (value) => { + expect(value.bytesWritten).toBe(chunkSize); + closeSync(fd); + unlinkSync(dest); + done(); + }, err => { + closeSync(fd); + unlinkSync(dest); + fail(`should not be here with error: ${error}.`); + }); + }); }); \ No newline at end of file diff --git a/test/node/timer.spec.ts b/test/node/timer.spec.ts new file mode 100644 index 000000000..082c0af32 --- /dev/null +++ b/test/node/timer.spec.ts @@ -0,0 +1,30 @@ +/** + * @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 { promisify } from 'util'; + +describe('node timer', () => { + it('util.promisify should work with setTimeout', (done: DoneFn) => { + const setTimeoutPromise = promisify(setTimeout); + setTimeoutPromise(50, 'value').then(value => { + expect(value).toEqual('value'); + done(); + }, error => { + fail(`should not be here with error: ${error}.`); + }); + }); + + it('util.promisify should work with setImmediate', (done: DoneFn) => { + const setImmediatePromise = promisify(setImmediate); + setImmediatePromise('value').then(value => { + expect(value).toEqual('value'); + done(); + }, error => { + fail(`should not be here with error: ${error}.`); + }); + }); +}); \ No newline at end of file diff --git a/test/node_tests.ts b/test/node_tests.ts index 0fcc9b6aa..1366ac573 100644 --- a/test/node_tests.ts +++ b/test/node_tests.ts @@ -13,3 +13,4 @@ import './node/Error.spec'; import './node/crypto.spec'; import './node/http.spec'; import './node/console.spec'; +import './node/timer.spec'; diff --git a/yarn.lock b/yarn.lock index 7b8a66fec..a5ef50c82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,9 +6,9 @@ version "2.2.33" resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.2.33.tgz#4715cfd2ca7fbd632fc7f1784f13e637bed028c5" -"@types/node@^6.0.96": - version "6.0.101" - resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.101.tgz#0c5911cfb434af4a51c0a499931fe6423207d921" +"@types/node@^8.10.17": + version "8.10.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.17.tgz#d48cf10f0dc6dcf59f827f5a3fc7a4a6004318d3" "@types/systemjs@^0.19.30": version "0.19.33" From ff3d5451ada4e7389041062ed9fd196871f07843 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Mon, 25 Jun 2018 08:37:18 +0900 Subject: [PATCH 055/106] feat(error): fix #975, can config how to load blacklist zone stack frames (#1045) --- .travis.yml | 4 + MODULE.md | 51 +++++++ file-size-limit.json | 2 +- gulpfile.js | 12 ++ karma-base.conf.js | 2 + karma-build.conf.js | 3 +- lib/browser/define-property.ts | 2 +- lib/common/error-rewrite.ts | 240 ++++++++++++++++++++++----------- lib/common/utils.ts | 4 +- lib/node/node_util.ts | 2 +- package.json | 2 +- sauce-selenium3.conf.js | 2 +- sauce.conf.js | 2 +- test/browser/WebSocket.spec.ts | 2 +- test/common/Error.spec.ts | 65 +++++++-- test/main.ts | 28 ++-- test/node/fs.spec.ts | 61 +++++---- test/node/timer.spec.ts | 31 +++-- test/node_entry_point.ts | 1 + test/node_error_entry_point.ts | 41 ++++++ test/webdriver/test.sauce.js | 6 +- yarn.lock | 6 +- 22 files changed, 408 insertions(+), 161 deletions(-) create mode 100644 test/node_error_entry_point.ts diff --git a/.travis.yml b/.travis.yml index 802a256f9..2e51e3b18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,9 +39,13 @@ script: - node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run - node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run + - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run --errorpolicy=disable + - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run --errorpolicy=lazy - node_modules/.bin/gulp test/node - node_modules/.bin/gulp test/node -no-patch-clock - node_modules/.bin/gulp test/bluebird + - node_modules/.bin/gulp test/node/disableerror + - node_modules/.bin/gulp test/node/lazyerror - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js - yarn add jasmine@3.0.0 jasmine-core@3.0.0 mocha@5.0.1 diff --git a/MODULE.md b/MODULE.md index 377f66fa9..51519a03e 100644 --- a/MODULE.md +++ b/MODULE.md @@ -76,6 +76,57 @@ you can do like this. ``` +- Error + +By default, `zone.js/dist/zone-error` will not be loaded for performance concern. +This package will provide following functionality. + + 1. Error inherit: handle `extend Error` issue. + ``` + class MyError extends Error {} + const myError = new MyError(); + console.log('is MyError instanceof Error', (myError instanceof Error)); + ``` + + without `zone-error` patch, the example above will output `false`, with the patch, the reuslt will be `true`. + + 2. BlacklistZoneStackFrames: remove zone.js stack from `stackTrace`, and add `zone` information. Without this patch, a lot of `zone.js` invocation stack will be shown + in stack frames. + + ``` + at zone.run (polyfill.bundle.js: 3424) + at zoneDelegate.invokeTask (polyfill.bundle.js: 3424) + at zoneDelegate.runTask (polyfill.bundle.js: 3424) + at zone.drainMicroTaskQueue (polyfill.bundle.js: 3424) + at a.b.c (vendor.bundle.js: 12345 ) + at d.e.f (main.bundle.js: 23456) + ``` + + with this patch, those zone frames will be removed, + and the zone information `/` will be added + + ``` + at a.b.c (vendor.bundle.js: 12345 ) + at d.e.f (main.bundle.js: 23456 ) + ``` + + The second feature will slow down the `Error` performance, so `zone.js` provide a flag to let you be able to control the behavior. + The flag is `__Zone_Error_BlacklistedStackFrames_policy`. And the available options is: + + 1. default: this is the default one, if you load `zone.js/dist/zone-error` without + setting the flag, `default` will be used, and `BlackListStackFrames` will be available + when `new Error()`, you can get a `error.stack` which is `zone stack free`. But this + will slow down `new Error()` a little bit. + + 2. disable: this will disable `BlackListZoneStackFrame` feature, and if you load + `zone.js/dist/zone-error`, you will only get a `wrapped Error` which can handle + `Error inherit` issue. + + 3. lazy: this is a feature to let you be able to get `BlackListZoneStackFrame` feature, + but not impact performance. But as a trade off, you can't get the `zone free stack + frames` by access `error.stack`. You can only get it by access `error.zoneAwareStack`. + + - Angular(2+) Angular uses zone.js to manage async operations and decide when to perform change detection. Thus, in Angular, diff --git a/file-size-limit.json b/file-size-limit.json index 2c03611e5..26e5195d5 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 40000 + "limit": 40144 } ] } diff --git a/gulpfile.js b/gulpfile.js index 385bcdde7..64235017b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -444,6 +444,18 @@ gulp.task('test/bluebird', ['compile-node'], function(cb) { nodeTest(specFiles, cb); }); +gulp.task('test/node/disableerror', ['compile-node'], function(cb) { + process.env.errorpolicy = 'disable'; + var specFiles = ['build/test/node_error_entry_point.js']; + nodeTest(specFiles, cb); +}); + +gulp.task('test/node/lazyerror', ['compile-node'], function(cb) { + process.env.errorpolicy = 'lazy'; + var specFiles = ['build/test/node_error_entry_point.js']; + nodeTest(specFiles, cb); +}); + // Check the coding standards and programming errors gulp.task('lint', () => { const tslint = require('gulp-tslint'); diff --git a/karma-base.conf.js b/karma-base.conf.js index d31a4310f..32f447cff 100644 --- a/karma-base.conf.js +++ b/karma-base.conf.js @@ -9,6 +9,7 @@ module.exports = function(config) { config.set({ basePath: '', + client: {errorpolicy: config.errorpolicy}, files: [ 'node_modules/systemjs/dist/system-polyfills.js', 'node_modules/systemjs/dist/system.src.js', 'node_modules/whatwg-fetch/fetch.js', @@ -41,6 +42,7 @@ module.exports = function(config) { browsers: ['Chrome'], captureTimeout: 60000, + retryLimit: 4, autoWatch: true, singleRun: false diff --git a/karma-build.conf.js b/karma-build.conf.js index 87c87a5ea..aa2d3113c 100644 --- a/karma-build.conf.js +++ b/karma-build.conf.js @@ -6,12 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -module.exports = function (config) { +module.exports = function(config) { require('./karma-base.conf.js')(config); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/lib/zone.js'); config.files.push('build/lib/common/promise.js'); - config.files.push('build/lib/common/error-rewrite.js'); config.files.push('build/test/main.js'); }; diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index 872e86ea9..872631148 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -19,7 +19,7 @@ const _create = Object.create; const unconfigurablesKey = zoneSymbol('unconfigurables'); export function propertyPatch() { - Object.defineProperty = function(obj, prop, desc) { + Object.defineProperty = function(obj: any, prop: string, desc: any) { if (isUnconfigurable(obj, prop)) { throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); } diff --git a/lib/common/error-rewrite.ts b/lib/common/error-rewrite.ts index dc9a48918..1f63473d0 100644 --- a/lib/common/error-rewrite.ts +++ b/lib/common/error-rewrite.ts @@ -46,10 +46,71 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // We must find the frame where Error was created, otherwise we assume we don't understand stack let zoneAwareFrame1: string; let zoneAwareFrame2: string; + let zoneAwareFrame1WithoutNew: string; + let zoneAwareFrame2WithoutNew: string; + let zoneAwareFrame3WithoutNew: string; global['Error'] = ZoneAwareError; const stackRewrite = 'stackRewrite'; + type BlackListedStackFramesPolicy = 'default'|'disable'|'lazy'; + const blackListedStackFramesPolicy: BlackListedStackFramesPolicy = + global['__Zone_Error_BlacklistedStackFrames_policy'] || 'default'; + + interface ZoneFrameName { + zoneName: string; + parent?: ZoneFrameName; + } + + function buildZoneFrameNames(zoneFrame: _ZoneFrame) { + let zoneFrameName: ZoneFrameName = {zoneName: zoneFrame.zone.name}; + let result = zoneFrameName; + while (zoneFrame.parent) { + zoneFrame = zoneFrame.parent; + const parentZoneFrameName = {zoneName: zoneFrame.zone.name}; + zoneFrameName.parent = parentZoneFrameName; + zoneFrameName = parentZoneFrameName; + } + return result; + } + + function buildZoneAwareStackFrames( + originalStack: string, zoneFrame: _ZoneFrame|ZoneFrameName|null, isZoneFrame = true) { + let frames: string[] = originalStack.split('\n'); + let i = 0; + // Find the first frame + while (!(frames[i] === zoneAwareFrame1 || frames[i] === zoneAwareFrame2 || + frames[i] === zoneAwareFrame1WithoutNew || frames[i] === zoneAwareFrame2WithoutNew || + frames[i] === zoneAwareFrame3WithoutNew) && + i < frames.length) { + i++; + } + for (; i < frames.length && zoneFrame; i++) { + let frame = frames[i]; + if (frame.trim()) { + switch (blackListedStackFrames[frame]) { + case FrameType.blackList: + frames.splice(i, 1); + i--; + break; + case FrameType.transition: + if (zoneFrame.parent) { + // This is the special frame where zone changed. Print and process it accordingly + zoneFrame = zoneFrame.parent; + } else { + zoneFrame = null; + } + frames.splice(i, 1); + i--; + break; + default: + frames[i] += isZoneFrame ? ` [${(zoneFrame as _ZoneFrame).zone.name}]` : + ` [${(zoneFrame as ZoneFrameName).zoneName}]`; + } + } + } + return frames.join('\n'); + } /** * This is ZoneAwareError which processes the stack frame and cleans up extra frames as well as * adds zone information to it. @@ -62,42 +123,17 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { // Process the stack trace and rewrite the frames. if ((ZoneAwareError as any)[stackRewrite] && originalStack) { - let frames: string[] = originalStack.split('\n'); - let zoneFrame: _ZoneFrame|null = api.currentZoneFrame(); - let i = 0; - // Find the first frame - while (!(frames[i] === zoneAwareFrame1 || frames[i] === zoneAwareFrame2) && - i < frames.length) { - i++; - } - for (; i < frames.length && zoneFrame; i++) { - let frame = frames[i]; - if (frame.trim()) { - switch (blackListedStackFrames[frame]) { - case FrameType.blackList: - frames.splice(i, 1); - i--; - break; - case FrameType.transition: - if (zoneFrame.parent) { - // This is the special frame where zone changed. Print and process it accordingly - zoneFrame = zoneFrame.parent; - } else { - zoneFrame = null; - } - frames.splice(i, 1); - i--; - break; - default: - frames[i] += ` [${zoneFrame.zone.name}]`; - } + let zoneFrame = api.currentZoneFrame(); + if (blackListedStackFramesPolicy === 'lazy') { + // don't handle stack trace now + (error as any)[api.symbol('zoneFrameNames')] = buildZoneFrameNames(zoneFrame); + } else if (blackListedStackFramesPolicy === 'default') { + try { + error.stack = error.zoneAwareStack = buildZoneAwareStackFrames(originalStack, zoneFrame); + } catch (e) { + // ignore as some browsers don't allow overriding of stack } } - try { - error.stack = error.zoneAwareStack = frames.join('\n'); - } catch (e) { - // ignore as some browsers don't allow overriding of stack - } } if (this instanceof NativeError && this.constructor != NativeError) { @@ -123,6 +159,29 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { (ZoneAwareError as any)[blacklistedStackFramesSymbol] = blackListedStackFrames; (ZoneAwareError as any)[stackRewrite] = false; + const zoneAwareStackSymbol = api.symbol('zoneAwareStack'); + + // try to define zoneAwareStack property when blackListed + // policy is delay + if (blackListedStackFramesPolicy === 'lazy') { + Object.defineProperty(ZoneAwareError.prototype, 'zoneAwareStack', { + configurable: true, + enumerable: true, + get: function() { + if (!this[zoneAwareStackSymbol]) { + this[zoneAwareStackSymbol] = buildZoneAwareStackFrames( + this.originalStack, this[api.symbol('zoneFrameNames')], false); + } + return this[zoneAwareStackSymbol]; + }, + set: function(newStack: string) { + this.originalStack = newStack; + this[zoneAwareStackSymbol] = buildZoneAwareStackFrames( + this.originalStack, this[api.symbol('zoneFrameNames')], false); + } + }); + } + // those properties need special handling const specialPropertyNames = ['stackTraceLimit', 'captureStackTrace', 'prepareStackTrace']; // those properties of NativeError should be set to ZoneAwareError @@ -194,65 +253,71 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { } }); + if (blackListedStackFramesPolicy === 'disable') { + // don't need to run detectZone to populate + // blacklisted stack frames + return; + } // Now we need to populate the `blacklistedStackFrames` as well as find the // run/runGuarded/runTask frames. This is done by creating a detect zone and then threading // the execution through all of the above methods so that we can look at the stack trace and // find the frames of interest. - const ZONE_AWARE_ERROR = 'ZoneAwareError'; - const ERROR_DOT = 'Error.'; - const EMPTY = ''; - const RUN_GUARDED = 'runGuarded'; - const RUN_TASK = 'runTask'; - const RUN = 'run'; - const BRACKETS = '('; - const AT = '@'; let detectZone: Zone = Zone.current.fork({ name: 'detect', - onHandleError: function(parentZD: ZoneDelegate, current: Zone, target: Zone, error: any): - boolean { - if (error.originalStack && Error === ZoneAwareError) { - let frames = error.originalStack.split(/\n/); - let runFrame = false, runGuardedFrame = false, runTaskFrame = false; - while (frames.length) { - let frame = frames.shift(); - // On safari it is possible to have stack frame with no line number. - // This check makes sure that we don't filter frames on name only (must have - // line number) - if (/:\d+:\d+/.test(frame)) { - // Get rid of the path so that we don't accidentally find function name in path. - // In chrome the separator is `(` and `@` in FF and safari - // Chrome: at Zone.run (zone.js:100) - // Chrome: at Zone.run (http://localhost:9876/base/build/lib/zone.js:100:24) - // FireFox: Zone.prototype.run@http://localhost:9876/base/build/lib/zone.js:101:24 - // Safari: run@http://localhost:9876/base/build/lib/zone.js:101:24 - let fnName: string = frame.split(BRACKETS)[0].split(AT)[0]; - let frameType = FrameType.transition; - if (fnName.indexOf(ZONE_AWARE_ERROR) !== -1) { - zoneAwareFrame1 = frame; - zoneAwareFrame2 = frame.replace(ERROR_DOT, EMPTY); - blackListedStackFrames[zoneAwareFrame2] = FrameType.blackList; - } - if (fnName.indexOf(RUN_GUARDED) !== -1) { - runGuardedFrame = true; - } else if (fnName.indexOf(RUN_TASK) !== -1) { - runTaskFrame = true; - } else if (fnName.indexOf(RUN) !== -1) { - runFrame = true; - } else { - frameType = FrameType.blackList; - } - blackListedStackFrames[frame] = frameType; - // Once we find all of the frames we can stop looking. - if (runFrame && runGuardedFrame && runTaskFrame) { - (ZoneAwareError as any)[stackRewrite] = true; - break; + onHandleError: function( + parentZD: ZoneDelegate, current: Zone, target: Zone, error: any): boolean { + if (error.originalStack && Error === ZoneAwareError) { + let frames = error.originalStack.split(/\n/); + let runFrame = false, runGuardedFrame = false, runTaskFrame = false; + while (frames.length) { + let frame = frames.shift(); + // On safari it is possible to have stack frame with no line number. + // This check makes sure that we don't filter frames on name only (must have + // line number or exact equals to `ZoneAwareError`) + if (/:\d+:\d+/.test(frame) || frame === 'ZoneAwareError') { + // Get rid of the path so that we don't accidentally find function name in path. + // In chrome the separator is `(` and `@` in FF and safari + // Chrome: at Zone.run (zone.js:100) + // Chrome: at Zone.run (http://localhost:9876/base/build/lib/zone.js:100:24) + // FireFox: Zone.prototype.run@http://localhost:9876/base/build/lib/zone.js:101:24 + // Safari: run@http://localhost:9876/base/build/lib/zone.js:101:24 + let fnName: string = frame.split('(')[0].split('@')[0]; + let frameType = FrameType.transition; + if (fnName.indexOf('ZoneAwareError') !== -1) { + if (fnName.indexOf('new ZoneAwareError') !== -1) { + zoneAwareFrame1 = frame; + zoneAwareFrame2 = frame.replace('new ZoneAwareError', 'new Error.ZoneAwareError'); + } else { + zoneAwareFrame1WithoutNew = frame; + zoneAwareFrame2WithoutNew = frame.replace('Error.', ''); + if (frame.indexOf('Error.ZoneAwareError') === -1) { + zoneAwareFrame3WithoutNew = + frame.replace('ZoneAwareError', 'Error.ZoneAwareError'); } } + blackListedStackFrames[zoneAwareFrame2] = FrameType.blackList; + } + if (fnName.indexOf('runGuarded') !== -1) { + runGuardedFrame = true; + } else if (fnName.indexOf('runTask') !== -1) { + runTaskFrame = true; + } else if (fnName.indexOf('run') !== -1) { + runFrame = true; + } else { + frameType = FrameType.blackList; + } + blackListedStackFrames[frame] = frameType; + // Once we find all of the frames we can stop looking. + if (runFrame && runGuardedFrame && runTaskFrame) { + (ZoneAwareError as any)[stackRewrite] = true; + break; } } - return false; } + } + return false; + } }) as Zone; // carefully constructor a stack frame which contains all of the frames of interest which // need to be detected and blacklisted. @@ -293,7 +358,17 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { childDetectZone.scheduleMicroTask( blacklistedStackFramesSymbol, () => { - throw new (ZoneAwareError as any)(ZoneAwareError, NativeError); + throw new Error(); + }, + undefined, + (t: Task) => { + (t as any)._transitionTo = fakeTransitionTo; + t.invoke(); + }); + childDetectZone.scheduleMicroTask( + blacklistedStackFramesSymbol, + () => { + throw Error(); }, undefined, (t: Task) => { @@ -316,5 +391,6 @@ Zone.__load_patch('Error', (global: any, Zone: ZoneType, api: _ZonePrivate) => { () => {}); }); }); + Error.stackTraceLimit = originalStackTraceLimit; }); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index e7bbed307..0165da1c0 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -342,10 +342,10 @@ export function copySymbolProperties(src: any, dest: any) { symbols.forEach((symbol: any) => { const desc = Object.getOwnPropertyDescriptor(src, symbol); Object.defineProperty(dest, symbol, { - get: function () { + get: function() { return src[symbol]; }, - set: function (value: any) { + set: function(value: any) { if (desc && (!desc.writable || typeof desc.set !== 'function')) { // if src[symbol] is not writable or not have a setter, just return return; diff --git a/lib/node/node_util.ts b/lib/node/node_util.ts index d37aa4aa0..7ea994851 100644 --- a/lib/node/node_util.ts +++ b/lib/node/node_util.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {setShouldCopySymbolProperties, patchOnProperties, patchMethod, bindArguments} from '../common/utils'; +import {bindArguments, patchMethod, patchOnProperties, setShouldCopySymbolProperties} from '../common/utils'; Zone.__load_patch('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; diff --git a/package.json b/package.json index edcf64c43..533547247 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "dependencies": {}, "devDependencies": { "@types/jasmine": "2.2.33", - "@types/node": "^8.10.17", + "@types/node": "^9.x", "@types/systemjs": "^0.19.30", "assert": "^1.4.1", "bluebird": "^3.5.1", diff --git a/sauce-selenium3.conf.js b/sauce-selenium3.conf.js index d06a50258..0141e8808 100644 --- a/sauce-selenium3.conf.js +++ b/sauce-selenium3.conf.js @@ -8,7 +8,7 @@ module.exports = function(config) { 'SL_CHROME60': {base: 'SauceLabs', browserName: 'Chrome', platform: 'Windows 10', version: '60.0'}, 'SL_SAFARI11': - {base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.0'}, + {base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.1'}, }; config.set({ diff --git a/sauce.conf.js b/sauce.conf.js index 8a1c8a53a..c3ad894fc 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -36,7 +36,7 @@ module.exports = function(config, ignoredLaunchers) { version: '8.4' },*/ 'SL_IOS9': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'}, - 'SL_IOS10': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '10.2'}, + 'SL_IOS10': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '10.3'}, 'SL_IE9': { base: 'SauceLabs', browserName: 'internet explorer', diff --git a/test/browser/WebSocket.spec.ts b/test/browser/WebSocket.spec.ts index 82c51c321..86441f2fe 100644 --- a/test/browser/WebSocket.spec.ts +++ b/test/browser/WebSocket.spec.ts @@ -47,7 +47,7 @@ if (!window['saucelabs']) { expect(e.data).toBe('pass'); done(); }; - }); + }, 10000); it('should work with addEventListener', function(done) { testZone.run(function() { diff --git a/test/common/Error.spec.ts b/test/common/Error.spec.ts index 540faf82f..3ed1a5713 100644 --- a/test/common/Error.spec.ts +++ b/test/common/Error.spec.ts @@ -78,7 +78,15 @@ class TestMessageError extends WrappedError { describe('ZoneAwareError', () => { // If the environment does not supports stack rewrites, then these tests will fail // and there is no point in running them. - if (!(Error as any)['stackRewrite']) return; + const _global: any = typeof window !== 'undefined' ? window : global; + let config: any; + if (typeof __karma__ !== 'undefined') { + config = __karma__ && (__karma__ as any).config; + } else if (typeof process !== 'undefined') { + config = process.env; + } + const policy = (config && config['errorpolicy']) || 'default'; + if (!(Error as any)['stackRewrite'] && policy !== 'disable') return; it('should keep error prototype chain correctly', () => { class MyError extends Error {} @@ -180,15 +188,18 @@ describe('ZoneAwareError', () => { }); it('should show zone names in stack frames and remove extra frames', () => { + if (policy === 'disable' || !(Error as any)['stackRewrite']) { + return; + } const rootZone = Zone.root; const innerZone = rootZone.fork({name: 'InnerZone'}); rootZone.run(testFn); function testFn() { - let outside: Error; - let inside: Error; - let outsideWithoutNew: Error; - let insideWithoutNew: Error; + let outside: any; + let inside: any; + let outsideWithoutNew: any; + let insideWithoutNew: any; try { throw new Error('Outside'); } catch (e) { @@ -212,6 +223,13 @@ describe('ZoneAwareError', () => { } }); + if (policy === 'lazy') { + outside.stack = outside.zoneAwareStack; + outsideWithoutNew.stack = outsideWithoutNew.zoneAwareStack; + inside.stack = inside.zoneAwareStack; + insideWithoutNew.stack = insideWithoutNew.zoneAwareStack; + } + expect(outside.stack).toEqual(outside.zoneAwareStack); expect(outsideWithoutNew.stack).toEqual(outsideWithoutNew.zoneAwareStack); expect(inside!.stack).toEqual(inside!.zoneAwareStack); @@ -251,7 +269,6 @@ describe('ZoneAwareError', () => { if (/Error /.test(insideWithoutNewFrames[0])) { insideWithoutNewFrames.shift(); } - expect(outsideFrames[0]).toMatch(/testFn.*[]/); expect(insideFrames[0]).toMatch(/insideRun.*[InnerZone]]/); @@ -267,13 +284,31 @@ describe('ZoneAwareError', () => { const zoneAwareFrames = [ 'Zone.run', 'Zone.runGuarded', 'Zone.scheduleEventTask', 'Zone.scheduleMicroTask', 'Zone.scheduleMacroTask', 'Zone.runTask', 'ZoneDelegate.scheduleTask', - 'ZoneDelegate.invokeTask', 'zoneAwareAddListener' + 'ZoneDelegate.invokeTask', 'zoneAwareAddListener', 'Zone.prototype.run', + 'Zone.prototype.runGuarded', 'Zone.prototype.scheduleEventTask', + 'Zone.prototype.scheduleMicroTask', 'Zone.prototype.scheduleMacroTask', + 'Zone.prototype.runTask', 'ZoneDelegate.prototype.scheduleTask', + 'ZoneDelegate.prototype.invokeTask', 'ZoneTask.invokeTask' ]; - function assertStackDoesNotContainZoneFrames(err: Error) { - const frames = err.stack!.split('\n'); - for (let i = 0; i < frames.length; i++) { - expect(zoneAwareFrames.filter(f => frames[i].indexOf(f) !== -1)).toEqual([]); + function assertStackDoesNotContainZoneFrames(err: any) { + const frames = policy === 'lazy' ? err.zoneAwareStack.split('\n') : err.stack.split('\n'); + if (policy === 'disable') { + let hasZoneStack = false; + for (let i = 0; i < frames.length; i++) { + if (hasZoneStack) { + break; + } + hasZoneStack = zoneAwareFrames.filter(f => frames[i].indexOf(f) !== -1).length > 0; + } + if (!hasZoneStack) { + console.log('stack', err.originalStack); + } + expect(hasZoneStack).toBe(true); + } else { + for (let i = 0; i < frames.length; i++) { + expect(zoneAwareFrames.filter(f => frames[i].indexOf(f) !== -1)).toEqual([]); + } } }; @@ -317,7 +352,9 @@ describe('ZoneAwareError', () => { it('Error with new which cause by promise rejection should not have zone frames visible', (done) => { const p = new Promise((resolve, reject) => { - reject(new Error('test error')); + setTimeout(() => { + reject(new Error('test error')); + }); }); p.catch(err => { assertStackDoesNotContainZoneFrames(err); @@ -328,7 +365,9 @@ describe('ZoneAwareError', () => { it('Error without new which cause by promise rejection should not have zone frames visible', (done) => { const p = new Promise((resolve, reject) => { - reject(Error('test error')); + setTimeout(() => { + reject(Error('test error')); + }); }); p.catch(err => { assertStackDoesNotContainZoneFrames(err); diff --git a/test/main.ts b/test/main.ts index 69514966d..ccfedf5a8 100644 --- a/test/main.ts +++ b/test/main.ts @@ -13,6 +13,14 @@ declare const __karma__: { }; __karma__.loaded = function() {}; + +if (typeof __karma__ !== 'undefined') { + (window as any)['__Zone_Error_BlacklistedStackFrames_policy'] = + (__karma__ as any).config.errorpolicy; +} else if (typeof process !== 'undefined') { + (window as any)['__Zone_Error_BlacklistedStackFrames_policy'] = process.env.errorpolicy; +} + (window as any).global = window; System.config({ defaultJSExtensions: true, @@ -29,7 +37,7 @@ if ((window as any)[(Zone as any).__symbol__('setTimeout')]) { // this means that Zone has not patched the browser yet, which means we must be running in // build mode and need to load the browser patch. browserPatchedPromise = System.import('/base/build/test/browser-zone-setup').then(() => { - let testFrameworkPatch = typeof(window as any).Mocha !== 'undefined' ? + let testFrameworkPatch = typeof (window as any).Mocha !== 'undefined' ? '/base/build/lib/mocha/mocha' : '/base/build/lib/jasmine/jasmine'; return System.import(testFrameworkPatch); @@ -42,13 +50,15 @@ browserPatchedPromise.then(() => { '/base/build/test/test-env-setup-jasmine'; // Setup test environment System.import(testFrameworkPatch).then(() => { - System.import('/base/build/test/browser_entry_point') - .then( - () => { - __karma__.start(); - }, - (error) => { - console.error(error.stack || error); - }); + System.import('/base/build/lib/common/error-rewrite').then(() => { + System.import('/base/build/test/browser_entry_point') + .then( + () => { + __karma__.start(); + }, + (error) => { + console.error(error.stack || error); + }); + }); }); }); diff --git a/test/node/fs.spec.ts b/test/node/fs.spec.ts index 1ba819dd7..55cd02b24 100644 --- a/test/node/fs.spec.ts +++ b/test/node/fs.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {exists, read, unlink, unwatchFile, watch, write, watchFile, writeFile, openSync, fstatSync, closeSync, unlinkSync} from 'fs'; +import {closeSync, exists, fstatSync, openSync, read, unlink, unlinkSync, unwatchFile, watch, watchFile, write, writeFile} from 'fs'; import * as util from 'util'; describe('nodejs file system', () => { @@ -94,12 +94,15 @@ describe('nodejs file system', () => { describe('util.promisify', () => { it('fs.exists should work with util.promisify', (done: DoneFn) => { const promisifyExists = util.promisify(exists); - promisifyExists(__filename).then(r => { - expect(r).toBe(true); - done(); - }, err => { - fail(`should not be here with error: ${err}`); - }); + promisifyExists(__filename) + .then( + r => { + expect(r).toBe(true); + done(); + }, + err => { + fail(`should not be here with error: ${err}`); + }); }); it('fs.read should work with util.promisify', (done: DoneFn) => { @@ -111,15 +114,17 @@ describe('util.promisify', () => { const buffer = new Buffer(bufferSize); let bytesRead = 0; // fd, buffer, offset, length, position, callback - promisifyRead(fd, buffer, bytesRead, chunkSize, bytesRead).then( - (value) => { - expect(value.bytesRead).toBe(chunkSize); - closeSync(fd); - done(); - }, err => { - closeSync(fd); - fail(`should not be here with error: ${error}.`); - }); + promisifyRead(fd, buffer, bytesRead, chunkSize, bytesRead) + .then( + (value) => { + expect(value.bytesRead).toBe(chunkSize); + closeSync(fd); + done(); + }, + err => { + closeSync(fd); + fail(`should not be here with error: ${error}.`); + }); }); it('fs.write should work with util.promisify', (done: DoneFn) => { @@ -133,16 +138,18 @@ describe('util.promisify', () => { buffer[i] = 0; } // fd, buffer, offset, length, position, callback - promisifyWrite(fd, buffer, 0, chunkSize, 0).then( - (value) => { - expect(value.bytesWritten).toBe(chunkSize); - closeSync(fd); - unlinkSync(dest); - done(); - }, err => { - closeSync(fd); - unlinkSync(dest); - fail(`should not be here with error: ${error}.`); - }); + promisifyWrite(fd, buffer, 0, chunkSize, 0) + .then( + (value) => { + expect(value.bytesWritten).toBe(chunkSize); + closeSync(fd); + unlinkSync(dest); + done(); + }, + err => { + closeSync(fd); + unlinkSync(dest); + fail(`should not be here with error: ${error}.`); + }); }); }); \ No newline at end of file diff --git a/test/node/timer.spec.ts b/test/node/timer.spec.ts index 082c0af32..eff071905 100644 --- a/test/node/timer.spec.ts +++ b/test/node/timer.spec.ts @@ -5,26 +5,31 @@ * 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 { promisify } from 'util'; +import {promisify} from 'util'; describe('node timer', () => { it('util.promisify should work with setTimeout', (done: DoneFn) => { const setTimeoutPromise = promisify(setTimeout); - setTimeoutPromise(50, 'value').then(value => { - expect(value).toEqual('value'); - done(); - }, error => { - fail(`should not be here with error: ${error}.`); - }); + setTimeoutPromise(50, 'value') + .then( + value => { + expect(value).toEqual('value'); + done(); + }, + error => { + fail(`should not be here with error: ${error}.`); + }); }); it('util.promisify should work with setImmediate', (done: DoneFn) => { const setImmediatePromise = promisify(setImmediate); - setImmediatePromise('value').then(value => { - expect(value).toEqual('value'); - done(); - }, error => { - fail(`should not be here with error: ${error}.`); - }); + setImmediatePromise('value').then( + value => { + expect(value).toEqual('value'); + done(); + }, + error => { + fail(`should not be here with error: ${error}.`); + }); }); }); \ No newline at end of file diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index a98cb3a7c..7d7c4ee79 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -20,6 +20,7 @@ import '../lib/zone-spec/task-tracking'; import '../lib/zone-spec/wtf'; import '../lib/rxjs/rxjs'; import '../lib/rxjs/rxjs-fake-async'; + // Setup test environment import '../lib/jasmine/jasmine'; import './test-env-setup-jasmine'; diff --git a/test/node_error_entry_point.ts b/test/node_error_entry_point.ts new file mode 100644 index 000000000..f70682ed9 --- /dev/null +++ b/test/node_error_entry_point.ts @@ -0,0 +1,41 @@ +/** + * @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 + */ + +// Must be loaded before zone loads, so that zone can detect WTF. +import './wtf_mock'; +import './test_fake_polyfill'; + +// Setup tests for Zone without microtask support +import '../lib/zone'; +import '../lib/common/promise'; +import '../lib/common/to-string'; + +if (typeof __karma__ !== 'undefined') { + (global as any)['__Zone_Error_BlacklistedStackFrames_policy'] = + (__karma__ as any).config.errorpolicy; +} else if (typeof process !== 'undefined') { + (global as any)['__Zone_Error_BlacklistedStackFrames_policy'] = process.env.errorpolicy; +} + +import '../lib/common/error-rewrite'; +import '../lib/node/node'; +import '../lib/zone-spec/async-test'; +import '../lib/zone-spec/fake-async-test'; +import '../lib/zone-spec/long-stack-trace'; +import '../lib/zone-spec/proxy'; +import '../lib/zone-spec/sync-test'; +import '../lib/zone-spec/task-tracking'; +import '../lib/zone-spec/wtf'; +import '../lib/rxjs/rxjs'; + +import '../lib/testing/promise-testing'; +// Setup test environment +import './test-env-setup-jasmine'; + +// List all tests here: +import './common/Error.spec'; diff --git a/test/webdriver/test.sauce.js b/test/webdriver/test.sauce.js index 13c7e80d1..922f91028 100644 --- a/test/webdriver/test.sauce.js +++ b/test/webdriver/test.sauce.js @@ -16,10 +16,10 @@ const desiredCapabilities = { safari8: {browserName: 'safari', platform: 'OS X 10.10', version: '8.0'}, safari9: {browserName: 'safari', platform: 'OS X 10.11', version: '9.0'}, safari10: {browserName: 'safari', platform: 'OS X 10.11', version: '10.0'}, - safari11: {browserName: 'safari', platform: 'macOS 10.13', version: '11.0'}, + safari11: {browserName: 'safari', platform: 'macOS 10.13', version: '11.1'}, /*ios84: {browserName: 'iphone', platform: 'OS X 10.10', version: '8.4'},*/ ios93: {browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'}, - ios10: {browserName: 'iphone', platform: 'OS X 10.10', version: '10.2'}, + ios10: {browserName: 'iphone', platform: 'OS X 10.10', version: '10.3'}, ios11: {browserName: 'iphone', platform: 'OS X 10.12', version: '11.2'}, /* ie9: { @@ -134,4 +134,4 @@ Promise.all(tasks).then(() => { } else { exit(0); } -}); \ No newline at end of file +}); diff --git a/yarn.lock b/yarn.lock index a5ef50c82..4047760fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,9 +6,9 @@ version "2.2.33" resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.2.33.tgz#4715cfd2ca7fbd632fc7f1784f13e637bed028c5" -"@types/node@^8.10.17": - version "8.10.17" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.17.tgz#d48cf10f0dc6dcf59f827f5a3fc7a4a6004318d3" +"@types/node@^9.x": + version "9.6.22" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.22.tgz#05b55093faaadedea7a4b3f76e9a61346a6dd209" "@types/systemjs@^0.19.30": version "0.19.33" From bf88c347caed5f18a488fc36df487a405b84092a Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 30 Jun 2018 02:34:33 +0900 Subject: [PATCH 056/106] feat(fetch): schedule macroTask when fetch (#1075) --- file-size-limit.json | 4 +- lib/browser/browser.ts | 46 +++++--- lib/browser/rollup-main.ts | 1 + lib/common/fetch.ts | 100 +++++++++++++++++ lib/common/promise.ts | 6 +- lib/zone.ts | 4 +- test/browser-zone-setup.ts | 1 + test/common/Promise.spec.ts | 72 ------------- test/common/fetch.spec.ts | 209 ++++++++++++++++++++++++++++++++++++ test/common_tests.ts | 1 + test/test-util.ts | 16 +++ 11 files changed, 366 insertions(+), 94 deletions(-) create mode 100644 lib/common/fetch.ts create mode 100644 test/common/fetch.spec.ts diff --git a/file-size-limit.json b/file-size-limit.json index 26e5195d5..03d3f5b83 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 40144 + "limit": 41500 } ] -} +} \ No newline at end of file diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index d4873797a..221977e7a 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -199,8 +199,16 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { }); const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - const sendNative = + const fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + const fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + const sendNative: Function|null = patchMethod(XMLHttpRequestPrototype, 'send', () => function(self: any, args: any[]) { + if ((Zone.current as any)[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative!.apply(self, args); + } if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative!.apply(self, args); @@ -212,22 +220,26 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { } }); - const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function(self: any) { - const task: Task = findPendingTask(self); - if (task && typeof task.type == 'string') { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && (task.data).aborted)) { - 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. - }); + const abortNative = + patchMethod(XMLHttpRequestPrototype, 'abort', () => function(self: any, args: any[]) { + const task: Task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && (task.data).aborted)) { + return; + } + task.zone.cancelTask(task); + } else if ((Zone.current as any)[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative!.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }); } }); diff --git a/lib/browser/rollup-main.ts b/lib/browser/rollup-main.ts index f7dfd8759..f360d0bcd 100644 --- a/lib/browser/rollup-main.ts +++ b/lib/browser/rollup-main.ts @@ -8,5 +8,6 @@ import '../zone'; import '../common/promise'; +import '../common/fetch'; import '../common/to-string'; import './browser'; diff --git a/lib/common/fetch.ts b/lib/common/fetch.ts new file mode 100644 index 000000000..5fda7a5ab --- /dev/null +++ b/lib/common/fetch.ts @@ -0,0 +1,100 @@ +/** + * @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.__load_patch('fetch', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const fetch = global['fetch']; + const ZoneAwarePromise = global.Promise; + const symbolThenPatched = api.symbol('thenPatched'); + const fetchTaskScheduling = api.symbol('fetchTaskScheduling'); + const fetchTaskAborting = api.symbol('fetchTaskAborting'); + if (typeof fetch !== 'function') { + return; + } + const OriginalAbortController = global['AbortController']; + const supportAbort = typeof OriginalAbortController === 'function'; + let abortNative: Function|null = null; + if (supportAbort) { + global['AbortController'] = function() { + const abortController = new OriginalAbortController(); + const signal = abortController.signal; + signal.abortController = abortController; + return abortController; + }; + abortNative = api.patchMethod( + OriginalAbortController.prototype, 'abort', + (delegate: Function) => (self: any, args: any) => { + if (self.task) { + return self.task.zone.cancelTask(self.task); + } + return delegate.apply(self, args); + }); + } + const placeholder = function() {}; + global['fetch'] = function() { + const args = Array.prototype.slice.call(arguments); + const options = args.length > 1 ? args[1] : null; + const signal = options && options.signal; + return new Promise((res, rej) => { + const task = Zone.current.scheduleMacroTask( + 'fetch', placeholder, args, + () => { + let fetchPromise; + let zone = Zone.current; + try { + (zone as any)[fetchTaskScheduling] = true; + fetchPromise = fetch.apply(this, args); + } catch (error) { + rej(error); + return; + } finally { + (zone as any)[fetchTaskScheduling] = false; + } + + if (!(fetchPromise instanceof ZoneAwarePromise)) { + let ctor = fetchPromise.constructor; + if (!ctor[symbolThenPatched]) { + api.patchThen(ctor); + } + } + fetchPromise.then( + (resource: any) => { + if (task.state !== 'notScheduled') { + task.invoke(); + } + res(resource); + }, + (error: any) => { + if (task.state !== 'notScheduled') { + task.invoke(); + } + rej(error); + }); + }, + () => { + if (!supportAbort) { + rej('No AbortController supported, can not cancel fetch'); + return; + } + if (signal && signal.abortController && !signal.aborted && + typeof signal.abortController.abort === 'function' && abortNative) { + try { + (Zone.current as any)[fetchTaskAborting] = true; + abortNative.call(signal.abortController); + } finally { + (Zone.current as any)[fetchTaskAborting] = false; + } + } else { + rej('cancel fetch need a AbortController.signal'); + } + }); + if (signal && signal.abortController) { + signal.abortController.task = task; + } + }); + }; +}); \ No newline at end of file diff --git a/lib/common/promise.ts b/lib/common/promise.ts index c59dffdd2..d0775f6c1 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -458,6 +458,8 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr (Ctor as any)[symbolThenPatched] = true; } + api.patchThen = patchThen; + function zoneify(fn: Function) { return function() { let resultPromise = fn.apply(this, arguments); @@ -475,10 +477,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if (NativePromise) { patchThen(NativePromise); - let fetch = global['fetch']; + /*let fetch = global['fetch']; if (typeof fetch == 'function') { global['fetch'] = zoneify(fetch); - } + }*/ } // This is not part of public API, but it is useful for tests, so we expose it. diff --git a/lib/zone.ts b/lib/zone.ts index a71617a3a..7b10783de 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -322,6 +322,7 @@ interface _ZonePrivate { showUncaughtError: () => boolean; patchEventTarget: (global: any, apis: any[], options?: any) => boolean[]; patchOnProperties: (obj: any, properties: string[]|null) => void; + patchThen: (ctro: Function) => void; setNativePromise: (nativePromise: any) => void; patchMethod: (target: any, name: string, @@ -1326,7 +1327,8 @@ const Zone: ZoneType = (function(global: any) { patchEventTarget: () => [], patchOnProperties: noop, patchMethod: () => noop, - bindArguments: () => (null as any), + bindArguments: () => [], + patchThen: () => noop, setNativePromise: (NativePromise: any) => { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 7fb70d1cf..d042450ff 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -11,6 +11,7 @@ if (typeof window !== 'undefined') { } import '../lib/common/to-string'; import '../lib/browser/browser'; +import '../lib/common/fetch'; import '../lib/browser/webapis-user-media'; import '../lib/browser/webapis-media-query'; import '../lib/testing/zone-testing'; diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index e3f3b070b..19e21cc83 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -549,76 +549,4 @@ describe( testPromiseSubClass(); }); }); - - describe('fetch', ifEnvSupports('fetch', function() { - it('should work for text response', function(done) { - testZone.run(function() { - global['fetch']('/base/test/assets/sample.json').then(function(response: any) { - const fetchZone = Zone.current; - expect(fetchZone).toBe(testZone); - - response.text().then(function(text: string) { - expect(Zone.current).toBe(fetchZone); - expect(text.trim()).toEqual('{"hello": "world"}'); - done(); - }); - }); - }); - }); - - it('should work for json response', function(done) { - testZone.run(function() { - global['fetch']('/base/test/assets/sample.json').then(function(response: any) { - const fetchZone = Zone.current; - expect(fetchZone).toBe(testZone); - - response.json().then(function(obj: any) { - expect(Zone.current).toBe(fetchZone); - expect(obj.hello).toEqual('world'); - done(); - }); - }); - }); - }); - - it('should work for blob response', function(done) { - testZone.run(function() { - global['fetch']('/base/test/assets/sample.json').then(function(response: any) { - const fetchZone = Zone.current; - expect(fetchZone).toBe(testZone); - - // Android 4.3- doesn't support response.blob() - if (response.blob) { - response.blob().then(function(blob: any) { - expect(Zone.current).toBe(fetchZone); - expect(blob instanceof Blob).toEqual(true); - done(); - }); - } else { - done(); - } - }); - }); - }); - - it('should work for arrayBuffer response', function(done) { - testZone.run(function() { - global['fetch']('/base/test/assets/sample.json').then(function(response: any) { - const fetchZone = Zone.current; - expect(fetchZone).toBe(testZone); - - // Android 4.3- doesn't support response.arrayBuffer() - if (response.arrayBuffer) { - response.arrayBuffer().then(function(blob: any) { - expect(Zone.current).toBe(fetchZone); - expect(blob instanceof ArrayBuffer).toEqual(true); - done(); - }); - } else { - done(); - } - }); - }); - }); - })); })); diff --git a/test/common/fetch.spec.ts b/test/common/fetch.spec.ts new file mode 100644 index 000000000..f2eb0e348 --- /dev/null +++ b/test/common/fetch.spec.ts @@ -0,0 +1,209 @@ +/** + * @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 {ifEnvSupports, ifEnvSupportsWithDone, isFirefox, isSafari} from '../test-util'; + +declare const global: any; + +describe( + 'fetch', ifEnvSupports('fetch', function() { + let testZone: Zone; + beforeEach(() => { + testZone = Zone.current.fork({name: 'TestZone'}); + }); + it('should work for text response', function(done) { + testZone.run(function() { + global['fetch']('/base/test/assets/sample.json').then(function(response: any) { + const fetchZone = Zone.current; + expect(fetchZone.name).toBe(testZone.name); + + response.text().then(function(text: string) { + expect(Zone.current.name).toBe(fetchZone.name); + expect(text.trim()).toEqual('{"hello": "world"}'); + done(); + }); + }); + }); + }); + + it('should work for json response', function(done) { + testZone.run(function() { + global['fetch']('/base/test/assets/sample.json').then(function(response: any) { + const fetchZone = Zone.current; + expect(fetchZone.name).toBe(testZone.name); + + response.json().then(function(obj: any) { + expect(Zone.current.name).toBe(fetchZone.name); + expect(obj.hello).toEqual('world'); + done(); + }); + }); + }); + }); + + it('should work for blob response', function(done) { + testZone.run(function() { + global['fetch']('/base/test/assets/sample.json').then(function(response: any) { + const fetchZone = Zone.current; + expect(fetchZone.name).toBe(testZone.name); + + // Android 4.3- doesn't support response.blob() + if (response.blob) { + response.blob().then(function(blob: any) { + expect(Zone.current.name).toBe(fetchZone.name); + expect(blob instanceof Blob).toEqual(true); + done(); + }); + } else { + done(); + } + }); + }); + }); + + it('should work for arrayBuffer response', function(done) { + testZone.run(function() { + global['fetch']('/base/test/assets/sample.json').then(function(response: any) { + const fetchZone = Zone.current; + expect(fetchZone.name).toBe(testZone.name); + + // Android 4.3- doesn't support response.arrayBuffer() + if (response.arrayBuffer) { + response.arrayBuffer().then(function(blob: any) { + expect(Zone.current).toBe(fetchZone); + expect(blob instanceof ArrayBuffer).toEqual(true); + done(); + }); + } else { + done(); + } + }); + }); + }); + + it('should throw error when send crendential', + ifEnvSupportsWithDone(isFirefox, function(done: DoneFn) { + testZone.run(function() { + global['fetch']('http://user:password@example.com') + .then( + function(response: any) { + fail('should not success'); + }, + (error: any) => { + expect(Zone.current.name).toEqual(testZone.name); + expect(error.constructor.name).toEqual('TypeError'); + done(); + }); + }); + })); + + describe('macroTask', () => { + const logs: string[] = []; + let fetchZone: Zone; + let fetchTask: any = null; + beforeEach(() => { + logs.splice(0); + fetchZone = Zone.current.fork({ + name: 'fetch', + onScheduleTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, task: Task) => { + if (task.type !== 'eventTask') { + logs.push(`scheduleTask:${task.source}:${task.type}`); + } + if (task.source === 'fetch') { + fetchTask = task; + } + return delegate.scheduleTask(target, task); + }, + onInvokeTask: + (delegate: ZoneDelegate, curr: Zone, target: Zone, task: Task, applyThis: any, + applyArgs: any) => { + if (task.type !== 'eventTask') { + logs.push(`invokeTask:${task.source}:${task.type}`); + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, task: Task) => { + if (task.type !== 'eventTask') { + logs.push(`cancelTask:${task.source}:${task.type}`); + } + return delegate.cancelTask(target, task); + } + }); + }); + it('fetch should be considered as macroTask', (done: DoneFn) => { + fetchZone.run(() => { + global['fetch']('/base/test/assets/sample.json').then(function(response: any) { + expect(Zone.current.name).toBe(fetchZone.name); + expect(logs).toEqual([ + 'scheduleTask:fetch:macroTask', 'scheduleTask:Promise.then:microTask', + 'invokeTask:Promise.then:microTask', 'invokeTask:fetch:macroTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask' + ]); + done(); + }); + }); + }); + + it('cancel fetch should invoke onCancelTask', + ifEnvSupportsWithDone('AbortController', (done: DoneFn) => { + if (isSafari) { + // safari not work with AbortController + done(); + return; + } + fetchZone.run(() => { + const AbortController = global['AbortController']; + const abort = new AbortController(); + const signal = abort.signal; + global['fetch']('/base/test/assets/sample.json', {signal}) + .then(function(response: any) { + fail('should not get response'); + }) + .catch(function(error: any) { + expect(error.name).toEqual('AbortError'); + expect(logs).toEqual([ + 'scheduleTask:fetch:macroTask', 'cancelTask:fetch:macroTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask' + ]); + done(); + }); + abort.abort(); + }); + })); + + it('cancel fetchTask should trigger abort', + ifEnvSupportsWithDone('AbortController', (done: DoneFn) => { + if (isSafari) { + // safari not work with AbortController + done(); + return; + } + fetchZone.run(() => { + const AbortController = global['AbortController']; + const abort = new AbortController(); + const signal = abort.signal; + global['fetch']('/base/test/assets/sample.json', {signal}) + .then(function(response: any) { + fail('should not get response'); + }) + .catch(function(error: any) { + expect(error.name).toEqual('AbortError'); + expect(logs).toEqual([ + 'scheduleTask:fetch:macroTask', 'cancelTask:fetch:macroTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask', + 'scheduleTask:Promise.then:microTask', 'invokeTask:Promise.then:microTask' + ]); + done(); + }); + fetchTask.zone.cancelTask(fetchTask); + }); + })); + }); + })); diff --git a/test/common_tests.ts b/test/common_tests.ts index 2fbb7ecfd..426762d56 100644 --- a/test/common_tests.ts +++ b/test/common_tests.ts @@ -11,6 +11,7 @@ import './common/zone.spec'; import './common/task.spec'; import './common/util.spec'; import './common/Promise.spec'; +import './common/fetch.spec'; import './common/Error.spec'; import './common/setInterval.spec'; import './common/setTimeout.spec'; diff --git a/test/test-util.ts b/test/test-util.ts index 5a58cf8bd..54bf4ff9a 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -103,6 +103,22 @@ export function getIEVersion() { return null; } +export function isFirefox() { + const userAgent = navigator.userAgent.toLowerCase(); + if (userAgent.indexOf('firefox') != -1) { + return true; + } + return false; +} + +export function isSafari() { + const userAgent = navigator.userAgent.toLowerCase(); + if (userAgent.indexOf('safari') != -1) { + return true; + } + return false; +} + export function isEdge() { const userAgent = navigator.userAgent.toLowerCase(); return userAgent.indexOf('edge') !== -1; From a86c6d5c20efb900ababb2c161c5eb0867795069 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 4 Jul 2018 07:49:51 +0900 Subject: [PATCH 057/106] feat(Core): fix #910, add a flag to allow user to ignore duplicate Zone error (#1093) --- lib/zone.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/zone.ts b/lib/zone.ts index 7b10783de..4de4e077d 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -644,7 +644,21 @@ const Zone: ZoneType = (function(global: any) { } mark('Zone'); if (global['Zone']) { - throw new Error('Zone already loaded.'); + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (global[('__zone_symbol__forceDuplicateZoneCheck')] === true || + typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } else { + return global['Zone']; + } } class Zone implements AmbientZone { From 34c12e51d44c3b7909e58e30492955e2ffff0c5a Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 4 Jul 2018 07:50:26 +0900 Subject: [PATCH 058/106] fix(xhr): fix #1072, should set scheduled flag to target (#1074) --- file-size-limit.json | 2 +- lib/browser/browser.ts | 20 ++++++-- test/browser/XMLHttpRequest.spec.ts | 73 +++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 5 deletions(-) diff --git a/file-size-limit.json b/file-size-limit.json index 03d3f5b83..6df60d7e1 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 41500 + "limit": 41600 } ] } \ No newline at end of file diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 221977e7a..bf01626d7 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -96,6 +96,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { const XHR_LISTENER = zoneSymbol('xhrListener'); const XHR_SCHEDULED = zoneSymbol('xhrScheduled'); const XHR_URL = zoneSymbol('xhrURL'); + const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); interface XHROptions extends TaskData { target: any; @@ -126,9 +127,10 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { const SCHEDULED = 'scheduled'; function scheduleTask(task: Task) { - (XMLHttpRequest as any)[XHR_SCHEDULED] = false; const data = task.data; const target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; // remove existing event listener const listener = target[XHR_LISTENER]; if (!oriAddListener) { @@ -143,7 +145,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { if (target.readyState === target.DONE) { // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && (XMLHttpRequest as any)[XHR_SCHEDULED] && task.state === SCHEDULED) { + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { // check whether the xhr has registered onload listener // if that is the case, the task should invoke after all // onload listeners finish. @@ -167,6 +169,9 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { } else { task.invoke(); } + } else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } }; @@ -177,7 +182,7 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { target[XHR_TASK] = task; } sendNative!.apply(target, data.args); - (XMLHttpRequest as any)[XHR_SCHEDULED] = true; + target[XHR_SCHEDULED] = true; return task; } @@ -215,8 +220,15 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { } else { const options: XHROptions = {target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false}; - return scheduleMacroTaskWithCurrentZone( + const task = scheduleMacroTaskWithCurrentZone( XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } } }); diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/browser/XMLHttpRequest.spec.ts index a1b59cff0..584f931e3 100644 --- a/test/browser/XMLHttpRequest.spec.ts +++ b/test/browser/XMLHttpRequest.spec.ts @@ -266,6 +266,79 @@ describe('XMLHttpRequest', function() { }); }); + it('should trigger readystatechange if xhr request trigger cors error', (done) => { + const req = new XMLHttpRequest(); + let err: any = null; + try { + req.open('get', 'file:///test', true); + } catch (err) { + // in IE, open will throw Access is denied error + done(); + return; + } + req.addEventListener('readystatechange', function(ev) { + if (req.readyState === 4) { + const xhrScheduled = (req as any)['__zone_symbol__xhrScheduled']; + const task = (req as any)['__zone_symbol__xhrTask']; + if (xhrScheduled === false) { + expect(task.state).toEqual('scheduling'); + setTimeout(() => { + if (err) { + expect(task.state).toEqual('unknown'); + } else { + expect(task.state).toEqual('notScheduled'); + } + done(); + }); + } else { + expect(task.state).toEqual('scheduled'); + done(); + } + } + }); + try { + req.send(); + } catch (error) { + err = error; + } + }); + + it('should invoke task if xhr request trigger cors error', (done) => { + const logs: string[] = []; + const zone = Zone.current.fork({ + name: 'xhr', + onHasTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, hasTask: HasTaskState) => { + logs.push(JSON.stringify(hasTask)); + } + }); + const req = new XMLHttpRequest(); + try { + req.open('get', 'file:///test', true); + } catch (err) { + // in IE, open will throw Access is denied error + done(); + return; + } + zone.run(() => { + let isError = false; + let timerId = null; + try { + timerId = (window as any)['__zone_symbol__setTimeout'](() => { + expect(logs).toEqual([ + `{"microTask":false,"macroTask":true,"eventTask":false,"change":"macroTask"}`, + `{"microTask":false,"macroTask":false,"eventTask":false,"change":"macroTask"}` + ]); + done(); + }, 500); + req.send(); + } catch (error) { + isError = true; + (window as any)['__zone_symbol__clearTimeout'](timerId); + done(); + } + }); + }); + it('should not throw error when get XMLHttpRequest.prototype.onreadystatechange the first time', function() { const func = function() { From 875086fe227e6657178884535c54ebf15ec13ac5 Mon Sep 17 00:00:00 2001 From: LookingMan Date: Tue, 17 Jul 2018 23:29:13 +0300 Subject: [PATCH 059/106] fix(memory): Add protection against excessive on prop patching (#1106) This caused memory leaks in Jest JSDOM environment --- lib/common/utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 0165da1c0..e1a184f48 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -158,6 +158,11 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { return; } + const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable // deleting the writable and value properties avoids this error: // @@ -240,6 +245,8 @@ export function patchProperty(obj: any, prop: string, prototype?: any) { }; ObjectDefineProperty(obj, prop, desc); + + obj[onPropPatchedSymbol] = true; } export function patchOnProperties(obj: any, properties: string[]|null, prototype?: any) { From 49e05484b2bc28d80a64846556bfd7863a828c27 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 18 Jul 2018 05:30:04 +0900 Subject: [PATCH 060/106] fix(core): fix #1108, window.onerror should have (message, source, lineno, colno, error) signiture (#1109) --- file-size-limit.json | 2 +- lib/browser/property-descriptor.ts | 9 +++++--- lib/common/utils.ts | 34 ++++++++++++++++++++++++++---- test/browser/browser.spec.ts | 22 +++++++++++++++++-- test/test-util.ts | 9 ++++++++ 5 files changed, 66 insertions(+), 10 deletions(-) diff --git a/file-size-limit.json b/file-size-limit.json index 6df60d7e1..c730e24ff 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 41600 + "limit": 42000 } ] } \ No newline at end of file diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index b302eaad5..1ac33b3d4 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -10,7 +10,7 @@ * @suppress {globalThis} */ -import {isBrowser, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, patchClass, patchOnProperties, wrapWithCurrentZone, zoneSymbol} from '../common/utils'; +import {isBrowser, isIE, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, patchClass, patchOnProperties, wrapWithCurrentZone, zoneSymbol} from '../common/utils'; import * as webSocketPatch from './websocket'; @@ -241,7 +241,7 @@ export interface IgnoreProperty { function filterProperties( target: any, onProperties: string[], ignoreProperties: IgnoreProperty[]): string[] { - if (!ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { return onProperties; } @@ -276,10 +276,13 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { const internalWindow: any = window; + const ignoreErrorProperties = + isIE ? [{target: internalWindow, ignoreProperties: ['error']}] : []; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not patchFilteredProperties( - internalWindow, eventNames.concat(['messageerror']), ignoreProperties, + internalWindow, eventNames.concat(['messageerror']), + ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index e1a184f48..77554e524 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -135,11 +135,26 @@ const wrapFn = function(event: Event) { } const target = this || event.target || _global; const listener = target[eventNameSymbol]; - let result = listener && listener.apply(this, arguments); - - if (result != undefined && !result) { - event.preventDefault(); + let result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + const errorEvent: ErrorEvent = event as any; + result = listener && + listener.call( + this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, + errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } + return result; }; @@ -475,6 +490,17 @@ export function attachOriginToPatched(patched: Function, original: any) { let isDetectedIEOrEdge = false; let ieOrEdge = false; +export function isIE() { + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } catch (error) { + } + return false; +} + export function isIEOrEdge() { if (isDetectedIEOrEdge) { return ieOrEdge; diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 0ca232fb3..93c840c4c 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -9,7 +9,7 @@ import {patchFilteredProperties} from '../../lib/browser/property-descriptor'; import {patchEventTarget} from '../../lib/common/events'; import {isBrowser, isIEOrEdge, isMix, zoneSymbol} from '../../lib/common/utils'; -import {getIEVersion, ifEnvSupports, ifEnvSupportsWithDone, isEdge} from '../test-util'; +import {getEdgeVersion, getIEVersion, ifEnvSupports, ifEnvSupportsWithDone, isEdge} from '../test-util'; import Spy = jasmine.Spy; declare const global: any; @@ -190,7 +190,7 @@ describe('Zone', function() { 'onvrdisplayactivate', 'onvrdisplayblur', 'onvrdisplayconnect', 'onvrdisplaydeactivate', 'onvrdisplaydisconnect', 'onvrdisplayfocus', 'onvrdisplaypointerrestricted', 'onvrdisplaypointerunrestricted', - 'onorientationchange' + 'onorientationchange', 'onerror' ]); }); @@ -390,6 +390,24 @@ describe('Zone', function() { }; expect(testFn).not.toThrow(); })); + + it('window.onerror callback signiture should be (message, source, lineno, colno, error)', + ifEnvSupportsWithDone(canPatchOnProperty(window, 'onerror'), function(done: DoneFn) { + let testError = new Error('testError'); + window.onerror = function( + message: any, source?: string, lineno?: number, colno?: number, error?: any) { + expect(message).toContain('testError'); + if (getEdgeVersion() !== 14) { + // Edge 14, error will be undefined. + expect(error).toBe(testError); + } + setTimeout(done); + return true; + }; + setTimeout(() => { + throw testError; + }, 100); + })); })); describe('eventListener hooks', function() { diff --git a/test/test-util.ts b/test/test-util.ts index 54bf4ff9a..46a28c699 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -123,3 +123,12 @@ export function isEdge() { const userAgent = navigator.userAgent.toLowerCase(); return userAgent.indexOf('edge') !== -1; } + +export function getEdgeVersion() { + const ua = navigator.userAgent.toLowerCase(); + const edge = ua.indexOf('edge/'); + if (edge === -1) { + return -1; + } + return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); +} From 6ba3169876a1be02410385651a9d23667eef0e93 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 28 Jul 2018 02:42:16 +0900 Subject: [PATCH 061/106] fix(bluebird): fix #1112, bluebird chained callback should return a Bluebird Promise (#1114) --- file-size-limit.json | 2 +- lib/common/promise.ts | 5 -- lib/extra/bluebird.ts | 20 ++++- test/extra/bluebird.spec.ts | 156 ++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 8 deletions(-) diff --git a/file-size-limit.json b/file-size-limit.json index c730e24ff..e5e12f2ef 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 42000 + "limit": 42050 } ] } \ No newline at end of file diff --git a/lib/common/promise.ts b/lib/common/promise.ts index d0775f6c1..ce765a260 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -476,11 +476,6 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if (NativePromise) { patchThen(NativePromise); - - /*let fetch = global['fetch']; - if (typeof fetch == 'function') { - global['fetch'] = zoneify(fetch); - }*/ } // This is not part of public API, but it is useful for tests, so we expose it. diff --git a/lib/extra/bluebird.ts b/lib/extra/bluebird.ts index 5fd00d3b6..59b4feec4 100644 --- a/lib/extra/bluebird.ts +++ b/lib/extra/bluebird.ts @@ -25,8 +25,14 @@ Zone.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) = args[i] = function() { const argSelf: any = this; const argArgs: any = arguments; - zone.scheduleMicroTask('Promise.then', () => { - return func.apply(argSelf, argArgs); + return new Bluebird((res: any, rej: any) => { + zone.scheduleMicroTask('Promise.then', () => { + try { + res(func.apply(argSelf, argArgs)); + } catch (error) { + rej(error); + } + }); }); }; } @@ -35,6 +41,16 @@ Zone.__load_patch('bluebird', (global: any, Zone: ZoneType, api: _ZonePrivate) = }); }); + Bluebird.onPossiblyUnhandledRejection(function(e: any, promise: any) { + try { + Zone.current.runGuarded(() => { + throw e; + }); + } catch (err) { + api.onUnhandledError(err); + } + }); + // override global promise global[api.symbol('ZoneAwarePromise')] = Bluebird; }; diff --git a/test/extra/bluebird.spec.ts b/test/extra/bluebird.spec.ts index 5e2e6eed7..41733e735 100644 --- a/test/extra/bluebird.spec.ts +++ b/test/extra/bluebird.spec.ts @@ -9,6 +9,10 @@ // this spec will not be integrated with Travis CI, because I don't // want to add bluebird into devDependencies, you can run this spec // on your local environment +process.on('unhandledRejection', (reason, p) => { + console.log('Unhandled Rejection at:', p, 'reason:', reason); + // application specific logging, throwing an error, or other logic here +}); describe('bluebird promise', () => { let BluebirdPromise: any; @@ -636,4 +640,156 @@ describe('bluebird promise', () => { }); }); }); + + it('should be able to chain promise', (done: DoneFn) => { + Zone.current.fork({name: 'zone_A'}).run(() => { + new BluebirdPromise((resolve: any, reject: any) => { + expect(Zone.current.name).toEqual('zone_A'); + resolve(1); + }) + .then((r: any) => { + expect(r).toBe(1); + expect(Zone.current.name).toEqual('zone_A'); + return Promise.resolve(2); + }) + .then((r: any) => { + expect(r).toBe(2); + expect(Zone.current.name).toEqual('zone_A'); + }); + }); + Zone.current.fork({name: 'zone_B'}).run(() => { + new BluebirdPromise((resolve: any, reject: any) => { + expect(Zone.current.name).toEqual('zone_B'); + reject(1); + }) + .then( + () => { + fail('should not be here.'); + }, + (r: any) => { + expect(r).toBe(1); + expect(Zone.current.name).toEqual('zone_B'); + return Promise.resolve(2); + }) + .then((r: any) => { + expect(r).toBe(2); + expect(Zone.current.name).toEqual('zone_B'); + done(); + }); + }); + }); + + it('should catch rejected chained bluebird promise', (done: DoneFn) => { + const logs: string[] = []; + const zone = Zone.current.fork({ + name: 'testErrorHandling', + onHandleError: function() { + // should not get here + logs.push('onHandleError'); + return true; + } + }); + + zone.runGuarded(() => { + return BluebirdPromise.resolve() + .then(() => { + throw new Error('test error'); + }) + .catch(() => { + expect(logs).toEqual([]); + done(); + }); + }); + }); + + it('should catch rejected chained global promise', (done: DoneFn) => { + const logs: string[] = []; + const zone = Zone.current.fork({ + name: 'testErrorHandling', + onHandleError: function() { + // should not get here + logs.push('onHandleError'); + return true; + } + }); + + zone.runGuarded(() => { + return Promise.resolve() + .then(() => { + throw new Error('test error'); + }) + .catch(() => { + expect(logs).toEqual([]); + done(); + }); + }); + }); + + it('should catch rejected bluebird promise', (done: DoneFn) => { + const logs: string[] = []; + const zone = Zone.current.fork({ + name: 'testErrorHandling', + onHandleError: function() { + // should not get here + logs.push('onHandleError'); + return true; + } + }); + + zone.runGuarded(() => { + return BluebirdPromise.reject().catch(() => { + expect(logs).toEqual([]); + done(); + }); + }); + }); + + it('should catch rejected global promise', (done: DoneFn) => { + const logs: string[] = []; + const zone = Zone.current.fork({ + name: 'testErrorHandling', + onHandleError: function() { + // should not get here + logs.push('onHandleError'); + return true; + } + }); + + zone.runGuarded(() => { + return Promise.reject(new Error('reject')).catch(() => { + expect(logs).toEqual([]); + done(); + }); + }); + }); + + it('should trigger onHandleError when unhandledRejection', (done: DoneFn) => { + const zone = Zone.current.fork({ + name: 'testErrorHandling', + onHandleError: function() { + setTimeout(done, 100); + return true; + } + }); + + zone.runGuarded(() => { + return Promise.reject(new Error('reject')); + }); + }); + + it('should trigger onHandleError when unhandledRejection in chained Promise', (done: DoneFn) => { + const zone = Zone.current.fork({ + name: 'testErrorHandling', + onHandleError: function() { + setTimeout(done, 100); + return true; + } + }); + + zone.runGuarded(() => { + return Promise.resolve().then(() => { + throw new Error('test'); + }); + }); + }); }); From 9c9690415237bd5866d20a360ec4049740de4742 Mon Sep 17 00:00:00 2001 From: Mitchell Wills Date: Fri, 27 Jul 2018 10:43:08 -0700 Subject: [PATCH 062/106] Ensure FakeAsyncTestZoneSpec tick always doTick (#1099) In the case where there is pending work in the scheduler queue, but the duration of the tick did not causes it to run the doTick callback would not be called (or would not be called with intervals summing to the total time ellapsed). --- lib/zone-spec/fake-async-test.ts | 4 ++++ test/zone-spec/fake-async-test.spec.ts | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 724ce68fa..307470cb1 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -150,7 +150,11 @@ class Scheduler { } } } + lastCurrentTime = this._currentTime; this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } } flush(limit = 20, flushPeriodic = false, doTick?: (elapsed: number) => void): number { diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index af2473765..21a2be440 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -172,6 +172,25 @@ describe('FakeAsyncTestZoneSpec', () => { }); }); + it('should run doTick callback even if no work ran', () => { + fakeAsyncTestZone.run(() => { + let totalElapsed = 0; + function doTick(elapsed: number) { + totalElapsed += elapsed; + } + setTimeout(() => {}, 10); + + testZoneSpec.tick(6, doTick); + expect(totalElapsed).toEqual(6); + + testZoneSpec.tick(6, doTick); + expect(totalElapsed).toEqual(12); + + testZoneSpec.tick(6, doTick); + expect(totalElapsed).toEqual(18); + }); + }); + it('should run queued timer created by timer callback', () => { fakeAsyncTestZone.run(() => { let counter = 0; From 31fc1276ef7bf37f173315b70bde25b41f8aa7fd Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Fri, 7 Sep 2018 08:08:37 +0900 Subject: [PATCH 063/106] feat(build): Upgrade to TypeScript 2.9 and rxjs6 (#1122) This includes a migration to TS2.9, and a migration to RxJS 6 (which is required for TS2.9 support). --- karma-base.conf.js | 1 + lib/rxjs/rxjs-fake-async.ts | 8 +- lib/rxjs/rxjs.ts | 278 ++++-------------- package.json | 5 +- test/browser_entry_point.ts | 2 + test/main.ts | 5 +- test/rxjs/rxjs.Observable.audit.spec.ts | 22 +- test/rxjs/rxjs.Observable.buffer.spec.ts | 49 +-- test/rxjs/rxjs.Observable.catch.spec.ts | 25 +- test/rxjs/rxjs.Observable.collection.spec.ts | 137 ++++----- test/rxjs/rxjs.Observable.combine.spec.ts | 40 +-- test/rxjs/rxjs.Observable.concat.spec.ts | 40 +-- test/rxjs/rxjs.Observable.count.spec.ts | 11 +- test/rxjs/rxjs.Observable.debounce.spec.ts | 16 +- test/rxjs/rxjs.Observable.default.spec.ts | 8 +- test/rxjs/rxjs.Observable.delay.spec.ts | 17 +- test/rxjs/rxjs.Observable.distinct.spec.ts | 19 +- test/rxjs/rxjs.Observable.do.spec.ts | 15 +- test/rxjs/rxjs.Observable.map.spec.ts | 23 +- test/rxjs/rxjs.Observable.merge.spec.ts | 63 ++-- test/rxjs/rxjs.Observable.multicast.spec.ts | 21 +- .../rxjs/rxjs.Observable.notification.spec.ts | 20 +- test/rxjs/rxjs.Observable.race.spec.ts | 11 +- test/rxjs/rxjs.Observable.sample.spec.ts | 18 +- test/rxjs/rxjs.Observable.take.spec.ts | 20 +- test/rxjs/rxjs.Observable.timeout.spec.ts | 18 +- test/rxjs/rxjs.Observable.window.spec.ts | 44 ++- test/rxjs/rxjs.asap.spec.ts | 59 ++-- test/rxjs/rxjs.bindCallback.spec.ts | 11 +- test/rxjs/rxjs.bindNodeCallback.spec.ts | 13 +- test/rxjs/rxjs.combineLatest.spec.ts | 57 ++-- test/rxjs/rxjs.common.spec.ts | 88 +++--- test/rxjs/rxjs.concat.spec.ts | 19 +- test/rxjs/rxjs.defer.spec.ts | 10 +- test/rxjs/rxjs.empty.spec.ts | 8 +- test/rxjs/rxjs.forkjoin.spec.ts | 17 +- test/rxjs/rxjs.from.spec.ts | 13 +- test/rxjs/rxjs.fromEvent.spec.ts | 8 +- test/rxjs/rxjs.fromPromise.spec.ts | 6 +- test/rxjs/rxjs.interval.spec.ts | 11 +- test/rxjs/rxjs.merge.spec.ts | 12 +- test/rxjs/rxjs.never.spec.ts | 9 +- test/rxjs/rxjs.of.spec.ts | 8 +- test/rxjs/rxjs.range.spec.ts | 11 +- test/rxjs/rxjs.spec.ts | 6 +- test/rxjs/rxjs.throw.spec.ts | 11 +- test/rxjs/rxjs.timer.spec.ts | 23 +- test/rxjs/rxjs.util.ts | 14 + test/rxjs/rxjs.zip.spec.ts | 11 +- test/test-util.ts | 10 + test/zone-spec/fake-async-test.spec.ts | 6 +- yarn.lock | 26 +- 52 files changed, 669 insertions(+), 734 deletions(-) create mode 100644 test/rxjs/rxjs.util.ts diff --git a/karma-base.conf.js b/karma-base.conf.js index 32f447cff..35b218c97 100644 --- a/karma-base.conf.js +++ b/karma-base.conf.js @@ -17,6 +17,7 @@ module.exports = function(config) { {pattern: 'node_modules/rxjs/**/**/*.js.map', included: false, watched: false}, {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false}, {pattern: 'node_modules/es6-promise/**/*.js', included: false, watched: false}, + {pattern: 'node_modules/core-js/**/*.js', included: false, watched: false}, {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false}, {pattern: 'test/assets/**/*.*', watched: true, served: true, included: false}, {pattern: 'build/**/*.js.map', watched: true, served: true, included: false}, diff --git a/lib/rxjs/rxjs-fake-async.ts b/lib/rxjs/rxjs-fake-async.ts index 85ef31dc7..fc1b617b7 100644 --- a/lib/rxjs/rxjs-fake-async.ts +++ b/lib/rxjs/rxjs-fake-async.ts @@ -6,18 +6,16 @@ * found in the LICENSE file at https://angular.io/license */ -import {Scheduler} from 'rxjs/Scheduler'; -import {asap} from 'rxjs/scheduler/asap'; -import {async} from 'rxjs/scheduler/async'; +import {asapScheduler, asyncScheduler, Scheduler} from 'rxjs'; Zone.__load_patch('rxjs.Scheduler.now', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchMethod(Scheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { return Date.now.apply(self, args); }); - api.patchMethod(async, 'now', (delegate: Function) => (self: any, args: any[]) => { + api.patchMethod(asyncScheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { return Date.now.apply(self, args); }); - api.patchMethod(asap, 'now', (delegate: Function) => (self: any, args: any[]) => { + api.patchMethod(asapScheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { return Date.now.apply(self, args); }); }); diff --git a/lib/rxjs/rxjs.ts b/lib/rxjs/rxjs.ts index b8e5340a1..4a29a7405 100644 --- a/lib/rxjs/rxjs.ts +++ b/lib/rxjs/rxjs.ts @@ -6,20 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import 'rxjs/add/observable/bindCallback'; -import 'rxjs/add/observable/bindNodeCallback'; -import 'rxjs/add/observable/defer'; -import 'rxjs/add/observable/forkJoin'; -import 'rxjs/add/observable/fromEventPattern'; -import 'rxjs/add/operator/multicast'; +import {Observable, Subscriber, Subscription} from 'rxjs'; -import {Observable} from 'rxjs/Observable'; -import {asap} from 'rxjs/scheduler/asap'; -import {Subscriber} from 'rxjs/Subscriber'; -import {Subscription} from 'rxjs/Subscription'; -import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; - -(Zone as any).__load_patch('rxjs', (global: any, Zone: ZoneType) => { +(Zone as any).__load_patch('rxjs', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const symbol: (symbolString: string) => string = (Zone as any).__symbol__; const nextSource = 'rxjs.Subscriber.next'; const errorSource = 'rxjs.Subscriber.error'; @@ -27,40 +16,10 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; const ObjectDefineProperties = Object.defineProperties; - const empty = { - closed: true, - next(value: any): void{}, - error(err: any): void { - throw err; - }, - complete(): void {} - }; - - function toSubscriber( - nextOrObserver?: any, error?: (error: any) => void, complete?: () => void): Subscriber { - if (nextOrObserver) { - if (nextOrObserver instanceof Subscriber) { - return (>nextOrObserver); - } - - if (nextOrObserver[rxSubscriber]) { - return nextOrObserver[rxSubscriber](); - } - } - - if (!nextOrObserver && !error && !complete) { - return new Subscriber(empty); - } - - return new Subscriber(nextOrObserver, error, complete); - } - const patchObservable = function() { const ObservablePrototype: any = Observable.prototype; - const symbolSubscribe = symbol('subscribe'); const _symbolSubscribe = symbol('_subscribe'); const _subscribe = ObservablePrototype[_symbolSubscribe] = ObservablePrototype._subscribe; - const subscribe = ObservablePrototype[symbolSubscribe] = ObservablePrototype.subscribe; ObjectDefineProperties(Observable.prototype, { _zone: {value: null, writable: true, configurable: true}, @@ -89,30 +48,58 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; }, set: function(this: Observable, subscribe: any) { (this as any)._zone = Zone.current; - (this as any)._zoneSubscribe = subscribe; + (this as any)._zoneSubscribe = function() { + if (this._zone && this._zone !== Zone.current) { + const tearDown = this._zone.run(subscribe, this, arguments); + if (tearDown && typeof tearDown === 'function') { + const zone = this._zone; + return function() { + if (zone !== Zone.current) { + return zone.run(tearDown, this, arguments); + } + return tearDown.apply(this, arguments); + }; + } + return tearDown; + } + return subscribe.apply(this, arguments); + }; } }, - subscribe: { - writable: true, - configurable: true, - value: function(this: Observable, observerOrNext: any, error: any, complete: any) { - // Only grab a zone if we Zone exists and it is different from the current zone. - const _zone = (this as any)._zone; - if (_zone && _zone !== Zone.current) { - // Current Zone is different from the intended zone. - // Restore the zone before invoking the subscribe callback. - return _zone.run(subscribe, this, [toSubscriber(observerOrNext, error, complete)]); - } - return subscribe.call(this, observerOrNext, error, complete); + subjectFactory: { + get: function() { + return (this as any)._zoneSubjectFactory; + }, + set: function(factory: any) { + const zone = this._zone; + this._zoneSubjectFactory = function() { + if (zone && zone !== Zone.current) { + return zone.run(factory, this, arguments); + } + return factory.apply(this, arguments); + }; } } }); }; + api.patchMethod(Observable.prototype, 'lift', (delegate: any) => (self: any, args: any[]) => { + const observable: any = delegate.apply(self, args); + if (observable.operator) { + observable.operator._zone = Zone.current; + api.patchMethod( + observable.operator, 'call', + (operatorDelegate: any) => (operatorSelf: any, operatorArgs: any[]) => { + if (operatorSelf._zone && operatorSelf._zone !== Zone.current) { + return operatorSelf._zone.run(operatorDelegate, operatorSelf, operatorArgs); + } + return operatorDelegate.apply(operatorSelf, operatorArgs); + }); + } + return observable; + }); + const patchSubscription = function() { - const unsubscribeSymbol = symbol('unsubscribe'); - const unsubscribe = (Subscription.prototype as any)[unsubscribeSymbol] = - Subscription.prototype.unsubscribe; ObjectDefineProperties(Subscription.prototype, { _zone: {value: null, writable: true, configurable: true}, _zoneUnsubscribe: {value: null, writable: true, configurable: true}, @@ -126,22 +113,12 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; }, set: function(this: Subscription, unsubscribe: any) { (this as any)._zone = Zone.current; - (this as any)._zoneUnsubscribe = unsubscribe; - } - }, - unsubscribe: { - writable: true, - configurable: true, - value: function(this: Subscription) { - // Only grab a zone if we Zone exists and it is different from the current zone. - const _zone: Zone = (this as any)._zone; - if (_zone && _zone !== Zone.current) { - // Current Zone is different from the intended zone. - // Restore the zone before invoking the subscribe callback. - _zone.run(unsubscribe, this); - } else { - unsubscribe.apply(this); - } + (this as any)._zoneUnsubscribe = function() { + if (this._zone && this._zone !== Zone.current) { + return this._zone.run(unsubscribe, this, arguments); + } + return unsubscribe.apply(this, arguments); + }; } } }); @@ -205,158 +182,7 @@ import {rxSubscriber} from 'rxjs/symbol/rxSubscriber'; }; }; - const patchObservableInstance = function(observable: any) { - observable._zone = Zone.current; - }; - - const patchObservableFactoryCreator = function(obj: any, factoryName: string) { - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factoryCreator: any = obj[symbolFactory] = obj[factoryName]; - if (!factoryCreator) { - return; - } - obj[factoryName] = function() { - const factory: any = factoryCreator.apply(this, arguments); - return function() { - const observable = factory.apply(this, arguments); - patchObservableInstance(observable); - return observable; - }; - }; - }; - - const patchObservableFactory = function(obj: any, factoryName: string) { - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factory: any = obj[symbolFactory] = obj[factoryName]; - if (!factory) { - return; - } - obj[factoryName] = function() { - const observable = factory.apply(this, arguments); - patchObservableInstance(observable); - return observable; - }; - }; - - const patchObservableFactoryArgs = function(obj: any, factoryName: string) { - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factory: any = obj[symbolFactory] = obj[factoryName]; - if (!factory) { - return; - } - obj[factoryName] = function() { - const initZone = Zone.current; - const args = Array.prototype.slice.call(arguments); - for (let i = 0; i < args.length; i++) { - const arg = args[i]; - if (typeof arg === 'function') { - args[i] = function() { - const argArgs = Array.prototype.slice.call(arguments); - const runningZone = Zone.current; - if (initZone && runningZone && initZone !== runningZone) { - return initZone.run(arg, this, argArgs); - } else { - return arg.apply(this, argArgs); - } - }; - } - } - - const observable = factory.apply(this, args); - patchObservableInstance(observable); - return observable; - }; - }; - - const patchMulticast = function() { - const obj: any = Observable.prototype; - const factoryName: string = 'multicast'; - const symbolFactory: string = symbol(factoryName); - if (obj[symbolFactory]) { - return; - } - const factory: any = obj[symbolFactory] = obj[factoryName]; - if (!factory) { - return; - } - obj[factoryName] = function() { - const _zone: any = Zone.current; - const args = Array.prototype.slice.call(arguments); - let subjectOrSubjectFactory: any = args.length > 0 ? args[0] : undefined; - if (typeof subjectOrSubjectFactory !== 'function') { - const originalFactory: any = subjectOrSubjectFactory; - subjectOrSubjectFactory = function() { - return originalFactory; - }; - } - args[0] = function() { - let subject: any; - if (_zone && _zone !== Zone.current) { - subject = _zone.run(subjectOrSubjectFactory, this, arguments); - } else { - subject = subjectOrSubjectFactory.apply(this, arguments); - } - if (subject && _zone) { - subject._zone = _zone; - } - return subject; - }; - const observable = factory.apply(this, args); - patchObservableInstance(observable); - return observable; - }; - }; - - const patchImmediate = function(asap: any) { - if (!asap) { - return; - } - - const scheduleSymbol = symbol('scheduleSymbol'); - const zoneSymbol = symbol('zone'); - if (asap[scheduleSymbol]) { - return; - } - - const schedule = asap[scheduleSymbol] = asap.schedule; - asap.schedule = function() { - const args = Array.prototype.slice.call(arguments); - const work = args.length > 0 ? args[0] : undefined; - const delay = args.length > 1 ? args[1] : 0; - const state = (args.length > 2 ? args[2] : undefined) || {}; - state[zoneSymbol] = Zone.current; - - const patchedWork = function() { - const workArgs = Array.prototype.slice.call(arguments); - const action = workArgs.length > 0 ? workArgs[0] : undefined; - const scheduleZone = action && action[zoneSymbol]; - if (scheduleZone && scheduleZone !== Zone.current) { - return scheduleZone.runGuarded(work, this, arguments); - } else { - return work.apply(this, arguments); - } - }; - return schedule.call(this, patchedWork, delay, state); - }; - }; - patchObservable(); patchSubscription(); patchSubscriber(); - patchObservableFactoryCreator(Observable, 'bindCallback'); - patchObservableFactoryCreator(Observable, 'bindNodeCallback'); - patchObservableFactory(Observable, 'defer'); - patchObservableFactory(Observable, 'forkJoin'); - patchObservableFactoryArgs(Observable, 'fromEventPattern'); - patchMulticast(); - patchImmediate(asap); }); diff --git a/package.json b/package.json index 533547247..e7b2dbd19 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "clang-format": "^1.2.3", "concurrently": "^2.2.0", "conventional-changelog": "^1.1.7", + "core-js": "^2.5.7", "es6-promise": "^3.0.2", "google-closure-compiler": "^20170409.0.0", "gulp": "^3.8.11", @@ -93,13 +94,13 @@ "phantomjs": "^2.1.7", "promises-aplus-tests": "^2.1.2", "pump": "^1.0.1", - "rxjs": "^5.5.3", + "rxjs": "^6.2.1", "selenium-webdriver": "^3.4.0", "systemjs": "^0.19.37", "ts-loader": "^0.6.0", "tslint": "^4.1.1", "tslint-eslint-rules": "^3.1.0", - "typescript": "2.5.2", + "typescript": "2.9.2", "vrsource-tslint-rules": "^4.0.0", "webdriver-manager": "^12.0.6", "webdriverio": "^4.8.0", diff --git a/test/browser_entry_point.ts b/test/browser_entry_point.ts index 4ec6e5776..d594c89fd 100644 --- a/test/browser_entry_point.ts +++ b/test/browser_entry_point.ts @@ -6,6 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ +import 'core-js/features/set'; +import 'core-js/features/map'; // List all tests here: import './common_tests'; import './browser/browser.spec'; diff --git a/test/main.ts b/test/main.ts index ccfedf5a8..a68c7ec49 100644 --- a/test/main.ts +++ b/test/main.ts @@ -25,7 +25,10 @@ if (typeof __karma__ !== 'undefined') { System.config({ defaultJSExtensions: true, map: { - 'rxjs': 'base/node_modules/rxjs', + 'rxjs': 'base/node_modules/rxjs/index', + 'rxjs/operators': 'base/node_modules/rxjs/operators/index', + 'core-js/features/set': 'base/node_modules/core-js/es6/set', + 'core-js/features/map': 'base/node_modules/core-js/es6/map', 'es6-promise': 'base/node_modules/es6-promise/dist/es6-promise' }, }); diff --git a/test/rxjs/rxjs.Observable.audit.spec.ts b/test/rxjs/rxjs.Observable.audit.spec.ts index f608b81a6..f46eddc54 100644 --- a/test/rxjs/rxjs.Observable.audit.spec.ts +++ b/test/rxjs/rxjs.Observable.audit.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable} from 'rxjs'; +import {audit, auditTime} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; xdescribe('Observable.audit', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,11 +22,11 @@ xdescribe('Observable.audit', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(100); - return source.audit(ev => { + const source = interval(100); + return source.pipe(audit(ev => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.interval(150); - }); + return interval(150); + })); }); subscriptionZone.run(() => { @@ -33,7 +35,7 @@ xdescribe('Observable.audit', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -54,8 +56,8 @@ xdescribe('Observable.audit', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(100); - return source.auditTime(360); + const source = interval(100); + return source.pipe(auditTime(360)); }); subscriptionZone.run(() => { @@ -64,7 +66,7 @@ xdescribe('Observable.audit', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result >= 7) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { diff --git a/test/rxjs/rxjs.Observable.buffer.spec.ts b/test/rxjs/rxjs.Observable.buffer.spec.ts index c134e71bb..fce6f909d 100644 --- a/test/rxjs/rxjs.Observable.buffer.spec.ts +++ b/test/rxjs/rxjs.Observable.buffer.spec.ts @@ -5,12 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {empty, interval, Observable, of} from 'rxjs'; +import {buffer, bufferCount, bufferTime, bufferToggle, bufferWhen} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; xdescribe('Observable.buffer', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,9 +23,9 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(350); - const interval = Rx.Observable.interval(100); - return interval.buffer(source); + const source = interval(350); + const iv = interval(100); + return iv.pipe(buffer(source)); }); subscriptionZone.run(() => { @@ -31,7 +34,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result[0] >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -52,8 +55,8 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const interval = Rx.Observable.interval(100); - return interval.bufferCount(3); + const iv = interval(100); + return iv.pipe(bufferCount(3)); }); subscriptionZone.run(() => { @@ -62,7 +65,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result[0] >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -83,8 +86,8 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const interval = Rx.Observable.interval(100); - return interval.bufferTime(350); + const iv = interval(100); + return iv.pipe(bufferTime(350)); }); subscriptionZone.run(() => { @@ -93,7 +96,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (result[0] >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -114,13 +117,13 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(10); - const opening = Rx.Observable.interval(25); + const source = interval(10); + const opening = interval(25); const closingSelector = (v: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return v % 2 === 0 ? Rx.Observable.of(v) : Rx.Observable.empty(); + return v % 2 === 0 ? of(v) : empty(); }; - return source.bufferToggle(opening, closingSelector); + return source.pipe(bufferToggle(opening, closingSelector)); }); let i = 0; @@ -129,7 +132,7 @@ xdescribe('Observable.buffer', () => { (result: any) => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); - subscriber.complete(); + subscriber.unsubscribe(); }, () => { fail('should not call error'); @@ -149,11 +152,11 @@ xdescribe('Observable.buffer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.interval(100); - return source.bufferWhen(() => { + const source = interval(100); + return source.pipe(bufferWhen(() => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.interval(220); - }); + return interval(220); + })); }); let i = 0; @@ -163,7 +166,7 @@ xdescribe('Observable.buffer', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); log.push(result); if (i++ >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); } }, () => { @@ -179,4 +182,4 @@ xdescribe('Observable.buffer', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.catch.spec.ts b/test/rxjs/rxjs.Observable.catch.spec.ts index 09a1e8270..33bd613cc 100644 --- a/test/rxjs/rxjs.Observable.catch.spec.ts +++ b/test/rxjs/rxjs.Observable.catch.spec.ts @@ -5,11 +5,12 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; +import {catchError, map, retry} from 'rxjs/operators'; describe('Observable.catch', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,17 +21,17 @@ describe('Observable.catch', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { const error = new Error('test'); - const source = Rx.Observable.of(1, 2, 3).map((n: number) => { + const source = of(1, 2, 3).pipe(map((n: number) => { expect(Zone.current.name).toEqual(constructorZone1.name); if (n === 2) { throw error; } return n; - }); - return source.catch((err: any) => { + })); + return source.pipe(catchError((err: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.of('error1', 'error2'); - }); + return of('error1', 'error2'); + })); }); subscriptionZone.run(() => { @@ -55,15 +56,15 @@ describe('Observable.catch', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3) - .map((n: number) => { + return of(1, 2, 3).pipe( + map((n: number) => { expect(Zone.current.name).toEqual(constructorZone1.name); if (n === 2) { throw error; } return n; - }) - .retry(1); + }), + retry(1)); }); subscriptionZone.run(() => { @@ -83,4 +84,4 @@ describe('Observable.catch', () => { }); expect(log).toEqual([1, 1, error]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.collection.spec.ts b/test/rxjs/rxjs.Observable.collection.spec.ts index e7f6ba608..a39208df2 100644 --- a/test/rxjs/rxjs.Observable.collection.spec.ts +++ b/test/rxjs/rxjs.Observable.collection.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; -import {asyncTest} from '../test-util'; +import {from, interval, Observable, of} from 'rxjs'; +import {elementAt, every, filter, find, findIndex, first, flatMap, groupBy, ignoreElements, isEmpty, last, map, mapTo, max, min, reduce, repeat, scan, single, skip, skipUntil, skipWhile, startWith} from 'rxjs/operators'; + +import {asyncTest, isPhantomJS} from '../test-util'; describe('Observable.collection', () => { let log: string[]; - let observable1: any; + let observable1: Observable; let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { @@ -27,7 +29,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).elementAt(1); + return of(1, 2, 3).pipe(elementAt(1)); }); subscriptionZone.run(() => { @@ -53,14 +55,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = everyZone1.run(() => { - return observable1.every((v: any) => { + return observable1.pipe(every((v: any) => { expect(Zone.current.name).toEqual(everyZone1.name); return v % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -86,14 +88,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = filterZone1.run(() => { - return observable1.filter((v: any) => { + return observable1.pipe(filter((v: any) => { expect(Zone.current.name).toEqual(filterZone1.name); return v % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -119,14 +121,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = findZone1.run(() => { - return observable1.find((v: any) => { + return observable1.pipe(find((v: any) => { expect(Zone.current.name).toEqual(findZone1.name); return v === 2; - }); + })); }); subscriptionZone.run(() => { @@ -152,14 +154,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = findZone1.run(() => { - return observable1.findIndex((v: any) => { + return observable1.pipe(findIndex((v: any) => { expect(Zone.current.name).toEqual(findZone1.name); return v === 2; - }); + })); }); subscriptionZone.run(() => { @@ -185,14 +187,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = firstZone1.run(() => { - return observable1.first((v: any) => { + return observable1.pipe(first((v: any) => { expect(Zone.current.name).toEqual(firstZone1.name); return v === 2; - }); + })); }); subscriptionZone.run(() => { @@ -213,26 +215,30 @@ describe('Observable.collection', () => { }); it('groupBy func callback should run in the correct zone', () => { + if (isPhantomJS()) { + return; + } const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const groupByZone1: Zone = Zone.current.fork({name: 'groupBy Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - const error = new Error('test'); observable1 = constructorZone1.run(() => { const people = [ {name: 'Sue', age: 25}, {name: 'Joe', age: 30}, {name: 'Frank', age: 25}, {name: 'Sarah', age: 35} ]; - return Rx.Observable.from(people); + return from(people); }); observable1 = groupByZone1.run(() => { - return observable1 - .groupBy((person: any) => { + return observable1.pipe( + groupBy((person: any) => { expect(Zone.current.name).toEqual(groupByZone1.name); return person.age; - }) + }), // return as array of each group - .flatMap((group: any) => group.reduce((acc: any, curr: any) => [...acc, curr], [])); + flatMap((group: any) => { + return group.pipe(reduce((acc: any, curr: any) => [...acc, curr], [])); + })); }); subscriptionZone.run(() => { @@ -242,7 +248,7 @@ describe('Observable.collection', () => { expect(Zone.current.name).toEqual(subscriptionZone.name); }, (err: any) => { - fail('should not call error'); + fail('should not call error' + err); }, () => { log.push('completed'); @@ -261,7 +267,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).ignoreElements(); + return of(1, 2, 3).pipe(ignoreElements()); }); subscriptionZone.run(() => { @@ -286,7 +292,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).isEmpty(); + return of(1, 2, 3).pipe(isEmpty()); }); subscriptionZone.run(() => { @@ -312,7 +318,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).last(); + return of(1, 2, 3).pipe(last()); }); subscriptionZone.run(() => { @@ -338,14 +344,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = mapZone1.run(() => { - return observable1.map((v: any) => { + return observable1.pipe(map((v: any) => { expect(Zone.current.name).toEqual(mapZone1.name); return v + 1; - }); + })); }); subscriptionZone.run(() => { @@ -371,11 +377,11 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = mapToZone1.run(() => { - return observable1.mapTo('a'); + return observable1.pipe(mapTo('a')); }); subscriptionZone.run(() => { @@ -400,7 +406,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3).max(); + return of(4, 2, 3).pipe(max()); }); subscriptionZone.run(() => { @@ -426,14 +432,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = maxZone1.run(() => { - return observable1.max((x: number, y: number) => { + return observable1.pipe(max((x: number, y: number) => { expect(Zone.current.name).toEqual(maxZone1.name); return x < y ? -1 : 1; - }); + })); }); subscriptionZone.run(() => { @@ -458,7 +464,7 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3).min(); + return of(4, 2, 3).pipe(min()); }); subscriptionZone.run(() => { @@ -484,14 +490,14 @@ describe('Observable.collection', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = minZone1.run(() => { - return observable1.max((x: number, y: number) => { + return observable1.pipe(max((x: number, y: number) => { expect(Zone.current.name).toEqual(minZone1.name); return x < y ? 1 : -1; - }); + })); }); subscriptionZone.run(() => { @@ -516,14 +522,14 @@ describe('Observable.collection', () => { const reduceZone1: Zone = Zone.current.fork({name: 'Min Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = reduceZone1.run(() => { - return observable1.reduce((acc: number, one: number) => { + return observable1.pipe(reduce((acc: number, one: number) => { expect(Zone.current.name).toEqual(reduceZone1.name); return acc + one; - }); + })); }); subscriptionZone.run(() => { @@ -548,14 +554,14 @@ describe('Observable.collection', () => { const scanZone1: Zone = Zone.current.fork({name: 'Min Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(4, 2, 3); + return of(4, 2, 3); }); observable1 = scanZone1.run(() => { - return observable1.scan((acc: number, one: number) => { + return observable1.pipe(scan((acc: number, one: number) => { expect(Zone.current.name).toEqual(scanZone1.name); return acc + one; - }); + })); }); subscriptionZone.run(() => { @@ -579,7 +585,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1).repeat(2); + return of(1).pipe(repeat(2)); }); subscriptionZone.run(() => { @@ -604,14 +610,14 @@ describe('Observable.collection', () => { const singleZone1: Zone = Zone.current.fork({name: 'Single Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3, 4, 5); + return of(1, 2, 3, 4, 5); }); observable1 = singleZone1.run(() => { - return observable1.single((val: any) => { + return observable1.pipe(single((val: any) => { expect(Zone.current.name).toEqual(singleZone1.name); return val === 4; - }); + })); }); subscriptionZone.run(() => { @@ -635,7 +641,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3, 4, 5).skip(3); + return of(1, 2, 3, 4, 5).pipe(skip(3)); }); subscriptionZone.run(() => { @@ -659,7 +665,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).skipUntil(Rx.Observable.interval(25)); + return interval(10).pipe(skipUntil(interval(25))); }); subscriptionZone.run(() => { @@ -667,7 +673,7 @@ describe('Observable.collection', () => { (result: any) => { log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); - subscriber.complete(); + subscriber.unsubscribe(); }, (err: any) => { fail('should not call error'); @@ -686,31 +692,26 @@ describe('Observable.collection', () => { const skipZone1: Zone = Zone.current.fork({name: 'Skip Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10); + return interval(10); }); observable1 = skipZone1.run(() => { - return observable1.skipWhile((val: any) => { + return observable1.pipe(skipWhile((val: any) => { expect(Zone.current.name).toEqual(skipZone1.name); return val < 2; - }); + })); }); subscriptionZone.run(() => { const subscriber = observable1.subscribe( (result: any) => { - log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); - subscriber.complete(); + subscriber.unsubscribe(); + expect(result).toEqual(2); + done(); }, (err: any) => { fail('should not call error'); - }, - () => { - log.push('completed'); - expect(Zone.current.name).toEqual(subscriptionZone.name); - expect(log).toEqual([2, 'completed']); - done(); }); }); }, Zone.root)); @@ -719,7 +720,7 @@ describe('Observable.collection', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2).startWith(3); + return of(1, 2).pipe(startWith(3)); }); subscriptionZone.run(() => { @@ -738,4 +739,4 @@ describe('Observable.collection', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.combine.spec.ts b/test/rxjs/rxjs.Observable.combine.spec.ts index c77f0596e..017ae4270 100644 --- a/test/rxjs/rxjs.Observable.combine.spec.ts +++ b/test/rxjs/rxjs.Observable.combine.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {combineLatest, Observable, of} from 'rxjs'; +import {combineAll, map} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.combine', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,12 +22,12 @@ describe('Observable.combine', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.of(1, 2); - const highOrder = source.map((src: any) => { + const source = of(1, 2); + const highOrder = source.pipe(map((src: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.of(src); - }); - return highOrder.combineAll(); + return of(src); + })); + return highOrder.pipe(combineAll()); }); subscriptionZone.run(() => { @@ -51,15 +53,15 @@ describe('Observable.combine', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.of(1, 2, 3); - const highOrder = source.map((src: any) => { + const source = of(1, 2, 3); + const highOrder = source.pipe(map((src: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.of(src); - }); - return highOrder.combineAll((x: any, y: any) => { + return of(src); + })); + return highOrder.pipe(combineAll((x: any, y: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); return {x: x, y: y}; - }); + })); }); subscriptionZone.run(() => { @@ -84,9 +86,9 @@ describe('Observable.combine', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.of(1, 2, 3); - const input = Rx.Observable.of(4, 5, 6); - return source.combineLatest(input); + const source = of(1, 2, 3); + const input = of(4, 5, 6); + return combineLatest(source, input); }); subscriptionZone.run(() => { @@ -111,9 +113,9 @@ describe('Observable.combine', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.of(1, 2, 3); - const input = Rx.Observable.of(4, 5, 6); - return source.combineLatest(input, function(x: any, y: any) { + const source = of(1, 2, 3); + const input = of(4, 5, 6); + return combineLatest(source, input, (x: number, y: number) => { return x + y; }); }); diff --git a/test/rxjs/rxjs.Observable.concat.spec.ts b/test/rxjs/rxjs.Observable.concat.spec.ts index 472b3f2cb..59f67de7b 100644 --- a/test/rxjs/rxjs.Observable.concat.spec.ts +++ b/test/rxjs/rxjs.Observable.concat.spec.ts @@ -6,7 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, concat, Observable, of, range} from 'rxjs'; +import {concatAll, concatMap, concatMapTo, map} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable instance method concat', () => { @@ -15,7 +17,7 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; let observable2: any; let concatObservable: any; @@ -26,7 +28,7 @@ describe('Observable instance method concat', () => { it('concat func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -35,11 +37,11 @@ describe('Observable instance method concat', () => { }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = observable1.concat(observable2); + concatObservable = concat(observable1, observable2); }); subscriptionZone.run(() => { @@ -59,15 +61,15 @@ describe('Observable instance method concat', () => { const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2); + return of(1, 2); }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = observable1.concat(observable2, Rx.Scheduler.asap); + concatObservable = concat(observable1, observable2, asapScheduler); }); subscriptionZone.run(() => { @@ -94,15 +96,15 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(0, 1, 2); + return of(0, 1, 2); }); constructorZone2.run(() => { - const highOrder = observable1.map((v: any) => { + const highOrder = observable1.pipe(map((v: any) => { expect(Zone.current.name).toEqual(constructorZone2.name); - return Rx.Observable.of(v + 1); - }); - concatObservable = highOrder.concatAll(); + return of(v + 1); + })); + concatObservable = highOrder.pipe(concatAll()); }); subscriptionZone.run(() => { @@ -127,7 +129,7 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -138,10 +140,10 @@ describe('Observable instance method concat', () => { }); constructorZone2.run(() => { - concatObservable = observable1.concatMap((v: any) => { + concatObservable = observable1.pipe(concatMap((v: any) => { expect(Zone.current.name).toEqual(constructorZone2.name); - return Rx.Observable.of(0, 1); - }); + return of(0, 1); + })); }); subscriptionZone.run(() => { @@ -166,7 +168,7 @@ describe('Observable instance method concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -177,7 +179,7 @@ describe('Observable instance method concat', () => { }); constructorZone2.run(() => { - concatObservable = observable1.concatMapTo(Rx.Observable.of(0, 1)); + concatObservable = observable1.pipe(concatMapTo(of(0, 1))); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.Observable.count.spec.ts b/test/rxjs/rxjs.Observable.count.spec.ts index 4bb7ab8bb..d866bbaf6 100644 --- a/test/rxjs/rxjs.Observable.count.spec.ts +++ b/test/rxjs/rxjs.Observable.count.spec.ts @@ -5,13 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, range} from 'rxjs'; +import {count} from 'rxjs/operators'; describe('Observable.count', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,10 +20,10 @@ describe('Observable.count', () => { it('count func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.range(1, 3).count((i: number) => { + return range(1, 3).pipe(count((i: number) => { expect(Zone.current.name).toEqual(constructorZone1.name); return i % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -41,4 +42,4 @@ describe('Observable.count', () => { }); expect(log).toEqual([1, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.debounce.spec.ts b/test/rxjs/rxjs.Observable.debounce.spec.ts index 36666e457..ff77c5001 100644 --- a/test/rxjs/rxjs.Observable.debounce.spec.ts +++ b/test/rxjs/rxjs.Observable.debounce.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of, timer} from 'rxjs'; +import {debounce, debounceTime} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.debounce', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,10 +22,10 @@ describe('Observable.debounce', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).debounce(() => { + return of(1, 2, 3).pipe(debounce(() => { expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.timer(100); - }); + return timer(100); + })); }); subscriptionZone.run(() => { @@ -48,7 +50,7 @@ describe('Observable.debounce', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).debounceTime(100); + return of(1, 2, 3).pipe(debounceTime(100)); }); subscriptionZone.run(() => { @@ -68,4 +70,4 @@ describe('Observable.debounce', () => { }); expect(log).toEqual([3, 'completed']); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.default.spec.ts b/test/rxjs/rxjs.Observable.default.spec.ts index 4c7cc4b7c..23ac2fb33 100644 --- a/test/rxjs/rxjs.Observable.default.spec.ts +++ b/test/rxjs/rxjs.Observable.default.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; +import {defaultIfEmpty} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.defaultIfEmpty', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +22,7 @@ describe('Observable.defaultIfEmpty', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of().defaultIfEmpty('empty'); + return of().pipe(defaultIfEmpty('empty')); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.Observable.delay.spec.ts b/test/rxjs/rxjs.Observable.delay.spec.ts index 289e8c362..a459cf5a2 100644 --- a/test/rxjs/rxjs.Observable.delay.spec.ts +++ b/test/rxjs/rxjs.Observable.delay.spec.ts @@ -5,12 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {Observable, of, timer} from 'rxjs'; +import {delay, delayWhen} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.delay', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +23,7 @@ describe('Observable.delay', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).delay(100); + return of(1, 2, 3).pipe(delay(100)); }); subscriptionZone.run(() => { @@ -45,9 +48,9 @@ describe('Observable.delay', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).delayWhen((v: any) => { - return Rx.Observable.timer(v * 10); - }); + return of(1, 2, 3).pipe(delayWhen((v: any) => { + return timer(v * 10); + })); }); subscriptionZone.run(() => { @@ -67,4 +70,4 @@ describe('Observable.delay', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.distinct.spec.ts b/test/rxjs/rxjs.Observable.distinct.spec.ts index 6e5534186..394c2dd8a 100644 --- a/test/rxjs/rxjs.Observable.distinct.spec.ts +++ b/test/rxjs/rxjs.Observable.distinct.spec.ts @@ -5,11 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {Observable, of} from 'rxjs'; +import {distinct, distinctUntilChanged, distinctUntilKeyChanged} from 'rxjs/operators'; describe('Observable.distinct', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +22,7 @@ describe('Observable.distinct', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).distinct(); + return of(1, 1, 2, 2, 2, 1, 2, 3, 4, 3, 2, 1).pipe(distinct()); }); subscriptionZone.run(() => { @@ -45,7 +47,7 @@ describe('Observable.distinct', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).distinctUntilChanged(); + return of(1, 1, 2, 2, 2, 1, 1, 2, 3, 3, 4).pipe(distinctUntilChanged()); }); subscriptionZone.run(() => { @@ -70,10 +72,9 @@ describe('Observable.distinct', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable - .of({age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, - {age: 6, name: 'Foo'}) - .distinctUntilKeyChanged('name'); + return of({age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, + {age: 6, name: 'Foo'}) + .pipe(distinctUntilKeyChanged('name')); }); subscriptionZone.run(() => { @@ -93,4 +94,4 @@ describe('Observable.distinct', () => { expect(log).toEqual( [{age: 4, name: 'Foo'}, {age: 7, name: 'Bar'}, {age: 5, name: 'Foo'}, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.do.spec.ts b/test/rxjs/rxjs.Observable.do.spec.ts index 3cbb3d4cd..75dd492bf 100644 --- a/test/rxjs/rxjs.Observable.do.spec.ts +++ b/test/rxjs/rxjs.Observable.do.spec.ts @@ -5,11 +5,12 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; +import {tap} from 'rxjs/operators'; -describe('Observable.do', () => { +describe('Observable.tap', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -21,14 +22,14 @@ describe('Observable.do', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1); + return of(1); }); observable1 = doZone1.run(() => { - return observable1.do((v: any) => { + return observable1.pipe(tap((v: any) => { log.push(v); expect(Zone.current.name).toEqual(doZone1.name); - }); + })); }); subscriptionZone.run(() => { @@ -47,4 +48,4 @@ describe('Observable.do', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.map.spec.ts b/test/rxjs/rxjs.Observable.map.spec.ts index 11c6ebe59..64a155847 100644 --- a/test/rxjs/rxjs.Observable.map.spec.ts +++ b/test/rxjs/rxjs.Observable.map.spec.ts @@ -5,13 +5,18 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, observable, of} from 'rxjs'; +import {pairwise, partition, pluck} from 'rxjs/operators'; + +import {ifEnvSupports} from '../test-util'; + +import {supportFeature} from './rxjs.util'; describe('Observable.map', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +24,7 @@ describe('Observable.map', () => { it('pairwise func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).pairwise(); + return of(1, 2, 3).pipe(pairwise()); }); subscriptionZone.run(() => { @@ -42,15 +47,15 @@ describe('Observable.map', () => { it('partition func callback should run in the correct zone', () => { const partitionZone = Zone.current.fork({name: 'Partition Zone1'}); - observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + const observable1: any = constructorZone1.run(() => { + return of(1, 2, 3); }); const part: any = partitionZone.run(() => { - return observable1.partition((val: any) => { + return observable1.pipe(partition((val: any) => { expect(Zone.current.name).toEqual(partitionZone.name); return val % 2 === 0; - }); + })); }); subscriptionZone.run(() => { @@ -86,7 +91,7 @@ describe('Observable.map', () => { it('pluck func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of({a: 1, b: 2}, {a: 3, b: 4}).pluck('a'); + return of({a: 1, b: 2}, {a: 3, b: 4}).pipe(pluck('a')); }); subscriptionZone.run(() => { @@ -106,4 +111,4 @@ describe('Observable.map', () => { expect(log).toEqual([1, 3, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.merge.spec.ts b/test/rxjs/rxjs.Observable.merge.spec.ts index 0f4f51da3..2d13dafd0 100644 --- a/test/rxjs/rxjs.Observable.merge.spec.ts +++ b/test/rxjs/rxjs.Observable.merge.spec.ts @@ -5,12 +5,16 @@ * 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 * as Rx from 'rxjs/Rx'; -import {asyncTest} from '../test-util'; +import {interval, merge, Observable, of, range} from 'rxjs'; +import {expand, map, mergeAll, mergeMap, mergeMapTo, switchAll, switchMap, switchMapTo, take} from 'rxjs/operators'; + +import {asyncTest, ifEnvSupports} from '../test-util'; + +import {supportFeature} from './rxjs.util'; describe('Observable.merge', () => { let log: string[]; - let observable1: any; + let observable1: Observable; let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { @@ -28,16 +32,16 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(2); + return of(2); }); observable1 = expandZone1.run(() => { - return observable1 - .expand((val: any) => { + return observable1.pipe( + expand((val: any) => { expect(Zone.current.name).toEqual(expandZone1.name); - return Rx.Observable.of(1 + val); - }) - .take(2); + return of(1 + val); + }), + take(2)); }); subscriptionZone.run(() => { @@ -62,8 +66,7 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.merge( - Rx.Observable.interval(10).take(2), Rx.Observable.interval(15).take(1)); + return merge(interval(10).pipe(take(2)), interval(15).pipe(take(1))); }); subscriptionZone.run(() => { @@ -89,11 +92,11 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2) - .map((v: any) => { - return Rx.Observable.of(v + 1); - }) - .mergeAll(); + return of(1, 2).pipe( + map((v: any) => { + return of(v + 1); + }), + mergeAll()); }); subscriptionZone.run(() => { @@ -119,9 +122,9 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2).mergeMap((v: any) => { - return Rx.Observable.of(v + 1); - }); + return of(1, 2).pipe(mergeMap((v: any) => { + return of(v + 1); + })); }); subscriptionZone.run(() => { @@ -146,7 +149,7 @@ describe('Observable.merge', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2).mergeMapTo(Rx.Observable.of(10)); + return of(1, 2).pipe(mergeMapTo(of(10))); }); subscriptionZone.run(() => { @@ -170,11 +173,11 @@ describe('Observable.merge', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.range(0, 3) - .map(function(x: any) { - return Rx.Observable.range(x, 3); - }) - .switch(); + return range(0, 3).pipe( + map(function(x: any) { + return range(x, 3); + }), + switchAll()); }); subscriptionZone.run(() => { @@ -198,9 +201,9 @@ describe('Observable.merge', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.range(0, 3).switchMap(function(x: any) { - return Rx.Observable.range(x, 3); - }); + return range(0, 3).pipe(switchMap(function(x: any) { + return range(x, 3); + })); }); subscriptionZone.run(() => { @@ -224,7 +227,7 @@ describe('Observable.merge', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.range(0, 3).switchMapTo('a'); + return range(0, 3).pipe(switchMapTo('a')); }); subscriptionZone.run(() => { @@ -243,4 +246,4 @@ describe('Observable.merge', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.multicast.spec.ts b/test/rxjs/rxjs.Observable.multicast.spec.ts index 2c1cb65f0..8473a0a78 100644 --- a/test/rxjs/rxjs.Observable.multicast.spec.ts +++ b/test/rxjs/rxjs.Observable.multicast.spec.ts @@ -5,7 +5,8 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of, Subject} from 'rxjs'; +import {mapTo, multicast, tap} from 'rxjs/operators'; // TODO: @JiaLiPassion, Observable.prototype.multicast return a readonly _subscribe // should find another way to patch subscribe @@ -16,7 +17,7 @@ describe('Observable.multicast', () => { const mapZone1: Zone = Zone.current.fork({name: 'Map Zone1'}); const multicastZone1: Zone = Zone.current.fork({name: 'Multicast Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -24,25 +25,25 @@ describe('Observable.multicast', () => { it('multicast func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); observable1 = doZone1.run(() => { - return observable1.do((v: any) => { + return observable1.pipe(tap((v: any) => { expect(Zone.current.name).toEqual(doZone1.name); log.push('do' + v); - }); + })); }); observable1 = mapZone1.run(() => { - return observable1.mapTo('test'); + return observable1.pipe(mapTo('test')); }); const multi: any = multicastZone1.run(() => { - return observable1.multicast(() => { + return observable1.pipe(multicast(() => { expect(Zone.current.name).toEqual(multicastZone1.name); - return new Rx.Subject(); - }); + return new Subject(); + })); }); multi.subscribe((val: any) => { @@ -75,4 +76,4 @@ describe('Observable.multicast', () => { 'test', 'do2', 'test', 'do3', 'test', 'completed' ]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.notification.spec.ts b/test/rxjs/rxjs.Observable.notification.spec.ts index c87ffb5fd..6212c85e8 100644 --- a/test/rxjs/rxjs.Observable.notification.spec.ts +++ b/test/rxjs/rxjs.Observable.notification.spec.ts @@ -5,18 +5,20 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Notification, Observable, of} from 'rxjs'; +import {dematerialize} from 'rxjs/operators'; + import {asyncTest, ifEnvSupports} from '../test-util'; const supportNotification = function() { - return typeof Rx.Notification !== 'undefined'; + return typeof Notification !== 'undefined'; }; (supportNotification as any).message = 'RxNotification'; describe('Observable.notification', ifEnvSupports(supportNotification, () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -27,11 +29,11 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - const notifA = new Rx.Notification('N', 'A'); - const notifB = new Rx.Notification('N', 'B'); - const notifE = new Rx.Notification('E', void 0, error); - const materialized = Rx.Observable.of(notifA, notifB, notifE as any); - return materialized.dematerialize(); + const notifA = new Notification('N', 'A'); + const notifB = new Notification('N', 'B'); + const notifE = new Notification('E', void 0, error); + const materialized = of(notifA, notifB, notifE as any); + return materialized.pipe(dematerialize()); }); subscriptionZone.run(() => { @@ -51,4 +53,4 @@ describe('Observable.notification', ifEnvSupports(supportNotification, () => { }); }); }); - })); \ No newline at end of file + })); diff --git a/test/rxjs/rxjs.Observable.race.spec.ts b/test/rxjs/rxjs.Observable.race.spec.ts index 44369d44d..7db80efc3 100644 --- a/test/rxjs/rxjs.Observable.race.spec.ts +++ b/test/rxjs/rxjs.Observable.race.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable, race} from 'rxjs'; +import {mapTo} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.race', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,8 +22,7 @@ describe('Observable.race', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.race( - Rx.Observable.interval(10).mapTo('a'), Rx.Observable.interval(15).mapTo('b')); + return race(interval(10).pipe(mapTo('a')), interval(15).pipe(mapTo('b'))); }); subscriptionZone.run(() => { @@ -42,4 +43,4 @@ describe('Observable.race', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.sample.spec.ts b/test/rxjs/rxjs.Observable.sample.spec.ts index 2f767df4d..1bc39406f 100644 --- a/test/rxjs/rxjs.Observable.sample.spec.ts +++ b/test/rxjs/rxjs.Observable.sample.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable} from 'rxjs'; +import {sample, take, throttle} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.sample', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +22,7 @@ describe('Observable.sample', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).sample(Rx.Observable.interval(15)); + return interval(10).pipe(sample(interval(15))); }); subscriptionZone.run(() => { @@ -46,10 +48,10 @@ describe('Observable.sample', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).take(5).throttle((val: any) => { - expect(Zone.current.name).toEqual(constructorZone1.name); - return Rx.Observable.interval(20); - }); + return interval(10).pipe(take(5), throttle((val: any) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + return interval(20); + })); }); subscriptionZone.run(() => { @@ -69,4 +71,4 @@ describe('Observable.sample', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.take.spec.ts b/test/rxjs/rxjs.Observable.take.spec.ts index 0edc377a2..4921a7359 100644 --- a/test/rxjs/rxjs.Observable.take.spec.ts +++ b/test/rxjs/rxjs.Observable.take.spec.ts @@ -5,12 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable, of} from 'rxjs'; +import {take, takeLast, takeUntil, takeWhile} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.take', () => { let log: string[]; - let observable1: any; + let observable1: Observable; let defaultTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; beforeEach(() => { @@ -26,7 +28,7 @@ describe('Observable.take', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).take(1); + return of(1, 2, 3).pipe(take(1)); }); subscriptionZone.run(() => { @@ -50,7 +52,7 @@ describe('Observable.take', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3).takeLast(1); + return of(1, 2, 3).pipe(takeLast(1)); }); subscriptionZone.run(() => { @@ -74,7 +76,7 @@ describe('Observable.take', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10).takeUntil(Rx.Observable.interval(25)); + return interval(10).pipe(takeUntil(interval(25))); }); subscriptionZone.run(() => { @@ -100,14 +102,14 @@ describe('Observable.take', () => { const takeZone1: Zone = Zone.current.fork({name: 'Take Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10); + return interval(10); }); observable1 = takeZone1.run(() => { - return observable1.takeWhile((val: any) => { + return observable1.pipe(takeWhile((val: any) => { expect(Zone.current.name).toEqual(takeZone1.name); return val < 2; - }); + })); }); subscriptionZone.run(() => { @@ -127,4 +129,4 @@ describe('Observable.take', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.timeout.spec.ts b/test/rxjs/rxjs.Observable.timeout.spec.ts index 28e7ccfbf..7675be42b 100644 --- a/test/rxjs/rxjs.Observable.timeout.spec.ts +++ b/test/rxjs/rxjs.Observable.timeout.spec.ts @@ -5,22 +5,28 @@ * 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 * as Rx from 'rxjs/Rx'; -import {asyncTest} from '../test-util'; +import {Observable, of} from 'rxjs'; +import {timeout} from 'rxjs/operators'; + +import {asyncTest, isPhantomJS} from '../test-util'; describe('Observable.timeout', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; }); it('timeout func callback should run in the correct zone', asyncTest((done: any) => { + if (isPhantomJS()) { + done(); + return; + } const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1).timeout(10); + return of(1).pipe(timeout(10)); }); subscriptionZone.run(() => { @@ -45,7 +51,7 @@ describe('Observable.timeout', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const promise: any = constructorZone1.run(() => { - return Rx.Observable.of(1).toPromise(); + return of(1).toPromise(); }); subscriptionZone.run(() => { @@ -60,4 +66,4 @@ describe('Observable.timeout', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.Observable.window.spec.ts b/test/rxjs/rxjs.Observable.window.spec.ts index b252b15fb..0daa28459 100644 --- a/test/rxjs/rxjs.Observable.window.spec.ts +++ b/test/rxjs/rxjs.Observable.window.spec.ts @@ -5,14 +5,16 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable, timer} from 'rxjs'; +import {mergeAll, take, window, windowCount, windowToggle, windowWhen} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; // @JiaLiPassion, in Safari 9(iOS 9), the case is not // stable because of the timer, try to fix it later xdescribe('Observable.window', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -23,9 +25,9 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.timer(0, 10).take(6); - const window = source.window(Rx.Observable.interval(30)); - return window.mergeAll(); + const source = timer(0, 10).pipe(take(6)); + const w = source.pipe(window(interval(30))); + return w.pipe(mergeAll()); }); subscriptionZone.run(() => { @@ -51,9 +53,9 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - const source = Rx.Observable.timer(0, 10).take(10); - const window = source.windowCount(4); - return window.mergeAll(); + const source = timer(0, 10).pipe(take(10)); + const window = source.pipe(windowCount(4)); + return window.pipe(mergeAll()); }); subscriptionZone.run(() => { @@ -80,18 +82,14 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.timer(0, 10).take(10); + return timer(0, 10).pipe(take(10)); }); windowZone1.run(() => { - return observable1 - .windowToggle( - Rx.Observable.interval(30), - (val: any) => { - expect(Zone.current.name).toEqual(windowZone1.name); - return Rx.Observable.interval(15); - }) - .mergeAll(); + return observable1.pipe(windowToggle(interval(30), (val: any) => { + expect(Zone.current.name).toEqual(windowZone1.name); + return interval(15); + }), mergeAll()); }); subscriptionZone.run(() => { @@ -118,16 +116,16 @@ xdescribe('Observable.window', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.timer(0, 10).take(10); + return timer(0, 10).pipe(take(10)); }); windowZone1.run(() => { - return observable1 - .windowWhen((val: any) => { + return observable1.pipe( + windowWhen(() => { expect(Zone.current.name).toEqual(windowZone1.name); - return Rx.Observable.interval(15); - }) - .mergeAll(); + return interval(15); + }), + mergeAll()); }); subscriptionZone.run(() => { diff --git a/test/rxjs/rxjs.asap.spec.ts b/test/rxjs/rxjs.asap.spec.ts index 1931bab8e..984628174 100644 --- a/test/rxjs/rxjs.asap.spec.ts +++ b/test/rxjs/rxjs.asap.spec.ts @@ -6,46 +6,65 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, of} from 'rxjs'; +import {map, observeOn} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Scheduler.asap', () => { let log: string[]; let errorCallback: Function; - const constructorZone: Zone = Zone.root.fork({ - name: 'Constructor Zone', - onHandleError: (delegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, error: Error) => { - log.push('error' + error.message); - const result = delegate.handleError(targetZone, error); - errorCallback && errorCallback(); - return false; - } - }); + const constructorZone: Zone = Zone.root.fork({name: 'Constructor Zone'}); beforeEach(() => { log = []; }); - it('scheduler asap error should run in correct zone', asyncTest((done: any) => { + it('scheduler asap should run in correct zone', asyncTest((done: any) => { let observable: any; constructorZone.run(() => { - observable = Rx.Observable.of(1, 2, 3).observeOn(Rx.Scheduler.asap); + observable = of(1, 2, 3).pipe(observeOn(asapScheduler)); }); - errorCallback = () => { - expect(log).toEqual(['erroroops']); - setTimeout(done, 0); - }; + const zone = Zone.current.fork({name: 'subscribeZone'}); + + zone.run(() => { + observable + .pipe(map((value: number) => { + return value; + })) + .subscribe( + (value: number) => { + expect(Zone.current.name).toEqual(zone.name); + if (value === 3) { + setTimeout(done); + } + }, + (err: any) => { + fail('should not be here'); + }); + }); + }, Zone.root)); + + it('scheduler asap error should run in correct zone', asyncTest((done: any) => { + let observable: any; + constructorZone.run(() => { + observable = of(1, 2, 3).pipe(observeOn(asapScheduler)); + }); Zone.root.run(() => { observable - .map((value: number) => { + .pipe(map((value: number) => { if (value === 3) { throw new Error('oops'); } return value; - }) - .subscribe((value: number) => {}); + })) + .subscribe((value: number) => {}, (err: any) => { + expect(err.message).toEqual('oops'); + expect(Zone.current.name).toEqual(''); + done(); + }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.bindCallback.spec.ts b/test/rxjs/rxjs.bindCallback.spec.ts index ca0cb708e..4de564aad 100644 --- a/test/rxjs/rxjs.bindCallback.spec.ts +++ b/test/rxjs/rxjs.bindCallback.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, bindCallback} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.bindCallback', () => { @@ -27,7 +28,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func); + boundFunc = bindCallback(func); observable = boundFunc('test'); }); @@ -47,7 +48,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func, (arg: any) => { + boundFunc = bindCallback(func, (arg: any) => { expect(Zone.current.name).toEqual(constructorZone.name); return 'selector' + arg; }); @@ -70,7 +71,7 @@ describe('Observable.bindCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg0); }; - boundFunc = Rx.Observable.bindCallback(func, undefined, Rx.Scheduler.asap); + boundFunc = bindCallback(func, () => true, asapScheduler); observable = boundFunc('test'); }); @@ -84,4 +85,4 @@ describe('Observable.bindCallback', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.bindNodeCallback.spec.ts b/test/rxjs/rxjs.bindNodeCallback.spec.ts index 5bcc0b023..ec8fb933f 100644 --- a/test/rxjs/rxjs.bindNodeCallback.spec.ts +++ b/test/rxjs/rxjs.bindNodeCallback.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, bindCallback, bindNodeCallback, Observable} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.bindNodeCallback', () => { @@ -27,7 +28,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindNodeCallback(func); + boundFunc = bindNodeCallback(func); observable = boundFunc('test'); }); @@ -47,7 +48,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindNodeCallback(func, (arg: any) => { + boundFunc = bindNodeCallback(func, (arg: any) => { expect(Zone.current.name).toEqual(constructorZone.name); return 'selector' + arg; }); @@ -70,7 +71,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(null, arg); }; - boundFunc = Rx.Observable.bindCallback(func, undefined, Rx.Scheduler.asap); + boundFunc = bindCallback(func, () => true, asapScheduler); observable = boundFunc('test'); }); @@ -91,7 +92,7 @@ describe('Observable.bindNodeCallback', () => { expect(Zone.current.name).toEqual(constructorZone.name); callback(arg, null); }; - boundFunc = Rx.Observable.bindCallback(func); + boundFunc = bindCallback(func); observable = boundFunc('test'); }); @@ -108,4 +109,4 @@ describe('Observable.bindNodeCallback', () => { expect(log).toEqual(['nexttest,']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.combineLatest.spec.ts b/test/rxjs/rxjs.combineLatest.spec.ts index 07406fc43..385b411c8 100644 --- a/test/rxjs/rxjs.combineLatest.spec.ts +++ b/test/rxjs/rxjs.combineLatest.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {combineLatest, Observable} from 'rxjs'; describe('Observable.combineLatest', () => { let log: string[]; @@ -14,7 +14,7 @@ describe('Observable.combineLatest', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; let observable2: any; let subscriber1: any; let subscriber2: any; @@ -26,19 +26,19 @@ describe('Observable.combineLatest', () => { }); it('combineLatest func should run in the correct zone', () => { - observable1 = constructorZone1.run(() => new Rx.Observable((_subscriber) => { - subscriber1 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone1.name); - log.push('setup1'); - })); - observable2 = constructorZone2.run(() => new Rx.Observable((_subscriber) => { - subscriber2 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone2.name); - log.push('setup2'); - })); + observable1 = constructorZone1.run(() => new Observable((_subscriber) => { + subscriber1 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone1.name); + log.push('setup1'); + })); + observable2 = constructorZone2.run(() => new Observable((_subscriber) => { + subscriber2 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone2.name); + log.push('setup2'); + })); constructorZone3.run(() => { - combinedObservable = Rx.Observable.combineLatest(observable1, observable2); + combinedObservable = combineLatest(observable1, observable2); }); subscriptionZone.run(() => { @@ -56,23 +56,22 @@ describe('Observable.combineLatest', () => { }); it('combineLatest func with project function should run in the correct zone', () => { - observable1 = constructorZone1.run(() => new Rx.Observable((_subscriber) => { - subscriber1 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone1.name); - log.push('setup1'); - })); - observable2 = constructorZone2.run(() => new Rx.Observable((_subscriber) => { - subscriber2 = _subscriber; - expect(Zone.current.name).toEqual(constructorZone2.name); - log.push('setup2'); - })); + observable1 = constructorZone1.run(() => new Observable((_subscriber) => { + subscriber1 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone1.name); + log.push('setup1'); + })); + observable2 = constructorZone2.run(() => new Observable((_subscriber) => { + subscriber2 = _subscriber; + expect(Zone.current.name).toEqual(constructorZone2.name); + log.push('setup2'); + })); constructorZone3.run(() => { - combinedObservable = - Rx.Observable.combineLatest(observable1, observable2, (x: number, y: number) => { - expect(Zone.current.name).toEqual(constructorZone3.name); - return x + y; - }); + combinedObservable = combineLatest(observable1, observable2, (x: number, y: number) => { + expect(Zone.current.name).toEqual(constructorZone3.name); + return x + y; + }); }); subscriptionZone.run(() => { @@ -88,4 +87,4 @@ describe('Observable.combineLatest', () => { expect(log).toEqual(['setup1', 'setup2', 3, 4]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.common.spec.ts b/test/rxjs/rxjs.common.spec.ts index eba01e333..f0ee5e9a9 100644 --- a/test/rxjs/rxjs.common.spec.ts +++ b/test/rxjs/rxjs.common.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {Observable, Subject} from 'rxjs'; +import {map} from 'rxjs/operators'; /** * The point of these tests, is to ensure that all callbacks execute in the Zone which was active @@ -26,15 +27,16 @@ describe('Zone interaction', () => { const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); let subscriber: any = null; - const observable: any = constructorZone.run(() => new Rx.Observable((_subscriber: any) => { - subscriber = _subscriber; - log.push('setup'); - expect(Zone.current.name).toEqual(constructorZone.name); - return () => { - expect(Zone.current.name).toEqual(constructorZone.name); - log.push('cleanup'); - }; - })); + const observable: any = + constructorZone.run(() => new Observable((_subscriber: any) => { + subscriber = _subscriber; + log.push('setup'); + expect(Zone.current.name).toEqual(constructorZone.name); + return () => { + expect(Zone.current.name).toEqual(constructorZone.name); + log.push('cleanup'); + }; + })); subscriptionZone.run( () => observable.subscribe( () => { @@ -67,19 +69,20 @@ describe('Zone interaction', () => { const rootZone: Zone = Zone.current; const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - const observable: any = constructorZone.run(() => new Rx.Observable((subscriber: any) => { - // Execute the `next`/`complete` in different zone, and assert that - // correct zone - // is restored. - rootZone.run(() => { - subscriber.next('MyValue'); - subscriber.complete(); - }); - return () => { - expect(Zone.current.name).toEqual(constructorZone.name); - log.push('cleanup'); - }; - })); + const observable: any = + constructorZone.run(() => new Observable((subscriber: any) => { + // Execute the `next`/`complete` in different zone, and assert that + // correct zone + // is restored. + rootZone.run(() => { + subscriber.next('MyValue'); + subscriber.complete(); + }); + return () => { + expect(Zone.current.name).toEqual(constructorZone.name); + log.push('cleanup'); + }; + })); subscriptionZone.run( () => observable.subscribe( @@ -102,25 +105,26 @@ describe('Zone interaction', () => { const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); const operatorZone: Zone = Zone.current.fork({name: 'Operator Zone'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable: any = constructorZone.run(() => new Rx.Observable((subscriber: any) => { - // Execute the `next`/`complete` in different zone, and assert that - // correct zone - // is restored. - rootZone.run(() => { - subscriber.next('MyValue'); - subscriber.complete(); - }); - return () => { - expect(Zone.current.name).toEqual(constructorZone.name); - log.push('cleanup'); - }; - })); - - observable = operatorZone.run(() => observable.map((value: any) => { + let observable: any = + constructorZone.run(() => new Observable((subscriber: any) => { + // Execute the `next`/`complete` in different zone, and assert that + // correct zone + // is restored. + rootZone.run(() => { + subscriber.next('MyValue'); + subscriber.complete(); + }); + return () => { + expect(Zone.current.name).toEqual(constructorZone.name); + log.push('cleanup'); + }; + })); + + observable = operatorZone.run(() => observable.pipe(map((value: any) => { expect(Zone.current.name).toEqual(operatorZone.name); log.push('map: ' + value); return value; - })); + }))); subscriptionZone.run( () => observable.subscribe( @@ -143,7 +147,7 @@ describe('Zone interaction', () => { it('should run subscribe in zone of declaration with Observable.create', () => { const log: string[] = []; const constructorZone: Zone = Zone.current.fork({name: 'Constructor Zone'}); - let observable: any = constructorZone.run(() => Rx.Observable.create((subscriber: any) => { + let observable: any = constructorZone.run(() => Observable.create((subscriber: any) => { expect(Zone.current.name).toEqual(constructorZone.name); subscriber.next(1); subscriber.complete(); @@ -169,7 +173,7 @@ describe('Zone interaction', () => { let subject: any; constructorZone.run(() => { - subject = new Rx.Subject(); + subject = new Subject(); }); let subscription1: any; @@ -206,4 +210,4 @@ describe('Zone interaction', () => { expect(log).toEqual(['next1', 'next2', 'complete1', 'complete2']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.concat.spec.ts b/test/rxjs/rxjs.concat.spec.ts index da7c5c8f1..afe072fe2 100644 --- a/test/rxjs/rxjs.concat.spec.ts +++ b/test/rxjs/rxjs.concat.spec.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {asapScheduler, concat, Observable, range} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.concat', () => { @@ -15,7 +16,7 @@ describe('Observable.concat', () => { const constructorZone2: Zone = Zone.current.fork({name: 'Constructor Zone2'}); const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; let observable2: any; let concatObservable: any; @@ -26,7 +27,7 @@ describe('Observable.concat', () => { it('concat func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -35,11 +36,11 @@ describe('Observable.concat', () => { }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = Rx.Observable.concat(observable1, observable2); + concatObservable = concat(observable1, observable2); }); subscriptionZone.run(() => { @@ -59,7 +60,7 @@ describe('Observable.concat', () => { const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return new Rx.Observable(subscriber => { + return new Observable(subscriber => { expect(Zone.current.name).toEqual(constructorZone1.name); subscriber.next(1); subscriber.next(2); @@ -68,11 +69,11 @@ describe('Observable.concat', () => { }); observable2 = constructorZone2.run(() => { - return Rx.Observable.range(3, 4); + return range(3, 4); }); constructorZone3.run(() => { - concatObservable = Rx.Observable.concat(observable1, observable2, Rx.Scheduler.asap); + concatObservable = concat(observable1, observable2, asapScheduler); }); subscriptionZone.run(() => { @@ -93,4 +94,4 @@ describe('Observable.concat', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.defer.spec.ts b/test/rxjs/rxjs.defer.spec.ts index 348f87117..4e5bd4458 100644 --- a/test/rxjs/rxjs.defer.spec.ts +++ b/test/rxjs/rxjs.defer.spec.ts @@ -6,13 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {defer, Observable} from 'rxjs'; describe('Observable.defer', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,8 +20,8 @@ describe('Observable.defer', () => { it('defer func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.defer(() => { - return new Rx.Observable(subscribe => { + return defer(() => { + return new Observable(subscribe => { log.push('setup'); expect(Zone.current.name).toEqual(constructorZone1.name); subscribe.next(1); @@ -43,4 +43,4 @@ describe('Observable.defer', () => { expect(log).toEqual(['setup', 1, 'cleanup']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.empty.spec.ts b/test/rxjs/rxjs.empty.spec.ts index 4f4e2c8a4..dfb6d7994 100644 --- a/test/rxjs/rxjs.empty.spec.ts +++ b/test/rxjs/rxjs.empty.spec.ts @@ -5,13 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; +import {empty, Observable} from 'rxjs'; describe('Observable.empty', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +19,7 @@ describe('Observable.empty', () => { it('empty func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.empty(); + return empty(); }); subscriptionZone.run(() => { @@ -35,4 +35,4 @@ describe('Observable.empty', () => { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.forkjoin.spec.ts b/test/rxjs/rxjs.forkjoin.spec.ts index a02a79fde..0f60c352c 100644 --- a/test/rxjs/rxjs.forkjoin.spec.ts +++ b/test/rxjs/rxjs.forkjoin.spec.ts @@ -6,13 +6,13 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {forkJoin, from, Observable, range} from 'rxjs'; describe('Observable.forkjoin', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +20,7 @@ describe('Observable.forkjoin', () => { it('forkjoin func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.forkJoin(Rx.Observable.range(1, 2), Rx.Observable.from([4, 5])); + return forkJoin(range(1, 2), from([4, 5])); }); subscriptionZone.run(() => { @@ -43,11 +43,10 @@ describe('Observable.forkjoin', () => { it('forkjoin func callback with selector should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.forkJoin( - Rx.Observable.range(1, 2), Rx.Observable.from([4, 5]), function(x, y) { - expect(Zone.current.name).toEqual(constructorZone1.name); - return x + y; - }); + return forkJoin(range(1, 2), from([4, 5]), (x: number, y: number) => { + expect(Zone.current.name).toEqual(constructorZone1.name); + return x + y; + }); }); subscriptionZone.run(() => { @@ -67,4 +66,4 @@ describe('Observable.forkjoin', () => { expect(log).toEqual([7, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.from.spec.ts b/test/rxjs/rxjs.from.spec.ts index 027f4af54..189925d7f 100644 --- a/test/rxjs/rxjs.from.spec.ts +++ b/test/rxjs/rxjs.from.spec.ts @@ -5,14 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; +import {from, Observable} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.from', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +21,7 @@ describe('Observable.from', () => { it('from array should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.from([1, 2]); + return from([1, 2]); }); subscriptionZone.run(() => { @@ -43,7 +44,7 @@ describe('Observable.from', () => { it('from array like object should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.from('foo'); + return from('foo'); }); subscriptionZone.run(() => { @@ -68,7 +69,7 @@ describe('Observable.from', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.from(new Promise((resolve, reject) => { + return from(new Promise((resolve, reject) => { resolve(1); })); }); @@ -92,4 +93,4 @@ describe('Observable.from', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.fromEvent.spec.ts b/test/rxjs/rxjs.fromEvent.spec.ts index e7cb8272e..52cf6a991 100644 --- a/test/rxjs/rxjs.fromEvent.spec.ts +++ b/test/rxjs/rxjs.fromEvent.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {fromEvent, fromEventPattern, Observable} from 'rxjs'; import {isBrowser} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; @@ -22,7 +22,7 @@ describe('Observable.fromEvent', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const triggerZone: Zone = Zone.current.fork({name: 'Trigger Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -31,7 +31,7 @@ describe('Observable.fromEvent', () => { it('fromEvent EventTarget func callback should run in the correct zone', ifEnvSupports(isEventTarget, () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEvent(document, 'click'); + return fromEvent(document, 'click'); }); const clickEvent = document.createEvent('Event'); @@ -64,7 +64,7 @@ describe('Observable.fromEvent', () => { const button = document.createElement('button'); document.body.appendChild(button); observable1 = constructorZone1.run(() => { - return Rx.Observable.fromEventPattern( + return fromEventPattern( (handler: any) => { expect(Zone.current.name).toEqual(constructorZone1.name); button.addEventListener('click', handler); diff --git a/test/rxjs/rxjs.fromPromise.spec.ts b/test/rxjs/rxjs.fromPromise.spec.ts index eba29e643..2727142fa 100644 --- a/test/rxjs/rxjs.fromPromise.spec.ts +++ b/test/rxjs/rxjs.fromPromise.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import * as Rx from 'rxjs/Rx'; +import {from} from 'rxjs'; import {asyncTest} from '../test-util'; describe('Observable.fromPromise', () => { @@ -28,7 +28,7 @@ describe('Observable.fromPromise', () => { }); }); observable1 = constructorZone1.run(() => { - return Rx.Observable.fromPromise(promise); + return from(promise); }); subscriptionZone.run(() => { @@ -48,4 +48,4 @@ describe('Observable.fromPromise', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.interval.spec.ts b/test/rxjs/rxjs.interval.spec.ts index 39bd5244f..1aa683029 100644 --- a/test/rxjs/rxjs.interval.spec.ts +++ b/test/rxjs/rxjs.interval.spec.ts @@ -5,12 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, Observable} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.interval', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +21,7 @@ describe('Observable.interval', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.interval(10); + return interval(10); }); subscriptionZone.run(() => { @@ -29,7 +30,7 @@ describe('Observable.interval', () => { log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); if (result >= 3) { - subscriber.complete(); + subscriber.unsubscribe(); expect(log).toEqual([0, 1, 2, 3]); done(); } @@ -40,4 +41,4 @@ describe('Observable.interval', () => { () => {}); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.merge.spec.ts b/test/rxjs/rxjs.merge.spec.ts index 144528d77..2ac9818bb 100644 --- a/test/rxjs/rxjs.merge.spec.ts +++ b/test/rxjs/rxjs.merge.spec.ts @@ -5,7 +5,9 @@ * 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 * as Rx from 'rxjs/Rx'; +import {interval, merge, Observable} from 'rxjs'; +import {map, take} from 'rxjs/operators'; + import {asyncTest} from '../test-util'; describe('Observable.merge', () => { @@ -21,15 +23,15 @@ describe('Observable.merge', () => { const constructorZone3: Zone = Zone.current.fork({name: 'Constructor Zone3'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); const observable1: any = constructorZone1.run(() => { - return Rx.Observable.interval(8).map(v => 'observable1' + v).take(1); + return interval(8).pipe(map(v => 'observable1' + v), take(1)); }); const observable2: any = constructorZone2.run(() => { - return Rx.Observable.interval(10).map(v => 'observable2' + v).take(1); + return interval(10).pipe(map(v => 'observable2' + v), take(1)); }); const observable3: any = constructorZone3.run(() => { - return Rx.Observable.merge(observable1, observable2); + return merge(observable1, observable2); }); subscriptionZone.run(() => { @@ -49,4 +51,4 @@ describe('Observable.merge', () => { }); }); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.never.spec.ts b/test/rxjs/rxjs.never.spec.ts index e4c6721b9..43b734d07 100644 --- a/test/rxjs/rxjs.never.spec.ts +++ b/test/rxjs/rxjs.never.spec.ts @@ -5,13 +5,14 @@ * 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 * as Rx from 'rxjs/Rx'; +import {NEVER, Observable} from 'rxjs'; +import {startWith} from 'rxjs/operators'; describe('Observable.never', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +20,7 @@ describe('Observable.never', () => { it('never func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.never().startWith(7); + return NEVER.pipe(startWith(7)); }); subscriptionZone.run(() => { @@ -38,4 +39,4 @@ describe('Observable.never', () => { expect(log).toEqual([7]); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.of.spec.ts b/test/rxjs/rxjs.of.spec.ts index 929036ac5..ea35f2726 100644 --- a/test/rxjs/rxjs.of.spec.ts +++ b/test/rxjs/rxjs.of.spec.ts @@ -5,13 +5,13 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, of} from 'rxjs'; describe('Observable.of', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -19,7 +19,7 @@ describe('Observable.of', () => { it('of func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.of(1, 2, 3); + return of(1, 2, 3); }); subscriptionZone.run(() => { @@ -39,4 +39,4 @@ describe('Observable.of', () => { expect(log).toEqual([1, 2, 3, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.range.spec.ts b/test/rxjs/rxjs.range.spec.ts index 0aa826f7a..73f6eecf9 100644 --- a/test/rxjs/rxjs.range.spec.ts +++ b/test/rxjs/rxjs.range.spec.ts @@ -5,14 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; +import {asapScheduler, Observable, range} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.range', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +21,7 @@ describe('Observable.range', () => { it('range func callback should run in the correct zone', () => { observable1 = constructorZone1.run(() => { - return Rx.Observable.range(1, 3); + return range(1, 3); }); subscriptionZone.run(() => { @@ -45,7 +46,7 @@ describe('Observable.range', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.range(1, 3, Rx.Scheduler.asap); + return range(1, 3, asapScheduler); }); subscriptionZone.run(() => { @@ -67,4 +68,4 @@ describe('Observable.range', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.spec.ts b/test/rxjs/rxjs.spec.ts index 8a42b0fe2..a1feb0930 100644 --- a/test/rxjs/rxjs.spec.ts +++ b/test/rxjs/rxjs.spec.ts @@ -5,6 +5,10 @@ * 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 */ +(Object as any).setPrototypeOf = (Object as any).setPrototypeOf || function(obj: any, proto: any) { + obj.__proto__ = proto; + return obj; +}; import '../../lib/rxjs/rxjs'; import './rxjs.common.spec'; import './rxjs.asap.spec'; @@ -39,7 +43,7 @@ import './rxjs.Observable.notification.spec'; import './rxjs.Observable.distinct.spec'; import './rxjs.Observable.do.spec'; import './rxjs.Observable.collection.spec'; -// TODO: @JiaLiPassion, add exhaust test +// // TODO: @JiaLiPassion, add exhaust test import './rxjs.Observable.merge.spec'; import './rxjs.Observable.multicast.spec'; import './rxjs.Observable.map.spec'; diff --git a/test/rxjs/rxjs.throw.spec.ts b/test/rxjs/rxjs.throw.spec.ts index 28555c358..bae55a856 100644 --- a/test/rxjs/rxjs.throw.spec.ts +++ b/test/rxjs/rxjs.throw.spec.ts @@ -5,14 +5,15 @@ * 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 * as Rx from 'rxjs/Rx'; +import {asapScheduler, Observable, throwError} from 'rxjs'; + import {asyncTest} from '../test-util'; describe('Observable.throw', () => { let log: string[]; const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -21,7 +22,7 @@ describe('Observable.throw', () => { it('throw func callback should run in the correct zone', () => { let error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.throw(error); + return throwError(error); }); subscriptionZone.run(() => { @@ -46,7 +47,7 @@ describe('Observable.throw', () => { const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); let error = new Error('test'); observable1 = constructorZone1.run(() => { - return Rx.Observable.throw(error, Rx.Scheduler.asap); + return throwError(error, asapScheduler); }); subscriptionZone.run(() => { @@ -67,4 +68,4 @@ describe('Observable.throw', () => { expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.timer.spec.ts b/test/rxjs/rxjs.timer.spec.ts index 45d4b1b66..a00423597 100644 --- a/test/rxjs/rxjs.timer.spec.ts +++ b/test/rxjs/rxjs.timer.spec.ts @@ -5,12 +5,12 @@ * 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 * as Rx from 'rxjs/Rx'; +import {Observable, timer} from 'rxjs'; import {asyncTest} from '../test-util'; describe('Observable.timer', () => { let log: string[]; - let observable1: any; + let observable1: Observable; beforeEach(() => { log = []; @@ -20,7 +20,7 @@ describe('Observable.timer', () => { const constructorZone1: Zone = Zone.current.fork({name: 'Constructor Zone1'}); const subscriptionZone: Zone = Zone.current.fork({name: 'Subscription Zone'}); observable1 = constructorZone1.run(() => { - return Rx.Observable.timer(10, 20); + return timer(10, 20); }); subscriptionZone.run(() => { @@ -29,19 +29,18 @@ describe('Observable.timer', () => { log.push(result); expect(Zone.current.name).toEqual(subscriptionZone.name); if (result >= 3) { - subscriber.complete(); + // subscriber.complete(); + subscriber.unsubscribe(); + log.push('completed'); + expect(Zone.current.name).toEqual(subscriptionZone.name); + expect(log).toEqual([0, 1, 2, 3, 'completed']); + done(); } }, () => { fail('should not call error'); - }, - () => { - log.push('completed'); - expect(Zone.current.name).toEqual(subscriptionZone.name); - expect(log).toEqual([0, 1, 2, 3, 'completed']); - done(); }); + expect(log).toEqual([]); }); - expect(log).toEqual([]); }, Zone.root)); -}); \ No newline at end of file +}); diff --git a/test/rxjs/rxjs.util.ts b/test/rxjs/rxjs.util.ts new file mode 100644 index 000000000..02523f942 --- /dev/null +++ b/test/rxjs/rxjs.util.ts @@ -0,0 +1,14 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +export function supportFeature(Observable: any, method: string) { + const func = function() { + return !!Observable.prototype[method]; + }; + (func as any).message = `Observable.${method} not support`; +} diff --git a/test/rxjs/rxjs.zip.spec.ts b/test/rxjs/rxjs.zip.spec.ts index 20ecd0f07..e768089b9 100644 --- a/test/rxjs/rxjs.zip.spec.ts +++ b/test/rxjs/rxjs.zip.spec.ts @@ -5,7 +5,8 @@ * 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 * as Rx from 'rxjs/Rx'; + +import {of, range, zip} from 'rxjs'; describe('Observable.zip', () => { let log: string[]; @@ -18,14 +19,14 @@ describe('Observable.zip', () => { it('zip func callback should run in the correct zone', () => { const observable1: any = constructorZone1.run(() => { - return Rx.Observable.range(1, 3); + return range(1, 3); }); const observable2: any = constructorZone1.run(() => { - return Rx.Observable.of('foo', 'bar', 'beer'); + return of('foo', 'bar', 'beer'); }); const observable3: any = constructorZone1.run(() => { - return Rx.Observable.zip(observable1, observable2, function(n: number, str: string) { + return zip(observable1, observable2, function(n: number, str: string) { expect(Zone.current.name).toEqual(constructorZone1.name); return {n: n, str: str}; }); @@ -48,4 +49,4 @@ describe('Observable.zip', () => { expect(log).toEqual([{n: 1, str: 'foo'}, {n: 2, str: 'bar'}, {n: 3, str: 'beer'}, 'completed']); }); -}); \ No newline at end of file +}); diff --git a/test/test-util.ts b/test/test-util.ts index 46a28c699..1a9179725 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -21,6 +21,8 @@ * * ifEnvSupports(supportsOnClick, function() { ... }); */ +import {isNode} from '../lib/common/utils'; + declare const global: any; export function ifEnvSupports(test: any, block: Function): () => void { return _ifEnvSupports(test, block); @@ -132,3 +134,11 @@ export function getEdgeVersion() { } return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); } + +export function isPhantomJS() { + if (isNode) { + return false; + } + const ua = navigator.userAgent.toLowerCase(); + return ua.indexOf('phantomjs') !== -1; +} diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 21a2be440..c58109ccd 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ -import 'rxjs/add/operator/delay'; import '../../lib/rxjs/rxjs-fake-async'; -import {Observable} from 'rxjs/Observable'; +import {Observable} from 'rxjs'; +import {delay} from 'rxjs/operators'; import {isNode, patchMacroTask} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; @@ -1146,7 +1146,7 @@ describe('FakeAsyncTestZoneSpec', () => { subscribe.next('hello'); subscribe.complete(); }); - observable.delay(1000).subscribe(v => { + observable.pipe(delay(1000)).subscribe(v => { result = v; }); expect(result).toBe(null); diff --git a/yarn.lock b/yarn.lock index 4047760fe..f589dbb95 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1072,6 +1072,10 @@ core-js@^2.1.0, core-js@^2.4.0: version "2.5.3" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" +core-js@^2.5.7: + version "2.5.7" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" + core-js@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.3.0.tgz#fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65" @@ -4716,11 +4720,11 @@ rx@2.3.24: version "2.3.24" resolved "https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7" -rxjs@^5.5.3: - version "5.5.6" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.5.6.tgz#e31fb96d6fd2ff1fd84bcea8ae9c02d007179c02" +rxjs@^6.2.1: + version "6.2.2" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.2.2.tgz#eb75fa3c186ff5289907d06483a77884586e1cf9" dependencies: - symbol-observable "1.0.1" + tslib "^1.9.0" safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" @@ -5173,10 +5177,6 @@ supports-color@~5.0.0: dependencies: has-flag "^2.0.0" -symbol-observable@1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" - systemjs@^0.19.37: version "0.19.47" resolved "https://registry.yarnpkg.com/systemjs/-/systemjs-0.19.47.tgz#c8c93937180f3f5481c769cd2720763fb4a31c6f" @@ -5458,6 +5458,10 @@ ts-loader@^0.6.0: object-assign "^2.0.0" semver "^5.0.1" +tslib@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" + tslint-eslint-rules@^3.1.0: version "3.5.1" resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-3.5.1.tgz#e43efdcdd760d6285600031720f972c92f4a058a" @@ -5507,9 +5511,9 @@ typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@2.5.2: - version "2.5.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.5.2.tgz#038a95f7d9bbb420b1bf35ba31d4c5c1dd3ffe34" +typescript@2.9.2: + version "2.9.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c" uglify-js@2.6.4: version "2.6.4" From 60adc9c59b0acdf501c84987ba7182d5d5398f8c Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 11 Sep 2018 07:00:16 +0900 Subject: [PATCH 064/106] feat(core): upgrade to typescript 3.0.3 (#1132) --- lib/browser/property-descriptor.ts | 4 ++-- package.json | 2 +- yarn.lock | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 1ac33b3d4..848204385 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -113,10 +113,10 @@ const globalEventHandlersEventNames = [ 'wheel' ]; const documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'fullscreenchange', + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange' + 'visibilitychange', 'resume' ]; const windowEventNames = [ 'absolutedeviceorientation', diff --git a/package.json b/package.json index e7b2dbd19..4d996b331 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "ts-loader": "^0.6.0", "tslint": "^4.1.1", "tslint-eslint-rules": "^3.1.0", - "typescript": "2.9.2", + "typescript": "^3.0.3", "vrsource-tslint-rules": "^4.0.0", "webdriver-manager": "^12.0.6", "webdriverio": "^4.8.0", diff --git a/yarn.lock b/yarn.lock index f589dbb95..a9f8fcb52 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5511,9 +5511,9 @@ typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -typescript@2.9.2: - version "2.9.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.9.2.tgz#1cbf61d05d6b96269244eb6a3bce4bd914e0f00c" +typescript@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8" uglify-js@2.6.4: version "2.6.4" From 427705f2a6468fc74fdd1e8dc15b70ecb11d32c9 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 12 Sep 2018 03:16:35 +0900 Subject: [PATCH 065/106] feat(custom-element): patch customElement v1 APIs (#1133) --- .travis.yml | 2 + file-size-limit.json | 4 +- karma-build-jasmine.es6.conf.js | 5 ++ karma-dist-sauce-jasmine.es6.conf.js | 6 ++ lib/browser/browser.ts | 6 +- lib/browser/register-element.ts | 41 +++++++--- package.json | 2 + sauce.es6.conf.js | 61 +++++++++++++++ test/browser/custom-element.spec.js | 108 +++++++++++++++++++++++++++ test/browser_es6_entry_point.ts | 9 +++ test/main.ts | 10 ++- 11 files changed, 239 insertions(+), 15 deletions(-) create mode 100644 karma-build-jasmine.es6.conf.js create mode 100644 karma-dist-sauce-jasmine.es6.conf.js create mode 100644 sauce.es6.conf.js create mode 100644 test/browser/custom-element.spec.js create mode 100644 test/browser_es6_entry_point.ts diff --git a/.travis.yml b/.travis.yml index 2e51e3b18..28ab26261 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,3 +54,5 @@ script: - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node - node_modules/.bin/gulp test/node -no-patch-clock + - cp ./test/browser/custom-element.spec.js ./build/test/browser + - node_modules/.bin/karma start karma-dist-sauce-jasmine.es6.conf.js --single-run diff --git a/file-size-limit.json b/file-size-limit.json index e5e12f2ef..e0fd98bf9 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 42050 + "limit": 42500 } ] -} \ No newline at end of file +} diff --git a/karma-build-jasmine.es6.conf.js b/karma-build-jasmine.es6.conf.js new file mode 100644 index 000000000..4d69b0d88 --- /dev/null +++ b/karma-build-jasmine.es6.conf.js @@ -0,0 +1,5 @@ + +module.exports = function (config) { + require('./karma-build-jasmine.conf.js')(config); + config.client.entrypoint = 'browser_es6_entry_point'; +}; diff --git a/karma-dist-sauce-jasmine.es6.conf.js b/karma-dist-sauce-jasmine.es6.conf.js new file mode 100644 index 000000000..fdeff8f45 --- /dev/null +++ b/karma-dist-sauce-jasmine.es6.conf.js @@ -0,0 +1,6 @@ + +module.exports = function (config) { + require('./karma-dist-jasmine.conf.js')(config); + require('./sauce.es6.conf')(config); + config.client.entrypoint = 'browser_es6_entry_point'; +}; diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index bf01626d7..0d7ab2458 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -17,7 +17,7 @@ import {bindArguments, patchClass, patchMacroTask, patchMethod, patchOnPropertie import {propertyPatch} from './define-property'; import {eventTargetPatch, patchEvent} from './event-target'; import {propertyDescriptorPatch} from './property-descriptor'; -import {registerElementPatch} from './register-element'; +import {patchCustomElements, registerElementPatch} from './register-element'; Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; @@ -74,7 +74,11 @@ Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate) => { propertyDescriptorPatch(api, global); propertyPatch(); +}); + +Zone.__load_patch('customElements', (global: any, Zone: ZoneType, api: _ZonePrivate) => { registerElementPatch(global); + patchCustomElements(global); }); Zone.__load_patch('canvas', (global: any) => { diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index aa1abbd7a..f590f0c60 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -10,19 +10,16 @@ import {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor, import {_redefineProperty} from './define-property'; -export function registerElementPatch(_global: any) { - if ((!isBrowser && !isMix) || !('registerElement' in (_global).document)) { +function patchCallbacks(target: any, targetName: string, method: string, callbacks: string[]) { + const symbol = Zone.__symbol__(method); + if (target[symbol]) { return; } - - const _registerElement = (document).registerElement; - const callbacks = - ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - - (document).registerElement = function(name: any, opts: any) { + const nativeDelegate = target[symbol] = target[method]; + target[method] = function(name: any, opts: any, options?: any) { if (opts && opts.prototype) { callbacks.forEach(function(callback) { - const source = 'Document.registerElement::' + callback; + const source = `${targetName}.${method}::` + callback; const prototype = opts.prototype; if (prototype.hasOwnProperty(callback)) { const descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); @@ -38,8 +35,30 @@ export function registerElementPatch(_global: any) { }); } - return _registerElement.call(document, name, opts); + return nativeDelegate.call(target, name, opts, options); }; - attachOriginToPatched((document).registerElement, _registerElement); + attachOriginToPatched(target[method], nativeDelegate); +} + +export function registerElementPatch(_global: any) { + if ((!isBrowser && !isMix) || !('registerElement' in (_global).document)) { + return; + } + + const callbacks = + ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + + patchCallbacks(document, 'Document', 'registerElement', callbacks); +} + +export function patchCustomElements(_global: any) { + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + + const callbacks = + ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + + patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); } diff --git a/package.json b/package.json index 4d996b331..479947dae 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "closure:test": "scripts/closure/closure_compiler.sh", "format": "gulp format:enforce", "karma-jasmine": "karma start karma-build-jasmine.conf.js", + "karma-jasmine:es6": "karma start karma-build-jasmine.es6.conf.js", "karma-jasmine:phantomjs": "karma start karma-build-jasmine-phantomjs.conf.js --single-run", "karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run", "karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client", @@ -38,6 +39,7 @@ "tsc:w": "tsc -w -p .", "tslint": "tslint -c tslint.json 'lib/**/*.ts'", "test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine\"", + "test:es6": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:es6\"", "test:phantomjs": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:phantomjs\"", "test:phantomjs-single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine-phantomjs:autoclose\"", "test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"", diff --git a/sauce.es6.conf.js b/sauce.es6.conf.js new file mode 100644 index 000000000..dd051f730 --- /dev/null +++ b/sauce.es6.conf.js @@ -0,0 +1,61 @@ +// Sauce configuration + +module.exports = function(config, ignoredLaunchers) { + // The WS server is not available with Sauce + config.files.unshift('test/saucelabs.js'); + + var basicLaunchers = { + 'SL_CHROME_66': {base: 'SauceLabs', browserName: 'chrome', version: '66'}, + }; + + var customLaunchers = {}; + if (!ignoredLaunchers) { + customLaunchers = basicLaunchers; + } else { + Object.keys(basicLaunchers).forEach(function(key) { + if (ignoredLaunchers + .filter(function(ignore) { + return ignore === key; + }) + .length === 0) { + customLaunchers[key] = basicLaunchers[key]; + } + }); + } + + config.set({ + captureTimeout: 120000, + browserNoActivityTimeout: 240000, + + sauceLabs: { + testName: 'Zone.js', + startConnect: false, + recordVideo: false, + recordScreenshots: false, + options: { + 'selenium-version': '2.53.0', + 'command-timeout': 600, + 'idle-timeout': 600, + 'max-duration': 5400 + } + }, + + customLaunchers: customLaunchers, + + browsers: Object.keys(customLaunchers), + + reporters: ['dots', 'saucelabs'], + + singleRun: true, + + plugins: ['karma-*'] + }); + + if (process.env.TRAVIS) { + config.sauceLabs.build = + 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; + config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; + + process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); + } +}; diff --git a/test/browser/custom-element.spec.js b/test/browser/custom-element.spec.js new file mode 100644 index 000000000..8f1c1db9f --- /dev/null +++ b/test/browser/custom-element.spec.js @@ -0,0 +1,108 @@ +/** + * @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 + */ + +/* + * check that document.registerElement(name, { prototype: proto }); + * is properly patched + */ + +function customElementsSupport() { + return 'registerElement' in document; +} +customElementsSupport.message = 'window.customElements'; + +describe('customElements', function() { + const testZone = Zone.current.fork({ name: 'test' }); + const bridge = { + connectedCallback: () => {}, + disconnectedCallback: () => {}, + adoptedCallback: () => {}, + attributeChangedCallback: () => {} + }; + + class TestCustomElement extends HTMLElement { + constructor() { + super(); + } + + static get observedAttributes() { + return ['attr1', 'attr2']; + } + + connectedCallback() { + return bridge.connectedCallback(); + } + + disconnectedCallback() { + return bridge.disconnectedCallback(); + } + + attributeChangedCallback(attrName, oldVal, newVal) { + return bridge.attributeChangedCallback(attrName, oldVal, newVal); + } + + adoptedCallback() { + return bridge.adoptedCallback(); + } + } + + testZone.run(() => { + customElements.define('x-test', TestCustomElement); + }); + + let elt; + + beforeEach(() => { + bridge.connectedCallback = () => {}; + bridge.disconnectedCallback = () => {}; + bridge.attributeChangedCallback = () => {}; + bridge.adoptedCallback = () => {}; + }); + + afterEach(() => { + if (elt) { + document.body.removeChild(elt); + elt = null; + } + }); + + it('should work with connectedCallback', function(done) { + bridge.connectedCallback = function() { + expect(Zone.current.name).toBe(testZone.name); + done(); + }; + + elt = document.createElement('x-test'); + document.body.appendChild(elt); + }); + + it('should work with disconnectedCallback', function(done) { + bridge.disconnectedCallback = function() { + expect(Zone.current.name).toBe(testZone.name); + done(); + }; + + elt = document.createElement('x-test'); + document.body.appendChild(elt); + document.body.removeChild(elt); + elt = null; + }); + + it('should work with attributeChanged', function(done) { + bridge.attributeChangedCallback = function(attrName, oldVal, newVal) { + expect(Zone.current.name).toBe(testZone.name); + expect(attrName).toEqual('attr1'); + expect(newVal).toEqual('value1'); + done(); + }; + + elt = document.createElement('x-test'); + document.body.appendChild(elt); + elt.setAttribute('attr1', 'value1'); + }); +}); diff --git a/test/browser_es6_entry_point.ts b/test/browser_es6_entry_point.ts new file mode 100644 index 000000000..d66e77c97 --- /dev/null +++ b/test/browser_es6_entry_point.ts @@ -0,0 +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 './browser/custom-element.spec'; diff --git a/test/main.ts b/test/main.ts index a68c7ec49..049f9ba6f 100644 --- a/test/main.ts +++ b/test/main.ts @@ -14,11 +14,19 @@ declare const __karma__: { __karma__.loaded = function() {}; +let entryPoint = 'browser_entry_point'; + if (typeof __karma__ !== 'undefined') { (window as any)['__Zone_Error_BlacklistedStackFrames_policy'] = (__karma__ as any).config.errorpolicy; + if ((__karma__ as any).config.entrypoint) { + entryPoint = (__karma__ as any).config.entrypoint; + } } else if (typeof process !== 'undefined') { (window as any)['__Zone_Error_BlacklistedStackFrames_policy'] = process.env.errorpolicy; + if (process.env.entrypoint) { + entryPoint = process.env.entrypoint; + } } (window as any).global = window; @@ -54,7 +62,7 @@ browserPatchedPromise.then(() => { // Setup test environment System.import(testFrameworkPatch).then(() => { System.import('/base/build/lib/common/error-rewrite').then(() => { - System.import('/base/build/test/browser_entry_point') + System.import(`/base/build/test/${entryPoint}`) .then( () => { __karma__.start(); From 7201d44451f6c67eac2b86eca3cbfafde14035d6 Mon Sep 17 00:00:00 2001 From: vikerman Date: Tue, 11 Sep 2018 11:18:24 -0700 Subject: [PATCH 066/106] fix(onProperty): user quoted access for __Zone_ignore_on_properties (#1134) Avoid closure renaming while accessing the global symbol. --- lib/browser/property-descriptor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 848204385..60500d2d7 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -272,7 +272,7 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { const supportsWebSocket = typeof WebSocket !== 'undefined'; if (canPatchViaPropertyDescriptor()) { - const ignoreProperties: IgnoreProperty[] = _global.__Zone_ignore_on_properties; + const ignoreProperties: IgnoreProperty[] = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { const internalWindow: any = window; From 9ed57124d19b116fbdf0869da94804be960a53fe Mon Sep 17 00:00:00 2001 From: Trevor Florence Date: Fri, 26 Oct 2018 11:11:33 -0600 Subject: [PATCH 067/106] Fix ZoneAwarePromise.all to resolve at the correct time (#1150) For ZoneAwarePromise.all, as [implemented](https://github.com/angular/zone.js/blob/7201d44451f6c67eac2b86eca3cbfafde14035d6/lib/common/promise.ts), the `count` variable serves three purposes: 1. Count the number of values passed-in 2. Specify the index of a resolved value in `resolvedValues` 3. Track when all the promises have been resolved. In the event that `value.then` is immediately called, `count` will be decremented at the incorrect time resulting in a potentially negative value or reaching 0 when not all values have actually been resolved. The fix is to be more meticulous about using the correct indices at the correct time and to not overload the count and number of resolved promises. This updated version is more explicit about the purpose of the `unresolvedCount` and `valueIndex` variables. `unresolvedCount` needs to start at 2 to prevent `resolve` from being called too soon in the event that `value.then` calls the callback immediately. The scoping of the index for use in `resolvedValues` is made constant to guarantee the correct index is used. This buggy behavior specifically manifested as an issue in the Monaco editor but most likely occurs elsewhere as well in cases where promises may immediately call into `.then`. Related issue: https://github.com/Microsoft/monaco-editor/issues/790#issuecomment-378452532 --- lib/common/promise.ts | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/common/promise.ts b/lib/common/promise.ts index ce765a260..aa1f44757 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -315,24 +315,37 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr resolve = res; reject = rej; }); - let count = 0; + + // Start at 2 to prevent prematurely resolving if .then is called immediately. + let unresolvedCount = 2; + let valueIndex = 0; + const resolvedValues: any[] = []; for (let value of values) { if (!isThenable(value)) { value = this.resolve(value); } - value.then( - ((index) => (value: any) => { - resolvedValues[index] = value; - count--; - if (!count) { - resolve(resolvedValues); - } - })(count), - reject!); - count++; + + const curValueIndex = valueIndex; + value.then((value: any) => { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve!(resolvedValues); + } + }, reject!); + + unresolvedCount++; + valueIndex++; } - if (!count) resolve!(resolvedValues); + + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + + if (unresolvedCount === 0) { + resolve!(resolvedValues); + } + return promise; } From 33a0ad60f4f1cfa49a23d742fadac27f759dd870 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Thu, 13 Dec 2018 06:36:15 +0900 Subject: [PATCH 068/106] fix(node): fix #1164, don't patch uncaughtException to prevent endless loop (#1170) update yarn --- .travis.yml | 2 +- lib/common/events.ts | 8 +- test/node/events.spec.ts | 8 +- yarn.lock | 971 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 981 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 28ab26261..1dc7307e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false dist: trusty cache: yarn node_js: - - 8 + - 10 env: global: - BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready diff --git a/lib/common/events.ts b/lib/common/events.ts index 4d404b427..b2a02f69c 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -10,7 +10,7 @@ * @suppress {missingRequire} */ -import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils'; +import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, isNode, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils'; /** @internal **/ interface EventTaskData extends TaskData { @@ -330,10 +330,15 @@ export function patchEventTarget( returnTarget = false, prepend = false) { return function() { const target = this || _global; + const eventName = arguments[0]; let delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } // don't create the bind delegate function for handleEvent // case here to improve addEventListener performance @@ -350,7 +355,6 @@ export function patchEventTarget( return; } - const eventName = arguments[0]; const options = arguments[2]; if (blackListedEvents) { diff --git a/test/node/events.spec.ts b/test/node/events.spec.ts index 758128e76..8b13c8012 100644 --- a/test/node/events.spec.ts +++ b/test/node/events.spec.ts @@ -183,4 +183,10 @@ describe('nodejs EventEmitter', () => { expect(emitter.listeners('removeListener').length).toBe(0); }); }); -}); \ No newline at end of file + it('should not enter endless loop when register uncaughtException to process', () => { + require('domain'); + zoneA.run(() => { + process.on('uncaughtException', function() {}); + }); + }); +}); diff --git a/yarn.lock b/yarn.lock index a9f8fcb52..da67007e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,18 +5,22 @@ "@types/jasmine@2.2.33": version "2.2.33" resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.2.33.tgz#4715cfd2ca7fbd632fc7f1784f13e637bed028c5" + integrity sha1-RxXP0sp/vWMvx/F4TxPmN77QKMU= "@types/node@^9.x": version "9.6.22" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.22.tgz#05b55093faaadedea7a4b3f76e9a61346a6dd209" + integrity sha512-RIg9EkxzVMkNH0M4sLRngK23f5QiigJC0iODQmu4nopzstt8AjegYund3r82iMrd2BNCjcZVnklaItvKHaGfBA== "@types/systemjs@^0.19.30": version "0.19.33" resolved "https://registry.yarnpkg.com/@types/systemjs/-/systemjs-0.19.33.tgz#47c47e7639867b6694beb3f60c4f53ad55eb1b13" + integrity sha1-R8R+djmGe2aUvrP2DE9TrVXrGxM= JSONStream@^1.0.4: version "1.3.2" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea" + integrity sha1-wQI3G27Dp887hHygDCC7D85Mbeo= dependencies: jsonparse "^1.2.0" through ">=2.2.7 <3" @@ -24,10 +28,12 @@ JSONStream@^1.0.4: abbrev@1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== accepts@1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.3.tgz#c3ca7434938648c3e0d9c1e328dd68b622c284ca" + integrity sha1-w8p0NJOGSMPg2cHjKN1otiLChMo= dependencies: mime-types "~2.1.11" negotiator "0.6.1" @@ -35,18 +41,22 @@ accepts@1.3.3: add-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" + integrity sha1-anmQQ3ynNtXhKI25K9MmbV9csqo= adm-zip@^0.4.7, adm-zip@~0.4.3: version "0.4.7" resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.4.7.tgz#8606c2cbf1c426ce8c8ec00174447fd49b6eafc1" + integrity sha1-hgbCy/HEJs6MjsABdER/1Jtur8E= after@0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" + integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8= ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" + integrity sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY= dependencies: co "^4.6.0" json-stable-stringify "^1.0.1" @@ -54,6 +64,7 @@ ajv@^4.9.1: ajv@^5.1.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + integrity sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU= dependencies: co "^4.6.0" fast-deep-equal "^1.0.0" @@ -63,6 +74,7 @@ ajv@^5.1.0: align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" + integrity sha1-DNkKVhCT810KmSVsIrcGlDP60Rc= dependencies: kind-of "^3.0.2" longest "^1.0.1" @@ -71,62 +83,75 @@ align-text@^0.1.1, align-text@^0.1.3: amdefine@>=0.0.4: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" + integrity sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU= ansi-align@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" + integrity sha1-w2rsy6VjuJzrVW82kPCx2eNUf38= dependencies: string-width "^2.0.0" ansi-colors@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-1.1.0.tgz#6374b4dd5d4718ff3ce27a671a3b1cad077132a9" + integrity sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA== dependencies: ansi-wrap "^0.1.0" ansi-escapes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + integrity sha512-O/klc27mWNUigtv0F8NJWbLF00OcegQalkqKURWdosW08YZKi4m6CnSUSvIZG1otNJbTWhN01Hhz389DW7mvDQ== ansi-gray@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ansi-gray/-/ansi-gray-0.1.1.tgz#2962cf54ec9792c48510a3deb524436861ef7251" + integrity sha1-KWLPVOyXksSFEKPetSRDaGHvclE= dependencies: ansi-wrap "0.1.0" ansi-regex@^0.2.0, ansi-regex@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-0.2.1.tgz#0d8e946967a3d8143f93e24e298525fc1b2235f9" + integrity sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk= ansi-regex@^2.0.0, ansi-regex@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= ansi-regex@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= ansi-styles@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-1.1.0.tgz#eaecbf66cd706882760b2f4691582b8f55d7a7de" + integrity sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94= ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= ansi-styles@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" + integrity sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug== dependencies: color-convert "^1.9.0" ansi-wrap@0.1.0, ansi-wrap@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf" + integrity sha1-qCJQ3bABXponyoLoLqYDu/pF768= anymatch@^1.3.0: version "1.3.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" + integrity sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA== dependencies: micromatch "^2.1.5" normalize-path "^2.0.0" @@ -134,10 +159,12 @@ anymatch@^1.3.0: aproba@^1.0.3: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== archiver-utils@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/archiver-utils/-/archiver-utils-1.3.0.tgz#e50b4c09c70bf3d680e32ff1b7994e9f9d895174" + integrity sha1-5QtMCccL89aA4y/xt5lOn52JUXQ= dependencies: glob "^7.0.0" graceful-fs "^4.1.0" @@ -149,6 +176,7 @@ archiver-utils@^1.3.0: archiver@~0.14.0: version "0.14.4" resolved "https://registry.yarnpkg.com/archiver/-/archiver-0.14.4.tgz#5b9ddb9f5ee1ceef21cb8f3b020e6240ecb4315c" + integrity sha1-W53bn17hzu8hy487Ag5iQOy0MVw= dependencies: async "~0.9.0" buffer-crc32 "~0.2.1" @@ -162,6 +190,7 @@ archiver@~0.14.0: archiver@~2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/archiver/-/archiver-2.1.1.tgz#ff662b4a78201494a3ee544d3a33fe7496509ebc" + integrity sha1-/2YrSnggFJSj7lRNOjP+dJZQnrw= dependencies: archiver-utils "^1.3.0" async "^2.0.0" @@ -175,10 +204,12 @@ archiver@~2.1.0: archy@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA= are-we-there-yet@~1.1.2: version "1.1.4" resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz#bb5dca382bb94f05e15194373d16fd3ba1ca110d" + integrity sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0= dependencies: delegates "^1.0.0" readable-stream "^2.0.6" @@ -186,166 +217,205 @@ are-we-there-yet@~1.1.2: arr-diff@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + integrity sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8= dependencies: arr-flatten "^1.0.1" arr-diff@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= arr-flatten@^1.0.1, arr-flatten@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== arr-union@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= array-differ@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" + integrity sha1-7/UuN1gknTO+QCuLuOVkuytdQDE= array-each@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f" + integrity sha1-p5SvDAWrF1KEbudTofIRoFugxE8= array-find-index@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + integrity sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E= array-ify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" + integrity sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4= array-slice@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-0.2.3.tgz#dd3cfb80ed7973a75117cdac69b0b99ec86186f5" + integrity sha1-3Tz7gO15c6dRF82sabC5nshhhvU= array-slice@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/array-slice/-/array-slice-1.1.0.tgz#e368ea15f89bc7069f7ffb89aec3a6c7d4ac22d4" + integrity sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w== array-union@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" + integrity sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk= dependencies: array-uniq "^1.0.1" array-uniq@^1.0.1, array-uniq@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY= array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + integrity sha1-odl8yvy8JiXMcPrc6zalDFiwGlM= array-unique@^0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= arraybuffer.slice@0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca" + integrity sha1-8zshWfBTKj8xB6JywMz70a0peco= arrify@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= asn1@0.1.11: version "0.1.11" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.1.11.tgz#559be18376d08a4ec4dbe80877d27818639b2df7" + integrity sha1-VZvhg3bQik7E2+gId9J4GGObLfc= asn1@~0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + integrity sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y= assert-plus@1.0.0, assert-plus@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= assert-plus@^0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.1.5.tgz#ee74009413002d84cec7219c6ac811812e723160" + integrity sha1-7nQAlBMALYTOxyGcasgRgS5yMWA= assert-plus@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + integrity sha1-104bh+ev/A24qttwIfP+SBAasjQ= assert@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/assert/-/assert-1.4.1.tgz#99912d591836b5a6f5b345c0f07eefc08fc65d91" + integrity sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE= dependencies: util "0.10.3" assign-symbols@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= async-each@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + integrity sha1-GdOGodntxufByF04iu28xW0zYC0= async@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/async/-/async-0.9.0.tgz#ac3613b1da9bed1b47510bb4651b8931e47146c7" + integrity sha1-rDYTsdqb7RtHUQu0ZRuJMeRxRsc= async@^1.4.0, async@^1.4.2, async@^1.5.2: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" + integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= async@^2.0.0, async@^2.0.1: version "2.6.0" resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" + integrity sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw== dependencies: lodash "^4.14.0" async@~0.2.6: version "0.2.10" resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" + integrity sha1-trvgsGdLnXGXCMo43owjfLUmw9E= async@~0.9.0: version "0.9.2" resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + integrity sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0= async@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9" + integrity sha1-+PwEyjoTeErenhZBr5hXjPvWR6k= asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= atob@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/atob/-/atob-2.0.3.tgz#19c7a760473774468f20b2d2d03372ad7d4cbf5d" + integrity sha1-GcenYEc3dEaPILLS0DNyrX1Mv10= atob@~1.1.0: version "1.1.3" resolved "https://registry.yarnpkg.com/atob/-/atob-1.1.3.tgz#95f13629b12c3a51a5d215abdce2aa9f32f80773" + integrity sha1-lfE2KbEsOlGl0hWr3OKqnzL4B3M= attempt-x@^1.1.0, attempt-x@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/attempt-x/-/attempt-x-1.1.1.tgz#fba64e96ce03c3e0bd92c92622061c4df387cb76" + integrity sha512-hIp37ojJRRW8ExWSxxLpkDHUufk/DFfsb7/cUC1cVbBg7JV4gJTkCTRa44dlL9e5jx1P3VNrjL7QOQfi4MyltA== aws-sign2@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.5.0.tgz#c57103f7a17fc037f02d7c2e64b602ea223f7d63" + integrity sha1-xXED96F/wDfwLXwuZLYC6iI/fWM= aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + integrity sha1-FDQt0428yU0OW4fXY81jYSwOeU8= aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" + integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= aws4@^1.2.1, aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" + integrity sha1-g+9cqGCysy5KDe7e6MdxudtXRx4= babel-code-frame@^6.20.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= dependencies: chalk "^1.1.3" esutils "^2.0.2" @@ -354,6 +424,7 @@ babel-code-frame@^6.20.0: babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= dependencies: core-js "^2.4.0" regenerator-runtime "^0.11.0" @@ -361,22 +432,27 @@ babel-runtime@^6.26.0: backo2@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/backo2/-/backo2-1.0.2.tgz#31ab1ac8b129363463e35b3ebb69f4dfcfba7947" + integrity sha1-MasayLEpNjRj41s+u2n038+6eUc= balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= base64-arraybuffer@0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" + integrity sha1-c5JncZI7Whl0etZmqlzUv5xunOg= base64id@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/base64id/-/base64id-1.0.0.tgz#47688cb99bb6804f0e06d3e763b1c32e57d8e6b6" + integrity sha1-R2iMuZu2gE8OBtPnY7HDLlfY5rY= base@^0.11.1: version "0.11.2" resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== dependencies: cache-base "^1.0.1" class-utils "^0.3.5" @@ -389,74 +465,89 @@ base@^0.11.1: batch@^0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/batch/-/batch-0.5.3.tgz#3f3414f380321743bfc1042f9a83ff1d5824d464" + integrity sha1-PzQU84AyF0O/wQQvmoP/HVgk1GQ= bcrypt-pbkdf@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" + integrity sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40= dependencies: tweetnacl "^0.14.3" beeper@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" + integrity sha1-5tXqjF2tABMEpwsiY4RH9pyy+Ak= better-assert@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/better-assert/-/better-assert-1.0.2.tgz#40866b9e1b9e0b55b481894311e68faffaebc522" + integrity sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI= dependencies: callsite "1.0.0" big.js@^3.1.3: version "3.2.0" resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e" + integrity sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q== binary-extensions@^1.0.0: version "1.11.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" + integrity sha1-RqoXUftqL5PuXmibsQh9SxTGwgU= bl@^0.9.0, bl@~0.9.0: version "0.9.5" resolved "https://registry.yarnpkg.com/bl/-/bl-0.9.5.tgz#c06b797af085ea00bc527afc8efcf11de2232054" + integrity sha1-wGt5evCF6gC8Unr8jvzxHeIjIFQ= dependencies: readable-stream "~1.0.26" bl@^1.0.0: version "1.2.1" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.1.tgz#cac328f7bee45730d404b692203fcb590e172d5e" + integrity sha1-ysMo977kVzDUBLaSID/LWQ4XLV4= dependencies: readable-stream "^2.0.5" bl@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/bl/-/bl-1.0.3.tgz#fc5421a28fd4226036c3b3891a66a25bc64d226e" + integrity sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4= dependencies: readable-stream "~2.0.5" blob@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" + integrity sha1-vPEwUspURj8w+fx+lbmkdjCpSSE= block-stream@*: version "0.0.9" resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + integrity sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo= dependencies: inherits "~2.0.0" bluebird@2.9.6: version "2.9.6" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.9.6.tgz#1fc3a6b1685267dc121b5ec89b32ce069d81ab7d" + integrity sha1-H8OmsWhSZ9wSG17ImzLOBp2Bq30= bluebird@^2.9.27, bluebird@^2.9.30: version "2.11.0" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" + integrity sha1-U0uQM8AiyVecVro7Plpcqvu2UOE= bluebird@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" + integrity sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== body-parser@^1.12.4: version "1.18.2" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454" + integrity sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ= dependencies: bytes "3.0.0" content-type "~1.0.4" @@ -472,24 +563,28 @@ body-parser@^1.12.4: boom@2.x.x: version "2.10.1" resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + integrity sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8= dependencies: hoek "2.x.x" boom@4.x.x: version "4.3.1" resolved "https://registry.yarnpkg.com/boom/-/boom-4.3.1.tgz#4f8a3005cb4a7e3889f749030fd25b96e01d2e31" + integrity sha1-T4owBctKfjiJ90kDD9JbluAdLjE= dependencies: hoek "4.x.x" boom@5.x.x: version "5.2.0" resolved "https://registry.yarnpkg.com/boom/-/boom-5.2.0.tgz#5dd9da6ee3a5f302077436290cb717d3f4a54e02" + integrity sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw== dependencies: hoek "4.x.x" boxen@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/boxen/-/boxen-1.3.0.tgz#55c6c39a8ba58d9c61ad22cd877532deb665a20b" + integrity sha512-TNPjfTr432qx7yOjQyaXm3dSR0MH9vXp7eT1BFSl/C51g+EFnOR9hTg1IreahGBmDNCehscshe45f+C1TBZbLw== dependencies: ansi-align "^2.0.0" camelcase "^4.0.0" @@ -502,6 +597,7 @@ boxen@^1.2.1: brace-expansion@^1.0.0, brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" @@ -509,12 +605,14 @@ brace-expansion@^1.0.0, brace-expansion@^1.1.7: braces@^0.1.2: version "0.1.5" resolved "https://registry.yarnpkg.com/braces/-/braces-0.1.5.tgz#c085711085291d8b75fdd74eab0f8597280711e6" + integrity sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY= dependencies: expand-range "^0.1.0" braces@^1.8.2: version "1.8.5" resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + integrity sha1-uneWLhLf+WnWt2cR6RS3N4V79qc= dependencies: expand-range "^1.8.1" preserve "^0.2.0" @@ -523,6 +621,7 @@ braces@^1.8.2: braces@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.1.tgz#7086c913b4e5a08dbe37ac0ee6a2500c4ba691bb" + integrity sha512-SO5lYHA3vO6gz66erVvedSCkp7AKWdv6VcQ2N4ysXfPxdAlxAMMAdwegGGcv1Bqwm7naF1hNdk5d6AAIEHV2nQ== dependencies: arr-flatten "^1.1.0" array-unique "^0.3.2" @@ -540,32 +639,39 @@ braces@^2.3.1: browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" + integrity sha1-81HTKWnTL6XXpVZxVCY9korjvR8= buffer-crc32@^0.2.1, buffer-crc32@~0.2.1: version "0.2.13" resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= buffer-from@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-0.1.1.tgz#57b18b1da0a19ec06f33837a5275a242351bd75e" + integrity sha1-V7GLHaChnsBvM4N6UnWiQjUb114= dependencies: is-array-buffer-x "^1.0.13" builtin-modules@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8= byline@^4.1.1: version "4.2.2" resolved "https://registry.yarnpkg.com/byline/-/byline-4.2.2.tgz#c203a98a5b0290822a9386a78eda2cbd5bcdb32f" + integrity sha1-wgOpilsCkIIqk4anjtosvVvNsy8= bytes@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + integrity sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg= cache-base@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== dependencies: collection-visit "^1.0.0" component-emitter "^1.2.1" @@ -580,14 +686,17 @@ cache-base@^1.0.1: cached-constructors-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/cached-constructors-x/-/cached-constructors-x-1.0.0.tgz#c421e3892a4b6f7794434bdcffd1299b330c181b" + integrity sha512-JVP0oilYlPgBTD8bkQ+of7hSIJRtydCCJiMtzdRMXVQ98gdj0NyrJTZzbu5wtlO26Ev/1HXRTtbBNsVlLJ3+3A== callsite@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" + integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA= camelcase-keys@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + integrity sha1-MIvur/3ygRkFHvodkyITyRuPkuc= dependencies: camelcase "^2.0.0" map-obj "^1.0.0" @@ -595,34 +704,42 @@ camelcase-keys@^2.0.0: camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" + integrity sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk= camelcase@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= camelcase@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= capture-stack-trace@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" + integrity sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0= caseless@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + integrity sha1-cVuW6phBWTzDMGeSP17GDr2k99c= caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= caseless@~0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.9.0.tgz#b7b65ce6bf1413886539cfd533f0b30effa9cf88" + integrity sha1-t7Zc5r8UE4hlOc/VM/CzDv+pz4g= center-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" + integrity sha1-qg0yYptu6XIgBBHL1EYckHvCt60= dependencies: align-text "^0.1.3" lazy-cache "^1.0.3" @@ -630,6 +747,7 @@ center-align@^0.1.1: chalk@0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-0.5.1.tgz#663b3a648b68b55d04690d49167aa837858f2174" + integrity sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ= dependencies: ansi-styles "^1.1.0" escape-string-regexp "^1.0.0" @@ -640,6 +758,7 @@ chalk@0.5.1: chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= dependencies: ansi-styles "^2.2.1" escape-string-regexp "^1.0.2" @@ -650,6 +769,7 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: chalk@^2.0.0, chalk@^2.0.1: version "2.3.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796" + integrity sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g== dependencies: ansi-styles "^3.2.0" escape-string-regexp "^1.0.5" @@ -658,10 +778,12 @@ chalk@^2.0.0, chalk@^2.0.1: chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + integrity sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I= chokidar@^1.4.1: version "1.7.0" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + integrity sha1-eY5ol3gVHIB2tLNg5e3SjNortGg= dependencies: anymatch "^1.3.0" async-each "^1.0.0" @@ -677,6 +799,7 @@ chokidar@^1.4.1: clang-format@^1.0.32: version "1.2.2" resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.2.tgz#a7277a03fce9aa4e387ddaa83b60d99dab115737" + integrity sha512-6X9u1JBMak/9VbC0IZajEDvp19/PbjCanbRO3Z2xsluypQtbPPAGDvGGovLOWoUpXIvJH9vJExmzlqWvwItZxA== dependencies: async "^1.5.2" glob "^7.0.0" @@ -685,6 +808,7 @@ clang-format@^1.0.32: clang-format@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.3.tgz#2763561aa7449c43737480f8df3a2b5b66e6cf37" + integrity sha512-x90Hac4ERacGDcZSvHKK58Ga0STuMD+Doi5g0iG2zf7wlJef5Huvhs/3BvMRFxwRYyYSdl6mpQNrtfMxE8MQzw== dependencies: async "^1.5.2" glob "^7.0.0" @@ -693,6 +817,7 @@ clang-format@^1.2.3: class-utils@^0.3.5: version "0.3.6" resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== dependencies: arr-union "^3.1.0" define-property "^0.2.5" @@ -702,10 +827,12 @@ class-utils@^0.3.5: cli-boxes@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" + integrity sha1-T6kXw+WclKAEzWH47lCdplFocUM= cli-color@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/cli-color/-/cli-color-1.2.0.tgz#3a5ae74fd76b6267af666e69e2afbbd01def34d1" + integrity sha1-OlrnT9drYmevZm5p4q+70B3vNNE= dependencies: ansi-regex "^2.1.1" d "1" @@ -717,16 +844,19 @@ cli-color@^1.0.0: cli-cursor@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" + integrity sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU= dependencies: restore-cursor "^2.0.0" cli-width@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" + integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= cliui@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1" + integrity sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE= dependencies: center-align "^0.1.1" right-align "^0.1.1" @@ -735,30 +865,37 @@ cliui@^2.1.0: clone-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" + integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg= clone-stats@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" + integrity sha1-uI+UqCzzi4eR1YBG6kAprYjKmdE= clone-stats@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" + integrity sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= clone@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" + integrity sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8= clone@^1.0.0, clone@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.3.tgz#298d7e2231660f40c003c2ed3140decf3f53085f" + integrity sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8= clone@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.1.tgz#d217d1e961118e3ac9a4b8bba3285553bf647cdb" + integrity sha1-0hfR6WERjjrJpLi7oyhVU79kfNs= cloneable-readable@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/cloneable-readable/-/cloneable-readable-1.0.0.tgz#a6290d413f217a61232f95e458ff38418cfb0117" + integrity sha1-pikNQT8hemEjL5XkWP84QYz7ARc= dependencies: inherits "^2.0.1" process-nextick-args "^1.0.6" @@ -767,14 +904,17 @@ cloneable-readable@^1.0.0: co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" + integrity sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ= code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" + integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= collection-visit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= dependencies: map-visit "^1.0.0" object-visit "^1.0.0" @@ -782,58 +922,70 @@ collection-visit@^1.0.0: color-convert@^1.9.0: version "1.9.1" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed" + integrity sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ== dependencies: color-name "^1.1.1" color-name@^1.1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= color-support@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" + integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== colors@^1.0.3, colors@^1.1.0, colors@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + integrity sha1-FopHAXVran9RoSzgyXv6KMCE7WM= combined-stream@1.0.6, combined-stream@^1.0.5, combined-stream@~1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + integrity sha1-cj599ugBrFYTETp+RFqbactjKBg= dependencies: delayed-stream "~1.0.0" combined-stream@~0.0.4, combined-stream@~0.0.5: version "0.0.7" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-0.0.7.tgz#0137e657baa5a7541c57ac37ac5fc07d73b4dc1f" + integrity sha1-ATfmV7qlp1QcV6w3rF/AfXO03B8= dependencies: delayed-stream "0.0.5" commander@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/commander/-/commander-0.6.1.tgz#fa68a14f6a945d54dbbe50d8cdb3320e9e3b1a06" + integrity sha1-+mihT2qUXVTbvlDYzbMyDp47GgY= commander@2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.3.0.tgz#fd430e889832ec353b9acd1de217c11cb3eef873" + integrity sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM= commander@2.6.0: version "2.6.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.6.0.tgz#9df7e52fb2a0cb0fb89058ee80c3104225f37e1d" + integrity sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0= commander@2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + integrity sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q= dependencies: graceful-readlink ">= 1.0.0" commander@^2.8.1, commander@^2.9.0: version "2.14.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" + integrity sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw== compare-func@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" + integrity sha1-md0LpFfh+bxyKxLAjsM+6rMfpkg= dependencies: array-ify "^1.0.0" dot-prop "^3.0.0" @@ -841,22 +993,27 @@ compare-func@^1.3.1: component-bind@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/component-bind/-/component-bind-1.0.0.tgz#00c608ab7dcd93897c0009651b1d3a8e1e73bbd1" + integrity sha1-AMYIq33Nk4l8AAllGx06jh5zu9E= component-emitter@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.1.2.tgz#296594f2753daa63996d2af08d15a95116c9aec3" + integrity sha1-KWWU8nU9qmOZbSrwjRWpURbJrsM= component-emitter@1.2.1, component-emitter@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" + integrity sha1-E3kY1teCg/ffemt8WmPhQOaUJeY= component-inherit@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/component-inherit/-/component-inherit-0.0.3.tgz#645fc4adf58b72b649d5cae65135619db26ff143" + integrity sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM= compress-commons@^1.2.0: version "1.2.2" resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-1.2.2.tgz#524a9f10903f3a813389b0225d27c48bb751890f" + integrity sha1-UkqfEJA/OoEzibAiXSfEi7dRiQ8= dependencies: buffer-crc32 "^0.2.1" crc32-stream "^2.0.0" @@ -866,6 +1023,7 @@ compress-commons@^1.2.0: compress-commons@~0.2.0: version "0.2.9" resolved "https://registry.yarnpkg.com/compress-commons/-/compress-commons-0.2.9.tgz#422d927430c01abd06cd455b6dfc04cb4cf8003c" + integrity sha1-Qi2SdDDAGr0GzUVbbfwEy0z4ADw= dependencies: buffer-crc32 "~0.2.1" crc32-stream "~0.3.1" @@ -875,10 +1033,12 @@ compress-commons@~0.2.0: concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= concat-stream@1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.0.tgz#53f7d43c51c5e43f81c8fdd03321c631be68d611" + integrity sha1-U/fUPFHF5D+ByP3QMyHGMb5o1hE= dependencies: inherits "~2.0.1" readable-stream "~2.0.0" @@ -887,6 +1047,7 @@ concat-stream@1.5.0: concat-stream@1.6.0, concat-stream@^1.5.0: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" + integrity sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc= dependencies: inherits "^2.0.3" readable-stream "^2.2.2" @@ -895,6 +1056,7 @@ concat-stream@1.6.0, concat-stream@^1.5.0: concurrently@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/concurrently/-/concurrently-2.2.0.tgz#bad248e0bb129fb1621768903a6311d45d56895a" + integrity sha1-utJI4LsSn7FiF2iQOmMR1F1WiVo= dependencies: bluebird "2.9.6" chalk "0.5.1" @@ -907,6 +1069,7 @@ concurrently@^2.2.0: configstore@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/configstore/-/configstore-3.1.1.tgz#094ee662ab83fad9917678de114faaea8fcdca90" + integrity sha512-5oNkD/L++l0O6xGXxb1EWS7SivtjfGQlRyxJsYgE0Z495/L81e2h4/d3r969hoPXuFItzNOKMtsXgYG4c7dYvw== dependencies: dot-prop "^4.1.0" graceful-fs "^4.1.2" @@ -918,6 +1081,7 @@ configstore@^3.0.0: connect@^3.3.5: version "3.6.6" resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" + integrity sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ= dependencies: debug "2.6.9" finalhandler "1.1.0" @@ -927,14 +1091,17 @@ connect@^3.3.5: console-control-strings@^1.0.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= content-type@~1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== conventional-changelog-angular@^1.6.5: version "1.6.5" resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.5.tgz#936249e897501affdffc6043da45cab59d6f0907" + integrity sha512-70zO0ThLMlAzPOiYqRAFcMTQbe1Qewy+4v/TJuKMZueCJwR1fLqJCVfvjRlnPrYDwgjI0kc74VymbFO7rJDIPg== dependencies: compare-func "^1.3.1" q "^1.4.1" @@ -942,18 +1109,21 @@ conventional-changelog-angular@^1.6.5: conventional-changelog-atom@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-0.2.3.tgz#117d024e5cf9e28dcbd0575981105395be1bca74" + integrity sha512-ZhhcyBeMQQbQ/eqanVb9bFJfS7ScsPgvlbPWLrL5HgcfdO9yGSaEp/hLvXIZ2tYYDd8e5Y0AB+5C4tiSE2K4EQ== dependencies: q "^1.4.1" conventional-changelog-codemirror@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-0.3.3.tgz#e1ec78e77e7fe26a2bd18e32f02523527916a07b" + integrity sha512-9vYteJT6F3Ao3CtgXYg1JCRdzLI4qqbH3GdHL0OSjEe/FQjsJRcGHqpbUQ1SQ0ga+vqAJlJdJNib9BwHIQF4mw== dependencies: q "^1.4.1" conventional-changelog-core@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-2.0.4.tgz#bbc476109c6b28ba6328b0b417f5ab5bfc7ca28a" + integrity sha512-XsmaKcbfewovP72N5w17TNV6fqZYTF0jnNKG0V/OhPsIZETFvFzJwPHCDM3FrRNvDXWRvqb2M0a83cvYhHbvzw== dependencies: conventional-changelog-writer "^3.0.3" conventional-commits-parser "^2.1.4" @@ -972,36 +1142,42 @@ conventional-changelog-core@^2.0.4: conventional-changelog-ember@^0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-0.3.5.tgz#db9a23f01103c6a0446ed2077ed5c87656d0571a" + integrity sha512-A55p1kg/ekyU2zTEScdRKwuHaCUfDocakIPoaxdCxsRQ1732C4Em4u6lbN0F1jQHoCsQqqA1aPAEOMKgDicnbA== dependencies: q "^1.4.1" conventional-changelog-eslint@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-1.0.3.tgz#023002a3f776266c501e4d4def7b0bb24130f29d" + integrity sha512-4Y1/9TX16RvWiOdMnJQ8flxZ+hdDGVm1E4yrWvyr1L1UBWM56CJobMRg7nf+LqqVnKj0kkuyhwf3WV9//luYHg== dependencies: q "^1.4.1" conventional-changelog-express@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-0.3.3.tgz#25aef42a30b5457f97681a94f2ac9b0ee515484a" + integrity sha512-ivIa/9a05xxcA4bH1jQFpzwCEJywDirHhcQ6OQwYvAy0/ekRfGXA9U2ULVqE1WRqcmpFuayfAuysE9BJjqthEQ== dependencies: q "^1.4.1" conventional-changelog-jquery@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-0.1.0.tgz#0208397162e3846986e71273b6c79c5b5f80f510" + integrity sha1-Agg5cWLjhGmG5xJztsecW1+A9RA= dependencies: q "^1.4.1" conventional-changelog-jscs@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/conventional-changelog-jscs/-/conventional-changelog-jscs-0.1.0.tgz#0479eb443cc7d72c58bf0bcf0ef1d444a92f0e5c" + integrity sha1-BHnrRDzH1yxYvwvPDvHURKkvDlw= dependencies: q "^1.4.1" conventional-changelog-jshint@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-0.3.3.tgz#28b6fe4d41fb945f38c6c31cd195fe37594f0007" + integrity sha512-RuGFuOp101qhxQdV+h4Dhdeqs1ZsycdoqN14GZ98E3MiDGQ++jfH6wjgUjU8uv8jULyrkLPenIWC0ooxQYneCw== dependencies: compare-func "^1.3.1" q "^1.4.1" @@ -1009,10 +1185,12 @@ conventional-changelog-jshint@^0.3.3: conventional-changelog-preset-loader@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-1.1.5.tgz#d5af525d7ad81179d9b54137284d74d665997fa7" + integrity sha512-ngaSOqeyH5hYYdvl+bcJNEiT9B2c8cSRpIZtnFxbRyH7MVQbLOEn5oPV9NpQM00hTyBtqDviNDCXmy/Al6Gq8w== conventional-changelog-writer@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-3.0.3.tgz#2faa65739370769639fff1c0008722162936d46c" + integrity sha512-gzkAFnFxjEOBCwISTBUJ6DnthMwzqY1MRyElN6S25VYBcRV/6DOVbbZgbBL1KdsogO6Z/QuJlSnIH7OteVd5lQ== dependencies: compare-func "^1.3.1" conventional-commits-filter "^1.1.4" @@ -1028,6 +1206,7 @@ conventional-changelog-writer@^3.0.3: conventional-changelog@^1.1.16, conventional-changelog@^1.1.7: version "1.1.16" resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-1.1.16.tgz#fa78386c831f5b1ae45f60391ef015c2a4a400b9" + integrity sha512-7Z7B39PJeCbviJw6ukVOjoyWDGmSvlZj77UkPxXPLO03zGgHHADCDSu1yU/YfVsKkQiel4Ot0o7jTqbP8zIvVQ== dependencies: conventional-changelog-angular "^1.6.5" conventional-changelog-atom "^0.2.3" @@ -1044,6 +1223,7 @@ conventional-changelog@^1.1.16, conventional-changelog@^1.1.7: conventional-commits-filter@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-1.1.4.tgz#8b5be3979c372e4f7440180d5c655a94ac5a134a" + integrity sha512-VaLmHo+P1IYQenZwkgp21y9z5tyU8sH3GKI/AfthQYPK9IYhT4lNbATGW9Iona+BU3fmWw/9S3L5vMopMI+jkA== dependencies: is-subset "^0.1.1" modify-values "^1.0.0" @@ -1051,6 +1231,7 @@ conventional-commits-filter@^1.1.4: conventional-commits-parser@^2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.1.4.tgz#86d2c21029268d99543c4ebda37d76fe5c44d8d1" + integrity sha512-dyTFuqQQzTynPN81zk9Pvm6d4mGiTuPz+Qi1ee8CmhupBji7gwO0DKXvAWo3MEFilE50pm8h8kRbETL5wsI65A== dependencies: JSONStream "^1.0.4" is-text-path "^1.0.0" @@ -1063,30 +1244,37 @@ conventional-commits-parser@^2.1.4: cookie@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb" + integrity sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s= copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= core-js@^2.1.0, core-js@^2.4.0: version "2.5.3" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" + integrity sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4= core-js@^2.5.7: version "2.5.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" + integrity sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw== core-js@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.3.0.tgz#fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65" + integrity sha1-+rg/uwstjchfpjbEudNMdUIMbWU= core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= crc32-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-2.0.0.tgz#e3cdd3b4df3168dd74e3de3fbbcb7b297fe908f4" + integrity sha1-483TtN8xaN10494/u8t7KX/pCPQ= dependencies: crc "^3.4.4" readable-stream "^2.0.0" @@ -1094,6 +1282,7 @@ crc32-stream@^2.0.0: crc32-stream@~0.3.1: version "0.3.4" resolved "https://registry.yarnpkg.com/crc32-stream/-/crc32-stream-0.3.4.tgz#73bc25b45fac1db6632231a7bfce8927e9f06552" + integrity sha1-c7wltF+sHbZjIjGnv86JJ+nwZVI= dependencies: buffer-crc32 "~0.2.1" readable-stream "~1.0.24" @@ -1101,22 +1290,26 @@ crc32-stream@~0.3.1: crc@^3.4.4: version "3.5.0" resolved "https://registry.yarnpkg.com/crc/-/crc-3.5.0.tgz#98b8ba7d489665ba3979f59b21381374101a1964" + integrity sha1-mLi6fUiWZbo5efWbITgTdBAaGWQ= create-error-class@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" + integrity sha1-Br56vvlHo/FKMP1hBnHUAbyot7Y= dependencies: capture-stack-trace "^1.0.0" cross-spawn@^0.2.9: version "0.2.9" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-0.2.9.tgz#bd67f96c07efb6303b7fe94c1e979f88478e0a39" + integrity sha1-vWf5bAfvtjA7f+lMHpefiEeOCjk= dependencies: lru-cache "^2.5.0" cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" + integrity sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk= dependencies: lru-cache "^4.0.1" shebang-command "^1.2.0" @@ -1125,32 +1318,38 @@ cross-spawn@^5.0.1: cryptiles@2.x.x: version "2.0.5" resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + integrity sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g= dependencies: boom "2.x.x" cryptiles@3.x.x: version "3.1.2" resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-3.1.2.tgz#a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe" + integrity sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4= dependencies: boom "5.x.x" crypto-random-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e" + integrity sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4= css-parse@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/css-parse/-/css-parse-2.0.0.tgz#a468ee667c16d81ccf05c58c38d2a97c780dbfd4" + integrity sha1-pGjuZnwW2BzPBcWMONKpfHgNv9Q= dependencies: css "^2.0.0" css-value@~0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/css-value/-/css-value-0.0.1.tgz#5efd6c2eea5ea1fd6b6ac57ec0427b18452424ea" + integrity sha1-Xv1sLupeof1rasV+wEJ7GEUkJOo= css@^2.0.0: version "2.2.1" resolved "https://registry.yarnpkg.com/css/-/css-2.2.1.tgz#73a4c81de85db664d4ee674f7d47085e3b2d55dc" + integrity sha1-c6TIHehdtmTU7mdPfUcIXjstVdw= dependencies: inherits "^2.0.1" source-map "^0.1.38" @@ -1160,38 +1359,45 @@ css@^2.0.0: ctype@0.5.3: version "0.5.3" resolved "https://registry.yarnpkg.com/ctype/-/ctype-0.5.3.tgz#82c18c2461f74114ef16c135224ad0b9144ca12f" + integrity sha1-gsGMJGH3QRTvFsE1IkrQuRRMoS8= currently-unhandled@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + integrity sha1-mI3zP+qxke95mmE2nddsF635V+o= dependencies: array-find-index "^1.0.1" custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= d@1: version "1.0.0" resolved "https://registry.yarnpkg.com/d/-/d-1.0.0.tgz#754bb5bfe55451da69a58b94d45f4c5b0462d58f" + integrity sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8= dependencies: es5-ext "^0.10.9" dargs@^4.0.1: version "4.1.0" resolved "https://registry.yarnpkg.com/dargs/-/dargs-4.1.0.tgz#03a9dbb4b5c2f139bf14ae53f0b8a2a6a86f4e17" + integrity sha1-A6nbtLXC8Tm/FK5T8LiipqhvThc= dependencies: number-is-nan "^1.0.0" dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" + integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= dependencies: assert-plus "^1.0.0" dateformat@^1.0.11, dateformat@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + integrity sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk= dependencies: get-stdin "^4.0.1" meow "^3.3.0" @@ -1199,76 +1405,91 @@ dateformat@^1.0.11, dateformat@^1.0.12: dateformat@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.2.0.tgz#4065e2013cf9fb916ddfd82efb506ad4c6769062" + integrity sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI= deap@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/deap/-/deap-1.0.0.tgz#b148bf82430a27699b7483a03eb6b67585bfc888" + integrity sha1-sUi/gkMKJ2mbdIOgPra2dYW/yIg= debug@0.7.4: version "0.7.4" resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" + integrity sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk= debug@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + integrity sha1-+HBX6ZWxofauaklgZkE3vFbwOdo= dependencies: ms "0.7.1" debug@2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c" + integrity sha1-QMRT5n5uE8kB3ewxeviYbNqe/4w= dependencies: ms "0.7.2" debug@2.6.8: version "2.6.8" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" + integrity sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw= dependencies: ms "2.0.0" debug@2.6.9, debug@^2.2.0, debug@^2.3.3: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== dependencies: ms "2.0.0" decamelize@^1.0.0, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= deep-extend@~0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" + integrity sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8= deepmerge@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-2.0.1.tgz#25c1c24f110fb914f80001b925264dd77f3f4312" + integrity sha512-VIPwiMJqJ13ZQfaCsIFnp5Me9tnjURiaIFxfz7EH0Ci0dTSQpZtSLrqOicXqEd/z2r+z+Klk9GzmnRsgpgbOsQ== defaults@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" + integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= dependencies: clone "^1.0.2" define-property@^0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= dependencies: is-descriptor "^0.1.0" define-property@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= dependencies: is-descriptor "^1.0.0" define-property@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== dependencies: is-descriptor "^1.0.2" isobject "^3.0.1" @@ -1276,6 +1497,7 @@ define-property@^2.0.2: del@^2.2.0: version "2.2.2" resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" + integrity sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag= dependencies: globby "^5.0.0" is-path-cwd "^1.0.0" @@ -1288,58 +1510,72 @@ del@^2.2.0: delayed-stream@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-0.0.5.tgz#d4b1f43a93e8296dfe02694f4680bc37a313c73f" + integrity sha1-1LH0OpPoKW3+AmlPRoC8N6MTxz8= delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= depd@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" + integrity sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k= depd@~1.1.1: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= deprecated@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19" + integrity sha1-+cmvVGSvoeepcUWKi97yqpTVuxk= detect-file@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" + integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= detect-libc@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= di@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" + integrity sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw= diff@1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-1.4.0.tgz#7f28d2eb9ee7b15a97efd89ce63dcfdaa3ccbabf" + integrity sha1-fyjS657nsVqX79ic5j3P2qPMur8= diff@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9" + integrity sha1-yc45Okt8vQsFinJck98pkCeGj/k= diff@^2.0.2: version "2.2.3" resolved "https://registry.yarnpkg.com/diff/-/diff-2.2.3.tgz#60eafd0d28ee906e4e8ff0a52c1229521033bf99" + integrity sha1-YOr9DSjukG5Oj/ClLBIpUhAzv5k= diff@^3.0.1: version "3.4.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c" + integrity sha512-QpVuMTEoJMF7cKzi6bvWhRulU1fZqZnvyVQgNhPaxxuTYwyjn/j1v9falseQ/uXWwPnO56RBfwtg4h/EQXmucA== doctrine@^0.7.2: version "0.7.2" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523" + integrity sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM= dependencies: esutils "^1.1.6" isarray "0.0.1" @@ -1347,6 +1583,7 @@ doctrine@^0.7.2: dom-serialize@^2.2.0: version "2.2.1" resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" + integrity sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs= dependencies: custom-event "~1.0.0" ent "~2.2.0" @@ -1356,38 +1593,45 @@ dom-serialize@^2.2.0: dot-prop@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" + integrity sha1-G3CK8JSknJoOfbyteQq6U52sEXc= dependencies: is-obj "^1.0.0" dot-prop@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" + integrity sha512-tUMXrxlExSW6U2EXiiKGSBVdYgtV8qlHL+C10TsW4PURY/ic+eaysnSkwB4kA/mBlCyy/IKDJ+Lc3wbWeaXtuQ== dependencies: is-obj "^1.0.0" duplexer2@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" + integrity sha1-xhTc9n4vsUmVqRcR5aYX6KYKMds= dependencies: readable-stream "~1.1.9" duplexer2@~0.1.0: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" + integrity sha1-ixLauHjA1p4+eJEFFmKjL8a93ME= dependencies: readable-stream "^2.0.2" duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= duplexer@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + integrity sha1-rOb/gIwc5mtX0ev5eXessCM0z8E= duplexify@^3.2.0: version "3.5.3" resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.3.tgz#8b5818800df92fd0125b27ab896491912858243e" + integrity sha512-g8ID9OroF9hKt2POf8YLayy+9594PzmM3scI00/uBXocX3TWNgoB67hjzkFe9ITAbQOne/lLdBxHXvYUM4ZgGA== dependencies: end-of-stream "^1.0.0" inherits "^2.0.1" @@ -1397,40 +1641,48 @@ duplexify@^3.2.0: ecc-jsbn@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + integrity sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU= dependencies: jsbn "~0.1.0" ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= ejs@~2.5.6: version "2.5.7" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" + integrity sha1-zIcsFoiArjxxiXYv1f/ACJbJUYo= emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" + integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k= encodeurl@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= end-of-stream@^1.0.0, end-of-stream@^1.1.0: version "1.4.1" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" + integrity sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q== dependencies: once "^1.4.0" end-of-stream@~0.1.5: version "0.1.5" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf" + integrity sha1-jhdyBsPICDfYVjLouTWd/osvbq8= dependencies: once "~1.3.0" engine.io-client@~1.8.4: version "1.8.5" resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-1.8.5.tgz#fe7fb60cb0dcf2fa2859489329cb5968dedeb11f" + integrity sha512-AYTgHyeVUPitsseqjoedjhYJapNVoSPShbZ+tEUX9/73jgZ/Z3sUlJf9oYgdEBBdVhupUpUqSxH0kBCXlQnmZg== dependencies: component-emitter "1.2.1" component-inherit "0.0.3" @@ -1448,6 +1700,7 @@ engine.io-client@~1.8.4: engine.io-parser@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-1.3.2.tgz#937b079f0007d0893ec56d46cb220b8cb435220a" + integrity sha1-k3sHnwAH0Ik+xW1GyyILjLQ1Igo= dependencies: after "0.8.2" arraybuffer.slice "0.0.6" @@ -1459,6 +1712,7 @@ engine.io-parser@1.3.2: engine.io@~1.8.4: version "1.8.5" resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.5.tgz#4ebe5e75c6dc123dee4afdce6e5fdced21eb93f6" + integrity sha512-j1DWIcktw4hRwrv6nWx++5nFH2X64x16MAG2P0Lmi5Dvdfi3I+Jhc7JKJIdAmDJa+5aZ/imHV7dWRPy2Cqjh3A== dependencies: accepts "1.3.3" base64id "1.0.0" @@ -1470,6 +1724,7 @@ engine.io@~1.8.4: enhanced-resolve@^0.9.0: version "0.9.1" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" + integrity sha1-TW5omzcl+GCQknzMhs2fFjW4ni4= dependencies: graceful-fs "^4.1.2" memory-fs "^0.2.0" @@ -1478,16 +1733,19 @@ enhanced-resolve@^0.9.0: ent@~2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= error-ex@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" + integrity sha1-+FWobOYa3E6GIcPNoh56dhLDqNw= dependencies: is-arrayish "^0.2.1" es5-ext@^0.10.12, es5-ext@^0.10.14, es5-ext@^0.10.30, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: version "0.10.39" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.39.tgz#fca21b67559277ca4ac1a1ed7048b107b6f76d87" + integrity sha512-AlaXZhPHl0po/uxMx1tyrlt1O86M6D5iVaDH8UgLfgek4kXTX6vzsRfJQWC2Ku+aG8pkw1XWzh9eTkwfVrsD5g== dependencies: es6-iterator "~2.0.3" es6-symbol "~3.1.1" @@ -1495,6 +1753,7 @@ es5-ext@^0.10.12, es5-ext@^0.10.14, es5-ext@^0.10.30, es5-ext@^0.10.35, es5-ext@ es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/es6-iterator/-/es6-iterator-2.0.3.tgz#a7de889141a05a94b0854403b2d0a0fbfa98f3b7" + integrity sha1-p96IkUGgWpSwhUQDstCg+/qY87c= dependencies: d "1" es5-ext "^0.10.35" @@ -1503,18 +1762,22 @@ es6-iterator@2, es6-iterator@^2.0.1, es6-iterator@~2.0.3: es6-promise@^3.0.2: version "3.3.1" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613" + integrity sha1-oIzd6EzNvzTQJ6FFG8kdS80ophM= es6-promise@^4.0.3: version "4.2.4" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29" + integrity sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ== es6-promise@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.0.2.tgz#010d5858423a5f118979665f46486a95c6ee2bb6" + integrity sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y= es6-symbol@^3.1.1, es6-symbol@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" + integrity sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc= dependencies: d "1" es5-ext "~0.10.14" @@ -1522,6 +1785,7 @@ es6-symbol@^3.1.1, es6-symbol@~3.1.1: es6-weak-map@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/es6-weak-map/-/es6-weak-map-2.0.2.tgz#5e3ab32251ffd1538a1f8e5ffa1357772f92d96f" + integrity sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8= dependencies: d "1" es5-ext "^0.10.14" @@ -1531,26 +1795,32 @@ es6-weak-map@^2.0.2: escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= escape-string-regexp@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz#4dbc2fe674e71949caf3fb2695ce7f2dc1d9a8d1" + integrity sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE= escape-string-regexp@1.0.5, escape-string-regexp@^1.0.0, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= esutils@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" + integrity sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U= esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + integrity sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs= event-emitter@^0.3.5: version "0.3.5" resolved "https://registry.yarnpkg.com/event-emitter/-/event-emitter-0.3.5.tgz#df8c69eef1647923c7157b9ce83840610b02cc39" + integrity sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk= dependencies: d "1" es5-ext "~0.10.14" @@ -1558,6 +1828,7 @@ event-emitter@^0.3.5: event-stream@^3.1.5: version "3.3.4" resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.4.tgz#4ab4c9a0f5a54db9338b4c34d86bfce8f4b35571" + integrity sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE= dependencies: duplexer "~0.1.1" from "~0" @@ -1570,10 +1841,12 @@ event-stream@^3.1.5: eventemitter3@1.x.x: version "1.2.0" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-1.2.0.tgz#1c86991d816ad1e504750e73874224ecf3bec508" + integrity sha1-HIaZHYFq0eUEdQ5zh0Ik7PO+xQg= execa@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" + integrity sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c= dependencies: cross-spawn "^5.0.1" get-stream "^3.0.0" @@ -1586,10 +1859,12 @@ execa@^0.7.0: exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" + integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= expand-braces@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" + integrity sha1-SIsdHSRRyz06axks/AMPRMWFX+o= dependencies: array-slice "^0.2.3" array-unique "^0.2.1" @@ -1598,12 +1873,14 @@ expand-braces@^0.1.1: expand-brackets@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + integrity sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s= dependencies: is-posix-bracket "^0.1.0" expand-brackets@^2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= dependencies: debug "^2.3.3" define-property "^0.2.5" @@ -1616,6 +1893,7 @@ expand-brackets@^2.1.4: expand-range@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-0.1.1.tgz#4cb8eda0993ca56fa4f41fc42f3cbb4ccadff044" + integrity sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ= dependencies: is-number "^0.1.1" repeat-string "^0.2.2" @@ -1623,24 +1901,28 @@ expand-range@^0.1.0: expand-range@^1.8.1: version "1.8.2" resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + integrity sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc= dependencies: fill-range "^2.1.0" expand-tilde@^2.0.0, expand-tilde@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" + integrity sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= dependencies: homedir-polyfill "^1.0.1" extend-shallow@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= dependencies: is-extendable "^0.1.0" extend-shallow@^3.0.0, extend-shallow@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= dependencies: assign-symbols "^1.0.0" is-extendable "^1.0.1" @@ -1648,10 +1930,12 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" + integrity sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ= external-editor@^2.0.4: version "2.1.0" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" + integrity sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA== dependencies: chardet "^0.4.0" iconv-lite "^0.4.17" @@ -1660,12 +1944,14 @@ external-editor@^2.0.4: extglob@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + integrity sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE= dependencies: is-extglob "^1.0.0" extglob@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== dependencies: array-unique "^0.3.2" define-property "^1.0.0" @@ -1679,6 +1965,7 @@ extglob@^2.0.4: extract-zip@^1.6.5: version "1.6.6" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.6.tgz#1290ede8d20d0872b429fd3f351ca128ec5ef85c" + integrity sha1-EpDt6NINCHK0Kf0/NRyhKOxe+Fw= dependencies: concat-stream "1.6.0" debug "2.6.9" @@ -1688,6 +1975,7 @@ extract-zip@^1.6.5: extract-zip@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.5.0.tgz#92ccf6d81ef70a9fa4c1747114ccef6d8688a6c4" + integrity sha1-ksz22B73Cp+kwXRxFMzvbYaIpsQ= dependencies: concat-stream "1.5.0" debug "0.7.4" @@ -1697,14 +1985,17 @@ extract-zip@~1.5.0: extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= extsprintf@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" + integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= fancy-log@^1.0.0, fancy-log@^1.1.0, fancy-log@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.2.tgz#f41125e3d84f2e7d89a43d06d958c8f78be16be1" + integrity sha1-9BEl49hPLn2JpD0G2VjI94vha+E= dependencies: ansi-gray "^0.1.1" color-support "^1.1.3" @@ -1713,30 +2004,36 @@ fancy-log@^1.0.0, fancy-log@^1.1.0, fancy-log@^1.3.2: fast-deep-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" + integrity sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8= fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" + integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= fd-slicer@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" + integrity sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU= dependencies: pend "~1.2.0" figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" + integrity sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI= dependencies: escape-string-regexp "^1.0.5" filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" + integrity sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY= fill-range@^2.1.0: version "2.2.3" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + integrity sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM= dependencies: is-number "^2.1.0" isobject "^2.0.0" @@ -1747,6 +2044,7 @@ fill-range@^2.1.0: fill-range@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= dependencies: extend-shallow "^2.0.1" is-number "^3.0.0" @@ -1756,6 +2054,7 @@ fill-range@^4.0.0: finalhandler@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.0.tgz#ce0b6855b45853e791b2fcc680046d88253dd7f5" + integrity sha1-zgtoVbRYU+eRsvzGgARtiCU91/U= dependencies: debug "2.6.9" encodeurl "~1.0.1" @@ -1768,10 +2067,12 @@ finalhandler@1.1.0: find-index@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" + integrity sha1-Z101iyyjiS15Whq0cjL4tuLg3eQ= find-up@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + integrity sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8= dependencies: path-exists "^2.0.0" pinkie-promise "^2.0.0" @@ -1779,6 +2080,7 @@ find-up@^1.0.0: findup-sync@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" + integrity sha1-kyaxSIwi0aYIhlCoaQGy2akKLLw= dependencies: detect-file "^1.0.0" is-glob "^3.1.0" @@ -1788,12 +2090,14 @@ findup-sync@^2.0.0: findup-sync@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16" + integrity sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY= dependencies: glob "~5.0.0" fined@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/fined/-/fined-1.1.0.tgz#b37dc844b76a2f5e7081e884f7c0ae344f153476" + integrity sha1-s33IRLdqL15wgeiE98CuNE8VNHY= dependencies: expand-tilde "^2.0.2" is-plain-object "^2.0.3" @@ -1804,34 +2108,41 @@ fined@^1.0.1: first-chunk-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" + integrity sha1-Wb+1DNkF9g18OUzT2ayqtOatk04= flagged-respawn@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.0.tgz#4e79ae9b2eb38bf86b3bb56bf3e0a56aa5fcabd7" + integrity sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c= for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= for-own@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + integrity sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4= dependencies: for-in "^1.0.1" for-own@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/for-own/-/for-own-1.0.0.tgz#c63332f415cedc4b04dbfe70cf836494c53cb44b" + integrity sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs= dependencies: for-in "^1.0.1" forever-agent@~0.6.0, forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= form-data@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/form-data/-/form-data-0.2.0.tgz#26f8bc26da6440e299cbdcfb69035c4f77a6e466" + integrity sha1-Jvi8JtpkQOKZy9z7aQNcT3em5GY= dependencies: async "~0.9.0" combined-stream "~0.0.4" @@ -1840,6 +2151,7 @@ form-data@~0.2.0: form-data@~1.0.0-rc3: version "1.0.1" resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.1.tgz#ae315db9a4907fa065502304a66d7733475ee37c" + integrity sha1-rjFduaSQf6BlUCMEpm13M0de43w= dependencies: async "^2.0.1" combined-stream "^1.0.5" @@ -1848,6 +2160,7 @@ form-data@~1.0.0-rc3: form-data@~2.1.1: version "2.1.4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + integrity sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE= dependencies: asynckit "^0.4.0" combined-stream "^1.0.5" @@ -1856,6 +2169,7 @@ form-data@~2.1.1: form-data@~2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099" + integrity sha1-SXBJi+YEwgwAXU9cI67NIda0kJk= dependencies: asynckit "^0.4.0" combined-stream "1.0.6" @@ -1864,28 +2178,33 @@ form-data@~2.3.1: formatio@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.1.1.tgz#5ed3ccd636551097383465d996199100e86161e9" + integrity sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek= dependencies: samsam "~1.1" fragment-cache@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= dependencies: map-cache "^0.2.2" from@~0: version "0.1.7" resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" + integrity sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4= fs-access@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/fs-access/-/fs-access-1.0.1.tgz#d6a87f262271cefebec30c553407fb995da8777a" + integrity sha1-1qh/JiJxzv6+wwxVNAf7mV2od3o= dependencies: null-check "^1.0.0" fs-extra@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" + integrity sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA= dependencies: graceful-fs "^4.1.2" jsonfile "^2.1.0" @@ -1894,6 +2213,7 @@ fs-extra@^1.0.0: fs-extra@~0.26.4: version "0.26.7" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9" + integrity sha1-muH92UiXeY7at20JGM9C0MMYT6k= dependencies: graceful-fs "^4.1.2" jsonfile "^2.1.0" @@ -1904,10 +2224,12 @@ fs-extra@~0.26.4: fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= fsevents@^1.0.0: version "1.1.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.3.tgz#11f82318f5fe7bb2cd22965a108e9306208216d8" + integrity sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q== dependencies: nan "^2.3.0" node-pre-gyp "^0.6.39" @@ -1915,6 +2237,7 @@ fsevents@^1.0.0: fstream-ignore@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + integrity sha1-nDHa40dnAY/h0kmyTa2mfQktoQU= dependencies: fstream "^1.0.0" inherits "2" @@ -1923,6 +2246,7 @@ fstream-ignore@^1.0.5: fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: version "1.0.11" resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.11.tgz#5c1fb1f117477114f0632a0eb4b71b3cb0fd3171" + integrity sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE= dependencies: graceful-fs "^4.1.2" inherits "~2.0.0" @@ -1932,6 +2256,7 @@ fstream@^1.0.0, fstream@^1.0.10, fstream@^1.0.2: gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" + integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" @@ -1945,28 +2270,33 @@ gauge@~2.7.3: gaze@^0.5.1: version "0.5.2" resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" + integrity sha1-QLcJU30k0dRXZ9takIaJ3+aaxE8= dependencies: globule "~0.1.0" gaze@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/gaze/-/gaze-1.1.2.tgz#847224677adb8870d679257ed3388fdb61e40105" + integrity sha1-hHIkZ3rbiHDWeSV+0ziP22HkAQU= dependencies: globule "^1.0.0" generate-function@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + integrity sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ= generate-object-property@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + integrity sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA= dependencies: is-property "^1.0.0" get-pkg-repo@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" + integrity sha1-xztInAbYDMVTbCyFP54FIyBWly0= dependencies: hosted-git-info "^2.1.4" meow "^3.3.0" @@ -1977,24 +2307,29 @@ get-pkg-repo@^1.0.0: get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" + integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= dependencies: assert-plus "^1.0.0" git-raw-commits@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-1.3.3.tgz#464f9aa14c4e78235e98654f0da467f3702590f9" + integrity sha512-EKgNIRhpCYFgLTM+o4lbu5+JxTGhUBgaRN3JQv/X2dm7zuSf64tay/igxf2RMJfOZYpmUYX96JOk3Q7JajPLVA== dependencies: dargs "^4.0.1" lodash.template "^4.0.2" @@ -2005,6 +2340,7 @@ git-raw-commits@^1.3.3: git-remote-origin-url@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/git-remote-origin-url/-/git-remote-origin-url-2.0.0.tgz#5282659dae2107145a11126112ad3216ec5fa65f" + integrity sha1-UoJlna4hBxRaERJhEq0yFuxfpl8= dependencies: gitconfiglocal "^1.0.0" pify "^2.3.0" @@ -2012,6 +2348,7 @@ git-remote-origin-url@^2.0.0: git-semver-tags@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-1.3.3.tgz#0b0416c43285adfdc93a8038ea25502a09319245" + integrity sha512-FK/ZQeFwANfsoo+3FFhO1XRVVKgSZgcO0ABtydFrPQj7U2N5ELVr8MxBqlXa5TdpRKTp6/H5ki1cK2Anxr2kJw== dependencies: meow "^3.3.0" semver "^5.0.1" @@ -2019,12 +2356,14 @@ git-semver-tags@^1.3.3: gitconfiglocal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/gitconfiglocal/-/gitconfiglocal-1.0.0.tgz#41d045f3851a5ea88f03f24ca1c6178114464b9b" + integrity sha1-QdBF84UaXqiPA/JMocYXgRRGS5s= dependencies: ini "^1.3.2" glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + integrity sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q= dependencies: glob-parent "^2.0.0" is-glob "^2.0.0" @@ -2032,12 +2371,14 @@ glob-base@^0.3.0: glob-parent@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + integrity sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg= dependencies: is-glob "^2.0.0" glob-stream@^3.1.5: version "3.1.18" resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" + integrity sha1-kXCl8St5Awb9/lmPMT+PeVT9FDs= dependencies: glob "^4.3.1" glob2base "^0.0.12" @@ -2049,6 +2390,7 @@ glob-stream@^3.1.5: glob-stream@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-4.1.1.tgz#b842df10d688c7eb6bcfcebd846f3852296b3200" + integrity sha1-uELfENaIx+trz869hG84UilrMgA= dependencies: glob "^4.3.1" glob2base "^0.0.12" @@ -2060,24 +2402,28 @@ glob-stream@^4.0.1: glob-watcher@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" + integrity sha1-uVtKjfdLOcgymLDAXJeLTZo7cQs= dependencies: gaze "^0.5.1" glob-watcher@^0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.8.tgz#68aeb661e7e2ce8d3634381b2ec415f00c6bc2a4" + integrity sha1-aK62Yefizo02NDgbLsQV8AxrwqQ= dependencies: gaze "^0.5.1" glob2base@^0.0.12: version "0.0.12" resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" + integrity sha1-nUGbPijxLoOjYhZKJ3BVkiycDVY= dependencies: find-index "^0.1.1" glob@3.2.11: version "3.2.11" resolved "https://registry.yarnpkg.com/glob/-/glob-3.2.11.tgz#4a973f635b9190f715d10987d5c00fd2815ebe3d" + integrity sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0= dependencies: inherits "2" minimatch "0.3" @@ -2085,6 +2431,7 @@ glob@3.2.11: glob@7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + integrity sha1-gFIR3wT6rxxjo2ADBs31reULLsg= dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -2096,6 +2443,7 @@ glob@7.1.1: glob@^4.3.1: version "4.5.3" resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" + integrity sha1-xstz0yJsHv7wTePFbQEvAzd+4V8= dependencies: inflight "^1.0.4" inherits "2" @@ -2105,6 +2453,7 @@ glob@^4.3.1: glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@~7.1.1: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" + integrity sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -2116,6 +2465,7 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@~7.1.1: glob@~3.1.21: version "3.1.21" resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" + integrity sha1-0p4KBV3qUTj00H7UDomC6DwgZs0= dependencies: graceful-fs "~1.2.0" inherits "1" @@ -2124,6 +2474,7 @@ glob@~3.1.21: glob@~4.3.0: version "4.3.5" resolved "https://registry.yarnpkg.com/glob/-/glob-4.3.5.tgz#80fbb08ca540f238acce5d11d1e9bc41e75173d3" + integrity sha1-gPuwjKVA8jiszl0R0em8QedRc9M= dependencies: inflight "^1.0.4" inherits "2" @@ -2133,6 +2484,7 @@ glob@~4.3.0: glob@~5.0.0: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + integrity sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E= dependencies: inflight "^1.0.4" inherits "2" @@ -2143,12 +2495,14 @@ glob@~5.0.0: global-dirs@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" + integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU= dependencies: ini "^1.3.4" global-modules@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea" + integrity sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg== dependencies: global-prefix "^1.0.1" is-windows "^1.0.1" @@ -2157,6 +2511,7 @@ global-modules@^1.0.0: global-prefix@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" + integrity sha1-2/dDxsFJklk8ZVVoy2btMsASLr4= dependencies: expand-tilde "^2.0.2" homedir-polyfill "^1.0.1" @@ -2167,6 +2522,7 @@ global-prefix@^1.0.1: globby@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" + integrity sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0= dependencies: array-union "^1.0.1" arrify "^1.0.0" @@ -2178,6 +2534,7 @@ globby@^5.0.0: globule@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/globule/-/globule-1.2.0.tgz#1dc49c6822dd9e8a2fa00ba2a295006e8664bd09" + integrity sha1-HcScaCLdnoovoAuiopUAboZkvQk= dependencies: glob "~7.1.1" lodash "~4.17.4" @@ -2186,6 +2543,7 @@ globule@^1.0.0: globule@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" + integrity sha1-2cjt3h2nnRJaFRt5UzuXhnY0auU= dependencies: glob "~3.1.21" lodash "~1.0.1" @@ -2194,12 +2552,14 @@ globule@~0.1.0: glogg@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.1.tgz#dcf758e44789cc3f3d32c1f3562a3676e6a34810" + integrity sha512-ynYqXLoluBKf9XGR1gA59yEJisIL7YHEH4xr3ZziHB5/yl4qWfaK8Js9jGe6gBGCSCKVqiyO30WnRZADvemUNw== dependencies: sparkles "^1.0.0" google-closure-compiler@^20170409.0.0: version "20170409.0.0" resolved "https://registry.yarnpkg.com/google-closure-compiler/-/google-closure-compiler-20170409.0.0.tgz#dc1be29a9f7eef8611364533b271b9fac757c970" + integrity sha1-3Bvimp9+74YRNkUzsnG5+sdXyXA= dependencies: chalk "^1.0.0" vinyl "^2.0.1" @@ -2208,6 +2568,7 @@ google-closure-compiler@^20170409.0.0: got@^6.7.1: version "6.7.1" resolved "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" + integrity sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA= dependencies: create-error-class "^3.0.0" duplexer3 "^0.1.4" @@ -2224,28 +2585,34 @@ got@^6.7.1: graceful-fs@^3.0.0: version "3.0.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" + integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg= dependencies: - natives "^1.1.0" + natives "^1.1.3" graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" + integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= graceful-fs@~1.2.0: version "1.2.3" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" + integrity sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q= "graceful-readlink@>= 1.0.0": version "1.0.1" resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU= growl@1.9.2: version "1.9.2" resolved "https://registry.yarnpkg.com/growl/-/growl-1.9.2.tgz#0ea7743715db8d8de2c5ede1775e1b45ac85c02f" + integrity sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8= gulp-clang-format@^1.0.25: version "1.0.25" resolved "https://registry.yarnpkg.com/gulp-clang-format/-/gulp-clang-format-1.0.25.tgz#5176567b9f72067bfb55c9204c8ef03115c3ff49" + integrity sha512-YSYk3st/ktKrBWfnDSutYZU9pLnCdaeJBTT8YguTJJLkQjSFZjBCBquecSXfoWW+NcVfGuei3N7vs7xuSR+2bg== dependencies: clang-format "^1.0.32" gulp-diff "^1.0.0" @@ -2258,6 +2625,7 @@ gulp-clang-format@^1.0.25: gulp-conventional-changelog@^1.1.7: version "1.1.16" resolved "https://registry.yarnpkg.com/gulp-conventional-changelog/-/gulp-conventional-changelog-1.1.16.tgz#c1b4295a7e340afec441b47f8a8fce7eea12cd13" + integrity sha512-bq5Dzut5idbjpK0oalnT8w+HM7JI+xn3Yic4EClLNqeoGAXYCJdRC/lUEb8zPf1mXj4l0X9ZDnqopZ5hXIagbg== dependencies: add-stream "^1.0.0" concat-stream "^1.5.0" @@ -2270,6 +2638,7 @@ gulp-conventional-changelog@^1.1.7: gulp-diff@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/gulp-diff/-/gulp-diff-1.0.0.tgz#101b23712dd6b107bd07d05ab88ea3ac485fed77" + integrity sha1-EBsjcS3WsQe9B9BauI6jrEhf7Xc= dependencies: cli-color "^1.0.0" diff "^2.0.2" @@ -2280,10 +2649,12 @@ gulp-diff@^1.0.0: gulp-rename@^1.2.2: version "1.2.2" resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.2.2.tgz#3ad4428763f05e2764dec1c67d868db275687817" + integrity sha1-OtRCh2PwXidk3sHGfYaNsnVoeBc= gulp-rollup@^2.16.1: version "2.16.2" resolved "https://registry.yarnpkg.com/gulp-rollup/-/gulp-rollup-2.16.2.tgz#1f805d3a3d808679fb545a683697eead73a93731" + integrity sha512-Gs9NYcUl0xXod7qenC1Lm49a/PGllAa5ONyCXu29lXfkP1oJnJzSdPBjopm9RlOVhefadbHlfy9AijovFrqABA== dependencies: buffer-from "^0.1.1" plugin-error "^1.0.0" @@ -2295,6 +2666,7 @@ gulp-rollup@^2.16.1: gulp-tsc@^1.1.4: version "1.3.2" resolved "https://registry.yarnpkg.com/gulp-tsc/-/gulp-tsc-1.3.2.tgz#5a66f80af3976005e6f5f06b9cfccb0e6d7399ce" + integrity sha1-Wmb4CvOXYAXm9fBrnPzLDm1zmc4= dependencies: async "^1.4.2" byline "^4.1.1" @@ -2311,6 +2683,7 @@ gulp-tsc@^1.1.4: gulp-tslint@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/gulp-tslint/-/gulp-tslint-7.1.0.tgz#9bd3ff4fbc16d4cbd9abb08ff786db89b563e93d" + integrity sha1-m9P/T7wW1MvZq7CP94bbibVj6T0= dependencies: gulp-util "~3.0.8" map-stream "~0.1.0" @@ -2319,6 +2692,7 @@ gulp-tslint@^7.0.1: gulp-uglify@^1.2.0: version "1.5.4" resolved "https://registry.yarnpkg.com/gulp-uglify/-/gulp-uglify-1.5.4.tgz#524788d87666d09f9d0c21fb2177f90039a658c9" + integrity sha1-UkeI2HZm0J+dDCH7IXf5ADmmWMk= dependencies: deap "^1.0.0" fancy-log "^1.0.0" @@ -2332,6 +2706,7 @@ gulp-uglify@^1.2.0: gulp-util@^3.0.0, gulp-util@^3.0.1, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-util@^3.0.7, gulp-util@~3.0.8: version "3.0.8" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" + integrity sha1-AFTh50RQLifATBh8PsxQXdVLu08= dependencies: array-differ "^1.0.0" array-uniq "^1.0.2" @@ -2355,6 +2730,7 @@ gulp-util@^3.0.0, gulp-util@^3.0.1, gulp-util@^3.0.4, gulp-util@^3.0.6, gulp-uti gulp@^3.8.11: version "3.9.1" resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" + integrity sha1-VxzkWSjdQK9lFPxAEYZgFsE4RbQ= dependencies: archy "^1.0.0" chalk "^1.0.0" @@ -2373,12 +2749,14 @@ gulp@^3.8.11: gulplog@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/gulplog/-/gulplog-1.0.0.tgz#e28c4d45d05ecbbed818363ce8f9c5926229ffe5" + integrity sha1-4oxNRdBey77YGDY86PnFkmIp/+U= dependencies: glogg "^1.0.0" handlebars@^4.0.2: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" + integrity sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw= dependencies: async "^1.4.0" optimist "^0.6.1" @@ -2389,14 +2767,17 @@ handlebars@^4.0.2: har-schema@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + integrity sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4= har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" + integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= har-validator@^1.4.0: version "1.8.0" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-1.8.0.tgz#d83842b0eb4c435960aeb108a067a3aa94c0eeb2" + integrity sha1-2DhCsOtMQ1lgrrEIoGejqpTA7rI= dependencies: bluebird "^2.9.30" chalk "^1.0.0" @@ -2406,6 +2787,7 @@ har-validator@^1.4.0: har-validator@~2.0.2: version "2.0.6" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + integrity sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0= dependencies: chalk "^1.1.1" commander "^2.9.0" @@ -2415,6 +2797,7 @@ har-validator@~2.0.2: har-validator@~4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + integrity sha1-M0gdDxu/9gDdID11gSpqX7oALio= dependencies: ajv "^4.9.1" har-schema "^1.0.5" @@ -2422,6 +2805,7 @@ har-validator@~4.2.1: har-validator@~5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" + integrity sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0= dependencies: ajv "^5.1.0" har-schema "^2.0.0" @@ -2429,46 +2813,55 @@ har-validator@~5.0.3: has-ansi@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-0.1.0.tgz#84f265aae8c0e6a88a12d7022894b7568894c62e" + integrity sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4= dependencies: ansi-regex "^0.2.0" has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= dependencies: ansi-regex "^2.0.0" has-binary@0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/has-binary/-/has-binary-0.1.7.tgz#68e61eb16210c9545a0a5cce06a873912fe1e68c" + integrity sha1-aOYesWIQyVRaClzOBqhzkS/h5ow= dependencies: isarray "0.0.1" has-cors@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/has-cors/-/has-cors-1.1.0.tgz#5e474793f7ea9843d1bb99c23eef49ff126fff39" + integrity sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk= has-flag@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + integrity sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo= has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" + integrity sha1-6CB68cx7MNRGzHC3NLXovhj4jVE= has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= has-gulplog@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" + integrity sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4= dependencies: sparkles "^1.0.0" has-own-property-x@^3.1.1: version "3.2.0" resolved "https://registry.yarnpkg.com/has-own-property-x/-/has-own-property-x-3.2.0.tgz#1c4b112a577c8cb5805469556e54b6e959e4ded9" + integrity sha512-HtRQTYpRFz/YVaQ7jh2mU5iorMAxFcML9FNOLMI1f8VNJ2K0hpOlXoi1a+nmVl6oUcGnhd6zYOFAVe7NUFStyQ== dependencies: cached-constructors-x "^1.0.0" to-object-x "^1.5.0" @@ -2477,20 +2870,24 @@ has-own-property-x@^3.1.1: has-symbol-support-x@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.1.tgz#66ec2e377e0c7d7ccedb07a3a84d77510ff1bc4c" + integrity sha512-JkaetveU7hFbqnAC1EV1sF4rlojU2D4Usc5CmS69l6NfmPDnpnFUegzFg33eDkkpNCxZ0mQp65HwUDrNFS/8MA== has-to-string-tag-x@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz#a045ab383d7b4b2012a00148ab0aa5f290044d4d" + integrity sha512-vdbKfmw+3LoOYVr+mtxHaX5a96+0f3DljYd8JOqvOLsf5mw2Otda2qCDT9qRqLAhrjyQ0h7ual5nOiASpsGNFw== dependencies: has-symbol-support-x "^1.4.1" has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= has-value@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= dependencies: get-value "^2.0.3" has-values "^0.1.4" @@ -2499,6 +2896,7 @@ has-value@^0.3.1: has-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= dependencies: get-value "^2.0.6" has-values "^1.0.0" @@ -2507,10 +2905,12 @@ has-value@^1.0.0: has-values@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= has-values@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= dependencies: is-number "^3.0.0" kind-of "^4.0.0" @@ -2518,6 +2918,7 @@ has-values@^1.0.0: hasha@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" + integrity sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE= dependencies: is-stream "^1.0.1" pinkie-promise "^2.0.0" @@ -2525,6 +2926,7 @@ hasha@^2.2.0: hawk@3.1.3, hawk@~3.1.0, hawk@~3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + integrity sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ= dependencies: boom "2.x.x" cryptiles "2.x.x" @@ -2534,6 +2936,7 @@ hawk@3.1.3, hawk@~3.1.0, hawk@~3.1.3: hawk@~2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/hawk/-/hawk-2.3.1.tgz#1e731ce39447fa1d0f6d707f7bceebec0fd1ec1f" + integrity sha1-HnMc45RH+h0PbXB/e87r7A/R7B8= dependencies: boom "2.x.x" cryptiles "2.x.x" @@ -2543,6 +2946,7 @@ hawk@~2.3.0: hawk@~6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/hawk/-/hawk-6.0.2.tgz#af4d914eb065f9b5ce4d9d11c1cb2126eecc3038" + integrity sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ== dependencies: boom "4.x.x" cryptiles "3.x.x" @@ -2552,28 +2956,34 @@ hawk@~6.0.2: he@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" + integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0= hoek@2.x.x: version "2.16.3" resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + integrity sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0= hoek@4.x.x: version "4.2.1" resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb" + integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA== homedir-polyfill@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz#4c2bbc8a758998feebf5ed68580f76d46768b4bc" + integrity sha1-TCu8inWJmP7r9e1oWA921GdotLw= dependencies: parse-passwd "^1.0.0" hosted-git-info@^2.1.4: version "2.5.0" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" + integrity sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg== http-errors@1.6.2, http-errors@~1.6.2: version "1.6.2" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" + integrity sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY= dependencies: depd "1.1.1" inherits "2.0.3" @@ -2583,6 +2993,7 @@ http-errors@1.6.2, http-errors@~1.6.2: http-proxy@^1.13.0: version "1.16.2" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742" + integrity sha1-Bt/ykpUr9k2+hHH6nfcwZtTzd0I= dependencies: eventemitter3 "1.x.x" requires-port "1.x.x" @@ -2590,6 +3001,7 @@ http-proxy@^1.13.0: http-signature@~0.10.0: version "0.10.1" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-0.10.1.tgz#4fbdac132559aa8323121e540779c0a012b27e66" + integrity sha1-T72sEyVZqoMjEh5UB3nAoBKyfmY= dependencies: asn1 "0.1.11" assert-plus "^0.1.5" @@ -2598,6 +3010,7 @@ http-signature@~0.10.0: http-signature@~1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + integrity sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8= dependencies: assert-plus "^0.2.0" jsprim "^1.2.2" @@ -2606,6 +3019,7 @@ http-signature@~1.1.0: http-signature@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" + integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= dependencies: assert-plus "^1.0.0" jsprim "^1.2.2" @@ -2614,36 +3028,44 @@ http-signature@~1.2.0: iconv-lite@0.4.19, iconv-lite@^0.4.17: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" + integrity sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ== immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha1-nbHb0Pr43m++D13V5Wu2BigN5ps= import-lazy@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" + integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM= imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= indent-string@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + integrity sha1-ji1INIdCEhtKghi3oTfppSBJ3IA= dependencies: repeating "^2.0.0" indexof@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" + integrity sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10= infinity-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/infinity-x/-/infinity-x-1.0.0.tgz#cea2d75181d820961b0f72d78e7c4e06fdd55a07" + integrity sha512-wjy2TupBtZ+aAniKt+xs/PO0xOkuaL6wBysUKbgD7aL1PMW/qY5xXDG59zXZ7dU+gk3zwXOu4yIEWPCEFBTgHQ== inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= dependencies: once "^1.3.0" wrappy "1" @@ -2651,22 +3073,27 @@ inflight@^1.0.4: inherits@1: version "1.0.2" resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" + integrity sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js= inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= inherits@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE= ini@^1.3.2, ini@^1.3.4, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== inquirer@~3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" + integrity sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ== dependencies: ansi-escapes "^3.0.0" chalk "^2.0.0" @@ -2686,10 +3113,12 @@ inquirer@~3.3.0: interpret@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" + integrity sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ= is-absolute@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" + integrity sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA== dependencies: is-relative "^1.0.0" is-windows "^1.0.1" @@ -2697,18 +3126,21 @@ is-absolute@^1.0.0: is-accessor-descriptor@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= dependencies: kind-of "^3.0.2" is-accessor-descriptor@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== dependencies: kind-of "^6.0.0" is-array-buffer-x@^1.0.13: version "1.7.0" resolved "https://registry.yarnpkg.com/is-array-buffer-x/-/is-array-buffer-x-1.7.0.tgz#4b0b10427b64aa3437767adf4fc07702c59b2371" + integrity sha512-ufSZRMY2WZX5xyNvk0NOZAG7cgi35B/sGQDGqv8w0X7MoQ2GC9vedanJhuYTPaC4PUCqLQsda1w7NF+dPZmAJw== dependencies: attempt-x "^1.1.0" has-to-string-tag-x "^1.4.1" @@ -2719,42 +3151,50 @@ is-array-buffer-x@^1.0.13: is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= is-binary-path@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + integrity sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg= dependencies: binary-extensions "^1.0.0" is-buffer@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== is-builtin-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + integrity sha1-VAVy0096wxGfj3bDDLwbHgN6/74= dependencies: builtin-modules "^1.0.0" is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= dependencies: kind-of "^3.0.2" is-data-descriptor@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== dependencies: kind-of "^6.0.0" is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" + integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY= is-descriptor@^0.1.0: version "0.1.6" resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== dependencies: is-accessor-descriptor "^0.1.6" is-data-descriptor "^0.1.4" @@ -2763,6 +3203,7 @@ is-descriptor@^0.1.0: is-descriptor@^1.0.0, is-descriptor@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== dependencies: is-accessor-descriptor "^1.0.0" is-data-descriptor "^1.0.0" @@ -2771,40 +3212,48 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-dotfile@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" + integrity sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE= is-equal-shallow@^0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + integrity sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ= dependencies: is-primitive "^2.0.0" is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= is-extendable@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== dependencies: is-plain-object "^2.0.4" is-extglob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + integrity sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA= is-extglob@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= is-falsey-x@^1.0.0, is-falsey-x@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-falsey-x/-/is-falsey-x-1.0.1.tgz#c469951adc95b8b3fdbf90929b335a7de937d17f" + integrity sha512-XWNZC4A+3FX1ECoMjspuEFgSdio82IWjqY/suE0gZ10QA7nzHd/KraRq7Tc5VEHtFRgTRyTdY6W+ykPrDnyoAQ== dependencies: to-boolean-x "^1.0.1" is-finite-x@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/is-finite-x/-/is-finite-x-3.0.2.tgz#a6ec683cfb2bc1a918a1ff59d178edbcea54f7a6" + integrity sha512-HyFrxJZsgmP5RtR1PVlVvHSP4VslZOqr4uoq4x3rDrSOFaYp4R9tfmiWtAzQxPzixXhac3cYEno3NuVn0OHk2Q== dependencies: infinity-x "^1.0.0" is-nan-x "^1.0.1" @@ -2812,22 +3261,26 @@ is-finite-x@^3.0.2: is-finite@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + integrity sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko= dependencies: number-is-nan "^1.0.0" is-fullwidth-code-point@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= dependencies: number-is-nan "^1.0.0" is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= is-function-x@^3.2.0, is-function-x@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/is-function-x/-/is-function-x-3.3.0.tgz#7d16bc113853db206d5e40a8b32caf99bd4ff7c0" + integrity sha512-SreSSU1dlgYaXR5c0mm4qJHKYHIiGiEY+7Cd8/aRLLoMP/VvofD2XcWgBnP833ajpU5XzXbUSpfysnfKZLJFlg== dependencies: attempt-x "^1.1.1" has-to-string-tag-x "^1.4.1" @@ -2841,18 +3294,21 @@ is-function-x@^3.2.0, is-function-x@^3.3.0: is-glob@^2.0.0, is-glob@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + integrity sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM= dependencies: is-extglob "^1.0.0" is-glob@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= dependencies: is-extglob "^2.1.0" is-index-x@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-index-x/-/is-index-x-1.1.0.tgz#43dac97b3a04f30191530833f45ac35001682ee2" + integrity sha512-qULKLMepQLGC8rSVdi8uF2vI4LiDrU9XSDg1D+Aa657GIB7GV1jHpga7uXgQvkt/cpQ5mVBHUFTpSehYSqT6+A== dependencies: math-clamp-x "^1.2.0" max-safe-integer "^1.0.1" @@ -2863,6 +3319,7 @@ is-index-x@^1.0.0: is-installed-globally@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.1.0.tgz#0dfd98f5a9111716dd535dda6492f67bf3d25a80" + integrity sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA= dependencies: global-dirs "^0.1.0" is-path-inside "^1.0.0" @@ -2870,10 +3327,12 @@ is-installed-globally@^0.1.0: is-my-ip-valid@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" + integrity sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ== is-my-json-valid@^2.12.0, is-my-json-valid@^2.12.4: version "2.17.2" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz#6b2103a288e94ef3de5cf15d29dd85fc4b78d65c" + integrity sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg== dependencies: generate-function "^2.0.0" generate-object-property "^1.1.0" @@ -2884,10 +3343,12 @@ is-my-json-valid@^2.12.0, is-my-json-valid@^2.12.4: is-nan-x@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-nan-x/-/is-nan-x-1.0.1.tgz#de747ebcc8bddeb66f367c17caca7eba843855c0" + integrity sha512-VfNJgfuT8USqKCYQss8g7sFvCzDnL+OOVMQoXhVoulZAyp0ZTj3oyZaaPrn2dxepAkKSQI2BiKHbBabX1DqVtw== is-nil-x@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/is-nil-x/-/is-nil-x-1.4.1.tgz#bd9e7b08b4cd732f9dcbde13d93291bb2ec2e248" + integrity sha512-cfTKWI5iSR04SSCzzugTH5tS2rYG7kwI8yl/AqWkyuxZ7k55cbA47Y7Lezdg1N9aaELd+UxLg628bdQeNQ6BUw== dependencies: lodash.isnull "^3.0.0" validate.io-undefined "^1.0.3" @@ -2895,34 +3356,41 @@ is-nil-x@^1.4.1: is-npm@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" + integrity sha1-8vtjpl5JBbQGyGBydloaTceTufQ= is-number@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-number/-/is-number-0.1.1.tgz#69a7af116963d47206ec9bd9b48a14216f1e3806" + integrity sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY= is-number@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + integrity sha1-Afy7s5NGOlSPL0ZszhbezknbkI8= dependencies: kind-of "^3.0.2" is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= dependencies: kind-of "^3.0.2" is-number@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff" + integrity sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ== is-obj@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= is-object-like-x@^1.5.1: version "1.6.0" resolved "https://registry.yarnpkg.com/is-object-like-x/-/is-object-like-x-1.6.0.tgz#a8c4a95bd6b95db174e0e4730171a160ec73be82" + integrity sha512-mc3dBMv1jEOdk0f1i2RkJFsZDux0MuHqGwHOoRo770ShUOf4VE6tWThAW8dAZARr9a5RN+iNX1yzMDA5ad1clQ== dependencies: is-function-x "^3.3.0" is-primitive "^2.0.0" @@ -2930,134 +3398,163 @@ is-object-like-x@^1.5.1: is-odd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-2.0.0.tgz#7646624671fd7ea558ccd9a2795182f2958f1b24" + integrity sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ== dependencies: is-number "^4.0.0" is-path-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" + integrity sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0= is-path-in-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc" + integrity sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw= dependencies: is-path-inside "^1.0.0" is-path-inside@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" + integrity sha1-jvW33lBDej/cprToZe96pVy0gDY= dependencies: path-is-inside "^1.0.1" is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== dependencies: isobject "^3.0.1" is-posix-bracket@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + integrity sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q= is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + integrity sha1-IHurkWOEmcB7Kt8kCkGochADRXU= is-promise@^2.1, is-promise@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o= is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + integrity sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ= is-redirect@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" + integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ= is-relative@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-1.0.0.tgz#a1bb6935ce8c5dba1e8b9754b9b2dcc020e2260d" + integrity sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA== dependencies: is-unc-path "^1.0.0" is-retry-allowed@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" + integrity sha1-EaBgVotnM5REAz0BJaYaINVk+zQ= is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= is-string@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.4.tgz#cc3a9b69857d621e963725a24caeec873b826e64" + integrity sha1-zDqbaYV9Yh6WNyWiTK7shzuCbmQ= is-subset@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6" + integrity sha1-ilkRfZMt4d4A8kX83TnOQ/HpOaY= is-symbol@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572" + integrity sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI= is-text-path@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" + integrity sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4= dependencies: text-extensions "^1.0.0" is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= is-unc-path@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-1.0.0.tgz#d731e8898ed090a12c352ad2eaed5095ad322c9d" + integrity sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ== dependencies: unc-path-regex "^0.1.2" is-utf8@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= is-windows@^1.0.1, is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= isbinaryfile@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.2.tgz#4a3e974ec0cba9004d3fc6cde7209ea69368a621" + integrity sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE= isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= dependencies: isarray "1.0.0" isobject@^3.0.0, isobject@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= isstream@~0.1.1, isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= jade@0.26.3: version "0.26.3" resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" + integrity sha1-jxDXl32NefL2/4YqgbBRPMslaGw= dependencies: commander "0.6.1" mkdirp "0.3.0" @@ -3065,10 +3562,12 @@ jade@0.26.3: jasmine-core@^2.9.1, jasmine-core@~2.99.0: version "2.99.1" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15" + integrity sha1-5kAN8ea1bhMLYcS80JPap/boyhU= jasmine@^2.9.1: version "2.99.0" resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.99.0.tgz#8ca72d102e639b867c6489856e0e18a9c7aa42b7" + integrity sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc= dependencies: exit "^0.1.2" glob "^7.0.6" @@ -3077,58 +3576,71 @@ jasmine@^2.9.1: js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" + integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" + integrity sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A= json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + integrity sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM= json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + integrity sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8= dependencies: jsonify "~0.0.0" json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.0, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= json3@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/json3/-/json3-3.3.2.tgz#3c0434743df93e2f5c42aee7b19bcb483575f4e1" + integrity sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE= json5@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= jsonfile@^2.1.0: version "2.4.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" + integrity sha1-NzaitCi4e72gzIO1P6PWM6NcKug= optionalDependencies: graceful-fs "^4.1.6" jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + integrity sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM= jsonparse@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" + integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= jsonpointer@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" + integrity sha1-T9kss04OnbPInIYi7PUfm5eMbLk= jsprim@^1.2.2: version "1.4.1" resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" + integrity sha1-MT5mvB5cwG5Di8G3SZwuXFastqI= dependencies: assert-plus "1.0.0" extsprintf "1.3.0" @@ -3138,6 +3650,7 @@ jsprim@^1.2.2: jszip@^3.1.3: version "3.1.5" resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.1.5.tgz#e3c2a6c6d706ac6e603314036d43cd40beefdf37" + integrity sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ== dependencies: core-js "~2.3.0" es6-promise "~3.0.2" @@ -3148,6 +3661,7 @@ jszip@^3.1.3: karma-chrome-launcher@^0.2.1: version "0.2.3" resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-0.2.3.tgz#4c6d700d163a9d34c618efd87918be49e7a4a8c9" + integrity sha1-TG1wDRY6nTTGGO/YeRi+SeekqMk= dependencies: fs-access "^1.0.0" which "^1.2.1" @@ -3155,20 +3669,24 @@ karma-chrome-launcher@^0.2.1: karma-firefox-launcher@^0.1.4: version "0.1.7" resolved "https://registry.yarnpkg.com/karma-firefox-launcher/-/karma-firefox-launcher-0.1.7.tgz#c05dd86533691e62f31952595098e8bd357d39f3" + integrity sha1-wF3YZTNpHmLzGVJZUJjovTV9OfM= karma-jasmine@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.1.tgz#6fe840e75a11600c9d91e84b33c458e1c46a3529" + integrity sha1-b+hA51oRYAydkehLM8RY4cRqNSk= karma-mocha@^1.2.0: version "1.3.0" resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-1.3.0.tgz#eeaac7ffc0e201eb63c467440d2b69c7cf3778bf" + integrity sha1-7qrH/8DiAetjxGdEDStpx883eL8= dependencies: minimist "1.2.0" karma-phantomjs-launcher@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2" + integrity sha1-0jyjSAG9qYY60xjju0vUBisTrNI= dependencies: lodash "^4.0.1" phantomjs-prebuilt "^2.1.7" @@ -3176,10 +3694,12 @@ karma-phantomjs-launcher@^1.0.4: karma-safari-launcher@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/karma-safari-launcher/-/karma-safari-launcher-0.1.1.tgz#a6380accab60a583fdd624f41b9a3f10fdf41008" + integrity sha1-pjgKzKtgpYP91iT0G5o/EP30EAg= karma-sauce-launcher@^0.2.10: version "0.2.14" resolved "https://registry.yarnpkg.com/karma-sauce-launcher/-/karma-sauce-launcher-0.2.14.tgz#e42e412517c5f40534c8bba7d14bb4f10727b6a7" + integrity sha1-5C5BJRfF9AU0yLun0Uu08Qcntqc= dependencies: q "~0.9.6" sauce-connect-launcher "~0.11.1" @@ -3189,12 +3709,14 @@ karma-sauce-launcher@^0.2.10: karma-sourcemap-loader@^0.3.6: version "0.3.7" resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz#91322c77f8f13d46fed062b042e1009d4c4505d8" + integrity sha1-kTIsd/jxPUb+0GKwQuEAnUxFBdg= dependencies: graceful-fs "^4.1.2" karma@^0.13.14: version "0.13.22" resolved "https://registry.yarnpkg.com/karma/-/karma-0.13.22.tgz#07750b1bd063d7e7e7b91bcd2e6354d8f2aa8744" + integrity sha1-B3ULG9Bj1+fnuRvNLmNU2PKqh0Q= dependencies: batch "^0.5.3" bluebird "^2.9.27" @@ -3223,70 +3745,83 @@ karma@^0.13.14: kew@^0.7.0, kew@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" + integrity sha1-edk9LTM2PW/dKXCzNdkUGtWR15s= kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= dependencies: is-buffer "^1.1.5" kind-of@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= dependencies: is-buffer "^1.1.5" kind-of@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" + integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== klaw@^1.0.0: version "1.3.1" resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" + integrity sha1-QIhDO0azsbolnXh4XY6W9zugJDk= optionalDependencies: graceful-fs "^4.1.9" latest-version@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" + integrity sha1-ogU4P+oyKzO1rjsYq+4NwvNW7hU= dependencies: package-json "^4.0.0" lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" + integrity sha1-odePw6UEdMuAhF07O24dpJpEbo4= lazy-cache@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-2.0.2.tgz#b9190a4f913354694840859f8a8f7084d8822264" + integrity sha1-uRkKT5EzVGlIQIWfio9whNiCImQ= dependencies: set-getter "^0.1.0" lazystream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" + integrity sha1-9plf4PggOS9hOWvolGJAe7dxaOQ= dependencies: readable-stream "^2.0.5" lazystream@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-0.1.0.tgz#1b25d63c772a4c20f0a5ed0a9d77f484b6e16920" + integrity sha1-GyXWPHcqTCDwpe0KnXf0hLbhaSA= dependencies: readable-stream "~1.0.2" lie@~3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + integrity sha1-mkNrLMd0bKWd56QfpGmz77dr2H4= dependencies: immediate "~3.0.5" liftoff@^2.1.0: version "2.5.0" resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.5.0.tgz#2009291bb31cea861bbf10a7c15a28caf75c31ec" + integrity sha1-IAkpG7Mc6oYbvxCnwVooyvdcMew= dependencies: extend "^3.0.0" findup-sync "^2.0.0" @@ -3300,6 +3835,7 @@ liftoff@^2.1.0: load-json-file@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + integrity sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA= dependencies: graceful-fs "^4.1.2" parse-json "^2.2.0" @@ -3310,6 +3846,7 @@ load-json-file@^1.0.0: loader-utils@^0.2.6: version "0.2.17" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" + integrity sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g= dependencies: big.js "^3.1.3" emojis-list "^2.0.0" @@ -3319,6 +3856,7 @@ loader-utils@^0.2.6: lodash._baseassign@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" + integrity sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4= dependencies: lodash._basecopy "^3.0.0" lodash.keys "^3.0.0" @@ -3326,46 +3864,57 @@ lodash._baseassign@^3.0.0: lodash._basecopy@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + integrity sha1-jaDmqHbPNEwK2KVIghEd08XHyjY= lodash._basecreate@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz#1bc661614daa7fc311b7d03bf16806a0213cf821" + integrity sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE= lodash._basetostring@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" + integrity sha1-0YYdh3+CSlL2aYMtyvPuFVZqB9U= lodash._basevalues@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7" + integrity sha1-W3dXYoAr3j0yl1A+JjAIIP32Ybc= lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= lodash._isiterateecall@^3.0.0: version "3.0.9" resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + integrity sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw= lodash._reescape@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._reescape/-/lodash._reescape-3.0.0.tgz#2b1d6f5dfe07c8a355753e5f27fac7f1cde1616a" + integrity sha1-Kx1vXf4HyKNVdT5fJ/rH8c3hYWo= lodash._reevaluate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz#58bc74c40664953ae0b124d806996daca431e2ed" + integrity sha1-WLx0xAZklTrgsSTYBpltrKQx4u0= lodash._reinterpolate@^3.0.0, lodash._reinterpolate@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0= lodash._root@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" + integrity sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI= lodash.create@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/lodash.create/-/lodash.create-3.1.1.tgz#d7f2849f0dbda7e04682bb8cd72ab022461debe7" + integrity sha1-1/KEnw29p+BGgruM1yqwIkYd6+c= dependencies: lodash._baseassign "^3.0.0" lodash._basecreate "^3.0.0" @@ -3374,24 +3923,29 @@ lodash.create@3.1.1: lodash.escape@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-3.2.0.tgz#995ee0dc18c1b48cc92effae71a10aab5b487698" + integrity sha1-mV7g3BjBtIzJLv+ucaEKq1tIdpg= dependencies: lodash._root "^3.0.0" lodash.isarguments@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + integrity sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo= lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + integrity sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U= lodash.isnull@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash.isnull/-/lodash.isnull-3.0.0.tgz#fafbe59ea1dca27eed786534039dd84c2e07c56e" + integrity sha1-+vvlnqHcon7teGU0A53YTC4HxW4= lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + integrity sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo= dependencies: lodash._getnative "^3.0.0" lodash.isarguments "^3.0.0" @@ -3400,10 +3954,12 @@ lodash.keys@^3.0.0: lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= lodash.template@^3.0.0: version "3.6.2" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-3.6.2.tgz#f8cdecc6169a255be9098ae8b0c53d378931d14f" + integrity sha1-+M3sxhaaJVvpCYrosMU9N4kx0U8= dependencies: lodash._basecopy "^3.0.0" lodash._basetostring "^3.0.0" @@ -3418,6 +3974,7 @@ lodash.template@^3.0.0: lodash.template@^4.0.2: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.4.0.tgz#e73a0385c8355591746e020b99679c690e68fba0" + integrity sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A= dependencies: lodash._reinterpolate "~3.0.0" lodash.templatesettings "^4.0.0" @@ -3425,6 +3982,7 @@ lodash.template@^4.0.2: lodash.templatesettings@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz#fb307844753b66b9f1afa54e262c745307dba8e5" + integrity sha1-+zB4RHU7Zrnxr6VOJix0UwfbqOU= dependencies: lodash._reinterpolate "^3.0.0" lodash.escape "^3.0.0" @@ -3432,36 +3990,44 @@ lodash.templatesettings@^3.0.0: lodash.templatesettings@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz#2b4d4e95ba440d915ff08bc899e4553666713316" + integrity sha1-K01OlbpEDZFf8IvImeRVNmZxMxY= dependencies: lodash._reinterpolate "~3.0.0" lodash@3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.5.0.tgz#19bb3f4d51278f0b8c818ed145c74ecf9fe40e6d" + integrity sha1-Gbs/TVEnjwuMgY7RRcdOz5/kDm0= lodash@^3.2.0, lodash@^3.8.0: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y= lodash@^4.0.0, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.8.0, lodash@~4.17.4: version "4.17.5" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" + integrity sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw== lodash@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" + integrity sha1-j1dWDIO1n8JwvT1WG2kAQ0MOJVE= lodash@~3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.2.0.tgz#4bf50a3243f9aeb0bac41a55d3d5990675a462fb" + integrity sha1-S/UKMkP5rrC6xBpV09WZBnWkYvs= lodash@~3.9.3: version "3.9.3" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.9.3.tgz#0159e86832feffc6d61d852b12a953b99496bd32" + integrity sha1-AVnoaDL+/8bWHYUrEqlTuZSWvTI= log4js@^0.6.31: version "0.6.38" resolved "https://registry.yarnpkg.com/log4js/-/log4js-0.6.38.tgz#2c494116695d6fb25480943d3fc872e662a522fd" + integrity sha1-LElBFmldb7JUgJQ9P8hy5mKlIv0= dependencies: readable-stream "~1.0.2" semver "~4.3.3" @@ -3469,14 +4035,17 @@ log4js@^0.6.31: lolex@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" + integrity sha1-fD2mL/yzDw9agKJWbKJORdigHzE= longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" + integrity sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc= loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + integrity sha1-W0b4AUft7leIcPCG0Eghz5mOVR8= dependencies: currently-unhandled "^0.4.1" signal-exit "^3.0.0" @@ -3484,14 +4053,17 @@ loud-rejection@^1.0.0: lowercase-keys@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306" + integrity sha1-TjNms55/VFfjXxMkvfb4jQv8cwY= lru-cache@2, lru-cache@^2.5.0: version "2.7.3" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + integrity sha1-bUUk6LlV+V1PW1iFHOId1y+06VI= lru-cache@4.1.x, lru-cache@^4.0.1: version "4.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" + integrity sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew== dependencies: pseudomap "^1.0.2" yallist "^2.1.2" @@ -3499,48 +4071,57 @@ lru-cache@4.1.x, lru-cache@^4.0.1: lru-queue@0.1: version "0.1.0" resolved "https://registry.yarnpkg.com/lru-queue/-/lru-queue-0.1.0.tgz#2738bd9f0d3cf4f84490c5736c48699ac632cda3" + integrity sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM= dependencies: es5-ext "~0.10.2" make-dir@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.2.0.tgz#6d6a49eead4aae296c53bbf3a1a008bd6c89469b" + integrity sha512-aNUAa4UMg/UougV25bbrU4ZaaKNjJ/3/xnvg/twpmKROPdKZPZ9wGgI0opdZzO8q/zUFawoUuixuOv33eZ61Iw== dependencies: pify "^3.0.0" make-iterator@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/make-iterator/-/make-iterator-1.0.0.tgz#57bef5dc85d23923ba23767324d8e8f8f3d9694b" + integrity sha1-V7713IXSOSO6I3ZzJNjo+PPZaUs= dependencies: kind-of "^3.1.0" map-cache@^0.2.0, map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= map-obj@^1.0.0, map-obj@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= map-stream@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/map-stream/-/map-stream-0.1.0.tgz#e56aa94c4c8055a16404a0674b78f215f7c8e194" + integrity sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ= map-visit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= dependencies: object-visit "^1.0.0" math-clamp-x@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/math-clamp-x/-/math-clamp-x-1.2.0.tgz#8b537be0645bbba7ee73ee16091e7d6018c5edcf" + integrity sha512-tqpjpBcIf9UulApz3EjWXqTZpMlr2vLN9PryC9ghoyCuRmqZaf3JJhPddzgQpJnKLi2QhoFnvKBFtJekAIBSYg== dependencies: to-number-x "^2.0.0" math-sign-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/math-sign-x/-/math-sign-x-3.0.0.tgz#d5286022b48e150c384729a86042e0835264c3ed" + integrity sha512-OzPas41Pn4d16KHnaXmGxxY3/l3zK4OIXtmIwdhgZsxz4FDDcNnbrABYPg2vGfxIkaT9ezGnzDviRH7RfF44jQ== dependencies: is-nan-x "^1.0.1" to-number-x "^2.0.0" @@ -3548,14 +4129,17 @@ math-sign-x@^3.0.0: max-safe-integer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/max-safe-integer/-/max-safe-integer-1.0.1.tgz#f38060be2c563d8c02e6d48af39122fd83b6f410" + integrity sha1-84BgvixWPYwC5tSK85Ei/YO29BA= media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= memoizee@^0.4.3: version "0.4.11" resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.11.tgz#bde9817663c9e40fdb2a4ea1c367296087ae8c8f" + integrity sha1-vemBdmPJ5A/bKk6hw2cpYIeujI8= dependencies: d "1" es5-ext "^0.10.30" @@ -3569,10 +4153,12 @@ memoizee@^0.4.3: memory-fs@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.2.0.tgz#f2bb25368bc121e391c2520de92969caee0a0290" + integrity sha1-8rslNovBIeORwlIN6Slpyu4KApA= meow@^3.3.0: version "3.7.0" resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + integrity sha1-cstmi0JSKCkKu/qFaJJYcwioAfs= dependencies: camelcase-keys "^2.0.0" decamelize "^1.1.2" @@ -3588,12 +4174,14 @@ meow@^3.3.0: merge-stream@^0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-0.1.8.tgz#48a07b3b4a121d74a3edbfdcdb4b08adbf0240b1" + integrity sha1-SKB7O0oSHXSj7b/c20sIrb8CQLE= dependencies: through2 "^0.6.1" micromatch@^2.1.5: version "2.3.11" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + integrity sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU= dependencies: arr-diff "^2.0.0" array-unique "^0.2.1" @@ -3612,6 +4200,7 @@ micromatch@^2.1.5: micromatch@^3.0.4: version "3.1.8" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.8.tgz#5c8caa008de588eebb395e8c0ad12c128f25fff1" + integrity sha512-/XeuOQqYg+B5kwjDWekXseSwGS7CzE0w9Gjo4Cjkf/uFitNh47NrZHAY2vp/oS2YQVfebPIdbEIvgdy+kIcAog== dependencies: arr-diff "^4.0.0" array-unique "^0.3.2" @@ -3630,34 +4219,41 @@ micromatch@^3.0.4: mime-db@~1.12.0: version "1.12.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.12.0.tgz#3d0c63180f458eb10d325aaa37d7c58ae312e9d7" + integrity sha1-PQxjGA9FjrENMlqqN9fFiuMS6dc= mime-db@~1.33.0: version "1.33.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" + integrity sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ== mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.7: version "2.1.18" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" + integrity sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ== dependencies: mime-db "~1.33.0" mime-types@~2.0.1, mime-types@~2.0.3: version "2.0.14" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.0.14.tgz#310e159db23e077f8bb22b748dabfa4957140aa6" + integrity sha1-MQ4VnbI+B3+Lsit0jav6SVcUCqY= dependencies: mime-db "~1.12.0" mime@^1.3.4: version "1.6.0" resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" + integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== minimatch@0.3: version "0.3.0" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.3.0.tgz#275d8edaac4f1bb3326472089e7949c8394699dd" + integrity sha1-J12O2qxPG7MyZHIInnlJyDlGmd0= dependencies: lru-cache "2" sigmund "~1.0.0" @@ -3665,18 +4261,21 @@ minimatch@0.3: "minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.2: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== dependencies: brace-expansion "^1.1.7" minimatch@^2.0.1: version "2.0.10" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" + integrity sha1-jQh8OcazjAAbl/ynzm0OHoCvusc= dependencies: brace-expansion "^1.0.0" minimatch@~0.2.11: version "0.2.14" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" + integrity sha1-x054BXT2PG+aCQ6Q775u9TpqdWo= dependencies: lru-cache "2" sigmund "~1.0.0" @@ -3684,18 +4283,22 @@ minimatch@~0.2.11: minimist@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0= minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" + integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= mixin-deep@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" + integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ== dependencies: for-in "^1.0.2" is-extendable "^1.0.1" @@ -3703,22 +4306,26 @@ mixin-deep@^1.2.0: mkdirp@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" + integrity sha1-G79asbqCevI1dRQ0kEJkVfSB/h4= mkdirp@0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" + integrity sha1-HXMHam35hs2TROFecfzAWkyavxI= dependencies: minimist "0.0.8" mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM= dependencies: minimist "0.0.8" mocha@^2.5.3: version "2.5.3" resolved "https://registry.yarnpkg.com/mocha/-/mocha-2.5.3.tgz#161be5bdeb496771eb9b35745050b622b5aefc58" + integrity sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg= dependencies: commander "2.3.0" debug "2.2.0" @@ -3734,6 +4341,7 @@ mocha@^2.5.3: mocha@^3.1.2: version "3.5.3" resolved "https://registry.yarnpkg.com/mocha/-/mocha-3.5.3.tgz#1e0480fe36d2da5858d1eb6acc38418b26eaa20d" + integrity sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg== dependencies: browser-stdout "1.3.0" commander "2.9.0" @@ -3751,44 +4359,54 @@ mocha@^3.1.2: modify-values@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.0.tgz#e2b6cdeb9ce19f99317a53722f3dbf5df5eaaab2" + integrity sha1-4rbN65zhn5kxelNyLz2/XfXqqrI= moment@^2.11.2: version "2.20.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.20.1.tgz#d6eb1a46cbcc14a2b2f9434112c1ff8907f313fd" + integrity sha512-Yh9y73JRljxW5QxN08Fner68eFLxM5ynNOAw2LbIB1YAGeQzZT8QFSUvkAz609Zf+IHhhaUxqZK8dG3W/+HEvg== ms@0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + integrity sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg= ms@0.7.2: version "0.7.2" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.2.tgz#ae25cf2512b3885a1d95d7f037868d8431124765" + integrity sha1-riXPJRKziFodldfwN4aNhDESR2U= ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= multipipe@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-0.1.2.tgz#2a8f2ddf70eed564dff2d57f1e1a137d9f05078b" + integrity sha1-Ko8t33Du1WTf8tV/HhoTfZ8FB4s= dependencies: duplexer2 "0.0.2" mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" + integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s= nan-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/nan-x/-/nan-x-1.0.0.tgz#0ee78e8d1cd0592d5b4260a5940154545c61c121" + integrity sha512-yw4Fhe2/UTzanQ4f0yHWkRnfTuHZFAi4GZDjXS4G+qv5BqXTqPJBbSxpa7MyyW9v4Y4ZySZQik1vcbNkhdnIOg== nan@^2.3.0: version "2.8.0" resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" + integrity sha1-7XFfP+neArV6XmJS2QqWZ14fCFo= nanomatch@^1.2.9: version "1.2.9" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.9.tgz#879f7150cb2dab7a471259066c104eee6e0fa7c2" + integrity sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA== dependencies: arr-diff "^4.0.0" array-unique "^0.3.2" @@ -3803,25 +4421,30 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -natives@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.1.tgz#011acce1f7cbd87f7ba6b3093d6cd9392be1c574" +natives@^1.1.3: + version "1.1.6" + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" + integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA== negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" + integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= next-tick@1: version "1.0.0" resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" + integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= node-int64@~0.3.0: version "0.3.3" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.3.3.tgz#2d6e6b2ece5de8588b43d88d1bc41b26cd1fa84d" + integrity sha1-LW5rLs5d6FiLQ9iNG8QbJs0fqE0= node-pre-gyp@^0.6.39: version "0.6.39" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" + integrity sha512-OsJV74qxnvz/AMGgcfZoDaeDXKD3oY3QVIbBmwszTFkRisTSXbMQyn4UWzUMOtA5SVhrBZOTp0wcoSBgfMfMmQ== dependencies: detect-libc "^1.0.2" hawk "3.1.3" @@ -3838,18 +4461,22 @@ node-pre-gyp@^0.6.39: node-uuid@~1.4.0, node-uuid@~1.4.7: version "1.4.8" resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" + integrity sha1-sEDrCSOWivq/jTL7HxfxFn/auQc= node-version-compare@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/node-version-compare/-/node-version-compare-1.0.1.tgz#d85bfd20f0acade33577f56682c7109c34c550cd" + integrity sha1-2Fv9IPCsreM1d/VmgscQnDTFUM0= nodejs-websocket@^1.2.0: version "1.7.1" resolved "https://registry.yarnpkg.com/nodejs-websocket/-/nodejs-websocket-1.7.1.tgz#cccfbba823bf1cfa9680f168ab7ab53121e48410" + integrity sha1-zM+7qCO/HPqWgPFoq3q1MSHkhBA= nopt@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.1.tgz#d0d4685afd5415193c8c7505602d0d17cd64474d" + integrity sha1-0NRoWv1UFRk8jHUFYC0NF81kR00= dependencies: abbrev "1" osenv "^0.1.4" @@ -3857,6 +4484,7 @@ nopt@^4.0.1: normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.3.5: version "2.4.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" + integrity sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw== dependencies: hosted-git-info "^2.1.4" is-builtin-module "^1.0.0" @@ -3866,12 +4494,14 @@ normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package- normalize-path@^2.0.0, normalize-path@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= dependencies: remove-trailing-separator "^1.0.1" normalize-space-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-space-x/-/normalize-space-x-3.0.0.tgz#17907d6c7c724a4f9567471cbb319553bc0f8882" + integrity sha512-tbCJerqZCCHPst4rRKgsTanLf45fjOyeAU5zE3mhDxJtFJKt66q39g2XArWhXelgTFVib8mNBUm6Wrd0LxYcfQ== dependencies: cached-constructors-x "^1.0.0" trim-x "^3.0.0" @@ -3880,16 +4510,19 @@ normalize-space-x@^3.0.0: npm-install-package@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/npm-install-package/-/npm-install-package-2.1.0.tgz#d7efe3cfcd7ab00614b896ea53119dc9ab259125" + integrity sha1-1+/jz816sAYUuJbqUxGdyaslkSU= npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= dependencies: path-key "^2.0.0" npmlog@^4.0.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" + integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" @@ -3899,42 +4532,52 @@ npmlog@^4.0.2: null-check@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/null-check/-/null-check-1.0.0.tgz#977dffd7176012b9ec30d2a39db5cf72a0439edd" + integrity sha1-l33/1xdgErnsMNKjnbXPcqBDnt0= number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= oauth-sign@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.6.0.tgz#7dbeae44f6ca454e1f168451d630746735813ce3" + integrity sha1-fb6uRPbKRU4fFoRR1jB0ZzWBPOM= oauth-sign@~0.8.0, oauth-sign@~0.8.1, oauth-sign@~0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + integrity sha1-Rqarfwrq2N6unsBWV4C31O/rnUM= object-assign@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + integrity sha1-ejs9DpgGPUP0wD8uiubNUahog6A= object-assign@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-2.1.1.tgz#43c36e5d569ff8e4816c4efa8be02d26967c18aa" + integrity sha1-Q8NuXVaf+OSBbE76i+AtJpZ8GKo= object-assign@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" + integrity sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I= object-assign@^4.0.1, object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= object-component@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/object-component/-/object-component-0.0.3.tgz#f0c69aa50efc95b866c186f400a33769cb2f1291" + integrity sha1-8MaapQ78lbhmwYb0AKM3acsvEpE= object-copy@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= dependencies: copy-descriptor "^0.1.0" define-property "^0.2.5" @@ -3943,6 +4586,7 @@ object-copy@^0.1.0: object-get-own-property-descriptor-x@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/object-get-own-property-descriptor-x/-/object-get-own-property-descriptor-x-3.2.0.tgz#464585ad03e66108ed166c99325b8d2c5ba93712" + integrity sha512-Z/0fIrptD9YuzN+SNK/1kxAEaBcPQM4gSrtOSMSi9eplnL/AbyQcAyAlreAoAzmBon+DQ1Z+AdhxyQSvav5Fyg== dependencies: attempt-x "^1.1.0" has-own-property-x "^3.1.1" @@ -3958,12 +4602,14 @@ object-get-own-property-descriptor-x@^3.2.0: object-visit@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= dependencies: isobject "^3.0.0" object.defaults@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/object.defaults/-/object.defaults-1.1.0.tgz#3a7f868334b407dea06da16d88d5cd29e435fecf" + integrity sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8= dependencies: array-each "^1.0.1" array-slice "^1.0.0" @@ -3973,6 +4619,7 @@ object.defaults@^1.1.0: object.map@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/object.map/-/object.map-1.0.1.tgz#cf83e59dc8fcc0ad5f4250e1f78b3b81bd801d37" + integrity sha1-z4Plncj8wK1fQlDh94s7gb2AHTc= dependencies: for-own "^1.0.0" make-iterator "^1.0.0" @@ -3980,6 +4627,7 @@ object.map@^1.0.0: object.omit@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + integrity sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo= dependencies: for-own "^0.1.4" is-extendable "^0.1.1" @@ -3987,36 +4635,42 @@ object.omit@^2.0.0: object.pick@^1.2.0, object.pick@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= dependencies: isobject "^3.0.1" on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= dependencies: ee-first "1.1.1" once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= dependencies: wrappy "1" once@~1.3.0: version "1.3.3" resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + integrity sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA= dependencies: wrappy "1" onetime@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + integrity sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ= dependencies: mimic-fn "^1.0.0" optimist@^0.6.1, optimist@~0.6.0, optimist@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686" + integrity sha1-2j6nRob6IaGaERwybpDrFaAZZoY= dependencies: minimist "~0.0.1" wordwrap "~0.0.2" @@ -4024,10 +4678,12 @@ optimist@^0.6.1, optimist@~0.6.0, optimist@~0.6.1: options@>=0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" + integrity sha1-7CLTEoBrtT5zF3Pnza788cZDEo8= orchestrator@^0.3.0: version "0.3.8" resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e" + integrity sha1-FOfp4nZPcxX7rBhOUGx6pt+UrX4= dependencies: end-of-stream "~0.1.5" sequencify "~0.0.7" @@ -4036,18 +4692,22 @@ orchestrator@^0.3.0: ordered-read-streams@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" + integrity sha1-/VZamvjrRHO6abbtijQ1LLVS8SY= os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= os-tmpdir@^1.0.0, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= osenv@^0.1.4: version "0.1.5" resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" + integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== dependencies: os-homedir "^1.0.0" os-tmpdir "^1.0.0" @@ -4055,10 +4715,12 @@ osenv@^0.1.4: p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= package-json@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" + integrity sha1-iGmgQBJTZhxMTKPabCEh7VVfXu0= dependencies: got "^6.7.1" registry-auth-token "^3.0.1" @@ -4068,10 +4730,12 @@ package-json@^4.0.0: pako@~1.0.2: version "1.0.6" resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258" + integrity sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg== parse-filepath@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.2.tgz#a632127f53aaf3d15876f5872f3ffac763d6c891" + integrity sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE= dependencies: is-absolute "^1.0.0" map-cache "^0.2.0" @@ -4080,10 +4744,12 @@ parse-filepath@^1.0.1: parse-github-repo-url@^1.3.0: version "1.4.1" resolved "https://registry.yarnpkg.com/parse-github-repo-url/-/parse-github-repo-url-1.4.1.tgz#9e7d8bb252a6cb6ba42595060b7bf6df3dbc1f50" + integrity sha1-nn2LslKmy2ukJZUGC3v23z28H1A= parse-glob@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + integrity sha1-ssN2z7EfNVE7rdFz7wu246OIORw= dependencies: glob-base "^0.3.0" is-dotfile "^1.0.0" @@ -4093,6 +4759,7 @@ parse-glob@^3.0.4: parse-int-x@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/parse-int-x/-/parse-int-x-2.0.0.tgz#9f979d4115930df2f4706a41810b9c712405552f" + integrity sha512-NIMm52gmd1+0qxJK8lV3OZ4zzWpRH1xcz9xCHXl+DNzddwUdS4NEtd7BmTeK7iCIXoaK5e6BoDMHgieH2eNIhg== dependencies: cached-constructors-x "^1.0.0" nan-x "^1.0.0" @@ -4102,74 +4769,89 @@ parse-int-x@^2.0.0: parse-json@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + integrity sha1-9ID0BDTvgHQfhGkJn43qGPVaTck= dependencies: error-ex "^1.2.0" parse-passwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" + integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= parsejson@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/parsejson/-/parsejson-0.0.3.tgz#ab7e3759f209ece99437973f7d0f1f64ae0e64ab" + integrity sha1-q343WfIJ7OmUN5c/fQ8fZK4OZKs= dependencies: better-assert "~1.0.0" parseqs@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/parseqs/-/parseqs-0.0.5.tgz#d5208a3738e46766e291ba2ea173684921a8b89d" + integrity sha1-1SCKNzjkZ2bikbouoXNoSSGouJ0= dependencies: better-assert "~1.0.0" parseuri@0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/parseuri/-/parseuri-0.0.5.tgz#80204a50d4dbb779bfdc6ebe2778d90e4bce320a" + integrity sha1-gCBKUNTbt3m/3G6+J3jZDkvOMgo= dependencies: better-assert "~1.0.0" parseurl@~1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" + integrity sha1-/CidTtiZMRlGDBViUyYs3I3mW/M= pascalcase@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + integrity sha1-D+tsZPD8UY2adU3V77YscCJ2H0s= dependencies: pinkie-promise "^2.0.0" path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= path-is-inside@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" + integrity sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM= path-key@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + integrity sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME= path-root-regex@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" + integrity sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0= path-root@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7" + integrity sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc= dependencies: path-root-regex "^0.1.0" path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + integrity sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE= dependencies: graceful-fs "^4.1.2" pify "^2.0.0" @@ -4178,24 +4860,29 @@ path-type@^1.0.0: pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" + integrity sha1-/lo0sMvOErWqaitAPuLnO2AvFEU= dependencies: through "~2.3" pend@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" + integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + integrity sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU= performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" + integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= phantomjs-prebuilt@^2.1.7: version "2.1.16" resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" + integrity sha1-79ISpKOWbTZHaE6ouniFSb4q7+8= dependencies: es6-promise "^4.0.3" extract-zip "^1.6.5" @@ -4210,6 +4897,7 @@ phantomjs-prebuilt@^2.1.7: phantomjs@^2.1.7: version "2.1.7" resolved "https://registry.yarnpkg.com/phantomjs/-/phantomjs-2.1.7.tgz#c6910f67935c37285b6114329fc2f27d5f3e3134" + integrity sha1-xpEPZ5NcNyhbYRQyn8LyfV8+MTQ= dependencies: extract-zip "~1.5.0" fs-extra "~0.26.4" @@ -4223,28 +4911,34 @@ phantomjs@^2.1.7: pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + integrity sha1-7RQaasBDqEnqWISY59yosVMw6Qw= pify@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + integrity sha1-ITXW36ejWMBprJsXh3YogihFD/o= dependencies: pinkie "^2.0.0" pinkie@^2.0.0: version "2.0.4" resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + integrity sha1-clVrgM+g1IqXToDnckjoDtT3+HA= pkginfo@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21" + integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE= plugin-error@^1.0.0, plugin-error@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/plugin-error/-/plugin-error-1.0.1.tgz#77016bd8919d0ac377fdcdd0322328953ca5781c" + integrity sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA== dependencies: ansi-colors "^1.0.1" arr-diff "^4.0.0" @@ -4254,34 +4948,42 @@ plugin-error@^1.0.0, plugin-error@^1.0.1: posix-character-classes@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= prepend-http@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" + integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks= pretty-hrtime@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz#b7e3ea42435a4c9b2759d99e0f201eb195802ee1" + integrity sha1-t+PqQkNaTJsnWdmeDyAesZWALuE= process-nextick-args@^1.0.6, process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + integrity sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M= process-nextick-args@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw== progress@^1.1.8, progress@~1.1.8: version "1.1.8" resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" + integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74= promises-aplus-tests@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/promises-aplus-tests/-/promises-aplus-tests-2.1.2.tgz#76b7c5638968720861969cfbcd8795afd274885c" + integrity sha1-drfFY4locghhlpz7zYeVr9J0iFw= dependencies: mocha "^2.5.3" sinon "^1.10.3" @@ -4290,6 +4992,7 @@ promises-aplus-tests@^2.1.2: property-is-enumerable-x@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/property-is-enumerable-x/-/property-is-enumerable-x-1.1.0.tgz#7ca48917476cd0914b37809bfd05776a0d942f6f" + integrity sha512-22cKy3w3OpRswU6to9iKWDDlg+F9vF2REcwGlGW23jyLjHb1U/jJEWA44sWupOnkhGfDgotU6Lw+N2oyhNi+5A== dependencies: to-object-x "^1.4.1" to-property-key-x "^2.0.1" @@ -4297,10 +5000,12 @@ property-is-enumerable-x@^1.1.0: pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" + integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= pump@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/pump/-/pump-1.0.3.tgz#5dfe8311c33bbf6fc18261f9f34702c47c08a954" + integrity sha512-8k0JupWme55+9tCVE+FS5ULT3K6AbgqrGa58lTT49RpyfwwcGedHqaC5LlQNdEAumn/wFsu6aPwkuPMioy8kqw== dependencies: end-of-stream "^1.1.0" once "^1.3.1" @@ -4308,46 +5013,57 @@ pump@^1.0.1: punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= q@^1.4.1, q@~1.5.0: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" + integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= q@~0.9.6: version "0.9.7" resolved "https://registry.yarnpkg.com/q/-/q-0.9.7.tgz#4de2e6cb3b29088c9e4cbc03bf9d42fb96ce2f75" + integrity sha1-TeLmyzspCIyeTLwDv51C+5bOL3U= q@~1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e" + integrity sha1-VXBbzZPF82c1MMLCy8DCs63cKG4= qs@6.5.1, qs@~6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" + integrity sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A== qs@~2.4.0: version "2.4.2" resolved "https://registry.yarnpkg.com/qs/-/qs-2.4.2.tgz#f7ce788e5777df0b5010da7f7c4e73ba32470f5a" + integrity sha1-9854jld33wtQENp/fE5zujJHD1o= qs@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.1.tgz#801fee030e0b9450d6385adc48a4cc55b44aedfc" + integrity sha1-gB/uAw4LlFDWOFrcSKTMVbRK7fw= qs@~6.4.0: version "6.4.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + integrity sha1-E+JtKK1rD/qpExLNO/cI7TUecjM= querystring@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= randomatic@^1.1.3: version "1.1.7" resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" + integrity sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how== dependencies: is-number "^3.0.0" kind-of "^4.0.0" @@ -4355,6 +5071,7 @@ randomatic@^1.1.3: raw-body@2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" + integrity sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k= dependencies: bytes "3.0.0" http-errors "1.6.2" @@ -4364,6 +5081,7 @@ raw-body@2.3.2: rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: version "1.2.5" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.5.tgz#275cd687f6e3b36cc756baa26dfee80a790301fd" + integrity sha1-J1zWh/bjs2zHVrqibf7oCnkDAf0= dependencies: deep-extend "~0.4.0" ini "~1.3.0" @@ -4373,6 +5091,7 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + integrity sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI= dependencies: find-up "^1.0.0" read-pkg "^1.0.0" @@ -4380,6 +5099,7 @@ read-pkg-up@^1.0.1: read-pkg@^1.0.0, read-pkg@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + integrity sha1-9f+qXs0pyzHAR0vKfXVra7KePyg= dependencies: load-json-file "^1.0.0" normalize-package-data "^2.3.2" @@ -4388,6 +5108,7 @@ read-pkg@^1.0.0, read-pkg@^1.1.0: "readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.2, readable-stream@~1.0.24, readable-stream@~1.0.26, readable-stream@~1.0.33: version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= dependencies: core-util-is "~1.0.0" inherits "~2.0.1" @@ -4397,6 +5118,7 @@ read-pkg@^1.0.0, read-pkg@^1.1.0: readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3: version "2.3.4" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.4.tgz#c946c3f47fa7d8eabc0b6150f4a12f69a4574071" + integrity sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ== dependencies: core-util-is "~1.0.0" inherits "~2.0.3" @@ -4409,6 +5131,7 @@ readable-stream@^2.0.0, readable-stream@^2.0.2, readable-stream@^2.0.5, readable readable-stream@~1.1.9: version "1.1.14" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha1-fPTFTvZI44EwhMY23SB54WbAgdk= dependencies: core-util-is "~1.0.0" inherits "~2.0.1" @@ -4418,6 +5141,7 @@ readable-stream@~1.1.9: readable-stream@~2.0.0, readable-stream@~2.0.5, readable-stream@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" + integrity sha1-j5A0HmilPMySh4jaz80Rs265t44= dependencies: core-util-is "~1.0.0" inherits "~2.0.1" @@ -4429,6 +5153,7 @@ readable-stream@~2.0.0, readable-stream@~2.0.5, readable-stream@~2.0.6: readdirp@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + integrity sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg= dependencies: graceful-fs "^4.1.2" minimatch "^3.0.2" @@ -4438,12 +5163,14 @@ readdirp@^2.0.0: rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + integrity sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q= dependencies: resolve "^1.1.6" redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + integrity sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94= dependencies: indent-string "^2.1.0" strip-indent "^1.0.1" @@ -4451,16 +5178,19 @@ redent@^1.0.0: regenerator-runtime@^0.11.0: version "0.11.1" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== regex-cache@^0.4.2: version "0.4.4" resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" + integrity sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ== dependencies: is-equal-shallow "^0.1.3" regex-not@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== dependencies: extend-shallow "^3.0.2" safe-regex "^1.1.0" @@ -4468,6 +5198,7 @@ regex-not@^1.0.0: registry-auth-token@^3.0.1: version "3.3.2" resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.2.tgz#851fd49038eecb586911115af845260eec983f20" + integrity sha512-JL39c60XlzCVgNrO+qq68FoNb56w/m7JYvGR2jT5iR1xBrUA3Mfx5Twk5rqTThPmQKMWydGmq8oFtDlxfrmxnQ== dependencies: rc "^1.1.6" safe-buffer "^5.0.1" @@ -4475,34 +5206,41 @@ registry-auth-token@^3.0.1: registry-url@^3.0.3: version "3.1.0" resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-3.1.0.tgz#3d4ef870f73dde1d77f0cf9a381432444e174942" + integrity sha1-PU74cPc93h138M+aOBQyRE4XSUI= dependencies: rc "^1.0.1" remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= repeat-element@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + integrity sha1-7wiaF40Ug7quTZPrmLT55OEdmQo= repeat-string@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-0.2.2.tgz#c7a8d3236068362059a7e4651fc6884e8b1fb4ae" + integrity sha1-x6jTI2BoNiBZp+RlH8aITosftK4= repeat-string@^1.5.2, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= repeating@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= dependencies: is-finite "^1.0.0" replace-comments-x@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/replace-comments-x/-/replace-comments-x-2.0.0.tgz#a5cec18efd912aad78a7c3c4b69d01768556d140" + integrity sha512-+vMP4jqU+8HboLWms6YMNEiaZG5hh1oR6ENCnGYDF/UQ7aYiJUK/8tcl3+KZAHRCKKa3gqzrfiarlUBHQSgRlg== dependencies: require-coercible-to-string-x "^1.0.0" to-string-x "^1.4.2" @@ -4510,20 +5248,24 @@ replace-comments-x@^2.0.0: replace-ext@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" + integrity sha1-KbvZIHinOfC8zitO5B6DeVNSKSQ= replace-ext@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" + integrity sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= request-progress@^2.0.1, request-progress@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08" + integrity sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg= dependencies: throttleit "^1.0.0" request@2.81.0: version "2.81.0" resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + integrity sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA= dependencies: aws-sign2 "~0.6.0" aws4 "^1.2.1" @@ -4551,6 +5293,7 @@ request@2.81.0: request@^2.78.0, request@^2.81.0, request@~2.83.0: version "2.83.0" resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" + integrity sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw== dependencies: aws-sign2 "~0.7.0" aws4 "^1.6.0" @@ -4578,6 +5321,7 @@ request@^2.78.0, request@^2.81.0, request@~2.83.0: request@~2.55.0: version "2.55.0" resolved "https://registry.yarnpkg.com/request/-/request-2.55.0.tgz#d75c1cdf679d76bb100f9bffe1fe551b5c24e93d" + integrity sha1-11wc32eddrsQD5v/4f5VG1wk6T0= dependencies: aws-sign2 "~0.5.0" bl "~0.9.0" @@ -4601,6 +5345,7 @@ request@~2.55.0: request@~2.67.0: version "2.67.0" resolved "https://registry.yarnpkg.com/request/-/request-2.67.0.tgz#8af74780e2bf11ea0ae9aa965c11f11afd272742" + integrity sha1-ivdHgOK/EeoK6aqWXBHxGv0nJ0I= dependencies: aws-sign2 "~0.6.0" bl "~1.0.0" @@ -4626,6 +5371,7 @@ request@~2.67.0: require-coercible-to-string-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/require-coercible-to-string-x/-/require-coercible-to-string-x-1.0.0.tgz#367b3e9ca67e00324c411b0b498453a74cd5569e" + integrity sha512-Rpfd4sMdflPAKecdKhfAtQHlZzzle4UMUgxJ01hXtTcNWMV8w9GeZnKhEyrT73kgrflBOP1zg41amUPZGcNspA== dependencies: require-object-coercible-x "^1.4.1" to-string-x "^1.4.2" @@ -4633,16 +5379,19 @@ require-coercible-to-string-x@^1.0.0: require-object-coercible-x@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/require-object-coercible-x/-/require-object-coercible-x-1.4.1.tgz#75b9fb5bda2d15cf705a5714f108e8b40ca3eb2e" + integrity sha512-0YHa2afepsLfQvwQ1P2XvDZnGOUia5sC07ZijIRU2dnsRxnuilXWF6B2CFaKGDA9eZl39lJHrXCDsnfgroRd6Q== dependencies: is-nil-x "^1.4.1" requires-port@1.x.x: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= resolve-dir@^1.0.0, resolve-dir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-1.0.1.tgz#79a40644c362be82f26effe739c9bb5382046f43" + integrity sha1-eaQGRMNivoLybv/nOcm7U4IEb0M= dependencies: expand-tilde "^2.0.0" global-modules "^1.0.0" @@ -4650,16 +5399,19 @@ resolve-dir@^1.0.0, resolve-dir@^1.0.1: resolve-url@^0.2.1, resolve-url@~0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= resolve@^1.0.0, resolve@^1.1.6, resolve@^1.1.7: version "1.5.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" + integrity sha512-hgoSGrc3pjzAPHNBg+KnFcK2HwlHTs/YrAGUr6qgTVUZmXv1UEXXl0bZNBKMA9fud6lRYFdPGz0xXxycPzmmiw== dependencies: path-parse "^1.0.5" restore-cursor@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" + integrity sha1-n37ih/gv0ybU/RYpI9YhKe7g368= dependencies: onetime "^2.0.0" signal-exit "^3.0.2" @@ -4667,86 +5419,104 @@ restore-cursor@^2.0.0: ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== rgb2hex@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/rgb2hex/-/rgb2hex-0.1.0.tgz#ccd55f860ae0c5c4ea37504b958e442d8d12325b" + integrity sha1-zNVfhgrgxcTqN1BLlY5ELY0SMls= right-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef" + integrity sha1-YTObci/mo1FWiSENJOFMlhSGE+8= dependencies: align-text "^0.1.1" rimraf@2, rimraf@^2.2.6, rimraf@^2.2.8, rimraf@^2.3.3, rimraf@^2.5.1, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1: version "2.6.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" + integrity sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w== dependencies: glob "^7.0.5" rimraf@2.2.6: version "2.2.6" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.6.tgz#c59597569b14d956ad29cacc42bdddf5f0ea4f4c" + integrity sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w= rimraf@~2.2.6: version "2.2.8" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" + integrity sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI= rollup-plugin-hypothetical@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/rollup-plugin-hypothetical/-/rollup-plugin-hypothetical-2.1.0.tgz#7fec9a865ed7d0eac14ca6ee2b2c4088acdb1955" + integrity sha512-MlxPQTkMtiRUtyhIJ7FpBvTzWtar8eFBA+V7/J6Deg9fSgIIHwL6bJKK1Wl1uWSWtOrWhOmtsMwb9F6aagP/Pg== rollup@^0.54.1: version "0.54.1" resolved "https://registry.yarnpkg.com/rollup/-/rollup-0.54.1.tgz#415a5d999421502646cf54b873fc4ce1a7393970" + integrity sha512-ebUUgUQ7K/sLn67CtO8Jj8H3RgKAoVWrpiJA7enOkwZPZzTCl8GC8CZ00g5jowjX80KgBmzs4Z1MV6cgglT86A== run-async@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" + integrity sha1-A3GrSuC91yDUFm19/aZP96RFpsA= dependencies: is-promise "^2.1.0" rx-lite-aggregates@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + integrity sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74= dependencies: rx-lite "*" rx-lite@*, rx-lite@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" + integrity sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ= rx@2.3.24: version "2.3.24" resolved "https://registry.yarnpkg.com/rx/-/rx-2.3.24.tgz#14f950a4217d7e35daa71bbcbe58eff68ea4b2b7" + integrity sha1-FPlQpCF9fjXapxu8vljv9o6ksrc= rxjs@^6.2.1: version "6.2.2" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.2.2.tgz#eb75fa3c186ff5289907d06483a77884586e1cf9" + integrity sha512-0MI8+mkKAXZUF9vMrEoPnaoHkfzBPP4IGwUYRJhIRJF6/w3uByO1e91bEHn8zd43RdkTMKiooYKmwz7RH6zfOQ== dependencies: tslib "^1.9.0" safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" + integrity sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg== safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= dependencies: ret "~0.1.10" samsam@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" + integrity sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc= samsam@~1.1: version "1.1.3" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.3.tgz#9f5087419b4d091f232571e7fa52e90b0f552621" + integrity sha1-n1CHQZtNCR8jJXHn+lLpCw9VJiE= sauce-connect-launcher@~0.11.1: version "0.11.1" resolved "https://registry.yarnpkg.com/sauce-connect-launcher/-/sauce-connect-launcher-0.11.1.tgz#65f51d8891249fdabaaf17599734de1902476129" + integrity sha1-ZfUdiJEkn9q6rxdZlzTeGQJHYSk= dependencies: adm-zip "~0.4.3" async "0.9.0" @@ -4756,14 +5526,17 @@ sauce-connect-launcher@~0.11.1: saucelabs@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-0.1.1.tgz#5e0ea1cf3d735d6ea15fde94b5bda6bc15d2c06d" + integrity sha1-Xg6hzz1zXW6hX96Utb2mvBXSwG0= sax@>=0.6.0: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" + integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== selenium-webdriver@^3.4.0: version "3.6.0" resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-3.6.0.tgz#2ba87a1662c020b8988c981ae62cb2a01298eafc" + integrity sha512-WH7Aldse+2P5bbFBO4Gle/nuQOdVwpHMTL6raL3uuBj/vPG07k6uzt3aiahu352ONBr5xXh0hDlM3LhtXPOC4Q== dependencies: jszip "^3.1.3" rimraf "^2.5.4" @@ -4773,38 +5546,46 @@ selenium-webdriver@^3.4.0: semver-diff@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" + integrity sha1-S7uEN8jTfksM8aaP1ybsbWRdbTY= dependencies: semver "^5.0.3" "semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.0.3, semver@^5.1.0, semver@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA== semver@^4.1.0, semver@~4.3.3: version "4.3.6" resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" + integrity sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto= sequencify@~0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" + integrity sha1-kM/xnQLgcCf9dn9erT57ldHnOAw= set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= set-getter@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/set-getter/-/set-getter-0.1.0.tgz#d769c182c9d5a51f409145f2fba82e5e86e80376" + integrity sha1-12nBgsnVpR9AkUXy+6guXoboA3Y= dependencies: to-object-path "^0.3.0" set-immediate-shim@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + integrity sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E= set-value@^0.4.3: version "0.4.3" resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" + integrity sha1-fbCPnT0i3H945Trzw79GZuzfzPE= dependencies: extend-shallow "^2.0.1" is-extendable "^0.1.1" @@ -4814,6 +5595,7 @@ set-value@^0.4.3: set-value@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" + integrity sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg== dependencies: extend-shallow "^2.0.1" is-extendable "^0.1.1" @@ -4823,28 +5605,34 @@ set-value@^2.0.0: setprototypeof@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" + integrity sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ= shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= dependencies: shebang-regex "^1.0.0" shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= sigmund@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + integrity sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA= signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" + integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= sinon@^1.10.3: version "1.17.7" resolved "https://registry.yarnpkg.com/sinon/-/sinon-1.17.7.tgz#4542a4f49ba0c45c05eb2e9dd9d203e2b8efe0bf" + integrity sha1-RUKk9JugxFwF6y6d2dID4rjv4L8= dependencies: formatio "1.1.1" lolex "1.3.2" @@ -4854,6 +5642,7 @@ sinon@^1.10.3: snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== dependencies: define-property "^1.0.0" isobject "^3.0.0" @@ -4862,12 +5651,14 @@ snapdragon-node@^2.0.1: snapdragon-util@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== dependencies: kind-of "^3.2.0" snapdragon@^0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.1.tgz#e12b5487faded3e3dea0ac91e9400bf75b401370" + integrity sha1-4StUh/re0+PeoKyR6UAL91tAE3A= dependencies: base "^0.11.1" debug "^2.2.0" @@ -4881,18 +5672,21 @@ snapdragon@^0.8.1: sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + integrity sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg= dependencies: hoek "2.x.x" sntp@2.x.x: version "2.1.0" resolved "https://registry.yarnpkg.com/sntp/-/sntp-2.1.0.tgz#2c6cec14fedc2222739caf9b5c3d85d1cc5a2cc8" + integrity sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg== dependencies: hoek "4.x.x" socket.io-adapter@0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-0.5.0.tgz#cb6d4bb8bec81e1078b99677f9ced0046066bb8b" + integrity sha1-y21LuL7IHhB4uZZ3+c7QBGBmu4s= dependencies: debug "2.3.3" socket.io-parser "2.3.1" @@ -4900,6 +5694,7 @@ socket.io-adapter@0.5.0: socket.io-client@1.7.4: version "1.7.4" resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.4.tgz#ec9f820356ed99ef6d357f0756d648717bdd4281" + integrity sha1-7J+CA1btme9tNX8HVtZIcXvdQoE= dependencies: backo2 "1.0.2" component-bind "1.0.0" @@ -4916,6 +5711,7 @@ socket.io-client@1.7.4: socket.io-parser@2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-2.3.1.tgz#dd532025103ce429697326befd64005fcfe5b4a0" + integrity sha1-3VMgJRA85Clpcya+/WQAX8/ltKA= dependencies: component-emitter "1.1.2" debug "2.2.0" @@ -4925,6 +5721,7 @@ socket.io-parser@2.3.1: socket.io@^1.4.5: version "1.7.4" resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.4.tgz#2f7ecedc3391bf2d5c73e291fe233e6e34d4dd00" + integrity sha1-L37O3DORvy1cc+KR/iM+bjTU3QA= dependencies: debug "2.3.3" engine.io "~1.8.4" @@ -4937,6 +5734,7 @@ socket.io@^1.4.5: source-map-resolve@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.3.1.tgz#610f6122a445b8dd51535a2a71b783dfc1248761" + integrity sha1-YQ9hIqRFuN1RU1oqcbeD38Ekh2E= dependencies: atob "~1.1.0" resolve-url "~0.2.1" @@ -4946,6 +5744,7 @@ source-map-resolve@^0.3.0: source-map-resolve@^0.5.0: version "0.5.1" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.1.tgz#7ad0f593f2281598e854df80f19aae4b92d7a11a" + integrity sha512-0KW2wvzfxm8NCTb30z0LMNyPqWCdDGE2viwzUaucqJdkTRXtZiSY3I+2A6nVAjmdOy0I4gU8DwnVVGsk9jvP2A== dependencies: atob "^2.0.0" decode-uri-component "^0.2.0" @@ -4956,72 +5755,86 @@ source-map-resolve@^0.5.0: source-map-url@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= source-map-url@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.3.0.tgz#7ecaf13b57bcd09da8a40c5d269db33799d4aaf9" + integrity sha1-fsrxO1e80J2opAxdJp2zN5nUqvk= source-map@^0.1.38: version "0.1.43" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.43.tgz#c24bc146ca517c1471f5dacbe2571b2b7f9e3346" + integrity sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y= dependencies: amdefine ">=0.0.4" source-map@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" + integrity sha1-66T12pwNyZneaAMti092FzZSA2s= dependencies: amdefine ">=0.0.4" source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= sparkles@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" + integrity sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM= spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + integrity sha1-SzBz2TP/UfORLwOsVRlJikFQ20A= dependencies: spdx-license-ids "^1.0.2" spdx-expression-parse@~1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + integrity sha1-m98vIOH0DtRH++JzJmGR/O1RYmw= spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + integrity sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc= split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== dependencies: extend-shallow "^3.0.0" split2@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/split2/-/split2-2.2.0.tgz#186b2575bcf83e85b7d18465756238ee4ee42493" + integrity sha512-RAb22TG39LhI31MbreBgIuKiIKhVsawfTgEGqKHTK87aG+ul/PB8Sqoi3I7kVdRWiCfrKxK3uo4/YUkpNvhPbw== dependencies: through2 "^2.0.2" split@0.3: version "0.3.3" resolved "https://registry.yarnpkg.com/split/-/split-0.3.3.tgz#cd0eea5e63a211dfff7eb0f091c4133e2d0dd28f" + integrity sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8= dependencies: through "2" split@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/split/-/split-1.0.1.tgz#605bd9be303aa59fb35f9229fbea0ddec9ea07d9" + integrity sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg== dependencies: through "2" sshpk@^1.7.0: version "1.13.1" resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" + integrity sha1-US322mKHFEMW3EwY/hzx2UBzm+M= dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -5036,6 +5849,7 @@ sshpk@^1.7.0: static-extend@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= dependencies: define-property "^0.2.5" object-copy "^0.1.0" @@ -5043,14 +5857,17 @@ static-extend@^0.1.1: "statuses@>= 1.3.1 < 2": version "1.4.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" + integrity sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew== statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" + integrity sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4= stream-combiner2@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.1.1.tgz#fb4d8a1420ea362764e21ad4780397bebcb41cbe" + integrity sha1-+02KFCDqNidk4hrUeAOXvry0HL4= dependencies: duplexer2 "~0.1.0" readable-stream "^2.0.2" @@ -5058,24 +5875,29 @@ stream-combiner2@^1.1.1: stream-combiner@~0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/stream-combiner/-/stream-combiner-0.0.4.tgz#4d5e433c185261dde623ca3f44c586bcf5c4ad14" + integrity sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ= dependencies: duplexer "~0.1.1" stream-consume@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.1.tgz#d3bdb598c2bd0ae82b8cac7ac50b1107a7996c48" + integrity sha512-tNa3hzgkjEP7XbCkbRXe1jpg+ievoa0O4SCFlMOYEscGSS4JJsckGL8swUyAa/ApGU3Ae4t6Honor4HhL+tRyg== stream-equal@0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/stream-equal/-/stream-equal-0.1.6.tgz#cc522fab38516012e4d4ee47513b147b72359019" + integrity sha1-zFIvqzhRYBLk1O5HUTsUe3I1kBk= stream-shift@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" + integrity sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI= string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= dependencies: code-point-at "^1.0.0" is-fullwidth-code-point "^1.0.0" @@ -5084,6 +5906,7 @@ string-width@^1.0.1, string-width@^1.0.2: string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" + integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== dependencies: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" @@ -5091,38 +5914,45 @@ string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= string_decoder@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" + integrity sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ== dependencies: safe-buffer "~5.1.0" stringstream@~0.0.4, stringstream@~0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + integrity sha1-TkhM1N5aC7vuGORjB3EKioFiGHg= strip-ansi@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-0.3.0.tgz#25f48ea22ca79187f3174a4db8759347bb126220" + integrity sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA= dependencies: ansi-regex "^0.2.1" strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= dependencies: ansi-regex "^2.0.0" strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= dependencies: ansi-regex "^3.0.0" strip-bom@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" + integrity sha1-hbiGLzhEtabV7IRnqTWYFzo295Q= dependencies: first-chunk-stream "^1.0.0" is-utf8 "^0.2.0" @@ -5130,66 +5960,79 @@ strip-bom@^1.0.0: strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + integrity sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4= dependencies: is-utf8 "^0.2.0" strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= strip-indent@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + integrity sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI= dependencies: get-stdin "^4.0.1" strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= supports-color@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-1.2.0.tgz#ff1ed1e61169d06b3cf2d588e188b18d8847e17e" + integrity sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4= supports-color@3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + integrity sha1-cqJiiU2dQIuVbKBf83su2KbiotU= dependencies: has-flag "^1.0.0" supports-color@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-0.2.0.tgz#d92de2694eb3f67323973d7ae3d8b55b4c22190a" + integrity sha1-2S3iaU6z9nMjlz1649i1W0wiGQo= supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= supports-color@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.2.0.tgz#b0d5333b1184dd3666cbe5aa0b45c5ac7ac17a4a" + integrity sha512-F39vS48la4YvTZUPVeTqsjsFNrvcMwrV3RLZINsmHo+7djCvuUzSIeXOnZ5hmjef4bajL1dNccN+tg5XAliO5Q== dependencies: has-flag "^3.0.0" supports-color@~5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.0.1.tgz#1c5331f22250c84202805b2f17adf16699f3a39a" + integrity sha512-7FQGOlSQ+AQxBNXJpVDj8efTA/FtyB5wcNE1omXXJ0cq6jm1jjDwuROlYDbnzHqdNPqliWFhcioCWSyav+xBnA== dependencies: has-flag "^2.0.0" systemjs@^0.19.37: version "0.19.47" resolved "https://registry.yarnpkg.com/systemjs/-/systemjs-0.19.47.tgz#c8c93937180f3f5481c769cd2720763fb4a31c6f" + integrity sha1-yMk5NxgPP1SBx2nNJyB2P7SjHG8= dependencies: when "^3.7.5" tapable@^0.1.8: version "0.1.10" resolved "https://registry.yarnpkg.com/tapable/-/tapable-0.1.10.tgz#29c35707c2b70e50d07482b5d202e8ed446dafd4" + integrity sha1-KcNXB8K3DlDQdIK10gLo7URtr9Q= tar-pack@^3.4.0: version "3.4.1" resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" + integrity sha512-PPRybI9+jM5tjtCbN2cxmmRU7YmqT3Zv/UDy48tAh2XRkLa9bAORtSWLkVc13+GJF+cdTh1yEnHEk3cpTaL5Kg== dependencies: debug "^2.2.0" fstream "^1.0.10" @@ -5203,6 +6046,7 @@ tar-pack@^3.4.0: tar-stream@^1.5.0: version "1.5.5" resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.5.5.tgz#5cad84779f45c83b1f2508d96b09d88c7218af55" + integrity sha512-mQdgLPc/Vjfr3VWqWbfxW8yQNiJCbAZ+Gf6GDu1Cy0bdb33ofyiNGBtAY96jHFhDuivCwgW1H9DgTON+INiXgg== dependencies: bl "^1.0.0" end-of-stream "^1.0.0" @@ -5212,6 +6056,7 @@ tar-stream@^1.5.0: tar-stream@~1.1.0: version "1.1.5" resolved "https://registry.yarnpkg.com/tar-stream/-/tar-stream-1.1.5.tgz#be9218c130c20029e107b0f967fb23de0579d13c" + integrity sha1-vpIYwTDCACnhB7D5Z/sj3gV50Tw= dependencies: bl "^0.9.0" end-of-stream "^1.0.0" @@ -5221,6 +6066,7 @@ tar-stream@~1.1.0: tar@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + integrity sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE= dependencies: block-stream "*" fstream "^1.0.2" @@ -5229,6 +6075,7 @@ tar@^2.2.1: temp@^0.8.1: version "0.8.3" resolved "https://registry.yarnpkg.com/temp/-/temp-0.8.3.tgz#e0c6bc4d26b903124410e4fed81103014dfc1f59" + integrity sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k= dependencies: os-tmpdir "^1.0.0" rimraf "~2.2.6" @@ -5236,20 +6083,24 @@ temp@^0.8.1: term-size@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/term-size/-/term-size-1.2.0.tgz#458b83887f288fc56d6fffbfad262e26638efa69" + integrity sha1-RYuDiH8oj8Vtb/+/rSYuJmOO+mk= dependencies: execa "^0.7.0" text-extensions@^1.0.0: version "1.7.0" resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39" + integrity sha512-AKXZeDq230UaSzaO5s3qQUZOaC7iKbzq0jOFL614R7d9R593HLqAOL0cYoqLdkNrjBSOdmoQI06yigq1TSBXAg== throttleit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" + integrity sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw= through2-filter@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec" + integrity sha1-YLxVoNrLdghdsfna6Zq0P4PWIuw= dependencies: through2 "~2.0.0" xtend "~4.0.0" @@ -5257,6 +6108,7 @@ through2-filter@^2.0.0: through2@^0.6.1, through2@^0.6.3: version "0.6.5" resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + integrity sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg= dependencies: readable-stream ">=1.0.33-1 <1.1.0-0" xtend ">=4.0.0 <4.1.0-0" @@ -5264,6 +6116,7 @@ through2@^0.6.1, through2@^0.6.3: through2@^2.0.0, through2@^2.0.1, through2@^2.0.2, through2@~2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" + integrity sha1-AARWmzfHx0ujnEPzzteNGtlBQL4= dependencies: readable-stream "^2.1.5" xtend "~4.0.1" @@ -5271,24 +6124,29 @@ through2@^2.0.0, through2@^2.0.1, through2@^2.0.2, through2@~2.0.0: through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3, through@~2.3.1, through@~2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= tildify@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" + integrity sha1-3OwD9V3Km3qj5bBPIYF+tW5jWIo= dependencies: os-homedir "^1.0.0" time-stamp@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.1.0.tgz#764a5a11af50561921b133f3b44e618687e0f5c3" + integrity sha1-dkpaEa9QVhkhsTPztE5hhofg9cM= timed-out@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" + integrity sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8= timers-ext@0.1, timers-ext@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.2.tgz#61cc47a76c1abd3195f14527f978d58ae94c5204" + integrity sha1-YcxHp2wavTGV8UUn+XjViulMUgQ= dependencies: es5-ext "~0.10.14" next-tick "1" @@ -5296,26 +6154,31 @@ timers-ext@0.1, timers-ext@^0.1.2: tmp@0.0.30: version "0.0.30" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.30.tgz#72419d4a8be7d6ce75148fd8b324e593a711c2ed" + integrity sha1-ckGdSovn1s51FI/YsyTlk6cRwu0= dependencies: os-tmpdir "~1.0.1" tmp@0.0.x, tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== dependencies: os-tmpdir "~1.0.2" to-array@0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/to-array/-/to-array-0.1.4.tgz#17e6c11f73dd4f3d74cda7a4ff3238e9ad9bf890" + integrity sha1-F+bBH3PdTz10zaek/zI46a2b+JA= to-boolean-x@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/to-boolean-x/-/to-boolean-x-1.0.1.tgz#724128dacc5bea75a93ad471be7ee9277561b2c1" + integrity sha512-PstxY3K6hVEHnY3FITs8XBoJbt0RI1e4MLIhAL9hWa3BtVLCrb86vU5z6lEKh7uZZjiPiLqIKMmfMro1nNgtXQ== to-integer-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/to-integer-x/-/to-integer-x-3.0.0.tgz#9f3b80e668c7f0ae45e6926b40d95f52c1addc74" + integrity sha512-794L2Lpwjtynm7RxahJi2YdbRY75gTxUW27TMuN26UgwPkmJb/+HPhkFEFbz+E4vNoiP0dxq5tq5fkXoXLaK/w== dependencies: is-finite-x "^3.0.2" is-nan-x "^1.0.1" @@ -5325,10 +6188,12 @@ to-integer-x@^3.0.0: to-iso-string@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/to-iso-string/-/to-iso-string-0.0.2.tgz#4dc19e664dfccbe25bd8db508b00c6da158255d1" + integrity sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE= to-number-x@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-number-x/-/to-number-x-2.0.0.tgz#c9099d7ded8fd327132a2987df2dcc8baf36df4d" + integrity sha512-lGOnCoccUoSzjZ/9Uen8TC4+VFaQcFGhTroWTv2tYWxXgyJV1zqAZ8hEIMkez/Eo790fBMOjidTnQ/OJSCvAoQ== dependencies: cached-constructors-x "^1.0.0" nan-x "^1.0.0" @@ -5339,12 +6204,14 @@ to-number-x@^2.0.0: to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= dependencies: kind-of "^3.0.2" to-object-x@^1.4.1, to-object-x@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/to-object-x/-/to-object-x-1.5.0.tgz#bd69dd4e104d77acc0cc0d84f5ac48f630aebe3c" + integrity sha512-AKn5GQcdWky+s20vjWkt+Wa6y3dxQH3yQyMBhOfBOPldUwqwhgvlqcIg5H092ntNc+TX8/Cxzs1kMHH19pyCnA== dependencies: cached-constructors-x "^1.0.0" require-object-coercible-x "^1.4.1" @@ -5352,6 +6219,7 @@ to-object-x@^1.4.1, to-object-x@^1.5.0: to-primitive-x@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/to-primitive-x/-/to-primitive-x-1.1.0.tgz#41ce2c13e3e246e0e5d0a8829a0567c6015833f8" + integrity sha512-gyMY0gi3wjK3e4MUBKqv9Zl8QGcWguIkaUr2VJmoBEsOpDcpDZSEyljR773eVG4maS48uX7muLkoQoh/BA82OQ== dependencies: has-symbol-support-x "^1.4.1" is-date-object "^1.0.1" @@ -5365,6 +6233,7 @@ to-primitive-x@^1.1.0: to-property-key-x@^2.0.1, to-property-key-x@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/to-property-key-x/-/to-property-key-x-2.0.2.tgz#b19aa8e22faa0ff7d1c102cfbc657af73413cfa1" + integrity sha512-YISLpZFYIazNm0P8hLsKEEUEZ3m8U3+eDysJZqTu3+B9tQp+2TrMpaEGT8Agh4fZ5LSoums60/glNEzk5ozqrg== dependencies: has-symbol-support-x "^1.4.1" to-primitive-x "^1.1.0" @@ -5373,6 +6242,7 @@ to-property-key-x@^2.0.1, to-property-key-x@^2.0.2: to-regex-range@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= dependencies: is-number "^3.0.0" repeat-string "^1.6.1" @@ -5380,6 +6250,7 @@ to-regex-range@^2.1.0: to-regex@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.1.tgz#15358bee4a2c83bd76377ba1dc049d0f18837aae" + integrity sha1-FTWL7kosg712N3uh3ASdDxiDeq4= dependencies: define-property "^0.2.5" extend-shallow "^2.0.1" @@ -5388,6 +6259,7 @@ to-regex@^3.0.1: to-string-symbols-supported-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/to-string-symbols-supported-x/-/to-string-symbols-supported-x-1.0.0.tgz#d435eb72312fe885b18047a96d59c75641476872" + integrity sha512-HbVH673pybrUmhzESGHUm17BBJvqb7BU8HciOvuEYm9ipuDyjmddhvkVqpVW6sM/C5/zhJo17n7O7I/24loJIQ== dependencies: cached-constructors-x "^1.0.0" has-symbol-support-x "^1.4.1" @@ -5396,6 +6268,7 @@ to-string-symbols-supported-x@^1.0.0: to-string-tag-x@^1.4.1, to-string-tag-x@^1.4.2: version "1.4.2" resolved "https://registry.yarnpkg.com/to-string-tag-x/-/to-string-tag-x-1.4.2.tgz#916a0c72d2f93dc27fccfe0ea0ce26cd78be21de" + integrity sha512-ytO9eLigxsQQLGuab0C1iSSTzKdJNVSlBg0Spg4J/rGAVrQJ5y774mo0SSzgGeTT4RJGGyJNfObXaTMzX0XDOQ== dependencies: lodash.isnull "^3.0.0" validate.io-undefined "^1.0.3" @@ -5403,22 +6276,26 @@ to-string-tag-x@^1.4.1, to-string-tag-x@^1.4.2: to-string-x@^1.4.2: version "1.4.2" resolved "https://registry.yarnpkg.com/to-string-x/-/to-string-x-1.4.2.tgz#7d9a2528e159a9214e668137c1e10a045abe6279" + integrity sha512-/WP5arlwtCpAAexCCHiQBW0eXwse84osWyP1Qtaz71nsYSuUpOkT6tBm8nQ4IIUfSh5hji0hDupUCD2xbbOL6A== dependencies: is-symbol "^1.0.1" tough-cookie@>=0.12.0, tough-cookie@~2.3.0, tough-cookie@~2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" + integrity sha1-C2GKVWW23qkL80JdBNVe3EdadWE= dependencies: punycode "^1.4.1" tough-cookie@~2.2.0: version "2.2.2" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.2.2.tgz#c83a1830f4e5ef0b93ef2a3488e724f8de016ac7" + integrity sha1-yDoYMPTl7wuT7yo0iOck+N4Basc= trim-left-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/trim-left-x/-/trim-left-x-3.0.0.tgz#356cf055896726b9754425e841398842e90b4cdf" + integrity sha512-+m6cqkppI+CxQBTwWEZliOHpOBnCArGyMnS1WCLb6IRgukhTkiQu/TNEN5Lj2eM9jk8ewJsc7WxFZfmwNpRXWQ== dependencies: cached-constructors-x "^1.0.0" require-coercible-to-string-x "^1.0.0" @@ -5427,14 +6304,17 @@ trim-left-x@^3.0.0: trim-newlines@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + integrity sha1-WIeWa7WCpFA6QetST301ARgVphM= trim-off-newlines@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" + integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= trim-right-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/trim-right-x/-/trim-right-x-3.0.0.tgz#28c4cd37d5981f50ace9b52e3ce9106f4d2d22c0" + integrity sha512-iIqEsWEbWVodqdixJHi4FoayJkUxhoL4AvSNGp4FF4FfQKRPGizt8++/RnyC9od75y7P/S6EfONoVqP+NddiKA== dependencies: cached-constructors-x "^1.0.0" require-coercible-to-string-x "^1.0.0" @@ -5443,6 +6323,7 @@ trim-right-x@^3.0.0: trim-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/trim-x/-/trim-x-3.0.0.tgz#24efdcd027b748bbfc246a0139ad1749befef024" + integrity sha512-w8s38RAUScQ6t3XqMkS75iz5ZkIYLQpVnv2lp3IuTS36JdlVzC54oe6okOf4Wz3UH4rr3XAb2xR3kR5Xei82fw== dependencies: trim-left-x "^3.0.0" trim-right-x "^3.0.0" @@ -5450,6 +6331,7 @@ trim-x@^3.0.0: ts-loader@^0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/ts-loader/-/ts-loader-0.6.1.tgz#98e29d8c3ecad951d544a4c57939f808866f67ac" + integrity sha1-mOKdjD7K2VHVRKTFeTn4CIZvZ6w= dependencies: arrify "^1.0.0" colors "^1.0.3" @@ -5461,16 +6343,19 @@ ts-loader@^0.6.0: tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" + integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== tslint-eslint-rules@^3.1.0: version "3.5.1" resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-3.5.1.tgz#e43efdcdd760d6285600031720f972c92f4a058a" + integrity sha1-5D79zddg1ihWAAMXIPlyyS9KBYo= dependencies: doctrine "^0.7.2" tslint@^4.1.1: version "4.5.1" resolved "https://registry.yarnpkg.com/tslint/-/tslint-4.5.1.tgz#05356871bef23a434906734006fc188336ba824b" + integrity sha1-BTVocb7yOkNJBnNABvwYgza6gks= dependencies: babel-code-frame "^6.20.0" colors "^1.1.2" @@ -5485,24 +6370,29 @@ tslint@^4.1.1: tsutils@^1.1.0: version "1.9.1" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0" + integrity sha1-ufmrROVa+WgYMdXyjQrur1x1DLA= tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= dependencies: safe-buffer "^5.0.1" tunnel-agent@~0.4.0, tunnel-agent@~0.4.1: version "0.4.3" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + integrity sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us= tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" + integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= type-is@~1.6.15: version "1.6.16" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" + integrity sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q== dependencies: media-typer "0.3.0" mime-types "~2.1.18" @@ -5510,14 +6400,17 @@ type-is@~1.6.15: typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= typescript@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8" + integrity sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg== uglify-js@2.6.4: version "2.6.4" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.6.4.tgz#65ea2fb3059c9394692f15fed87c2b36c16b9adf" + integrity sha1-ZeovswWck5RpLxX+2HwrNsFrmt8= dependencies: async "~0.2.6" source-map "~0.5.1" @@ -5527,6 +6420,7 @@ uglify-js@2.6.4: uglify-js@^2.6: version "2.8.29" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" + integrity sha1-KcVzMUgFe7Th913zW3qcty5qWd0= dependencies: source-map "~0.5.1" yargs "~3.10.0" @@ -5536,34 +6430,42 @@ uglify-js@^2.6: uglify-save-license@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/uglify-save-license/-/uglify-save-license-0.4.1.tgz#95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1" + integrity sha1-lXJsF8xv0XHDYX479NjYKqjEzOE= uglify-to-browserify@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7" + integrity sha1-bgkk1r2mta/jSeOabWMoUKD4grc= uid-number@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + integrity sha1-DqEOgDXo61uOREnwbaHHMGY7qoE= ultron@1.0.x: version "1.0.2" resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" + integrity sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po= unc-path-regex@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" + integrity sha1-5z3T17DXxe2G+6xrCufYxqadUPo= underscore.string@~3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-3.0.3.tgz#4617b8c1a250cf6e5064fbbb363d0fa96cf14552" + integrity sha1-Rhe4waJQz25QZPu7Nj0PqWzxRVI= underscore@~1.8.3: version "1.8.3" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.8.3.tgz#4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022" + integrity sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI= union-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" + integrity sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ= dependencies: arr-union "^3.1.0" get-value "^2.0.6" @@ -5573,10 +6475,12 @@ union-value@^1.0.0: unique-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" + integrity sha1-1ZpKdUJ0R9mqbJHnAmP40mpLEEs= unique-stream@^2.0.2: version "2.2.1" resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369" + integrity sha1-WqADz76Uxf+GbE59ZouxxNuts2k= dependencies: json-stable-stringify "^1.0.0" through2-filter "^2.0.0" @@ -5584,16 +6488,19 @@ unique-stream@^2.0.2: unique-string@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-1.0.0.tgz#9e1057cca851abb93398f8b33ae187b99caec11a" + integrity sha1-nhBXzKhRq7kzmPizOuGHuZyuwRo= dependencies: crypto-random-string "^1.0.0" unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= unset-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= dependencies: has-value "^0.3.1" isobject "^3.0.0" @@ -5601,10 +6508,12 @@ unset-value@^1.0.0: unzip-response@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" + integrity sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c= update-notifier@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.3.0.tgz#4e8827a6bb915140ab093559d7014e3ebb837451" + integrity sha1-TognpruRUUCrCTVZ1wFOPruDdFE= dependencies: boxen "^1.2.1" chalk "^2.0.1" @@ -5619,16 +6528,19 @@ update-notifier@^2.0.0: urix@^0.1.0, urix@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= url-parse-lax@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-1.0.0.tgz#7af8f303645e9bd79a272e7a14ac68bc0609da73" + integrity sha1-evjzA2Rem9eaJy56FKxovAYJ2nM= dependencies: prepend-http "^1.0.1" url@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= dependencies: punycode "1.3.2" querystring "0.2.0" @@ -5636,6 +6548,7 @@ url@~0.11.0: use@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/use/-/use-2.0.2.tgz#ae28a0d72f93bf22422a18a2e379993112dec8e8" + integrity sha1-riig1y+TvyJCKhii43mZMRLeyOg= dependencies: define-property "^0.2.5" isobject "^3.0.0" @@ -5644,10 +6557,12 @@ use@^2.0.0: user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + integrity sha1-K1viOjK2Onyd640PKNSFcko98ZA= useragent@^2.1.6: version "2.3.0" resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972" + integrity sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw== dependencies: lru-cache "4.1.x" tmp "0.0.x" @@ -5655,30 +6570,36 @@ useragent@^2.1.6: util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= util@0.10.3, "util@>=0.10.3 <1": version "0.10.3" resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + integrity sha1-evsa/lCAUkZInj23/g7TeTNqwPk= dependencies: inherits "2.0.1" utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= uuid@^3.0.0, uuid@^3.1.0: version "3.2.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" + integrity sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA== v8flags@^2.0.2: version "2.1.1" resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + integrity sha1-qrGh+jDUX4jdMhFIh1rALAtV5bQ= dependencies: user-home "^1.1.1" validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + integrity sha1-KAS6vnEq0zeUWaz74kdGqywwP7w= dependencies: spdx-correct "~1.0.0" spdx-expression-parse "~1.0.0" @@ -5686,18 +6607,22 @@ validate-npm-package-license@^3.0.1: validate.io-undefined@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/validate.io-undefined/-/validate.io-undefined-1.0.3.tgz#7e27fcbb315b841e78243431897671929e20b7f4" + integrity sha1-fif8uzFbhB54JDQxiXZxkp4gt/Q= validator@~9.1.1: version "9.1.2" resolved "https://registry.yarnpkg.com/validator/-/validator-9.1.2.tgz#5711b6413f78bd9d56003130c81b47c39e86546c" + integrity sha512-1Tml6crNdsSC61jHssWksQxq6C7MmSFCCmf99Eb+l/V/cwVlw4/Pg3YXBP1WKcHLsyqe3E+iJXUZgoTTQFcqQg== vargs@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/vargs/-/vargs-0.1.0.tgz#6b6184da6520cc3204ce1b407cac26d92609ebff" + integrity sha1-a2GE2mUgzDIEzhtAfKwm2SYJ6/8= verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" + integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= dependencies: assert-plus "^1.0.0" core-util-is "1.0.2" @@ -5706,6 +6631,7 @@ verror@1.10.0: vinyl-fs@^0.3.0: version "0.3.14" resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" + integrity sha1-mmhRzhysHBzqX+hsCTHWIMLPqeY= dependencies: defaults "^1.0.0" glob-stream "^3.1.5" @@ -5719,6 +6645,7 @@ vinyl-fs@^0.3.0: vinyl-fs@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-1.0.0.tgz#d15752e68c2dad74364e7e853473735354692edf" + integrity sha1-0VdS5owtrXQ2Tn6FNHNzU1RpLt8= dependencies: duplexify "^3.2.0" glob-stream "^4.0.1" @@ -5734,12 +6661,14 @@ vinyl-fs@^1.0.0: vinyl-sourcemaps-apply@^0.2.0: version "0.2.1" resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" + integrity sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU= dependencies: source-map "^0.5.1" vinyl@^0.4.0: version "0.4.6" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" + integrity sha1-LzVsh6VQolVGHza76ypbqL94SEc= dependencies: clone "^0.2.0" clone-stats "^0.0.1" @@ -5747,6 +6676,7 @@ vinyl@^0.4.0: vinyl@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.5.3.tgz#b0455b38fc5e0cf30d4325132e461970c2091cde" + integrity sha1-sEVbOPxeDPMNQyUTLkYZcMIJHN4= dependencies: clone "^1.0.0" clone-stats "^0.0.1" @@ -5755,6 +6685,7 @@ vinyl@^0.5.0: vinyl@^2.0.1, vinyl@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.1.0.tgz#021f9c2cf951d6b939943c89eb5ee5add4fd924c" + integrity sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw= dependencies: clone "^2.1.1" clone-buffer "^1.0.0" @@ -5766,16 +6697,19 @@ vinyl@^2.0.1, vinyl@^2.1.0: void-elements@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" + integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= vrsource-tslint-rules@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/vrsource-tslint-rules/-/vrsource-tslint-rules-4.0.1.tgz#f3cf8026e1d3a9b63d263dd591248dc96dc3ec1c" + integrity sha1-88+AJuHTqbY9Jj3VkSSNyW3D7Bw= dependencies: tslint "^4.1.1" wd@~0.3.4: version "0.3.12" resolved "https://registry.yarnpkg.com/wd/-/wd-0.3.12.tgz#3fb4f1d759f8c85dde5393d17334ffe03e9bb329" + integrity sha1-P7Tx11n4yF3eU5PRczT/4D6bsyk= dependencies: archiver "~0.14.0" async "~1.0.0" @@ -5788,10 +6722,12 @@ wd@~0.3.4: wdio-dot-reporter@~0.0.8: version "0.0.9" resolved "https://registry.yarnpkg.com/wdio-dot-reporter/-/wdio-dot-reporter-0.0.9.tgz#929b2adafd49d6b0534fda068e87319b47e38fe5" + integrity sha1-kpsq2v1J1rBTT9oGjocxm0fjj+U= webdriver-manager@^12.0.6: version "12.0.6" resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.0.6.tgz#3df1a481977010b4cbf8c9d85c7a577828c0e70b" + integrity sha1-PfGkgZdwELTL+MnYXHpXeCjA5ws= dependencies: adm-zip "^0.4.7" chalk "^1.1.1" @@ -5808,6 +6744,7 @@ webdriver-manager@^12.0.6: webdriverio@^4.8.0: version "4.10.2" resolved "https://registry.yarnpkg.com/webdriverio/-/webdriverio-4.10.2.tgz#0d28622802c966015afe34b3ac566dc339f22e43" + integrity sha1-DShiKALJZgFa/jSzrFZtwznyLkM= dependencies: archiver "~2.1.0" babel-runtime "^6.26.0" @@ -5835,62 +6772,75 @@ webdriverio@^4.8.0: wgxpath@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wgxpath/-/wgxpath-1.0.0.tgz#eef8a4b9d558cc495ad3a9a2b751597ecd9af690" + integrity sha1-7vikudVYzEla06mit1FZfs2a9pA= whatwg-fetch@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" + integrity sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ= when@^3.7.5: version "3.7.8" resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82" + integrity sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I= which@^1.0.5, which@^1.2.1, which@^1.2.10, which@^1.2.14, which@^1.2.9: version "1.3.0" resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" + integrity sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg== dependencies: isexe "^2.0.0" which@~1.2.2: version "1.2.14" resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" + integrity sha1-mofEN48D6CfOyvGs31bHNsAcFOU= dependencies: isexe "^2.0.0" white-space-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/white-space-x/-/white-space-x-3.0.0.tgz#c8e31ed4fecf4f3feebe6532e6046008a666a3e1" + integrity sha512-nMPVXGMdi/jQepXKryxqzEh/vCwdOYY/u6NZy40glMHvZfEr7/+vQKnDhEq4rZ1nniOFq9GWohQYB30uW/5Olg== wide-align@^1.1.0: version "1.1.2" resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" + integrity sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w== dependencies: string-width "^1.0.2" widest-line@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.0.tgz#0142a4e8a243f8882c0233aa0e0281aa76152273" + integrity sha1-AUKk6KJD+IgsAjOqDgKBqnYVInM= dependencies: string-width "^2.1.1" window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" + integrity sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0= wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" + integrity sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8= wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" + integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= write-file-atomic@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" + integrity sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA== dependencies: graceful-fs "^4.1.11" imurmurhash "^0.1.4" @@ -5899,6 +6849,7 @@ write-file-atomic@^2.0.0: ws@~1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.5.tgz#cbd9e6e75e09fc5d2c90015f21f0c40875e0dd51" + integrity sha512-o3KqipXNUdS7wpQzBHSe180lBGO60SoK0yVo3CYJgb2MkobuWuBX6dhkYP5ORCLd55y+SaflMOV5fqAB53ux4w== dependencies: options ">=0.0.5" ultron "1.0.x" @@ -5906,14 +6857,17 @@ ws@~1.1.5: wtf-8@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a" + integrity sha1-OS2LotDxw00e4tYw8V0O+2jhBIo= xdg-basedir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4" + integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= xml2js@^0.4.17: version "0.4.19" resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7" + integrity sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q== dependencies: sax ">=0.6.0" xmlbuilder "~9.0.1" @@ -5921,22 +6875,27 @@ xml2js@^0.4.17: xmlbuilder@~9.0.1: version "9.0.7" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" + integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0= xmlhttprequest-ssl@1.5.3: version "1.5.3" resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" + integrity sha1-GFqIjATspGw+QHDZn3tJ3jUomS0= "xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" + integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" + integrity sha1-9+572FfdfB0tOMDnTvvWgdFDH9E= dependencies: camelcase "^1.0.2" cliui "^2.1.0" @@ -5946,16 +6905,19 @@ yargs@~3.10.0: yauzl@2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" + integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU= dependencies: fd-slicer "~1.0.1" yeast@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" + integrity sha1-AI4G2AlDIMNy28L47XagymyKxBk= zip-stream@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-1.2.0.tgz#a8bc45f4c1b49699c6b90198baacaacdbcd4ba04" + integrity sha1-qLxF9MG0lpnGuQGYuqyqzbzUugQ= dependencies: archiver-utils "^1.3.0" compress-commons "^1.2.0" @@ -5965,6 +6927,7 @@ zip-stream@^1.2.0: zip-stream@~0.5.0: version "0.5.2" resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-0.5.2.tgz#32dcbc506d0dab4d21372625bd7ebaac3c2fff56" + integrity sha1-Mty8UG0Nq00hNyYlvX66rDwv/1Y= dependencies: compress-commons "~0.2.0" lodash "~3.2.0" From afa1363eb9ae3be506442311a18723a112f9ef8b Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Thu, 13 Dec 2018 06:36:43 +0900 Subject: [PATCH 069/106] fix(core): fix #1153, ZoneTask.toString should always be a string (#1166) --- lib/zone.ts | 2 +- test/common/toString.spec.ts | 40 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/zone.ts b/lib/zone.ts index 4de4e077d..74fb76536 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -1240,7 +1240,7 @@ const Zone: ZoneType = (function(global: any) { public toString() { if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId; + return this.data.handleId.toString(); } else { return Object.prototype.toString.call(this); } diff --git a/test/common/toString.spec.ts b/test/common/toString.spec.ts index 9d9b57090..a8a29f788 100644 --- a/test/common/toString.spec.ts +++ b/test/common/toString.spec.ts @@ -47,3 +47,43 @@ describe('global function patch', () => { })); }); }); + +describe('ZoneTask', () => { + it('should return handleId.toString if handleId is available', () => { + let macroTask1: any = undefined; + let macroTask2: any = undefined; + let microTask: any = undefined; + const zone = Zone.current.fork({ + name: 'timer', + onScheduleTask: (delegate: ZoneDelegate, curr: Zone, target: Zone, task: Task) => { + if (task.type === 'macroTask') { + if (!macroTask1) { + macroTask1 = task; + } else { + macroTask2 = task; + } + } else if (task.type === 'microTask') { + microTask = task; + } + return task; + } + }); + zone.run(() => { + const id1 = setTimeout(() => {}); + clearTimeout(id1); + const id2 = setTimeout(() => {}); + clearTimeout(id2); + Promise.resolve().then(() => {}); + const macroTask1Str = macroTask1.toString(); + const macroTask2Str = macroTask2.toString(); + expect(typeof macroTask1Str).toEqual('string'); + expect(macroTask1Str).toEqual(id1.toString()); + expect(typeof macroTask2Str).toEqual('string'); + expect(macroTask2Str).toEqual(id2.toString()); + if (macroTask1.data && typeof macroTask1.data.handleId === 'number') { + expect(macroTask1Str).not.toEqual(macroTask2Str); + } + expect(typeof microTask.toString()).toEqual('string'); + }); + }); +}); From eb72ff4cc26536670f38b841d0a3f6bfa22f9b94 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 8 Jan 2019 08:49:45 +0800 Subject: [PATCH 070/106] fix(core): fix interval will still run after cancelled error (#1156) --- lib/zone.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/zone.ts b/lib/zone.ts index 74fb76536..7e02452be 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -796,7 +796,7 @@ const Zone: ZoneType = (function(global: any) { // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - if (task.state === notScheduled && task.type === eventTask) { + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { return; } From 96420d6b2df57507f62bcf6e562e9cd191a694cb Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 8 Jan 2019 08:50:19 +0800 Subject: [PATCH 071/106] fix(event): fix #1110, nodejs EventEmitter should support Symbol eventName (#1113) --- file-size-limit.json | 2 +- lib/common/events.ts | 16 ++++++++++++---- lib/node/events.ts | 13 ++++++++++++- test/node/events.spec.ts | 12 ++++++++++++ tsconfig-esm-node.json | 3 ++- tsconfig-esm.json | 9 ++++++++- tsconfig-node.json | 3 ++- tsconfig.json | 9 ++++++++- 8 files changed, 57 insertions(+), 10 deletions(-) diff --git a/file-size-limit.json b/file-size-limit.json index e0fd98bf9..bd147342a 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -3,7 +3,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 42500 + "limit": 43000 } ] } diff --git a/lib/common/events.ts b/lib/common/events.ts index b2a02f69c..ff2442dfe 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -69,6 +69,8 @@ export interface PatchEventTargetOptions { diff?: (task: any, delegate: any) => boolean; // support passive or not supportPassive?: boolean; + // get string from eventName (in nodejs, eventName maybe Symbol) + eventNameToString?: (eventName: any) => string; } export function patchEventTarget( @@ -212,6 +214,8 @@ export function patchEventTarget( return false; } + const eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask // so we do not need to create a new object just for pass some data const taskData: any = {}; @@ -384,8 +388,10 @@ export function patchEventTarget( let symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - const falseEventName = eventName + FALSE_STR; - const trueEventName = eventName + TRUE_STR; + const falseEventName = + (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + const trueEventName = + (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; const symbol = ZONE_SYMBOL_PREFIX + falseEventName; const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; zoneSymbolEventNames[eventName] = {}; @@ -418,7 +424,8 @@ export function patchEventTarget( source = targetSource[eventName]; } if (!source) { - source = constructorName + addSource + eventName; + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); } // do not create a new object as task.data to pass those things // just use the global shared one @@ -556,7 +563,8 @@ export function patchEventTarget( const eventName = arguments[0]; const listeners: any[] = []; - const tasks = findEventTasks(target, eventName); + const tasks = + findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); for (let i = 0; i < tasks.length; i++) { const task: any = tasks[i]; diff --git a/lib/node/events.ts b/lib/node/events.ts index d7eda2596..09ab0c856 100644 --- a/lib/node/events.ts +++ b/lib/node/events.ts @@ -22,6 +22,16 @@ Zone.__load_patch('EventEmitter', (global: any) => { return task.callback === delegate || task.callback.listener === delegate; }; + const eventNameToString = function(eventName: string|Symbol) { + if (typeof eventName === 'string') { + return eventName as string; + } + if (!eventName) { + return ''; + } + return eventName.toString().replace('(', '_').replace(')', '_'); + }; + function patchEventEmitterMethods(obj: any) { const result = patchEventTarget(global, [obj], { useG: false, @@ -32,7 +42,8 @@ Zone.__load_patch('EventEmitter', (global: any) => { listeners: EE_LISTENERS, chkDup: false, rt: true, - diff: compareTaskCallbackVsDelegate + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; diff --git a/test/node/events.spec.ts b/test/node/events.spec.ts index 8b13c8012..09757e2aa 100644 --- a/test/node/events.spec.ts +++ b/test/node/events.spec.ts @@ -189,4 +189,16 @@ describe('nodejs EventEmitter', () => { process.on('uncaughtException', function() {}); }); }); + it('should be able to addEventListener with symbol eventName', () => { + zoneA.run(() => { + const testSymbol = Symbol('test'); + const test1Symbol = Symbol('test1'); + emitter.on(testSymbol, expectZoneA); + emitter.on(test1Symbol, shouldNotRun); + emitter.removeListener(test1Symbol, shouldNotRun); + expect(emitter.listeners(testSymbol).length).toBe(1); + expect(emitter.listeners(test1Symbol).length).toBe(0); + emitter.emit(testSymbol, 'test value'); + }); + }); }); diff --git a/tsconfig-esm-node.json b/tsconfig-esm-node.json index 8a79dc143..7bc17d63b 100644 --- a/tsconfig-esm-node.json +++ b/tsconfig-esm-node.json @@ -18,7 +18,8 @@ "lib": [ "es5", "dom", - "es2015.promise" + "es2015.promise", + "es2015.symbol" ] }, "exclude": [ diff --git a/tsconfig-esm.json b/tsconfig-esm.json index ab2416b2d..6fd80e075 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -26,6 +26,13 @@ "build", "build-esm", "dist", - "lib/closure" + "lib/closure", + "lib/node/**", + "lib/mix/**", + "test/node/**", + "test/node_bluebird_entry_point.ts", + "test/node_entry_point.ts", + "test/node_error_entry_point.ts", + "test/node_tests.ts" ] } \ No newline at end of file diff --git a/tsconfig-node.json b/tsconfig-node.json index eca611773..f33fd87af 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -16,7 +16,8 @@ "lib": [ "es5", "dom", - "es2015.promise" + "es2015.promise", + "es2015.symbol" ] }, "exclude": [ diff --git a/tsconfig.json b/tsconfig.json index ec1d893a9..90ba090fc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,13 @@ "build", "build-esm", "dist", - "lib/closure" + "lib/closure", + "lib/node/**", + "lib/mix/**", + "test/node/**", + "test/node_bluebird_entry_point.ts", + "test/node_entry_point.ts", + "test/node_error_entry_point.ts", + "test/node_tests.ts" ] } \ No newline at end of file From 8ce5e331b11abad2b2a8adfc3fa13622afd77da5 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 8 Jan 2019 08:50:42 +0800 Subject: [PATCH 072/106] fix(duplicate): fix #1081, load patch should also check the duplicate flag (#1121) --- lib/zone.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/zone.ts b/lib/zone.ts index 7e02452be..a65a249f4 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -643,6 +643,7 @@ const Zone: ZoneType = (function(global: any) { performance && performance['measure'] && performance['measure'](name, label); } mark('Zone'); + const checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; if (global['Zone']) { // if global['Zone'] already exists (maybe zone.js was already loaded or // some other lib also registered a global object named Zone), we may need @@ -653,8 +654,7 @@ const Zone: ZoneType = (function(global: any) { // but when user load page2 again, error occurs because global['Zone'] already exists. // so we add a flag to let user choose whether to throw this error or not. // By default, if existing Zone is from zone.js, we will not throw the error. - if (global[('__zone_symbol__forceDuplicateZoneCheck')] === true || - typeof global['Zone'].__symbol__ !== 'function') { + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { throw new Error('Zone already loaded.'); } else { return global['Zone']; @@ -693,7 +693,9 @@ const Zone: ZoneType = (function(global: any) { static __load_patch(name: string, fn: _PatchFn): void { if (patches.hasOwnProperty(name)) { - throw Error('Already loaded patch: ' + name); + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } else if (!global['__Zone_disable_' + name]) { const perfName = 'Zone:' + name; mark(perfName); @@ -1364,4 +1366,4 @@ const Zone: ZoneType = (function(global: any) { performanceMeasure('Zone', 'Zone'); return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); \ No newline at end of file From d8c3b9dcbe519000583bdb717ce8ae184ac5e394 Mon Sep 17 00:00:00 2001 From: CaerusKaru Date: Fri, 11 Jan 2019 11:16:24 -0600 Subject: [PATCH 073/106] chore: release v0.8.27 (#1172) --- CHANGELOG.md | 36 ++ dist/fake-async-test.js | 42 +- dist/proxy.js | 1 + dist/proxy.min.js | 2 +- dist/webapis-media-query.js | 2 +- dist/wtf.js | 17 +- dist/wtf.min.js | 2 +- dist/zone-bluebird.js | 21 +- dist/zone-bluebird.min.js | 2 +- dist/zone-error.js | 176 +++++--- dist/zone-error.min.js | 2 +- dist/zone-mix.js | 468 ++++++++++++++------ dist/zone-node.js | 330 ++++++++++---- dist/zone-patch-jsonp.js | 7 +- dist/zone-patch-resize-observer.js | 6 +- dist/zone-patch-resize-observer.min.js | 2 +- dist/zone-patch-rxjs-fake-async.js | 14 +- dist/zone-patch-rxjs-fake-async.min.js | 2 +- dist/zone-patch-rxjs.js | 281 +++--------- dist/zone-patch-rxjs.min.js | 2 +- dist/zone-testing-bundle.js | 575 +++++++++++++++++++------ dist/zone-testing-node-bundle.js | 373 +++++++++++----- dist/zone-testing.js | 43 +- dist/zone.js | 532 +++++++++++++++++------ dist/zone.js.d.ts | 24 +- dist/zone.min.js | 4 +- package.json | 2 +- 27 files changed, 2006 insertions(+), 962 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8d1cb7ff..aa1b47247 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ + +## [0.8.27](https://github.com/angular/zone.js/compare/v0.8.26...0.8.27) (2019-01-08) + + +### Bug Fixes + +* **bluebird:** fix [#1112](https://github.com/angular/zone.js/issues/1112), bluebird chained callback should return a Bluebird Promise ([#1114](https://github.com/angular/zone.js/issues/1114)) ([6ba3169](https://github.com/angular/zone.js/commit/6ba3169)) +* **core:** fix [#1108](https://github.com/angular/zone.js/issues/1108), window.onerror should have (message, source, lineno, colno, error) signiture ([#1109](https://github.com/angular/zone.js/issues/1109)) ([49e0548](https://github.com/angular/zone.js/commit/49e0548)) +* **core:** fix [#1153](https://github.com/angular/zone.js/issues/1153), ZoneTask.toString should always be a string ([#1166](https://github.com/angular/zone.js/issues/1166)) ([afa1363](https://github.com/angular/zone.js/commit/afa1363)) +* **core:** fix interval will still run after cancelled error ([#1156](https://github.com/angular/zone.js/issues/1156)) ([eb72ff4](https://github.com/angular/zone.js/commit/eb72ff4)) +* **core:** use then directly when promise is not patchable ([#1079](https://github.com/angular/zone.js/issues/1079)) ([d7e0a31](https://github.com/angular/zone.js/commit/d7e0a31)) +* **duplicate:** fix [#1081](https://github.com/angular/zone.js/issues/1081), load patch should also check the duplicate flag ([#1121](https://github.com/angular/zone.js/issues/1121)) ([8ce5e33](https://github.com/angular/zone.js/commit/8ce5e33)) +* **event:** fix [#1110](https://github.com/angular/zone.js/issues/1110), nodejs EventEmitter should support Symbol eventName ([#1113](https://github.com/angular/zone.js/issues/1113)) ([96420d6](https://github.com/angular/zone.js/commit/96420d6)) +* **event:** should pass boolean to addEventListener if not support passive ([#1053](https://github.com/angular/zone.js/issues/1053)) ([e9536ec](https://github.com/angular/zone.js/commit/e9536ec)) +* **format:** update clang-format to 1.2.3 ([f238908](https://github.com/angular/zone.js/commit/f238908)) +* **memory:** Add protection against excessive on prop patching ([#1106](https://github.com/angular/zone.js/issues/1106)) ([875086f](https://github.com/angular/zone.js/commit/875086f)) +* **node:** fix [#1164](https://github.com/angular/zone.js/issues/1164), don't patch uncaughtException to prevent endless loop ([#1170](https://github.com/angular/zone.js/issues/1170)) ([33a0ad6](https://github.com/angular/zone.js/commit/33a0ad6)) +* **node:** node patched method should copy original delegate's symbol properties ([#1095](https://github.com/angular/zone.js/issues/1095)) ([0a2f6ff](https://github.com/angular/zone.js/commit/0a2f6ff)) +* **onProperty:** user quoted access for __Zone_ignore_on_properties ([#1134](https://github.com/angular/zone.js/issues/1134)) ([7201d44](https://github.com/angular/zone.js/commit/7201d44)) +* **test:** karma-dist should test bundle under dist ([#1049](https://github.com/angular/zone.js/issues/1049)) ([0720d79](https://github.com/angular/zone.js/commit/0720d79)) +* **tsc:** tsconfig.json strict:true ([915042d](https://github.com/angular/zone.js/commit/915042d)) +* **xhr:** fix [#1072](https://github.com/angular/zone.js/issues/1072), should set scheduled flag to target ([#1074](https://github.com/angular/zone.js/issues/1074)) ([34c12e5](https://github.com/angular/zone.js/commit/34c12e5)) +* **xhr:** should invoke xhr task after onload is triggered ([#1055](https://github.com/angular/zone.js/issues/1055)) ([2aab9c8](https://github.com/angular/zone.js/commit/2aab9c8)) + + +### Features + +* **build:** Upgrade to TypeScript 2.9 and rxjs6 ([#1122](https://github.com/angular/zone.js/issues/1122)) ([31fc127](https://github.com/angular/zone.js/commit/31fc127)) +* **core:** upgrade to typescript 3.0.3 ([#1132](https://github.com/angular/zone.js/issues/1132)) ([60adc9c](https://github.com/angular/zone.js/commit/60adc9c)) +* **Core:** fix [#910](https://github.com/angular/zone.js/issues/910), add a flag to allow user to ignore duplicate Zone error ([#1093](https://github.com/angular/zone.js/issues/1093)) ([a86c6d5](https://github.com/angular/zone.js/commit/a86c6d5)) +* **custom-element:** patch customElement v1 APIs ([#1133](https://github.com/angular/zone.js/issues/1133)) ([427705f](https://github.com/angular/zone.js/commit/427705f)) +* **error:** fix [#975](https://github.com/angular/zone.js/issues/975), can config how to load blacklist zone stack frames ([#1045](https://github.com/angular/zone.js/issues/1045)) ([ff3d545](https://github.com/angular/zone.js/commit/ff3d545)) +* **fetch:** schedule macroTask when fetch ([#1075](https://github.com/angular/zone.js/issues/1075)) ([bf88c34](https://github.com/angular/zone.js/commit/bf88c34)) + + + ## [0.8.26](https://github.com/angular/zone.js/compare/v0.8.25...0.8.26) (2018-04-08) diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index 9bc27674e..348de8d0f 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -154,7 +154,11 @@ var __spread = (undefined && undefined.__spread) || function () { } } } + lastCurrentTime = this._currentTime; this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } }; Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { if (limit === void 0) { limit = 20; } @@ -243,14 +247,14 @@ var __spread = (undefined && undefined.__spread) || function () { args[_i] = arguments[_i]; } fn.apply(global, args); - if (_this._lastError === null) { + if (_this._lastError === null) { // Success if (completers.onSuccess != null) { completers.onSuccess.apply(global); } // Flush microtasks only on success. _this.flushMicrotasks(); } - else { + else { // Failure if (completers.onError != null) { completers.onError.apply(global); } @@ -549,23 +553,23 @@ Zone.__load_patch('fakeasync', function (global, Zone, api) { ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); } /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ function fakeAsync(fn) { // Not using an arrow function to preserve context passed from call site return function () { diff --git a/dist/proxy.js b/dist/proxy.js index 5766ee978..d2535215a 100644 --- a/dist/proxy.js +++ b/dist/proxy.js @@ -23,6 +23,7 @@ var ProxyZoneSpec = /** @class */ (function () { if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } this.defaultSpecDelegate = defaultSpecDelegate; this.name = 'ProxyZone'; + this._delegateSpec = null; this.properties = { 'ProxyZoneSpec': this }; this.propertyKeys = null; this.lastTaskState = null; diff --git a/dist/proxy.min.js b/dist/proxy.min.js index c0c44d725..2d4c72c21 100644 --- a/dist/proxy.min.js +++ b/dist/proxy.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";var e=function(){function e(e){void 0===e&&(e=null),this.defaultSpecDelegate=e,this.name="ProxyZone",this.properties={ProxyZoneSpec:this},this.propertyKeys=null,this.lastTaskState=null,this.isNeedToTriggerHasTask=!1,this.tasks=[],this.setDelegate(e)}return e.get=function(){return Zone.current.get("ProxyZoneSpec")},e.isLoaded=function(){return e.get()instanceof e},e.assertPresent=function(){if(!e.isLoaded())throw new Error("Expected to be running in 'ProxyZone', but it was not found.");return e.get()},e.prototype.setDelegate=function(e){var t=this,s=this._delegateSpec!==e;this._delegateSpec=e,this.propertyKeys&&this.propertyKeys.forEach(function(e){return delete t.properties[e]}),this.propertyKeys=null,e&&e.properties&&(this.propertyKeys=Object.keys(e.properties),this.propertyKeys.forEach(function(s){return t.properties[s]=e.properties[s]})),s&&this.lastTaskState&&(this.lastTaskState.macroTask||this.lastTaskState.microTask)&&(this.isNeedToTriggerHasTask=!0)},e.prototype.getDelegate=function(){return this._delegateSpec},e.prototype.resetDelegate=function(){this.getDelegate();this.setDelegate(this.defaultSpecDelegate)},e.prototype.tryTriggerHasTask=function(e,t,s){this.isNeedToTriggerHasTask&&this.lastTaskState&&(this.isNeedToTriggerHasTask=!1,this.onHasTask(e,t,s,this.lastTaskState))},e.prototype.removeFromTasks=function(e){if(this.tasks)for(var t=0;t'; this._properties = zoneSpec && zoneSpec.properties || {}; @@ -76,7 +89,9 @@ var Zone$1 = (function (global) { }); Zone.__load_patch = function (name, fn) { if (patches.hasOwnProperty(name)) { - throw Error('Already loaded patch: ' + name); + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } else if (!global['__Zone_disable_' + name]) { var perfName = 'Zone:' + name; @@ -120,7 +135,7 @@ var Zone$1 = (function (global) { return this._zoneDelegate.fork(this, zoneSpec); }; Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== FUNCTION) { + if (typeof callback !== 'function') { throw new Error('Expecting function got: ' + callback); } var _callback = this._zoneDelegate.intercept(this, callback, source); @@ -130,9 +145,6 @@ var Zone$1 = (function (global) { }; }; Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = undefined; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); @@ -143,8 +155,6 @@ var Zone$1 = (function (global) { }; Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { if (applyThis === void 0) { applyThis = null; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { try { @@ -168,10 +178,7 @@ var Zone$1 = (function (global) { // https://github.com/angular/zone.js/issues/778, sometimes eventTask // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - // we have to define an variable here, if not - // typescript compiler will complain below - var isNotScheduled = task.state === notScheduled; - if (isNotScheduled && task.type === eventTask) { + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { return; } var reEntryGuard = task.state != running; @@ -182,7 +189,7 @@ var Zone$1 = (function (global) { _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = null; + task.cancelFn = undefined; } try { return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); @@ -218,8 +225,7 @@ var Zone$1 = (function (global) { var newZone = this; while (newZone) { if (newZone === task.zone) { - throw Error("can not reschedule task to " + this - .name + " which is descendants of the original zone " + task.zone.name); + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); } newZone = newZone.parent; } @@ -249,7 +255,7 @@ var Zone$1 = (function (global) { return task; }; Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, null)); + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); }; Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); @@ -290,16 +296,14 @@ var Zone$1 = (function (global) { }()); var DELEGATE_ZS = { name: '', - onHasTask: function (delegate, _, target, hasTaskState) { - return delegate.hasTask(target, hasTaskState); - }, + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, - onCancelTask: function (delegate, _, target, task) { - return delegate.cancelTask(target, task); - } + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { @@ -327,8 +331,8 @@ var Zone$1 = (function (global) { zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = - zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); this._invokeTaskZS = @@ -383,8 +387,7 @@ var Zone$1 = (function (global) { callback; }; ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? - this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.handleError = function (targetZone, error) { @@ -416,8 +419,7 @@ var Zone$1 = (function (global) { return returnTask; }; ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.cancelTask = function (targetZone, task) { @@ -437,7 +439,7 @@ var Zone$1 = (function (global) { // hasTask should not throw error so other ZoneDelegate // can still trigger hasTask callback try { - return this._hasTaskZS && + this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } catch (err) { @@ -527,14 +529,12 @@ var Zone$1 = (function (global) { } } else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? - ' or \'' + fromState2 + '\'' : - '') + ", was '" + this._state + "'."); + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); } }; ZoneTask.prototype.toString = function () { if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId; + return this.data.handleId.toString(); } else { return Object.prototype.toString.call(this); @@ -575,7 +575,13 @@ var Zone$1 = (function (global) { } } if (nativeMicroTaskQueuePromise) { - nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue); + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); } else { global[symbolSetTimeout](drainMicroTaskQueue, 0); @@ -622,12 +628,13 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - bindArguments: function () { return null; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === FUNCTION) { + if (NativePromise && typeof NativePromise.resolve === 'function') { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, @@ -643,6 +650,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -785,7 +802,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var queue = promise[symbolValue]; promise[symbolValue] = value; if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally + // the promise is generated by Promise.prototype.finally if (state === RESOLVED) { // the state is resolved, should ignore the value // and use parent promise value @@ -869,7 +886,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { chainPromise[symbolParentPromiseState] = promiseState; } // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); resolvePromise(chainPromise, true, value); } catch (error) { @@ -904,6 +923,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { return resolvePromise(new this(null), REJECTED, error); }; ZoneAwarePromise.race = function (values) { + var e_1, _a; var resolve; var reject; var promise = new this(function (res, rej) { @@ -916,40 +936,70 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; }; ZoneAwarePromise.all = function (values) { + var e_2, _a; var resolve; var reject; var promise = new this(function (res, rej) { resolve = res; reject = rej; }); - var count = 0; + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; + var _loop_2 = function (value) { if (!isThenable(value)) { - value = this.resolve(value); + value = this_1.resolve(value); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { resolve(resolvedValues); } - }; })(count), reject); - count++; + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + _loop_2(value); + } } - if (!count) + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { resolve(resolvedValues); + } return promise; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { @@ -1045,25 +1095,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; Ctor[symbolThenPatched] = true; } - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } + api.patchThen = patchThen; if (NativePromise) { patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global['fetch'] = zoneify(fetch_1); - } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; @@ -1185,9 +1219,23 @@ var wrapFn = function (event) { } var target = this || event.target || _global; var listener = target[eventNameSymbol]; - var result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } return result; }; @@ -1205,6 +1253,10 @@ function patchProperty(obj, prop, prototype) { if (!desc || !desc.configurable) { return; } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } // A property descriptor cannot have getter/setter and be writable // deleting the writable and value properties avoids this error: // @@ -1282,6 +1334,7 @@ function patchProperty(obj, prop, prototype) { return null; }; ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1372,6 +1425,33 @@ function patchClass(className) { } } } +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +var shouldCopySymbolProperties = false; +function setShouldCopySymbolProperties(flag) { + shouldCopySymbolProperties = flag; +} function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { @@ -1382,7 +1462,7 @@ function patchMethod(target, name, patchFn) { proto = target; } var delegateName = zoneSymbol(name); - var delegate; + var delegate = null; if (proto && !(delegate = proto[delegateName])) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable @@ -1394,6 +1474,9 @@ function patchMethod(target, name, patchFn) { return patchDelegate_1(this, arguments); }; attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } } } return delegate; @@ -1412,7 +1495,7 @@ function patchMacroTask(obj, funcName, metaCreator) { setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1446,6 +1529,17 @@ function attachOriginToPatched(patched, original) { } var isDetectedIEOrEdge = false; var ieOrEdge = false; +function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; +} function isIEOrEdge() { if (isDetectedIEOrEdge) { return ieOrEdge; @@ -1527,6 +1621,21 @@ Zone.__load_patch('toString', function (global) { * @fileoverview * @suppress {missingRequire} */ +var passiveSupported = false; +if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { useG: true @@ -1662,6 +1771,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (proto[zoneSymbolAddEventListener]) { return false; } + var eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask // so we do not need to create a new object just for pass some data var taskData = {}; @@ -1677,12 +1787,24 @@ function patchEventTarget(_global, apis, patchOptions) { nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = proto[patchOptions.prepend]; } - var customScheduleGlobal = function () { + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { @@ -1723,6 +1845,7 @@ function patchEventTarget(_global, apis, patchOptions) { return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { @@ -1745,10 +1868,15 @@ function patchEventTarget(_global, apis, patchOptions) { if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; + var eventName = arguments[0]; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } // don't create the bind delegate function for handleEvent // case here to improve addEventListener performance // we will create the bind delegate when invoke @@ -1762,7 +1890,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { return; } - var eventName = arguments[0]; var options = arguments[2]; if (blackListedEvents) { // check black list @@ -1792,8 +1919,8 @@ function patchEventTarget(_global, apis, patchOptions) { var symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; zoneSymbolEventNames$1[eventName] = {}; @@ -1828,7 +1955,8 @@ function patchEventTarget(_global, apis, patchOptions) { source = targetSource[eventName]; } if (!source) { - source = constructorName + addSource + eventName; + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); } // do not create a new object as task.data to pass those things // just use the global shared one @@ -1843,7 +1971,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.capture = capture; taskData.eventName = eventName; taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; @@ -1861,7 +1989,11 @@ function patchEventTarget(_global, apis, patchOptions) { if (once) { options.once = true; } - task.options = options; + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } task.target = target; task.capture = capture; task.eventName = eventName; @@ -1946,7 +2078,7 @@ function patchEventTarget(_global, apis, patchOptions) { var target = this || _global; var eventName = arguments[0]; var listeners = []; - var tasks = findEventTasks(target, eventName); + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); for (var i = 0; i < tasks.length; i++) { var task = tasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; @@ -2102,9 +2234,9 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, setName, function (delegate) { return function (self, args) { if (typeof args[0] === 'function') { var options = { - handleId: null, isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, args: args }; var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); @@ -2219,7 +2351,7 @@ function propertyPatch() { }; Object.getOwnPropertyDescriptor = function (obj, prop) { var desc = _getOwnPropertyDescriptor(obj, prop); - if (isUnconfigurable(obj, prop)) { + if (desc && isUnconfigurable(obj, prop)) { desc.configurable = false; } return desc; @@ -2447,10 +2579,10 @@ var globalEventHandlersEventNames = [ 'wheel' ]; var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'fullscreenchange', + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange' + 'visibilitychange', 'resume' ]; var windowEventNames = [ 'absolutedeviceorientation', @@ -2562,7 +2694,7 @@ var websocketEventNames = ['close', 'error', 'open', 'message']; var workerEventNames = ['error', 'message']; var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { return onProperties; } var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); @@ -2587,13 +2719,14 @@ function propertyDescriptorPatch(api, _global) { } var supportsWebSocket = typeof WebSocket !== 'undefined'; if (canPatchViaPropertyDescriptor()) { - var ignoreProperties = _global.__Zone_ignore_on_properties; + var ignoreProperties = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); if (typeof internalWindow['SVGElement'] !== 'undefined') { patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); @@ -2615,9 +2748,9 @@ function propertyDescriptorPatch(api, _global) { } } patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget_1 = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + patchFilteredProperties(XMLHttpRequestEventTarget_1 && XMLHttpRequestEventTarget_1.prototype, XMLHttpRequestEventNames, ignoreProperties); } if (typeof IDBIndex !== 'undefined') { patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); @@ -2832,16 +2965,16 @@ function patchEvent(global, api) { * 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 && !isMix) || !('registerElement' in _global.document)) { +function patchCallbacks(target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { return; } - var _registerElement = document.registerElement; - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - document.registerElement = function (name, opts) { + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { if (opts && opts.prototype) { callbacks.forEach(function (callback) { - var source = 'Document.registerElement::' + callback; + var source = targetName + "." + method + "::" + callback; var prototype = opts.prototype; if (prototype.hasOwnProperty(callback)) { var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); @@ -2858,9 +2991,23 @@ function registerElementPatch(_global) { } }); } - return _registerElement.call(document, name, opts); + return nativeDelegate.call(target, name, opts, options); }; - attachOriginToPatched(document.registerElement, _registerElement); + attachOriginToPatched(target[method], nativeDelegate); +} +function registerElementPatch(_global) { + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + patchCallbacks(document, 'Document', 'registerElement', callbacks); +} +function patchCustomElements(_global) { + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); } /** @@ -2923,7 +3070,10 @@ Zone.__load_patch('EventTarget', function (global, Zone, api) { Zone.__load_patch('on_property', function (global, Zone, api) { propertyDescriptorPatch(api, global); propertyPatch(); +}); +Zone.__load_patch('customElements', function (global, Zone, api) { registerElementPatch(global); + patchCustomElements(global); }); Zone.__load_patch('canvas', function (global) { var HTMLCanvasElement = global['HTMLCanvasElement']; @@ -2942,6 +3092,7 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_LISTENER = zoneSymbol('xhrListener'); var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { @@ -2950,9 +3101,9 @@ Zone.__load_patch('XHR', function (global, Zone) { var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { - var XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } @@ -2960,9 +3111,10 @@ Zone.__load_patch('XHR', function (global, Zone) { var READY_STATE_CHANGE = 'readystatechange'; var SCHEDULED = 'scheduled'; function scheduleTask(task) { - XMLHttpRequest[XHR_SCHEDULED] = false; var data = task.data; var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; // remove existing event listener var listener = target[XHR_LISTENER]; if (!oriAddListener) { @@ -2976,8 +3128,35 @@ Zone.__load_patch('XHR', function (global, Zone) { if (target.readyState === target.DONE) { // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && XMLHttpRequest[XHR_SCHEDULED] && task.state === SCHEDULED) { - task.invoke(); + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target['__zone_symbol__loadfalse']; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target['__zone_symbol__loadfalse']; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } }; @@ -2987,7 +3166,7 @@ Zone.__load_patch('XHR', function (global, Zone) { target[XHR_TASK] = task; } sendNative.apply(target, data.args); - XMLHttpRequest[XHR_SCHEDULED] = true; + target[XHR_SCHEDULED] = true; return task; } function placeholderCallback() { } @@ -3004,24 +3183,32 @@ Zone.__load_patch('XHR', function (global, Zone) { return openNative.apply(self, args); }; }); var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); } else { - var options = { - target: self, - url: self[XHR_URL], - isPeriodic: false, - delay: null, - args: args, - aborted: false - }; - return scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } } }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self) { + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { var task = findPendingTask(self); if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. @@ -3033,6 +3220,10 @@ Zone.__load_patch('XHR', function (global, Zone) { } task.zone.cancelTask(task); } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no // task // to cancel. Do nothing. @@ -3069,6 +3260,20 @@ Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { } }); +/** + * @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.__load_patch('node_util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + setShouldCopySymbolProperties(true); +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -3088,6 +3293,15 @@ Zone.__load_patch('EventEmitter', function (global) { // same callback, same capture, same event name, just return return task.callback === delegate || task.callback.listener === delegate; }; + var eventNameToString = function (eventName) { + if (typeof eventName === 'string') { + return eventName; + } + if (!eventName) { + return ''; + } + return eventName.toString().replace('(', '_').replace(')', '_'); + }; function patchEventEmitterMethods(obj) { var result = patchEventTarget(global, [obj], { useG: false, @@ -3098,7 +3312,8 @@ Zone.__load_patch('EventEmitter', function (global) { listeners: EE_LISTENERS, chkDup: false, rt: true, - diff: compareTaskCallbackVsDelegate + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; @@ -3163,11 +3378,6 @@ Zone.__load_patch('fs', function () { */ var set = 'set'; var clear = 'clear'; -Zone.__load_patch('node_util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; -}); Zone.__load_patch('node_timers', function (global, Zone) { // Timers var globalUseTimeoutFromTimer = false; diff --git a/dist/zone-node.js b/dist/zone-node.js index c857c893c..8bbe1e846 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -19,7 +19,6 @@ * found in the LICENSE file at https://angular.io/license */ var Zone$1 = (function (global) { - var FUNCTION = 'function'; var performance = global['performance']; function mark(name) { performance && performance['mark'] && performance['mark'](name); @@ -28,12 +27,26 @@ var Zone$1 = (function (global) { performance && performance['measure'] && performance['measure'](name, label); } mark('Zone'); + var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; if (global['Zone']) { - throw new Error('Zone already loaded.'); + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } var Zone = /** @class */ (function () { function Zone(parent, zoneSpec) { - this._properties = null; this._parent = parent; this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; this._properties = zoneSpec && zoneSpec.properties || {}; @@ -76,7 +89,9 @@ var Zone$1 = (function (global) { }); Zone.__load_patch = function (name, fn) { if (patches.hasOwnProperty(name)) { - throw Error('Already loaded patch: ' + name); + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } else if (!global['__Zone_disable_' + name]) { var perfName = 'Zone:' + name; @@ -120,7 +135,7 @@ var Zone$1 = (function (global) { return this._zoneDelegate.fork(this, zoneSpec); }; Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== FUNCTION) { + if (typeof callback !== 'function') { throw new Error('Expecting function got: ' + callback); } var _callback = this._zoneDelegate.intercept(this, callback, source); @@ -130,9 +145,6 @@ var Zone$1 = (function (global) { }; }; Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = undefined; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); @@ -143,8 +155,6 @@ var Zone$1 = (function (global) { }; Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { if (applyThis === void 0) { applyThis = null; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { try { @@ -168,10 +178,7 @@ var Zone$1 = (function (global) { // https://github.com/angular/zone.js/issues/778, sometimes eventTask // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - // we have to define an variable here, if not - // typescript compiler will complain below - var isNotScheduled = task.state === notScheduled; - if (isNotScheduled && task.type === eventTask) { + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { return; } var reEntryGuard = task.state != running; @@ -182,7 +189,7 @@ var Zone$1 = (function (global) { _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = null; + task.cancelFn = undefined; } try { return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); @@ -218,8 +225,7 @@ var Zone$1 = (function (global) { var newZone = this; while (newZone) { if (newZone === task.zone) { - throw Error("can not reschedule task to " + this - .name + " which is descendants of the original zone " + task.zone.name); + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); } newZone = newZone.parent; } @@ -249,7 +255,7 @@ var Zone$1 = (function (global) { return task; }; Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, null)); + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); }; Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); @@ -290,16 +296,14 @@ var Zone$1 = (function (global) { }()); var DELEGATE_ZS = { name: '', - onHasTask: function (delegate, _, target, hasTaskState) { - return delegate.hasTask(target, hasTaskState); - }, + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, - onCancelTask: function (delegate, _, target, task) { - return delegate.cancelTask(target, task); - } + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { @@ -327,8 +331,8 @@ var Zone$1 = (function (global) { zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = - zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); this._invokeTaskZS = @@ -383,8 +387,7 @@ var Zone$1 = (function (global) { callback; }; ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? - this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.handleError = function (targetZone, error) { @@ -416,8 +419,7 @@ var Zone$1 = (function (global) { return returnTask; }; ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.cancelTask = function (targetZone, task) { @@ -437,7 +439,7 @@ var Zone$1 = (function (global) { // hasTask should not throw error so other ZoneDelegate // can still trigger hasTask callback try { - return this._hasTaskZS && + this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } catch (err) { @@ -527,14 +529,12 @@ var Zone$1 = (function (global) { } } else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? - ' or \'' + fromState2 + '\'' : - '') + ", was '" + this._state + "'."); + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); } }; ZoneTask.prototype.toString = function () { if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId; + return this.data.handleId.toString(); } else { return Object.prototype.toString.call(this); @@ -575,7 +575,13 @@ var Zone$1 = (function (global) { } } if (nativeMicroTaskQueuePromise) { - nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue); + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); } else { global[symbolSetTimeout](drainMicroTaskQueue, 0); @@ -622,12 +628,13 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - bindArguments: function () { return null; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === FUNCTION) { + if (NativePromise && typeof NativePromise.resolve === 'function') { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, @@ -643,6 +650,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -785,7 +802,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var queue = promise[symbolValue]; promise[symbolValue] = value; if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally + // the promise is generated by Promise.prototype.finally if (state === RESOLVED) { // the state is resolved, should ignore the value // and use parent promise value @@ -869,7 +886,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { chainPromise[symbolParentPromiseState] = promiseState; } // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); resolvePromise(chainPromise, true, value); } catch (error) { @@ -904,6 +923,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { return resolvePromise(new this(null), REJECTED, error); }; ZoneAwarePromise.race = function (values) { + var e_1, _a; var resolve; var reject; var promise = new this(function (res, rej) { @@ -916,40 +936,70 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); } - value.then(onResolve, onReject); + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + } + finally { if (e_1) throw e_1.error; } } return promise; }; ZoneAwarePromise.all = function (values) { + var e_2, _a; var resolve; var reject; var promise = new this(function (res, rej) { resolve = res; reject = rej; }); - var count = 0; + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; + var _loop_2 = function (value) { if (!isThenable(value)) { - value = this.resolve(value); + value = this_1.resolve(value); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { resolve(resolvedValues); } - }; })(count), reject); - count++; + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + _loop_2(value); + } } - if (!count) + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { resolve(resolvedValues); + } return promise; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { @@ -1045,25 +1095,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; Ctor[symbolThenPatched] = true; } - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } + api.patchThen = patchThen; if (NativePromise) { patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global['fetch'] = zoneify(fetch_1); - } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; @@ -1163,9 +1197,23 @@ var wrapFn = function (event) { } var target = this || event.target || _global; var listener = target[eventNameSymbol]; - var result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } return result; }; @@ -1183,6 +1231,10 @@ function patchProperty(obj, prop, prototype) { if (!desc || !desc.configurable) { return; } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } // A property descriptor cannot have getter/setter and be writable // deleting the writable and value properties avoids this error: // @@ -1260,6 +1312,7 @@ function patchProperty(obj, prop, prototype) { return null; }; ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1282,6 +1335,33 @@ function patchOnProperties(obj, properties, prototype) { var originalInstanceKey = zoneSymbol('originalInstance'); // wrap some native API on `window` +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +var shouldCopySymbolProperties = false; +function setShouldCopySymbolProperties(flag) { + shouldCopySymbolProperties = flag; +} function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { @@ -1292,7 +1372,7 @@ function patchMethod(target, name, patchFn) { proto = target; } var delegateName = zoneSymbol(name); - var delegate; + var delegate = null; if (proto && !(delegate = proto[delegateName])) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable @@ -1304,6 +1384,9 @@ function patchMethod(target, name, patchFn) { return patchDelegate_1(this, arguments); }; attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } } } return delegate; @@ -1322,7 +1405,7 @@ function patchMacroTask(obj, funcName, metaCreator) { setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1409,6 +1492,20 @@ Zone.__load_patch('toString', function (global) { }; }); +/** + * @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.__load_patch('node_util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + setShouldCopySymbolProperties(true); +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1420,6 +1517,21 @@ Zone.__load_patch('toString', function (global) { * @fileoverview * @suppress {missingRequire} */ +var passiveSupported = false; +if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { useG: true @@ -1555,6 +1667,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (proto[zoneSymbolAddEventListener]) { return false; } + var eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask // so we do not need to create a new object just for pass some data var taskData = {}; @@ -1570,12 +1683,24 @@ function patchEventTarget(_global, apis, patchOptions) { nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = proto[patchOptions.prepend]; } - var customScheduleGlobal = function () { + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { @@ -1616,6 +1741,7 @@ function patchEventTarget(_global, apis, patchOptions) { return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { @@ -1638,10 +1764,15 @@ function patchEventTarget(_global, apis, patchOptions) { if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; + var eventName = arguments[0]; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } // don't create the bind delegate function for handleEvent // case here to improve addEventListener performance // we will create the bind delegate when invoke @@ -1655,7 +1786,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { return; } - var eventName = arguments[0]; var options = arguments[2]; if (blackListedEvents) { // check black list @@ -1685,8 +1815,8 @@ function patchEventTarget(_global, apis, patchOptions) { var symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; zoneSymbolEventNames$1[eventName] = {}; @@ -1721,7 +1851,8 @@ function patchEventTarget(_global, apis, patchOptions) { source = targetSource[eventName]; } if (!source) { - source = constructorName + addSource + eventName; + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); } // do not create a new object as task.data to pass those things // just use the global shared one @@ -1736,7 +1867,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.capture = capture; taskData.eventName = eventName; taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; @@ -1754,7 +1885,11 @@ function patchEventTarget(_global, apis, patchOptions) { if (once) { options.once = true; } - task.options = options; + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } task.target = target; task.capture = capture; task.eventName = eventName; @@ -1839,7 +1974,7 @@ function patchEventTarget(_global, apis, patchOptions) { var target = this || _global; var eventName = arguments[0]; var listeners = []; - var tasks = findEventTasks(target, eventName); + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); for (var i = 0; i < tasks.length; i++) { var task = tasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; @@ -1949,6 +2084,15 @@ Zone.__load_patch('EventEmitter', function (global) { // same callback, same capture, same event name, just return return task.callback === delegate || task.callback.listener === delegate; }; + var eventNameToString = function (eventName) { + if (typeof eventName === 'string') { + return eventName; + } + if (!eventName) { + return ''; + } + return eventName.toString().replace('(', '_').replace(')', '_'); + }; function patchEventEmitterMethods(obj) { var result = patchEventTarget(global, [obj], { useG: false, @@ -1959,7 +2103,8 @@ Zone.__load_patch('EventEmitter', function (global) { listeners: EE_LISTENERS, chkDup: false, rt: true, - diff: compareTaskCallbackVsDelegate + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; @@ -2068,9 +2213,9 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, setName, function (delegate) { return function (self, args) { if (typeof args[0] === 'function') { var options = { - handleId: null, isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, args: args }; var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); @@ -2151,11 +2296,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ var set = 'set'; var clear = 'clear'; -Zone.__load_patch('node_util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; -}); Zone.__load_patch('node_timers', function (global, Zone) { // Timers var globalUseTimeoutFromTimer = false; diff --git a/dist/zone-patch-jsonp.js b/dist/zone-patch-jsonp.js index 4dcf57382..d7e75f2b8 100644 --- a/dist/zone-patch-jsonp.js +++ b/dist/zone-patch-jsonp.js @@ -71,9 +71,10 @@ Zone.__load_patch('jsonp', function (global, Zone, api) { } }); api.patchMethod(options.jsonp, options.sendFuncName, function (delegate) { return function (self, args) { - global[api.symbol('jsonpTask')] = Zone.current.scheduleMacroTask('jsonp', noop, {}, function (task) { - return delegate.apply(self, args); - }, noop); + global[api.symbol('jsonpTask')] = + Zone.current.scheduleMacroTask('jsonp', noop, {}, function (task) { + return delegate.apply(self, args); + }, noop); }; }); }; }); diff --git a/dist/zone-patch-resize-observer.js b/dist/zone-patch-resize-observer.js index e80c32588..b85d7ee9f 100644 --- a/dist/zone-patch-resize-observer.js +++ b/dist/zone-patch-resize-observer.js @@ -39,6 +39,7 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { if (callback) { args[0] = function (entries, observer) { var _this = this; + var e_1, _a; var zones = {}; var currZone = Zone.current; try { @@ -71,7 +72,6 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { callback.call(_this, zoneEntriesInfo.entries, observer); } }); - var e_1, _a; }; } return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); @@ -109,7 +109,9 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { api.patchMethod(ResizeObserver.prototype, 'disconnect', function (delegate) { return function (self, args) { var targets = self[resizeObserverSymbol]; if (targets) { - targets.forEach(function (target) { target[resizeObserverSymbol] = undefined; }); + targets.forEach(function (target) { + target[resizeObserverSymbol] = undefined; + }); self[resizeObserverSymbol] = undefined; } return delegate.apply(self, args); diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js index 4e3ef0583..4762c8bc7 100644 --- a/dist/zone-patch-resize-observer.min.js +++ b/dist/zone-patch-resize-observer.min.js @@ -1 +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){var n="function"==typeof Symbol&&e[Symbol.iterator],r=0;return n?n.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o=this,a={},c=r.current;try{for(var f=e(n),l=f.next();!l.done;l=f.next()){var v=l.value,p=v.target[i];p||(p=c);var s=a[p.name];s||(a[p.name]=s={entries:[],zone:p}),s.entries.push(v)}}catch(h){d={error:h}}finally{try{l&&!l.done&&(y=f["return"])&&y.call(f)}finally{if(d)throw d.error}}Object.keys(a).forEach(function(e){var n=a[e];n.zone!==r.current?n.zone.run(u,o,[n.entries,t],"ResizeObserver"):u.call(o,n.entries,t)});var d,y}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o,a,c=this,f={},l=r.current;try{for(var p=e(n),v=p.next();!v.done;v=p.next()){var s=v.value,h=s.target[i];h||(h=l);var d=f[h.name];d||(f[h.name]=d={entries:[],zone:h}),d.entries.push(s)}}catch(y){o={error:y}}finally{try{v&&!v.done&&(a=p["return"])&&a.call(p)}finally{if(o)throw o.error}}Object.keys(f).forEach(function(e){var n=f[e];n.zone!==r.current?n.zone.run(u,c,[n.entries,t],"ResizeObserver"):u.call(c,n.entries,t)})}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u 0 ? args[0] : undefined; - if (typeof subjectOrSubjectFactory !== 'function') { - var originalFactory_1 = subjectOrSubjectFactory; - subjectOrSubjectFactory = function () { - return originalFactory_1; - }; - } - args[0] = function () { - var subject; - if (_zone && _zone !== Zone.current) { - subject = _zone.run(subjectOrSubjectFactory, this, arguments); - } - else { - subject = subjectOrSubjectFactory.apply(this, arguments); - } - if (subject && _zone) { - subject._zone = _zone; - } - return subject; - }; - var observable = factory.apply(this, args); - patchObservableInstance(observable); - return observable; - }; - }; - var patchImmediate = function (asap$$1) { - if (!asap$$1) { - return; - } - var scheduleSymbol = symbol('scheduleSymbol'); - var zoneSymbol = symbol('zone'); - if (asap$$1[scheduleSymbol]) { - return; - } - var schedule = asap$$1[scheduleSymbol] = asap$$1.schedule; - asap$$1.schedule = function () { - var args = Array.prototype.slice.call(arguments); - var work = args.length > 0 ? args[0] : undefined; - var delay = args.length > 1 ? args[1] : 0; - var state = (args.length > 2 ? args[2] : undefined) || {}; - state[zoneSymbol] = Zone.current; - var patchedWork = function () { - var workArgs = Array.prototype.slice.call(arguments); - var action = workArgs.length > 0 ? workArgs[0] : undefined; - var scheduleZone = action && action[zoneSymbol]; - if (scheduleZone && scheduleZone !== Zone.current) { - return scheduleZone.runGuarded(work, this, arguments); - } - else { - return work.apply(this, arguments); - } - }; - return schedule.call(this, patchedWork, delay, state); - }; - }; patchObservable(); patchSubscription(); patchSubscriber(); - patchObservableFactoryCreator(Observable.Observable, 'bindCallback'); - patchObservableFactoryCreator(Observable.Observable, 'bindNodeCallback'); - patchObservableFactory(Observable.Observable, 'defer'); - patchObservableFactory(Observable.Observable, 'forkJoin'); - patchObservableFactoryArgs(Observable.Observable, 'fromEventPattern'); - patchMulticast(); - patchImmediate(asap.asap); }); }))); diff --git a/dist/zone-patch-rxjs.min.js b/dist/zone-patch-rxjs.min.js index 8a509ada3..ead0815d5 100644 --- a/dist/zone-patch-rxjs.min.js +++ b/dist/zone-patch-rxjs.min.js @@ -1 +1 @@ -!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("rxjs/add/observable/bindCallback"),require("rxjs/add/observable/bindNodeCallback"),require("rxjs/add/observable/defer"),require("rxjs/add/observable/forkJoin"),require("rxjs/add/observable/fromEventPattern"),require("rxjs/add/operator/multicast"),require("rxjs/Observable"),require("rxjs/scheduler/asap"),require("rxjs/Subscriber"),require("rxjs/Subscription"),require("rxjs/symbol/rxSubscriber")):"function"==typeof define&&define.amd?define(["rxjs/add/observable/bindCallback","rxjs/add/observable/bindNodeCallback","rxjs/add/observable/defer","rxjs/add/observable/forkJoin","rxjs/add/observable/fromEventPattern","rxjs/add/operator/multicast","rxjs/Observable","rxjs/scheduler/asap","rxjs/Subscriber","rxjs/Subscription","rxjs/symbol/rxSubscriber"],e):e(null,null,null,null,null,null,r.Rx,r.Rx.Scheduler,r.Rx,r.Rx,r.Rx.Symbol)}(this,function(r,e,t,n,i,u,o,s,b,c,a){"use strict";Zone.__load_patch("rxjs",function(r,e){function t(r,e,t){if(r){if(r instanceof b.Subscriber)return r;if(r[a.rxSubscriber])return r[a.rxSubscriber]()}return r||e||t?new b.Subscriber(r,e,t):new b.Subscriber(p)}var n=e.__symbol__,i="rxjs.Subscriber.next",u="rxjs.Subscriber.error",l="rxjs.Subscriber.complete",f=Object.defineProperties,p={closed:!0,next:function(r){},error:function(r){throw r},complete:function(){}},v=function(){var r=o.Observable.prototype,i=n("subscribe"),u=n("_subscribe"),s=r[u]=r._subscribe,b=r[i]=r.subscribe;f(o.Observable.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneSource:{value:null,writable:!0,configurable:!0},_zoneSubscribe:{value:null,writable:!0,configurable:!0},source:{configurable:!0,get:function(){return this._zoneSource},set:function(r){this._zone=e.current,this._zoneSource=r}},_subscribe:{configurable:!0,get:function(){if(this._zoneSubscribe)return this._zoneSubscribe;if(this.constructor===o.Observable)return s;var r=Object.getPrototypeOf(this);return r&&r._subscribe},set:function(r){this._zone=e.current,this._zoneSubscribe=r}},subscribe:{writable:!0,configurable:!0,value:function(r,n,i){var u=this._zone;return u&&u!==e.current?u.run(b,this,[t(r,n,i)]):b.call(this,r,n,i)}}})},d=function(){var r=n("unsubscribe"),t=c.Subscription.prototype[r]=c.Subscription.prototype.unsubscribe;f(c.Subscription.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneUnsubscribe:{value:null,writable:!0,configurable:!0},_unsubscribe:{get:function(){if(this._zoneUnsubscribe)return this._zoneUnsubscribe;var r=Object.getPrototypeOf(this);return r&&r._unsubscribe},set:function(r){this._zone=e.current,this._zoneUnsubscribe=r}},unsubscribe:{writable:!0,configurable:!0,value:function(){var r=this._zone;r&&r!==e.current?r.run(t,this):t.apply(this)}}})},h=function(){var r=b.Subscriber.prototype.next,t=b.Subscriber.prototype.error,n=b.Subscriber.prototype.complete;Object.defineProperty(b.Subscriber.prototype,"destination",{configurable:!0,get:function(){return this._zoneDestination},set:function(r){this._zone=e.current,this._zoneDestination=r}}),b.Subscriber.prototype.next=function(){var t=e.current,n=this._zone;return n&&n!==t?n.run(r,this,arguments,i):r.apply(this,arguments)},b.Subscriber.prototype.error=function(){var r=e.current,n=this._zone;return n&&n!==r?n.run(t,this,arguments,u):t.apply(this,arguments)},b.Subscriber.prototype.complete=function(){var r=e.current,t=this._zone;return t&&t!==r?t.run(n,this,arguments,l):n.apply(this,arguments)}},y=function(r){r._zone=e.current},x=function(r,e){var t=n(e);if(!r[t]){var i=r[t]=r[e];i&&(r[e]=function(){var r=i.apply(this,arguments);return function(){var e=r.apply(this,arguments);return y(e),e}})}},_=function(r,e){var t=n(e);if(!r[t]){var i=r[t]=r[e];i&&(r[e]=function(){var r=i.apply(this,arguments);return y(r),r})}},S=function(r,t){var i=n(t);if(!r[i]){var u=r[i]=r[t];u&&(r[t]=function(){for(var r=e.current,t=Array.prototype.slice.call(arguments),n=function(n){var i=t[n];"function"==typeof i&&(t[n]=function(){var t=Array.prototype.slice.call(arguments),n=e.current;return r&&n&&r!==n?r.run(i,this,t):i.apply(this,t)})},i=0;i0?t[0]:void 0;if("function"!=typeof n){var i=n;n=function(){return i}}t[0]=function(){var t;return t=r&&r!==e.current?r.run(n,this,arguments):n.apply(this,arguments),t&&r&&(t._zone=r),t};var o=u.apply(this,t);return y(o),o})}},z=function(r){if(r){var t=n("scheduleSymbol"),i=n("zone");if(!r[t]){var u=r[t]=r.schedule;r.schedule=function(){var r=Array.prototype.slice.call(arguments),t=r.length>0?r[0]:void 0,n=r.length>1?r[1]:0,o=(r.length>2?r[2]:void 0)||{};o[i]=e.current;var s=function(){var r=Array.prototype.slice.call(arguments),n=r.length>0?r[0]:void 0,u=n&&n[i];return u&&u!==e.current?u.runGuarded(t,this,arguments):t.apply(this,arguments)};return u.call(this,s,n,o)}}}};v(),d(),h(),x(o.Observable,"bindCallback"),x(o.Observable,"bindNodeCallback"),_(o.Observable,"defer"),_(o.Observable,"forkJoin"),S(o.Observable,"fromEventPattern"),j(),z(s.asap)})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("rxjs")):"function"==typeof define&&define.amd?define(["rxjs"],t):t(e.rxjs)}(this,function(e){"use strict";Zone.__load_patch("rxjs",function(t,r,n){var o=r.__symbol__,i="rxjs.Subscriber.next",u="rxjs.Subscriber.error",s="rxjs.Subscriber.complete",c=Object.defineProperties,b=function(){var t=e.Observable.prototype,n=o("_subscribe"),i=t[n]=t._subscribe;c(e.Observable.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneSource:{value:null,writable:!0,configurable:!0},_zoneSubscribe:{value:null,writable:!0,configurable:!0},source:{configurable:!0,get:function(){return this._zoneSource},set:function(e){this._zone=r.current,this._zoneSource=e}},_subscribe:{configurable:!0,get:function(){if(this._zoneSubscribe)return this._zoneSubscribe;if(this.constructor===e.Observable)return i;var t=Object.getPrototypeOf(this);return t&&t._subscribe},set:function(e){this._zone=r.current,this._zoneSubscribe=function(){if(this._zone&&this._zone!==r.current){var t=this._zone.run(e,this,arguments);if(t&&"function"==typeof t){var n=this._zone;return function(){return n!==r.current?n.run(t,this,arguments):t.apply(this,arguments)}}return t}return e.apply(this,arguments)}}},subjectFactory:{get:function(){return this._zoneSubjectFactory},set:function(e){var t=this._zone;this._zoneSubjectFactory=function(){return t&&t!==r.current?t.run(e,this,arguments):e.apply(this,arguments)}}}})};n.patchMethod(e.Observable.prototype,"lift",function(e){return function(t,o){var i=e.apply(t,o);return i.operator&&(i.operator._zone=r.current,n.patchMethod(i.operator,"call",function(e){return function(t,n){return t._zone&&t._zone!==r.current?t._zone.run(e,t,n):e.apply(t,n)}})),i}});var a=function(){c(e.Subscription.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneUnsubscribe:{value:null,writable:!0,configurable:!0},_unsubscribe:{get:function(){if(this._zoneUnsubscribe)return this._zoneUnsubscribe;var e=Object.getPrototypeOf(this);return e&&e._unsubscribe},set:function(e){this._zone=r.current,this._zoneUnsubscribe=function(){return this._zone&&this._zone!==r.current?this._zone.run(e,this,arguments):e.apply(this,arguments)}}}})},p=function(){var t=e.Subscriber.prototype.next,n=e.Subscriber.prototype.error,o=e.Subscriber.prototype.complete;Object.defineProperty(e.Subscriber.prototype,"destination",{configurable:!0,get:function(){return this._zoneDestination},set:function(e){this._zone=r.current,this._zoneDestination=e}}),e.Subscriber.prototype.next=function(){var e=r.current,n=this._zone;return n&&n!==e?n.run(t,this,arguments,i):t.apply(this,arguments)},e.Subscriber.prototype.error=function(){var e=r.current,t=this._zone;return t&&t!==e?t.run(n,this,arguments,u):n.apply(this,arguments)},e.Subscriber.prototype.complete=function(){var e=r.current,t=this._zone;return t&&t!==e?t.run(o,this,arguments,s):o.apply(this,arguments)}};b(),a(),p()})}); \ No newline at end of file diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index 7a8a81e5e..0f88dd882 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -19,7 +19,6 @@ * found in the LICENSE file at https://angular.io/license */ var Zone$1 = (function (global) { - var FUNCTION = 'function'; var performance = global['performance']; function mark(name) { performance && performance['mark'] && performance['mark'](name); @@ -28,12 +27,26 @@ var Zone$1 = (function (global) { performance && performance['measure'] && performance['measure'](name, label); } mark('Zone'); + var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; if (global['Zone']) { - throw new Error('Zone already loaded.'); + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } var Zone = /** @class */ (function () { function Zone(parent, zoneSpec) { - this._properties = null; this._parent = parent; this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; this._properties = zoneSpec && zoneSpec.properties || {}; @@ -76,7 +89,9 @@ var Zone$1 = (function (global) { }); Zone.__load_patch = function (name, fn) { if (patches.hasOwnProperty(name)) { - throw Error('Already loaded patch: ' + name); + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } else if (!global['__Zone_disable_' + name]) { var perfName = 'Zone:' + name; @@ -120,7 +135,7 @@ var Zone$1 = (function (global) { return this._zoneDelegate.fork(this, zoneSpec); }; Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== FUNCTION) { + if (typeof callback !== 'function') { throw new Error('Expecting function got: ' + callback); } var _callback = this._zoneDelegate.intercept(this, callback, source); @@ -130,9 +145,6 @@ var Zone$1 = (function (global) { }; }; Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = undefined; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); @@ -143,8 +155,6 @@ var Zone$1 = (function (global) { }; Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { if (applyThis === void 0) { applyThis = null; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { try { @@ -168,10 +178,7 @@ var Zone$1 = (function (global) { // https://github.com/angular/zone.js/issues/778, sometimes eventTask // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - // we have to define an variable here, if not - // typescript compiler will complain below - var isNotScheduled = task.state === notScheduled; - if (isNotScheduled && task.type === eventTask) { + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { return; } var reEntryGuard = task.state != running; @@ -182,7 +189,7 @@ var Zone$1 = (function (global) { _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = null; + task.cancelFn = undefined; } try { return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); @@ -218,8 +225,7 @@ var Zone$1 = (function (global) { var newZone = this; while (newZone) { if (newZone === task.zone) { - throw Error("can not reschedule task to " + this - .name + " which is descendants of the original zone " + task.zone.name); + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); } newZone = newZone.parent; } @@ -249,7 +255,7 @@ var Zone$1 = (function (global) { return task; }; Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, null)); + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); }; Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); @@ -290,16 +296,14 @@ var Zone$1 = (function (global) { }()); var DELEGATE_ZS = { name: '', - onHasTask: function (delegate, _, target, hasTaskState) { - return delegate.hasTask(target, hasTaskState); - }, + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, - onCancelTask: function (delegate, _, target, task) { - return delegate.cancelTask(target, task); - } + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { @@ -327,8 +331,8 @@ var Zone$1 = (function (global) { zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = - zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); this._invokeTaskZS = @@ -383,8 +387,7 @@ var Zone$1 = (function (global) { callback; }; ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? - this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.handleError = function (targetZone, error) { @@ -416,8 +419,7 @@ var Zone$1 = (function (global) { return returnTask; }; ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.cancelTask = function (targetZone, task) { @@ -437,7 +439,7 @@ var Zone$1 = (function (global) { // hasTask should not throw error so other ZoneDelegate // can still trigger hasTask callback try { - return this._hasTaskZS && + this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } catch (err) { @@ -527,14 +529,12 @@ var Zone$1 = (function (global) { } } else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? - ' or \'' + fromState2 + '\'' : - '') + ", was '" + this._state + "'."); + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); } }; ZoneTask.prototype.toString = function () { if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId; + return this.data.handleId.toString(); } else { return Object.prototype.toString.call(this); @@ -575,7 +575,13 @@ var Zone$1 = (function (global) { } } if (nativeMicroTaskQueuePromise) { - nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue); + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); } else { global[symbolSetTimeout](drainMicroTaskQueue, 0); @@ -622,12 +628,13 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - bindArguments: function () { return null; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === FUNCTION) { + if (NativePromise && typeof NativePromise.resolve === 'function') { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, @@ -643,6 +650,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -785,7 +802,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var queue = promise[symbolValue]; promise[symbolValue] = value; if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally + // the promise is generated by Promise.prototype.finally if (state === RESOLVED) { // the state is resolved, should ignore the value // and use parent promise value @@ -869,7 +886,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { chainPromise[symbolParentPromiseState] = promiseState; } // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); resolvePromise(chainPromise, true, value); } catch (error) { @@ -904,6 +923,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { return resolvePromise(new this(null), REJECTED, error); }; ZoneAwarePromise.race = function (values) { + var e_1, _a; var resolve; var reject; var promise = new this(function (res, rej) { @@ -916,40 +936,70 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; }; ZoneAwarePromise.all = function (values) { + var e_2, _a; var resolve; var reject; var promise = new this(function (res, rej) { resolve = res; reject = rej; }); - var count = 0; + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; + var _loop_2 = function (value) { if (!isThenable(value)) { - value = this.resolve(value); + value = this_1.resolve(value); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { resolve(resolvedValues); } - }; })(count), reject); - count++; + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + _loop_2(value); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } } - if (!count) + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { resolve(resolvedValues); + } return promise; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { @@ -1045,31 +1095,112 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; Ctor[symbolThenPatched] = true; } - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } + api.patchThen = patchThen; if (NativePromise) { patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global['fetch'] = zoneify(fetch_1); - } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; return ZoneAwarePromise; }); +/** + * @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.__load_patch('fetch', function (global, Zone, api) { + var fetch = global['fetch']; + var ZoneAwarePromise = global.Promise; + var symbolThenPatched = api.symbol('thenPatched'); + var fetchTaskScheduling = api.symbol('fetchTaskScheduling'); + var fetchTaskAborting = api.symbol('fetchTaskAborting'); + if (typeof fetch !== 'function') { + return; + } + var OriginalAbortController = global['AbortController']; + var supportAbort = typeof OriginalAbortController === 'function'; + var abortNative = null; + if (supportAbort) { + global['AbortController'] = function () { + var abortController = new OriginalAbortController(); + var signal = abortController.signal; + signal.abortController = abortController; + return abortController; + }; + abortNative = api.patchMethod(OriginalAbortController.prototype, 'abort', function (delegate) { return function (self, args) { + if (self.task) { + return self.task.zone.cancelTask(self.task); + } + return delegate.apply(self, args); + }; }); + } + var placeholder = function () { }; + global['fetch'] = function () { + var _this = this; + var args = Array.prototype.slice.call(arguments); + var options = args.length > 1 ? args[1] : null; + var signal = options && options.signal; + return new Promise(function (res, rej) { + var task = Zone.current.scheduleMacroTask('fetch', placeholder, args, function () { + var fetchPromise; + var zone = Zone.current; + try { + zone[fetchTaskScheduling] = true; + fetchPromise = fetch.apply(_this, args); + } + catch (error) { + rej(error); + return; + } + finally { + zone[fetchTaskScheduling] = false; + } + if (!(fetchPromise instanceof ZoneAwarePromise)) { + var ctor = fetchPromise.constructor; + if (!ctor[symbolThenPatched]) { + api.patchThen(ctor); + } + } + fetchPromise.then(function (resource) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + res(resource); + }, function (error) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + rej(error); + }); + }, function () { + if (!supportAbort) { + rej('No AbortController supported, can not cancel fetch'); + return; + } + if (signal && signal.abortController && !signal.aborted && + typeof signal.abortController.abort === 'function' && abortNative) { + try { + Zone.current[fetchTaskAborting] = true; + abortNative.call(signal.abortController); + } + finally { + Zone.current[fetchTaskAborting] = false; + } + } + else { + rej('cancel fetch need a AbortController.signal'); + } + }); + if (signal && signal.abortController) { + signal.abortController.task = task; + } + }); + }; +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1185,9 +1316,23 @@ var wrapFn = function (event) { } var target = this || event.target || _global; var listener = target[eventNameSymbol]; - var result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } return result; }; @@ -1205,6 +1350,10 @@ function patchProperty(obj, prop, prototype) { if (!desc || !desc.configurable) { return; } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } // A property descriptor cannot have getter/setter and be writable // deleting the writable and value properties avoids this error: // @@ -1282,6 +1431,7 @@ function patchProperty(obj, prop, prototype) { return null; }; ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1372,6 +1522,31 @@ function patchClass(className) { } } } +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +var shouldCopySymbolProperties = false; + function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { @@ -1382,7 +1557,7 @@ function patchMethod(target, name, patchFn) { proto = target; } var delegateName = zoneSymbol(name); - var delegate; + var delegate = null; if (proto && !(delegate = proto[delegateName])) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable @@ -1394,6 +1569,9 @@ function patchMethod(target, name, patchFn) { return patchDelegate_1(this, arguments); }; attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } } } return delegate; @@ -1412,7 +1590,7 @@ function patchMacroTask(obj, funcName, metaCreator) { setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1426,6 +1604,17 @@ function attachOriginToPatched(patched, original) { } var isDetectedIEOrEdge = false; var ieOrEdge = false; +function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; +} function isIEOrEdge() { if (isDetectedIEOrEdge) { return ieOrEdge; @@ -1507,6 +1696,21 @@ Zone.__load_patch('toString', function (global) { * @fileoverview * @suppress {missingRequire} */ +var passiveSupported = false; +if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { useG: true @@ -1642,6 +1846,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (proto[zoneSymbolAddEventListener]) { return false; } + var eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask // so we do not need to create a new object just for pass some data var taskData = {}; @@ -1657,12 +1862,24 @@ function patchEventTarget(_global, apis, patchOptions) { nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = proto[patchOptions.prepend]; } - var customScheduleGlobal = function () { + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { @@ -1703,6 +1920,7 @@ function patchEventTarget(_global, apis, patchOptions) { return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { @@ -1725,10 +1943,15 @@ function patchEventTarget(_global, apis, patchOptions) { if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; + var eventName = arguments[0]; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } // don't create the bind delegate function for handleEvent // case here to improve addEventListener performance // we will create the bind delegate when invoke @@ -1742,7 +1965,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { return; } - var eventName = arguments[0]; var options = arguments[2]; if (blackListedEvents) { // check black list @@ -1772,8 +1994,8 @@ function patchEventTarget(_global, apis, patchOptions) { var symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; zoneSymbolEventNames$1[eventName] = {}; @@ -1808,7 +2030,8 @@ function patchEventTarget(_global, apis, patchOptions) { source = targetSource[eventName]; } if (!source) { - source = constructorName + addSource + eventName; + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); } // do not create a new object as task.data to pass those things // just use the global shared one @@ -1823,7 +2046,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.capture = capture; taskData.eventName = eventName; taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; @@ -1841,7 +2064,11 @@ function patchEventTarget(_global, apis, patchOptions) { if (once) { options.once = true; } - task.options = options; + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } task.target = target; task.capture = capture; task.eventName = eventName; @@ -1926,7 +2153,7 @@ function patchEventTarget(_global, apis, patchOptions) { var target = this || _global; var eventName = arguments[0]; var listeners = []; - var tasks = findEventTasks(target, eventName); + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); for (var i = 0; i < tasks.length; i++) { var task = tasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; @@ -2082,9 +2309,9 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, setName, function (delegate) { return function (self, args) { if (typeof args[0] === 'function') { var options = { - handleId: null, isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, args: args }; var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); @@ -2199,7 +2426,7 @@ function propertyPatch() { }; Object.getOwnPropertyDescriptor = function (obj, prop) { var desc = _getOwnPropertyDescriptor(obj, prop); - if (isUnconfigurable(obj, prop)) { + if (desc && isUnconfigurable(obj, prop)) { desc.configurable = false; } return desc; @@ -2427,10 +2654,10 @@ var globalEventHandlersEventNames = [ 'wheel' ]; var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'fullscreenchange', + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange' + 'visibilitychange', 'resume' ]; var windowEventNames = [ 'absolutedeviceorientation', @@ -2542,7 +2769,7 @@ var websocketEventNames = ['close', 'error', 'open', 'message']; var workerEventNames = ['error', 'message']; var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { return onProperties; } var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); @@ -2567,13 +2794,14 @@ function propertyDescriptorPatch(api, _global) { } var supportsWebSocket = typeof WebSocket !== 'undefined'; if (canPatchViaPropertyDescriptor()) { - var ignoreProperties = _global.__Zone_ignore_on_properties; + var ignoreProperties = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); if (typeof internalWindow['SVGElement'] !== 'undefined') { patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); @@ -2595,9 +2823,9 @@ function propertyDescriptorPatch(api, _global) { } } patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget_1 = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + patchFilteredProperties(XMLHttpRequestEventTarget_1 && XMLHttpRequestEventTarget_1.prototype, XMLHttpRequestEventNames, ignoreProperties); } if (typeof IDBIndex !== 'undefined') { patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); @@ -2812,16 +3040,16 @@ function patchEvent(global, api) { * 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 && !isMix) || !('registerElement' in _global.document)) { +function patchCallbacks(target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { return; } - var _registerElement = document.registerElement; - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - document.registerElement = function (name, opts) { + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { if (opts && opts.prototype) { callbacks.forEach(function (callback) { - var source = 'Document.registerElement::' + callback; + var source = targetName + "." + method + "::" + callback; var prototype = opts.prototype; if (prototype.hasOwnProperty(callback)) { var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); @@ -2838,9 +3066,23 @@ function registerElementPatch(_global) { } }); } - return _registerElement.call(document, name, opts); + return nativeDelegate.call(target, name, opts, options); }; - attachOriginToPatched(document.registerElement, _registerElement); + attachOriginToPatched(target[method], nativeDelegate); +} +function registerElementPatch(_global) { + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + patchCallbacks(document, 'Document', 'registerElement', callbacks); +} +function patchCustomElements(_global) { + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); } /** @@ -2903,7 +3145,10 @@ Zone.__load_patch('EventTarget', function (global, Zone, api) { Zone.__load_patch('on_property', function (global, Zone, api) { propertyDescriptorPatch(api, global); propertyPatch(); +}); +Zone.__load_patch('customElements', function (global, Zone, api) { registerElementPatch(global); + patchCustomElements(global); }); Zone.__load_patch('canvas', function (global) { var HTMLCanvasElement = global['HTMLCanvasElement']; @@ -2922,6 +3167,7 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_LISTENER = zoneSymbol('xhrListener'); var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { @@ -2930,9 +3176,9 @@ Zone.__load_patch('XHR', function (global, Zone) { var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { - var XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } @@ -2940,9 +3186,10 @@ Zone.__load_patch('XHR', function (global, Zone) { var READY_STATE_CHANGE = 'readystatechange'; var SCHEDULED = 'scheduled'; function scheduleTask(task) { - XMLHttpRequest[XHR_SCHEDULED] = false; var data = task.data; var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; // remove existing event listener var listener = target[XHR_LISTENER]; if (!oriAddListener) { @@ -2956,8 +3203,35 @@ Zone.__load_patch('XHR', function (global, Zone) { if (target.readyState === target.DONE) { // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && XMLHttpRequest[XHR_SCHEDULED] && task.state === SCHEDULED) { - task.invoke(); + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target['__zone_symbol__loadfalse']; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target['__zone_symbol__loadfalse']; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } }; @@ -2967,7 +3241,7 @@ Zone.__load_patch('XHR', function (global, Zone) { target[XHR_TASK] = task; } sendNative.apply(target, data.args); - XMLHttpRequest[XHR_SCHEDULED] = true; + target[XHR_SCHEDULED] = true; return task; } function placeholderCallback() { } @@ -2984,24 +3258,32 @@ Zone.__load_patch('XHR', function (global, Zone) { return openNative.apply(self, args); }; }); var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); } else { - var options = { - target: self, - url: self[XHR_URL], - isPeriodic: false, - delay: null, - args: args, - aborted: false - }; - return scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } } }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self) { + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { var task = findPendingTask(self); if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. @@ -3013,6 +3295,10 @@ Zone.__load_patch('XHR', function (global, Zone) { } task.zone.cancelTask(task); } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no // task // to cancel. Do nothing. @@ -3229,6 +3515,7 @@ var ProxyZoneSpec = /** @class */ (function () { if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } this.defaultSpecDelegate = defaultSpecDelegate; this.name = 'ProxyZone'; + this._delegateSpec = null; this.properties = { 'ProxyZoneSpec': this }; this.propertyKeys = null; this.lastTaskState = null; @@ -4031,7 +4318,11 @@ var __spread = (undefined && undefined.__spread) || function () { } } } + lastCurrentTime = this._currentTime; this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } }; Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { if (limit === void 0) { limit = 20; } @@ -4120,14 +4411,14 @@ var __spread = (undefined && undefined.__spread) || function () { args[_i] = arguments[_i]; } fn.apply(global, args); - if (_this._lastError === null) { + if (_this._lastError === null) { // Success if (completers.onSuccess != null) { completers.onSuccess.apply(global); } // Flush microtasks only on success. _this.flushMicrotasks(); } - else { + else { // Failure if (completers.onError != null) { completers.onError.apply(global); } @@ -4426,23 +4717,23 @@ Zone.__load_patch('fakeasync', function (global, Zone, api) { ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); } /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ function fakeAsync(fn) { // Not using an arrow function to preserve context passed from call site return function () { diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index a95fbf996..5347637e2 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -19,7 +19,6 @@ * found in the LICENSE file at https://angular.io/license */ var Zone$1 = (function (global) { - var FUNCTION = 'function'; var performance = global['performance']; function mark(name) { performance && performance['mark'] && performance['mark'](name); @@ -28,12 +27,26 @@ var Zone$1 = (function (global) { performance && performance['measure'] && performance['measure'](name, label); } mark('Zone'); + var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; if (global['Zone']) { - throw new Error('Zone already loaded.'); + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } var Zone = /** @class */ (function () { function Zone(parent, zoneSpec) { - this._properties = null; this._parent = parent; this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; this._properties = zoneSpec && zoneSpec.properties || {}; @@ -76,7 +89,9 @@ var Zone$1 = (function (global) { }); Zone.__load_patch = function (name, fn) { if (patches.hasOwnProperty(name)) { - throw Error('Already loaded patch: ' + name); + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } else if (!global['__Zone_disable_' + name]) { var perfName = 'Zone:' + name; @@ -120,7 +135,7 @@ var Zone$1 = (function (global) { return this._zoneDelegate.fork(this, zoneSpec); }; Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== FUNCTION) { + if (typeof callback !== 'function') { throw new Error('Expecting function got: ' + callback); } var _callback = this._zoneDelegate.intercept(this, callback, source); @@ -130,9 +145,6 @@ var Zone$1 = (function (global) { }; }; Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = undefined; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); @@ -143,8 +155,6 @@ var Zone$1 = (function (global) { }; Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { if (applyThis === void 0) { applyThis = null; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { try { @@ -168,10 +178,7 @@ var Zone$1 = (function (global) { // https://github.com/angular/zone.js/issues/778, sometimes eventTask // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - // we have to define an variable here, if not - // typescript compiler will complain below - var isNotScheduled = task.state === notScheduled; - if (isNotScheduled && task.type === eventTask) { + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { return; } var reEntryGuard = task.state != running; @@ -182,7 +189,7 @@ var Zone$1 = (function (global) { _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = null; + task.cancelFn = undefined; } try { return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); @@ -218,8 +225,7 @@ var Zone$1 = (function (global) { var newZone = this; while (newZone) { if (newZone === task.zone) { - throw Error("can not reschedule task to " + this - .name + " which is descendants of the original zone " + task.zone.name); + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); } newZone = newZone.parent; } @@ -249,7 +255,7 @@ var Zone$1 = (function (global) { return task; }; Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, null)); + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); }; Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); @@ -290,16 +296,14 @@ var Zone$1 = (function (global) { }()); var DELEGATE_ZS = { name: '', - onHasTask: function (delegate, _, target, hasTaskState) { - return delegate.hasTask(target, hasTaskState); - }, + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, - onCancelTask: function (delegate, _, target, task) { - return delegate.cancelTask(target, task); - } + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { @@ -327,8 +331,8 @@ var Zone$1 = (function (global) { zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = - zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); this._invokeTaskZS = @@ -383,8 +387,7 @@ var Zone$1 = (function (global) { callback; }; ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? - this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.handleError = function (targetZone, error) { @@ -416,8 +419,7 @@ var Zone$1 = (function (global) { return returnTask; }; ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.cancelTask = function (targetZone, task) { @@ -437,7 +439,7 @@ var Zone$1 = (function (global) { // hasTask should not throw error so other ZoneDelegate // can still trigger hasTask callback try { - return this._hasTaskZS && + this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } catch (err) { @@ -527,14 +529,12 @@ var Zone$1 = (function (global) { } } else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? - ' or \'' + fromState2 + '\'' : - '') + ", was '" + this._state + "'."); + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); } }; ZoneTask.prototype.toString = function () { if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId; + return this.data.handleId.toString(); } else { return Object.prototype.toString.call(this); @@ -575,7 +575,13 @@ var Zone$1 = (function (global) { } } if (nativeMicroTaskQueuePromise) { - nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue); + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); } else { global[symbolSetTimeout](drainMicroTaskQueue, 0); @@ -622,12 +628,13 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - bindArguments: function () { return null; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === FUNCTION) { + if (NativePromise && typeof NativePromise.resolve === 'function') { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, @@ -643,6 +650,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -785,7 +802,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var queue = promise[symbolValue]; promise[symbolValue] = value; if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally + // the promise is generated by Promise.prototype.finally if (state === RESOLVED) { // the state is resolved, should ignore the value // and use parent promise value @@ -869,7 +886,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { chainPromise[symbolParentPromiseState] = promiseState; } // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); resolvePromise(chainPromise, true, value); } catch (error) { @@ -904,6 +923,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { return resolvePromise(new this(null), REJECTED, error); }; ZoneAwarePromise.race = function (values) { + var e_1, _a; var resolve; var reject; var promise = new this(function (res, rej) { @@ -916,40 +936,70 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); } - value.then(onResolve, onReject); + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + } + finally { if (e_1) throw e_1.error; } } return promise; }; ZoneAwarePromise.all = function (values) { + var e_2, _a; var resolve; var reject; var promise = new this(function (res, rej) { resolve = res; reject = rej; }); - var count = 0; + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; + var _loop_2 = function (value) { if (!isThenable(value)) { - value = this.resolve(value); + value = this_1.resolve(value); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { resolve(resolvedValues); } - }; })(count), reject); - count++; + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + _loop_2(value); + } } - if (!count) + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { resolve(resolvedValues); + } return promise; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { @@ -1045,25 +1095,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; Ctor[symbolThenPatched] = true; } - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } + api.patchThen = patchThen; if (NativePromise) { patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global['fetch'] = zoneify(fetch_1); - } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; @@ -1163,9 +1197,23 @@ var wrapFn = function (event) { } var target = this || event.target || _global; var listener = target[eventNameSymbol]; - var result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } return result; }; @@ -1183,6 +1231,10 @@ function patchProperty(obj, prop, prototype) { if (!desc || !desc.configurable) { return; } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } // A property descriptor cannot have getter/setter and be writable // deleting the writable and value properties avoids this error: // @@ -1260,6 +1312,7 @@ function patchProperty(obj, prop, prototype) { return null; }; ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1282,6 +1335,33 @@ function patchOnProperties(obj, properties, prototype) { var originalInstanceKey = zoneSymbol('originalInstance'); // wrap some native API on `window` +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +var shouldCopySymbolProperties = false; +function setShouldCopySymbolProperties(flag) { + shouldCopySymbolProperties = flag; +} function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { @@ -1292,7 +1372,7 @@ function patchMethod(target, name, patchFn) { proto = target; } var delegateName = zoneSymbol(name); - var delegate; + var delegate = null; if (proto && !(delegate = proto[delegateName])) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable @@ -1304,6 +1384,9 @@ function patchMethod(target, name, patchFn) { return patchDelegate_1(this, arguments); }; attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } } } return delegate; @@ -1322,7 +1405,7 @@ function patchMacroTask(obj, funcName, metaCreator) { setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1409,6 +1492,20 @@ Zone.__load_patch('toString', function (global) { }; }); +/** + * @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.__load_patch('node_util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + setShouldCopySymbolProperties(true); +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1420,6 +1517,21 @@ Zone.__load_patch('toString', function (global) { * @fileoverview * @suppress {missingRequire} */ +var passiveSupported = false; +if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { useG: true @@ -1555,6 +1667,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (proto[zoneSymbolAddEventListener]) { return false; } + var eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask // so we do not need to create a new object just for pass some data var taskData = {}; @@ -1570,12 +1683,24 @@ function patchEventTarget(_global, apis, patchOptions) { nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = proto[patchOptions.prepend]; } - var customScheduleGlobal = function () { + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { @@ -1616,6 +1741,7 @@ function patchEventTarget(_global, apis, patchOptions) { return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { @@ -1638,10 +1764,15 @@ function patchEventTarget(_global, apis, patchOptions) { if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; + var eventName = arguments[0]; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } // don't create the bind delegate function for handleEvent // case here to improve addEventListener performance // we will create the bind delegate when invoke @@ -1655,7 +1786,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { return; } - var eventName = arguments[0]; var options = arguments[2]; if (blackListedEvents) { // check black list @@ -1685,8 +1815,8 @@ function patchEventTarget(_global, apis, patchOptions) { var symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; zoneSymbolEventNames$1[eventName] = {}; @@ -1721,7 +1851,8 @@ function patchEventTarget(_global, apis, patchOptions) { source = targetSource[eventName]; } if (!source) { - source = constructorName + addSource + eventName; + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); } // do not create a new object as task.data to pass those things // just use the global shared one @@ -1736,7 +1867,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.capture = capture; taskData.eventName = eventName; taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; @@ -1754,7 +1885,11 @@ function patchEventTarget(_global, apis, patchOptions) { if (once) { options.once = true; } - task.options = options; + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } task.target = target; task.capture = capture; task.eventName = eventName; @@ -1839,7 +1974,7 @@ function patchEventTarget(_global, apis, patchOptions) { var target = this || _global; var eventName = arguments[0]; var listeners = []; - var tasks = findEventTasks(target, eventName); + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); for (var i = 0; i < tasks.length; i++) { var task = tasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; @@ -1949,6 +2084,15 @@ Zone.__load_patch('EventEmitter', function (global) { // same callback, same capture, same event name, just return return task.callback === delegate || task.callback.listener === delegate; }; + var eventNameToString = function (eventName) { + if (typeof eventName === 'string') { + return eventName; + } + if (!eventName) { + return ''; + } + return eventName.toString().replace('(', '_').replace(')', '_'); + }; function patchEventEmitterMethods(obj) { var result = patchEventTarget(global, [obj], { useG: false, @@ -1959,7 +2103,8 @@ Zone.__load_patch('EventEmitter', function (global) { listeners: EE_LISTENERS, chkDup: false, rt: true, - diff: compareTaskCallbackVsDelegate + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString }); if (result && result[0]) { obj[EE_ON] = obj[EE_ADD_LISTENER]; @@ -2068,9 +2213,9 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, setName, function (delegate) { return function (self, args) { if (typeof args[0] === 'function') { var options = { - handleId: null, isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, args: args }; var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); @@ -2151,11 +2296,6 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ var set = 'set'; var clear = 'clear'; -Zone.__load_patch('node_util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; -}); Zone.__load_patch('node_timers', function (global, Zone) { // Timers var globalUseTimeoutFromTimer = false; @@ -2467,6 +2607,7 @@ var ProxyZoneSpec = /** @class */ (function () { if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } this.defaultSpecDelegate = defaultSpecDelegate; this.name = 'ProxyZone'; + this._delegateSpec = null; this.properties = { 'ProxyZoneSpec': this }; this.propertyKeys = null; this.lastTaskState = null; @@ -3269,7 +3410,11 @@ var __spread = (undefined && undefined.__spread) || function () { } } } + lastCurrentTime = this._currentTime; this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } }; Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { if (limit === void 0) { limit = 20; } @@ -3358,14 +3503,14 @@ var __spread = (undefined && undefined.__spread) || function () { args[_i] = arguments[_i]; } fn.apply(global, args); - if (_this._lastError === null) { + if (_this._lastError === null) { // Success if (completers.onSuccess != null) { completers.onSuccess.apply(global); } // Flush microtasks only on success. _this.flushMicrotasks(); } - else { + else { // Failure if (completers.onError != null) { completers.onError.apply(global); } @@ -3664,23 +3809,23 @@ Zone.__load_patch('fakeasync', function (global, Zone, api) { ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); } /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ function fakeAsync(fn) { // Not using an arrow function to preserve context passed from call site return function () { diff --git a/dist/zone-testing.js b/dist/zone-testing.js index aa2bbb2f2..735a76d7c 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -183,6 +183,7 @@ var ProxyZoneSpec = /** @class */ (function () { if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } this.defaultSpecDelegate = defaultSpecDelegate; this.name = 'ProxyZone'; + this._delegateSpec = null; this.properties = { 'ProxyZoneSpec': this }; this.propertyKeys = null; this.lastTaskState = null; @@ -985,7 +986,11 @@ var __spread = (undefined && undefined.__spread) || function () { } } } + lastCurrentTime = this._currentTime; this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } }; Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { if (limit === void 0) { limit = 20; } @@ -1074,14 +1079,14 @@ var __spread = (undefined && undefined.__spread) || function () { args[_i] = arguments[_i]; } fn.apply(global, args); - if (_this._lastError === null) { + if (_this._lastError === null) { // Success if (completers.onSuccess != null) { completers.onSuccess.apply(global); } // Flush microtasks only on success. _this.flushMicrotasks(); } - else { + else { // Failure if (completers.onError != null) { completers.onError.apply(global); } @@ -1380,23 +1385,23 @@ Zone.__load_patch('fakeasync', function (global, Zone, api) { ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); } /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ function fakeAsync(fn) { // Not using an arrow function to preserve context passed from call site return function () { diff --git a/dist/zone.js b/dist/zone.js index e15c127cf..fb3f4649b 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -19,7 +19,6 @@ * found in the LICENSE file at https://angular.io/license */ var Zone$1 = (function (global) { - var FUNCTION = 'function'; var performance = global['performance']; function mark(name) { performance && performance['mark'] && performance['mark'](name); @@ -28,12 +27,26 @@ var Zone$1 = (function (global) { performance && performance['measure'] && performance['measure'](name, label); } mark('Zone'); + var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; if (global['Zone']) { - throw new Error('Zone already loaded.'); + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } var Zone = /** @class */ (function () { function Zone(parent, zoneSpec) { - this._properties = null; this._parent = parent; this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; this._properties = zoneSpec && zoneSpec.properties || {}; @@ -76,7 +89,9 @@ var Zone$1 = (function (global) { }); Zone.__load_patch = function (name, fn) { if (patches.hasOwnProperty(name)) { - throw Error('Already loaded patch: ' + name); + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } else if (!global['__Zone_disable_' + name]) { var perfName = 'Zone:' + name; @@ -120,7 +135,7 @@ var Zone$1 = (function (global) { return this._zoneDelegate.fork(this, zoneSpec); }; Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== FUNCTION) { + if (typeof callback !== 'function') { throw new Error('Expecting function got: ' + callback); } var _callback = this._zoneDelegate.intercept(this, callback, source); @@ -130,9 +145,6 @@ var Zone$1 = (function (global) { }; }; Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = undefined; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); @@ -143,8 +155,6 @@ var Zone$1 = (function (global) { }; Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { if (applyThis === void 0) { applyThis = null; } - if (applyArgs === void 0) { applyArgs = null; } - if (source === void 0) { source = null; } _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { try { @@ -168,10 +178,7 @@ var Zone$1 = (function (global) { // https://github.com/angular/zone.js/issues/778, sometimes eventTask // will run in notScheduled(canceled) state, we should not try to // run such kind of task but just return - // we have to define an variable here, if not - // typescript compiler will complain below - var isNotScheduled = task.state === notScheduled; - if (isNotScheduled && task.type === eventTask) { + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { return; } var reEntryGuard = task.state != running; @@ -182,7 +189,7 @@ var Zone$1 = (function (global) { _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = null; + task.cancelFn = undefined; } try { return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); @@ -218,8 +225,7 @@ var Zone$1 = (function (global) { var newZone = this; while (newZone) { if (newZone === task.zone) { - throw Error("can not reschedule task to " + this - .name + " which is descendants of the original zone " + task.zone.name); + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); } newZone = newZone.parent; } @@ -249,7 +255,7 @@ var Zone$1 = (function (global) { return task; }; Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, null)); + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); }; Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); @@ -290,16 +296,14 @@ var Zone$1 = (function (global) { }()); var DELEGATE_ZS = { name: '', - onHasTask: function (delegate, _, target, hasTaskState) { - return delegate.hasTask(target, hasTaskState); - }, + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, - onCancelTask: function (delegate, _, target, task) { - return delegate.cancelTask(target, task); - } + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; var ZoneDelegate = /** @class */ (function () { function ZoneDelegate(zone, parentDelegate, zoneSpec) { @@ -327,8 +331,8 @@ var Zone$1 = (function (global) { zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); this._scheduleTaskZS = zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = - zoneSpec && (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); this._scheduleTaskCurrZone = zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); this._invokeTaskZS = @@ -383,8 +387,7 @@ var Zone$1 = (function (global) { callback; }; ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? - this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.handleError = function (targetZone, error) { @@ -416,8 +419,7 @@ var Zone$1 = (function (global) { return returnTask; }; ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? - this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : task.callback.apply(applyThis, applyArgs); }; ZoneDelegate.prototype.cancelTask = function (targetZone, task) { @@ -437,7 +439,7 @@ var Zone$1 = (function (global) { // hasTask should not throw error so other ZoneDelegate // can still trigger hasTask callback try { - return this._hasTaskZS && + this._hasTaskZS && this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } catch (err) { @@ -527,14 +529,12 @@ var Zone$1 = (function (global) { } } else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? - ' or \'' + fromState2 + '\'' : - '') + ", was '" + this._state + "'."); + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); } }; ZoneTask.prototype.toString = function () { if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId; + return this.data.handleId.toString(); } else { return Object.prototype.toString.call(this); @@ -575,7 +575,13 @@ var Zone$1 = (function (global) { } } if (nativeMicroTaskQueuePromise) { - nativeMicroTaskQueuePromise[symbolThen](drainMicroTaskQueue); + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); } else { global[symbolSetTimeout](drainMicroTaskQueue, 0); @@ -622,12 +628,13 @@ var Zone$1 = (function (global) { patchEventTarget: function () { return []; }, patchOnProperties: noop, patchMethod: function () { return noop; }, - bindArguments: function () { return null; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === FUNCTION) { + if (NativePromise && typeof NativePromise.resolve === 'function') { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, @@ -643,6 +650,16 @@ var Zone$1 = (function (global) { return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -785,7 +802,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var queue = promise[symbolValue]; promise[symbolValue] = value; if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally + // the promise is generated by Promise.prototype.finally if (state === RESOLVED) { // the state is resolved, should ignore the value // and use parent promise value @@ -869,7 +886,9 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { chainPromise[symbolParentPromiseState] = promiseState; } // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? [] : [parentPromiseValue]); + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); resolvePromise(chainPromise, true, value); } catch (error) { @@ -904,6 +923,7 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { return resolvePromise(new this(null), REJECTED, error); }; ZoneAwarePromise.race = function (values) { + var e_1, _a; var resolve; var reject; var promise = new this(function (res, rej) { @@ -916,40 +936,70 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { function onReject(error) { promise && (promise = null || reject(error)); } - for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { - var value = values_1[_i]; - if (!isThenable(value)) { - value = this.resolve(value); + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); } - value.then(onResolve, onReject); + finally { if (e_1) throw e_1.error; } } return promise; }; ZoneAwarePromise.all = function (values) { + var e_2, _a; var resolve; var reject; var promise = new this(function (res, rej) { resolve = res; reject = rej; }); - var count = 0; + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; var resolvedValues = []; - for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { - var value = values_2[_i]; + var _loop_2 = function (value) { if (!isThenable(value)) { - value = this.resolve(value); + value = this_1.resolve(value); } - value.then((function (index) { return function (value) { - resolvedValues[index] = value; - count--; - if (!count) { + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { resolve(resolvedValues); } - }; })(count), reject); - count++; + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + _loop_2(value); + } } - if (!count) + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { resolve(resolvedValues); + } return promise; }; ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { @@ -1045,31 +1095,112 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { }; Ctor[symbolThenPatched] = true; } - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } + api.patchThen = patchThen; if (NativePromise) { patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global['fetch'] = zoneify(fetch_1); - } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; return ZoneAwarePromise; }); +/** + * @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.__load_patch('fetch', function (global, Zone, api) { + var fetch = global['fetch']; + var ZoneAwarePromise = global.Promise; + var symbolThenPatched = api.symbol('thenPatched'); + var fetchTaskScheduling = api.symbol('fetchTaskScheduling'); + var fetchTaskAborting = api.symbol('fetchTaskAborting'); + if (typeof fetch !== 'function') { + return; + } + var OriginalAbortController = global['AbortController']; + var supportAbort = typeof OriginalAbortController === 'function'; + var abortNative = null; + if (supportAbort) { + global['AbortController'] = function () { + var abortController = new OriginalAbortController(); + var signal = abortController.signal; + signal.abortController = abortController; + return abortController; + }; + abortNative = api.patchMethod(OriginalAbortController.prototype, 'abort', function (delegate) { return function (self, args) { + if (self.task) { + return self.task.zone.cancelTask(self.task); + } + return delegate.apply(self, args); + }; }); + } + var placeholder = function () { }; + global['fetch'] = function () { + var _this = this; + var args = Array.prototype.slice.call(arguments); + var options = args.length > 1 ? args[1] : null; + var signal = options && options.signal; + return new Promise(function (res, rej) { + var task = Zone.current.scheduleMacroTask('fetch', placeholder, args, function () { + var fetchPromise; + var zone = Zone.current; + try { + zone[fetchTaskScheduling] = true; + fetchPromise = fetch.apply(_this, args); + } + catch (error) { + rej(error); + return; + } + finally { + zone[fetchTaskScheduling] = false; + } + if (!(fetchPromise instanceof ZoneAwarePromise)) { + var ctor = fetchPromise.constructor; + if (!ctor[symbolThenPatched]) { + api.patchThen(ctor); + } + } + fetchPromise.then(function (resource) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + res(resource); + }, function (error) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + rej(error); + }); + }, function () { + if (!supportAbort) { + rej('No AbortController supported, can not cancel fetch'); + return; + } + if (signal && signal.abortController && !signal.aborted && + typeof signal.abortController.abort === 'function' && abortNative) { + try { + Zone.current[fetchTaskAborting] = true; + abortNative.call(signal.abortController); + } + finally { + Zone.current[fetchTaskAborting] = false; + } + } + else { + rej('cancel fetch need a AbortController.signal'); + } + }); + if (signal && signal.abortController) { + signal.abortController.task = task; + } + }); + }; +}); + /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1185,9 +1316,23 @@ var wrapFn = function (event) { } var target = this || event.target || _global; var listener = target[eventNameSymbol]; - var result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } return result; }; @@ -1205,6 +1350,10 @@ function patchProperty(obj, prop, prototype) { if (!desc || !desc.configurable) { return; } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } // A property descriptor cannot have getter/setter and be writable // deleting the writable and value properties avoids this error: // @@ -1282,6 +1431,7 @@ function patchProperty(obj, prop, prototype) { return null; }; ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } function patchOnProperties(obj, properties, prototype) { if (properties) { @@ -1372,6 +1522,31 @@ function patchClass(className) { } } } +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +var shouldCopySymbolProperties = false; + function patchMethod(target, name, patchFn) { var proto = target; while (proto && !proto.hasOwnProperty(name)) { @@ -1382,7 +1557,7 @@ function patchMethod(target, name, patchFn) { proto = target; } var delegateName = zoneSymbol(name); - var delegate; + var delegate = null; if (proto && !(delegate = proto[delegateName])) { delegate = proto[delegateName] = proto[name]; // check whether proto[name] is writable @@ -1394,6 +1569,9 @@ function patchMethod(target, name, patchFn) { return patchDelegate_1(this, arguments); }; attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } } } return delegate; @@ -1412,7 +1590,7 @@ function patchMacroTask(obj, funcName, metaCreator) { setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { var meta = metaCreator(self, args); if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask, null); + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { // cause an error by calling it directly. @@ -1426,6 +1604,17 @@ function attachOriginToPatched(patched, original) { } var isDetectedIEOrEdge = false; var ieOrEdge = false; +function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; +} function isIEOrEdge() { if (isDetectedIEOrEdge) { return ieOrEdge; @@ -1507,6 +1696,21 @@ Zone.__load_patch('toString', function (global) { * @fileoverview * @suppress {missingRequire} */ +var passiveSupported = false; +if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} // an identifier to tell ZoneTask do not create a new invoke closure var OPTIMIZED_ZONE_EVENT_TASK_DATA = { useG: true @@ -1642,6 +1846,7 @@ function patchEventTarget(_global, apis, patchOptions) { if (proto[zoneSymbolAddEventListener]) { return false; } + var eventNameToString = patchOptions && patchOptions.eventNameToString; // a shared global taskData to pass data for scheduleEventTask // so we do not need to create a new object just for pass some data var taskData = {}; @@ -1657,12 +1862,24 @@ function patchEventTarget(_global, apis, patchOptions) { nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = proto[patchOptions.prepend]; } - var customScheduleGlobal = function () { + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { // if there is already a task for the eventName + capture, // just return, because we use the shared globalZoneAwareCallback here. if (taskData.isExisting) { return; } + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); }; var customCancelGlobal = function (task) { @@ -1703,6 +1920,7 @@ function patchEventTarget(_global, apis, patchOptions) { return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); }; var customScheduleNonGlobal = function (task) { + checkIsPassive(task); return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; var customSchedulePrepend = function (task) { @@ -1725,10 +1943,15 @@ function patchEventTarget(_global, apis, patchOptions) { if (prepend === void 0) { prepend = false; } return function () { var target = this || _global; + var eventName = arguments[0]; var delegate = arguments[1]; if (!delegate) { return nativeListener.apply(this, arguments); } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } // don't create the bind delegate function for handleEvent // case here to improve addEventListener performance // we will create the bind delegate when invoke @@ -1742,7 +1965,6 @@ function patchEventTarget(_global, apis, patchOptions) { if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { return; } - var eventName = arguments[0]; var options = arguments[2]; if (blackListedEvents) { // check black list @@ -1772,8 +1994,8 @@ function patchEventTarget(_global, apis, patchOptions) { var symbolEventName; if (!symbolEventNames) { // the code is duplicate, but I just want to get some better performance - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; zoneSymbolEventNames$1[eventName] = {}; @@ -1808,7 +2030,8 @@ function patchEventTarget(_global, apis, patchOptions) { source = targetSource[eventName]; } if (!source) { - source = constructorName + addSource + eventName; + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); } // do not create a new object as task.data to pass those things // just use the global shared one @@ -1823,7 +2046,7 @@ function patchEventTarget(_global, apis, patchOptions) { taskData.capture = capture; taskData.eventName = eventName; taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : null; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; // keep taskData into data to allow onScheduleEventTask to access the task information if (data) { data.taskData = taskData; @@ -1841,7 +2064,11 @@ function patchEventTarget(_global, apis, patchOptions) { if (once) { options.once = true; } - task.options = options; + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } task.target = target; task.capture = capture; task.eventName = eventName; @@ -1926,7 +2153,7 @@ function patchEventTarget(_global, apis, patchOptions) { var target = this || _global; var eventName = arguments[0]; var listeners = []; - var tasks = findEventTasks(target, eventName); + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); for (var i = 0; i < tasks.length; i++) { var task = tasks[i]; var delegate = task.originalDelegate ? task.originalDelegate : task.callback; @@ -2082,9 +2309,9 @@ function patchTimer(window, setName, cancelName, nameSuffix) { patchMethod(window, setName, function (delegate) { return function (self, args) { if (typeof args[0] === 'function') { var options = { - handleId: null, isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : null, + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, args: args }; var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); @@ -2199,7 +2426,7 @@ function propertyPatch() { }; Object.getOwnPropertyDescriptor = function (obj, prop) { var desc = _getOwnPropertyDescriptor(obj, prop); - if (isUnconfigurable(obj, prop)) { + if (desc && isUnconfigurable(obj, prop)) { desc.configurable = false; } return desc; @@ -2427,10 +2654,10 @@ var globalEventHandlersEventNames = [ 'wheel' ]; var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'fullscreenchange', + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange' + 'visibilitychange', 'resume' ]; var windowEventNames = [ 'absolutedeviceorientation', @@ -2542,7 +2769,7 @@ var websocketEventNames = ['close', 'error', 'open', 'message']; var workerEventNames = ['error', 'message']; var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { return onProperties; } var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); @@ -2567,13 +2794,14 @@ function propertyDescriptorPatch(api, _global) { } var supportsWebSocket = typeof WebSocket !== 'undefined'; if (canPatchViaPropertyDescriptor()) { - var ignoreProperties = _global.__Zone_ignore_on_properties; + var ignoreProperties = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox if (isBrowser) { var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; // in IE/Edge, onProp not exist in window object, but in WindowPrototype // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); if (typeof internalWindow['SVGElement'] !== 'undefined') { patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); @@ -2595,9 +2823,9 @@ function propertyDescriptorPatch(api, _global) { } } patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget_1 = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + patchFilteredProperties(XMLHttpRequestEventTarget_1 && XMLHttpRequestEventTarget_1.prototype, XMLHttpRequestEventNames, ignoreProperties); } if (typeof IDBIndex !== 'undefined') { patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); @@ -2812,16 +3040,16 @@ function patchEvent(global, api) { * 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 && !isMix) || !('registerElement' in _global.document)) { +function patchCallbacks(target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { return; } - var _registerElement = document.registerElement; - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - document.registerElement = function (name, opts) { + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { if (opts && opts.prototype) { callbacks.forEach(function (callback) { - var source = 'Document.registerElement::' + callback; + var source = targetName + "." + method + "::" + callback; var prototype = opts.prototype; if (prototype.hasOwnProperty(callback)) { var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); @@ -2838,9 +3066,23 @@ function registerElementPatch(_global) { } }); } - return _registerElement.call(document, name, opts); + return nativeDelegate.call(target, name, opts, options); }; - attachOriginToPatched(document.registerElement, _registerElement); + attachOriginToPatched(target[method], nativeDelegate); +} +function registerElementPatch(_global) { + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + patchCallbacks(document, 'Document', 'registerElement', callbacks); +} +function patchCustomElements(_global) { + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); } /** @@ -2903,7 +3145,10 @@ Zone.__load_patch('EventTarget', function (global, Zone, api) { Zone.__load_patch('on_property', function (global, Zone, api) { propertyDescriptorPatch(api, global); propertyPatch(); +}); +Zone.__load_patch('customElements', function (global, Zone, api) { registerElementPatch(global); + patchCustomElements(global); }); Zone.__load_patch('canvas', function (global) { var HTMLCanvasElement = global['HTMLCanvasElement']; @@ -2922,6 +3167,7 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_LISTENER = zoneSymbol('xhrListener'); var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { @@ -2930,9 +3176,9 @@ Zone.__load_patch('XHR', function (global, Zone) { var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; if (!oriAddListener) { - var XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; } @@ -2940,9 +3186,10 @@ Zone.__load_patch('XHR', function (global, Zone) { var READY_STATE_CHANGE = 'readystatechange'; var SCHEDULED = 'scheduled'; function scheduleTask(task) { - XMLHttpRequest[XHR_SCHEDULED] = false; var data = task.data; var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; // remove existing event listener var listener = target[XHR_LISTENER]; if (!oriAddListener) { @@ -2956,8 +3203,35 @@ Zone.__load_patch('XHR', function (global, Zone) { if (target.readyState === target.DONE) { // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && XMLHttpRequest[XHR_SCHEDULED] && task.state === SCHEDULED) { - task.invoke(); + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target['__zone_symbol__loadfalse']; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target['__zone_symbol__loadfalse']; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } }; @@ -2967,7 +3241,7 @@ Zone.__load_patch('XHR', function (global, Zone) { target[XHR_TASK] = task; } sendNative.apply(target, data.args); - XMLHttpRequest[XHR_SCHEDULED] = true; + target[XHR_SCHEDULED] = true; return task; } function placeholderCallback() { } @@ -2984,24 +3258,32 @@ Zone.__load_patch('XHR', function (global, Zone) { return openNative.apply(self, args); }; }); var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } if (self[XHR_SYNC]) { // if the XHR is sync there is no task to schedule, just execute the code. return sendNative.apply(self, args); } else { - var options = { - target: self, - url: self[XHR_URL], - isPeriodic: false, - delay: null, - args: args, - aborted: false - }; - return scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } } }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self) { + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { var task = findPendingTask(self); if (task && typeof task.type == 'string') { // If the XHR has already completed, do nothing. @@ -3013,6 +3295,10 @@ Zone.__load_patch('XHR', function (global, Zone) { } task.zone.cancelTask(task); } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no // task // to cancel. Do nothing. diff --git a/dist/zone.js.d.ts b/dist/zone.js.d.ts index ac7ddcdb4..5420fe1ba 100644 --- a/dist/zone.js.d.ts +++ b/dist/zone.js.d.ts @@ -136,7 +136,7 @@ interface Zone { * * @returns {Zone} The parent Zone. */ - parent: Zone; + parent: Zone | null; /** * @returns {string} The Zone name (useful for debugging) */ @@ -159,7 +159,7 @@ interface Zone { * @param key The key to use for identification of the returned zone. * @returns {Zone} The Zone which defines the `key`, `null` if not found. */ - getZoneWith(key: string): Zone; + getZoneWith(key: string): Zone | null; /** * Used to create a child zone. * @@ -235,7 +235,7 @@ interface Zone { * @param customSchedule * @param customCancel */ - scheduleMacroTask(source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, customCancel: (task: Task) => void): MacroTask; + scheduleMacroTask(source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, customCancel?: (task: Task) => void): MacroTask; /** * Schedule an EventTask. * @@ -245,7 +245,7 @@ interface Zone { * @param customSchedule * @param customCancel */ - scheduleEventTask(source: string, callback: Function, data: TaskData, customSchedule: (task: Task) => void, customCancel: (task: Task) => void): EventTask; + scheduleEventTask(source: string, callback: Function, data?: TaskData, customSchedule?: (task: Task) => void, customCancel?: (task: Task) => void): EventTask; /** * Schedule an existing Task. * @@ -275,7 +275,7 @@ interface ZoneType { /** * @returns {Task} The task associated with the current execution. */ - currentTask: Task; + currentTask: Task | null; /** * Verify that Zone has been correctly patched. Specifically that Promise is zone aware. */ @@ -339,7 +339,7 @@ interface ZoneSpec { * @param applyArgs The argument passed into the `run` method. * @param source The argument passed into the `run` method. */ - 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; /** * Allows interception of the error handling. * @@ -358,7 +358,7 @@ interface ZoneSpec { * @param task The argument passed into the `scheduleTask` method. */ 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; /** * Allows interception of task cancellation. * @@ -413,10 +413,10 @@ interface ZoneDelegate { zone: Zone; fork(targetZone: Zone, zoneSpec: ZoneSpec): Zone; 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; scheduleTask(targetZone: Zone, task: Task): Task; - invokeTask(targetZone: Zone, task: Task, applyThis: any, applyArgs: any): any; + invokeTask(targetZone: Zone, task: Task, applyThis?: any, applyArgs?: any[]): any; cancelTask(targetZone: Zone, task: Task): any; hasTask(targetZone: Zone, isEmpty: HasTaskState): void; } @@ -493,20 +493,20 @@ interface Task { /** * Task specific options associated with the current task. This is passed to the `scheduleFn`. */ - data: TaskData; + data?: TaskData; /** * Represents the default work which needs to be done to schedule the Task by the VM. * * A zone may choose to intercept this function and perform its own scheduling. */ - scheduleFn: (task: Task) => void; + scheduleFn?: (task: Task) => void; /** * Represents the default work which needs to be done to un-schedule the Task from the VM. Not all * Tasks are cancelable, and therefore this method is optional. * * A zone may chose to intercept this function and perform its own un-scheduling. */ - cancelFn: (task: Task) => void; + cancelFn?: (task: Task) => void; /** * @type {Zone} The zone which will be used to invoke the `callback`. The Zone is captured * at the time of Task creation. diff --git a/dist/zone.min.js b/dist/zone.min.js index b95e78412..2c5af2585 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=P(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return l(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o,null):e.apply(n,a)}})}function l(e,t){e[B("OriginalDelegate")]=t}function f(){if(te)return ne;te=!0;try{var e=W.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ne=!0),ne}catch(t){}}function p(e,t,n){function r(t,n){if(!t)return!1;var r=!0;n&&void 0!==n.useG&&(r=n.useG);var d=n&&n.vh,y=!0;n&&void 0!==n.chkDup&&(y=n.chkDup);var m=!1;n&&void 0!==n.rt&&(m=n.rt);for(var k=t;k&&!k.hasOwnProperty(o);)k=C(k);if(!k&&t[o]&&(k=t),!k)return!1;if(k[c])return!1;var _,b={},T=k[c]=k[o],w=k[B(a)]=k[a],E=k[B(i)]=k[i],S=k[B(s)]=k[s];n&&n.prepend&&(_=k[B(n.prepend)]=k[n.prepend]);var D=function(){if(!b.isExisting)return T.call(b.target,b.eventName,b.capture?g:v,b.options)},Z=function(e){if(!e.isRemoved){var t=oe[e.eventName],n=void 0;t&&(n=t[e.capture?F:q]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=P(a,"onmessage");return s&&s.configurable===!1?(r=I(a),o=a,[M,R,"send","close"].forEach(function(e){r[e]=function(){var t=L.call(arguments);if(e===M||e===R){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function T(e,t,n){if(!n)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function w(e,t,n,r){if(e){var o=T(e,t,n);i(e,o,r)}}function E(e,t){if(!K||Y){var n="undefined"!=typeof WebSocket;if(S()){var r=t.__Zone_ignore_on_properties;if(J){var o=window;w(o,Oe.concat(["messageerror"]),r,C(o)),w(Document.prototype,Oe,r),"undefined"!=typeof o.SVGElement&&w(o.SVGElement.prototype,Oe,r),w(Element.prototype,Oe,r),w(HTMLElement.prototype,Oe,r),w(HTMLMediaElement.prototype,ye,r),w(HTMLFrameSetElement.prototype,ve.concat(we),r),w(HTMLBodyElement.prototype,ve.concat(we),r),w(HTMLFrameElement.prototype,Te,r),w(HTMLIFrameElement.prototype,Te,r);var a=o.HTMLMarqueeElement;a&&w(a.prototype,Ee,r);var i=o.Worker;i&&w(i.prototype,ze,r)}w(XMLHttpRequest.prototype,Se,r);var c=t.XMLHttpRequestEventTarget;c&&w(c&&c.prototype,Se,r),"undefined"!=typeof IDBIndex&&(w(IDBIndex.prototype,De,r),w(IDBRequest.prototype,De,r),w(IDBOpenDBRequest.prototype,De,r),w(IDBDatabase.prototype,De,r),w(IDBTransaction.prototype,De,r),w(IDBCursor.prototype,De,r)),n&&w(WebSocket.prototype,Ze,r)}else D(),s("XMLHttpRequest"),n&&b(e,t)}}function S(){if((J||Y)&&!P(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=P(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=P(n,t);if(r){j(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return j(n,t,r||{}),a}var i=B("fake");j(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function D(){for(var t=function(t){var n=Oe[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Pe]&&(n=e(a[r],o),n[Pe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o))throw Error("Already loaded patch: "+o);if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.prototype.wrap=function(e,t){if(typeof e!==s)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)}},r.prototype.run=function(e,t,n,r){void 0===t&&(t=void 0),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{j=j.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");var r=e.state===_;if(!r||e.type!==z){var o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;var a=C;C=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=null);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(i){if(this._zoneDelegate.handleError(this,i))throw i}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(_,w,_))),j=j.parent,C=a}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,null))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId:Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return j},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return null},setNativePromise:function(e){e&&typeof e.resolve===s&&(u=e.resolve(0))}},j={parent:null,zone:new l(null,null)},C=null,I=0;return n("Zone","Zone"),e.Zone=l})("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[b];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return H.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(I);if(e[T]===z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==P&&a instanceof H&&a.hasOwnProperty(T)&&a.hasOwnProperty(w)&&a[T]!==z)l(a),u(e,a[T],a[w]);else if(o!==P&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[T]=o;var h=e[w];if(e[w]=a,e[E]===E&&o===O&&(e[T]=e[D],e[w]=e[S]),o===P&&a instanceof Error){var d=t.currentTask&&t.currentTask.data&&t.currentTask.data[_];d&&v(a,L,{configurable:!0,enumerable:!1,writable:!0,value:d})}for(var g=0;g=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=L(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return f(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o):e.apply(n,a)}})}function f(e,t){e[U("OriginalDelegate")]=t}function p(){try{var e=K.navigator.userAgent;if(e.indexOf("MSIE ")!==-1||e.indexOf("Trident/")!==-1)return!0}catch(t){}return!1}function h(){if(se)return ce;se=!0;try{var e=K.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ce=!0),ce}catch(t){}}function d(e,t,n){function r(t,n){function r(e){ue||"boolean"==typeof w.options||"undefined"==typeof w.options||null===w.options||(e.options=!!w.options.capture,w.options=e.options)}if(!t)return!1;var h=!0;n&&void 0!==n.useG&&(h=n.useG);var y=n&&n.vh,m=!0;n&&void 0!==n.chkDup&&(m=n.chkDup);var k=!1;n&&void 0!==n.rt&&(k=n.rt);for(var _=t;_&&!_.hasOwnProperty(o);)_=R(_);if(!_&&t[o]&&(_=t),!_)return!1;if(_[c])return!1;var b,T=n&&n.eventNameToString,w={},E=_[c]=_[o],S=_[U(a)]=_[a],D=_[U(i)]=_[i],Z=_[U(s)]=_[s];n&&n.prepend&&(b=_[U(n.prepend)]=_[n.prepend]);var z=function(e){if(!w.isExisting)return r(e),E.call(w.target,w.eventName,w.capture?g:d,w.options)},O=function(e){if(!e.isRemoved){var t=he[e.eventName],n=void 0;t&&(n=t[e.capture?W:X]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=L(a,"onmessage");return s&&s.configurable===!1?(r=H(a),o=a,[A,B,"send","close"].forEach(function(e){r[e]=function(){var t=F.call(arguments);if(e===A||e===B){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function E(e,t,n){if(!n||0===n.length)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function S(e,t,n,r){if(e){var o=E(e,t,n);i(e,o,r)}}function D(e,t){if(!ee||ne){var n="undefined"!=typeof WebSocket;if(Z()){var r=t.__Zone_ignore_on_properties;if(te){var o=window,a=p?[{target:o,ignoreProperties:["error"]}]:[];S(o,He.concat(["messageerror"]),r?r.concat(a):r,R(o)),S(Document.prototype,He,r),"undefined"!=typeof o.SVGElement&&S(o.SVGElement.prototype,He,r),S(Element.prototype,He,r),S(HTMLElement.prototype,He,r),S(HTMLMediaElement.prototype,De,r),S(HTMLFrameSetElement.prototype,Ee.concat(je),r),S(HTMLBodyElement.prototype,Ee.concat(je),r),S(HTMLFrameElement.prototype,Ce,r),S(HTMLIFrameElement.prototype,Ce,r);var i=o.HTMLMarqueeElement;i&&S(i.prototype,Ie,r);var c=o.Worker;c&&S(c.prototype,Re,r)}S(XMLHttpRequest.prototype,Me,r);var u=t.XMLHttpRequestEventTarget;u&&S(u&&u.prototype,Me,r),"undefined"!=typeof IDBIndex&&(S(IDBIndex.prototype,Le,r),S(IDBRequest.prototype,Le,r),S(IDBOpenDBRequest.prototype,Le,r),S(IDBDatabase.prototype,Le,r),S(IDBTransaction.prototype,Le,r),S(IDBCursor.prototype,Le,r)),n&&S(WebSocket.prototype,xe,r)}else z(),s("XMLHttpRequest"),n&&w(e,t)}}function Z(){if((te||ne)&&!L(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=L(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=L(n,t);if(r){x(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return x(n,t,r||{}),a}var i=U("fake");x(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function z(){for(var t=function(t){var n=He[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Fe]&&(n=e(a[r],o),n[Fe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return C.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o)){if(c)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.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)}},r.prototype.run=function(e,t,n,r){C={parent:C,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{C=C.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),C={parent:C,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{C=C.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==z&&e.type!==Z){var r=e.state!=w;r&&e._transitionTo(w,T),e.runCount++;var o=j;j=e,C={parent:C,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?r&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,w,_))),C=C.parent,j=o}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,(void 0)))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return C},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return[]},patchThen:function(){return a},setNativePromise:function(e){e&&"function"==typeof e.resolve&&(u=e.resolve(0))}},C={parent:null,zone:new l(null,null)},j=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[_];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return R.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(j);if(e[b]===Z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==O&&a instanceof R&&a.hasOwnProperty(b)&&a.hasOwnProperty(T)&&a[b]!==Z)l(a),u(e,a[b],a[T]);else if(o!==O&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[b]=o;var h=e[T];if(e[T]=a,e[w]===w&&o===z&&(e[b]=e[S],e[T]=e[E]),o===O&&a instanceof Error){var v=t.currentTask&&t.currentTask.data&&t.currentTask.data[k];v&&d(a,I,{configurable:!0,enumerable:!1,writable:!0,value:v})}for(var y=0;y1?c[1]:null,h=p&&p.signal;return new Promise(function(p,d){var v=t.current.scheduleMacroTask("fetch",f,c,function(){var s,u=t.current;try{u[i]=!0,s=r.apply(e,c)}catch(l){return void d(l)}finally{u[i]=!1}if(!(s instanceof o)){var f=s.constructor;f[a]||n.patchThen(f)}s.then(function(e){"notScheduled"!==v.state&&v.invoke(),p(e)},function(e){"notScheduled"!==v.state&&v.invoke(),d(e)})},function(){if(!u)return void d("No AbortController supported, can not cancel fetch");if(h&&h.abortController&&!h.aborted&&"function"==typeof h.abortController.abort&&l)try{t.current[s]=!0,l.call(h.abortController)}finally{t.current[s]=!1}else d("cancel fetch need a AbortController.signal")});h&&h.abortController&&(h.abortController.task=v)})}}});var L=Object.getOwnPropertyDescriptor,x=Object.defineProperty,R=Object.getPrototypeOf,H=Object.create,F=Array.prototype.slice,A="addEventListener",B="removeEventListener",q=Zone.__symbol__(A),N=Zone.__symbol__(B),W="true",X="false",G="__zone_symbol__",U=Zone.__symbol__,V="undefined"!=typeof window,K=V?window:void 0,J=V&&K||"object"==typeof self&&self||global,Y="removeAttribute",Q=[null],$="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,ee=!("nw"in J)&&"undefined"!=typeof J.process&&"[object process]"==={}.toString.call(J.process),te=!ee&&!$&&!(!V||!K.HTMLElement),ne="undefined"!=typeof J.process&&"[object process]"==={}.toString.call(J.process)&&!$&&!(!V||!K.HTMLElement),re={},oe=function(e){if(e=e||J.event){var t=re[e.type];t||(t=re[e.type]=U("ON_PROPERTY"+e.type));var n,r=this||e.target||J,o=r[t];if(te&&r===K&&"error"===e.type){var a=e;n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error),n===!0&&e.preventDefault()}else n=o&&o.apply(this,arguments),void 0==n||n||e.preventDefault();return n}},ae=U("originalInstance"),ie=!1,se=!1,ce=!1;Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=U("OriginalDelegate"),r=U("Promise"),o=U("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.apply(this[n],arguments):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.apply(i,arguments)}if(this===Error){var s=e[o];if(s)return t.apply(s,arguments)}}return t.apply(this,arguments)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString,s="[object Promise]";Object.prototype.toString=function(){return this instanceof Promise?s:i.apply(this,arguments)}});var ue=!1;if("undefined"!=typeof window)try{var le=Object.defineProperty({},"passive",{get:function(){ue=!0}});window.addEventListener("test",le,le),window.removeEventListener("test",le,le)}catch(fe){ue=!1}var pe={useG:!0},he={},de={},ve=/^__zone_symbol__(\w+)(true|false)$/,ge="__zone_symbol__propagationStopped",ye=U("zoneTask"),me=Object[U("defineProperty")]=Object.defineProperty,ke=Object[U("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_e=Object.create,be=U("unconfigurables"),Te=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],we=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],Ee=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],Se=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],De=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],Ze=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],ze=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],Oe=["autocomplete","autocompleteerror"],Pe=["toggle"],Ce=["load"],je=["blur","error","focus","load","resize","scroll","messageerror"],Ie=["bounce","finish","start"],Me=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],Le=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],xe=["close","error","open","message"],Re=["error","message"],He=Te.concat(ze,Oe,Pe,we,Ee,Se,Ze),Fe=U("unbound");Zone.__load_patch("util",function(e,t,r){r.patchOnProperties=i,r.patchMethod=u,r.bindArguments=n}),Zone.__load_patch("timers",function(e){var t="set",n="clear";y(e,t,n,"Timeout"),y(e,t,n,"Interval"),y(e,t,n,"Immediate")}),Zone.__load_patch("requestAnimationFrame",function(e){y(e,"request","cancel","AnimationFrame"),y(e,"mozRequest","mozCancel","AnimationFrame"),y(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",function(e,t){for(var n=["alert","prompt","confirm"],r=0;r0){var o=e.invoke;e.invoke=function(){for(var r=n.__zone_symbol__loadfalse,a=0;a Date: Thu, 17 Jan 2019 05:23:55 +0900 Subject: [PATCH 074/106] patch jasmine beforeAll/afterAll (#1176) --- lib/jasmine/jasmine.ts | 2 +- test/jasmine-patch.spec.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 33b0654c7..ee9dd029a 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -59,7 +59,7 @@ return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach(methodName => { + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(methodName => { let originalJasmineFn: Function = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function(specDefinitions: Function, timeout: number) { diff --git a/test/jasmine-patch.spec.ts b/test/jasmine-patch.spec.ts index 71ecf240f..5193e3e92 100644 --- a/test/jasmine-patch.spec.ts +++ b/test/jasmine-patch.spec.ts @@ -23,6 +23,7 @@ ifEnvSupports(supportJasmineSpec, () => { describe('jasmine', () => { let throwOnAsync = false; let beforeEachZone: Zone|null = null; + let beforeAllZone: Zone|null = null; let itZone: Zone|null = null; const syncZone = Zone.current; try { @@ -31,6 +32,8 @@ ifEnvSupports(supportJasmineSpec, () => { throwOnAsync = true; } + beforeAll(() => beforeAllZone = Zone.current); + beforeEach(() => beforeEachZone = Zone.current); it('should throw on async in describe', () => { @@ -47,6 +50,12 @@ ifEnvSupports(supportJasmineSpec, () => { expect(beforeEachZone!.name).toEqual(zone.name); expect(itZone).toBe(zone); }); + + afterAll(() => { + let zone = Zone.current; + expect(zone.name).toEqual('ProxyZone'); + expect(beforeAllZone!.name).toEqual(zone.name); + }); }); describe('return promise', () => { From 9c04a3b5a55711b0da9e5cef5a9de057198def18 Mon Sep 17 00:00:00 2001 From: Vikram Subramanian Date: Wed, 16 Jan 2019 15:20:55 -0800 Subject: [PATCH 075/106] chore: release v0.8.28 --- CHANGELOG.md | 9 +++++++++ dist/jasmine-patch.js | 2 +- dist/jasmine-patch.min.js | 2 +- dist/zone-testing-bundle.js | 2 +- dist/zone-testing-node-bundle.js | 2 +- dist/zone-testing.js | 2 +- package.json | 2 +- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1b47247..5c9a1bbbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ + +## [0.8.28](https://github.com/angular/zone.js/compare/v0.8.27...0.8.28) (2019-01-16) + + +### Bug Fixes + +* **jasmine:** patch jasmine beforeAll/afterAll ([9d27abc4](https://github.com/angular/zone.js/commit/9d27abc4)) + + ## [0.8.27](https://github.com/angular/zone.js/compare/v0.8.26...0.8.27) (2019-01-08) diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 33e809a72..8276ea2fd 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -68,7 +68,7 @@ return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach(function (methodName) { + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index e78cb748a..8d984ddfb 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!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 a.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[u("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,c=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!c)throw new Error("Missing: ProxyZoneSpec");var s=Zone.current,a=s.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=r[u("fakeAsyncPatchLock")]===!0,p=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=p[n];p[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=p[e];p[u(e)]=n,p[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach"].forEach(function(e){var n=p[e];p[u(e)]=n,p[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var l=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments);if(!e[u("patched")]){e[u("patched")]=u("patched");var n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},f&&["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}})}return e};var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,s.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}c&&c.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===s){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new c,this.testProxyZone=s.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(){function e(e){return function(){return a.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[u("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,c=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!c)throw new Error("Missing: ProxyZoneSpec");var s=Zone.current,a=s.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=r[u("fakeAsyncPatchLock")]===!0,l=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=l[n];l[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=l[e];l[u(e)]=n,l[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=l[e];l[u(e)]=n,l[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var p=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=p.apply(this,arguments);if(!e[u("patched")]){e[u("patched")]=u("patched");var n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},f&&["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}})}return e};var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,s.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}c&&c.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===s){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new c,this.testProxyZone=s.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); \ No newline at end of file diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index 0f88dd882..d457f94a6 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -3765,7 +3765,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach(function (methodName) { + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 5347637e2..28d496d71 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -2857,7 +2857,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach(function (methodName) { + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 735a76d7c..8d59251d7 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -433,7 +433,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - ['beforeEach', 'afterEach'].forEach(function (methodName) { + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { var originalJasmineFn = jasmineEnv[methodName]; jasmineEnv[symbol(methodName)] = originalJasmineFn; jasmineEnv[methodName] = function (specDefinitions, timeout) { diff --git a/package.json b/package.json index 480d675c7..93fde1c80 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zone.js", - "version": "0.8.27", + "version": "0.8.28", "description": "Zones for JavaScript", "main": "dist/zone-node.js", "browser": "dist/zone.js", From fd069db3b9f272d201bf0b75300793bc4a7c8152 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 23 Jan 2019 03:46:04 +0900 Subject: [PATCH 076/106] fix for tests in angular repo (#1179) --- lib/browser/register-element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index f590f0c60..23fd30d4e 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -26,7 +26,7 @@ function patchCallbacks(target: any, targetName: string, method: string, callbac if (descriptor && descriptor.value) { descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); - } else { + } else if (prototype[callback]) { prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } else if (prototype[callback]) { From ce9c2e056e1393e2d5e01be688f4cbf6d174ce15 Mon Sep 17 00:00:00 2001 From: Vikram Subramanian Date: Tue, 22 Jan 2019 12:02:35 -0800 Subject: [PATCH 077/106] chore: release v0.8.29 --- CHANGELOG.md | 9 +++++++++ dist/zone-mix.js | 2 +- dist/zone-testing-bundle.js | 2 +- dist/zone.js | 2 +- dist/zone.min.js | 2 +- package.json | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c9a1bbbe..00eac3742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ + +## [0.8.29](https://github.com/angular/zone.js/compare/v0.8.28...0.8.29) (2019-01-22) + + +### Bug Fixes + +* **core:** fix for tests in angular repo ([fd069db](https://github.com/angular/zone.js/commit/fd069db)) + + ## [0.8.28](https://github.com/angular/zone.js/compare/v0.8.27...0.8.28) (2019-01-16) diff --git a/dist/zone-mix.js b/dist/zone-mix.js index bf2006a0b..31d7f31d0 100644 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -2982,7 +2982,7 @@ function patchCallbacks(target, targetName, method, callbacks) { descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } - else { + else if (prototype[callback]) { prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index d457f94a6..902976b0a 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -3057,7 +3057,7 @@ function patchCallbacks(target, targetName, method, callbacks) { descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } - else { + else if (prototype[callback]) { prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } diff --git a/dist/zone.js b/dist/zone.js index fb3f4649b..80463ae48 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -3057,7 +3057,7 @@ function patchCallbacks(target, targetName, method, callbacks) { descriptor.value = wrapWithCurrentZone(descriptor.value, source); _redefineProperty(opts.prototype, callback, descriptor); } - else { + else if (prototype[callback]) { prototype[callback] = wrapWithCurrentZone(prototype[callback], source); } } diff --git a/dist/zone.min.js b/dist/zone.min.js index 2c5af2585..00515ef75 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +1,2 @@ -!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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=L(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return f(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o):e.apply(n,a)}})}function f(e,t){e[U("OriginalDelegate")]=t}function p(){try{var e=K.navigator.userAgent;if(e.indexOf("MSIE ")!==-1||e.indexOf("Trident/")!==-1)return!0}catch(t){}return!1}function h(){if(se)return ce;se=!0;try{var e=K.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ce=!0),ce}catch(t){}}function d(e,t,n){function r(t,n){function r(e){ue||"boolean"==typeof w.options||"undefined"==typeof w.options||null===w.options||(e.options=!!w.options.capture,w.options=e.options)}if(!t)return!1;var h=!0;n&&void 0!==n.useG&&(h=n.useG);var y=n&&n.vh,m=!0;n&&void 0!==n.chkDup&&(m=n.chkDup);var k=!1;n&&void 0!==n.rt&&(k=n.rt);for(var _=t;_&&!_.hasOwnProperty(o);)_=R(_);if(!_&&t[o]&&(_=t),!_)return!1;if(_[c])return!1;var b,T=n&&n.eventNameToString,w={},E=_[c]=_[o],S=_[U(a)]=_[a],D=_[U(i)]=_[i],Z=_[U(s)]=_[s];n&&n.prepend&&(b=_[U(n.prepend)]=_[n.prepend]);var z=function(e){if(!w.isExisting)return r(e),E.call(w.target,w.eventName,w.capture?g:d,w.options)},O=function(e){if(!e.isRemoved){var t=he[e.eventName],n=void 0;t&&(n=t[e.capture?W:X]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=L(a,"onmessage");return s&&s.configurable===!1?(r=H(a),o=a,[A,B,"send","close"].forEach(function(e){r[e]=function(){var t=F.call(arguments);if(e===A||e===B){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function E(e,t,n){if(!n||0===n.length)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function S(e,t,n,r){if(e){var o=E(e,t,n);i(e,o,r)}}function D(e,t){if(!ee||ne){var n="undefined"!=typeof WebSocket;if(Z()){var r=t.__Zone_ignore_on_properties;if(te){var o=window,a=p?[{target:o,ignoreProperties:["error"]}]:[];S(o,He.concat(["messageerror"]),r?r.concat(a):r,R(o)),S(Document.prototype,He,r),"undefined"!=typeof o.SVGElement&&S(o.SVGElement.prototype,He,r),S(Element.prototype,He,r),S(HTMLElement.prototype,He,r),S(HTMLMediaElement.prototype,De,r),S(HTMLFrameSetElement.prototype,Ee.concat(je),r),S(HTMLBodyElement.prototype,Ee.concat(je),r),S(HTMLFrameElement.prototype,Ce,r),S(HTMLIFrameElement.prototype,Ce,r);var i=o.HTMLMarqueeElement;i&&S(i.prototype,Ie,r);var c=o.Worker;c&&S(c.prototype,Re,r)}S(XMLHttpRequest.prototype,Me,r);var u=t.XMLHttpRequestEventTarget;u&&S(u&&u.prototype,Me,r),"undefined"!=typeof IDBIndex&&(S(IDBIndex.prototype,Le,r),S(IDBRequest.prototype,Le,r),S(IDBOpenDBRequest.prototype,Le,r),S(IDBDatabase.prototype,Le,r),S(IDBTransaction.prototype,Le,r),S(IDBCursor.prototype,Le,r)),n&&S(WebSocket.prototype,xe,r)}else z(),s("XMLHttpRequest"),n&&w(e,t)}}function Z(){if((te||ne)&&!L(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=L(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=L(n,t);if(r){x(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return x(n,t,r||{}),a}var i=U("fake");x(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function z(){for(var t=function(t){var n=He[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Fe]&&(n=e(a[r],o),n[Fe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return C.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o)){if(c)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.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)}},r.prototype.run=function(e,t,n,r){C={parent:C,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{C=C.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),C={parent:C,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{C=C.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==z&&e.type!==Z){var r=e.state!=w;r&&e._transitionTo(w,T),e.runCount++;var o=j;j=e,C={parent:C,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?r&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,w,_))),C=C.parent,j=o}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,(void 0)))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return C},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return[]},patchThen:function(){return a},setNativePromise:function(e){e&&"function"==typeof e.resolve&&(u=e.resolve(0))}},C={parent:null,zone:new l(null,null)},j=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[_];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return R.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(j);if(e[b]===Z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==O&&a instanceof R&&a.hasOwnProperty(b)&&a.hasOwnProperty(T)&&a[b]!==Z)l(a),u(e,a[b],a[T]);else if(o!==O&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[b]=o;var h=e[T];if(e[T]=a,e[w]===w&&o===z&&(e[b]=e[S],e[T]=e[E]),o===O&&a instanceof Error){var v=t.currentTask&&t.currentTask.data&&t.currentTask.data[k];v&&d(a,I,{configurable:!0,enumerable:!1,writable:!0,value:v})}for(var y=0;y=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=L(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return f(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o):e.apply(n,a)}})}function f(e,t){e[U("OriginalDelegate")]=t}function p(){try{var e=K.navigator.userAgent;if(e.indexOf("MSIE ")!==-1||e.indexOf("Trident/")!==-1)return!0}catch(t){}return!1}function h(){if(se)return ce;se=!0;try{var e=K.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ce=!0),ce}catch(t){}}function d(e,t,n){function r(t,n){function r(e){ue||"boolean"==typeof w.options||"undefined"==typeof w.options||null===w.options||(e.options=!!w.options.capture,w.options=e.options)}if(!t)return!1;var h=!0;n&&void 0!==n.useG&&(h=n.useG);var y=n&&n.vh,m=!0;n&&void 0!==n.chkDup&&(m=n.chkDup);var k=!1;n&&void 0!==n.rt&&(k=n.rt);for(var _=t;_&&!_.hasOwnProperty(o);)_=R(_);if(!_&&t[o]&&(_=t),!_)return!1;if(_[c])return!1;var b,T=n&&n.eventNameToString,w={},E=_[c]=_[o],S=_[U(a)]=_[a],D=_[U(i)]=_[i],Z=_[U(s)]=_[s];n&&n.prepend&&(b=_[U(n.prepend)]=_[n.prepend]);var z=function(e){if(!w.isExisting)return r(e),E.call(w.target,w.eventName,w.capture?g:d,w.options)},O=function(e){if(!e.isRemoved){var t=he[e.eventName],n=void 0;t&&(n=t[e.capture?W:X]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=L(a,"onmessage");return s&&s.configurable===!1?(r=H(a),o=a,[A,B,"send","close"].forEach(function(e){r[e]=function(){var t=F.call(arguments);if(e===A||e===B){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function E(e,t,n){if(!n||0===n.length)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function S(e,t,n,r){if(e){var o=E(e,t,n);i(e,o,r)}}function D(e,t){if(!ee||ne){var n="undefined"!=typeof WebSocket;if(Z()){var r=t.__Zone_ignore_on_properties;if(te){var o=window,a=p?[{target:o,ignoreProperties:["error"]}]:[];S(o,He.concat(["messageerror"]),r?r.concat(a):r,R(o)),S(Document.prototype,He,r),"undefined"!=typeof o.SVGElement&&S(o.SVGElement.prototype,He,r),S(Element.prototype,He,r),S(HTMLElement.prototype,He,r),S(HTMLMediaElement.prototype,De,r),S(HTMLFrameSetElement.prototype,Ee.concat(je),r),S(HTMLBodyElement.prototype,Ee.concat(je),r),S(HTMLFrameElement.prototype,Ce,r),S(HTMLIFrameElement.prototype,Ce,r);var i=o.HTMLMarqueeElement;i&&S(i.prototype,Ie,r);var c=o.Worker;c&&S(c.prototype,Re,r)}S(XMLHttpRequest.prototype,Me,r);var u=t.XMLHttpRequestEventTarget;u&&S(u&&u.prototype,Me,r),"undefined"!=typeof IDBIndex&&(S(IDBIndex.prototype,Le,r),S(IDBRequest.prototype,Le,r),S(IDBOpenDBRequest.prototype,Le,r),S(IDBDatabase.prototype,Le,r),S(IDBTransaction.prototype,Le,r),S(IDBCursor.prototype,Le,r)),n&&S(WebSocket.prototype,xe,r)}else z(),s("XMLHttpRequest"),n&&w(e,t)}}function Z(){if((te||ne)&&!L(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=L(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=L(n,t);if(r){x(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return x(n,t,r||{}),a}var i=U("fake");x(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function z(){for(var t=function(t){var n=He[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Fe]&&(n=e(a[r],o),n[Fe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return C.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o)){if(c)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.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)}},r.prototype.run=function(e,t,n,r){C={parent:C,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{C=C.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),C={parent:C,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{C=C.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==z&&e.type!==Z){var r=e.state!=w;r&&e._transitionTo(w,T),e.runCount++;var o=j;j=e,C={parent:C,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?r&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,w,_))),C=C.parent,j=o}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,(void 0)))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return C},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return[]},patchThen:function(){return a},setNativePromise:function(e){e&&"function"==typeof e.resolve&&(u=e.resolve(0))}},C={parent:null,zone:new l(null,null)},j=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[_];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return R.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(j);if(e[b]===Z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==O&&a instanceof R&&a.hasOwnProperty(b)&&a.hasOwnProperty(T)&&a[b]!==Z)l(a),u(e,a[b],a[T]);else if(o!==O&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[b]=o;var h=e[T];if(e[T]=a,e[w]===w&&o===z&&(e[b]=e[S],e[T]=e[E]),o===O&&a instanceof Error){var v=t.currentTask&&t.currentTask.data&&t.currentTask.data[k];v&&d(a,I,{configurable:!0,enumerable:!1,writable:!0,value:v})}for(var y=0;y1?c[1]:null,h=p&&p.signal;return new Promise(function(p,d){var v=t.current.scheduleMacroTask("fetch",f,c,function(){var s,u=t.current;try{u[i]=!0,s=r.apply(e,c)}catch(l){return void d(l)}finally{u[i]=!1}if(!(s instanceof o)){var f=s.constructor;f[a]||n.patchThen(f)}s.then(function(e){"notScheduled"!==v.state&&v.invoke(),p(e)},function(e){"notScheduled"!==v.state&&v.invoke(),d(e)})},function(){if(!u)return void d("No AbortController supported, can not cancel fetch");if(h&&h.abortController&&!h.aborted&&"function"==typeof h.abortController.abort&&l)try{t.current[s]=!0,l.call(h.abortController)}finally{t.current[s]=!1}else d("cancel fetch need a AbortController.signal")});h&&h.abortController&&(h.abortController.task=v)})}}});var L=Object.getOwnPropertyDescriptor,x=Object.defineProperty,R=Object.getPrototypeOf,H=Object.create,F=Array.prototype.slice,A="addEventListener",B="removeEventListener",q=Zone.__symbol__(A),N=Zone.__symbol__(B),W="true",X="false",G="__zone_symbol__",U=Zone.__symbol__,V="undefined"!=typeof window,K=V?window:void 0,J=V&&K||"object"==typeof self&&self||global,Y="removeAttribute",Q=[null],$="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,ee=!("nw"in J)&&"undefined"!=typeof J.process&&"[object process]"==={}.toString.call(J.process),te=!ee&&!$&&!(!V||!K.HTMLElement),ne="undefined"!=typeof J.process&&"[object process]"==={}.toString.call(J.process)&&!$&&!(!V||!K.HTMLElement),re={},oe=function(e){if(e=e||J.event){var t=re[e.type];t||(t=re[e.type]=U("ON_PROPERTY"+e.type));var n,r=this||e.target||J,o=r[t];if(te&&r===K&&"error"===e.type){var a=e;n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error),n===!0&&e.preventDefault()}else n=o&&o.apply(this,arguments),void 0==n||n||e.preventDefault();return n}},ae=U("originalInstance"),ie=!1,se=!1,ce=!1;Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=U("OriginalDelegate"),r=U("Promise"),o=U("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.apply(this[n],arguments):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.apply(i,arguments)}if(this===Error){var s=e[o];if(s)return t.apply(s,arguments)}}return t.apply(this,arguments)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString,s="[object Promise]";Object.prototype.toString=function(){return this instanceof Promise?s:i.apply(this,arguments)}});var ue=!1;if("undefined"!=typeof window)try{var le=Object.defineProperty({},"passive",{get:function(){ue=!0}});window.addEventListener("test",le,le),window.removeEventListener("test",le,le)}catch(fe){ue=!1}var pe={useG:!0},he={},de={},ve=/^__zone_symbol__(\w+)(true|false)$/,ge="__zone_symbol__propagationStopped",ye=U("zoneTask"),me=Object[U("defineProperty")]=Object.defineProperty,ke=Object[U("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_e=Object.create,be=U("unconfigurables"),Te=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],we=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],Ee=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],Se=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],De=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],Ze=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],ze=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],Oe=["autocomplete","autocompleteerror"],Pe=["toggle"],Ce=["load"],je=["blur","error","focus","load","resize","scroll","messageerror"],Ie=["bounce","finish","start"],Me=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],Le=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],xe=["close","error","open","message"],Re=["error","message"],He=Te.concat(ze,Oe,Pe,we,Ee,Se,Ze),Fe=U("unbound");Zone.__load_patch("util",function(e,t,r){r.patchOnProperties=i,r.patchMethod=u,r.bindArguments=n}),Zone.__load_patch("timers",function(e){var t="set",n="clear";y(e,t,n,"Timeout"),y(e,t,n,"Interval"),y(e,t,n,"Immediate")}),Zone.__load_patch("requestAnimationFrame",function(e){y(e,"request","cancel","AnimationFrame"),y(e,"mozRequest","mozCancel","AnimationFrame"),y(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",function(e,t){for(var n=["alert","prompt","confirm"],r=0;r0){var o=e.invoke;e.invoke=function(){for(var r=n.__zone_symbol__loadfalse,a=0;a Date: Sat, 9 Feb 2019 22:10:19 +0800 Subject: [PATCH 078/106] build: seperate zone.js into evergreen only and legacy included bundles. --- .travis.yml | 1 + README.md | 32 ++++ gulpfile.js | 67 ++++++- karma-dist.conf.js | 2 + karma-evergreen-dist-jasmine.conf.js | 7 + karma-evergreen-dist-sauce-jasmine.conf.js | 12 ++ karma-evergreen-dist.conf.js | 25 +++ lib/browser/api-util.ts | 16 ++ lib/browser/browser-legacy.ts | 28 +++ lib/browser/browser.ts | 22 +-- lib/browser/canvas.ts | 16 ++ lib/browser/custom-elements.ts | 54 ++++++ lib/browser/event-target-legacy.ts | 113 ++++++++++++ lib/browser/event-target.ts | 85 +-------- lib/browser/property-descriptor-legacy.ts | 126 ++++++++++++++ lib/browser/property-descriptor.ts | 192 ++++++--------------- lib/browser/register-element.ts | 47 +---- lib/browser/rollup-common.ts | 12 ++ lib/browser/rollup-legacy-main.ts | 11 ++ lib/browser/rollup-legacy-test-main.ts | 12 ++ lib/browser/rollup-main.ts | 5 +- lib/common/fetch.ts | 15 +- lib/common/promise.ts | 5 + lib/node/node_util.ts | 3 +- lib/zone.ts | 5 +- sauce-evergreen.conf.js | 73 ++++++++ test/browser-zone-setup.ts | 3 + test/browser/browser.spec.ts | 6 +- test/browser/registerElement.spec.ts | 2 +- test/zone_worker_entry_point.ts | 32 ++-- tsconfig-esm-node.json | 2 +- tsconfig-esm.json | 2 +- tsconfig-node.json | 2 +- tsconfig.json | 2 +- 34 files changed, 713 insertions(+), 324 deletions(-) create mode 100644 karma-evergreen-dist-jasmine.conf.js create mode 100644 karma-evergreen-dist-sauce-jasmine.conf.js create mode 100644 karma-evergreen-dist.conf.js create mode 100644 lib/browser/api-util.ts create mode 100644 lib/browser/browser-legacy.ts create mode 100644 lib/browser/canvas.ts create mode 100644 lib/browser/custom-elements.ts create mode 100644 lib/browser/event-target-legacy.ts create mode 100644 lib/browser/property-descriptor-legacy.ts create mode 100644 lib/browser/rollup-common.ts create mode 100644 lib/browser/rollup-legacy-main.ts create mode 100644 lib/browser/rollup-legacy-test-main.ts create mode 100644 sauce-evergreen.conf.js diff --git a/.travis.yml b/.travis.yml index 1dc7307e2..8a219aca0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,3 +56,4 @@ script: - node_modules/.bin/gulp test/node -no-patch-clock - cp ./test/browser/custom-element.spec.js ./build/test/browser - node_modules/.bin/karma start karma-dist-sauce-jasmine.es6.conf.js --single-run + - node_modules/.bin/karma start karma-evergreen-dist-sauce-jasmine.conf.js --single-run diff --git a/README.md b/README.md index 07ab1c9c1..b0ef5faad 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,38 @@ Starting from zone.js v0.8.9, you can choose which web API module you want to pa For more details, please see [MODULE.md](MODULE.md). +## Bundles +There are several bundles under `dist` folder. + +|Bundle|Summary| +|---|---| +|zone.js|the default bundle, contains the most used APIs such as `setTimeout/Promise/EventTarget...`, also this bundle supports all evergreen and legacy (IE/Legacy Firefox/Legacy Safari) Browsers| +|zone-evergreen.js|the bundle for evergreen browsers, doesn't include the `patch` for `legacy` browsers such as `IE` or old versions of `Firefox/Safari`| +|zone-legacy.js|the patch bundle for legacy browsers, only includes the `patch` for `legacy` browsers such as `IE` or old versions of `Firefox/Safari`. This bundle must be loaded after `zone-evergreen.js`, **`zone.js`=`zone-evergreen.js` + `zone-legacy.js`**| +|zone-testing.js|the bundle for zone testing support, including `jasmine/mocha` support and `async/fakeAsync/sync` test utilities| +|zone-externs.js|the API definitions for `closure compiler`| + +And here are the additional optional patches not included in the main zone.js bundles + +|Patch|Summary| +|---|---| +|webapis-media-query.js|patch for `MediaQuery APIs`| +|webapis-notification.js|patch for `Notification APIs`| +|webapis-rtc-peer-connection.js|patch for `RTCPeerConnection APIs`| +|webapis-shadydom.js|patch for `Shady DOM APIs`| +|zone-bluebird.js|patch for `Bluebird APIs`| +|zone-error.js|patch for `Error Global Object`, supports remove `Zone StackTrace`| +|zone-patch-canvas.js|patch for `Canvas API`| +|zone-patch-cordova.js|patch for `Cordova API`| +|zone-patch-electron.js|patch for `Electron API`| +|zone-patch-fetch.js|patch for `Fetch API`| +|zone-patch-jsonp.js|utility for `jsonp API`| +|zone-patch-resize-observer.js|patch for `ResizeObserver API`| +|zone-patch-rxjs.js|patch for `rxjs API`| +|zone-patch-rxjs-fake-async.js|patch for `rxjs fakeasync test`| +|zone-patch-socket-io.js|patch for `socket-io`| +|zone-patch-user-media.js|patch for `UserMedia API`| + ## Promise A+ test passed [![Promises/A+ 1.1 compliant](https://promisesaplus.com/assets/logo-small.png)](https://promisesaplus.com/) diff --git a/gulpfile.js b/gulpfile.js index 64235017b..86f1e1482 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,7 +16,10 @@ var path = require('path'); var spawn = require('child_process').spawn; const os = require('os'); -function generateScript(inFile, outFile, minify, callback) { +function generateScript(inFile, outFile, minify, callback, format) { + if (!format) { + format = 'umd'; + } inFile = path.join('./build-esm/', inFile).replace(/\.ts$/, '.js'); var parts = [ gulp.src('./build-esm/lib/**/*.js') @@ -30,7 +33,7 @@ function generateScript(inFile, outFile, minify, callback) { console.error(warning.message); }, output: { - format: 'umd', + format: format, name: 'zone', banner: '/**\n' + '* @license\n' + @@ -115,16 +118,39 @@ gulp.task('build/zone-node.js', ['compile-esm-node'], function(cb) { // Zone for the browser. gulp.task('build/zone.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/rollup-main.ts', 'zone.js', false, cb); + return generateScript('./lib/browser/rollup-legacy-main.ts', 'zone.js', false, cb); }); gulp.task('build/zone.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/rollup-main.ts', 'zone.min.js', true, cb); + return generateScript('./lib/browser/rollup-legacy-main.ts', 'zone.min.js', true, cb); +}); + +// Zone for the evergreen browser. +gulp.task('build/zone-evergreen.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/rollup-main.ts', 'zone-evergreen.js', false, cb); +}); + +gulp.task('build/zone-evergreen.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/rollup-main.ts', 'zone-evergreen.min.js', true, cb); +}); + +// Zone legacy patch for the legacy browser. +gulp.task('build/zone-legacy.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/browser-legacy.ts', 'zone-legacy.js', false, cb); +}); + +gulp.task('build/zone-legacy.min.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/browser-legacy.ts', 'zone-legacy.min.js', true, cb); }); // Zone test bundle for the browser. gulp.task('build/zone-testing-bundle.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/rollup-test-main.ts', 'zone-testing-bundle.js', false, cb); + return generateScript('./lib/browser/rollup-legacy-test-main.ts', 'zone-testing-bundle.js', false, cb); +}); + +// Zone test bundle for the evergreen browser. +gulp.task('build/zone-evergreen-testing-bundle.js', ['compile-esm'], function(cb) { + return generateScript('./lib/browser/rollup-test-main.ts', 'zone-evergreen-testing-bundle.js', false, cb); }); // Zone test bundle for node. @@ -150,6 +176,27 @@ gulp.task('build/zone-error.min.js', ['compile-esm'], function(cb) { return generateScript('./lib/common/error-rewrite.ts', 'zone-error.min.js', true, cb); }); +gulp.task('build/zone-patch-canvas.js', ['compile-esm'], function(cb) { + return generateScript( + './lib/browser/canvas.ts', 'zone-patch-canvas.js', false, cb); +}); + +gulp.task('build/zone-patch-canvas.min.js', ['compile-esm'], function(cb) { + return generateScript( + './lib/browser/canvas.ts', 'zone-patch-canvas.min.js', true, cb); +}); + +gulp.task('build/zone-patch-fetch.js', ['compile-esm'], function(cb) { + return generateScript( + './lib/common/fetch.ts', 'zone-patch-fetch.js', false, cb); +}); + +gulp.task('build/zone-patch-fetch.min.js', ['compile-esm'], function(cb) { + return generateScript( + './lib/common/fetch.ts', 'zone-patch-fetch.min.js', true, cb); +}); + + gulp.task('build/webapis-media-query.js', ['compile-esm'], function(cb) { return generateScript( './lib/browser/webapis-media-query.ts', 'webapis-media-query.js', false, cb); @@ -347,12 +394,21 @@ gulp.task('build', [ 'build/zone.js', 'build/zone.js.d.ts', 'build/zone.min.js', + 'build/zone-evergreen.js', + 'build/zone-evergreen.min.js', + 'build/zone-legacy.js', + 'build/zone-legacy.min.js', 'build/zone-testing.js', 'build/zone-testing-bundle.js', + 'build/zone-evergreen-testing-bundle.js', 'build/zone-testing-node-bundle.js', 'build/zone-error.js', 'build/zone-error.min.js', 'build/zone-node.js', + 'build/zone-patch-canvas.js', + 'build/zone-patch-canvas.min.js', + 'build/zone-patch-fetch.js', + 'build/zone-patch-fetch.min.js', 'build/webapis-media-query.js', 'build/webapis-media-query.min.js', 'build/webapis-notification.js', @@ -409,7 +465,6 @@ function nodeTest(specFiles, cb) { require('./build/test/test-env-setup-jasmine' + args[3]); } var JasmineRunner = require('jasmine'); - var JasmineRunner = require('jasmine'); var jrunner = new JasmineRunner(); jrunner.configureDefaultReporter({showColors: true}); diff --git a/karma-dist.conf.js b/karma-dist.conf.js index 8d45297f2..f2121d364 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -12,6 +12,8 @@ module.exports = function(config) { config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); config.files.push('dist/zone.js'); + config.files.push('dist/zone-patch-fetch.js'); + config.files.push('dist/zone-patch-canvas.js'); config.files.push('dist/webapis-media-query.js'); config.files.push('dist/webapis-notification.js'); config.files.push('dist/zone-patch-user-media.js'); diff --git a/karma-evergreen-dist-jasmine.conf.js b/karma-evergreen-dist-jasmine.conf.js new file mode 100644 index 000000000..0426c9f7a --- /dev/null +++ b/karma-evergreen-dist-jasmine.conf.js @@ -0,0 +1,7 @@ + +module.exports = function (config) { + require('./karma-evergreen-dist.conf.js')(config); + + config.plugins.push(require('karma-jasmine')); + config.frameworks.push('jasmine'); +}; diff --git a/karma-evergreen-dist-sauce-jasmine.conf.js b/karma-evergreen-dist-sauce-jasmine.conf.js new file mode 100644 index 000000000..748cc9c21 --- /dev/null +++ b/karma-evergreen-dist-sauce-jasmine.conf.js @@ -0,0 +1,12 @@ +/** + * @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 + */ + +module.exports = function (config) { + require('./karma-evergreen-dist-jasmine.conf.js')(config); + require('./sauce-evergreen.conf')(config); +}; diff --git a/karma-evergreen-dist.conf.js b/karma-evergreen-dist.conf.js new file mode 100644 index 000000000..a4f4678da --- /dev/null +++ b/karma-evergreen-dist.conf.js @@ -0,0 +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 + */ + +module.exports = function(config) { + require('./karma-base.conf.js')(config); + config.files.push('build/test/wtf_mock.js'); + config.files.push('build/test/test_fake_polyfill.js'); + config.files.push('build/test/custom_error.js'); + config.files.push('dist/zone-evergreen.js'); + config.files.push('dist/zone-patch-canvas.js'); + config.files.push('dist/zone-patch-fetch.js'); + config.files.push('dist/webapis-media-query.js'); + config.files.push('dist/webapis-notification.js'); + config.files.push('dist/zone-patch-user-media.js'); + config.files.push('dist/zone-patch-resize-observer.js'); + config.files.push('dist/task-tracking.js'); + config.files.push('dist/wtf.js'); + config.files.push('dist/zone-testing.js'); + config.files.push('build/test/main.js'); +}; diff --git a/lib/browser/api-util.ts b/lib/browser/api-util.ts new file mode 100644 index 000000000..7b2602e18 --- /dev/null +++ b/lib/browser/api-util.ts @@ -0,0 +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 {bindArguments, patchMacroTask, patchMethod, patchOnProperties} from '../common/utils'; + +Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; +}); diff --git a/lib/browser/browser-legacy.ts b/lib/browser/browser-legacy.ts new file mode 100644 index 000000000..4fb3e6ce9 --- /dev/null +++ b/lib/browser/browser-legacy.ts @@ -0,0 +1,28 @@ +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ + +import {eventTargetLegacyPatch} from './event-target-legacy'; +import {propertyDescriptorLegacyPatch} from './property-descriptor-legacy'; +import {registerElementPatch} from './register-element'; + +Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + registerElementPatch(global); +}); + +Zone.__load_patch('EventTargetLegacy', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; + } + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); +}); diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 0d7ab2458..73e7e121b 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -12,18 +12,13 @@ import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; -import {bindArguments, patchClass, patchMacroTask, patchMethod, patchOnProperties, patchPrototype, scheduleMacroTaskWithCurrentZone, ZONE_SYMBOL_ADD_EVENT_LISTENER, ZONE_SYMBOL_REMOVE_EVENT_LISTENER, zoneSymbol} from '../common/utils'; +import {patchClass, patchMethod, patchPrototype, scheduleMacroTaskWithCurrentZone, ZONE_SYMBOL_ADD_EVENT_LISTENER, ZONE_SYMBOL_REMOVE_EVENT_LISTENER, zoneSymbol} from '../common/utils'; +import {patchCustomElements} from './custom-elements'; import {propertyPatch} from './define-property'; import {eventTargetPatch, patchEvent} from './event-target'; import {propertyDescriptorPatch} from './property-descriptor'; -import {patchCustomElements, registerElementPatch} from './register-element'; - -Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; -}); +import {registerElementPatch} from './register-element'; Zone.__load_patch('timers', (global: any) => { const set = 'set'; @@ -77,20 +72,9 @@ Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate }); Zone.__load_patch('customElements', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - registerElementPatch(global); patchCustomElements(global); }); -Zone.__load_patch('canvas', (global: any) => { - const HTMLCanvasElement = global['HTMLCanvasElement']; - if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && - HTMLCanvasElement.prototype.toBlob) { - patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', (self: any, args: any[]) => { - return {name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args}; - }); - } -}); - Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { // Treat XMLHttpRequest as a macrotask. patchXHR(global); diff --git a/lib/browser/canvas.ts b/lib/browser/canvas.ts new file mode 100644 index 000000000..527e09817 --- /dev/null +++ b/lib/browser/canvas.ts @@ -0,0 +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 + */ +Zone.__load_patch('canvas', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + const HTMLCanvasElement = global['HTMLCanvasElement']; + if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && + HTMLCanvasElement.prototype.toBlob) { + api.patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', (self: any, args: any[]) => { + return {name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args}; + }); + } +}); diff --git a/lib/browser/custom-elements.ts b/lib/browser/custom-elements.ts new file mode 100644 index 000000000..be37aa2d4 --- /dev/null +++ b/lib/browser/custom-elements.ts @@ -0,0 +1,54 @@ +/** + * @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 {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor, wrapWithCurrentZone} from '../common/utils'; + +import {_redefineProperty} from './define-property'; + +export function patchCallbacks( + target: any, targetName: string, method: string, callbacks: string[]) { + const symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + const nativeDelegate = target[symbol] = target[method]; + target[method] = function(name: any, opts: any, options?: any) { + if (opts && opts.prototype) { + callbacks.forEach(function(callback) { + const source = `${targetName}.${method}::` + callback; + const prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + const descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = wrapWithCurrentZone(descriptor.value, source); + _redefineProperty(opts.prototype, callback, descriptor); + } else if (prototype[callback]) { + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); + } + } else if (prototype[callback]) { + prototype[callback] = wrapWithCurrentZone(prototype[callback], source); + } + }); + } + + return nativeDelegate.call(target, name, opts, options); + }; + + attachOriginToPatched(target[method], nativeDelegate); +} + +export function patchCustomElements(_global: any) { + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + + const callbacks = + ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + + patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); +} diff --git a/lib/browser/event-target-legacy.ts b/lib/browser/event-target-legacy.ts new file mode 100644 index 000000000..610f08be1 --- /dev/null +++ b/lib/browser/event-target-legacy.ts @@ -0,0 +1,113 @@ +/** + * @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 {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNames} from '../common/events'; +import {FALSE_STR, isIEOrEdge, TRUE_STR, ZONE_SYMBOL_PREFIX} from '../common/utils'; + +import {eventNames} from './property-descriptor'; + +export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { + 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,WebSocket' + .split(','); + const EVENT_TARGET = 'EventTarget'; + + let apis: any[] = []; + const isWtf = _global['wtf']; + const WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); + + if (isWtf) { + // Workaround for: https://github.com/google/tracing-framework/issues/555 + apis = WTF_ISSUE_555_ARRAY.map((v) => 'HTML' + v + 'Element').concat(NO_EVENT_TARGET); + } else if (_global[EVENT_TARGET]) { + // EventTarget is already patched in browser.ts + } 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; + } + + const isDisableIECheck = _global['__Zone_disable_IE_check'] || false; + const isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; + const ieOrEdge = isIEOrEdge(); + + const ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; + const FUNCTION_WRAPPER = '[object FunctionWrapper]'; + const BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; + + // predefine all __zone_symbol__ + eventName + true/false string + for (let i = 0; i < eventNames.length; i++) { + const eventName = eventNames[i]; + const falseEventName = eventName + FALSE_STR; + const trueEventName = eventName + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + + // predefine all task.source string + for (let i = 0; i < WTF_ISSUE_555.length; i++) { + const target: any = WTF_ISSUE_555_ARRAY[i]; + const targets: any = globalSources[target] = {}; + for (let j = 0; j < eventNames.length; j++) { + const eventName = eventNames[j]; + targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + } + } + + const checkIEAndCrossContext = function( + nativeDelegate: any, delegate: any, target: any, args: any) { + if (!isDisableIECheck && ieOrEdge) { + if (isEnableCrossContextCheck) { + try { + const testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } else { + const testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } + } else if (isEnableCrossContextCheck) { + try { + delegate.toString(); + } catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } + return true; + }; + + const apiTypes: any[] = []; + for (let i = 0; i < apis.length; i++) { + const type = _global[apis[i]]; + apiTypes.push(type && type.prototype); + } + // vh is validateHandler to check event handler + // is valid or not(for security check) + patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); + + return true; +} + +export function patchEvent(global: any, api: _ZonePrivate) { + patchEventPrototype(global, api); +} diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index 4a67d7567..0f4c23c4b 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -7,41 +7,11 @@ */ import {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNames} from '../common/events'; -import {FALSE_STR, isIEOrEdge, TRUE_STR, ZONE_SYMBOL_PREFIX} from '../common/utils'; +import {FALSE_STR, TRUE_STR, ZONE_SYMBOL_PREFIX} from '../common/utils'; import {eventNames} from './property-descriptor'; export function eventTargetPatch(_global: any, api: _ZonePrivate) { - 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,WebSocket' - .split(','); - const EVENT_TARGET = 'EventTarget'; - - let apis = []; - const isWtf = _global['wtf']; - const WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); - - if (isWtf) { - // Workaround for: https://github.com/google/tracing-framework/issues/555 - apis = WTF_ISSUE_555_ARRAY.map((v) => 'HTML' + v + 'Element').concat(NO_EVENT_TARGET); - } else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); - } else { - // Note: EventTarget is not available in all browsers, - // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget - apis = NO_EVENT_TARGET; - } - - const isDisableIECheck = _global['__Zone_disable_IE_check'] || false; - const isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - const ieOrEdge = isIEOrEdge(); - - const ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; - const FUNCTION_WRAPPER = '[object FunctionWrapper]'; - const BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; - // predefine all __zone_symbol__ + eventName + true/false string for (let i = 0; i < eventNames.length; i++) { const eventName = eventNames[i]; @@ -54,56 +24,11 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; } - // predefine all task.source string - for (let i = 0; i < WTF_ISSUE_555.length; i++) { - const target: any = WTF_ISSUE_555_ARRAY[i]; - const targets: any = globalSources[target] = {}; - for (let j = 0; j < eventNames.length; j++) { - const eventName = eventNames[j]; - targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; - } - } - - const checkIEAndCrossContext = function( - nativeDelegate: any, delegate: any, target: any, args: any) { - if (!isDisableIECheck && ieOrEdge) { - if (isEnableCrossContextCheck) { - try { - const testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { - nativeDelegate.apply(target, args); - return false; - } - } catch (error) { - nativeDelegate.apply(target, args); - return false; - } - } else { - const testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { - nativeDelegate.apply(target, args); - return false; - } - } - } else if (isEnableCrossContextCheck) { - try { - delegate.toString(); - } catch (error) { - nativeDelegate.apply(target, args); - return false; - } - } - return true; - }; - - const apiTypes: any[] = []; - for (let i = 0; i < apis.length; i++) { - const type = _global[apis[i]]; - apiTypes.push(type && type.prototype); + const EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; } - // vh is validateHandler to check event handler - // is valid or not(for security check) - patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); + patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); api.patchEventTarget = patchEventTarget; return true; diff --git a/lib/browser/property-descriptor-legacy.ts b/lib/browser/property-descriptor-legacy.ts new file mode 100644 index 000000000..b994fd0ad --- /dev/null +++ b/lib/browser/property-descriptor-legacy.ts @@ -0,0 +1,126 @@ +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ + +import {isBrowser, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, patchClass, patchOnProperties, wrapWithCurrentZone, zoneSymbol} from '../common/utils'; + +import {eventNames, filterProperties, IgnoreProperty} from './property-descriptor'; +import * as webSocketPatch from './websocket'; + +export function patchFilteredProperties( + target: any, onProperties: string[], ignoreProperties: IgnoreProperty[], prototype?: any) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + const filteredProperties: string[] = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); +} + +export function propertyDescriptorLegacyPatch(api: _ZonePrivate, _global: any) { + if (isNode && !isMix) { + return; + } + + const supportsWebSocket = typeof WebSocket !== 'undefined'; + if (!canPatchViaPropertyDescriptor()) { + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(); + patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + webSocketPatch.apply(api, _global); + } + (Zone as any)[api.symbol('patchEvents')] = true; + } +} + +function canPatchViaPropertyDescriptor() { + if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + const desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) return false; + } + + const ON_READY_STATE_CHANGE = 'onreadystatechange'; + const XMLHttpRequestPrototype = XMLHttpRequest.prototype; + + const xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function() { + return true; + } + }); + const req = new XMLHttpRequest(); + const result = !!req.onreadystatechange; + // restore original desc + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + return result; + } else { + const SYMBOL_FAKE_ONREADYSTATECHANGE = zoneSymbol('fake'); + ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function() { + return this[SYMBOL_FAKE_ONREADYSTATECHANGE]; + }, + set: function(value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE] = value; + } + }); + const req = new XMLHttpRequest(); + const detectFunc = () => {}; + req.onreadystatechange = detectFunc; + const result = (req as any)[SYMBOL_FAKE_ONREADYSTATECHANGE] === detectFunc; + req.onreadystatechange = null as any; + return result; + } +} + +const unboundKey = zoneSymbol('unbound'); + +// Whenever any eventListener fires, we check the eventListener target and all parents +// for `onwhatever` properties and replace them with zone-bound functions +// - Chrome (for now) +function patchViaCapturingAllTheEvents() { + for (let i = 0; i < eventNames.length; i++) { + const property = eventNames[i]; + const onproperty = 'on' + property; + self.addEventListener(property, function(event) { + let elt: any = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; + } else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; + } + elt = elt.parentElement; + } + }, true); + } +} diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 60500d2d7..39b8ae139 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -239,7 +239,7 @@ export interface IgnoreProperty { ignoreProperties: string[]; } -function filterProperties( +export function filterProperties( target: any, onProperties: string[], ignoreProperties: IgnoreProperty[]): string[] { if (!ignoreProperties || ignoreProperties.length === 0) { return onProperties; @@ -269,153 +269,65 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { if (isNode && !isMix) { return; } + if ((Zone as any)[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } const supportsWebSocket = typeof WebSocket !== 'undefined'; - if (canPatchViaPropertyDescriptor()) { - const ignoreProperties: IgnoreProperty[] = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - const internalWindow: any = window; - const ignoreErrorProperties = - isIE ? [{target: internalWindow, ignoreProperties: ['error']}] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties( - internalWindow, eventNames.concat(['messageerror']), - ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, - ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + const ignoreProperties: IgnoreProperty[] = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + const internalWindow: any = window; + const ignoreErrorProperties = + isIE ? [{target: internalWindow, ignoreProperties: ['error']}] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties( + internalWindow, eventNames.concat(['messageerror']), + ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, + ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties( - internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties( - HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), - ignoreProperties); - patchFilteredProperties( - HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - - const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement) { - patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); - } - const Worker = internalWindow['Worker']; - if (Worker) { - patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); - } - } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties( - XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, - XMLHttpRequestEventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties( + HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), + ignoreProperties); + patchFilteredProperties( + HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + + const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement) { + patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); } - } else { - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(); - patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - webSocketPatch.apply(api, _global); + const Worker = internalWindow['Worker']; + if (Worker) { + patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); } } -} - -function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - const desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) return false; + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties( + XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, + ignoreProperties); } - - const ON_READY_STATE_CHANGE = 'onreadystatechange'; - const XMLHttpRequestPrototype = XMLHttpRequest.prototype; - - const xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function() { - return true; - } - }); - const req = new XMLHttpRequest(); - const result = !!req.onreadystatechange; - // restore original desc - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } else { - const SYMBOL_FAKE_ONREADYSTATECHANGE = zoneSymbol('fake'); - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function() { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE]; - }, - set: function(value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE] = value; - } - }); - const req = new XMLHttpRequest(); - const detectFunc = () => {}; - req.onreadystatechange = detectFunc; - const result = (req as any)[SYMBOL_FAKE_ONREADYSTATECHANGE] === detectFunc; - req.onreadystatechange = null as any; - return result; + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); } -} - -const unboundKey = zoneSymbol('unbound'); - -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents() { - for (let i = 0; i < eventNames.length; i++) { - const property = eventNames[i]; - const onproperty = 'on' + property; - self.addEventListener(property, function(event) { - let elt: any = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; - } - elt = elt.parentElement; - } - }, true); + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); } } diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index 23fd30d4e..911a25166 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -6,40 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor, wrapWithCurrentZone} from '../common/utils'; - -import {_redefineProperty} from './define-property'; - -function patchCallbacks(target: any, targetName: string, method: string, callbacks: string[]) { - const symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; - } - const nativeDelegate = target[symbol] = target[method]; - target[method] = function(name: any, opts: any, options?: any) { - if (opts && opts.prototype) { - callbacks.forEach(function(callback) { - const source = `${targetName}.${method}::` + callback; - const prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - const descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = wrapWithCurrentZone(descriptor.value, source); - _redefineProperty(opts.prototype, callback, descriptor); - } else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } - } else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } - }); - } - - return nativeDelegate.call(target, name, opts, options); - }; - - attachOriginToPatched(target[method], nativeDelegate); -} +import {isBrowser, isMix} from '../common/utils'; +import {patchCallbacks} from './custom-elements'; export function registerElementPatch(_global: any) { if ((!isBrowser && !isMix) || !('registerElement' in (_global).document)) { @@ -51,14 +19,3 @@ export function registerElementPatch(_global: any) { patchCallbacks(document, 'Document', 'registerElement', callbacks); } - -export function patchCustomElements(_global: any) { - if ((!isBrowser && !isMix) || !('customElements' in _global)) { - return; - } - - const callbacks = - ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - - patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); -} diff --git a/lib/browser/rollup-common.ts b/lib/browser/rollup-common.ts new file mode 100644 index 000000000..006ede27e --- /dev/null +++ b/lib/browser/rollup-common.ts @@ -0,0 +1,12 @@ +/** + * @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 '../common/promise'; +import '../common/to-string'; +import './api-util'; diff --git a/lib/browser/rollup-legacy-main.ts b/lib/browser/rollup-legacy-main.ts new file mode 100644 index 000000000..68034c61c --- /dev/null +++ b/lib/browser/rollup-legacy-main.ts @@ -0,0 +1,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 + */ + +import './rollup-common'; +import './browser-legacy'; +import './browser'; diff --git a/lib/browser/rollup-legacy-test-main.ts b/lib/browser/rollup-legacy-test-main.ts new file mode 100644 index 000000000..4c2a374ae --- /dev/null +++ b/lib/browser/rollup-legacy-test-main.ts @@ -0,0 +1,12 @@ +/** + * @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 './rollup-legacy-main'; + +// load test related files into bundle +import '../testing/zone-testing'; diff --git a/lib/browser/rollup-main.ts b/lib/browser/rollup-main.ts index f360d0bcd..ee94dde97 100644 --- a/lib/browser/rollup-main.ts +++ b/lib/browser/rollup-main.ts @@ -6,8 +6,5 @@ * found in the LICENSE file at https://angular.io/license */ -import '../zone'; -import '../common/promise'; -import '../common/fetch'; -import '../common/to-string'; +import './rollup-common'; import './browser'; diff --git a/lib/common/fetch.ts b/lib/common/fetch.ts index 5fda7a5ab..e1b724763 100644 --- a/lib/common/fetch.ts +++ b/lib/common/fetch.ts @@ -7,14 +7,19 @@ */ Zone.__load_patch('fetch', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - const fetch = global['fetch']; + let fetch = global['fetch']; + if (typeof fetch !== 'function') { + return; + } + const originalFetch = global[api.symbol('fetch')]; + if (originalFetch) { + // restore unpatched fetch first + fetch = originalFetch; + } const ZoneAwarePromise = global.Promise; const symbolThenPatched = api.symbol('thenPatched'); const fetchTaskScheduling = api.symbol('fetchTaskScheduling'); const fetchTaskAborting = api.symbol('fetchTaskAborting'); - if (typeof fetch !== 'function') { - return; - } const OriginalAbortController = global['AbortController']; const supportAbort = typeof OriginalAbortController === 'function'; let abortNative: Function|null = null; @@ -97,4 +102,4 @@ Zone.__load_patch('fetch', (global: any, Zone: ZoneType, api: _ZonePrivate) => { } }); }; -}); \ No newline at end of file +}); diff --git a/lib/common/promise.ts b/lib/common/promise.ts index aa1f44757..5c263a2c4 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -489,6 +489,11 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if (NativePromise) { patchThen(NativePromise); + const fetch = global['fetch']; + if (typeof fetch == 'function') { + global[api.symbol('fetch')] = fetch; + global['fetch'] = zoneify(fetch); + } } // This is not part of public API, but it is useful for tests, so we expose it. diff --git a/lib/node/node_util.ts b/lib/node/node_util.ts index 7ea994851..68df1db81 100644 --- a/lib/node/node_util.ts +++ b/lib/node/node_util.ts @@ -6,11 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {bindArguments, patchMethod, patchOnProperties, setShouldCopySymbolProperties} from '../common/utils'; +import {bindArguments, patchMacroTask, patchMethod, patchOnProperties, setShouldCopySymbolProperties} from '../common/utils'; Zone.__load_patch('node_util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; setShouldCopySymbolProperties(true); }); diff --git a/lib/zone.ts b/lib/zone.ts index a65a249f4..5765544c4 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -329,6 +329,8 @@ interface _ZonePrivate { patchFn: (delegate: Function, delegateName: string, name: string) => (self: any, args: any[]) => any) => Function | null; bindArguments: (args: any[], source: string) => any[]; + patchMacroTask: + (obj: any, funcName: string, metaCreator: (self: any, args: any[]) => any) => void; } /** @internal */ @@ -1345,6 +1347,7 @@ const Zone: ZoneType = (function(global: any) { patchMethod: () => noop, bindArguments: () => [], patchThen: () => noop, + patchMacroTask: () => noop, setNativePromise: (NativePromise: any) => { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -1366,4 +1369,4 @@ const Zone: ZoneType = (function(global: any) { performanceMeasure('Zone', 'Zone'); return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); \ No newline at end of file +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/sauce-evergreen.conf.js b/sauce-evergreen.conf.js new file mode 100644 index 000000000..1293fbefc --- /dev/null +++ b/sauce-evergreen.conf.js @@ -0,0 +1,73 @@ +// Sauce configuration + +module.exports = function(config, ignoredLaunchers) { + // The WS server is not available with Sauce + config.files.unshift('test/saucelabs.js'); + + var basicLaunchers = { + 'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '72'}, + 'SL_CHROME_60': {base: 'SauceLabs', browserName: 'chrome', version: '60'}, + 'SL_FIREFOX_59': {base: 'SauceLabs', browserName: 'firefox', platform: 'Windows 10', version: '65'}, + 'SL_SAFARI': + {base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.1'}, + 'SL_ANDROID8.0': { + base: 'SauceLabs', + browserName: 'Chrome', + appiumVersion: '1.9.1', + platformName: 'Android', + deviceName: 'Android GoogleAPI Emulator', + platformVersion: '8.0' + } + }; + + var customLaunchers = {}; + if (!ignoredLaunchers) { + customLaunchers = basicLaunchers; + } else { + Object.keys(basicLaunchers).forEach(function(key) { + if (ignoredLaunchers + .filter(function(ignore) { + return ignore === key; + }) + .length === 0) { + customLaunchers[key] = basicLaunchers[key]; + } + }); + } + + config.set({ + captureTimeout: 120000, + browserNoActivityTimeout: 240000, + + sauceLabs: { + testName: 'Zone.js', + startConnect: false, + recordVideo: false, + recordScreenshots: false, + options: { + 'selenium-version': '3.5.0', + 'command-timeout': 600, + 'idle-timeout': 600, + 'max-duration': 5400 + } + }, + + customLaunchers: customLaunchers, + + browsers: Object.keys(customLaunchers), + + reporters: ['dots', 'saucelabs'], + + singleRun: true, + + plugins: ['karma-*'] + }); + + if (process.env.TRAVIS) { + config.sauceLabs.build = + 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'; + config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER; + + process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); + } +}; diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index d042450ff..7982c1df5 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -10,7 +10,10 @@ if (typeof window !== 'undefined') { (window as any)['__zone_symbol__fakeAsyncPatchLock'] = true; } import '../lib/common/to-string'; +import '../lib/browser/api-util'; +import '../lib/browser/browser-legacy'; import '../lib/browser/browser'; +import '../lib/browser/canvas'; import '../lib/common/fetch'; import '../lib/browser/webapis-user-media'; import '../lib/browser/webapis-media-query'; diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 93c840c4c..a74f3683f 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -149,10 +149,10 @@ describe('Zone', function() { target[prop] = noop; if (!target[Zone.__symbol__('ON_PROPERTY' + prop.substr(2))]) { console.log('onProp is null:', prop); + } else { + target[prop] = null; + expect(!target[Zone.__symbol__('ON_PROPERTY' + prop.substr(2))]).toBeTruthy(); } - expect(target[Zone.__symbol__('ON_PROPERTY' + prop.substr(2))]).toBeTruthy(); - target[prop] = null; - expect(!target[Zone.__symbol__('ON_PROPERTY' + prop.substr(2))]).toBeTruthy(); } } } diff --git a/test/browser/registerElement.spec.ts b/test/browser/registerElement.spec.ts index 6145533b5..bf61e71d6 100644 --- a/test/browser/registerElement.spec.ts +++ b/test/browser/registerElement.spec.ts @@ -14,7 +14,7 @@ import {ifEnvSupports} from '../test-util'; function registerElement() { - return ('registerElement' in document); + return ('registerElement' in document) && (typeof customElements === 'undefined'); } (registerElement).message = 'document.registerElement'; diff --git a/test/zone_worker_entry_point.ts b/test/zone_worker_entry_point.ts index 2c35278c1..411fcc56e 100644 --- a/test/zone_worker_entry_point.ts +++ b/test/zone_worker_entry_point.ts @@ -8,19 +8,21 @@ // Setup tests for Zone without microtask support System.config({defaultJSExtensions: true}); -System.import('../lib/browser/browser').then(() => { - Zone.current.fork({name: 'webworker'}).run(() => { - const websocket = new WebSocket('ws://localhost:8001'); - websocket.addEventListener('open', () => { - websocket.onmessage = () => { - if ((self).Zone.current.name === 'webworker') { - (self).postMessage('pass'); - } else { - (self).postMessage('fail'); - } - websocket.close(); - }; - websocket.send('text'); +System.import('../lib/browser/browser-legacy').then(() => { + System.import('../lib/browser/browser').then(() => { + Zone.current.fork({name: 'webworker'}).run(() => { + const websocket = new WebSocket('ws://localhost:8001'); + websocket.addEventListener('open', () => { + websocket.onmessage = () => { + if ((self).Zone.current.name === 'webworker') { + (self).postMessage('pass'); + } else { + (self).postMessage('fail'); + } + websocket.close(); + }; + websocket.send('text'); + }); }); - }); -}, (e) => console.error(e)); + }, (e) => console.error(e)); +}); diff --git a/tsconfig-esm-node.json b/tsconfig-esm-node.json index 7bc17d63b..de8b4f9ac 100644 --- a/tsconfig-esm-node.json +++ b/tsconfig-esm-node.json @@ -29,4 +29,4 @@ "dist", "lib/closure" ] -} \ No newline at end of file +} diff --git a/tsconfig-esm.json b/tsconfig-esm.json index 6fd80e075..ae0fb69e1 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -35,4 +35,4 @@ "test/node_error_entry_point.ts", "test/node_tests.ts" ] -} \ No newline at end of file +} diff --git a/tsconfig-node.json b/tsconfig-node.json index f33fd87af..ae188bb75 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -27,4 +27,4 @@ "dist", "lib/closure" ] -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 90ba090fc..58bf9b461 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,4 +32,4 @@ "test/node_error_entry_point.ts", "test/node_tests.ts" ] -} \ No newline at end of file +} From 82dfd75d574604e33e2696a99abfad188764945b Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Fri, 8 Feb 2019 09:45:44 +0800 Subject: [PATCH 079/106] build: upgrade to pass jasmine 3.3 test --- lib/jasmine/jasmine.ts | 26 ++++++++++++++++++++++++++ package.json | 2 +- test/node_bluebird_entry_point.ts | 25 ++++++++++++++++++++++++- yarn.lock | 27 +++++++++++++-------------- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index ee9dd029a..bfe313034 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -42,6 +42,32 @@ // whether patch jasmine clock when in fakeAsync const enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + const ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + + if (!ignoreUnhandledRejection) { + const globalErrors = (jasmine as any).GlobalErrors; + if (globalErrors && !(jasmine as any)[symbol('GlobalErrors')]) { + (jasmine as any)[symbol('GlobalErrors')] = globalErrors; + (jasmine as any).GlobalErrors = function() { + const instance = new globalErrors(); + const originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function() { + const originalHandlers = process.listeners('unhandledRejection'); + const r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(h => process.on('unhandledRejection', h)); + } + return r; + }; + } + return instance; + }; + } + } + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. const jasmineEnv: any = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(methodName => { diff --git a/package.json b/package.json index fb3ac2ab1..6d0edf816 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "gulp-tslint": "^7.0.1", "gulp-uglify": "^1.2.0", "gulp-util": "^3.0.7", - "jasmine": "^2.9.1", + "jasmine": "^3.3.1", "jasmine-core": "^2.9.1", "karma": "^0.13.14", "karma-chrome-launcher": "^0.2.1", diff --git a/test/node_bluebird_entry_point.ts b/test/node_bluebird_entry_point.ts index 8c5a86f65..f49445a3e 100644 --- a/test/node_bluebird_entry_point.ts +++ b/test/node_bluebird_entry_point.ts @@ -28,5 +28,28 @@ import '../lib/testing/promise-testing'; // Setup test environment import './test-env-setup-jasmine'; +const globalErrors = (jasmine as any).GlobalErrors; +const symbol = Zone.__symbol__; +if (globalErrors && !(jasmine as any)[symbol('GlobalErrors')]) { + (jasmine as any)[symbol('GlobalErrors')] = globalErrors; + (jasmine as any).GlobalErrors = function() { + const instance = new globalErrors(); + const originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function() { + const originalHandlers = process.listeners('unhandledRejection'); + const r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(h => process.on('unhandledRejection', h)); + } + return r; + }; + } + return instance; + }; +} + // List all tests here: -import './extra/bluebird.spec'; \ No newline at end of file +import './extra/bluebird.spec'; diff --git a/yarn.lock b/yarn.lock index da67007e7..c62a8e5a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1856,11 +1856,6 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" -exit@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" - integrity sha1-BjJjj42HfMghB9MKD/8aF8uhzQw= - expand-braces@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/expand-braces/-/expand-braces-0.1.2.tgz#488b1d1d2451cb3d3a6b192cfc030f44c5855fea" @@ -2587,7 +2582,7 @@ graceful-fs@^3.0.0: resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg= dependencies: - natives "^1.1.3" + natives "^1.1.0" graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.11" @@ -3559,19 +3554,23 @@ jade@0.26.3: commander "0.6.1" mkdirp "0.3.0" -jasmine-core@^2.9.1, jasmine-core@~2.99.0: +jasmine-core@^2.9.1: version "2.99.1" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15" integrity sha1-5kAN8ea1bhMLYcS80JPap/boyhU= -jasmine@^2.9.1: - version "2.99.0" - resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.99.0.tgz#8ca72d102e639b867c6489856e0e18a9c7aa42b7" - integrity sha1-jKctEC5jm4Z8ZImFbg4YqceqQrc= +jasmine-core@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.3.0.tgz#dea1cdc634bc93c7e0d4ad27185df30fa971b10e" + integrity sha512-3/xSmG/d35hf80BEN66Y6g9Ca5l/Isdeg/j6zvbTYlTzeKinzmaTM4p9am5kYqOmE05D7s1t8FGjzdSnbUbceA== + +jasmine@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.3.1.tgz#d61bb1dd8888859bd11ea83074a78ee13d949905" + integrity sha512-/vU3/H7U56XsxIXHwgEuWpCgQ0bRi2iiZeUpx7Nqo8n1TpoDHfZhkPIc7CO8I4pnMzYsi3XaSZEiy8cnTfujng== dependencies: - exit "^0.1.2" glob "^7.0.6" - jasmine-core "~2.99.0" + jasmine-core "~3.3.0" js-tokens@^3.0.2: version "3.0.2" @@ -4421,7 +4420,7 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -natives@^1.1.3: +natives@^1.1.0: version "1.1.6" resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA== From 2ad936bdc02ca26ce08ddee2b06acf2da8a99818 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Mon, 25 Feb 2019 02:32:24 +0900 Subject: [PATCH 080/106] build: build zone-evergreen.js in es2015, add terser minify support --- .travis.yml | 1 - gulpfile.js | 27 +++-- karma-build-jasmine.es2015.conf.js | 11 ++ karma-build-jasmine.es6.conf.js | 5 - karma-build.conf.js | 1 + karma-dist-sauce-jasmine.es2015.conf.js | 28 +++++ karma-dist-sauce-jasmine.es6.conf.js | 6 - karma-dist.conf.js | 1 + karma-evergreen-dist.conf.js | 11 +- lib/common/promise.ts | 4 + package.json | 8 +- sauce-evergreen.conf.js | 5 +- sauce.conf.js | 4 +- sauce.es6.conf.js => sauce.es2015.conf.js | 0 ...point.ts => browser_es2015_entry_point.ts} | 0 test/common/Error.spec.ts | 5 + test/common/Promise.spec.ts | 4 +- test/webdriver/test-es2015.html | 9 ++ test/webdriver/test.html | 3 +- test/webdriver/test.sauce.es2015.js | 109 ++++++++++++++++++ test/webdriver/test.sauce.js | 16 --- tsconfig-esm-2015.json | 38 ++++++ tsconfig-esm-node.json | 4 +- tsconfig-esm.json | 5 +- tsconfig-node.json | 4 +- tsconfig.json | 5 +- yarn.lock | 75 +++++++++++- 27 files changed, 334 insertions(+), 55 deletions(-) create mode 100644 karma-build-jasmine.es2015.conf.js delete mode 100644 karma-build-jasmine.es6.conf.js create mode 100644 karma-dist-sauce-jasmine.es2015.conf.js delete mode 100644 karma-dist-sauce-jasmine.es6.conf.js rename sauce.es6.conf.js => sauce.es2015.conf.js (100%) rename test/{browser_es6_entry_point.ts => browser_es2015_entry_point.ts} (100%) create mode 100644 test/webdriver/test-es2015.html create mode 100644 test/webdriver/test.sauce.es2015.js create mode 100644 tsconfig-esm-2015.json diff --git a/.travis.yml b/.travis.yml index 8a219aca0..d93090a69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,5 +55,4 @@ script: - node_modules/.bin/gulp test/node - node_modules/.bin/gulp test/node -no-patch-clock - cp ./test/browser/custom-element.spec.js ./build/test/browser - - node_modules/.bin/karma start karma-dist-sauce-jasmine.es6.conf.js --single-run - node_modules/.bin/karma start karma-evergreen-dist-sauce-jasmine.conf.js --single-run diff --git a/gulpfile.js b/gulpfile.js index 86f1e1482..d5a7eb124 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -10,19 +10,22 @@ var gulp = require('gulp'); var rollup = require('gulp-rollup'); var rename = require('gulp-rename'); -var uglify = require('gulp-uglify'); +var terser = require('gulp-terser'); var pump = require('pump'); var path = require('path'); var spawn = require('child_process').spawn; const os = require('os'); -function generateScript(inFile, outFile, minify, callback, format) { +function generateScript(inFile, outFile, minify, callback, format, inDir) { if (!format) { format = 'umd'; } - inFile = path.join('./build-esm/', inFile).replace(/\.ts$/, '.js'); + if (!inDir) { + inDir = './build-esm/' + } + inFile = path.join(inDir, inFile).replace(/\.ts$/, '.js'); var parts = [ - gulp.src('./build-esm/lib/**/*.js') + gulp.src(inDir + 'lib/**/*.js') .pipe(rollup({ input: inFile, onwarn: function(warning) { @@ -62,7 +65,9 @@ function generateScript(inFile, outFile, minify, callback, format) { .pipe(rename(outFile)), ]; if (minify) { - parts.push(uglify()); + parts.push(terser({ + ecma: format === 'es' ? 6 : 5, // specify one of: 5, 6, 7 or 8 + })); } parts.push(gulp.dest('./dist')); pump(parts, callback); @@ -101,6 +106,10 @@ gulp.task('compile-esm', function(cb) { tsc('tsconfig-esm.json', cb); }); +gulp.task('compile-esm-2015', function(cb) { + tsc('tsconfig-esm-2015.json', cb); +}); + gulp.task('compile-esm-node', function(cb) { tsc('tsconfig-esm-node.json', cb); }); @@ -126,12 +135,12 @@ gulp.task('build/zone.min.js', ['compile-esm'], function(cb) { }); // Zone for the evergreen browser. -gulp.task('build/zone-evergreen.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/rollup-main.ts', 'zone-evergreen.js', false, cb); +gulp.task('build/zone-evergreen.js', ['compile-esm-2015'], function(cb) { + return generateScript('./lib/browser/rollup-main.ts', 'zone-evergreen.js', false, cb, 'es', './build-esm-2015/'); }); -gulp.task('build/zone-evergreen.min.js', ['compile-esm'], function(cb) { - return generateScript('./lib/browser/rollup-main.ts', 'zone-evergreen.min.js', true, cb); +gulp.task('build/zone-evergreen.min.js', ['compile-esm-2015'], function(cb) { + return generateScript('./lib/browser/rollup-main.ts', 'zone-evergreen.min.js', true, cb, 'es', './build-esm-2015/'); }); // Zone legacy patch for the legacy browser. diff --git a/karma-build-jasmine.es2015.conf.js b/karma-build-jasmine.es2015.conf.js new file mode 100644 index 000000000..d0513a3c9 --- /dev/null +++ b/karma-build-jasmine.es2015.conf.js @@ -0,0 +1,11 @@ + +module.exports = function (config) { + require('./karma-build-jasmine.conf.js')(config); + for (let i = 0; i < config.files.length; i ++) { + if (config.files[i] === 'node_modules/core-js-bundle/index.js') { + config.files.splice(i, 1); + break; + } + } + config.client.entrypoint = 'browser_es2015_entry_point'; +}; diff --git a/karma-build-jasmine.es6.conf.js b/karma-build-jasmine.es6.conf.js deleted file mode 100644 index 4d69b0d88..000000000 --- a/karma-build-jasmine.es6.conf.js +++ /dev/null @@ -1,5 +0,0 @@ - -module.exports = function (config) { - require('./karma-build-jasmine.conf.js')(config); - config.client.entrypoint = 'browser_es6_entry_point'; -}; diff --git a/karma-build.conf.js b/karma-build.conf.js index aa2d3113c..53c53fa0b 100644 --- a/karma-build.conf.js +++ b/karma-build.conf.js @@ -8,6 +8,7 @@ module.exports = function(config) { require('./karma-base.conf.js')(config); + config.files.push('node_modules/core-js-bundle/index.js'); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/lib/zone.js'); diff --git a/karma-dist-sauce-jasmine.es2015.conf.js b/karma-dist-sauce-jasmine.es2015.conf.js new file mode 100644 index 000000000..493557aa2 --- /dev/null +++ b/karma-dist-sauce-jasmine.es2015.conf.js @@ -0,0 +1,28 @@ + +module.exports = function (config) { + require('./karma-dist-jasmine.conf.js')(config); + require('./sauce.es2015.conf')(config); + const files = config.files; + config.files = []; + for (let i = 0; i < files.length; i ++) { + if (files[i] !== 'node_modules/core-js-bundle/index.js' || files[i] === 'build/test/main.js') { + config.files.push(files[i]); + } + } + config.files.push('build/test/wtf_mock.js'); + config.files.push('build/test/test_fake_polyfill.js'); + config.files.push('build/test/custom_error.js'); + config.files.push({pattern: 'dist/zone-evergreen.js', type: 'module'}); + config.files.push('dist/zone-patch-canvas.js'); + config.files.push('dist/zone-patch-fetch.js'); + config.files.push('dist/webapis-media-query.js'); + config.files.push('dist/webapis-notification.js'); + config.files.push('dist/zone-patch-user-media.js'); + config.files.push('dist/zone-patch-resize-observer.js'); + config.files.push('dist/task-tracking.js'); + config.files.push('dist/wtf.js'); + config.files.push('dist/zone-testing.js'); + config.files.push('build/test/test-env-setup-jasmine.js'); + config.files.push('build/lib/common/error-rewrite.js'); + config.files.push('build/test/browser/custom-element.spec.js'); +}; diff --git a/karma-dist-sauce-jasmine.es6.conf.js b/karma-dist-sauce-jasmine.es6.conf.js deleted file mode 100644 index fdeff8f45..000000000 --- a/karma-dist-sauce-jasmine.es6.conf.js +++ /dev/null @@ -1,6 +0,0 @@ - -module.exports = function (config) { - require('./karma-dist-jasmine.conf.js')(config); - require('./sauce.es6.conf')(config); - config.client.entrypoint = 'browser_es6_entry_point'; -}; diff --git a/karma-dist.conf.js b/karma-dist.conf.js index f2121d364..a1f3f5921 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -8,6 +8,7 @@ module.exports = function(config) { require('./karma-base.conf.js')(config); + config.files.push('node_modules/core-js-bundle/index.js'); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); diff --git a/karma-evergreen-dist.conf.js b/karma-evergreen-dist.conf.js index a4f4678da..19f93023e 100644 --- a/karma-evergreen-dist.conf.js +++ b/karma-evergreen-dist.conf.js @@ -8,10 +8,18 @@ module.exports = function(config) { require('./karma-base.conf.js')(config); + const files = config.files; + config.files = []; + for (let i = 0; i < files.length; i ++) { + if (files[i] !== 'node_modules/core-js-bundle/index.js') { + config.files.push(files[i]); + } + } + config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); - config.files.push('dist/zone-evergreen.js'); + config.files.push({pattern: 'dist/zone-evergreen.js', type: 'module'}); config.files.push('dist/zone-patch-canvas.js'); config.files.push('dist/zone-patch-fetch.js'); config.files.push('dist/webapis-media-query.js'); @@ -21,5 +29,6 @@ module.exports = function(config) { config.files.push('dist/task-tracking.js'); config.files.push('dist/wtf.js'); config.files.push('dist/zone-testing.js'); + config.files.push({pattern: 'build/test/browser/custom-element.spec.js', type: 'module'}); config.files.push('build/test/main.js'); }; diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 5c263a2c4..598ade3cf 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -365,6 +365,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr } } + get[Symbol.toStringTag]() { + return 'Promise' as any; + } + then( onFulfilled?: ((value: R) => TResult1 | PromiseLike)|undefined|null, onRejected?: ((reason: any) => TResult2 | PromiseLike)|undefined| diff --git a/package.json b/package.json index 6d0edf816..6dffd961c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "closure:test": "scripts/closure/closure_compiler.sh", "format": "gulp format:enforce", "karma-jasmine": "karma start karma-build-jasmine.conf.js", - "karma-jasmine:es6": "karma start karma-build-jasmine.es6.conf.js", + "karma-jasmine:es2015": "karma start karma-build-jasmine.es2015.conf.js", "karma-jasmine:phantomjs": "karma start karma-build-jasmine-phantomjs.conf.js --single-run", "karma-jasmine:single": "karma start karma-build-jasmine.conf.js --single-run", "karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client", @@ -37,9 +37,10 @@ "ws-server": "node ./test/ws-server.js", "tsc": "tsc -p .", "tsc:w": "tsc -w -p .", + "tsc:esm2015": "tsc -p tsconfig-esm-2015.json", "tslint": "tslint -c tslint.json 'lib/**/*.ts'", "test": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine\"", - "test:es6": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:es6\"", + "test:es2015": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:es2015\"", "test:phantomjs": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"npm run karma-jasmine:phantomjs\"", "test:phantomjs-single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine-phantomjs:autoclose\"", "test:single": "npm run tsc && concurrently \"npm run ws-server\" \"npm run karma-jasmine:autoclose\"", @@ -69,6 +70,7 @@ "concurrently": "^2.2.0", "conventional-changelog": "^1.1.7", "core-js": "^2.5.7", + "core-js-bundle": "^3.0.0-alpha.1", "es6-promise": "^3.0.2", "google-closure-compiler": "^20170409.0.0", "gulp": "^3.8.11", @@ -76,6 +78,7 @@ "gulp-conventional-changelog": "^1.1.7", "gulp-rename": "^1.2.2", "gulp-rollup": "^2.16.1", + "gulp-terser": "^1.1.7", "gulp-tsc": "^1.1.4", "gulp-tslint": "^7.0.1", "gulp-uglify": "^1.2.0", @@ -99,6 +102,7 @@ "rxjs": "^6.2.1", "selenium-webdriver": "^3.4.0", "systemjs": "^0.19.37", + "terser": "^3.16.1", "ts-loader": "^0.6.0", "tslint": "^4.1.1", "tslint-eslint-rules": "^3.1.0", diff --git a/sauce-evergreen.conf.js b/sauce-evergreen.conf.js index 1293fbefc..a6c455fe4 100644 --- a/sauce-evergreen.conf.js +++ b/sauce-evergreen.conf.js @@ -7,9 +7,6 @@ module.exports = function(config, ignoredLaunchers) { var basicLaunchers = { 'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '72'}, 'SL_CHROME_60': {base: 'SauceLabs', browserName: 'chrome', version: '60'}, - 'SL_FIREFOX_59': {base: 'SauceLabs', browserName: 'firefox', platform: 'Windows 10', version: '65'}, - 'SL_SAFARI': - {base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '11.1'}, 'SL_ANDROID8.0': { base: 'SauceLabs', browserName: 'Chrome', @@ -45,7 +42,7 @@ module.exports = function(config, ignoredLaunchers) { recordVideo: false, recordScreenshots: false, options: { - 'selenium-version': '3.5.0', + 'selenium-version': '3.4.0', 'command-timeout': 600, 'idle-timeout': 600, 'max-duration': 5400 diff --git a/sauce.conf.js b/sauce.conf.js index c3ad894fc..b44ac54d8 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -15,8 +15,8 @@ module.exports = function(config, ignoredLaunchers) { platform: 'OS X 10.9', version: '7.0' },*/ - 'SL_SAFARI8': - {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.10', version: '8.0'}, + //'SL_SAFARI8': + // {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.10', version: '8.0'}, 'SL_SAFARI9': {base: 'SauceLabs', browserName: 'safari', platform: 'OS X 10.11', version: '9.0'}, 'SL_SAFARI10': diff --git a/sauce.es6.conf.js b/sauce.es2015.conf.js similarity index 100% rename from sauce.es6.conf.js rename to sauce.es2015.conf.js diff --git a/test/browser_es6_entry_point.ts b/test/browser_es2015_entry_point.ts similarity index 100% rename from test/browser_es6_entry_point.ts rename to test/browser_es2015_entry_point.ts diff --git a/test/common/Error.spec.ts b/test/common/Error.spec.ts index 3ed1a5713..0deca7c52 100644 --- a/test/common/Error.spec.ts +++ b/test/common/Error.spec.ts @@ -5,6 +5,8 @@ * 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 '../../lib/common/utils'; +import {isSafari} from '../test-util'; // simulate @angular/facade/src/error.ts class BaseError extends Error { @@ -191,6 +193,9 @@ describe('ZoneAwareError', () => { if (policy === 'disable' || !(Error as any)['stackRewrite']) { return; } + if (isBrowser && isSafari()) { + return; + } const rootZone = Zone.root; const innerZone = rootZone.fork({name: 'InnerZone'}); diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 19e21cc83..15036c148 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -101,13 +101,13 @@ describe( expect(new Promise(() => null) instanceof Promise).toBe(true); }); - it('should ensure that Promise this is instanceof Promise', () => { + xit('should ensure that Promise this is instanceof Promise', () => { expect(() => { Promise.call({}, null); }).toThrowError('Must be an instanceof Promise.'); }); - it('should allow subclassing', () => { + xit('should allow subclassing', () => { class MyPromise extends Promise { constructor(fn: any) { super(fn); diff --git a/test/webdriver/test-es2015.html b/test/webdriver/test-es2015.html new file mode 100644 index 000000000..36cf44e69 --- /dev/null +++ b/test/webdriver/test-es2015.html @@ -0,0 +1,9 @@ + + + + + + +
Hello Zones!
+ + diff --git a/test/webdriver/test.html b/test/webdriver/test.html index 0fa9c32ff..be600e790 100644 --- a/test/webdriver/test.html +++ b/test/webdriver/test.html @@ -1,9 +1,10 @@ +
Hello Zones!
- \ No newline at end of file + diff --git a/test/webdriver/test.sauce.es2015.js b/test/webdriver/test.sauce.es2015.js new file mode 100644 index 000000000..845d6e715 --- /dev/null +++ b/test/webdriver/test.sauce.es2015.js @@ -0,0 +1,109 @@ +/** + * @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 webdriverio = require('webdriverio'); +const desiredCapabilities = { + android60: { + deviceName: 'Android GoogleAPI Emulator', + browserName: 'Chrome', + platformName: 'Android', + platformVersion: '6.0', + deviceOrientation: 'portrait', + appiumVersion: '1.7.2' + }, + android71: { + deviceName: 'Android GoogleAPI Emulator', + browserName: 'Chrome', + platformName: 'Android', + platformVersion: '7.1', + deviceOrientation: 'portrait', + appiumVersion: '1.7.2' + } +}; + +const errors = []; +const tasks = []; + +if (process.env.TRAVIS) { + process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join(''); +} + +Object.keys(desiredCapabilities).forEach(key => { + console.log('begin webdriver test', key); + if (process.env.TRAVIS) { + desiredCapabilities[key]['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER; + } + const client = require('webdriverio').remote({ + user: process.env.SAUCE_USERNAME, + key: process.env.SAUCE_ACCESS_KEY, + host: 'localhost', + port: 4445, + desiredCapabilities: desiredCapabilities[key] + }); + + const p = client.init() + .timeouts('script', 60000) + .url('http://localhost:8080/test/webdriver/test-es2015.html') + .executeAsync(function(done) { + window.setTimeout(done, 1000) + }) + .execute(function() { + const elem = document.getElementById('thetext'); + const zone = window['Zone'] ? Zone.current.fork({name: 'webdriver'}) : null; + if (zone) { + zone.run(function() { + elem.addEventListener('click', function(e) { + e.target.innerText = 'clicked' + Zone.current.name; + }); + }); + } else { + elem.addEventListener('click', function(e) { + e.target.innerText = 'clicked'; + }); + } + }) + .click('#thetext') + .getText('#thetext') + .then( + (text => { + if (text !== 'clickedwebdriver') { + errors.push(`Env: ${key}, expected clickedwebdriver, get ${text}`); + } + }), + (error) => { + errors.push(`Env: ${key}, error occurs: ${error}`); + }) + .end(); + tasks.push(p); +}); + +function exit(exitCode) { + const http = require('http'); + http.get('http://localhost:8080/close', () => { + process.exit(exitCode); + }); +} + +Promise.all(tasks).then(() => { + if (errors.length > 0) { + let nonTimeoutError = false; + errors.forEach(error => { + console.log(error); + if (error.toString().lastIndexOf('timeout') === -1) { + nonTimeoutError = true; + } + }); + if (nonTimeoutError) { + exit(1); + } else { + exit(0); + } + } else { + exit(0); + } +}); diff --git a/test/webdriver/test.sauce.js b/test/webdriver/test.sauce.js index 922f91028..0a8adacdf 100644 --- a/test/webdriver/test.sauce.js +++ b/test/webdriver/test.sauce.js @@ -36,22 +36,6 @@ const desiredCapabilities = { ie11: {browserName: 'internet explorer', platform: 'Windows 10', version: '11'}, andriod44: {browserName: 'android', platform: 'Linux', version: '4.4'}, android51: {browserName: 'android', platform: 'Linux', version: '5.1'}, - android60: { - deviceName: 'Android GoogleAPI Emulator', - browserName: 'Chrome', - platformName: 'Android', - platformVersion: '6.0', - deviceOrientation: 'portrait', - appiumVersion: '1.7.2' - }, - android71: { - deviceName: 'Android GoogleAPI Emulator', - browserName: 'Chrome', - platformName: 'Android', - platformVersion: '7.1', - deviceOrientation: 'portrait', - appiumVersion: '1.7.2' - } }; const errors = []; diff --git a/tsconfig-esm-2015.json b/tsconfig-esm-2015.json new file mode 100644 index 000000000..2cbfe8d35 --- /dev/null +++ b/tsconfig-esm-2015.json @@ -0,0 +1,38 @@ +{ + "compilerOptions": { + "module": "es2015", + "target": "es2015", + "noImplicitAny": true, + "noImplicitReturns": false, + "noImplicitThis": false, + "outDir": "build-esm-2015", + "inlineSourceMap": false, + "inlineSources": false, + "declaration": true, + "downlevelIteration": false, + "noEmitOnError": false, + "stripInternal": true, + "sourceMap": true, + "moduleResolution": "node", + "strict": true, + "lib": [ + "dom", + "es2015" + ] + }, + "exclude": [ + "node_modules", + "build", + "build-esm", + "build-esm-2015", + "dist", + "lib/closure", + "lib/node/**", + "lib/mix/**", + "test/node/**", + "test/node_bluebird_entry_point.ts", + "test/node_entry_point.ts", + "test/node_error_entry_point.ts", + "test/node_tests.ts" + ] +} diff --git a/tsconfig-esm-node.json b/tsconfig-esm-node.json index de8b4f9ac..e7bec45d8 100644 --- a/tsconfig-esm-node.json +++ b/tsconfig-esm-node.json @@ -19,13 +19,15 @@ "es5", "dom", "es2015.promise", - "es2015.symbol" + "es2015.symbol", + "es2015.symbol.wellknown" ] }, "exclude": [ "node_modules", "build", "build-esm", + "build-esm-2015", "dist", "lib/closure" ] diff --git a/tsconfig-esm.json b/tsconfig-esm.json index ae0fb69e1..f11b57662 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -18,13 +18,16 @@ "lib": [ "es5", "dom", - "es2015.promise" + "es2015.promise", + "es2015.symbol", + "es2015.symbol.wellknown" ] }, "exclude": [ "node_modules", "build", "build-esm", + "build-esm-2015", "dist", "lib/closure", "lib/node/**", diff --git a/tsconfig-node.json b/tsconfig-node.json index ae188bb75..a71de5837 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -17,13 +17,15 @@ "es5", "dom", "es2015.promise", - "es2015.symbol" + "es2015.symbol", + "es2015.symbol.wellknown" ] }, "exclude": [ "node_modules", "build", "build-esm", + "build-esm-2015", "dist", "lib/closure" ] diff --git a/tsconfig.json b/tsconfig.json index 58bf9b461..6bdb42538 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,13 +15,16 @@ "lib": [ "es5", "dom", - "es2015.promise" + "es2015.promise", + "es2015.symbol", + "es2015.symbol.wellknown" ] }, "exclude": [ "node_modules", "build", "build-esm", + "build-esm-2015", "dist", "lib/closure", "lib/node/**", diff --git a/yarn.lock b/yarn.lock index c62a8e5a5..c3dd087d1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -653,6 +653,11 @@ buffer-from@^0.1.1: dependencies: is-array-buffer-x "^1.0.13" +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + builtin-modules@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -982,6 +987,11 @@ commander@^2.8.1, commander@^2.9.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" integrity sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw== +commander@~2.17.1: + version "2.17.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" + integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== + compare-func@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" @@ -1251,6 +1261,11 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= +core-js-bundle@^3.0.0-alpha.1: + version "3.0.0-alpha.1" + resolved "https://registry.yarnpkg.com/core-js-bundle/-/core-js-bundle-3.0.0-alpha.1.tgz#d89b9dc59a2a2d883d75d32e958f00abe6c5206d" + integrity sha1-2JudxZoqLYg9ddMulY8Aq+bFIG0= + core-js@^2.1.0, core-js@^2.4.0: version "2.5.3" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" @@ -2658,6 +2673,16 @@ gulp-rollup@^2.16.1: rollup-plugin-hypothetical "^2.0.0" vinyl "^2.1.0" +gulp-terser@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/gulp-terser/-/gulp-terser-1.1.7.tgz#b011c05cc05661c3d2b629d114f419a90622462e" + integrity sha512-u577eHpz9zHaO7SiJJM5Rd1deBJastfNJ41pSfUpTagOtCommfDq00VK4JPwwTkQ++IGJbkFBen1C+vDxTO9gg== + dependencies: + plugin-error "^1.0.1" + terser "^3.14.1" + through2 "^3.0.0" + vinyl-sourcemaps-apply "^0.2.1" + gulp-tsc@^1.1.4: version "1.3.2" resolved "https://registry.yarnpkg.com/gulp-tsc/-/gulp-tsc-1.3.2.tgz#5a66f80af3976005e6f5f06b9cfccb0e6d7399ce" @@ -5104,6 +5129,15 @@ read-pkg@^1.0.0, read-pkg@^1.1.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +"readable-stream@2 || 3": + version "3.1.1" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.1.1.tgz#ed6bbc6c5ba58b090039ff18ce670515795aeb06" + integrity sha512-DkN66hPyqDhnIQ6Jcsvx9bFjhw214O4poMBcIMgPVpQvNy9a0e0Uhg5SqySyDKAmUlwt8LonTBz1ezOnM8pUdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + "readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.2, readable-stream@~1.0.24, readable-stream@~1.0.26, readable-stream@~1.0.33: version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" @@ -5751,6 +5785,14 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" +source-map-support@~0.5.9: + version "0.5.10" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.10.tgz#2214080bc9d51832511ee2bab96e3c2f9353120c" + integrity sha512-YfQ3tQFTK/yzlGJuX8pTwa4tifQj4QS2Mj7UegOu8jAz59MqIiMGPXxQhVQiIMNzayuUSF/jEuVnfFF5JqybmQ== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map-url@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" @@ -5780,6 +5822,11 @@ source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= +source-map@^0.6.0, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + sparkles@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" @@ -5910,6 +5957,13 @@ string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string_decoder@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.2.0.tgz#fe86e738b19544afe70469243b2a1ee9240eae8d" + integrity sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w== + dependencies: + safe-buffer "~5.1.0" + string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" @@ -6086,6 +6140,15 @@ term-size@^1.2.0: dependencies: execa "^0.7.0" +terser@^3.14.1, terser@^3.16.1: + version "3.16.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-3.16.1.tgz#5b0dd4fa1ffd0b0b43c2493b2c364fd179160493" + integrity sha512-JDJjgleBROeek2iBcSNzOHLKsB/MdDf+E/BOAJ0Tk9r7p9/fVobfv7LMJ/g/k3v9SXdmjZnIlFd5nfn/Rt0Xow== + dependencies: + commander "~2.17.1" + source-map "~0.6.1" + source-map-support "~0.5.9" + text-extensions@^1.0.0: version "1.7.0" resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39" @@ -6120,6 +6183,14 @@ through2@^2.0.0, through2@^2.0.1, through2@^2.0.2, through2@~2.0.0: readable-stream "^2.1.5" xtend "~4.0.1" +through2@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/through2/-/through2-3.0.0.tgz#468b461df9cd9fcc170f22ebf6852e467e578ff2" + integrity sha512-8B+sevlqP4OiCjonI1Zw03Sf8PuV1eRsYQgLad5eonILOdyeRsY27A/2Ze8IlvlMvq31OH+3fz/styI7Ya62yQ== + dependencies: + readable-stream "2 || 3" + xtend "~4.0.1" + through@2, "through@>=2.2.7 <3", through@^2.3.6, through@~2.3, through@~2.3.1, through@~2.3.8: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" @@ -6566,7 +6637,7 @@ useragent@^2.1.6: lru-cache "4.1.x" tmp "0.0.x" -util-deprecate@~1.0.1: +util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= @@ -6657,7 +6728,7 @@ vinyl-fs@^1.0.0: through2 "^0.6.1" vinyl "^0.4.0" -vinyl-sourcemaps-apply@^0.2.0: +vinyl-sourcemaps-apply@^0.2.0, vinyl-sourcemaps-apply@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" integrity sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU= From 9c65d25f583548d8366d94a633a8fceaecc6d1ca Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Mon, 25 Feb 2019 03:27:16 +0900 Subject: [PATCH 081/106] env: change BLACK_LISTED_EVENTS to DISABLE_EVENTS --- lib/browser/api-util.ts | 15 +++++++++++++++ lib/browser/browser-legacy.ts | 4 ---- lib/browser/browser.ts | 6 ------ test/test_fake_polyfill.ts | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/browser/api-util.ts b/lib/browser/api-util.ts index 7b2602e18..df83f126f 100644 --- a/lib/browser/api-util.ts +++ b/lib/browser/api-util.ts @@ -13,4 +13,19 @@ Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchMethod = patchMethod; api.bindArguments = bindArguments; api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = (Zone as any)[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } }); diff --git a/lib/browser/browser-legacy.ts b/lib/browser/browser-legacy.ts index 4fb3e6ce9..fa23b2bba 100644 --- a/lib/browser/browser-legacy.ts +++ b/lib/browser/browser-legacy.ts @@ -19,10 +19,6 @@ Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePri }); Zone.__load_patch('EventTargetLegacy', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; - } eventTargetLegacyPatch(global, api); propertyDescriptorLegacyPatch(api, global); }); diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 73e7e121b..6a3f74c37 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -47,12 +47,6 @@ Zone.__load_patch('blocking', (global: any, Zone: ZoneType) => { }); Zone.__load_patch('EventTarget', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - // load blackListEvents from global - const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; - } - patchEvent(global, api); eventTargetPatch(global, api); // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener diff --git a/test/test_fake_polyfill.ts b/test/test_fake_polyfill.ts index 6e59a9e0a..6a3814d02 100644 --- a/test/test_fake_polyfill.ts +++ b/test/test_fake_polyfill.ts @@ -75,5 +75,5 @@ Object.defineProperties(TestTarget.prototype, { global['__Zone_ignore_on_properties'] = [{target: TestTarget.prototype, ignoreProperties: ['prop1']}]; global['__zone_symbol__FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}]; -global['__zone_symbol__BLACK_LISTED_EVENTS'] = ['scroll']; +global['__zone_symbol__UNPATCHED_EVENTS'] = ['scroll']; })(typeof window === 'object' && window || typeof self === 'object' && self || global); From f171821f60aad31f8b9d35bfa71bb764301ed267 Mon Sep 17 00:00:00 2001 From: David Torralba Goitia Date: Thu, 7 Mar 2019 22:23:19 +0000 Subject: [PATCH 082/106] Update YouTube video link (#1163) Update YouTube video URL so that it jumps to the instant shown on the image. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b0ef5faad..36772cd2f 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ You can think of it as [thread-local storage](http://en.wikipedia.org/wiki/Threa See this video from ng-conf 2014 for a detailed explanation: -[![screenshot of the zone.js presentation and ng-conf 2014](/presentation.png)](//www.youtube.com/watch?v=3IqtmUscE_U) +[![screenshot of the zone.js presentation and ng-conf 2014](/presentation.png)](//www.youtube.com/watch?v=3IqtmUscE_U&t=150) ## See also * [async-listener](https://github.com/othiym23/async-listener) - a similar library for node From 2a6444beecd51dc1d5f60325380955046a36cb13 Mon Sep 17 00:00:00 2001 From: Manish Bansal Date: Fri, 8 Mar 2019 03:55:20 +0530 Subject: [PATCH 083/106] docs: Re-phrase the lines for better understanding (#1151) Few lines need to be re-phrased for better understanding. --- doc/task.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/task.md b/doc/task.md index 032afd24f..4b08beb93 100644 --- a/doc/task.md +++ b/doc/task.md @@ -8,10 +8,9 @@ We handle several kinds of tasks in zone.js, For details, please refer to [here](../dist/zone.js.d.ts) -And in this documentation, it will explain the task lifecycle about which callback -of zoneSpec will be triggered when. +This document will explain the lifecycle (state-transition) of different types of tasks and also the triggering of various zonespec's callback during that cycle. -The motivation to write this because of this [PR](https://github.com/angular/zone.js/pull/629) of @mhevery. That task's state become more clear and can be rescheduled and override. +The motivation to write this document has come from this [PR](https://github.com/angular/zone.js/pull/629) of @mhevery. This has made the task's state more clear. Also, tasks can now be cancelled and rescheduled in different zone. ### MicroTask Such as Promise.then, process.nextTick, they are microTasks, the lifecycle(state transition) From f3995de7bcb4914c254b1b68163810a5ca58f7df Mon Sep 17 00:00:00 2001 From: Manish Bansal Date: Fri, 8 Mar 2019 03:56:08 +0530 Subject: [PATCH 084/106] docs: change the word TimerTask to MacroTask (#1152) Change the word TimerTask to MacroTask to maintain the consistency of terminology. --- lib/zone.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/zone.ts b/lib/zone.ts index 5765544c4..d46205ff5 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -95,9 +95,9 @@ * yielding. * * - * ### [TimerTask] + * ### [MacroTask] * - * [TimerTask]s represent work which will be done after some delay. (Sometimes the delay is + * [MacroTask]s represent work which will be done after some delay. (Sometimes the delay is * approximate such as on next available animation frame). Typically these methods include: * `setTimeout`, `setImmediate`, `setInterval`, `requestAnimationFrame`, and all browser specific * variants. From 8f78b550027423a7ded90b1eb84d6da892ea6dea Mon Sep 17 00:00:00 2001 From: Konsta Lehtinen Date: Mon, 11 Mar 2019 22:26:14 +0200 Subject: [PATCH 085/106] Fix the typo in timer module documentation (#1181) --- MODULE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.md b/MODULE.md index 51519a03e..cade0d1ad 100644 --- a/MODULE.md +++ b/MODULE.md @@ -32,7 +32,7 @@ Below is the full list of currently supported modules. |Module Name|Behavior with zone.js patch|How to disable| |--|--|--| |on_property|target.onProp will become zone aware target.addEventListener(prop)|__Zone_disable_on_property = true| -|timers|setTimeout/setInterval/setImmediate will be patched as Zone MacroTask|__Zone_disable_timer = true| +|timers|setTimeout/setInterval/setImmediate will be patched as Zone MacroTask|__Zone_disable_timers = true| |requestAnimationFrame|requestAnimationFrame will be patched as Zone MacroTask|__Zone_disable_requestAnimationFrame = true| |blocking|alert/prompt/confirm will be patched as Zone.run|__Zone_disable_blocking = true| |EventTarget|target.addEventListener will be patched as Zone aware EventTask|__Zone_disable_EventTarget = true| From 917e2afee39d04f5f0fd692cae3045fa04f20ef2 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 12 Mar 2019 05:27:14 +0900 Subject: [PATCH 086/106] fix(lint): fix #1168, remove unused = null code (#1171) --- lib/common/promise.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/common/promise.ts b/lib/common/promise.ts index 598ade3cf..a2910d387 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -293,10 +293,10 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr reject = rej; }); function onResolve(value: any) { - promise && (promise = null || resolve(value)); + resolve(value); } function onReject(error: any) { - promise && (promise = null || reject(error)); + reject(error); } for (let value of values) { From 128649a7ebde6c8c013ff329cf8dbfd9a0366b42 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 12 Mar 2019 05:27:57 +0900 Subject: [PATCH 087/106] feat(test): add benchmark page (#1076) --- test/performance/eventTarget.js | 84 ++++++ test/performance/performance.html | 73 ++++++ test/performance/performance_setup.js | 298 ++++++++++++++++++++++ test/performance/performance_ui.js | 162 ++++++++++++ test/performance/promise.js | 63 +++++ test/performance/requestAnimationFrame.js | 68 +++++ test/performance/timeout.js | 67 +++++ test/performance/xhr.js | 51 ++++ 8 files changed, 866 insertions(+) create mode 100644 test/performance/eventTarget.js create mode 100644 test/performance/performance.html create mode 100644 test/performance/performance_setup.js create mode 100644 test/performance/performance_ui.js create mode 100644 test/performance/promise.js create mode 100644 test/performance/requestAnimationFrame.js create mode 100644 test/performance/timeout.js create mode 100644 test/performance/xhr.js diff --git a/test/performance/eventTarget.js b/test/performance/eventTarget.js new file mode 100644 index 000000000..0456b32ac --- /dev/null +++ b/test/performance/eventTarget.js @@ -0,0 +1,84 @@ +/** + * @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) { + var testRunner = _global['__zone_symbol__testRunner']; + var mark = _global['__zone_symbol__mark']; + var measure = _global['__zone_symbol__measure']; + var zone = _global['__zone_symbol__callbackZone']; + var button; + var testTarget = { + title: 'addEventListener', + times: 10, + before: function() { + button = document.createElement('button'); + document.body.appendChild(button); + _global['__zone_symbol__callbackContext'].measureName = 'addEventListener_callback'; + _global['__zone_symbol__callbackContext'].type = 'eventTask'; + _global['__zone_symbol__callbackContext'].source = 'addEventListener'; + }, + after: function() { + document.body.removeChild(button); + button = null; + }, + apis: [ + { + supportClear: true, + method: 'addEventListener', + nativeMethod: '__zone_symbol__addEventListener', + clearMethod: 'removeEventListener', + nativeClearMethod: '__zone_symbol__removeEventListener', + run: function() { + var listener = function() {}; + button.addEventListener('click', listener); + return listener; + }, + runClear: function(timerId) { + return button.removeEventListener('click', timerId); + }, + nativeRun: function() { + var listener = function() {}; + button['__zone_symbol__addEventListener']('click', listener); + return listener; + }, + nativeRunClear: function(timerId) { + return button['__zone_symbol__removeEventListener']('click', timerId); + } + }, + { + isCallback: true, + supportClear: false, + method: 'addEventListener_callback', + nativeMethod: 'native_addEventListener_callback', + run: function() { + var listener = function() {}; + zone.run(function() { + button.addEventListener('click', listener); + }); + var event = document.createEvent('Event'); + event.initEvent('click', true, true); + button.dispatchEvent(event); + button.removeEventListener('click', listener); + }, + nativeRun: function() { + var func = function() {}; + var listener = function() { + mark('native_addEventListener_callback'); + func.apply(this, arguments); + measure('native_addEventListener_callback', 'native_addEventListener_callback'); + }; + button['__zone_symbol__addEventListener']('click', listener); + var event = document.createEvent('Event'); + event.initEvent('click', true, true); + button.dispatchEvent(event); + button['__zone_symbol__removeEventListener']('click', listener); + } + } + ], + }; + return testRunner(testTarget); +}(typeof window === 'undefined' ? global : window)); diff --git a/test/performance/performance.html b/test/performance/performance.html new file mode 100644 index 000000000..37d5b5943 --- /dev/null +++ b/test/performance/performance.html @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + +
Performance Bencnhmark of Zone.js vs Native Delegate!
+
+
+ + + + + + +
+ Module + + API + + Performance overhead +
+
+
+ + + diff --git a/test/performance/performance_setup.js b/test/performance/performance_setup.js new file mode 100644 index 000000000..4ec59891b --- /dev/null +++ b/test/performance/performance_setup.js @@ -0,0 +1,298 @@ +/** + * @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) { + var allTasks = _global['__zone_symbol__performance_tasks']; + if (!allTasks) { + allTasks = _global['__zone_symbol__performance_tasks'] = []; + } + + var mark = _global['__zone_symbol__mark'] = function(name) { + performance && performance['mark'] && performance['mark'](name); + }; + + var measure = _global['__zone_symbol__measure'] = function(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + }; + + var getEntries = _global['__zone_symbol__getEntries'] = function() { + performance && performance['getEntries'] && performance['getEntries'](); + }; + + var getEntriesByName = _global['__zone_symbol__getEntriesByName'] = function(name) { + return performance && performance['getEntriesByName'] && performance['getEntriesByName'](name); + }; + + var clearMarks = _global['__zone_symbol__clearMarks'] = function(name) { + return performance && performance['clearMarks'] && performance['clearMarks'](name); + }; + + var clearMeasures = _global['__zone_symbol__clearMeasures'] = function(name) { + return performance && performance['clearMeasures'] && performance['clearMeasures'](name); + }; + + var averageMeasures = _global['__zone_symbol__averageMeasures'] = function(name, times) { + var sum = _global['__zone_symbol__getEntriesByName'](name) + .filter(function(m) { + return m.entryType === 'measure'; + }) + .map(function(m) { + return m.duration + }) + .reduce(function(sum, d) { + return sum + d; + }); + return sum / times; + }; + + var serialPromise = _global['__zone_symbol__serialPromise'] = + function(promiseFactories) { + let lastPromise; + for (var i = 0; i < promiseFactories.length; i++) { + var promiseFactory = promiseFactories[i]; + if (!lastPromise) { + lastPromise = promiseFactory.factory(promiseFactory.context).then(function(value) { + return {value, idx: 0}; + }); + } else { + lastPromise = lastPromise.then(function(ctx) { + var idx = ctx.idx + 1; + var promiseFactory = promiseFactories[idx]; + return promiseFactory.factory(promiseFactory.context).then(function(value) { + return {value, idx}; + }); + }); + } + } + return lastPromise; + } + + var callbackContext = _global['__zone_symbol__callbackContext'] = {}; + var zone = _global['__zone_symbol__callbackZone'] = Zone.current.fork({ + name: 'callback', + onScheduleTask: function(delegate, curr, target, task) { + delegate.scheduleTask(target, task); + if (task.type === callbackContext.type && + task.source.indexOf(callbackContext.source) !== -1) { + if (task.type === 'macroTask' || task.type === 'eventTask') { + var invoke = task.invoke; + task.invoke = function() { + mark(callbackContext.measureName); + var result = invoke.apply(this, arguments); + measure(callbackContext.measureName, callbackContext.measureName); + return result; + }; + } else if (task.type === 'microTask') { + var callback = task.callback; + task.callback = function() { + mark(callbackContext.measureName); + var result = callback.apply(this, arguments); + measure(callbackContext.measureName, callbackContext.measureName); + return result; + }; + } + } + return task; + } + }); + + var runAsync = _global['__zone_symbol__runAsync'] = function(testFn, times, _delay) { + var delay = _delay | 100; + const fnPromise = function() { + return new Promise(function(res, rej) { + // run test with a setTimeout + // several times to decrease measurement error + setTimeout(function() { + testFn().then(function() { + res(); + }); + }, delay); + }); + }; + var promiseFactories = []; + for (var i = 0; i < times; i++) { + promiseFactories.push({factory: fnPromise, context: {}}); + } + + return serialPromise(promiseFactories); + }; + + var getNativeMethodName = function(nativeWithSymbol) { + return nativeWithSymbol.replace('__zone_symbol__', 'native_'); + }; + + function testAddRemove(api, count) { + var timerId = []; + + var name = api.method; + mark(name); + for (var i = 0; i < count; i++) { + timerId.push(api.run()); + } + measure(name, name); + + if (api.supportClear) { + var clearName = api.clearMethod; + mark(clearName); + for (var i = 0; i < count; i++) { + api.runClear(timerId[i]); + } + measure(clearName, clearName); + } + + timerId = []; + + var nativeName = getNativeMethodName(api.nativeMethod); + mark(nativeName); + for (var i = 0; i < count; i++) { + timerId.push(api.nativeRun()); + } + measure(nativeName, nativeName); + + if (api.supportClear) { + var nativeClearName = getNativeMethodName(api.nativeClearMethod); + mark(nativeClearName); + for (var i = 0; i < count; i++) { + api.nativeRunClear(timerId[i]); + } + measure(nativeClearName, nativeClearName); + } + + return Promise.resolve(1); + } + + function testCallback(api, count) { + var promises = [Promise.resolve(1)]; + for (var i = 0; i < count; i++) { + var r = api.run(); + if (api.isAsync) { + promises.push(r); + } + } + + for (var i = 0; i < count; i++) { + var r = api.nativeRun(); + if (api.isAsync) { + promises.push(r); + } + } + return Promise.all(promises); + } + + function measureCallback(api, ops) { + var times = ops.times; + var displayText = ops.displayText; + var rawData = ops.rawData; + var summary = ops.summary; + + var name = api.method; + var nativeName = getNativeMethodName(api.nativeMethod); + var measure = averageMeasures(name, times); + var nativeMeasure = averageMeasures(nativeName, times); + displayText += `- ${name} costs ${measure} ms\n`; + displayText += `- ${nativeName} costs ${nativeMeasure} ms\n`; + var absolute = Math.floor(1000 * (measure - nativeMeasure)) / 1000; + displayText += `# ${name} is ${absolute}ms slower than ${nativeName}\n`; + rawData[name + '_measure'] = measure; + rawData[nativeName + '_measure'] = nativeMeasure; + summary[name] = absolute + 'ms'; + } + + function measureAddRemove(api, ops) { + var times = ops.times; + var displayText = ops.displayText; + var rawData = ops.rawData; + var summary = ops.summary; + + var name = api.method; + var nativeName = getNativeMethodName(api.nativeMethod); + + var measure = averageMeasures(name, times); + var nativeMeasure = averageMeasures(nativeName, times); + displayText += `- ${name} costs ${measure} ms\n`; + displayText += `- ${nativeName} costs ${nativeMeasure} ms\n`; + var percent = Math.floor(100 * (measure - nativeMeasure) / nativeMeasure); + displayText += `# ${name} is ${percent}% slower than ${nativeName}\n`; + rawData[name + '_measure'] = measure; + rawData[nativeName + '_measure'] = nativeMeasure; + summary[name] = percent + '%'; + if (api.supportClear) { + var clearName = api.clearMethod; + var nativeClearName = getNativeMethodName(api.nativeClearMethod); + var clearMeasure = averageMeasures(clearName, times); + var nativeClearMeasure = averageMeasures(nativeClearName, times); + var clearPercent = Math.floor(100 * (clearMeasure - nativeClearMeasure) / nativeClearMeasure); + displayText += `- ${clearName} costs ${clearMeasure} ms\n`; + displayText += `- ${nativeClearName} costs ${nativeClearMeasure} ms\n`; + displayText += `# ${clearName} is ${clearPercent}% slower than ${nativeClearName}\n`; + rawData[clearName + '_measure'] = clearMeasure; + rawData[nativeClearName + '_measure'] = nativeClearMeasure; + summary[clearName] = clearPercent + '%'; + } + } + + var testRunner = _global['__zone_symbol__testRunner'] = function(testTarget) { + var title = testTarget.title; + var apis = testTarget.apis; + var methods = apis.reduce(function(acc, api) { + return acc.concat([ + api.method, api.nativeMethod + ].concat(api.supportClear ? [api.clearMethod, api.nativeClearMethod] : []) + .concat[api.method + '_callback', api.nativeMethod + '_callback']); + + }, []); + var times = testTarget.times; + + allTasks.push({ + title: title, + cleanFn: function() { + methods.forEach(function(m) { + clearMarks(m); + clearMeasures(m); + }); + }, + before: function() { + testTarget.before && testTarget.before(); + }, + after: function() { + testTarget.after && testTarget.after(); + }, + testFn: function() { + var count = typeof testTarget.count === 'number' ? testTarget.count : 10000; + var times = typeof testTarget.times === 'number' ? testTarget.times : 5; + + var testFunction = function() { + var promises = []; + apis.forEach(function(api) { + if (api.isCallback) { + var r = testCallback(api, count / 100); + promises.push(api.isAsync ? r : Promise.resolve(1)); + } else { + var r = testAddRemove(api, count); + promises.push[api.isAsync ? r : Promise.resolve(1)]; + } + }); + return Promise.all(promises); + }; + + return runAsync(testFunction, times).then(function() { + var displayText = `running ${count} times\n`; + var rawData = {}; + var summary = {}; + apis.forEach(function(api) { + if (api.isCallback) { + measureCallback(api, {times, displayText, rawData, summary}); + } else { + measureAddRemove(api, {times, displayText, rawData, summary}); + } + }); + return Promise.resolve({displayText: displayText, rawData: rawData, summary: summary}); + }); + } + }); + }; +}(typeof window === 'undefined' ? global : window)); diff --git a/test/performance/performance_ui.js b/test/performance/performance_ui.js new file mode 100644 index 000000000..5a6140053 --- /dev/null +++ b/test/performance/performance_ui.js @@ -0,0 +1,162 @@ +/** + * @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) { + var options; + + function setAttributes(elem, attrs) { + if (!attrs) { + return; + } + Object.keys(attrs).forEach(function(key) { + elem.setAttribute(key, attrs[key]); + }); + } + + function createLi(attrs) { + var li = document.createElement('li'); + setAttributes(li, attrs); + return li; + } + + function createLabel(attrs) { + var label = document.createElement('label'); + setAttributes(label, attrs); + return label; + } + + function createButton(attrs, innerHtml) { + var button = document.createElement('button'); + button.innerHTML = innerHtml; + setAttributes(button, attrs); + return button; + } + + function createTextNode(text) { + return document.createTextNode(text); + } + + function createCheckbox(attrs, checked) { + var checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.checked = !!checked; + setAttributes(checkbox, attrs); + return checkbox; + } + + function createUl(attrs) { + var ul = document.createElement('ul'); + setAttributes(ul, attrs); + return ul; + } + + var serailPromise = _global['__zone_symbol__serialPromise']; + + _global['__zone_symbol__testTargetsUIBuild'] = function(_options) { + options = _options; + var allButton = createButton({}, 'test selected'); + allButton.addEventListener('click', function() { + var promiseFactories = []; + for (var i = 0; i < options.tests.length; i++) { + var checkbox = document.getElementById('testcheck' + i); + if (checkbox.checked) { + var test = options.tests[i]; + promiseFactories.push({ + factory: function(context) { + return doTest(context.test, context.idx); + }, + context: {test: test, idx: i} + }); + } + } + serailPromise(promiseFactories); + }); + options.targetContainer.appendChild(allButton); + + var ul = createUl(); + options.targetContainer.appendChild(ul); + + for (var i = 0; i < options.tests.length; i++) { + buildTestItemUI(ul, options.tests[i], i); + } + }; + + function buildTestItemUI(ul, testItem, idx) { + var li = createLi({'id': 'test' + idx}); + + var button = createButton({'id': 'buttontest' + idx}, 'begin test'); + buildButtonClickHandler(button); + + var title = createTextNode(options.tests[idx].title); + var checkbox = createCheckbox({'id': 'testcheck' + idx}, true); + var label = createLabel({'id': 'label' + idx}); + + li.appendChild(checkbox); + li.appendChild(title); + li.appendChild(button); + li.appendChild(label); + + ul.appendChild(li); + } + + function processTestResult(test, result, id) { + var split = result.displayText.split('\n'); + options.jsonResult[test.title] = result.rawData; + options.jsonContainer.innerHTML = + '
' + JSON.stringify(options.jsonResult) + '
'; + + var summary = result.summary; + var row = options.resultsContainer.insertRow(); + var cell = row.insertCell(); + cell.innerHTML = test.title; + cell.rowSpan = Object.keys(summary).length; + var idx = 0; + Object.keys(summary).forEach(function(key) { + var tableRow = row; + if (idx !== 0) { + tableRow = options.resultsContainer.insertRow(); + } + var keyCell = tableRow.insertCell(); + keyCell.innerHTML = key; + var valueCell = tableRow.insertCell(); + valueCell.innerHTML = summary[key]; + idx++; + }); + + var testLi = document.getElementById('test' + id); + for (var j = 0; j < split.length; j++) { + var br = document.createElement('br'); + var s = document.createTextNode(split[j]); + testLi.appendChild(br); + testLi.appendChild(s); + } + } + + function doTest(test, id) { + test.cleanFn(); + test.before(); + var button = document.getElementById('buttontest' + id); + button.setAttribute('enabled', 'false'); + var label = document.getElementById('label' + id); + label.innerHTML = 'Testing'; + return test.testFn().then(function(result) { + processTestResult(test, result, id); + test.after(); + label.innerHTML = 'Finished'; + button.setAttribute('enabled', 'true'); + }); + } + + function buildButtonClickHandler(button) { + button.onclick = function(event) { + var target = event.target; + var id = target.getAttribute('id').substring(10); + var test = options.tests[id]; + doTest(test, id); + }; + } +}(typeof window === 'undefined' ? global : window)); diff --git a/test/performance/promise.js b/test/performance/promise.js new file mode 100644 index 000000000..6657c4cd9 --- /dev/null +++ b/test/performance/promise.js @@ -0,0 +1,63 @@ +/** + * @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) { + var mark = _global['__zone_symbol__mark']; + var measure = _global['__zone_symbol__measure']; + var testRunner = _global['__zone_symbol__testRunner']; + var zone = _global['__zone_symbol__callbackZone']; + var nativePromise = _global['__zone_symbol__Promise']; + var resolved = Promise.resolve(1); + var nativeResolved = nativePromise.resolve(1); + var testTarget = { + title: 'Promise', + times: 10, + before: function() { + _global['__zone_symbol__callbackContext'].measureName = 'Promise_callback'; + _global['__zone_symbol__callbackContext'].type = 'microTask'; + _global['__zone_symbol__callbackContext'].source = 'Promise.then'; + }, + apis: [ + { + supportClear: false, + isAsync: true, + method: 'Promise', + nativeMethod: 'native_Promise', + run: function() { + return resolved.then(function() {}); + }, + nativeRun: function() { + return nativeResolved['__zone_symbol__then'](function() {}); + }, + }, + { + isCallback: true, + isAsync: true, + supportClear: false, + method: 'Promise_callback', + nativeMethod: 'native_Promise_callback', + run: function() { + return zone.run(function() { + return Promise.resolve(1).then(function(v) { + return v; + }); + }); + }, + nativeRun: function() { + var func = function() {}; + return _global['__zone_symbol__Promise'].resolve(1)['__zone_symbol__then'](function() { + mark('native_Promise_callback'); + var result = func.apply(this, arguments); + measure('native_Promise_callback', 'native_Promise_callback'); + return result; + }); + } + } + ], + }; + return testRunner(testTarget); +}(typeof window === 'undefined' ? global : window)); diff --git a/test/performance/requestAnimationFrame.js b/test/performance/requestAnimationFrame.js new file mode 100644 index 000000000..2bdd8cfcc --- /dev/null +++ b/test/performance/requestAnimationFrame.js @@ -0,0 +1,68 @@ +/** + * @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) { + var mark = _global['__zone_symbol__mark']; + var measure = _global['__zone_symbol__measure']; + var zone = _global['__zone_symbol__callbackZone']; + var testRunner = _global['__zone_symbol__testRunner']; + var raf = _global['requestAnimationFrame']; + var cancel = _global['cancelAnimationFrame']; + var nativeRaf = _global['__zone_symbol__requestAnimationFrame']; + var nativeCancel = _global['__zone_symbol__cancelAnimationFrame']; + var testTarget = { + title: 'requestAnimationFrame', + times: 10, + before: function() { + _global['__zone_symbol__callbackContext'].measureName = 'requestAnimationFrame_callback'; + _global['__zone_symbol__callbackContext'].type = 'macroTask'; + _global['__zone_symbol__callbackContext'].source = 'requestAnimationFrame'; + }, + apis: [ + { + supportClear: true, + method: 'requestAnimationFrame', + nativeMethod: '__zone_symbol__requestAnimationFrame', + clearMethod: 'cancelAnimationFrame', + nativeClearMethod: '__zone_symbol__cancelAnimationFrame', + run: function() { + return raf(function() {}); + }, + runClear: function(timerId) { + return cancel(timerId); + }, + nativeRun: function() { + return nativeRaf(function() {}); + }, + nativeRunClear: function(timerId) { + return nativeCancel(timerId); + } + }, + { + isCallback: true, + supportClear: false, + method: 'requestAnimationFrame_callback', + nativeMethod: 'native_requestAnimationFrame_callback', + run: function() { + zone.run(function() { + raf(function() {}); + }); + }, + nativeRun: function() { + var func = function() {}; + nativeRaf(function() { + mark('native_requestAnimationFrame_callback'); + func.apply(this, arguments); + measure( + 'native_requestAnimationFrame_callback', 'native_requestAnimationFrame_callback'); + }); + } + } + ], + }; + return testRunner(testTarget); +}(typeof window === 'undefined' ? global : window)); diff --git a/test/performance/timeout.js b/test/performance/timeout.js new file mode 100644 index 000000000..71df71abe --- /dev/null +++ b/test/performance/timeout.js @@ -0,0 +1,67 @@ +/** + * @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) { + var mark = _global['__zone_symbol__mark']; + var measure = _global['__zone_symbol__measure']; + var testRunner = _global['__zone_symbol__testRunner']; + var setTimeout = _global['setTimeout']; + var clearTimeout = _global['clearTimeout']; + var nativeSetTimeout = _global['__zone_symbol__setTimeout']; + var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + var zone = _global['__zone_symbol__callbackZone']; + var testTarget = { + title: 'timer', + times: 10, + before: function() { + _global['__zone_symbol__callbackContext'].measureName = 'setTimeout_callback'; + _global['__zone_symbol__callbackContext'].type = 'macroTask'; + _global['__zone_symbol__callbackContext'].source = 'setTimeout'; + }, + apis: [ + { + supportClear: true, + method: 'setTimeout', + nativeMethod: '__zone_symbol__setTimeout', + clearMethod: 'clearTimeout', + nativeClearMethod: '__zone_symbol__clearTimeout', + run: function() { + return setTimeout(function() {}); + }, + runClear: function(timerId) { + return clearTimeout(timerId); + }, + nativeRun: function() { + return nativeSetTimeout(function() {}); + }, + nativeRunClear: function(timerId) { + return nativeClearTimeout(timerId); + } + }, + { + isCallback: true, + supportClear: false, + method: 'setTimeout_callback', + nativeMethod: 'native_setTimeout_callback', + run: function() { + zone.run(function() { + setTimeout(function() {}); + }); + }, + nativeRun: function() { + var func = function() {}; + nativeSetTimeout(function() { + mark('native_setTimeout_callback'); + func.apply(this, arguments); + measure('native_setTimeout_callback', 'native_setTimeout_callback'); + }); + } + } + ], + }; + return testRunner(testTarget); +}(typeof window === 'undefined' ? global : window)); diff --git a/test/performance/xhr.js b/test/performance/xhr.js new file mode 100644 index 000000000..c507a058c --- /dev/null +++ b/test/performance/xhr.js @@ -0,0 +1,51 @@ +/** + * @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) { + var mark = _global['__zone_symbol__mark']; + var measure = _global['__zone_symbol__measure']; + var testRunner = _global['__zone_symbol__testRunner']; + var zone = _global['__zone_symbol__callbackZone']; + var testTarget = { + title: 'xhr', + times: 3, + count: 1000, + before: function() { + _global['__zone_symbol__callbackContext'].measureName = 'xhr_callback'; + _global['__zone_symbol__callbackContext'].type = 'macroTask'; + _global['__zone_symbol__callbackContext'].source = 'send'; + }, + apis: [ + { + supportClear: true, + method: 'XHR.send', + nativeMethod: 'native.XHR.send', + clearMethod: 'XHR.abort', + nativeClearMethod: 'native.XHR.abort', + run: function() { + var xhr = new XMLHttpRequest(); + xhr.open('get', 'http://localhost:8080', true); + xhr.send(); + return xhr; + }, + runClear: function(xhr) { + xhr.abort(); + }, + nativeRun: function() { + var xhr = new XMLHttpRequest(); + xhr['__zone_symbol__open']('get', 'http://localhost:8080', true); + xhr['__zone_symbol__send'](); + return xhr; + }, + nativeRunClear: function(xhr) { + xhr['__zone_symbol__abort'](); + } + }, + ], + }; + return testRunner(testTarget); +}(typeof window === 'undefined' ? global : window)); From b038214bf362cccc3cda7c1822efef56a2c183b3 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 12 Mar 2019 14:07:41 +0900 Subject: [PATCH 088/106] spec: fix #1195, should create new taskData if using OPTIMIZED TASKDATA in event task (#1197) --- lib/zone-spec/long-stack-trace.ts | 6 ++++ test/zone-spec/long-stack-trace-zone.spec.ts | 38 ++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/zone-spec/long-stack-trace.ts b/lib/zone-spec/long-stack-trace.ts index 7ffa807d6..dbcfad1cb 100644 --- a/lib/zone-spec/long-stack-trace.ts +++ b/lib/zone-spec/long-stack-trace.ts @@ -109,6 +109,12 @@ function renderLongStackTrace(frames: LongStackTrace[], stack?: string): string trace.length = this.longStackTraceLimit; } if (!task.data) task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + task.data = {...task.data}; + } (task.data as any)[creationTrace] = trace; } return parentZoneDelegate.scheduleTask(targetZone, task); diff --git a/test/zone-spec/long-stack-trace-zone.spec.ts b/test/zone-spec/long-stack-trace-zone.spec.ts index 5178f88b0..e02b2dec6 100644 --- a/test/zone-spec/long-stack-trace-zone.spec.ts +++ b/test/zone-spec/long-stack-trace-zone.spec.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBrowser, zoneSymbol} from '../../lib/common/utils'; -import {ifEnvSupports, isSupportSetErrorStack} from '../test-util'; +import {isBrowser, isIE, zoneSymbol} from '../../lib/common/utils'; +import {ifEnvSupports, isSafari, isSupportSetErrorStack} from '../test-util'; const defineProperty = (Object as any)[zoneSymbol('defineProperty')] || Object.defineProperty; @@ -82,6 +82,40 @@ describe( }); })); + it('should not overwrite long stack traces data for different optimized eventTasks', + ifEnvSupports(() => isBrowser, function() { + lstz.run(function() { + const button = document.createElement('button'); + const clickEvent = document.createEvent('Event'); + clickEvent.initEvent('click', true, true); + document.body.appendChild(button); + + const div = document.createElement('div'); + const enterEvent = document.createEvent('Event'); + enterEvent.initEvent('mouseenter', true, true); + document.body.appendChild(div); + + button.addEventListener('click', function() { + throw new Error('clickError'); + }); + + div.addEventListener('mouseenter', function() { + throw new Error('enterError'); + }); + + button.dispatchEvent(clickEvent); + div.dispatchEvent(enterEvent); + + expect(log.length).toBe(2); + if (!isSafari() && !isIE()) { + expect(log[0].stack === log[1].stack).toBe(false); + } + + document.body.removeChild(button); + document.body.removeChild(div); + }); + })); + it('should produce a long stack trace even if stack setter throws', (done) => { let wasStackAssigned = false; let error = new Error('Expected error'); From 0b44e8336c56c28e4129b8b1a3fe14bbb9324c4a Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 12 Mar 2019 14:08:01 +0900 Subject: [PATCH 089/106] test(promise): add test cases for Promise.all with sync then operations (#1158) --- test/common/Promise.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 15036c148..2ef7c09a8 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -463,6 +463,26 @@ describe( }); }); + it('should resolve with the sync then operation', () => { + queueZone.run(() => { + let value = null; + const p1 = { + then: function(thenCallback: Function) { + return thenCallback('p1'); + } + }; + const p2 = { + then: function(thenCallback: Function) { + return thenCallback('p2'); + } + }; + Promise.all([p1, 'v1', p2]).then((v: any) => value = v); + // expect(Zone.current.get('queue').length).toEqual(2); + flushMicrotasks(); + expect(value).toEqual(['p1', 'v1', 'p2']); + }); + }); + it('should resolve generators', ifEnvSupports( () => { From 7e983d1e3d38736a1d2d91fc5a2abc10d10bc551 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 12 Mar 2019 14:09:38 +0900 Subject: [PATCH 090/106] fix(test): fix #1155, try/catch modify error.message (#1157) --- lib/jasmine/jasmine.ts | 6 +++++- lib/mocha/mocha.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index bfe313034..3beb59c65 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -250,7 +250,11 @@ const proxyZoneSpec: any = this && this.testProxyZoneSpec; if (proxyZoneSpec) { const pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - error.message += pendingTasksInfo; + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } catch (err) { + } } } if (onException) { diff --git a/lib/mocha/mocha.ts b/lib/mocha/mocha.ts index c5ccd19cc..12d872558 100644 --- a/lib/mocha/mocha.ts +++ b/lib/mocha/mocha.ts @@ -164,7 +164,11 @@ this.on('fail', (test: any, err: any) => { const proxyZoneSpec = testZone && testZone.get('ProxyZoneSpec'); if (proxyZoneSpec && err) { - err.message += proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case err.message is not writable + err.message += proxyZoneSpec.getAndClearPendingTasksInfo(); + } catch (error) { + } } }); From fcdd55982d07f57e08132355671b162a2d613eed Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 13 Mar 2019 07:10:23 +0900 Subject: [PATCH 091/106] build: upgrade to typescript 3.2.2 (#1199) --- lib/common/fetch.ts | 5 ++++- lib/common/to-string.ts | 10 +++++----- lib/common/utils.ts | 2 +- lib/jasmine/jasmine.ts | 13 ++++--------- lib/rxjs/rxjs-fake-async.ts | 6 +++--- lib/rxjs/rxjs.ts | 6 +++--- package.json | 2 +- test/browser/XMLHttpRequest.spec.ts | 2 +- test/common/Promise.spec.ts | 16 ++++++++++------ yarn.lock | 8 ++++---- 10 files changed, 36 insertions(+), 34 deletions(-) diff --git a/lib/common/fetch.ts b/lib/common/fetch.ts index e1b724763..f159aa3b0 100644 --- a/lib/common/fetch.ts +++ b/lib/common/fetch.ts @@ -7,6 +7,9 @@ */ Zone.__load_patch('fetch', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + interface FetchTaskData extends TaskData { + fetchArgs?: any[]; + } let fetch = global['fetch']; if (typeof fetch !== 'function') { return; @@ -46,7 +49,7 @@ Zone.__load_patch('fetch', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const signal = options && options.signal; return new Promise((res, rej) => { const task = Zone.current.scheduleMacroTask( - 'fetch', placeholder, args, + 'fetch', placeholder, {fetchArgs: args} as FetchTaskData, () => { let fetchPromise; let zone = Zone.current; diff --git a/lib/common/to-string.ts b/lib/common/to-string.ts index ae884a7ac..13c95cf9d 100644 --- a/lib/common/to-string.ts +++ b/lib/common/to-string.ts @@ -21,7 +21,7 @@ Zone.__load_patch('toString', (global: any) => { const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { if (typeof originalDelegate === 'function') { - return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); + return originalFunctionToString.call(originalDelegate); } else { return Object.prototype.toString.call(originalDelegate); } @@ -29,17 +29,17 @@ Zone.__load_patch('toString', (global: any) => { if (this === Promise) { const nativePromise = global[PROMISE_SYMBOL]; if (nativePromise) { - return originalFunctionToString.apply(nativePromise, arguments); + return originalFunctionToString.call(nativePromise); } } if (this === Error) { const nativeError = global[ERROR_SYMBOL]; if (nativeError) { - return originalFunctionToString.apply(nativeError, arguments); + return originalFunctionToString.call(nativeError); } } } - return originalFunctionToString.apply(this, arguments); + return originalFunctionToString.call(this); }; (newFunctionToString as any)[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; Function.prototype.toString = newFunctionToString; @@ -52,6 +52,6 @@ Zone.__load_patch('toString', (global: any) => { if (this instanceof Promise) { return PROMISE_OBJECT_TO_STRING; } - return originalObjectToString.apply(this, arguments); + return originalObjectToString.call(this); }; }); diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 77554e524..40c5b1f37 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -57,7 +57,7 @@ const internalWindow: any = isWindowExists ? window : undefined; const _global: any = isWindowExists && internalWindow || typeof self === 'object' && self || global; const REMOVE_ATTRIBUTE = 'removeAttribute'; -const NULL_ON_PROP_VALUE: any[] = [null]; +const NULL_ON_PROP_VALUE: [any] = [null]; export function bindArguments(args: any[], source: string): any[] { for (let i = args.length - 1; i >= 0; i--) { diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 3beb59c65..9bd387fdd 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -188,13 +188,13 @@ } interface QueueRunnerAttrs { queueableFns: {fn: Function}[]; - onComplete: () => void; clearStack: (fn: any) => void; - onException: (error: any) => void; catchException: () => boolean; + fail: () => void; + onComplete: () => void; + onException: (error: any) => void; userContext: any; timeout: {setTimeout: Function; clearTimeout: Function}; - fail: () => void; } const QueueRunner = (jasmine as any).QueueRunner as { @@ -202,12 +202,7 @@ }; (jasmine as any).QueueRunner = (function(_super) { __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs: { - onComplete: Function; - userContext?: any; - timeout?: {setTimeout: Function; clearTimeout: Function}; - onException?: (error: any) => void; - }) { + function ZoneQueueRunner(attrs: QueueRunnerAttrs) { attrs.onComplete = (fn => () => { // All functions are done, clear the test zone. this.testProxyZone = null; diff --git a/lib/rxjs/rxjs-fake-async.ts b/lib/rxjs/rxjs-fake-async.ts index fc1b617b7..d6e10e385 100644 --- a/lib/rxjs/rxjs-fake-async.ts +++ b/lib/rxjs/rxjs-fake-async.ts @@ -10,12 +10,12 @@ import {asapScheduler, asyncScheduler, Scheduler} from 'rxjs'; Zone.__load_patch('rxjs.Scheduler.now', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchMethod(Scheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { - return Date.now.apply(self, args); + return Date.now.call(self); }); api.patchMethod(asyncScheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { - return Date.now.apply(self, args); + return Date.now.call(self); }); api.patchMethod(asapScheduler, 'now', (delegate: Function) => (self: any, args: any[]) => { - return Date.now.apply(self, args); + return Date.now.call(self); }); }); diff --git a/lib/rxjs/rxjs.ts b/lib/rxjs/rxjs.ts index 4a29a7405..c84e9ed83 100644 --- a/lib/rxjs/rxjs.ts +++ b/lib/rxjs/rxjs.ts @@ -151,7 +151,7 @@ import {Observable, Subscriber, Subscription} from 'rxjs'; if (subscriptionZone && subscriptionZone !== currentZone) { return subscriptionZone.run(next, this, arguments, nextSource); } else { - return next.apply(this, arguments); + return next.apply(this, arguments as any); } }; @@ -164,7 +164,7 @@ import {Observable, Subscriber, Subscription} from 'rxjs'; if (subscriptionZone && subscriptionZone !== currentZone) { return subscriptionZone.run(error, this, arguments, errorSource); } else { - return error.apply(this, arguments); + return error.apply(this, arguments as any); } }; @@ -177,7 +177,7 @@ import {Observable, Subscriber, Subscription} from 'rxjs'; if (subscriptionZone && subscriptionZone !== currentZone) { return subscriptionZone.run(complete, this, arguments, completeSource); } else { - return complete.apply(this, arguments); + return complete.call(this); } }; }; diff --git a/package.json b/package.json index 6dffd961c..3db6bee95 100644 --- a/package.json +++ b/package.json @@ -106,7 +106,7 @@ "ts-loader": "^0.6.0", "tslint": "^4.1.1", "tslint-eslint-rules": "^3.1.0", - "typescript": "^3.0.3", + "typescript": "^3.2.2", "vrsource-tslint-rules": "^4.0.0", "webdriver-manager": "^12.0.6", "webdriverio": "^4.8.0", diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/browser/XMLHttpRequest.spec.ts index 584f931e3..2a54e5901 100644 --- a/test/browser/XMLHttpRequest.spec.ts +++ b/test/browser/XMLHttpRequest.spec.ts @@ -386,7 +386,7 @@ describe('XMLHttpRequest', function() { }; expect(req.onreadystatechange).toBe(listener); req.onreadystatechange = function() { - return listener.apply(this, arguments); + return listener.call(this); }; req.send(); }); diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index 2ef7c09a8..d43b56728 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -103,7 +103,7 @@ describe( xit('should ensure that Promise this is instanceof Promise', () => { expect(() => { - Promise.call({}, null); + Promise.call({}, () => null); }).toThrowError('Must be an instanceof Promise.'); }); @@ -508,18 +508,22 @@ describe( }); describe('Promise subclasses', function() { - class MyPromise { + class MyPromise { private _promise: Promise; constructor(init: any) { this._promise = new Promise(init); } - catch() { - return this._promise.catch.apply(this._promise, arguments); + catch(onrejected?: ((reason: any) => TResult | PromiseLike)| + undefined|null): Promise { + return this._promise.catch.call(this._promise, onrejected); }; - then() { - return this._promise.then.apply(this._promise, arguments); + then( + onfulfilled?: ((value: T) => TResult1 | PromiseLike)|undefined|null, + onrejected?: ((reason: any) => TResult2 | PromiseLike)|undefined| + null): Promise { + return this._promise.then.call(this._promise, onfulfilled, onrejected); }; } diff --git a/yarn.lock b/yarn.lock index c3dd087d1..d5bff0187 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6472,10 +6472,10 @@ typedarray@^0.0.6, typedarray@~0.0.5: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.0.3.tgz#4853b3e275ecdaa27f78fda46dc273a7eb7fc1c8" - integrity sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg== +typescript@^3.2.2: + version "3.3.3333" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.3333.tgz#171b2c5af66c59e9431199117a3bcadc66fdcfd6" + integrity sha512-JjSKsAfuHBE/fB2oZ8NxtRTk5iGcg6hkYXMnZ3Wc+b2RSqejEqTaem11mHASMnFilHrax3sLK0GDzcJrekZYLw== uglify-js@2.6.4: version "2.6.4" From a5fe09b0fac27ac5df1fa746042f96f05ccb6a00 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 20 Mar 2019 04:33:57 +0900 Subject: [PATCH 092/106] build: make legacy standalone bundle (#1201) --- file-size-limit.json | 7 +++- lib/browser/api-util.ts | 33 +++++++++++++++- lib/browser/browser-legacy.ts | 19 +++++---- lib/browser/browser-util.ts | 38 ++++++++++++++++++ lib/browser/browser.ts | 10 ++++- lib/browser/custom-elements.ts | 41 ++----------------- lib/browser/define-property.ts | 2 +- lib/browser/event-target-legacy.ts | 13 +++--- lib/browser/event-target.ts | 12 ++---- lib/browser/property-descriptor-legacy.ts | 48 +++++++++-------------- lib/browser/property-descriptor.ts | 5 +-- lib/browser/register-element.ts | 8 ++-- lib/browser/websocket.ts | 14 +++---- lib/common/utils.ts | 3 +- lib/zone.ts | 36 ++++++++++++++++- test/browser/WebSocket.spec.ts | 6 ++- test/zone_worker_entry_point.ts | 35 +++++++++-------- 17 files changed, 198 insertions(+), 132 deletions(-) create mode 100644 lib/browser/browser-util.ts diff --git a/file-size-limit.json b/file-size-limit.json index bd147342a..035086819 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -1,9 +1,14 @@ { "targets": [ { - "path": "dist/zone.min.js", + "path": "dist/zone-evergreen.min.js", "checkTarget": true, "limit": 43000 + }, + { + "path": "dist/zone.min.js", + "checkTarget": true, + "limit": 44000 } ] } diff --git a/lib/browser/api-util.ts b/lib/browser/api-util.ts index df83f126f..89ca58144 100644 --- a/lib/browser/api-util.ts +++ b/lib/browser/api-util.ts @@ -6,7 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {bindArguments, patchMacroTask, patchMethod, patchOnProperties} from '../common/utils'; +import {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNames} from '../common/events'; +import {ADD_EVENT_LISTENER_STR, ArraySlice, attachOriginToPatched, bindArguments, FALSE_STR, isBrowser, isIEOrEdge, isMix, isNode, ObjectCreate, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, patchClass, patchMacroTask, patchMethod, patchOnProperties, REMOVE_EVENT_LISTENER_STR, TRUE_STR, wrapWithCurrentZone, ZONE_SYMBOL_PREFIX} from '../common/utils'; + +import {patchCallbacks} from './browser-util'; +import {_redefineProperty} from './define-property'; +import {eventNames, filterProperties} from './property-descriptor'; Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { api.patchOnProperties = patchOnProperties; @@ -28,4 +33,30 @@ Zone.__load_patch('util', (global: any, Zone: ZoneType, api: _ZonePrivate) => { (Zone as any)[SYMBOL_BLACK_LISTED_EVENTS] = (Zone as any)[SYMBOL_UNPATCHED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = () => ({ + globalSources, + zoneSymbolEventNames, + eventNames, + isBrowser, + isMix, + isNode, + TRUE_STR, + FALSE_STR, + ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR + }); }); diff --git a/lib/browser/browser-legacy.ts b/lib/browser/browser-legacy.ts index fa23b2bba..2637c353d 100644 --- a/lib/browser/browser-legacy.ts +++ b/lib/browser/browser-legacy.ts @@ -14,11 +14,16 @@ import {eventTargetLegacyPatch} from './event-target-legacy'; import {propertyDescriptorLegacyPatch} from './property-descriptor-legacy'; import {registerElementPatch} from './register-element'; -Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - registerElementPatch(global); -}); +(function(_global: any) { +_global['__zone_symbol__legacyPatch'] = function() { + const Zone = _global['Zone']; + Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + registerElementPatch(global, api); + }); -Zone.__load_patch('EventTargetLegacy', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - eventTargetLegacyPatch(global, api); - propertyDescriptorLegacyPatch(api, global); -}); + Zone.__load_patch('EventTargetLegacy', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); +}; +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/lib/browser/browser-util.ts b/lib/browser/browser-util.ts new file mode 100644 index 000000000..99c453030 --- /dev/null +++ b/lib/browser/browser-util.ts @@ -0,0 +1,38 @@ +/** + * @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 + */ +export function patchCallbacks( + api: _ZonePrivate, target: any, targetName: string, method: string, callbacks: string[]) { + const symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + const nativeDelegate = target[symbol] = target[method]; + target[method] = function(name: any, opts: any, options?: any) { + if (opts && opts.prototype) { + callbacks.forEach(function(callback) { + const source = `${targetName}.${method}::` + callback; + const prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + } else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + + return nativeDelegate.call(target, name, opts, options); + }; + + api.attachOriginToPatched(target[method], nativeDelegate); +} diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 6a3f74c37..8599ad02f 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -18,7 +18,13 @@ import {patchCustomElements} from './custom-elements'; import {propertyPatch} from './define-property'; import {eventTargetPatch, patchEvent} from './event-target'; import {propertyDescriptorPatch} from './property-descriptor'; -import {registerElementPatch} from './register-element'; + +Zone.__load_patch('legacy', (global: any) => { + const legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } +}); Zone.__load_patch('timers', (global: any) => { const set = 'set'; @@ -66,7 +72,7 @@ Zone.__load_patch('on_property', (global: any, Zone: ZoneType, api: _ZonePrivate }); Zone.__load_patch('customElements', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - patchCustomElements(global); + patchCustomElements(global, api); }); Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { diff --git a/lib/browser/custom-elements.ts b/lib/browser/custom-elements.ts index be37aa2d4..dc8fea845 100644 --- a/lib/browser/custom-elements.ts +++ b/lib/browser/custom-elements.ts @@ -6,43 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {attachOriginToPatched, isBrowser, isMix, ObjectGetOwnPropertyDescriptor, wrapWithCurrentZone} from '../common/utils'; - -import {_redefineProperty} from './define-property'; - -export function patchCallbacks( - target: any, targetName: string, method: string, callbacks: string[]) { - const symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; - } - const nativeDelegate = target[symbol] = target[method]; - target[method] = function(name: any, opts: any, options?: any) { - if (opts && opts.prototype) { - callbacks.forEach(function(callback) { - const source = `${targetName}.${method}::` + callback; - const prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - const descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = wrapWithCurrentZone(descriptor.value, source); - _redefineProperty(opts.prototype, callback, descriptor); - } else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } - } else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } - }); - } - - return nativeDelegate.call(target, name, opts, options); - }; - - attachOriginToPatched(target[method], nativeDelegate); -} - -export function patchCustomElements(_global: any) { +export function patchCustomElements(_global: any, api: _ZonePrivate) { + const {isBrowser, isMix} = api.getGlobalObjects()!; if ((!isBrowser && !isMix) || !('customElements' in _global)) { return; } @@ -50,5 +15,5 @@ export function patchCustomElements(_global: any) { const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); } diff --git a/lib/browser/define-property.ts b/lib/browser/define-property.ts index 872631148..2c00b118f 100644 --- a/lib/browser/define-property.ts +++ b/lib/browser/define-property.ts @@ -6,12 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {zoneSymbol} from '../common/utils'; /* * This is necessary for Chrome and Chrome mobile, to enable * things like redefining `createdCallback` on an element. */ +const zoneSymbol = Zone.__symbol__; const _defineProperty = (Object as any)[zoneSymbol('defineProperty')] = Object.defineProperty; const _getOwnPropertyDescriptor = (Object as any)[zoneSymbol('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; diff --git a/lib/browser/event-target-legacy.ts b/lib/browser/event-target-legacy.ts index 610f08be1..9a4b025ef 100644 --- a/lib/browser/event-target-legacy.ts +++ b/lib/browser/event-target-legacy.ts @@ -6,12 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNames} from '../common/events'; -import {FALSE_STR, isIEOrEdge, TRUE_STR, ZONE_SYMBOL_PREFIX} from '../common/utils'; - -import {eventNames} from './property-descriptor'; - export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { + const {eventNames, globalSources, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX} = + api.getGlobalObjects()!; 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 = @@ -36,7 +33,7 @@ export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { const isDisableIECheck = _global['__Zone_disable_IE_check'] || false; const isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - const ieOrEdge = isIEOrEdge(); + const ieOrEdge = api.isIEOrEdge(); const ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; const FUNCTION_WRAPPER = '[object FunctionWrapper]'; @@ -103,11 +100,11 @@ export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { } // vh is validateHandler to check event handler // is valid or not(for security check) - patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); + api.patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); return true; } export function patchEvent(global: any, api: _ZonePrivate) { - patchEventPrototype(global, api); + api.patchEventPrototype(global, api); } diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index 0f4c23c4b..abbe51837 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -6,12 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {globalSources, patchEventPrototype, patchEventTarget, zoneSymbolEventNames} from '../common/events'; -import {FALSE_STR, TRUE_STR, ZONE_SYMBOL_PREFIX} from '../common/utils'; - -import {eventNames} from './property-descriptor'; - export function eventTargetPatch(_global: any, api: _ZonePrivate) { + const {eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX} = + api.getGlobalObjects()!; // predefine all __zone_symbol__ + eventName + true/false string for (let i = 0; i < eventNames.length; i++) { const eventName = eventNames[i]; @@ -28,12 +25,11 @@ export function eventTargetPatch(_global: any, api: _ZonePrivate) { if (!EVENT_TARGET || !EVENT_TARGET.prototype) { return; } - patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); - api.patchEventTarget = patchEventTarget; + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); return true; } export function patchEvent(global: any, api: _ZonePrivate) { - patchEventPrototype(global, api); + api.patchEventPrototype(global, api); } diff --git a/lib/browser/property-descriptor-legacy.ts b/lib/browser/property-descriptor-legacy.ts index b994fd0ad..8ee0ea291 100644 --- a/lib/browser/property-descriptor-legacy.ts +++ b/lib/browser/property-descriptor-legacy.ts @@ -10,32 +10,19 @@ * @suppress {globalThis} */ -import {isBrowser, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, patchClass, patchOnProperties, wrapWithCurrentZone, zoneSymbol} from '../common/utils'; - -import {eventNames, filterProperties, IgnoreProperty} from './property-descriptor'; import * as webSocketPatch from './websocket'; -export function patchFilteredProperties( - target: any, onProperties: string[], ignoreProperties: IgnoreProperty[], prototype?: any) { - // check whether target is available, sometimes target will be undefined - // because different browser or some 3rd party plugin. - if (!target) { - return; - } - const filteredProperties: string[] = filterProperties(target, onProperties, ignoreProperties); - patchOnProperties(target, filteredProperties, prototype); -} - export function propertyDescriptorLegacyPatch(api: _ZonePrivate, _global: any) { + const {isNode, isMix} = api.getGlobalObjects()!; if (isNode && !isMix) { return; } const supportsWebSocket = typeof WebSocket !== 'undefined'; - if (!canPatchViaPropertyDescriptor()) { + if (!canPatchViaPropertyDescriptor(api)) { // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(); - patchClass('XMLHttpRequest'); + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); if (supportsWebSocket) { webSocketPatch.apply(api, _global); } @@ -43,19 +30,22 @@ export function propertyDescriptorLegacyPatch(api: _ZonePrivate, _global: any) { } } -function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && +function canPatchViaPropertyDescriptor(api: _ZonePrivate) { + const {isBrowser, isMix} = api.getGlobalObjects()!; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') { // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 // IDL interface attributes are not configurable - const desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + const desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; } const ON_READY_STATE_CHANGE = 'onreadystatechange'; const XMLHttpRequestPrototype = XMLHttpRequest.prototype; - const xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + const xhrDesc = + api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); // add enumerable and configurable here because in opera // by default XMLHttpRequest.prototype.onreadystatechange is undefined @@ -64,7 +54,7 @@ function canPatchViaPropertyDescriptor() { // and if XMLHttpRequest.prototype.onreadystatechange is undefined, // we should set a real desc instead a fake one if (xhrDesc) { - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function() { @@ -74,11 +64,11 @@ function canPatchViaPropertyDescriptor() { const req = new XMLHttpRequest(); const result = !!req.onreadystatechange; // restore original desc - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } else { - const SYMBOL_FAKE_ONREADYSTATECHANGE = zoneSymbol('fake'); - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + const SYMBOL_FAKE_ONREADYSTATECHANGE = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function() { @@ -97,12 +87,12 @@ function canPatchViaPropertyDescriptor() { } } -const unboundKey = zoneSymbol('unbound'); - // Whenever any eventListener fires, we check the eventListener target and all parents // for `onwhatever` properties and replace them with zone-bound functions // - Chrome (for now) -function patchViaCapturingAllTheEvents() { +function patchViaCapturingAllTheEvents(api: _ZonePrivate) { + const {eventNames} = api.getGlobalObjects()!; + const unboundKey = api.symbol('unbound'); for (let i = 0; i < eventNames.length; i++) { const property = eventNames[i]; const onproperty = 'on' + property; @@ -115,7 +105,7 @@ function patchViaCapturingAllTheEvents() { } while (elt) { if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = wrapWithCurrentZone(elt[onproperty], source); + bound = api.wrapWithCurrentZone(elt[onproperty], source); bound[unboundKey] = elt[onproperty]; elt[onproperty] = bound; } diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 39b8ae139..5b518c00f 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -10,9 +10,7 @@ * @suppress {globalThis} */ -import {isBrowser, isIE, isMix, isNode, ObjectDefineProperty, ObjectGetOwnPropertyDescriptor, ObjectGetPrototypeOf, patchClass, patchOnProperties, wrapWithCurrentZone, zoneSymbol} from '../common/utils'; - -import * as webSocketPatch from './websocket'; +import {isBrowser, isIE, isMix, isNode, ObjectGetPrototypeOf, patchOnProperties} from '../common/utils'; const globalEventHandlersEventNames = [ 'abort', @@ -273,7 +271,6 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { // events are already been patched by legacy patch. return; } - const supportsWebSocket = typeof WebSocket !== 'undefined'; const ignoreProperties: IgnoreProperty[] = _global['__Zone_ignore_on_properties']; // for browsers that we can patch the descriptor: Chrome & Firefox diff --git a/lib/browser/register-element.ts b/lib/browser/register-element.ts index 911a25166..b61b380b8 100644 --- a/lib/browser/register-element.ts +++ b/lib/browser/register-element.ts @@ -6,10 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {isBrowser, isMix} from '../common/utils'; -import {patchCallbacks} from './custom-elements'; - -export function registerElementPatch(_global: any) { +export function registerElementPatch(_global: any, api: _ZonePrivate) { + const {isBrowser, isMix} = api.getGlobalObjects()!; if ((!isBrowser && !isMix) || !('registerElement' in (_global).document)) { return; } @@ -17,5 +15,5 @@ export function registerElementPatch(_global: any) { const callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - patchCallbacks(document, 'Document', 'registerElement', callbacks); + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); } diff --git a/lib/browser/websocket.ts b/lib/browser/websocket.ts index ab3cc0d41..07055b45d 100644 --- a/lib/browser/websocket.ts +++ b/lib/browser/websocket.ts @@ -6,16 +6,14 @@ * found in the LICENSE file at https://angular.io/license */ -import {patchEventTarget} from '../common/events'; -import {ADD_EVENT_LISTENER_STR, ArraySlice, ObjectCreate, ObjectGetOwnPropertyDescriptor, patchOnProperties, REMOVE_EVENT_LISTENER_STR} from '../common/utils'; - // we have to patch the instance since the proto is non-configurable export function apply(api: _ZonePrivate, _global: any) { + const {ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR} = api.getGlobalObjects()!; const WS = (_global).WebSocket; // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener // On older Chrome, no need since EventTarget was already patched if (!(_global).EventTarget) { - patchEventTarget(_global, [WS.prototype]); + api.patchEventTarget(_global, [WS.prototype]); } (_global).WebSocket = function(x: any, y: any) { const socket = arguments.length > 1 ? new WS(x, y) : new WS(x); @@ -24,9 +22,9 @@ export function apply(api: _ZonePrivate, _global: any) { let proxySocketProto: any; // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - const onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + const onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = ObjectCreate(socket); + proxySocket = api.ObjectCreate(socket); // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' // but proxySocket not, so we will keep socket as prototype and pass it to // patchOnProperties method @@ -34,7 +32,7 @@ export function apply(api: _ZonePrivate, _global: any) { [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function( propName) { proxySocket[propName] = function() { - const args = ArraySlice.call(arguments); + const args = api.ArraySlice.call(arguments); if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { const eventName = args.length > 0 ? args[0] : undefined; if (eventName) { @@ -50,7 +48,7 @@ export function apply(api: _ZonePrivate, _global: any) { proxySocket = socket; } - patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); return proxySocket; }; diff --git a/lib/common/utils.ts b/lib/common/utils.ts index 40c5b1f37..b032f3c5a 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -12,7 +12,6 @@ */ // issue #989, to reduce bundle size, use short name - /** Object.getOwnPropertyDescriptor */ export const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; /** Object.defineProperty */ @@ -513,7 +512,7 @@ export function isIEOrEdge() { if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } - return ieOrEdge; } catch (error) { } + return ieOrEdge; } diff --git a/lib/zone.ts b/lib/zone.ts index d46205ff5..3c6204e65 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -321,7 +321,7 @@ interface _ZonePrivate { microtaskDrainDone: () => void; showUncaughtError: () => boolean; patchEventTarget: (global: any, apis: any[], options?: any) => boolean[]; - patchOnProperties: (obj: any, properties: string[]|null) => void; + patchOnProperties: (obj: any, properties: string[]|null, prototype?: any) => void; patchThen: (ctro: Function) => void; setNativePromise: (nativePromise: any) => void; patchMethod: @@ -331,6 +331,27 @@ interface _ZonePrivate { bindArguments: (args: any[], source: string) => any[]; patchMacroTask: (obj: any, funcName: string, metaCreator: (self: any, args: any[]) => any) => void; + patchEventPrototype: (_global: any, api: _ZonePrivate) => void; + isIEOrEdge: () => boolean; + ObjectDefineProperty: + (o: any, p: PropertyKey, attributes: PropertyDescriptor&ThisType) => any; + ObjectGetOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined; + ObjectCreate(o: object|null, properties?: PropertyDescriptorMap&ThisType): any; + ArraySlice(start?: number, end?: number): any[]; + patchClass: (className: string) => void; + wrapWithCurrentZone: (callback: any, source: string) => any; + filterProperties: (target: any, onProperties: string[], ignoreProperties: any[]) => string[]; + attachOriginToPatched: (target: any, origin: any) => void; + _redefineProperty: (target: any, callback: string, desc: any) => void; + patchCallbacks: + (api: _ZonePrivate, target: any, targetName: string, method: string, + callbacks: string[]) => void; + getGlobalObjects: () => { + globalSources: any, zoneSymbolEventNames: any, eventNames: string[], isBrowser: boolean, + isMix: boolean, isNode: boolean, TRUE_STR: string, FALSE_STR: string, + ZONE_SYMBOL_PREFIX: string, ADD_EVENT_LISTENER_STR: string, + REMOVE_EVENT_LISTENER_STR: string + } | undefined; } /** @internal */ @@ -1356,6 +1377,19 @@ const Zone: ZoneType = (function(global: any) { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, + patchEventPrototype: () => noop, + isIEOrEdge: () => false, + getGlobalObjects: () => undefined, + ObjectDefineProperty: () => noop, + ObjectGetOwnPropertyDescriptor: () => undefined, + ObjectCreate: () => undefined, + ArraySlice: () => [], + patchClass: () => noop, + wrapWithCurrentZone: () => noop, + filterProperties: () => [], + attachOriginToPatched: () => noop, + _redefineProperty: () => noop, + patchCallbacks: () => noop }; let _currentZoneFrame: _ZoneFrame = {parent: null, zone: new Zone(null, null)}; let _currentTask: Task|null = null; diff --git a/test/browser/WebSocket.spec.ts b/test/browser/WebSocket.spec.ts index 86441f2fe..f5aab9077 100644 --- a/test/browser/WebSocket.spec.ts +++ b/test/browser/WebSocket.spec.ts @@ -44,6 +44,10 @@ if (!window['saucelabs']) { it('should be patched in a Web Worker', done => { const worker = new Worker('/base/build/test/ws-webworker-context.js'); worker.onmessage = (e: MessageEvent) => { + if (e.data !== 'pass' && e.data !== 'fail') { + fail(`web worker ${e.data}`); + return; + } expect(e.data).toBe('pass'); done(); }; @@ -138,4 +142,4 @@ if (!window['saucelabs']) { expect(Object.keys(WebSocket)).toContain('CLOSED'); }); })); -} \ No newline at end of file +} diff --git a/test/zone_worker_entry_point.ts b/test/zone_worker_entry_point.ts index 411fcc56e..ce22f666b 100644 --- a/test/zone_worker_entry_point.ts +++ b/test/zone_worker_entry_point.ts @@ -8,21 +8,24 @@ // Setup tests for Zone without microtask support System.config({defaultJSExtensions: true}); -System.import('../lib/browser/browser-legacy').then(() => { - System.import('../lib/browser/browser').then(() => { - Zone.current.fork({name: 'webworker'}).run(() => { - const websocket = new WebSocket('ws://localhost:8001'); - websocket.addEventListener('open', () => { - websocket.onmessage = () => { - if ((self).Zone.current.name === 'webworker') { - (self).postMessage('pass'); - } else { - (self).postMessage('fail'); - } - websocket.close(); - }; - websocket.send('text'); +System.import('../lib/browser/api-util').then(() => { + System.import('../lib/browser/browser-legacy').then(() => { + System.import('../lib/browser/browser').then(() => { + const _global = typeof window !== 'undefined' ? window : self; + Zone.current.fork({name: 'webworker'}).run(() => { + const websocket = new WebSocket('ws://localhost:8001'); + websocket.addEventListener('open', () => { + websocket.onmessage = () => { + if ((self).Zone.current.name === 'webworker') { + (self).postMessage('pass'); + } else { + (self).postMessage('fail'); + } + websocket.close(); + }; + websocket.send('text'); + }); }); - }); - }, (e) => console.error(e)); + }, (e) => (self).postMessage(`error ${e.message}`)); + }); }); From c378f879a87277512c7341298e9375fa555fc9d2 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Thu, 21 Mar 2019 01:55:01 +0900 Subject: [PATCH 093/106] feat: add an option __zone_symbol__disableDatePatching to allow disable patching global.Date (#1203) --- lib/zone-spec/fake-async-test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index 307470cb1..b52c444f4 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -346,6 +346,15 @@ class FakeAsyncTestZoneSpec implements ZoneSpec { } static patchDate() { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } + if (global['Date'] === FakeDate) { // already patched return; From 47dd3f49c3f3749385dafc5d0f51b8e4fd650f21 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Thu, 21 Mar 2019 08:12:52 +0900 Subject: [PATCH 094/106] fix: remove finally definition from Promise interface, will use es2018.promise in the future (#1204) --- lib/common/promise.ts | 10 +++------- test/common/Promise.spec.ts | 30 ++++++++++++++++-------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/common/promise.ts b/lib/common/promise.ts index a2910d387..92ac35cc8 100644 --- a/lib/common/promise.ts +++ b/lib/common/promise.ts @@ -5,10 +5,6 @@ * 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 */ -interface Promise { - finally(onFinally?: () => U | PromiseLike): Promise; -} - Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePrivate) => { const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; const ObjectDefineProperty = Object.defineProperty; @@ -146,7 +142,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if (state !== REJECTED && value instanceof ZoneAwarePromise && value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && (value as any)[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(>value); + clearRejectedNoCatch(>value as any); resolvePromise(promise, (value as any)[symbolState], (value as any)[symbolValue]); } else if (state !== REJECTED && typeof then === 'function') { try { @@ -379,7 +375,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if ((this as any)[symbolState] == UNRESOLVED) { ((this as any)[symbolValue]).push(zone, chainPromise, onFulfilled, onRejected); } else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + scheduleResolveOrReject(this, zone, chainPromise as any, onFulfilled, onRejected); } return chainPromise; } @@ -397,7 +393,7 @@ Zone.__load_patch('ZoneAwarePromise', (global: any, Zone: ZoneType, api: _ZonePr if ((this as any)[symbolState] == UNRESOLVED) { ((this as any)[symbolValue]).push(zone, chainPromise, onFinally, onFinally); } else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + scheduleResolveOrReject(this, zone, chainPromise as any, onFinally, onFinally); } return chainPromise; } diff --git a/test/common/Promise.spec.ts b/test/common/Promise.spec.ts index d43b56728..66d4024b0 100644 --- a/test/common/Promise.spec.ts +++ b/test/common/Promise.spec.ts @@ -219,13 +219,14 @@ describe( let resolve: Function|null = null; testZone.run(function() { - new Promise(function(resolveFn) { - resolve = resolveFn; - }).finally(function() { - expect(arguments.length).toBe(0); - expect(Zone.current).toBe(testZone); - done(); - }); + (new Promise(function(resolveFn) { + resolve = resolveFn; + }) as any) + .finally(function() { + expect(arguments.length).toBe(0); + expect(Zone.current).toBe(testZone); + done(); + }); }); resolve!('value'); @@ -235,13 +236,14 @@ describe( let reject: Function|null = null; testZone.run(function() { - new Promise(function(_, rejectFn) { - reject = rejectFn; - }).finally(function() { - expect(arguments.length).toBe(0); - expect(Zone.current).toBe(testZone); - done(); - }); + (new Promise(function(_, rejectFn) { + reject = rejectFn; + }) as any) + .finally(function() { + expect(arguments.length).toBe(0); + expect(Zone.current).toBe(testZone); + done(); + }); }); reject!('error'); From 2a8415df975fd7e154d3a93f9973ec0c594385b5 Mon Sep 17 00:00:00 2001 From: vikerman Date: Wed, 20 Mar 2019 16:14:28 -0700 Subject: [PATCH 095/106] fix: closure related fixes (#1206) These fixes are needed to make Zone compile with closure with advanced optimizations. --- lib/common/fetch.ts | 4 ++++ lib/zone-spec/long-stack-trace.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/common/fetch.ts b/lib/common/fetch.ts index f159aa3b0..ee1db6b05 100644 --- a/lib/common/fetch.ts +++ b/lib/common/fetch.ts @@ -5,6 +5,10 @@ * 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 */ +/** + * @fileoverview + * @suppress {missingRequire} + */ Zone.__load_patch('fetch', (global: any, Zone: ZoneType, api: _ZonePrivate) => { interface FetchTaskData extends TaskData { diff --git a/lib/zone-spec/long-stack-trace.ts b/lib/zone-spec/long-stack-trace.ts index dbcfad1cb..e60c704f6 100644 --- a/lib/zone-spec/long-stack-trace.ts +++ b/lib/zone-spec/long-stack-trace.ts @@ -113,7 +113,10 @@ function renderLongStackTrace(frames: LongStackTrace[], stack?: string): string // Fix issue https://github.com/angular/zone.js/issues/1195, // For event task of browser, by default, all task will share a // singleton instance of data object, we should create a new one here - task.data = {...task.data}; + + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + (task.data as any) = {...(task.data as any)}; } (task.data as any)[creationTrace] = trace; } From d32e79be3603304ac43e64552c19045a39c5eac5 Mon Sep 17 00:00:00 2001 From: vikerman Date: Wed, 20 Mar 2019 18:39:20 -0700 Subject: [PATCH 096/106] fix: make fakeAsync test spec timer id global (#1207) There is a possibility that a single test gets timer id-s from two separate fakeAsync test zones and the id-s could clash. This changes makes it such that the next timer id is global and the can never clash. --- lib/zone-spec/fake-async-test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index b52c444f4..babdcfec3 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -64,7 +64,7 @@ const timers = { class Scheduler { // Next scheduler id. - public nextId: number = 1; + public static nextId: number = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. private _schedulerQueue: ScheduledFunction[] = []; @@ -90,7 +90,7 @@ class Scheduler { scheduleFunction( cb: Function, delay: number, args: any[] = [], isPeriodic: boolean = false, isRequestAnimationFrame: boolean = false, id: number = -1): number { - let currentId: number = id < 0 ? this.nextId++ : id; + let currentId: number = id < 0 ? Scheduler.nextId++ : id; let endTime = this._currentTime + delay; // Insert so that scheduler queue remains sorted by end time. @@ -292,7 +292,7 @@ class FakeAsyncTestZoneSpec implements ZoneSpec { } private _setTimeout(fn: Function, delay: number, args: any[], isTimer = true): number { - let removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + let removeTimerFn = this._dequeueTimer(Scheduler.nextId); // Queue the callback and dequeue the timer on success and error. let cb = this._fnAndFlush(fn, {onSuccess: removeTimerFn, onError: removeTimerFn}); let id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); @@ -308,7 +308,7 @@ class FakeAsyncTestZoneSpec implements ZoneSpec { } private _setInterval(fn: Function, interval: number, args: any[]): number { - let id = this._scheduler.nextId; + let id = Scheduler.nextId; let completers = {onSuccess: null as any, onError: this._dequeuePeriodicTimer(id)}; let cb = this._fnAndFlush(fn, completers); From 31d31ceead4a8dfd0b747f1912f98f61c89dceff Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Fri, 22 Mar 2019 11:19:38 +0900 Subject: [PATCH 097/106] build: bump version to 0.9.0 (#1193) --- CHANGELOG.md | 38 + dist/fake-async-test.js | 18 +- dist/jasmine-patch.js | 31 +- dist/jasmine-patch.min.js | 2 +- dist/long-stack-trace-zone.js | 19 + dist/long-stack-trace-zone.min.js | 2 +- dist/mocha-patch.js | 7 +- dist/mocha-patch.min.js | 2 +- dist/proxy.min.js | 2 +- dist/task-tracking.min.js | 2 +- dist/webapis-media-query.min.js | 2 +- dist/webapis-notification.min.js | 2 +- dist/webapis-rtc-peer-connection.min.js | 2 +- dist/webapis-shadydom.min.js | 2 +- dist/wtf.min.js | 2 +- dist/zone-bluebird.min.js | 2 +- dist/zone-error.min.js | 2 +- dist/zone-evergreen-testing-bundle.js | 4769 +++++++++++++++++++++++ dist/zone-evergreen.js | 3040 +++++++++++++++ dist/zone-evergreen.min.js | 1 + dist/zone-legacy.js | 321 ++ dist/zone-legacy.min.js | 1 + dist/zone-mix.js | 546 +-- dist/zone-node.js | 61 +- dist/zone-patch-canvas.js | 31 + dist/zone-patch-canvas.min.js | 1 + dist/zone-patch-cordova.min.js | 2 +- dist/zone-patch-electron.min.js | 2 +- dist/zone-patch-fetch.js | 120 + dist/zone-patch-fetch.min.js | 1 + dist/zone-patch-jsonp.min.js | 2 +- dist/zone-patch-promise-test.min.js | 2 +- dist/zone-patch-resize-observer.min.js | 2 +- dist/zone-patch-rxjs-fake-async.js | 6 +- dist/zone-patch-rxjs-fake-async.min.js | 2 +- dist/zone-patch-rxjs.js | 2 +- dist/zone-patch-rxjs.min.js | 2 +- dist/zone-patch-socket-io.min.js | 2 +- dist/zone-patch-user-media.min.js | 2 +- dist/zone-testing-bundle.js | 1097 +++--- dist/zone-testing-node-bundle.js | 129 +- dist/zone-testing.js | 68 +- dist/zone.js | 1033 ++--- dist/zone.js.d.ts | 4 +- dist/zone.min.js | 3 +- package.json | 2 +- 46 files changed, 9989 insertions(+), 1402 deletions(-) create mode 100644 dist/zone-evergreen-testing-bundle.js create mode 100644 dist/zone-evergreen.js create mode 100644 dist/zone-evergreen.min.js create mode 100644 dist/zone-legacy.js create mode 100644 dist/zone-legacy.min.js create mode 100644 dist/zone-patch-canvas.js create mode 100644 dist/zone-patch-canvas.min.js create mode 100644 dist/zone-patch-fetch.js create mode 100644 dist/zone-patch-fetch.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 00eac3742..06eef6011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,41 @@ + +# [0.9.0](https://github.com/angular/zone.js/compare/v0.8.29...0.9.0) (2019-03-12) + + +### Bug Fixes + +* **lint:** fix [#1168](https://github.com/angular/zone.js/issues/1168), remove unused = null code ([#1171](https://github.com/angular/zone.js/issues/1171)) ([917e2af](https://github.com/angular/zone.js/commit/917e2af)) +* **test:** fix [#1155](https://github.com/angular/zone.js/issues/1155), try/catch modify error.message ([#1157](https://github.com/angular/zone.js/issues/1157)) ([7e983d1](https://github.com/angular/zone.js/commit/7e983d1)) +* **test:** fix: make fakeAsync test spec timer id global ([d32e79b](https://github.com/angular/zone.js/commit/d32e79b)) +* **build:** fix: closure related fixes ([2a8415d](https://github.com/angular/zone.js/commit/2a8415d)) +* **compile:** fix: remove finally definition from Promise interface ([47dd3f4](https://github.com/angular/zone.js/commit/47dd3f4)) + +### Doc + +* **doc:** [#1181](https://github.com/angular/zone.js/pull/1181), Fix the typo in timer module documentation ([8f78b55](https://github.com/angular/zone.js/commit/8f78b55)) +* **doc:** [#1163](https://github.com/angular/zone.js/pull/1163), Update YouTube video link ([f171821](https://github.com/angular/zone.js/commit/f171821)) +* **doc:** [#1151](https://github.com/angular/zone.js/pull/1151), Re-phrase the lines for better understanding ([2a6444b](https://github.com/angular/zone.js/commit/2a6444b)) +* **doc:** [#1152](https://github.com/angular/zone.js/pull/1152), change the word TimerTask to MacroTask ([f3995de](https://github.com/angular/zone.js/commit/f3995de)) + + +### Features + +* **test:** add benchmark page ([#1076](https://github.com/angular/zone.js/issues/1076)) ([128649a](https://github.com/angular/zone.js/commit/128649a)) +* **test:** test(promise): add test cases for Promise.all with sync then operation ([#1158](https://github.com/angular/zone.js/issues/1158)) ([0b44e83](https://github.com/angular/zone.js/commit/0b44e83)) +* **test:** feat: add an option __zone_symbol__disableDatePatching to allow disabling Date patching ([c378f87](https://github.com/angular/zone.js/commit/c378f87)) + +### Env + +* **env:** change BLACK_LISTED_EVENTS to DISABLE_EVENTS ([9c65d25](https://github.com/angular/zone.js/commit/9c65d25)) + +### Build + +* **build:** build zone-evergreen.js in es2015, add terser minify support ([2ad936b](https://github.com/angular/zone.js/commit/2ad936b)) +* **build:** upgrade to pass jasmine 3.3 test ([82dfd75](https://github.com/angular/zone.js/commit/82dfd75)) +* **build:** upgrade to typescript 3.2.2 ([fcdd559](https://github.com/angular/zone.js/commit/fcdd559)) +* **build:** separate zone.js into evergreen only and legacy included bundles ([ac3851e](https://github.com/angular/zone.js/commit/ac3851e)) +* **build:** make legacy standalone bundle ([a5fe09b](https://github.com/angular/zone.js/commit/a5fe09b)) + ## [0.8.29](https://github.com/angular/zone.js/compare/v0.8.28...0.8.29) (2019-01-22) diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index 348de8d0f..63ac9898d 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -72,8 +72,6 @@ var __spread = (undefined && undefined.__spread) || function () { }; var Scheduler = /** @class */ (function () { function Scheduler() { - // Next scheduler id. - this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. @@ -95,7 +93,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (isPeriodic === void 0) { isPeriodic = false; } if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } if (id === void 0) { id = -1; } - var currentId = id < 0 ? this.nextId++ : id; + var currentId = id < 0 ? Scheduler.nextId++ : id; var endTime = this._currentTime + delay; // Insert so that scheduler queue remains sorted by end time. var newEntry = { @@ -212,6 +210,8 @@ var __spread = (undefined && undefined.__spread) || function () { } return this._currentTime - startTime; }; + // Next scheduler id. + Scheduler.nextId = 1; return Scheduler; }()); var FakeAsyncTestZoneSpec = /** @class */ (function () { @@ -292,7 +292,7 @@ var __spread = (undefined && undefined.__spread) || function () { }; FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); // Queue the callback and dequeue the timer on success and error. var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); @@ -306,7 +306,7 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.removeScheduledFunctionWithId(id); }; FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = this._scheduler.nextId; + var id = Scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); // Use the callback created above to requeue on success. @@ -336,6 +336,14 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.setCurrentRealTime(realTime); }; FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } if (global['Date'] === FakeDate) { // already patched return; diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 8276ea2fd..4191c6005 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -52,6 +52,30 @@ var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -205,7 +229,12 @@ var proxyZoneSpec = this && this.testProxyZoneSpec; if (proxyZoneSpec) { var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - error.message += pendingTasksInfo; + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } } } if (onException) { diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index 8d984ddfb..505ff0c26 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!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 a.run(e,this,arguments)}}function n(e,n,t,o){var r=!!jasmine[u("clockInstalled")],i=(t.testProxyZoneSpec,t.testProxyZone);if(r&&f){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?i.run(e,n,[o]):i.run(e,n)}function t(e){return e&&(e.length?function(t){return n(e,this,this.queueRunner,t)}:function(){return n(e,this,this.queueRunner)})}var o=function(e,n){function t(){this.constructor=e}for(var o in n)n.hasOwnProperty(o)&&(e[o]=n[o]);e.prototype=null===n?Object.create(n):(t.prototype=n.prototype,new t)},r="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 i=Zone.SyncTestZoneSpec,c=Zone.ProxyZoneSpec;if(!i)throw new Error("Missing: SyncTestZoneSpec");if(!c)throw new Error("Missing: ProxyZoneSpec");var s=Zone.current,a=s.fork(new i("jasmine.describe")),u=Zone.__symbol__,f=r[u("fakeAsyncPatchLock")]===!0,l=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(n){var t=l[n];l[n]=function(n,o){return t.call(this,n,e(o))}}),["it","xit","fit"].forEach(function(e){var n=l[e];l[u(e)]=n,l[e]=function(e,o,r){return arguments[1]=t(o),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=l[e];l[u(e)]=n,l[e]=function(e,o){return arguments[0]=t(e),n.apply(this,arguments)}});var p=jasmine[u("clock")]=jasmine.clock;jasmine.clock=function(){var e=p.apply(this,arguments);if(!e[u("patched")]){e[u("patched")]=u("patched");var n=e[u("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[u("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},f&&["install","uninstall"].forEach(function(n){var t=e[u(n)]=e[n];e[n]=function(){var e=Zone.FakeAsyncTestZoneSpec;return e?void(jasmine[u("clockInstalled")]="install"===n):t.apply(this,arguments)}})}return e};var h=jasmine.QueueRunner;jasmine.QueueRunner=function(e){function n(n){var t=this;n.onComplete=function(e){return function(){t.testProxyZone=null,t.testProxyZoneSpec=null,s.scheduleMicroTask("jasmine.onComplete",e)}}(n.onComplete);var o=r.__zone_symbol__setTimeout,i=r.__zone_symbol__clearTimeout;o&&(n.timeout={setTimeout:o?o:r.setTimeout,clearTimeout:i?i:r.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();e.message+=t}}c&&c.call(this,e)},e.call(this,n)}return o(n,e),n.prototype.execute=function(){for(var n=this,t=Zone.current,o=!1;t;){if(t===s){o=!0;break}t=t.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new c,this.testProxyZone=s.fork(this.testProxyZoneSpec),Zone.currentTask?e.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(n)})},n}(h)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";!function(){var e="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 n=Zone.SyncTestZoneSpec,t=Zone.ProxyZoneSpec;if(!n)throw new Error("Missing: SyncTestZoneSpec");if(!t)throw new Error("Missing: ProxyZoneSpec");var o=Zone.current,r=o.fork(new n("jasmine.describe")),i=Zone.__symbol__,s=!0===e[i("fakeAsyncPatchLock")];if(!(!0===e[i("ignoreUnhandledRejection")])){var a=jasmine.GlobalErrors;a&&!jasmine[i("GlobalErrors")]&&(jasmine[i("GlobalErrors")]=a,jasmine.GlobalErrors=function(){var e=new a,n=e.install;return n&&!e[i("install")]&&(e[i("install")]=n,e.install=function(){var e=process.listeners("unhandledRejection"),t=n.apply(this,arguments);return process.removeAllListeners("unhandledRejection"),e&&e.forEach(function(e){return process.on("unhandledRejection",e)}),t}),e})}var c=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(e){var n=c[e];c[e]=function(e,t){return n.call(this,e,(o=t,function(){return r.run(o,this,arguments)}));var o}}),["it","xit","fit"].forEach(function(e){var n=c[e];c[i(e)]=n,c[e]=function(e,t,o){return arguments[1]=f(t),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=c[e];c[i(e)]=n,c[e]=function(e,t){return arguments[0]=f(e),n.apply(this,arguments)}});var u=jasmine[i("clock")]=jasmine.clock;function l(e,n,t,o){var r=!!jasmine[i("clockInstalled")],a=(t.testProxyZoneSpec,t.testProxyZone);if(r&&s){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?a.run(e,n,[o]):a.run(e,n)}function f(e){return e&&(e.length?function(n){return l(e,this,this.queueRunner,n)}:function(){return l(e,this,this.queueRunner)})}jasmine.clock=function(){var e=u.apply(this,arguments);if(!e[i("patched")]){e[i("patched")]=i("patched");var n=e[i("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[i("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},s&&["install","uninstall"].forEach(function(n){var t=e[i(n)]=e[n];e[n]=function(){if(!Zone.FakeAsyncTestZoneSpec)return t.apply(this,arguments);jasmine[i("clockInstalled")]="install"===n}})}return e};var p=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(t){var r,i=this;t.onComplete=(r=t.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,o.scheduleMicroTask("jasmine.onComplete",r)});var s=e.__zone_symbol__setTimeout,a=e.__zone_symbol__clearTimeout;s&&(t.timeout={setTimeout:s||e.setTimeout,clearTimeout:a||e.clearTimeout}),jasmine.UserContext?(t.userContext||(t.userContext=new jasmine.UserContext),t.userContext.queueRunner=this):(t.userContext||(t.userContext={}),t.userContext.queueRunner=this);var c=t.onException;t.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();try{e.message+=t}catch(e){}}}c&&c.call(this,e)},n.call(this,t)}return function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);function o(){this.constructor=e}e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(r,n),r.prototype.execute=function(){for(var e=this,r=Zone.current,i=!1;r;){if(r===o){i=!0;break}r=r.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new t,this.testProxyZone=o.fork(this.testProxyZoneSpec),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(e)})},r}(p)}()}); \ No newline at end of file diff --git a/dist/long-stack-trace-zone.js b/dist/long-stack-trace-zone.js index 4f3f2f047..9200ae7ca 100644 --- a/dist/long-stack-trace-zone.js +++ b/dist/long-stack-trace-zone.js @@ -22,6 +22,17 @@ * @fileoverview * @suppress {globalThis} */ +var __assign = (undefined && undefined.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var NEWLINE = '\n'; var IGNORE_FRAMES = {}; var creationTrace = '__creationTrace__'; @@ -111,6 +122,14 @@ Zone['longStackTraceZoneSpec'] = { } if (!task.data) task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = __assign({}, task.data); + } task.data[creationTrace] = trace; } return parentZoneDelegate.scheduleTask(targetZone, task); diff --git a/dist/long-stack-trace-zone.min.js b/dist/long-stack-trace-zone.min.js index 0565d31bd..fe18bf627 100644 --- a/dist/long-stack-trace-zone.min.js +++ b/dist/long-stack-trace-zone.min.js @@ -1 +1 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r():"function"==typeof define&&define.amd?define(r):r()}(this,function(){"use strict";function t(){return new Error(u)}function r(){try{throw t()}catch(r){return r}}function a(t){return t.stack?t.stack.split(o):[]}function e(t,r){for(var e=a(r),n=0;n0&&(t.push(a((new h).error)),c(t,r-1))}function i(){if(!(Error.stackTraceLimit<=0)){var t=[];c(t,2);for(var r=t[0],a=t[1],e=0;e0){var n=Zone.currentTask,c=n&&n.data&&n.data[f]||[];c=[new h].concat(c),c.length>this.longStackTraceLimit&&(c.length=this.longStackTraceLimit),e.data||(e.data={}),e.data[f]=c}return t.scheduleTask(a,e)},onHandleError:function(t,r,a,e){if(Error.stackTraceLimit>0){var c=Zone.currentTask||e.task;if(e instanceof Error&&c){var i=n(c.data&&c.data[f],e.stack);try{e.stack=e.longStack=i}catch(o){}}}return t.handleError(a,e)}},i()}); \ No newline at end of file +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r():"function"==typeof define&&define.amd?define(r):r()}(0,function(){"use strict";var t=function(){return(t=Object.assign||function(t){for(var r,a=1,e=arguments.length;a0){var c=Zone.currentTask,i=c&&c.data&&c.data.__creationTrace__||[];(i=[new o].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),n.data||(n.data={}),"eventTask"===n.type&&(n.data=t({},n.data)),n.data.__creationTrace__=i}return r.scheduleTask(e,n)},onHandleError:function(t,r,a,e){if(Error.stackTraceLimit>0){var n=Zone.currentTask||e.task;if(e instanceof Error&&n){var c=h(n.data&&n.data.__creationTrace__,e.stack);try{e.stack=e.longStack=c}catch(t){}}}return t.handleError(a,e)}},function(){if(!(Error.stackTraceLimit<=0)){var t=[];!function t(r,a){a>0&&(r.push(l((new o).error)),t(r,a-1))}(t,2);for(var r=t[0],i=t[1],s=0;s0?i[0]:null;if("function"==typeof a){var o=t.current.wrap(a,"MediaQuery");return a[n.symbol("mediaQueryCallback")]=o,e.call(r,o)}return e.apply(r,i)}})}function i(e){n.patchMethod(e,"removeListener",function(e){return function(t,r){var i=r.length>0?r[0]:null;if("function"==typeof i){var a=i[n.symbol("mediaQueryCallback")];return a?e.call(t,a):e.apply(t,r)}return e.apply(t,r)}})}if(e.MediaQueryList){var a=e.MediaQueryList.prototype;r(a),i(a)}else e.matchMedia&&n.patchMethod(e,"matchMedia",function(e){return function(t,n){var a=e.apply(t,n);if(a){var o=Object.getPrototypeOf(a);o&&o.addListener?(r(o),i(o),r(a),i(a)):a.addListener&&(r(a),i(a))}return a}})})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("mediaQuery",function(e,t,n){function r(e){n.patchMethod(e,"addListener",function(e){return function(r,a){var i=a.length>0?a[0]:null;if("function"==typeof i){var o=t.current.wrap(i,"MediaQuery");return i[n.symbol("mediaQueryCallback")]=o,e.call(r,o)}return e.apply(r,a)}})}function a(e){n.patchMethod(e,"removeListener",function(e){return function(t,r){var a=r.length>0?r[0]:null;if("function"==typeof a){var i=a[n.symbol("mediaQueryCallback")];return i?e.call(t,i):e.apply(t,r)}return e.apply(t,r)}})}if(e.MediaQueryList){var i=e.MediaQueryList.prototype;r(i),a(i)}else e.matchMedia&&n.patchMethod(e,"matchMedia",function(e){return function(t,n){var i=e.apply(t,n);if(i){var o=Object.getPrototypeOf(i);o&&o.addListener?(r(o),a(o),r(i),a(i)):i.addListener&&(r(i),a(i))}return i}})})}); \ No newline at end of file diff --git a/dist/webapis-notification.min.js b/dist/webapis-notification.min.js index cf8cdf11b..c632924e5 100644 --- a/dist/webapis-notification.min.js +++ b/dist/webapis-notification.min.js @@ -1 +1 @@ -!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("notification",function(t,o,e){var n=t.Notification;if(n&&n.prototype){var i=Object.getOwnPropertyDescriptor(n.prototype,"onerror");i&&i.configurable&&e.patchOnProperties(n.prototype,null)}})}); \ No newline at end of file +!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("notification",function(o,t,e){var n=o.Notification;if(n&&n.prototype){var i=Object.getOwnPropertyDescriptor(n.prototype,"onerror");i&&i.configurable&&e.patchOnProperties(n.prototype,null)}})}); \ No newline at end of file diff --git a/dist/webapis-rtc-peer-connection.min.js b/dist/webapis-rtc-peer-connection.min.js index a2f70d40c..ded10ecbb 100644 --- a/dist/webapis-rtc-peer-connection.min.js +++ b/dist/webapis-rtc-peer-connection.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("RTCPeerConnection",function(e,t,o){var n=e.RTCPeerConnection;if(n){var p=o.symbol("addEventListener"),r=o.symbol("removeEventListener");n.prototype.addEventListener=n.prototype[p],n.prototype.removeEventListener=n.prototype[r],n.prototype[p]=null,n.prototype[r]=null,o.patchEventTarget(e,[n.prototype],{useG:!1})}})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("RTCPeerConnection",function(e,t,o){var n=e.RTCPeerConnection;if(n){var p=o.symbol("addEventListener"),r=o.symbol("removeEventListener");n.prototype.addEventListener=n.prototype[p],n.prototype.removeEventListener=n.prototype[r],n.prototype[p]=null,n.prototype[r]=null,o.patchEventTarget(e,[n.prototype],{useG:!1})}})}); \ No newline at end of file diff --git a/dist/webapis-shadydom.min.js b/dist/webapis-shadydom.min.js index 4d0f64feb..cbdc0c953 100644 --- a/dist/webapis-shadydom.min.js +++ b/dist/webapis-shadydom.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("shadydom",function(e,t,o){var n=Object.getPrototypeOf(window);n&&n.hasOwnProperty("addEventListener")&&(n[t.__symbol__("addEventListener")]=null,n[t.__symbol__("removeEventListener")]=null,o.patchEventTarget(e,[n])),Node.prototype.hasOwnProperty("addEventListener")&&(Node.prototype[t.__symbol__("addEventListener")]=null,Node.prototype[t.__symbol__("removeEventListener")]=null,o.patchEventTarget(e,[Node.prototype]))})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("shadydom",function(e,t,o){var n=Object.getPrototypeOf(window);n&&n.hasOwnProperty("addEventListener")&&(n[t.__symbol__("addEventListener")]=null,n[t.__symbol__("removeEventListener")]=null,o.patchEventTarget(e,[n])),Node.prototype.hasOwnProperty("addEventListener")&&(Node.prototype[t.__symbol__("addEventListener")]=null,Node.prototype[t.__symbol__("removeEventListener")]=null,o.patchEventTarget(e,[Node.prototype]))})}); \ No newline at end of file diff --git a/dist/wtf.min.js b/dist/wtf.min.js index ae6905708..b5e62239f 100644 --- a/dist/wtf.min.js +++ b/dist/wtf.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(this,function(){"use strict";!function(e){function n(e,o){if(!e||!o)return null;var t={};for(var c in e)if(e.hasOwnProperty(c)){var a=e[c];switch(typeof a){case"object":var r=a&&a.constructor&&a.constructor.name;a=r==Object.name?n(a,o-1):r;break;case"function":a=a.name||void 0}t[c]=a}return t}function o(e){for(var n=e.name,o=e.parent;null!=o;)n=o.name+"::"+n,o=o.parent;return n}var t=null,c=null,a=function(){var n=e.wtf;return!(!n||!(t=n.trace))&&(c=t.events,!0)}(),r=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,t,c,a){var r=n.fork(c,a);return e.forkInstance(o(c),r.name),r},e.prototype.onInvoke=function(n,a,r,i,s,u,f){var p=f||"unknown",l=e.invokeScope[p];return l||(l=e.invokeScope[p]=c.createScope("Zone:invoke:"+f+"(ascii zone)")),t.leaveScope(l(o(r)),n.invoke(r,i,s,u,f))},e.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},e.prototype.onScheduleTask=function(t,a,r,i){var s=i.type+":"+i.source,u=e.scheduleInstance[s];u||(u=e.scheduleInstance[s]=c.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var f=t.scheduleTask(r,i);return u(o(r),n(i.data,2)),f},e.prototype.onInvokeTask=function(n,a,r,i,s,u){var f=i.source,p=e.invokeTaskScope[f];return p||(p=e.invokeTaskScope[f]=c.createScope("Zone:invokeTask:"+f+"(ascii zone)")),t.leaveScope(p(o(r)),n.invokeTask(r,i,s,u))},e.prototype.onCancelTask=function(t,a,r,i){var s=i.source,u=e.cancelInstance[s];u||(u=e.cancelInstance[s]=c.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var f=t.cancelTask(r,i);return u(o(r),n(i.data,2)),f},e.forkInstance=a?c.createInstance("Zone:fork(ascii zone, ascii newZone)"):null,e.scheduleInstance={},e.cancelInstance={},e.invokeScope={},e.invokeTaskScope={},e}();Zone.wtfZoneSpec=a?new r:null}("object"==typeof window&&window||"object"==typeof self&&self||global)}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";!function(e){var n,o=null,t=null,c=!(!(n=e.wtf)||!(o=n.trace)||(t=o.events,0)),a=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,o,t,c){var a=n.fork(t,c);return e.forkInstance(i(t),a.name),a},e.prototype.onInvoke=function(n,c,a,r,s,u,f){var p=f||"unknown",l=e.invokeScope[p];return l||(l=e.invokeScope[p]=t.createScope("Zone:invoke:"+f+"(ascii zone)")),o.leaveScope(l(i(a)),n.invoke(a,r,s,u,f))},e.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},e.prototype.onScheduleTask=function(n,o,c,a){var s=a.type+":"+a.source,u=e.scheduleInstance[s];u||(u=e.scheduleInstance[s]=t.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var f=n.scheduleTask(c,a);return u(i(c),r(a.data,2)),f},e.prototype.onInvokeTask=function(n,c,a,r,s,u){var f=r.source,p=e.invokeTaskScope[f];return p||(p=e.invokeTaskScope[f]=t.createScope("Zone:invokeTask:"+f+"(ascii zone)")),o.leaveScope(p(i(a)),n.invokeTask(a,r,s,u))},e.prototype.onCancelTask=function(n,o,c,a){var s=a.source,u=e.cancelInstance[s];u||(u=e.cancelInstance[s]=t.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var f=n.cancelTask(c,a);return u(i(c),r(a.data,2)),f},e.forkInstance=c?t.createInstance("Zone:fork(ascii zone, ascii newZone)"):null,e.scheduleInstance={},e.cancelInstance={},e.invokeScope={},e.invokeTaskScope={},e}();function r(e,n){if(!e||!n)return null;var o={};for(var t in e)if(e.hasOwnProperty(t)){var c=e[t];switch(typeof c){case"object":var a=c&&c.constructor&&c.constructor.name;c=a==Object.name?r(c,n-1):a;break;case"function":c=c.name||void 0}o[t]=c}return o}function i(e){for(var n=e.name,o=e.parent;null!=o;)n=o.name+"::"+n,o=o.parent;return n}Zone.wtfZoneSpec=c?new a:null}("object"==typeof window&&window||"object"==typeof self&&self||global)}); \ No newline at end of file diff --git a/dist/zone-bluebird.min.js b/dist/zone-bluebird.min.js index 4502c2f8c..9c05f0c1e 100644 --- a/dist/zone-bluebird.min.js +++ b/dist/zone-bluebird.min.js @@ -1 +1 @@ -!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("bluebird",function(n,t,e){var o="bluebird";t[t.__symbol__(o)]=function(o){var r=["then","spread","finally"];r.forEach(function(n){e.patchMethod(o.prototype,n,function(n){return function(e,r){for(var i=t.current,c=function(n){var t=r[n];"function"==typeof t&&(r[n]=function(){var n=this,e=arguments;return new o(function(o,r){i.scheduleMicroTask("Promise.then",function(){try{o(t.apply(n,e))}catch(i){r(i)}})})})},u=0;u'; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); + } + Zone.assertZonePatched = function () { + if (global['Promise'] !== patches['ZoneAwarePromise']) { + throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + + 'has been overwritten.\n' + + 'Most likely cause is that a Promise polyfill has been loaded ' + + 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + + 'If you must load one, do so before loading zone.js.)'); + } + }; + Object.defineProperty(Zone, "root", { + get: function () { + var zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "current", { + get: function () { + return _currentZoneFrame.zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "currentTask", { + get: function () { + return _currentTask; + }, + enumerable: true, + configurable: true + }); + Zone.__load_patch = function (name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } + } + else if (!global['__Zone_disable_' + name]) { + var perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); + } + }; + Object.defineProperty(Zone.prototype, "parent", { + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Zone.prototype.get = function (key) { + var zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + }; + Zone.prototype.getZoneWith = function (key) { + var current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + }; + Zone.prototype.fork = function (zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + }; + Zone.prototype.wrap = function (callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + var _callback = this._zoneDelegate.intercept(this, callback, source); + var zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + }; + Zone.prototype.run = function (callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { + if (applyThis === void 0) { applyThis = null; } + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runTask = function (task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; + } + var reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + var previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + }; + Zone.prototype.scheduleTask = function (task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + var newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + var zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + }; + Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + }; + Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.cancelTask = function (task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + }; + Zone.prototype._updateTaskCount = function (task, count) { + var zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (var i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + }; + Zone.__symbol__ = __symbol__; + return Zone; + }()); + var DELEGATE_ZS = { + name: '', + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, + onScheduleTask: function (delegate, _, target, task) { + return delegate.scheduleTask(target, task); + }, + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { + return delegate.invokeTask(target, task, applyThis, applyArgs); + }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } + }; + var ZoneDelegate = /** @class */ (function () { + function ZoneDelegate(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; + } + } + } + ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + }; + ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + }; + ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.handleError = function (targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + }; + ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { + var returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); + } + else { + throw new Error('Task is missing scheduleFn.'); + } + } + return returnTask; + }; + ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.cancelTask = function (targetZone, task) { + var value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + } + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); + } + return value; + }; + ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + }; + ZoneDelegate.prototype._updateTaskCount = function (type, count) { + var counts = this._taskCounts; + var prev = counts[type]; + var next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + var isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + }; + return ZoneDelegate; + }()); + var ZoneTask = /** @class */ (function () { + function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + var self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; + } + } + ZoneTask.invokeTask = function (task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + }; + Object.defineProperty(ZoneTask.prototype, "zone", { + get: function () { + return this._zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ZoneTask.prototype, "state", { + get: function () { + return this._state; + }, + enumerable: true, + configurable: true + }); + ZoneTask.prototype.cancelScheduleRequest = function () { + this._transitionTo(notScheduled, scheduling); + }; + ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); + } + }; + ZoneTask.prototype.toString = function () { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + }; + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + ZoneTask.prototype.toJSON = function () { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + }; + return ZoneTask; + }()); + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var symbolSetTimeout = __symbol__('setTimeout'); + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var _microTaskQueue = []; + var _isDrainingMicrotaskQueue = false; + var nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } + } + task && _microTaskQueue.push(task); + } + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + var queue = _microTaskQueue; + _microTaskQueue = []; + for (var i = 0; i < queue.length; i++) { + var task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var NO_ZONE = { name: 'NO ZONE' }; + var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + var patches = {}; + var _api = { + symbol: __symbol__, + currentZoneFrame: function () { return _currentZoneFrame; }, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, + patchEventTarget: function () { return []; }, + patchOnProperties: noop, + patchMethod: function () { return noop; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, + setNativePromise: function (NativePromise) { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); + } + }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } + }; + var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + var _currentTask = null; + var _numberOfNestedTaskFrames = 0; + function noop() { } + function __symbol__(name) { + return '__zone_symbol__' + name; + } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); + +var __values = (undefined && undefined.__values) || function (o) { + var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; + if (m) return m.call(o); + return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; +}; +/** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + var className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + var __symbol__ = api.symbol; + var _uncaughtPromiseErrors = []; + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var creationTrace = '__creationTrace__'; + api.onUnhandledError = function (e) { + if (api.showUncaughtError()) { + var rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); + } + } + }; + api.microtaskDrainDone = function () { + while (_uncaughtPromiseErrors.length) { + var _loop_1 = function () { + var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(function () { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + }; + while (_uncaughtPromiseErrors.length) { + _loop_1(); + } + } + }; + var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); + try { + var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } + } + catch (err) { + } + } + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + var symbolState = __symbol__('state'); + var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); + var source = 'Promise.then'; + var UNRESOLVED = null; + var RESOLVED = true; + var REJECTED = false; + var REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return function (v) { + try { + resolvePromise(promise, state, v); + } + catch (err) { + resolvePromise(promise, false, err); + } + // Do not return value or you will break the Promise spec. + }; + } + var once = function () { + var wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; + }; + }; + var TYPE_ERROR = 'Promise resolved with itself'; + var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + var onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + var then = null; + try { + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } + } + catch (err) { + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + return promise; + } + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { + try { + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + } + catch (err) { + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + var queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + var trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (var i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + var error_1 = err; + error_1.rejection = value; + error_1.promise = promise; + error_1.zone = Zone.current; + error_1.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error_1); + api.scheduleMicroTask(); // to make sure that it is running + } + } + } + } + // Resolving an already resolved promise is a noop. + return promise; + } + var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + var handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } + } + catch (err) { + } + promise[symbolState] = REJECTED; + for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } + } + } + } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + var promiseState = promise[symbolState]; + var delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, function () { + try { + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); + } + var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + var ZoneAwarePromise = /** @class */ (function () { + function ZoneAwarePromise(executor) { + var promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } + } + ZoneAwarePromise.toString = function () { + return ZONE_AWARE_PROMISE_TO_STRING; + }; + ZoneAwarePromise.resolve = function (value) { + return resolvePromise(new this(null), RESOLVED, value); + }; + ZoneAwarePromise.reject = function (error) { + return resolvePromise(new this(null), REJECTED, error); + }; + ZoneAwarePromise.race = function (values) { + var e_1, _a; + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + try { + for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { + var value = values_1_1.value; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + } + finally { if (e_1) throw e_1.error; } + } + return promise; + }; + ZoneAwarePromise.all = function (values) { + var e_2, _a; + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; + var resolvedValues = []; + var _loop_2 = function (value) { + if (!isThenable(value)) { + value = this_1.resolve(value); + } + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + try { + for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { + var value = values_2_1.value; + _loop_2(value); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + finally { if (e_2) throw e_2.error; } + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true + }); + ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { + var chainPromise = new this.constructor(null); + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; + }; + ZoneAwarePromise.prototype.catch = function (onRejected) { + return this.then(null, onRejected); + }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + }; + return ZoneAwarePromise; + }()); + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + var NativePromise = global[symbolPromise] = global['Promise']; + var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + var symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } + var originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + var _this = this; + var wrapped = new ZoneAwarePromise(function (resolve, reject) { + originalThen.call(_this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; + } + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); + } + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; +}); + +/** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ +// issue #989, to reduce bundle size, use short name +/** Object.getOwnPropertyDescriptor */ +var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ +var ObjectDefineProperty = Object.defineProperty; +/** Object.getPrototypeOf */ +var ObjectGetPrototypeOf = Object.getPrototypeOf; +/** Object.create */ +var ObjectCreate = Object.create; +/** Array.prototype.slice */ +var ArraySlice = Array.prototype.slice; +/** addEventListener string const */ +var ADD_EVENT_LISTENER_STR = 'addEventListener'; +/** removeEventListener string const */ +var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; +/** zoneSymbol addEventListener */ +var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); +/** zoneSymbol removeEventListener */ +var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); +/** true string const */ +var TRUE_STR = 'true'; +/** false string const */ +var FALSE_STR = 'false'; +/** __zone_symbol__ string const */ +var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); +} +function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} +var zoneSymbol = Zone.__symbol__; +var isWindowExists = typeof window !== 'undefined'; +var internalWindow = isWindowExists ? window : undefined; +var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; +var REMOVE_ATTRIBUTE = 'removeAttribute'; +var NULL_ON_PROP_VALUE = [null]; +function bindArguments(args, source) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; +} +function patchPrototype(prototype, fnNames) { + var source = prototype.constructor['name']; + var _loop_1 = function (i) { + var name_1 = fnNames[i]; + var delegate = prototype[name_1]; + if (delegate) { + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); + if (!isPropertyWritable(prototypeDesc)) { + return "continue"; + } + prototype[name_1] = (function (delegate) { + var patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); + } + }; + for (var i = 0; i < fnNames.length; i++) { + _loop_1(i); + } +} +function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; + } + if (propertyDesc.writable === false) { + return false; + } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); +} +var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify +// this code. +var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); +var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); +// we are in electron of nw, so we are both browser and nodejs +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify +// this code. +var isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); +var zoneSymbolEventNames = {}; +var wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + var eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + } + var target = this || event.target || _global; + var listener = target[eventNameSymbol]; + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } + } + return result; +}; +function patchProperty(obj, prop, prototype) { + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; + } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + var originalDescGet = desc.get; + var originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; + } + var previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); + } + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); + } + else { + target[eventNameSymbol] = null; + } + }; + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + var listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + var value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; + } + } + return null; + }; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; +} +function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (var i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } + } + else { + var onProperties = []; + for (var prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); + } + } + for (var j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); + } + } +} +var originalInstanceKey = zoneSymbol('originalInstance'); +// wrap some native API on `window` +function patchClass(className) { + var OriginalClass = _global[className]; + if (!OriginalClass) + return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + var a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); + } + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + var instance = new OriginalClass(function () { }); + var prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; + } + }); + } + }(prop)); + } + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; + } + } +} +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +var shouldCopySymbolProperties = false; + +function patchMethod(target, name, patchFn) { + var proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + var delegateName = zoneSymbol(name); + var delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + var patchDelegate_1 = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate_1(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } + } + } + return delegate; +} +// TODO: @JiaLiPassion, support cancel task later if necessary +function patchMacroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; + } + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }; }); +} + +function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; +} +var isDetectedIEOrEdge = false; +var ieOrEdge = false; +function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; +} +function isIEOrEdge() { + if (isDetectedIEOrEdge) { + return ieOrEdge; + } + isDetectedIEOrEdge = true; + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { + ieOrEdge = true; + } + } + catch (error) { + } + return ieOrEdge; +} + +/** + * @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 + */ +// override Function.prototype.toString to make zone.js patched function +// look like native function +Zone.__load_patch('toString', function (global) { + // patch Func.prototype.toString to let them look like native + var originalFunctionToString = Function.prototype.toString; + var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + var PROMISE_SYMBOL = zoneSymbol('Promise'); + var ERROR_SYMBOL = zoneSymbol('Error'); + var newFunctionToString = function toString() { + if (typeof this === 'function') { + var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } + } + if (this === Promise) { + var nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } + } + if (this === Error) { + var nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } + } + } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + var originalObjectToString = Object.prototype.toString; + var PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; +}); + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +var passiveSupported = false; +if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} +// an identifier to tell ZoneTask do not create a new invoke closure +var OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true +}; +var zoneSymbolEventNames$1 = {}; +var globalSources = {}; +var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; +var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); +function patchEventTarget(_global, apis, patchOptions) { + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + var PREPEND_EVENT_LISTENER = 'prependListener'; + var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + var invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; + } + var delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = function (event) { return delegate.handleEvent(event); }; + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + var options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + var globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + var globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + var useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + var validateHandler = patchOptions && patchOptions.vh; + var checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + var returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + var proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + var eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + var taskData = {}; + var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + var nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + var customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + var symbolEventName = void 0; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } + } + } + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { + return; + } + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + var customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + var compareTaskCallbackVsDelegate = function (task, delegate) { + var typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; + var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { + if (returnTarget === void 0) { returnTarget = false; } + if (prepend === void 0) { prepend = false; } + return function () { + var target = this || _global; + var eventName = arguments[0]; + var delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + var isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { + return nativeListener.apply(this, arguments); + } + isHandleEvent = true; + } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + var options = arguments[2]; + if (blackListedEvents) { + // check black list + for (var i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + var capture; + var once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + var zone = Zone.current; + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = target[symbolEventName]; + var isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (var i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + var source; + var constructorName = target.constructor['name']; + var targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var options = arguments[2]; + var capture; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + } + var delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; + } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; + } + } + } + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var listeners = []; + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (var i = 0; i < tasks.length; i++) { + var task = tasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); + } + return listeners; + }; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + if (!eventName) { + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); + } + } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); + } + else { + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + var symbolEventName = symbolEventNames[FALSE_STR]; + var symbolCaptureEventName = symbolEventNames[TRUE_STR]; + var tasks = target[symbolEventName]; + var captureTasks = target[symbolCaptureEventName]; + if (tasks) { + var removeTasks = tasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + if (captureTasks) { + var removeTasks = captureTasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + } + } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + } + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + } + return true; + } + var results = []; + for (var i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; +} +function findEventTasks(target, eventName) { + var foundTasks = []; + for (var prop in target) { + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + var tasks = target[prop]; + if (tasks) { + for (var i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } + } + } + } + return foundTasks; +} +function patchEventPrototype(global, api) { + var Event = global['Event']; + if (Event && Event.prototype) { + api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) { return function (self, args) { + self[IMMEDIATE_PROPAGATION_SYMBOL] = true; + // we need to call the native stopImmediatePropagation + // in case in some hybrid application, some part of + // application will be controlled by zone, some are not + delegate && delegate.apply(self, 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 + */ +function patchCallbacks(api, target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + var source = targetName + "." + method + "::" + callback; + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); +} + +/** + * @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 + */ +/* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ +var zoneSymbol$1 = Zone.__symbol__; +var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; +var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; +var _create = Object.create; +var unconfigurablesKey = zoneSymbol$1('unconfigurables'); +function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + var originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); + } + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + var desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; + } + return desc; + }; +} +function _redefineProperty(obj, prop, desc) { + var originalConfigurableFlag = desc.configurable; + desc = rewriteDescriptor(obj, prop, desc); + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); +} +function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; +} +function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; + } + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; + } + } + return desc; +} +function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; + } + else { + desc.configurable = originalConfigurableFlag; + } + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + var descJson = null; + try { + descJson = JSON.stringify(desc); + } + catch (error) { + descJson = desc.toString(); + } + console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); + } + } + else { + throw error; + } + } +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ +var globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' +]; +var documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' +]; +var windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' +]; +var htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' +]; +var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; +var ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' +]; +var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; +var formEventNames = ['autocomplete', 'autocompleteerror']; +var detailEventNames = ['toggle']; +var frameEventNames = ['load']; +var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; +var marqueeEventNames = ['bounce', 'finish', 'start']; +var XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' +]; +var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; +var websocketEventNames = ['close', 'error', 'open', 'message']; +var workerEventNames = ['error', 'message']; +var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); +function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); + if (!tip || tip.length === 0) { + return onProperties; + } + var targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); +} +function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + var filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); +} +function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; + } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } + var supportsWebSocket = typeof WebSocket !== 'undefined'; + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + } + } + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + } +} + +/** + * @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.__load_patch('util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = function () { return ({ + globalSources: globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames: eventNames, + isBrowser: isBrowser, + isMix: isMix, + isNode: isNode, + TRUE_STR: TRUE_STR, + FALSE_STR: FALSE_STR, + ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR + }); }; +}); + +/** + * @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 + */ + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +var taskSymbol = zoneSymbol('zoneTask'); +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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } + } + } + data.args[0] = timer; + 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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return 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 id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // 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 + */ +function patchCustomElements(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); +} + +/** + * @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 eventTargetPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; +} +function patchEvent(global, api) { + api.patchEventPrototype(global, api); +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +Zone.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } +}); +Zone.__load_patch('timers', function (global) { + var set = 'set'; + var clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); +}); +Zone.__load_patch('requestAnimationFrame', function (global) { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); +}); +Zone.__load_patch('blocking', function (global, Zone) { + var blockingMethods = ['alert', 'prompt', 'confirm']; + for (var i = 0; i < blockingMethods.length; i++) { + var name_1 = blockingMethods[i]; + patchMethod(global, name_1, function (delegate, symbol, name) { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); + } +}); +Zone.__load_patch('EventTarget', function (global, Zone, api) { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); +}); +Zone.__load_patch('on_property', function (global, Zone, api) { + propertyDescriptorPatch(api, global); + propertyPatch(); +}); +Zone.__load_patch('customElements', function (global, Zone, api) { + patchCustomElements(global, api); +}); +Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + var XHR_TASK = zoneSymbol('xhrTask'); + var XHR_SYNC = zoneSymbol('xhrSync'); + var XHR_LISTENER = zoneSymbol('xhrListener'); + var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; + } + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + var READY_STATE_CHANGE = 'readystatechange'; + var SCHEDULED = 'scheduled'; + function scheduleTask(task) { + var data = task.data; + var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + var listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + var newListener = target[XHR_LISTENER] = function () { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target['__zone_symbol__loadfalse']; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target['__zone_symbol__loadfalse']; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; + } + } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + var storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; + } + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; + } + function placeholderCallback() { } + function clearTask(task) { + var data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }; }); + var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + if (self[XHR_SYNC]) { + // if the XHR is sync there is no task to schedule, just execute the code. + return sendNative.apply(self, args); + } + else { + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } + } + }; }); + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { + var task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); + } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }; }); + } +}); +Zone.__load_patch('geolocation', function (global) { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); + } +}); +Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(function (eventTask) { + // windows has added unhandledrejection event listener + // trigger the event listener + var PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; + } + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); + } +}); + +/** + * @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 + */ + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ +var __assign = (undefined && undefined.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var NEWLINE = '\n'; +var IGNORE_FRAMES = {}; +var creationTrace = '__creationTrace__'; +var ERROR_TAG = 'STACKTRACE TRACKING'; +var SEP_TAG = '__SEP_TAG__'; +var sepTemplate = SEP_TAG + '@[native]'; +var LongStackTrace = /** @class */ (function () { + function LongStackTrace() { + this.error = getStacktrace(); + this.timestamp = new Date(); + } + return LongStackTrace; +}()); +function getStacktraceWithUncaughtError() { + return new Error(ERROR_TAG); +} +function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); + } + catch (err) { + return err; + } +} +// Some implementations of exception handling don't create a stack trace if the exception +// isn't thrown, however it's faster not to actually throw the exception. +var error = getStacktraceWithUncaughtError(); +var caughtError = getStacktraceWithCaughtError(); +var getStacktrace = error.stack ? + getStacktraceWithUncaughtError : + (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); +function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; +} +function addErrorStack(lines, error) { + var trace = getFrames(error); + for (var i = 0; i < trace.length; i++) { + var frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!IGNORE_FRAMES.hasOwnProperty(frame)) { + lines.push(trace[i]); + } + } +} +function renderLongStackTrace(frames, stack) { + var longTrace = [stack ? stack.trim() : '']; + if (frames) { + var timestamp = new Date().getTime(); + for (var i = 0; i < frames.length; i++) { + var traceFrames = frames[i]; + var lastTime = traceFrames.timestamp; + var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; + separator = separator.replace(/[^\w\d]/g, '_'); + longTrace.push(sepTemplate.replace(SEP_TAG, separator)); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); + } + } + return longTrace.join(NEWLINE); +} +Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + // add a getLongStackTrace method in spec to + // handle handled reject promise error. + getLongStackTrace: function (error) { + if (!error) { + return undefined; + } + var trace = error[Zone.__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; + } + return renderLongStackTrace(trace, error.stack); + }, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var currentTask = Zone.currentTask; + var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; + } + if (!task.data) + task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = __assign({}, task.data); + } + task.data[creationTrace] = trace; + } + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + try { + error.stack = error.longStack = longStack; + } + catch (err) { + } + } + } + return parentZoneDelegate.handleError(targetZone, error); + } +}; +function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); + } +} +function computeIgnoreFrames() { + if (Error.stackTraceLimit <= 0) { + return; + } + var frames = []; + captureStackTraces(frames, 2); + var frames1 = frames[0]; + var frames2 = frames[1]; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + if (frame1.indexOf(ERROR_TAG) == -1) { + var match = frame1.match(/^\s*at\s+/); + if (match) { + sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + break; + } + } + } + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + var frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES[frame1] = true; + } + else { + break; + } + } +} +computeIgnoreFrames(); + +/** + * @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 = /** @class */ (function () { + function ProxyZoneSpec(defaultSpecDelegate) { + if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } + this.defaultSpecDelegate = defaultSpecDelegate; + this.name = 'ProxyZone'; + this._delegateSpec = null; + this.properties = { 'ProxyZoneSpec': this }; + this.propertyKeys = null; + this.lastTaskState = null; + this.isNeedToTriggerHasTask = false; + this.tasks = []; + this.setDelegate(defaultSpecDelegate); + } + ProxyZoneSpec.get = function () { + return Zone.current.get('ProxyZoneSpec'); + }; + ProxyZoneSpec.isLoaded = function () { + return ProxyZoneSpec.get() instanceof ProxyZoneSpec; + }; + ProxyZoneSpec.assertPresent = function () { + if (!ProxyZoneSpec.isLoaded()) { + throw new Error("Expected to be running in 'ProxyZone', but it was not found."); + } + return ProxyZoneSpec.get(); + }; + ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { + var _this = this; + var isNewDelegate = this._delegateSpec !== delegateSpec; + this._delegateSpec = delegateSpec; + this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); + this.propertyKeys = null; + if (delegateSpec && delegateSpec.properties) { + this.propertyKeys = Object.keys(delegateSpec.properties); + this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); + } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } + }; + ProxyZoneSpec.prototype.getDelegate = function () { + return this._delegateSpec; + }; + ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); + this.setDelegate(this.defaultSpecDelegate); + }; + ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + }; + ProxyZoneSpec.prototype.removeFromTasks = function (task) { + if (!this.tasks) { + return; + } + for (var i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; + } + } + }; + ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { + if (this.tasks.length === 0) { + return ''; + } + var taskInfo = this.tasks.map(function (task) { + var dataInfo = task.data && + Object.keys(task.data) + .map(function (key) { + return key + ':' + task.data[key]; + }) + .join(','); + return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; + }); + var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; + }; + ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); + } + else { + return parentZoneDelegate.fork(targetZone, zoneSpec); + } + }; + ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { + if (this._delegateSpec && this._delegateSpec.onIntercept) { + return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); + } + else { + return parentZoneDelegate.intercept(targetZone, delegate, source); + } + }; + ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvoke) { + return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); + } + else { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + }; + ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + if (this._delegateSpec && this._delegateSpec.onHandleError) { + return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); + } + else { + return parentZoneDelegate.handleError(targetZone, error); + } + }; + ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } + if (this._delegateSpec && this._delegateSpec.onScheduleTask) { + return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.scheduleTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { + return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); + } + else { + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } + }; + ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onCancelTask) { + return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.cancelTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; + if (this._delegateSpec && this._delegateSpec.onHasTask) { + this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); + } + else { + delegate.hasTask(target, hasTaskState); + } + }; + return ProxyZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['ProxyZoneSpec'] = ProxyZoneSpec; + +/** + * @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 = /** @class */ (function () { + function SyncTestZoneSpec(namePrefix) { + this.runZone = Zone.current; + this.name = 'syncTestZone for ' + namePrefix; + } + SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + case 'macroTask': + throw new Error("Cannot call " + task.source + " from within a sync test."); + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + return SyncTestZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; + +/** + * @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 __()); + }; + var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; + // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs + // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) + if (!Zone) + throw new Error('Missing: zone.js'); + if (typeof jasmine == 'undefined') + throw new Error('Missing: jasmine.js'); + if (jasmine['__zone_patch__']) + throw new Error("'jasmine' has already been patched with 'Zone'."); + jasmine['__zone_patch__'] = true; + var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (!SyncTestZoneSpec) + throw new Error('Missing: SyncTestZoneSpec'); + if (!ProxyZoneSpec) + throw new Error('Missing: ProxyZoneSpec'); + var ambientZone = Zone.current; + // Create a synchronous-only zone in which to run `describe` blocks in order to raise an + // error if any asynchronous operations are attempted inside of a `describe` but outside of + // a `beforeEach` or `it`. + var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. + var jasmineEnv = jasmine.getEnv(); + ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[methodName] = function (description, specDefinitions) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + }; + }); + ['it', 'xit', 'fit'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableClockPatch) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; + /** + * Gets a function wrapping the body of a Jasmine `describe` block to execute in a + * synchronous-only zone. + */ + function wrapDescribeInZone(describeBody) { + return function () { + return syncZone.run(describeBody, this, arguments); + }; + } + function runInTestZone(testBody, applyThis, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + if (isClockInstalled && enableClockPatch) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); + } + } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); + } + else { + return testProxyZone.run(testBody, applyThis); + } + } + /** + * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to + * execute in a ProxyZone zone. + * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` + */ + function wrapTestInZone(testBody) { + // The `done` callback is only passed through if the function expects at least one argument. + // Note we have to make a function with correct number of arguments, otherwise jasmine will + // think that all functions are sync or async. + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this, this.queueRunner, done); + } : function () { + return runInTestZone(testBody, this, this.queueRunner); + })); + } + var QueueRunner = jasmine.QueueRunner; + jasmine.QueueRunner = (function (_super) { + __extends(ZoneQueueRunner, _super); + function ZoneQueueRunner(attrs) { + var _this = this; + attrs.onComplete = (function (fn) { return function () { + // All functions are done, clear the test zone. + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + }; })(attrs.onComplete); + var nativeSetTimeout = _global['__zone_symbol__setTimeout']; + var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } + } + } + if (onException) { + onException.call(this, error); + } + }; + _super.call(this, attrs); + } + ZoneQueueRunner.prototype.execute = function () { + var _this = this; + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); + if (!Zone.currentTask) { + // if we are not running in a task then if someone would register a + // element.addEventListener and then calling element.click() the + // addEventListener callback would think that it is the top most task and would + // drain the microtask queue on element.click() which would be incorrect. + // For this reason we always force a task when running jasmine tests. + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); + } + else { + _super.prototype.execute.call(this); + } + }; + return ZoneQueueRunner; + })(QueueRunner); +})(); + +/** + * @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 _global$1 = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; +var AsyncTestZoneSpec = /** @class */ (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this._isSync = false; + this.runZone = Zone.current; + this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; + this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global$1[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; + } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { + _this.finishCallback(); + } + }, 0); + }); + } + }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; + } + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + this._isSync = true; + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } + } + }; + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this.failCallback(error); + this._alreadyErrored = true; + } + return false; + }; + AsyncTestZoneSpec.prototype.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(); + } + }; + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + return AsyncTestZoneSpec; +}()); +// Export the class so that new instances can be created with proper +// constructor params. +Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + +/** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } +}); + +/** + * @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 __read = (undefined && undefined.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (undefined && undefined.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +(function (global) { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); + } + } + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + return FakeDate; + }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; + var Scheduler = /** @class */ (function () { + function Scheduler() { + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = OriginalDate.now(); + } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; + Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { + if (args === void 0) { args = []; } + if (isPeriodic === void 0) { isPeriodic = false; } + if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } + if (id === void 0) { id = -1; } + var currentId = id < 0 ? Scheduler.nextId++ : id; + var endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + var newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + var i = 0; + for (; i < this._schedulerQueue.length; i++) { + var currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } + } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + }; + Scheduler.prototype.removeScheduledFunctionWithId = function (id) { + for (var i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; + } + } + }; + Scheduler.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + var finalTime = this._currentTime + millis; + var lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + var current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; + } + else { + // Time to run scheduled function. Remove it from the head of queue. + var current_1 = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current_1.endTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + var retval = current_1.func.apply(global, current_1.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + } + lastCurrentTime = this._currentTime; + this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + }; + Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { + if (limit === void 0) { limit = 20; } + if (flushPeriodic === void 0) { flushPeriodic = false; } + if (flushPeriodic) { + return this.flushPeriodic(doTick); + } + else { + return this.flushNonPeriodic(limit, doTick); + } + }; + Scheduler.prototype.flushPeriodic = function (doTick) { + if (this._schedulerQueue.length === 0) { + return 0; + } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + var startTime = this._currentTime; + var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + }; + Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { + var startTime = this._currentTime; + var lastCurrentTime = 0; + var count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error('flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) + .length === 0) { + break; + } + var current = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current.endTime; + if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. + doTick(this._currentTime - lastCurrentTime); + } + var retval = current.func.apply(global, current.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + return this._currentTime - startTime; + }; + // Next scheduler id. + Scheduler.nextId = 1; + return Scheduler; + }()); + var FakeAsyncTestZoneSpec = /** @class */ (function () { + function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { + if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } + this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; + this.macroTaskOptions = macroTaskOptions; + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.patchDateLocked = false; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + } + } + FakeAsyncTestZoneSpec.assertInZone = function () { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + }; + FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { + var _this = this; + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + fn.apply(global, args); + if (_this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + _this.flushMicrotasks(); + } + else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } + } + // Return true if there were no errors, false otherwise. + return _this._lastError === null; + }; + }; + FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { + var index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); + } + }; + FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { + var _this = this; + return function () { + // Requeue the timer callback if it's not been canceled. + if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { + _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + } + }; + }; + FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { + if (isTimer === void 0) { isTimer = true; } + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); + } + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { + var id = Scheduler.nextId; + var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + var cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { + var error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); + }; + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + }; + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; + FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + }; + FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { + var _this = this; + FakeAsyncTestZoneSpec.assertInZone(); + var flushErrors = function () { + if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + _this._resetLastErrorAndThrow(); + } + }; + while (this._microtasks.length > 0) { + var microtask = this._microtasks.shift(); + microtask.func.apply(microtask.target, microtask.args); + } + flushErrors(); + }; + FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + }; + FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + var args = task.data && task.data.args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + var additionalArgs = void 0; + if (args) { + var callbackIndex = task.data.cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + } + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && task.data.target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; + case 'setInterval': + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + + task.data['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var args_1 = task.data && task.data['args']; + var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; + var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data.isPeriodic = true; + } + else { + // not periodic, use setTimeout to simulate + task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + } + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var handleId = task.data['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); + } + }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } + } + }; + FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { + if (!this.macroTaskOptions) { + return null; + } + for (var i = 0; i < this.macroTaskOptions.length; i++) { + var macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; + } + } + return null; + }; + FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + }; + return FakeAsyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; +})(typeof window === 'object' && window || typeof self === 'object' && self || global); + +/** + * @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.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; +}); + +/** + * @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 + */ +/** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ +Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; +}); + +/** + * @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 + */ +// load test related files into bundle in correct order + +/** + * @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 + */ +// load test related files into bundle + +}))); diff --git a/dist/zone-evergreen.js b/dist/zone-evergreen.js new file mode 100644 index 000000000..6666bf1cb --- /dev/null +++ b/dist/zone-evergreen.js @@ -0,0 +1,3040 @@ +/** +* @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 +*/ +/** + * @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 Zone$1 = (function (global) { + const performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + const checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } + } + class Zone { + constructor(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); + } + static assertZonePatched() { + if (global['Promise'] !== patches['ZoneAwarePromise']) { + throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + + 'has been overwritten.\n' + + 'Most likely cause is that a Promise polyfill has been loaded ' + + 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + + 'If you must load one, do so before loading zone.js.)'); + } + } + static get root() { + let zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + } + static get current() { + return _currentZoneFrame.zone; + } + static get currentTask() { + return _currentTask; + } + static __load_patch(name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } + } + else if (!global['__Zone_disable_' + name]) { + const perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); + } + } + get parent() { + return this._parent; + } + get name() { + return this._name; + } + get(key) { + const zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + } + getZoneWith(key) { + let current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + } + fork(zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + } + wrap(callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + const _callback = this._zoneDelegate.intercept(this, callback, source); + const zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + } + run(callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + } + runGuarded(callback, applyThis = null, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + } + runTask(task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; + } + const reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + const previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + } + scheduleTask(task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + let newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${task.zone.name}`); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + const zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + } + scheduleMicroTask(source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + } + scheduleMacroTask(source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + } + scheduleEventTask(source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + } + cancelTask(task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + } + _updateTaskCount(task, count) { + const zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (let i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + } + } + Zone.__symbol__ = __symbol__; + const DELEGATE_ZS = { + name: '', + onHasTask: (delegate, _, target, hasTaskState) => delegate.hasTask(target, hasTaskState), + onScheduleTask: (delegate, _, target, task) => delegate.scheduleTask(target, task), + onInvokeTask: (delegate, _, target, task, applyThis, applyArgs) => delegate.invokeTask(target, task, applyThis, applyArgs), + onCancelTask: (delegate, _, target, task) => delegate.cancelTask(target, task) + }; + class ZoneDelegate { + constructor(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + const zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + const parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; + } + } + } + fork(targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + } + intercept(targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + } + invoke(targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + } + handleError(targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + } + scheduleTask(targetZone, task) { + let returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); + } + else { + throw new Error('Task is missing scheduleFn.'); + } + } + return returnTask; + } + invokeTask(targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + } + cancelTask(targetZone, task) { + let value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + } + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); + } + return value; + } + hasTask(targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + } + _updateTaskCount(type, count) { + const counts = this._taskCounts; + const prev = counts[type]; + const next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + const isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + } + } + class ZoneTask { + constructor(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + const self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; + } + } + static invokeTask(task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + } + get zone() { + return this._zone; + } + get state() { + return this._state; + } + cancelScheduleRequest() { + this._transitionTo(notScheduled, scheduling); + } + _transitionTo(toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(`${this.type} '${this.source}': can not transition to '${toState}', expecting state '${fromState1}'${fromState2 ? ' or \'' + fromState2 + '\'' : ''}, was '${this._state}'.`); + } + } + toString() { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + } + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + toJSON() { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + const symbolSetTimeout = __symbol__('setTimeout'); + const symbolPromise = __symbol__('Promise'); + const symbolThen = __symbol__('then'); + let _microTaskQueue = []; + let _isDrainingMicrotaskQueue = false; + let nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + let nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } + } + task && _microTaskQueue.push(task); + } + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + const queue = _microTaskQueue; + _microTaskQueue = []; + for (let i = 0; i < queue.length; i++) { + const task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + const NO_ZONE = { name: 'NO ZONE' }; + const notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + const microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + const patches = {}; + const _api = { + symbol: __symbol__, + currentZoneFrame: () => _currentZoneFrame, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: () => !Zone[__symbol__('ignoreConsoleErrorUncaughtError')], + patchEventTarget: () => [], + patchOnProperties: noop, + patchMethod: () => noop, + bindArguments: () => [], + patchThen: () => noop, + patchMacroTask: () => noop, + setNativePromise: (NativePromise) => { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); + } + }, + patchEventPrototype: () => noop, + isIEOrEdge: () => false, + getGlobalObjects: () => undefined, + ObjectDefineProperty: () => noop, + ObjectGetOwnPropertyDescriptor: () => undefined, + ObjectCreate: () => undefined, + ArraySlice: () => [], + patchClass: () => noop, + wrapWithCurrentZone: () => noop, + filterProperties: () => [], + attachOriginToPatched: () => noop, + _redefineProperty: () => noop, + patchCallbacks: () => noop + }; + let _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + let _currentTask = null; + let _numberOfNestedTaskFrames = 0; + function noop() { } + function __symbol__(name) { + return '__zone_symbol__' + name; + } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); + +/** + * @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.__load_patch('ZoneAwarePromise', (global, Zone, api) => { + const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + const ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + const className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + const __symbol__ = api.symbol; + const _uncaughtPromiseErrors = []; + const symbolPromise = __symbol__('Promise'); + const symbolThen = __symbol__('then'); + const creationTrace = '__creationTrace__'; + api.onUnhandledError = (e) => { + if (api.showUncaughtError()) { + const rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); + } + } + }; + api.microtaskDrainDone = () => { + while (_uncaughtPromiseErrors.length) { + while (_uncaughtPromiseErrors.length) { + const uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(() => { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + } + } + }; + const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); + try { + const handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } + } + catch (err) { + } + } + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + const symbolState = __symbol__('state'); + const symbolValue = __symbol__('value'); + const symbolFinally = __symbol__('finally'); + const symbolParentPromiseValue = __symbol__('parentPromiseValue'); + const symbolParentPromiseState = __symbol__('parentPromiseState'); + const source = 'Promise.then'; + const UNRESOLVED = null; + const RESOLVED = true; + const REJECTED = false; + const REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return (v) => { + try { + resolvePromise(promise, state, v); + } + catch (err) { + resolvePromise(promise, false, err); + } + // Do not return value or you will break the Promise spec. + }; + } + const once = function () { + let wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; + }; + }; + const TYPE_ERROR = 'Promise resolved with itself'; + const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + const onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + let then = null; + try { + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } + } + catch (err) { + onceWrapper(() => { + resolvePromise(promise, false, err); + })(); + return promise; + } + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { + try { + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + } + catch (err) { + onceWrapper(() => { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + const queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + const trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (let i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + const error = err; + error.rejection = value; + error.promise = promise; + error.zone = Zone.current; + error.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error); + api.scheduleMicroTask(); // to make sure that it is running + } + } + } + } + // Resolving an already resolved promise is a noop. + return promise; + } + const REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + const handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } + } + catch (err) { + } + promise[symbolState] = REJECTED; + for (let i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } + } + } + } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + const promiseState = promise[symbolState]; + const delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, () => { + try { + const parentPromiseValue = promise[symbolValue]; + const isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); + } + const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + class ZoneAwarePromise { + constructor(executor) { + const promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } + } + static toString() { + return ZONE_AWARE_PROMISE_TO_STRING; + } + static resolve(value) { + return resolvePromise(new this(null), RESOLVED, value); + } + static reject(error) { + return resolvePromise(new this(null), REJECTED, error); + } + static race(values) { + let resolve; + let reject; + let promise = new this((res, rej) => { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (let value of values) { + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + return promise; + } + static all(values) { + let resolve; + let reject; + let promise = new this((res, rej) => { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + let unresolvedCount = 2; + let valueIndex = 0; + const resolvedValues = []; + for (let value of values) { + if (!isThenable(value)) { + value = this.resolve(value); + } + const curValueIndex = valueIndex; + value.then((value) => { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + } + get [Symbol.toStringTag]() { + return 'Promise'; + } + then(onFulfilled, onRejected) { + const chainPromise = new this.constructor(null); + const zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; + } + catch(onRejected) { + return this.then(null, onRejected); + } + finally(onFinally) { + const chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + const zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + } + } + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + const NativePromise = global[symbolPromise] = global['Promise']; + const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + const symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + const proto = Ctor.prototype; + const prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } + const originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + const wrapped = new ZoneAwarePromise((resolve, reject) => { + originalThen.call(this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; + } + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + let resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + let ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + const fetch = global['fetch']; + if (typeof fetch == 'function') { + global[api.symbol('fetch')] = fetch; + global['fetch'] = zoneify(fetch); + } + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; +}); + +/** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ +// issue #989, to reduce bundle size, use short name +/** Object.getOwnPropertyDescriptor */ +const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +/** Object.defineProperty */ +const ObjectDefineProperty = Object.defineProperty; +/** Object.getPrototypeOf */ +const ObjectGetPrototypeOf = Object.getPrototypeOf; +/** Object.create */ +const ObjectCreate = Object.create; +/** Array.prototype.slice */ +const ArraySlice = Array.prototype.slice; +/** addEventListener string const */ +const ADD_EVENT_LISTENER_STR = 'addEventListener'; +/** removeEventListener string const */ +const REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; +/** zoneSymbol addEventListener */ +const ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); +/** zoneSymbol removeEventListener */ +const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); +/** true string const */ +const TRUE_STR = 'true'; +/** false string const */ +const FALSE_STR = 'false'; +/** __zone_symbol__ string const */ +const ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); +} +function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); +} +const zoneSymbol = Zone.__symbol__; +const isWindowExists = typeof window !== 'undefined'; +const internalWindow = isWindowExists ? window : undefined; +const _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; +const REMOVE_ATTRIBUTE = 'removeAttribute'; +const NULL_ON_PROP_VALUE = [null]; +function bindArguments(args, source) { + for (let i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; +} +function patchPrototype(prototype, fnNames) { + const source = prototype.constructor['name']; + for (let i = 0; i < fnNames.length; i++) { + const name = fnNames[i]; + const delegate = prototype[name]; + if (delegate) { + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name); + if (!isPropertyWritable(prototypeDesc)) { + continue; + } + prototype[name] = ((delegate) => { + const patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); + } + } +} +function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; + } + if (propertyDesc.writable === false) { + return false; + } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); +} +const isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify +// this code. +const isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); +const isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); +// we are in electron of nw, so we are both browser and nodejs +// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify +// this code. +const isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); +const zoneSymbolEventNames = {}; +const wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + let eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + } + const target = this || event.target || _global; + const listener = target[eventNameSymbol]; + let result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + const errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } + } + return result; +}; +function patchProperty(obj, prop, prototype) { + let desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; + } + const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + const originalDescGet = desc.get; + const originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + const eventName = prop.substr(2); + let eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + let target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; + } + let previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); + } + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); + } + else { + target[eventNameSymbol] = null; + } + }; + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + let target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + const listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + let value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; + } + } + return null; + }; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; +} +function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (let i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } + } + else { + const onProperties = []; + for (const prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); + } + } + for (let j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); + } + } +} +const originalInstanceKey = zoneSymbol('originalInstance'); +// wrap some native API on `window` +function patchClass(className) { + const OriginalClass = _global[className]; + if (!OriginalClass) + return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + const a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); + } + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + const instance = new OriginalClass(function () { }); + let prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; + } + }); + } + }(prop)); + } + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; + } + } +} +function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + const symbols = Object.getOwnPropertySymbols(src); + symbols.forEach((symbol) => { + const desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); +} +let shouldCopySymbolProperties = false; + +function patchMethod(target, name, patchFn) { + let proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + const delegateName = zoneSymbol(name); + let delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + const patchDelegate = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } + } + } + return delegate; +} +// TODO: @JiaLiPassion, support cancel task later if necessary +function patchMacroTask(obj, funcName, metaCreator) { + let setNative = null; + function scheduleTask(task) { + const data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; + } + setNative = patchMethod(obj, funcName, (delegate) => function (self, args) { + const meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }); +} + +function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; +} +let isDetectedIEOrEdge = false; +let ieOrEdge = false; +function isIE() { + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; +} +function isIEOrEdge() { + if (isDetectedIEOrEdge) { + return ieOrEdge; + } + isDetectedIEOrEdge = true; + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { + ieOrEdge = true; + } + } + catch (error) { + } + return ieOrEdge; +} + +/** + * @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 + */ +// override Function.prototype.toString to make zone.js patched function +// look like native function +Zone.__load_patch('toString', (global) => { + // patch Func.prototype.toString to let them look like native + const originalFunctionToString = Function.prototype.toString; + const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + const PROMISE_SYMBOL = zoneSymbol('Promise'); + const ERROR_SYMBOL = zoneSymbol('Error'); + const newFunctionToString = function toString() { + if (typeof this === 'function') { + const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } + } + if (this === Promise) { + const nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } + } + if (this === Error) { + const nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } + } + } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + const originalObjectToString = Object.prototype.toString; + const PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; +}); + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +let passiveSupported = false; +if (typeof window !== 'undefined') { + try { + const options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } +} +// an identifier to tell ZoneTask do not create a new invoke closure +const OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true +}; +const zoneSymbolEventNames$1 = {}; +const globalSources = {}; +const EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; +const IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); +function patchEventTarget(_global, apis, patchOptions) { + const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + const LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + const REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + const PREPEND_EVENT_LISTENER = 'prependListener'; + const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + const invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; + } + const delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = (event) => delegate.handleEvent(event); + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + const options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + const delegate = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options); + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + const globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + const target = this || event.target || _global; + const tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + const copyTasks = tasks.slice(); + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + const globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + const target = this || event.target || _global; + const tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + const copyTasks = tasks.slice(); + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + let useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + const validateHandler = patchOptions && patchOptions.vh; + let checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + let returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + let proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + const eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + const taskData = {}; + const nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + const nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + const nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + const nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + let nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + const customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + const customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + const symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + let symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + const existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (let i = 0; i < existingTasks.length; i++) { + const existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } + } + } + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { + return; + } + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + const customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + const customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + const customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + const customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + const compareTaskCallbackVsDelegate = function (task, delegate) { + const typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + const compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + const blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; + const makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget = false, prepend = false) { + return function () { + const target = this || _global; + const eventName = arguments[0]; + let delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + let isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { + return nativeListener.apply(this, arguments); + } + isHandleEvent = true; + } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + const options = arguments[2]; + if (blackListedEvents) { + // check black list + for (let i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + let capture; + let once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + const zone = Zone.current; + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + let symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + const falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + const trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + let existingTasks = target[symbolEventName]; + let isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (let i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + let source; + const constructorName = target.constructor['name']; + const targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + const task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + const options = arguments[2]; + let capture; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + } + const delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + let symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + const existingTasks = symbolEventName && target[symbolEventName]; + if (existingTasks) { + for (let i = 0; i < existingTasks.length; i++) { + const existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; + } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; + } + } + } + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + const listeners = []; + const tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (let i = 0; i < tasks.length; i++) { + const task = tasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); + } + return listeners; + }; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + if (!eventName) { + const keys = Object.keys(target); + for (let i = 0; i < keys.length; i++) { + const prop = keys[i]; + const match = EVENT_NAME_SYMBOL_REGX.exec(prop); + let evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); + } + } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); + } + else { + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + const symbolEventName = symbolEventNames[FALSE_STR]; + const symbolCaptureEventName = symbolEventNames[TRUE_STR]; + const tasks = target[symbolEventName]; + const captureTasks = target[symbolCaptureEventName]; + if (tasks) { + const removeTasks = tasks.slice(); + for (let i = 0; i < removeTasks.length; i++) { + const task = removeTasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + if (captureTasks) { + const removeTasks = captureTasks.slice(); + for (let i = 0; i < removeTasks.length; i++) { + const task = removeTasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + } + } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + } + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + } + return true; + } + let results = []; + for (let i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; +} +function findEventTasks(target, eventName) { + const foundTasks = []; + for (let prop in target) { + const match = EVENT_NAME_SYMBOL_REGX.exec(prop); + let evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + const tasks = target[prop]; + if (tasks) { + for (let i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } + } + } + } + return foundTasks; +} +function patchEventPrototype(global, api) { + const Event = global['Event']; + if (Event && Event.prototype) { + api.patchMethod(Event.prototype, 'stopImmediatePropagation', (delegate) => function (self, args) { + self[IMMEDIATE_PROPAGATION_SYMBOL] = true; + // we need to call the native stopImmediatePropagation + // in case in some hybrid application, some part of + // application will be controlled by zone, some are not + delegate && delegate.apply(self, 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 + */ +function patchCallbacks(api, target, targetName, method, callbacks) { + const symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + const nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + const source = `${targetName}.${method}::` + callback; + const prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); +} + +/** + * @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 + */ +/* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ +const zoneSymbol$1 = Zone.__symbol__; +const _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; +const _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; +const _create = Object.create; +const unconfigurablesKey = zoneSymbol$1('unconfigurables'); +function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + const originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); + } + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + const desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; + } + return desc; + }; +} +function _redefineProperty(obj, prop, desc) { + const originalConfigurableFlag = desc.configurable; + desc = rewriteDescriptor(obj, prop, desc); + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); +} +function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; +} +function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; + } + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; + } + } + return desc; +} +function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; + } + else { + desc.configurable = originalConfigurableFlag; + } + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + let descJson = null; + try { + descJson = JSON.stringify(desc); + } + catch (error) { + descJson = desc.toString(); + } + console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${obj}' and got error, giving up: ${error}`); + } + } + else { + throw error; + } + } +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ +const globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' +]; +const documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' +]; +const windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' +]; +const htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' +]; +const mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; +const ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' +]; +const webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; +const formEventNames = ['autocomplete', 'autocompleteerror']; +const detailEventNames = ['toggle']; +const frameEventNames = ['load']; +const frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; +const marqueeEventNames = ['bounce', 'finish', 'start']; +const XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' +]; +const IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; +const websocketEventNames = ['close', 'error', 'open', 'message']; +const workerEventNames = ['error', 'message']; +const eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); +function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + const tip = ignoreProperties.filter(ip => ip.target === target); + if (!tip || tip.length === 0) { + return onProperties; + } + const targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(op => targetIgnoreProperties.indexOf(op) === -1); +} +function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + const filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); +} +function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; + } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } + const supportsWebSocket = typeof WebSocket !== 'undefined'; + const ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + const internalWindow = window; + const ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement) { + patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); + } + const Worker = internalWindow['Worker']; + if (Worker) { + patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); + } + } + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + } +} + +/** + * @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.__load_patch('util', (global, Zone, api) => { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = () => ({ + globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames, + isBrowser, + isMix, + isNode, + TRUE_STR, + FALSE_STR, + ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR + }); +}); + +/** + * @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 + */ + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +const taskSymbol = zoneSymbol('zoneTask'); +function patchTimer(window, setName, cancelName, nameSuffix) { + let setNative = null; + let clearNative = null; + setName += nameSuffix; + cancelName += nameSuffix; + const tasksByHandleId = {}; + function scheduleTask(task) { + const data = task.data; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } + } + } + data.args[0] = timer; + data.handleId = setNative.apply(window, data.args); + return task; + } + function clearTask(task) { + return clearNative(task.data.handleId); + } + setNative = + patchMethod(window, setName, (delegate) => function (self, args) { + if (typeof args[0] === 'function') { + const options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + const task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); + if (!task) { + return task; + } + // Node.js must additionally support the ref and unref functions. + const handle = task.data.handleId; + if (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } + return task; + } + else { + // cause an error by calling it directly. + return delegate.apply(window, args); + } + }); + clearNative = + patchMethod(window, cancelName, (delegate) => function (self, args) { + const id = args[0]; + let task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // 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 + */ +function patchCustomElements(_global, api) { + const { isBrowser, isMix } = api.getGlobalObjects(); + if ((!isBrowser && !isMix) || !('customElements' in _global)) { + return; + } + const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); +} + +/** + * @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 eventTargetPatch(_global, api) { + const { eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX } = api.getGlobalObjects(); + // predefine all __zone_symbol__ + eventName + true/false string + for (let i = 0; i < eventNames.length; i++) { + const eventName = eventNames[i]; + const falseEventName = eventName + FALSE_STR; + const trueEventName = eventName + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + const EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; +} +function patchEvent(global, api) { + api.patchEventPrototype(global, api); +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +Zone.__load_patch('legacy', (global) => { + const legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } +}); +Zone.__load_patch('timers', (global) => { + const set = 'set'; + const clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); +}); +Zone.__load_patch('requestAnimationFrame', (global) => { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); +}); +Zone.__load_patch('blocking', (global, Zone) => { + const blockingMethods = ['alert', 'prompt', 'confirm']; + for (let i = 0; i < blockingMethods.length; i++) { + const name = blockingMethods[i]; + patchMethod(global, name, (delegate, symbol, name) => { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); + } +}); +Zone.__load_patch('EventTarget', (global, Zone, api) => { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + const XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); +}); +Zone.__load_patch('on_property', (global, Zone, api) => { + propertyDescriptorPatch(api, global); + propertyPatch(); +}); +Zone.__load_patch('customElements', (global, Zone, api) => { + patchCustomElements(global, api); +}); +Zone.__load_patch('XHR', (global, Zone) => { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + const XHR_TASK = zoneSymbol('xhrTask'); + const XHR_SYNC = zoneSymbol('xhrSync'); + const XHR_LISTENER = zoneSymbol('xhrListener'); + const XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + const XHR_URL = zoneSymbol('xhrURL'); + const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + const XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; + } + let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + const READY_STATE_CHANGE = 'readystatechange'; + const SCHEDULED = 'scheduled'; + function scheduleTask(task) { + const data = task.data; + const target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + const listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + const newListener = target[XHR_LISTENER] = () => { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + const loadTasks = target['__zone_symbol__loadfalse']; + if (loadTasks && loadTasks.length > 0) { + const oriInvoke = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + const loadTasks = target['__zone_symbol__loadfalse']; + for (let i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; + } + } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + const storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; + } + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; + } + function placeholderCallback() { } + function clearTask(task) { + const data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + const openNative = patchMethod(XMLHttpRequestPrototype, 'open', () => function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }); + const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + const fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + const fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + const sendNative = patchMethod(XMLHttpRequestPrototype, 'send', () => function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + 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 { + const options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + const task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } + } + }); + const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function (self, args) { + const task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); + } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }); + } +}); +Zone.__load_patch('geolocation', (global) => { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); + } +}); +Zone.__load_patch('PromiseRejectionEvent', (global, Zone) => { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + const eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(eventTask => { + // windows has added unhandledrejection event listener + // trigger the event listener + const PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + const evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; + } + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); + } +}); + +/** + * @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 + */ diff --git a/dist/zone-evergreen.min.js b/dist/zone-evergreen.min.js new file mode 100644 index 000000000..7d044141c --- /dev/null +++ b/dist/zone-evergreen.min.js @@ -0,0 +1 @@ +const Zone$1=function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(r||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class s{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new a(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=s.current;for(;e.parent;)e=e.parent;return e}static get current(){return D.zone}static get currentTask(){return z}static __load_patch(t,i){if(P.hasOwnProperty(t)){if(r)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const r="Zone:"+t;n(r),P[t]=i(e,s,N),o(r,r)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){D={parent:D,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{D=D.parent}}runGuarded(e,t=null,n,o){D={parent:D,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{D=D.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state===y&&(e.type===w||e.type===O))return;const o=e.state!=T;o&&e._transitionTo(T,b),e.runCount++;const r=z;z=e,D={parent:D,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==y&&e.state!==v&&(e.type==w||e.data&&e.data.isPeriodic?o&&e._transitionTo(b,T):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(y,T,y))),D=D.parent,z=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;t;){if(t===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);t=t.parent}}e._transitionTo(E,y);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(v,E,y),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==E&&e._transitionTo(b,E),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new c(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new c(O,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new c(w,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(k,b,T);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(v,k),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(y,k),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class a{constructor(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._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask,r=t&&t._hasTaskZS;(o||r)&&(this._hasTaskZS=o?n:i,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=i,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=i,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=i,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new s(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");if(0==o||0==r){const t={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,t)}}}class c{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;t===w&&r&&r.useG?this.invoke=c.invokeTask:this.invoke=function(){return c.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),Z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==Z&&m(),Z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(y,E)}_transitionTo(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(`${this.type} '${this.source}': can not transition to '${e}', expecting state '${t}'${n?" or '"+n+"'":""}, was '${this._state}'.`);this._state=e,e==y&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const l=R("setTimeout"),u=R("Promise"),p=R("then");let h,f=[],d=!1;function _(t){if(0===Z&&0===f.length)if(h||e[u]&&(h=e[u].resolve(0)),h){let e=h[p];e||(e=h.then),e.call(h,m)}else e[l](m,0);t&&f.push(t)}function m(){if(!d){for(d=!0;f.length;){const e=f;f=[];for(let t=0;tD,onUnhandledError:I,microtaskDrainDone:I,scheduleMicroTask:_,showUncaughtError:()=>!s[R("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:I,patchMethod:()=>I,bindArguments:()=>[],patchThen:()=>I,patchMacroTask:()=>I,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(h=e.resolve(0))},patchEventPrototype:()=>I,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>I,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>I,wrapWithCurrentZone:()=>I,filterProperties:()=>[],attachOriginToPatched:()=>I,_redefineProperty:()=>I,patchCallbacks:()=>I};let D={parent:null,zone:new s(null,null)},z=null,Z=0;function I(){}function R(e){return"__zone_symbol__"+e}return o("Zone","Zone"),e.Zone=s}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty;const s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const 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)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){p(e)}}});const u=s("unhandledPromiseRejectionHandler");function p(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function h(e){return e&&e.then}function f(e){return e}function d(e){return M.reject(e)}const _=s("state"),m=s("value"),g=s("finally"),y=s("parentPromiseValue"),E=s("parentPromiseState"),b="Promise.then",T=null,k=!0,v=!1,S=0;function O(e,t){return n=>{try{D(e,t,n)}catch(t){D(e,!1,t)}}}const w=function(){let e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},P="Promise resolved with itself",N=s("currentTaskTrace");function D(e,o,s){const a=w();if(e===s)throw new TypeError(P);if(e[_]===T){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{D(e,!1,t)})(),e}if(o!==v&&s instanceof M&&s.hasOwnProperty(_)&&s.hasOwnProperty(m)&&s[_]!==T)Z(s),D(e,s[_],s[m]);else if(o!==v&&"function"==typeof c)try{c.call(s,a(O(e,o)),a(O(e,!1)))}catch(t){a(()=>{D(e,!1,t)})()}else{e[_]=o;const a=e[m];if(e[m]=s,e[g]===g&&o===k&&(e[_]=e[E],e[m]=e[y]),o===v&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,N,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[m],r=n&&g===n[g];r&&(n[y]=o,n[E]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);D(n,!0,a)}catch(e){D(n,!1,e)}},n)}const R="function ZoneAwarePromise() { [native code] }";class M{constructor(e){const t=this;if(!(t instanceof M))throw new Error("Must be an instanceof Promise.");t[_]=T,t[m]=[];try{e&&e(O(t,k),O(t,v))}catch(e){D(t,!1,e)}}static toString(){return R}static resolve(e){return D(new this(null),k,e)}static reject(e){return D(new this(null),v,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)h(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){h(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0===--r&&t(i)},n),r++,s++}return 0===(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[_]==T?this[m].push(r,o,e,n):I(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[g]=g;const o=t.current;return this[_]==T?this[m].push(o,n,e,e):I(this,o,n,e,e),n}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;const j=e[a]=e.Promise,C=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[C]?e[C]:e[a]},L.set=function(t){t===M?e[C]=t:(e[a]=t,t.prototype[c]||F(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=M;const A=s("thenPatched");function F(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new M((e,t)=>{r.call(this,e,t)}).then(e,t)},e[A]=!0}if(n.patchThen=F,j){F(j);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function(e){return function(){let t=e.apply(this,arguments);if(t instanceof M)return t;let n=t.constructor;return n[A]||F(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,M});const ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ObjectDefineProperty=Object.defineProperty,ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectCreate=Object.create,ArraySlice=Array.prototype.slice,ADD_EVENT_LISTENER_STR="addEventListener",REMOVE_EVENT_LISTENER_STR="removeEventListener",ZONE_SYMBOL_ADD_EVENT_LISTENER=Zone.__symbol__(ADD_EVENT_LISTENER_STR),ZONE_SYMBOL_REMOVE_EVENT_LISTENER=Zone.__symbol__(REMOVE_EVENT_LISTENER_STR),TRUE_STR="true",FALSE_STR="false",ZONE_SYMBOL_PREFIX="__zone_symbol__";function wrapWithCurrentZone(e,t){return Zone.current.wrap(e,t)}function scheduleMacroTaskWithCurrentZone(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const zoneSymbol=Zone.__symbol__,isWindowExists="undefined"!=typeof window,internalWindow=isWindowExists?window:void 0,_global=isWindowExists&&internalWindow||"object"==typeof self&&self||global,REMOVE_ATTRIBUTE="removeAttribute",NULL_ON_PROP_VALUE=[null];function bindArguments(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=wrapWithCurrentZone(e[n],t+"_"+n));return e}function patchPrototype(e,t){const n=e.constructor.name;for(let o=0;o{const t=function(){return e.apply(this,bindArguments(arguments,n+"."+r))};return attachOriginToPatched(t,e),t})(s)}}}function isPropertyWritable(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode=!("nw"in _global)&&void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process),isBrowser=!isNode&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),isMix=void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process)&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),zoneSymbolEventNames={},wrapFn=function(e){if(!(e=e||_global.event))return;let t=zoneSymbolEventNames[e.type];t||(t=zoneSymbolEventNames[e.type]=zoneSymbol("ON_PROPERTY"+e.type));const n=this||e.target||_global,o=n[t];let r;if(isBrowser&&n===internalWindow&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function patchProperty(e,t,n){let o=ObjectGetOwnPropertyDescriptor(e,t);if(!o&&n){ObjectGetOwnPropertyDescriptor(n,t)&&(o={enumerable:!0,configurable:!0})}if(!o||!o.configurable)return;const r=zoneSymbol("on"+t+"patched");if(e.hasOwnProperty(r)&&e[r])return;delete o.writable,delete o.value;const s=o.get,i=o.set,a=t.substr(2);let c=zoneSymbolEventNames[a];c||(c=zoneSymbolEventNames[a]=zoneSymbol("ON_PROPERTY"+a)),o.set=function(t){let n=this;n||e!==_global||(n=_global),n&&(n[c]&&n.removeEventListener(a,wrapFn),i&&i.apply(n,NULL_ON_PROP_VALUE),"function"==typeof t?(n[c]=t,n.addEventListener(a,wrapFn,!1)):n[c]=null)},o.get=function(){let n=this;if(n||e!==_global||(n=_global),!n)return null;const r=n[c];if(r)return r;if(s){let e=s&&s.call(this);if(e)return o.set.call(this,e),"function"==typeof n[REMOVE_ATTRIBUTE]&&n.removeAttribute(t),e}return null},ObjectDefineProperty(e,t,o),e[r]=!0}function patchOnProperties(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}let shouldCopySymbolProperties=!1;function patchMethod(e,t,n){let o=e;for(;o&&!o.hasOwnProperty(t);)o=ObjectGetPrototypeOf(o);!o&&e[t]&&(o=e);const r=zoneSymbol(t);let s=null;if(o&&!(s=o[r])){if(s=o[r]=o[t],isPropertyWritable(o&&ObjectGetOwnPropertyDescriptor(o,t))){const e=n(s,r,t);o[t]=function(){return e(this,arguments)},attachOriginToPatched(o[t],s),shouldCopySymbolProperties&©SymbolProperties(s,o[t])}}return s}function patchMacroTask(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=patchMethod(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?scheduleMacroTaskWithCurrentZone(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function attachOriginToPatched(e,t){e[zoneSymbol("OriginalDelegate")]=t}let isDetectedIEOrEdge=!1,ieOrEdge=!1;function isIE(){try{const e=internalWindow.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function isIEOrEdge(){if(isDetectedIEOrEdge)return ieOrEdge;isDetectedIEOrEdge=!0;try{const e=internalWindow.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(ieOrEdge=!0)}catch(e){}return ieOrEdge}Zone.__load_patch("toString",e=>{const t=Function.prototype.toString,n=zoneSymbol("OriginalDelegate"),o=zoneSymbol("Promise"),r=zoneSymbol("Error"),s=function(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});let passiveSupported=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){passiveSupported=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){passiveSupported=!1}const OPTIMIZED_ZONE_EVENT_TASK_DATA={useG:!0},zoneSymbolEventNames$1={},globalSources={},EVENT_NAME_SYMBOL_REGX=/^__zone_symbol__(\w+)(true|false)$/,IMMEDIATE_PROPAGATION_SYMBOL="__zone_symbol__propagationStopped";function patchEventTarget(e,t,n){const o=n&&n.add||ADD_EVENT_LISTENER_STR,r=n&&n.rm||REMOVE_EVENT_LISTENER_STR,s=n&&n.listeners||"eventListeners",i=n&&n.rmAll||"removeAllListeners",a=zoneSymbol(o),c="."+o+":",l="prependListener",u="."+l+":",p=function(e,t,n){if(e.isRemoved)return;const o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=(e=>o.handleEvent(e)),e.originalDelegate=o),e.invoke(e,t,[n]);const s=e.options;if(s&&"object"==typeof s&&s.once){const o=e.originalDelegate?e.originalDelegate:e.callback;t[r].call(t,n.type,o,s)}},h=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[zoneSymbolEventNames$1[t.type][FALSE_STR]];if(o)if(1===o.length)p(o[0],n,t);else{const e=o.slice();for(let o=0;o(function(t,n){t[IMMEDIATE_PROPAGATION_SYMBOL]=!0,e&&e.apply(t,n)}))}function patchCallbacks(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)}const zoneSymbol$1=Zone.__symbol__,_defineProperty=Object[zoneSymbol$1("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol$1("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol$1("unconfigurables");function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,o)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=_getOwnPropertyDescriptor(e,t);return n&&isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){const o=n.configurable;return _tryDefineProperty(e,t,n=rewriteDescriptor(e,t,n),o)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[unconfigurablesKey]||Object.isFrozen(e)||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey]&&(e[unconfigurablesKey][t]=!0)),n}function _tryDefineProperty(e,t,n,o){try{return _defineProperty(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return _defineProperty(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}}const globalEventHandlersEventNames=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],documentEventNames=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],windowEventNames=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],htmlElementEventNames=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],mediaElementEventNames=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ieElementEventNames=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],webglEventNames=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],formEventNames=["autocomplete","autocompleteerror"],detailEventNames=["toggle"],frameEventNames=["load"],frameSetEventNames=["blur","error","focus","load","resize","scroll","messageerror"],marqueeEventNames=["bounce","finish","start"],XMLHttpRequestEventNames=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],IDBIndexEventNames=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],websocketEventNames=["close","error","open","message"],workerEventNames=["error","message"],eventNames=globalEventHandlersEventNames.concat(webglEventNames,formEventNames,detailEventNames,documentEventNames,windowEventNames,htmlElementEventNames,ieElementEventNames);function filterProperties(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function patchFilteredProperties(e,t,n,o){if(!e)return;patchOnProperties(e,filterProperties(e,t,n),o)}function propertyDescriptorPatch(e,t){if(isNode&&!isMix)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(isBrowser){const e=window,t=isIE?[{target:e,ignoreProperties:["error"]}]:[];patchFilteredProperties(e,eventNames.concat(["messageerror"]),o?o.concat(t):o,ObjectGetPrototypeOf(e)),patchFilteredProperties(Document.prototype,eventNames,o),void 0!==e.SVGElement&&patchFilteredProperties(e.SVGElement.prototype,eventNames,o),patchFilteredProperties(Element.prototype,eventNames,o),patchFilteredProperties(HTMLElement.prototype,eventNames,o),patchFilteredProperties(HTMLMediaElement.prototype,mediaElementEventNames,o),patchFilteredProperties(HTMLFrameSetElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLBodyElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLFrameElement.prototype,frameEventNames,o),patchFilteredProperties(HTMLIFrameElement.prototype,frameEventNames,o);const n=e.HTMLMarqueeElement;n&&patchFilteredProperties(n.prototype,marqueeEventNames,o);const r=e.Worker;r&&patchFilteredProperties(r.prototype,workerEventNames,o)}patchFilteredProperties(XMLHttpRequest.prototype,XMLHttpRequestEventNames,o);const r=t.XMLHttpRequestEventTarget;r&&patchFilteredProperties(r&&r.prototype,XMLHttpRequestEventNames,o),"undefined"!=typeof IDBIndex&&(patchFilteredProperties(IDBIndex.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBOpenDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBDatabase.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBTransaction.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBCursor.prototype,IDBIndexEventNames,o)),n&&patchFilteredProperties(WebSocket.prototype,websocketEventNames,o)}Zone.__load_patch("util",(e,t,n)=>{n.patchOnProperties=patchOnProperties,n.patchMethod=patchMethod,n.bindArguments=bindArguments,n.patchMacroTask=patchMacroTask;const o=t.__symbol__("BLACK_LISTED_EVENTS"),r=t.__symbol__("UNPATCHED_EVENTS");e[r]&&(e[o]=e[r]),e[o]&&(t[o]=t[r]=e[o]),n.patchEventPrototype=patchEventPrototype,n.patchEventTarget=patchEventTarget,n.isIEOrEdge=isIEOrEdge,n.ObjectDefineProperty=ObjectDefineProperty,n.ObjectGetOwnPropertyDescriptor=ObjectGetOwnPropertyDescriptor,n.ObjectCreate=ObjectCreate,n.ArraySlice=ArraySlice,n.patchClass=patchClass,n.wrapWithCurrentZone=wrapWithCurrentZone,n.filterProperties=filterProperties,n.attachOriginToPatched=attachOriginToPatched,n._redefineProperty=_redefineProperty,n.patchCallbacks=patchCallbacks,n.getGlobalObjects=(()=>({globalSources,zoneSymbolEventNames:zoneSymbolEventNames$1,eventNames,isBrowser,isMix,isNode,TRUE_STR,FALSE_STR,ZONE_SYMBOL_PREFIX,ADD_EVENT_LISTENER_STR,REMOVE_EVENT_LISTENER_STR}))});const taskSymbol=zoneSymbol("zoneTask");function patchTimer(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[taskSymbol]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=patchMethod(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e={isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},n=scheduleMacroTaskWithCurrentZone(t,s[0],e,a,c);if(!n)return n;const r=n.data.handleId;return"number"==typeof r?i[r]=n:r&&(r[taskSymbol]=n),r&&r.ref&&r.unref&&"function"==typeof r.ref&&"function"==typeof r.unref&&(n.ref=r.ref.bind(r),n.unref=r.unref.bind(r)),"number"==typeof r||r?r:n}return n.apply(e,s)})),s=patchMethod(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[taskSymbol])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[taskSymbol]=null),s.zone.cancelTask(s)):t.apply(e,o)}))}function patchCustomElements(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();if(!n&&!o||!("customElements"in e))return;t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}function eventTargetPatch(e,t){const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{patchTimer(e,"set","clear","Timeout"),patchTimer(e,"set","clear","Interval"),patchTimer(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{patchTimer(e,"request","cancel","AnimationFrame"),patchTimer(e,"mozRequest","mozCancel","AnimationFrame"),patchTimer(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}}),Zone.__load_patch("EventTarget",(e,t,n)=>{patchEvent(e,n),eventTargetPatch(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("IntersectionObserver"),patchClass("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{propertyDescriptorPatch(n,e),propertyPatch()}),Zone.__load_patch("customElements",(e,t,n)=>{patchCustomElements(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function(e){const c=XMLHttpRequest.prototype;let l=c[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=c[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];if(!l){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;l=e[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=e[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]}}const p="readystatechange",h="scheduled";function f(e){const t=e.data,o=t.target;o[s]=!1,o[a]=!1;const i=o[r];l||(l=o[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=o[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]),i&&u.call(o,p,i);const c=o[r]=(()=>{if(o.readyState===o.DONE)if(!t.aborted&&o[s]&&e.state===h){const n=o.__zone_symbol__loadfalse;if(n&&n.length>0){const r=e.invoke;e.invoke=function(){const n=o.__zone_symbol__loadfalse;for(let t=0;t(function(e,t){return e[o]=0==t[2],e[i]=t[1],m.apply(e,t)})),g=zoneSymbol("fetchTaskAborting"),y=zoneSymbol("fetchTaskScheduling"),E=patchMethod(c,"send",()=>(function(e,n){if(!0===t.current[y])return E.apply(e,n);if(e[o])return E.apply(e,n);{const t={target:e,url:e[i],isPeriodic:!1,args:n,aborted:!1},o=scheduleMacroTaskWithCurrentZone("XMLHttpRequest.send",d,t,f,_);e&&!0===e[a]&&!t.aborted&&o.state===h&&o.invoke()}})),b=patchMethod(c,"abort",()=>(function(e,o){const r=e[n];if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[g])return b.apply(e,o)}))}(e);const n=zoneSymbol("xhrTask"),o=zoneSymbol("xhrSync"),r=zoneSymbol("xhrListener"),s=zoneSymbol("xhrScheduled"),i=zoneSymbol("xhrURL"),a=zoneSymbol("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&patchPrototype(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){findEventTasks(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[zoneSymbol("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[zoneSymbol("rejectionHandledHandler")]=n("rejectionhandled"))}); \ No newline at end of file diff --git a/dist/zone-legacy.js b/dist/zone-legacy.js new file mode 100644 index 000000000..69d76cd2c --- /dev/null +++ b/dist/zone-legacy.js @@ -0,0 +1,321 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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 eventTargetLegacyPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + 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,WebSocket' + .split(','); + var EVENT_TARGET = 'EventTarget'; + var apis = []; + var isWtf = _global['wtf']; + var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); + if (isWtf) { + // Workaround for: https://github.com/google/tracing-framework/issues/555 + apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); + } + else if (_global[EVENT_TARGET]) { + // EventTarget is already patched in browser.ts + } + 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; + } + var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; + var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; + var ieOrEdge = api.isIEOrEdge(); + var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; + var FUNCTION_WRAPPER = '[object FunctionWrapper]'; + var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + // predefine all task.source string + for (var i = 0; i < WTF_ISSUE_555.length; i++) { + var target = WTF_ISSUE_555_ARRAY[i]; + var targets = globalSources[target] = {}; + for (var j = 0; j < eventNames.length; j++) { + var eventName = eventNames[j]; + targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + } + } + var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { + if (!isDisableIECheck && ieOrEdge) { + if (isEnableCrossContextCheck) { + try { + var testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } + catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } + else { + var testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } + } + else if (isEnableCrossContextCheck) { + try { + delegate.toString(); + } + catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } + return true; + }; + var apiTypes = []; + for (var i = 0; i < apis.length; i++) { + var type = _global[apis[i]]; + apiTypes.push(type && type.prototype); + } + // vh is validateHandler to check event handler + // is valid or not(for security check) + api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + return true; +} + +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +// we have to patch the instance since the proto is non-configurable +function apply(api, _global) { + var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; + var WS = _global.WebSocket; + // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener + // On older Chrome, no need since EventTarget was already patched + if (!_global.EventTarget) { + api.patchEventTarget(_global, [WS.prototype]); + } + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); + var proxySocket; + var proxySocketProto; + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = api.ObjectCreate(socket); + // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' + // but proxySocket not, so we will keep socket as prototype and pass it to + // patchOnProperties method + proxySocketProto = socket; + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { + proxySocket[propName] = function () { + var args = api.ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { + var eventName = args.length > 0 ? args[0] : undefined; + if (eventName) { + var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + socket[propertySymbol] = proxySocket[propertySymbol]; + } + } + return socket[propName].apply(socket, args); + }; + }); + } + else { + // we can patch the real socket + proxySocket = socket; + } + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + return proxySocket; + }; + var globalWebSocket = _global['WebSocket']; + for (var prop in WS) { + globalWebSocket[prop] = WS[prop]; + } +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ +function propertyDescriptorLegacyPatch(api, _global) { + var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; + if (isNode && !isMix) { + return; + } + var supportsWebSocket = typeof WebSocket !== 'undefined'; + if (!canPatchViaPropertyDescriptor(api)) { + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + apply(api, _global); + } + Zone[api.symbol('patchEvents')] = true; + } +} +function canPatchViaPropertyDescriptor(api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) + return false; + } + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var req = new XMLHttpRequest(); + var result = !!req.onreadystatechange; + // restore original desc + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + return result; + } + else { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; + }, + set: function (value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; + } + }); + var req = new XMLHttpRequest(); + var detectFunc = function () { }; + req.onreadystatechange = detectFunc; + var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = null; + return result; + } +} +// Whenever any eventListener fires, we check the eventListener target and all parents +// for `onwhatever` properties and replace them with zone-bound functions +// - Chrome (for now) +function patchViaCapturingAllTheEvents(api) { + var eventNames = api.getGlobalObjects().eventNames; + var unboundKey = api.symbol('unbound'); + var _loop_1 = function (i) { + var property = eventNames[i]; + var onproperty = 'on' + property; + self.addEventListener(property, function (event) { + var elt = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; + } + else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = api.wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; + } + elt = elt.parentElement; + } + }, true); + }; + for (var i = 0; i < eventNames.length; i++) { + _loop_1(i); + } +} + +/** + * @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, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +(function (_global) { + _global['__zone_symbol__legacyPatch'] = function () { + var Zone = _global['Zone']; + Zone.__load_patch('registerElement', function (global, Zone, api) { + registerElementPatch(global, api); + }); + Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); + }; +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); + +}))); diff --git a/dist/zone-legacy.min.js b/dist/zone-legacy.min.js new file mode 100644 index 000000000..7ec8b01a1 --- /dev/null +++ b/dist/zone-legacy.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function e(e,t){var n=e.getGlobalObjects(),r=n.isNode,a=n.isMix;if(!r||a){var o="undefined"!=typeof WebSocket;(function(e){var t=e.getGlobalObjects(),n=t.isBrowser,r=t.isMix;if((n||r)&&!e.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var a=e.ObjectGetOwnPropertyDescriptor(Element.prototype,"onclick");if(a&&!a.configurable)return!1}var o=XMLHttpRequest.prototype,c=e.ObjectGetOwnPropertyDescriptor(o,"onreadystatechange");if(c){e.ObjectDefineProperty(o,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return!0}});var i=new XMLHttpRequest,l=!!i.onreadystatechange;return e.ObjectDefineProperty(o,"onreadystatechange",c||{}),l}var s=e.symbol("fake");e.ObjectDefineProperty(o,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return this[s]},set:function(e){this[s]=e}});var i=new XMLHttpRequest,u=function(){};i.onreadystatechange=u;var l=i[s]===u;return i.onreadystatechange=null,l})(e)||(!function(e){for(var t=e.getGlobalObjects().eventNames,n=e.symbol("unbound"),r=function(r){var a=t[r],o="on"+a;self.addEventListener(a,function(t){var r,a,c=t.target;for(a=c?c.constructor.name+"."+o:"unknown."+o;c;)c[o]&&!c[o][n]&&((r=e.wrapWithCurrentZone(c[o],a))[n]=c[o],c[o]=r),c=c.parentElement},!0)},a=0;a1?new o(t,n):new o(t),s=e.ObjectGetOwnPropertyDescriptor(l,"onmessage");return s&&!1===s.configurable?(c=e.ObjectCreate(l),i=l,[r,a,"send","close"].forEach(function(t){c[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===a){var o=n.length>0?n[0]:void 0;if(o){var i=Zone.__symbol__("ON_PROPERTY"+o);l[i]=c[i]}}return l[t].apply(l,n)}})):c=l,e.patchOnProperties(c,["close","error","message","open"],i),c};var c=t.WebSocket;for(var i in o)c[i]=o[i]}(e,t),Zone[e.symbol("patchEvents")]=!0)}}var t;(t="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global).__zone_symbol__legacyPatch=function(){var n=t.Zone;n.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,a=n.isMix;(r||a)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),n.__load_patch("EventTargetLegacy",function(t,n,r){!function(e,t){var n=t.getGlobalObjects(),r=n.eventNames,a=n.globalSources,o=n.zoneSymbolEventNames,c=n.TRUE_STR,i=n.FALSE_STR,l=n.ZONE_SYMBOL_PREFIX,s="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",u="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,WebSocket".split(","),p=[],f=e.wtf,b=s.split(",");f?p=b.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget||(p=u);for(var d=e.__Zone_disable_IE_check||!1,g=e.__Zone_enable_cross_context_check||!1,v=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",E=0;E 1 ? new WS(x, y) : new WS(x); - var proxySocket; - var proxySocketProto; - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = ObjectCreate(socket); - // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' - // but proxySocket not, so we will keep socket as prototype and pass it to - // patchOnProperties method - proxySocketProto = socket; - [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { - proxySocket[propName] = function () { - var args = ArraySlice.call(arguments); - if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { - var eventName = args.length > 0 ? args[0] : undefined; - if (eventName) { - var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); - socket[propertySymbol] = proxySocket[propertySymbol]; - } - } - return socket[propName].apply(socket, args); - }; - }); - } - else { - // we can patch the real socket - proxySocket = socket; - } - patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); - return proxySocket; - }; - var globalWebSocket = _global['WebSocket']; - for (var prop in WS) { - globalWebSocket[prop] = WS[prop]; +function eventTargetPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; +} +function patchEvent(global, api) { + api.patchEventPrototype(global, api); } /** @@ -2717,297 +2724,55 @@ function propertyDescriptorPatch(api, _global) { if (isNode && !isMix) { return; } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - if (canPatchViaPropertyDescriptor()) { - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); - } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); - } - } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - var XMLHttpRequestEventTarget_1 = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - patchFilteredProperties(XMLHttpRequestEventTarget_1 && XMLHttpRequestEventTarget_1.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } - } - else { - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(); - patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - apply(api, _global); - } - } -} -function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) - return false; - } - var ON_READY_STATE_CHANGE = 'onreadystatechange'; - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - var xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return true; - } - }); - var req = new XMLHttpRequest(); - var result = !!req.onreadystatechange; - // restore original desc - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } - else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fake'); - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; - }, - set: function (value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; - } - }); - var req = new XMLHttpRequest(); - var detectFunc = function () { }; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; - req.onreadystatechange = null; - return result; - } -} -var unboundKey = zoneSymbol('unbound'); -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents() { - var _loop_1 = function (i) { - var property = eventNames[i]; - var onproperty = 'on' + property; - self.addEventListener(property, function (event) { - var elt = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } - else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; - } - elt = elt.parentElement; - } - }, true); - }; - for (var i = 0; i < eventNames.length; i++) { - _loop_1(i); - } -} - -/** - * @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 eventTargetPatch(_global, api) { - 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,WebSocket' - .split(','); - var EVENT_TARGET = 'EventTarget'; - var apis = []; - var isWtf = _global['wtf']; - var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); - if (isWtf) { - // Workaround for: https://github.com/google/tracing-framework/issues/555 - apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); - } - else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); - } - else { - // Note: EventTarget is not available in all browsers, - // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget - apis = NO_EVENT_TARGET; - } - var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; - var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - var ieOrEdge = isIEOrEdge(); - var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; - var FUNCTION_WRAPPER = '[object FunctionWrapper]'; - var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - } - // predefine all task.source string - for (var i = 0; i < WTF_ISSUE_555.length; i++) { - var target = WTF_ISSUE_555_ARRAY[i]; - var targets = globalSources[target] = {}; - for (var j = 0; j < eventNames.length; j++) { - var eventName = eventNames[j]; - targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; - } - } - var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { - if (!isDisableIECheck && ieOrEdge) { - if (isEnableCrossContextCheck) { - try { - var testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { - nativeDelegate.apply(target, args); - return false; - } - } - catch (error) { - nativeDelegate.apply(target, args); - return false; - } - } - else { - var testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { - nativeDelegate.apply(target, args); - return false; - } - } - } - else if (isEnableCrossContextCheck) { - try { - delegate.toString(); - } - catch (error) { - nativeDelegate.apply(target, args); - return false; - } - } - return true; - }; - var apiTypes = []; - for (var i = 0; i < apis.length; i++) { - var type = _global[apis[i]]; - apiTypes.push(type && type.prototype); - } - // vh is validateHandler to check event handler - // is valid or not(for security check) - patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); - api.patchEventTarget = patchEventTarget; - return true; -} -function patchEvent(global, api) { - patchEventPrototype(global, api); -} - -/** - * @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 patchCallbacks(target, targetName, method, callbacks) { - var symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; - } - var nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - var source = targetName + "." + method + "::" + callback; - var prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = wrapWithCurrentZone(descriptor.value, source); - _redefineProperty(opts.prototype, callback, descriptor); - } - else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } - } - else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } - }); - } - return nativeDelegate.call(target, name, opts, options); - }; - attachOriginToPatched(target[method], nativeDelegate); -} -function registerElementPatch(_global) { - if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. return; } - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - patchCallbacks(document, 'Document', 'registerElement', callbacks); -} -function patchCustomElements(_global) { - if ((!isBrowser && !isMix) || !('customElements' in _global)) { - return; + var supportsWebSocket = typeof WebSocket !== 'undefined'; + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + } + } + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); } - var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); } /** @@ -3021,10 +2786,11 @@ function patchCustomElements(_global) { * @fileoverview * @suppress {missingRequire} */ -Zone.__load_patch('util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; +Zone.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } }); Zone.__load_patch('timers', function (global) { var set = 'set'; @@ -3050,11 +2816,6 @@ Zone.__load_patch('blocking', function (global, Zone) { } }); Zone.__load_patch('EventTarget', function (global, Zone, api) { - // load blackListEvents from global - var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; - } patchEvent(global, api); eventTargetPatch(global, api); // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener @@ -3072,17 +2833,7 @@ Zone.__load_patch('on_property', function (global, Zone, api) { propertyPatch(); }); Zone.__load_patch('customElements', function (global, Zone, api) { - registerElementPatch(global); - patchCustomElements(global); -}); -Zone.__load_patch('canvas', function (global) { - var HTMLCanvasElement = global['HTMLCanvasElement']; - if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && - HTMLCanvasElement.prototype.toBlob) { - patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; - }); - } + patchCustomElements(global, api); }); Zone.__load_patch('XHR', function (global, Zone) { // Treat XMLHttpRequest as a macrotask. @@ -3271,6 +3022,7 @@ Zone.__load_patch('node_util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; setShouldCopySymbolProperties(true); }); diff --git a/dist/zone-node.js b/dist/zone-node.js index 8bbe1e846..9f90c8cd6 100644 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -630,6 +630,7 @@ var Zone$1 = (function (global) { patchMethod: function () { return noop; }, bindArguments: function () { return []; }, patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -638,6 +639,19 @@ var Zone$1 = (function (global) { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } }; var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; var _currentTask = null; @@ -660,6 +674,13 @@ var __values = (undefined && undefined.__values) || function (o) { } }; }; +/** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -931,10 +952,10 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { reject = rej; }); function onResolve(value) { - promise && (promise = null || resolve(value)); + resolve(value); } function onReject(error) { - promise && (promise = null || reject(error)); + reject(error); } try { for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { @@ -1002,6 +1023,13 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } return promise; }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true + }); ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); var zone = Zone.current; @@ -1096,8 +1124,26 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Ctor[symbolThenPatched] = true; } api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } if (NativePromise) { patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); + } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; @@ -1458,7 +1504,7 @@ Zone.__load_patch('toString', function (global) { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { if (typeof originalDelegate === 'function') { - return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); + return originalFunctionToString.call(originalDelegate); } else { return Object.prototype.toString.call(originalDelegate); @@ -1467,17 +1513,17 @@ Zone.__load_patch('toString', function (global) { if (this === Promise) { var nativePromise = global[PROMISE_SYMBOL]; if (nativePromise) { - return originalFunctionToString.apply(nativePromise, arguments); + return originalFunctionToString.call(nativePromise); } } if (this === Error) { var nativeError = global[ERROR_SYMBOL]; if (nativeError) { - return originalFunctionToString.apply(nativeError, arguments); + return originalFunctionToString.call(nativeError); } } } - return originalFunctionToString.apply(this, arguments); + return originalFunctionToString.call(this); }; newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; Function.prototype.toString = newFunctionToString; @@ -1488,7 +1534,7 @@ Zone.__load_patch('toString', function (global) { if (this instanceof Promise) { return PROMISE_OBJECT_TO_STRING; } - return originalObjectToString.apply(this, arguments); + return originalObjectToString.call(this); }; }); @@ -1503,6 +1549,7 @@ Zone.__load_patch('node_util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; setShouldCopySymbolProperties(true); }); diff --git a/dist/zone-patch-canvas.js b/dist/zone-patch-canvas.js new file mode 100644 index 000000000..593f4cc26 --- /dev/null +++ b/dist/zone-patch-canvas.js @@ -0,0 +1,31 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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.__load_patch('canvas', function (global, Zone, api) { + var HTMLCanvasElement = global['HTMLCanvasElement']; + if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && + HTMLCanvasElement.prototype.toBlob) { + api.patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { + return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; + }); + } +}); + +}))); diff --git a/dist/zone-patch-canvas.min.js b/dist/zone-patch-canvas.min.js new file mode 100644 index 000000000..94168d1d4 --- /dev/null +++ b/dist/zone-patch-canvas.min.js @@ -0,0 +1 @@ +!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("canvas",function(t,o,e){var n=t.HTMLCanvasElement;void 0!==n&&n.prototype&&n.prototype.toBlob&&e.patchMacroTask(n.prototype,"toBlob",function(t,o){return{name:"HTMLCanvasElement.toBlob",target:t,cbIdx:0,args:o}})})}); \ No newline at end of file diff --git a/dist/zone-patch-cordova.min.js b/dist/zone-patch-cordova.min.js index b30c6e97e..6f6dad108 100644 --- a/dist/zone-patch-cordova.min.js +++ b/dist/zone-patch-cordova.min.js @@ -1 +1 @@ -!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("cordova",function(e,o,r){if(e.cordova)var t="cordova.exec.success",n="cordova.exec.error",a="function",c=r.patchMethod(e.cordova,"exec",function(){return function(e,r){return r.length>0&&typeof r[0]===a&&(r[0]=o.current.wrap(r[0],t)),r.length>1&&typeof r[1]===a&&(r[1]=o.current.wrap(r[1],n)),c.apply(e,r)}})}),Zone.__load_patch("cordova.FileReader",function(e,o){e.cordova&&"undefined"!=typeof e.FileReader&&document.addEventListener("deviceReady",function(){var r=e.FileReader;["abort","error","load","loadstart","loadend","progress"].forEach(function(e){var t=o.__symbol__("ON_PROPERTY"+e);Object.defineProperty(r.prototype,t,{configurable:!0,get:function(){return this._realReader&&this._realReader[t]}})})})})}); \ No newline at end of file +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("cordova",function(e,o,r){if(e.cordova)var t=r.patchMethod(e.cordova,"exec",function(){return function(e,r){return r.length>0&&"function"==typeof r[0]&&(r[0]=o.current.wrap(r[0],"cordova.exec.success")),r.length>1&&"function"==typeof r[1]&&(r[1]=o.current.wrap(r[1],"cordova.exec.error")),t.apply(e,r)}})}),Zone.__load_patch("cordova.FileReader",function(e,o){e.cordova&&void 0!==e.FileReader&&document.addEventListener("deviceReady",function(){var r=e.FileReader;["abort","error","load","loadstart","loadend","progress"].forEach(function(e){var t=o.__symbol__("ON_PROPERTY"+e);Object.defineProperty(r.prototype,t,{configurable:!0,get:function(){return this._realReader&&this._realReader[t]}})})})})}); \ No newline at end of file diff --git a/dist/zone-patch-electron.min.js b/dist/zone-patch-electron.min.js index 0c049edac..e23b6d97e 100644 --- a/dist/zone-patch-electron.min.js +++ b/dist/zone-patch-electron.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(this,function(){"use strict";Zone.__load_patch("electron",function(e,t,n){function o(e,t,o){return n.patchMethod(e,t,function(e){return function(t,r){return e&&e.apply(t,n.bindArguments(r,o))}})}var r=require("electron"),c=r.desktopCapturer,u=r.shell,i=r.CallbacksRegistry;c&&o(c,"getSources","electron.desktopCapturer.getSources"),u&&o(u,"openExternal","electron.shell.openExternal"),i&&o(i.prototype,"add","CallbackRegistry.add")})}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("electron",function(e,t,n){function o(e,t,o){return n.patchMethod(e,t,function(e){return function(t,r){return e&&e.apply(t,n.bindArguments(r,o))}})}var r=require("electron"),c=r.desktopCapturer,u=r.shell,l=r.CallbacksRegistry;c&&o(c,"getSources","electron.desktopCapturer.getSources"),u&&o(u,"openExternal","electron.shell.openExternal"),l&&o(l.prototype,"add","CallbackRegistry.add")})}); \ No newline at end of file diff --git a/dist/zone-patch-fetch.js b/dist/zone-patch-fetch.js new file mode 100644 index 000000000..5fe62a84a --- /dev/null +++ b/dist/zone-patch-fetch.js @@ -0,0 +1,120 @@ +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory() : + typeof define === 'function' && define.amd ? define(factory) : + (factory()); +}(this, (function () { 'use strict'; + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +Zone.__load_patch('fetch', function (global, Zone, api) { + var fetch = global['fetch']; + if (typeof fetch !== 'function') { + return; + } + var originalFetch = global[api.symbol('fetch')]; + if (originalFetch) { + // restore unpatched fetch first + fetch = originalFetch; + } + var ZoneAwarePromise = global.Promise; + var symbolThenPatched = api.symbol('thenPatched'); + var fetchTaskScheduling = api.symbol('fetchTaskScheduling'); + var fetchTaskAborting = api.symbol('fetchTaskAborting'); + var OriginalAbortController = global['AbortController']; + var supportAbort = typeof OriginalAbortController === 'function'; + var abortNative = null; + if (supportAbort) { + global['AbortController'] = function () { + var abortController = new OriginalAbortController(); + var signal = abortController.signal; + signal.abortController = abortController; + return abortController; + }; + abortNative = api.patchMethod(OriginalAbortController.prototype, 'abort', function (delegate) { return function (self, args) { + if (self.task) { + return self.task.zone.cancelTask(self.task); + } + return delegate.apply(self, args); + }; }); + } + var placeholder = function () { }; + global['fetch'] = function () { + var _this = this; + var args = Array.prototype.slice.call(arguments); + var options = args.length > 1 ? args[1] : null; + var signal = options && options.signal; + return new Promise(function (res, rej) { + var task = Zone.current.scheduleMacroTask('fetch', placeholder, { fetchArgs: args }, function () { + var fetchPromise; + var zone = Zone.current; + try { + zone[fetchTaskScheduling] = true; + fetchPromise = fetch.apply(_this, args); + } + catch (error) { + rej(error); + return; + } + finally { + zone[fetchTaskScheduling] = false; + } + if (!(fetchPromise instanceof ZoneAwarePromise)) { + var ctor = fetchPromise.constructor; + if (!ctor[symbolThenPatched]) { + api.patchThen(ctor); + } + } + fetchPromise.then(function (resource) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + res(resource); + }, function (error) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + rej(error); + }); + }, function () { + if (!supportAbort) { + rej('No AbortController supported, can not cancel fetch'); + return; + } + if (signal && signal.abortController && !signal.aborted && + typeof signal.abortController.abort === 'function' && abortNative) { + try { + Zone.current[fetchTaskAborting] = true; + abortNative.call(signal.abortController); + } + finally { + Zone.current[fetchTaskAborting] = false; + } + } + else { + rej('cancel fetch need a AbortController.signal'); + } + }); + if (signal && signal.abortController) { + signal.abortController.task = task; + } + }); + }; +}); + +}))); diff --git a/dist/zone-patch-fetch.min.js b/dist/zone-patch-fetch.min.js new file mode 100644 index 000000000..29c5d0db0 --- /dev/null +++ b/dist/zone-patch-fetch.min.js @@ -0,0 +1 @@ +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";Zone.__load_patch("fetch",function(t,n,o){var e=t.fetch;if("function"==typeof e){var r=t[o.symbol("fetch")];r&&(e=r);var c=t.Promise,l=o.symbol("thenPatched"),a=o.symbol("fetchTaskScheduling"),f=o.symbol("fetchTaskAborting"),i=t.AbortController,u="function"==typeof i,s=null;u&&(t.AbortController=function(){var t=new i;return t.signal.abortController=t,t},s=o.patchMethod(i.prototype,"abort",function(t){return function(n,o){return n.task?n.task.zone.cancelTask(n.task):t.apply(n,o)}}));var h=function(){};t.fetch=function(){var t=this,r=Array.prototype.slice.call(arguments),i=r.length>1?r[1]:null,d=i&&i.signal;return new Promise(function(i,p){var b=n.current.scheduleMacroTask("fetch",h,{fetchArgs:r},function(){var f,u=n.current;try{u[a]=!0,f=e.apply(t,r)}catch(t){return void p(t)}finally{u[a]=!1}if(!(f instanceof c)){var s=f.constructor;s[l]||o.patchThen(s)}f.then(function(t){"notScheduled"!==b.state&&b.invoke(),i(t)},function(t){"notScheduled"!==b.state&&b.invoke(),p(t)})},function(){if(u)if(d&&d.abortController&&!d.aborted&&"function"==typeof d.abortController.abort&&s)try{n.current[f]=!0,s.call(d.abortController)}finally{n.current[f]=!1}else p("cancel fetch need a AbortController.signal");else p("No AbortController supported, can not cancel fetch")});d&&d.abortController&&(d.abortController.task=b)})}}})}); \ No newline at end of file diff --git a/dist/zone-patch-jsonp.min.js b/dist/zone-patch-jsonp.min.js index 6d8881776..854d97b9b 100644 --- a/dist/zone-patch-jsonp.min.js +++ b/dist/zone-patch-jsonp.min.js @@ -1 +1 @@ -!function(n,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("jsonp",function(n,o,e){o[o.__symbol__("jsonp")]=function(t){if(t&&t.jsonp&&t.sendFuncName){var c=function(){};[t.successFuncName,t.failedFuncName].forEach(function(o){if(o){var t=n[o];t?e.patchMethod(n,o,function(o){return function(t,c){var s=n[e.symbol("jsonTask")];return s?(s.callback=o,s.invoke.apply(t,c)):o.apply(t,c)}}):Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:function(){return function(){var t=n[e.symbol("jsonpTask")],c=n[e.symbol("jsonp"+o+"callback")];return t?(c&&(t.callback=c),n[e.symbol("jsonpTask")]=void 0,t.invoke.apply(this,arguments)):c?c.apply(this,arguments):null}},set:function(n){this[e.symbol("jsonp"+o+"callback")]=n}})}}),e.patchMethod(t.jsonp,t.sendFuncName,function(t){return function(s,a){n[e.symbol("jsonpTask")]=o.current.scheduleMacroTask("jsonp",c,{},function(n){return t.apply(s,a)},c)}})}}})}); \ No newline at end of file +!function(n,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("jsonp",function(n,o,e){o[o.__symbol__("jsonp")]=function(t){if(t&&t.jsonp&&t.sendFuncName){var c=function(){};[t.successFuncName,t.failedFuncName].forEach(function(o){o&&(n[o]?e.patchMethod(n,o,function(o){return function(t,c){var s=n[e.symbol("jsonTask")];return s?(s.callback=o,s.invoke.apply(t,c)):o.apply(t,c)}}):Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:function(){return function(){var t=n[e.symbol("jsonpTask")],c=n[e.symbol("jsonp"+o+"callback")];return t?(c&&(t.callback=c),n[e.symbol("jsonpTask")]=void 0,t.invoke.apply(this,arguments)):c?c.apply(this,arguments):null}},set:function(n){this[e.symbol("jsonp"+o+"callback")]=n}}))}),e.patchMethod(t.jsonp,t.sendFuncName,function(t){return function(s,a){n[e.symbol("jsonpTask")]=o.current.scheduleMacroTask("jsonp",c,{},function(n){return t.apply(s,a)},c)}})}}})}); \ No newline at end of file diff --git a/dist/zone-patch-promise-test.min.js b/dist/zone-patch-promise-test.min.js index 55ac90a8c..276e491e8 100644 --- a/dist/zone-patch-promise-test.min.js +++ b/dist/zone-patch-promise-test.min.js @@ -1 +1 @@ -!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(this,function(){"use strict";Zone.__load_patch("promisefortest",function(e,o,n){var t=n.symbol("state"),s=null,r=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e||(e=Promise[o.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var n=e.apply(this,arguments);if(this[t]===s){var i=o.current.get("AsyncTestZoneSpec");i&&(i.unresolvedChainedPromiseCount++,n[r]=!0)}return n})},Promise[n.symbol("unPatchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e&&(Promise.prototype.then=e,Promise[o.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file +!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("promisefortest",function(e,o,n){var t=n.symbol("state"),s=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e||(e=Promise[o.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var n=e.apply(this,arguments);if(null===this[t]){var r=o.current.get("AsyncTestZoneSpec");r&&(r.unresolvedChainedPromiseCount++,n[s]=!0)}return n})},Promise[n.symbol("unPatchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e&&(Promise.prototype.then=e,Promise[o.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js index 4762c8bc7..b118bc8d4 100644 --- a/dist/zone-patch-resize-observer.min.js +++ b/dist/zone-patch-resize-observer.min.js @@ -1 +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){var n="function"==typeof Symbol&&e[Symbol.iterator],r=0;return n?n.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o,a,c=this,f={},l=r.current;try{for(var p=e(n),v=p.next();!v.done;v=p.next()){var s=v.value,h=s.target[i];h||(h=l);var d=f[h.name];d||(f[h.name]=d={entries:[],zone:h}),d.entries.push(s)}}catch(y){o={error:y}}finally{try{v&&!v.done&&(a=p["return"])&&a.call(p)}finally{if(o)throw o.error}}Object.keys(f).forEach(function(e){var n=f[e];n.zone!==r.current?n.zone.run(u,c,[n.entries,t],"ResizeObserver"):u.call(c,n.entries,t)})}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o,a,c=this,f={},l=r.current;try{for(var p=e(n),v=p.next();!v.done;v=p.next()){var s=v.value,h=s.target[i];h||(h=l);var d=f[h.name];d||(f[h.name]=d={entries:[],zone:h}),d.entries.push(s)}}catch(e){o={error:e}}finally{try{v&&!v.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}Object.keys(f).forEach(function(e){var n=f[e];n.zone!==r.current?n.zone.run(u,c,[n.entries,t],"ResizeObserver"):u.call(c,n.entries,t)})}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u 1 ? args[1] : null; - var signal = options && options.signal; - return new Promise(function (res, rej) { - var task = Zone.current.scheduleMacroTask('fetch', placeholder, args, function () { - var fetchPromise; - var zone = Zone.current; - try { - zone[fetchTaskScheduling] = true; - fetchPromise = fetch.apply(_this, args); - } - catch (error) { - rej(error); - return; - } - finally { - zone[fetchTaskScheduling] = false; - } - if (!(fetchPromise instanceof ZoneAwarePromise)) { - var ctor = fetchPromise.constructor; - if (!ctor[symbolThenPatched]) { - api.patchThen(ctor); - } - } - fetchPromise.then(function (resource) { - if (task.state !== 'notScheduled') { - task.invoke(); - } - res(resource); - }, function (error) { - if (task.state !== 'notScheduled') { - task.invoke(); - } - rej(error); - }); - }, function () { - if (!supportAbort) { - rej('No AbortController supported, can not cancel fetch'); - return; - } - if (signal && signal.abortController && !signal.aborted && - typeof signal.abortController.abort === 'function' && abortNative) { - try { - Zone.current[fetchTaskAborting] = true; - abortNative.call(signal.abortController); - } - finally { - Zone.current[fetchTaskAborting] = false; - } - } - else { - rej('cancel fetch need a AbortController.signal'); - } - }); - if (signal && signal.abortController) { - signal.abortController.task = task; - } - }); - }; -}); - /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1625,10 +1574,10 @@ function isIEOrEdge() { if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } - return ieOrEdge; } catch (error) { } + return ieOrEdge; } /** @@ -1651,7 +1600,7 @@ Zone.__load_patch('toString', function (global) { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { if (typeof originalDelegate === 'function') { - return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); + return originalFunctionToString.call(originalDelegate); } else { return Object.prototype.toString.call(originalDelegate); @@ -1660,17 +1609,17 @@ Zone.__load_patch('toString', function (global) { if (this === Promise) { var nativePromise = global[PROMISE_SYMBOL]; if (nativePromise) { - return originalFunctionToString.apply(nativePromise, arguments); + return originalFunctionToString.call(nativePromise); } } if (this === Error) { var nativeError = global[ERROR_SYMBOL]; if (nativeError) { - return originalFunctionToString.apply(nativeError, arguments); + return originalFunctionToString.call(nativeError); } } } - return originalFunctionToString.apply(this, arguments); + return originalFunctionToString.call(this); }; newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; Function.prototype.toString = newFunctionToString; @@ -1681,7 +1630,7 @@ Zone.__load_patch('toString', function (global) { if (this instanceof Promise) { return PROMISE_OBJECT_TO_STRING; } - return originalObjectToString.apply(this, arguments); + return originalObjectToString.call(this); }; }); @@ -2263,124 +2212,35 @@ function patchEventPrototype(global, api) { * 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 */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; - } - } - } - } - data.args[0] = timer; - data.handleId = setNative.apply(window, data.args); - return task; - } - function clearTask(task) { - return clearNative(task.data.handleId); +function patchCallbacks(api, target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; } - setNative = - patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === 'function') { - var options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); - } - if (typeof handle === 'number' || handle) { - return 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; - } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + var source = targetName + "." + method + "::" + callback; + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); } - else if (id) { - id[taskSymbol] = null; + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); } - // Do not cancel already canceled functions - task.zone.cancelTask(task); } - } - else { - // cause an error by calling it directly. - delegate.apply(window, args); - } - }; }); + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); } /** @@ -2394,11 +2254,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { * This is necessary for Chrome and Chrome mobile, to enable * things like redefining `createdCallback` on an element. */ -var _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty; -var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = +var zoneSymbol$1 = Zone.__symbol__; +var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; +var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; var _create = Object.create; -var unconfigurablesKey = zoneSymbol('unconfigurables'); +var unconfigurablesKey = zoneSymbol$1('unconfigurables'); function propertyPatch() { Object.defineProperty = function (obj, prop, desc) { if (isUnconfigurable(obj, prop)) { @@ -2490,60 +2351,6 @@ function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { } } -/** - * @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 -function apply(api, _global) { - var WS = _global.WebSocket; - // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener - // On older Chrome, no need since EventTarget was already patched - if (!_global.EventTarget) { - patchEventTarget(_global, [WS.prototype]); - } - _global.WebSocket = function (x, y) { - var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); - var proxySocket; - var proxySocketProto; - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = ObjectCreate(socket); - // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' - // but proxySocket not, so we will keep socket as prototype and pass it to - // patchOnProperties method - proxySocketProto = socket; - [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { - proxySocket[propName] = function () { - var args = ArraySlice.call(arguments); - if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { - var eventName = args.length > 0 ? args[0] : undefined; - if (eventName) { - var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); - socket[propertySymbol] = proxySocket[propertySymbol]; - } - } - return socket[propName].apply(socket, args); - }; - }); - } - else { - // we can patch the real socket - proxySocket = socket; - } - patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); - return proxySocket; - }; - var globalWebSocket = _global['WebSocket']; - for (var prop in WS) { - globalWebSocket[prop] = WS[prop]; - } -} - /** * @license * Copyright Google Inc. All Rights Reserved. @@ -2792,144 +2599,111 @@ function propertyDescriptorPatch(api, _global) { if (isNode && !isMix) { return; } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } var supportsWebSocket = typeof WebSocket !== 'undefined'; - if (canPatchViaPropertyDescriptor()) { - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); - } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); - } - } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - var XMLHttpRequestEventTarget_1 = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - patchFilteredProperties(XMLHttpRequestEventTarget_1 && XMLHttpRequestEventTarget_1.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } } - else { - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(); - patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - apply(api, _global); - } + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); } } -function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) - return false; - } - var ON_READY_STATE_CHANGE = 'onreadystatechange'; - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - var xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return true; - } - }); - var req = new XMLHttpRequest(); - var result = !!req.onreadystatechange; - // restore original desc - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } - else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fake'); - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; - }, - set: function (value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; - } - }); - var req = new XMLHttpRequest(); - var detectFunc = function () { }; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; - req.onreadystatechange = null; - return result; + +/** + * @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.__load_patch('util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; } -} -var unboundKey = zoneSymbol('unbound'); -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents() { - var _loop_1 = function (i) { - var property = eventNames[i]; - var onproperty = 'on' + property; - self.addEventListener(property, function (event) { - var elt = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } - else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; - } - elt = elt.parentElement; - } - }, true); - }; - for (var i = 0; i < eventNames.length; i++) { - _loop_1(i); + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; } -} + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = function () { return ({ + globalSources: globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames: eventNames, + isBrowser: isBrowser, + isMix: isMix, + isNode: isNode, + TRUE_STR: TRUE_STR, + FALSE_STR: FALSE_STR, + ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR + }); }; +}); /** * @license @@ -2938,7 +2712,16 @@ function patchViaCapturingAllTheEvents() { * 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 eventTargetPatch(_global, api) { + +/** + * @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 eventTargetLegacyPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; 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,WebSocket' .split(','); @@ -2951,7 +2734,7 @@ function eventTargetPatch(_global, api) { apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); + // EventTarget is already patched in browser.ts } else { // Note: EventTarget is not available in all browsers, @@ -2960,7 +2743,7 @@ function eventTargetPatch(_global, api) { } var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - var ieOrEdge = isIEOrEdge(); + var ieOrEdge = api.isIEOrEdge(); var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; var FUNCTION_WRAPPER = '[object FunctionWrapper]'; var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; @@ -2971,9 +2754,9 @@ function eventTargetPatch(_global, api) { var trueEventName = eventName + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; } // predefine all task.source string for (var i = 0; i < WTF_ISSUE_555.length; i++) { @@ -3025,13 +2808,9 @@ function eventTargetPatch(_global, api) { } // vh is validateHandler to check event handler // is valid or not(for security check) - patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); - api.patchEventTarget = patchEventTarget; + api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); return true; } -function patchEvent(global, api) { - patchEventPrototype(global, api); -} /** * @license @@ -3040,49 +2819,379 @@ function patchEvent(global, api) { * 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 patchCallbacks(target, targetName, method, callbacks) { - var symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; +// we have to patch the instance since the proto is non-configurable +function apply(api, _global) { + var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; + var WS = _global.WebSocket; + // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener + // On older Chrome, no need since EventTarget was already patched + if (!_global.EventTarget) { + api.patchEventTarget(_global, [WS.prototype]); } - var nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - var source = targetName + "." + method + "::" + callback; - var prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = wrapWithCurrentZone(descriptor.value, source); - _redefineProperty(opts.prototype, callback, descriptor); - } - else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); + var proxySocket; + var proxySocketProto; + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = api.ObjectCreate(socket); + // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' + // but proxySocket not, so we will keep socket as prototype and pass it to + // patchOnProperties method + proxySocketProto = socket; + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { + proxySocket[propName] = function () { + var args = api.ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { + var eventName = args.length > 0 ? args[0] : undefined; + if (eventName) { + var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + socket[propertySymbol] = proxySocket[propertySymbol]; + } } - } - else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } + return socket[propName].apply(socket, args); + }; }); } - return nativeDelegate.call(target, name, opts, options); + else { + // we can patch the real socket + proxySocket = socket; + } + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + return proxySocket; }; - attachOriginToPatched(target[method], nativeDelegate); + var globalWebSocket = _global['WebSocket']; + for (var prop in WS) { + globalWebSocket[prop] = WS[prop]; + } +} + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ +function propertyDescriptorLegacyPatch(api, _global) { + var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; + if (isNode && !isMix) { + return; + } + var supportsWebSocket = typeof WebSocket !== 'undefined'; + if (!canPatchViaPropertyDescriptor(api)) { + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + apply(api, _global); + } + Zone[api.symbol('patchEvents')] = true; + } } -function registerElementPatch(_global) { +function canPatchViaPropertyDescriptor(api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) + return false; + } + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var req = new XMLHttpRequest(); + var result = !!req.onreadystatechange; + // restore original desc + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + return result; + } + else { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; + }, + set: function (value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; + } + }); + var req = new XMLHttpRequest(); + var detectFunc = function () { }; + req.onreadystatechange = detectFunc; + var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = null; + return result; + } +} +// Whenever any eventListener fires, we check the eventListener target and all parents +// for `onwhatever` properties and replace them with zone-bound functions +// - Chrome (for now) +function patchViaCapturingAllTheEvents(api) { + var eventNames = api.getGlobalObjects().eventNames; + var unboundKey = api.symbol('unbound'); + var _loop_1 = function (i) { + var property = eventNames[i]; + var onproperty = 'on' + property; + self.addEventListener(property, function (event) { + var elt = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; + } + else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = api.wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; + } + elt = elt.parentElement; + } + }, true); + }; + for (var i = 0; i < eventNames.length; i++) { + _loop_1(i); + } +} + +/** + * @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, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { return; } var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - patchCallbacks(document, 'Document', 'registerElement', callbacks); + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); } -function patchCustomElements(_global) { + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +(function (_global) { + _global['__zone_symbol__legacyPatch'] = function () { + var Zone = _global['Zone']; + Zone.__load_patch('registerElement', function (global, Zone, api) { + registerElementPatch(global, api); + }); + Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); + }; +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +var taskSymbol = zoneSymbol('zoneTask'); +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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } + } + } + data.args[0] = timer; + 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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return 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 id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // 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 + */ +function patchCustomElements(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((!isBrowser && !isMix) || !('customElements' in _global)) { return; } var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); +} + +/** + * @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 eventTargetPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; +} +function patchEvent$1(global, api) { + api.patchEventPrototype(global, api); } /** @@ -3096,10 +3205,11 @@ function patchCustomElements(_global) { * @fileoverview * @suppress {missingRequire} */ -Zone.__load_patch('util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; +Zone.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } }); Zone.__load_patch('timers', function (global) { var set = 'set'; @@ -3125,12 +3235,7 @@ Zone.__load_patch('blocking', function (global, Zone) { } }); Zone.__load_patch('EventTarget', function (global, Zone, api) { - // load blackListEvents from global - var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; - } - patchEvent(global, api); + patchEvent$1(global, api); eventTargetPatch(global, api); // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; @@ -3147,17 +3252,7 @@ Zone.__load_patch('on_property', function (global, Zone, api) { propertyPatch(); }); Zone.__load_patch('customElements', function (global, Zone, api) { - registerElementPatch(global); - patchCustomElements(global); -}); -Zone.__load_patch('canvas', function (global) { - var HTMLCanvasElement = global['HTMLCanvasElement']; - if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && - HTMLCanvasElement.prototype.toBlob) { - patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; - }); - } + patchCustomElements(global, api); }); Zone.__load_patch('XHR', function (global, Zone) { // Treat XMLHttpRequest as a macrotask. @@ -3354,6 +3449,17 @@ Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { * @fileoverview * @suppress {globalThis} */ +var __assign = (undefined && undefined.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var NEWLINE = '\n'; var IGNORE_FRAMES = {}; var creationTrace = '__creationTrace__'; @@ -3443,6 +3549,14 @@ Zone['longStackTraceZoneSpec'] = { } if (!task.data) task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = __assign({}, task.data); + } task.data[creationTrace] = trace; } return parentZoneDelegate.scheduleTask(targetZone, task); @@ -3749,6 +3863,30 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -3902,7 +4040,12 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var proxyZoneSpec = this && this.testProxyZoneSpec; if (proxyZoneSpec) { var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - error.message += pendingTasksInfo; + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } } } if (onException) { @@ -4236,8 +4379,6 @@ var __spread = (undefined && undefined.__spread) || function () { }; var Scheduler = /** @class */ (function () { function Scheduler() { - // Next scheduler id. - this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. @@ -4259,7 +4400,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (isPeriodic === void 0) { isPeriodic = false; } if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } if (id === void 0) { id = -1; } - var currentId = id < 0 ? this.nextId++ : id; + var currentId = id < 0 ? Scheduler.nextId++ : id; var endTime = this._currentTime + delay; // Insert so that scheduler queue remains sorted by end time. var newEntry = { @@ -4376,6 +4517,8 @@ var __spread = (undefined && undefined.__spread) || function () { } return this._currentTime - startTime; }; + // Next scheduler id. + Scheduler.nextId = 1; return Scheduler; }()); var FakeAsyncTestZoneSpec = /** @class */ (function () { @@ -4456,7 +4599,7 @@ var __spread = (undefined && undefined.__spread) || function () { }; FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); // Queue the callback and dequeue the timer on success and error. var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); @@ -4470,7 +4613,7 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.removeScheduledFunctionWithId(id); }; FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = this._scheduler.nextId; + var id = Scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); // Use the callback created above to requeue on success. @@ -4500,6 +4643,14 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.setCurrentRealTime(realTime); }; FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } if (global['Date'] === FakeDate) { // already patched return; diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 28d496d71..1114a410a 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -630,6 +630,7 @@ var Zone$1 = (function (global) { patchMethod: function () { return noop; }, bindArguments: function () { return []; }, patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -638,6 +639,19 @@ var Zone$1 = (function (global) { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } }; var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; var _currentTask = null; @@ -660,6 +674,13 @@ var __values = (undefined && undefined.__values) || function (o) { } }; }; +/** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -931,10 +952,10 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { reject = rej; }); function onResolve(value) { - promise && (promise = null || resolve(value)); + resolve(value); } function onReject(error) { - promise && (promise = null || reject(error)); + reject(error); } try { for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { @@ -1002,6 +1023,13 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } return promise; }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true + }); ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); var zone = Zone.current; @@ -1096,8 +1124,26 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Ctor[symbolThenPatched] = true; } api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } if (NativePromise) { patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); + } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; @@ -1458,7 +1504,7 @@ Zone.__load_patch('toString', function (global) { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { if (typeof originalDelegate === 'function') { - return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); + return originalFunctionToString.call(originalDelegate); } else { return Object.prototype.toString.call(originalDelegate); @@ -1467,17 +1513,17 @@ Zone.__load_patch('toString', function (global) { if (this === Promise) { var nativePromise = global[PROMISE_SYMBOL]; if (nativePromise) { - return originalFunctionToString.apply(nativePromise, arguments); + return originalFunctionToString.call(nativePromise); } } if (this === Error) { var nativeError = global[ERROR_SYMBOL]; if (nativeError) { - return originalFunctionToString.apply(nativeError, arguments); + return originalFunctionToString.call(nativeError); } } } - return originalFunctionToString.apply(this, arguments); + return originalFunctionToString.call(this); }; newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; Function.prototype.toString = newFunctionToString; @@ -1488,7 +1534,7 @@ Zone.__load_patch('toString', function (global) { if (this instanceof Promise) { return PROMISE_OBJECT_TO_STRING; } - return originalObjectToString.apply(this, arguments); + return originalObjectToString.call(this); }; }); @@ -1503,6 +1549,7 @@ Zone.__load_patch('node_util', function (global, Zone, api) { api.patchOnProperties = patchOnProperties; api.patchMethod = patchMethod; api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; setShouldCopySymbolProperties(true); }); @@ -2446,6 +2493,17 @@ Zone.__load_patch('console', function (global, Zone) { * @fileoverview * @suppress {globalThis} */ +var __assign = (undefined && undefined.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var NEWLINE = '\n'; var IGNORE_FRAMES = {}; var creationTrace = '__creationTrace__'; @@ -2535,6 +2593,14 @@ Zone['longStackTraceZoneSpec'] = { } if (!task.data) task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = __assign({}, task.data); + } task.data[creationTrace] = trace; } return parentZoneDelegate.scheduleTask(targetZone, task); @@ -2841,6 +2907,30 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -2994,7 +3084,12 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var proxyZoneSpec = this && this.testProxyZoneSpec; if (proxyZoneSpec) { var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - error.message += pendingTasksInfo; + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } } } if (onException) { @@ -3328,8 +3423,6 @@ var __spread = (undefined && undefined.__spread) || function () { }; var Scheduler = /** @class */ (function () { function Scheduler() { - // Next scheduler id. - this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. @@ -3351,7 +3444,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (isPeriodic === void 0) { isPeriodic = false; } if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } if (id === void 0) { id = -1; } - var currentId = id < 0 ? this.nextId++ : id; + var currentId = id < 0 ? Scheduler.nextId++ : id; var endTime = this._currentTime + delay; // Insert so that scheduler queue remains sorted by end time. var newEntry = { @@ -3468,6 +3561,8 @@ var __spread = (undefined && undefined.__spread) || function () { } return this._currentTime - startTime; }; + // Next scheduler id. + Scheduler.nextId = 1; return Scheduler; }()); var FakeAsyncTestZoneSpec = /** @class */ (function () { @@ -3548,7 +3643,7 @@ var __spread = (undefined && undefined.__spread) || function () { }; FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); // Queue the callback and dequeue the timer on success and error. var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); @@ -3562,7 +3657,7 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.removeScheduledFunctionWithId(id); }; FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = this._scheduler.nextId; + var id = Scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); // Use the callback created above to requeue on success. @@ -3592,6 +3687,14 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.setCurrentRealTime(realTime); }; FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } if (global['Date'] === FakeDate) { // already patched return; diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 8d59251d7..221d8d75e 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -22,6 +22,17 @@ * @fileoverview * @suppress {globalThis} */ +var __assign = (undefined && undefined.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; var NEWLINE = '\n'; var IGNORE_FRAMES = {}; var creationTrace = '__creationTrace__'; @@ -111,6 +122,14 @@ Zone['longStackTraceZoneSpec'] = { } if (!task.data) task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = __assign({}, task.data); + } task.data[creationTrace] = trace; } return parentZoneDelegate.scheduleTask(targetZone, task); @@ -417,6 +436,30 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. var jasmineEnv = jasmine.getEnv(); ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { @@ -570,7 +613,12 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var proxyZoneSpec = this && this.testProxyZoneSpec; if (proxyZoneSpec) { var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - error.message += pendingTasksInfo; + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } } } if (onException) { @@ -904,8 +952,6 @@ var __spread = (undefined && undefined.__spread) || function () { }; var Scheduler = /** @class */ (function () { function Scheduler() { - // Next scheduler id. - this.nextId = 1; // Scheduler queue with the tuple of end time and callback function - sorted by end time. this._schedulerQueue = []; // Current simulated time in millis. @@ -927,7 +973,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (isPeriodic === void 0) { isPeriodic = false; } if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } if (id === void 0) { id = -1; } - var currentId = id < 0 ? this.nextId++ : id; + var currentId = id < 0 ? Scheduler.nextId++ : id; var endTime = this._currentTime + delay; // Insert so that scheduler queue remains sorted by end time. var newEntry = { @@ -1044,6 +1090,8 @@ var __spread = (undefined && undefined.__spread) || function () { } return this._currentTime - startTime; }; + // Next scheduler id. + Scheduler.nextId = 1; return Scheduler; }()); var FakeAsyncTestZoneSpec = /** @class */ (function () { @@ -1124,7 +1172,7 @@ var __spread = (undefined && undefined.__spread) || function () { }; FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(this._scheduler.nextId); + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); // Queue the callback and dequeue the timer on success and error. var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); @@ -1138,7 +1186,7 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.removeScheduledFunctionWithId(id); }; FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = this._scheduler.nextId; + var id = Scheduler.nextId; var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; var cb = this._fnAndFlush(fn, completers); // Use the callback created above to requeue on success. @@ -1168,6 +1216,14 @@ var __spread = (undefined && undefined.__spread) || function () { this._scheduler.setCurrentRealTime(realTime); }; FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } if (global['Date'] === FakeDate) { // already patched return; diff --git a/dist/zone.js b/dist/zone.js index 80463ae48..f812a3b72 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -630,6 +630,7 @@ var Zone$1 = (function (global) { patchMethod: function () { return noop; }, bindArguments: function () { return []; }, patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, setNativePromise: function (NativePromise) { // sometimes NativePromise.resolve static function // is not ready yet, (such as core-js/es6.promise) @@ -638,6 +639,19 @@ var Zone$1 = (function (global) { nativeMicroTaskQueuePromise = NativePromise.resolve(0); } }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } }; var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; var _currentTask = null; @@ -660,6 +674,13 @@ var __values = (undefined && undefined.__values) || function (o) { } }; }; +/** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; var ObjectDefineProperty = Object.defineProperty; @@ -931,10 +952,10 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { reject = rej; }); function onResolve(value) { - promise && (promise = null || resolve(value)); + resolve(value); } function onReject(error) { - promise && (promise = null || reject(error)); + reject(error); } try { for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { @@ -1002,6 +1023,13 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { } return promise; }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true + }); ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { var chainPromise = new this.constructor(null); var zone = Zone.current; @@ -1096,111 +1124,32 @@ Zone.__load_patch('ZoneAwarePromise', function (global, Zone, api) { Ctor[symbolThenPatched] = true; } api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } if (NativePromise) { patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); + } } // This is not part of public API, but it is useful for tests, so we expose it. Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; return ZoneAwarePromise; }); -/** - * @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.__load_patch('fetch', function (global, Zone, api) { - var fetch = global['fetch']; - var ZoneAwarePromise = global.Promise; - var symbolThenPatched = api.symbol('thenPatched'); - var fetchTaskScheduling = api.symbol('fetchTaskScheduling'); - var fetchTaskAborting = api.symbol('fetchTaskAborting'); - if (typeof fetch !== 'function') { - return; - } - var OriginalAbortController = global['AbortController']; - var supportAbort = typeof OriginalAbortController === 'function'; - var abortNative = null; - if (supportAbort) { - global['AbortController'] = function () { - var abortController = new OriginalAbortController(); - var signal = abortController.signal; - signal.abortController = abortController; - return abortController; - }; - abortNative = api.patchMethod(OriginalAbortController.prototype, 'abort', function (delegate) { return function (self, args) { - if (self.task) { - return self.task.zone.cancelTask(self.task); - } - return delegate.apply(self, args); - }; }); - } - var placeholder = function () { }; - global['fetch'] = function () { - var _this = this; - var args = Array.prototype.slice.call(arguments); - var options = args.length > 1 ? args[1] : null; - var signal = options && options.signal; - return new Promise(function (res, rej) { - var task = Zone.current.scheduleMacroTask('fetch', placeholder, args, function () { - var fetchPromise; - var zone = Zone.current; - try { - zone[fetchTaskScheduling] = true; - fetchPromise = fetch.apply(_this, args); - } - catch (error) { - rej(error); - return; - } - finally { - zone[fetchTaskScheduling] = false; - } - if (!(fetchPromise instanceof ZoneAwarePromise)) { - var ctor = fetchPromise.constructor; - if (!ctor[symbolThenPatched]) { - api.patchThen(ctor); - } - } - fetchPromise.then(function (resource) { - if (task.state !== 'notScheduled') { - task.invoke(); - } - res(resource); - }, function (error) { - if (task.state !== 'notScheduled') { - task.invoke(); - } - rej(error); - }); - }, function () { - if (!supportAbort) { - rej('No AbortController supported, can not cancel fetch'); - return; - } - if (signal && signal.abortController && !signal.aborted && - typeof signal.abortController.abort === 'function' && abortNative) { - try { - Zone.current[fetchTaskAborting] = true; - abortNative.call(signal.abortController); - } - finally { - Zone.current[fetchTaskAborting] = false; - } - } - else { - rej('cancel fetch need a AbortController.signal'); - } - }); - if (signal && signal.abortController) { - signal.abortController.task = task; - } - }); - }; -}); - /** * @license * Copyright Google Inc. All Rights Reserved. @@ -1625,10 +1574,10 @@ function isIEOrEdge() { if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { ieOrEdge = true; } - return ieOrEdge; } catch (error) { } + return ieOrEdge; } /** @@ -1651,7 +1600,7 @@ Zone.__load_patch('toString', function (global) { var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; if (originalDelegate) { if (typeof originalDelegate === 'function') { - return originalFunctionToString.apply(this[ORIGINAL_DELEGATE_SYMBOL], arguments); + return originalFunctionToString.call(originalDelegate); } else { return Object.prototype.toString.call(originalDelegate); @@ -1660,17 +1609,17 @@ Zone.__load_patch('toString', function (global) { if (this === Promise) { var nativePromise = global[PROMISE_SYMBOL]; if (nativePromise) { - return originalFunctionToString.apply(nativePromise, arguments); + return originalFunctionToString.call(nativePromise); } } if (this === Error) { var nativeError = global[ERROR_SYMBOL]; if (nativeError) { - return originalFunctionToString.apply(nativeError, arguments); + return originalFunctionToString.call(nativeError); } } } - return originalFunctionToString.apply(this, arguments); + return originalFunctionToString.call(this); }; newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; Function.prototype.toString = newFunctionToString; @@ -1681,7 +1630,7 @@ Zone.__load_patch('toString', function (global) { if (this instanceof Promise) { return PROMISE_OBJECT_TO_STRING; } - return originalObjectToString.apply(this, arguments); + return originalObjectToString.call(this); }; }); @@ -2263,124 +2212,35 @@ function patchEventPrototype(global, api) { * 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 */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; - } - } - } - } - data.args[0] = timer; - data.handleId = setNative.apply(window, data.args); - return task; - } - function clearTask(task) { - return clearNative(task.data.handleId); +function patchCallbacks(api, target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; } - setNative = - patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === 'function') { - var options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); - } - if (typeof handle === 'number' || handle) { - return 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; - } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + var source = targetName + "." + method + "::" + callback; + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); } - else if (id) { - id[taskSymbol] = null; + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); } - // Do not cancel already canceled functions - task.zone.cancelTask(task); } - } - else { - // cause an error by calling it directly. - delegate.apply(window, args); - } - }; }); + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); } /** @@ -2394,11 +2254,12 @@ function patchTimer(window, setName, cancelName, nameSuffix) { * This is necessary for Chrome and Chrome mobile, to enable * things like redefining `createdCallback` on an element. */ -var _defineProperty = Object[zoneSymbol('defineProperty')] = Object.defineProperty; -var _getOwnPropertyDescriptor = Object[zoneSymbol('getOwnPropertyDescriptor')] = +var zoneSymbol$1 = Zone.__symbol__; +var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; +var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = Object.getOwnPropertyDescriptor; var _create = Object.create; -var unconfigurablesKey = zoneSymbol('unconfigurables'); +var unconfigurablesKey = zoneSymbol$1('unconfigurables'); function propertyPatch() { Object.defineProperty = function (obj, prop, desc) { if (isUnconfigurable(obj, prop)) { @@ -2490,60 +2351,6 @@ function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { } } -/** - * @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 -function apply(api, _global) { - var WS = _global.WebSocket; - // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener - // On older Chrome, no need since EventTarget was already patched - if (!_global.EventTarget) { - patchEventTarget(_global, [WS.prototype]); - } - _global.WebSocket = function (x, y) { - var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); - var proxySocket; - var proxySocketProto; - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = ObjectCreate(socket); - // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' - // but proxySocket not, so we will keep socket as prototype and pass it to - // patchOnProperties method - proxySocketProto = socket; - [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { - proxySocket[propName] = function () { - var args = ArraySlice.call(arguments); - if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { - var eventName = args.length > 0 ? args[0] : undefined; - if (eventName) { - var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); - socket[propertySymbol] = proxySocket[propertySymbol]; - } - } - return socket[propName].apply(socket, args); - }; - }); - } - else { - // we can patch the real socket - proxySocket = socket; - } - patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); - return proxySocket; - }; - var globalWebSocket = _global['WebSocket']; - for (var prop in WS) { - globalWebSocket[prop] = WS[prop]; - } -} - /** * @license * Copyright Google Inc. All Rights Reserved. @@ -2792,144 +2599,111 @@ function propertyDescriptorPatch(api, _global) { if (isNode && !isMix) { return; } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - if (canPatchViaPropertyDescriptor()) { - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); - } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); - } - } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - var XMLHttpRequestEventTarget_1 = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - patchFilteredProperties(XMLHttpRequestEventTarget_1 && XMLHttpRequestEventTarget_1.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; } - else { - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(); - patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - apply(api, _global); - } + var supportsWebSocket = typeof WebSocket !== 'undefined'; + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + } + } + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); } } -function canPatchViaPropertyDescriptor() { - if ((isBrowser || isMix) && !ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) - return false; - } - var ON_READY_STATE_CHANGE = 'onreadystatechange'; - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - var xhrDesc = ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return true; - } - }); - var req = new XMLHttpRequest(); - var result = !!req.onreadystatechange; - // restore original desc - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } - else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = zoneSymbol('fake'); - ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; - }, - set: function (value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; - } - }); - var req = new XMLHttpRequest(); - var detectFunc = function () { }; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; - req.onreadystatechange = null; - return result; + +/** + * @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.__load_patch('util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; } -} -var unboundKey = zoneSymbol('unbound'); -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents() { - var _loop_1 = function (i) { - var property = eventNames[i]; - var onproperty = 'on' + property; - self.addEventListener(property, function (event) { - var elt = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } - else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; - } - elt = elt.parentElement; - } - }, true); - }; - for (var i = 0; i < eventNames.length; i++) { - _loop_1(i); + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; } -} + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = function () { return ({ + globalSources: globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames: eventNames, + isBrowser: isBrowser, + isMix: isMix, + isNode: isNode, + TRUE_STR: TRUE_STR, + FALSE_STR: FALSE_STR, + ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR + }); }; +}); /** * @license @@ -2938,7 +2712,16 @@ function patchViaCapturingAllTheEvents() { * 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 eventTargetPatch(_global, api) { + +/** + * @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 eventTargetLegacyPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; 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,WebSocket' .split(','); @@ -2951,7 +2734,7 @@ function eventTargetPatch(_global, api) { apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); + // EventTarget is already patched in browser.ts } else { // Note: EventTarget is not available in all browsers, @@ -2960,7 +2743,7 @@ function eventTargetPatch(_global, api) { } var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - var ieOrEdge = isIEOrEdge(); + var ieOrEdge = api.isIEOrEdge(); var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; var FUNCTION_WRAPPER = '[object FunctionWrapper]'; var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; @@ -2971,9 +2754,9 @@ function eventTargetPatch(_global, api) { var trueEventName = eventName + TRUE_STR; var symbol = ZONE_SYMBOL_PREFIX + falseEventName; var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; } // predefine all task.source string for (var i = 0; i < WTF_ISSUE_555.length; i++) { @@ -3025,13 +2808,9 @@ function eventTargetPatch(_global, api) { } // vh is validateHandler to check event handler // is valid or not(for security check) - patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); - api.patchEventTarget = patchEventTarget; + api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); return true; } -function patchEvent(global, api) { - patchEventPrototype(global, api); -} /** * @license @@ -3040,49 +2819,379 @@ function patchEvent(global, api) { * 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 patchCallbacks(target, targetName, method, callbacks) { - var symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; +// we have to patch the instance since the proto is non-configurable +function apply(api, _global) { + var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; + var WS = _global.WebSocket; + // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener + // On older Chrome, no need since EventTarget was already patched + if (!_global.EventTarget) { + api.patchEventTarget(_global, [WS.prototype]); } - var nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - var source = targetName + "." + method + "::" + callback; - var prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - var descriptor = ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = wrapWithCurrentZone(descriptor.value, source); - _redefineProperty(opts.prototype, callback, descriptor); - } - else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); + var proxySocket; + var proxySocketProto; + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = api.ObjectCreate(socket); + // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' + // but proxySocket not, so we will keep socket as prototype and pass it to + // patchOnProperties method + proxySocketProto = socket; + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { + proxySocket[propName] = function () { + var args = api.ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { + var eventName = args.length > 0 ? args[0] : undefined; + if (eventName) { + var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + socket[propertySymbol] = proxySocket[propertySymbol]; + } } - } - else if (prototype[callback]) { - prototype[callback] = wrapWithCurrentZone(prototype[callback], source); - } + return socket[propName].apply(socket, args); + }; }); } - return nativeDelegate.call(target, name, opts, options); + else { + // we can patch the real socket + proxySocket = socket; + } + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + return proxySocket; }; - attachOriginToPatched(target[method], nativeDelegate); + var globalWebSocket = _global['WebSocket']; + for (var prop in WS) { + globalWebSocket[prop] = WS[prop]; + } } -function registerElementPatch(_global) { + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {globalThis} + */ +function propertyDescriptorLegacyPatch(api, _global) { + var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; + if (isNode && !isMix) { + return; + } + var supportsWebSocket = typeof WebSocket !== 'undefined'; + if (!canPatchViaPropertyDescriptor(api)) { + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + apply(api, _global); + } + Zone[api.symbol('patchEvents')] = true; + } +} +function canPatchViaPropertyDescriptor(api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) + return false; + } + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var req = new XMLHttpRequest(); + var result = !!req.onreadystatechange; + // restore original desc + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + return result; + } + else { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; + }, + set: function (value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; + } + }); + var req = new XMLHttpRequest(); + var detectFunc = function () { }; + req.onreadystatechange = detectFunc; + var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = null; + return result; + } +} +// Whenever any eventListener fires, we check the eventListener target and all parents +// for `onwhatever` properties and replace them with zone-bound functions +// - Chrome (for now) +function patchViaCapturingAllTheEvents(api) { + var eventNames = api.getGlobalObjects().eventNames; + var unboundKey = api.symbol('unbound'); + var _loop_1 = function (i) { + var property = eventNames[i]; + var onproperty = 'on' + property; + self.addEventListener(property, function (event) { + var elt = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; + } + else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = api.wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; + } + elt = elt.parentElement; + } + }, true); + }; + for (var i = 0; i < eventNames.length; i++) { + _loop_1(i); + } +} + +/** + * @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, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { return; } var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - patchCallbacks(document, 'Document', 'registerElement', callbacks); + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); } -function patchCustomElements(_global) { + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +(function (_global) { + _global['__zone_symbol__legacyPatch'] = function () { + var Zone = _global['Zone']; + Zone.__load_patch('registerElement', function (global, Zone, api) { + registerElementPatch(global, api); + }); + Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); + }; +})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); + +/** + * @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 + */ +/** + * @fileoverview + * @suppress {missingRequire} + */ +var taskSymbol = zoneSymbol('zoneTask'); +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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } + } + } + data.args[0] = timer; + 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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return 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 id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // 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 + */ +function patchCustomElements(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((!isBrowser && !isMix) || !('customElements' in _global)) { return; } var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - patchCallbacks(_global.customElements, 'customElements', 'define', callbacks); + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); +} + +/** + * @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 eventTargetPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; +} +function patchEvent$1(global, api) { + api.patchEventPrototype(global, api); } /** @@ -3096,10 +3205,11 @@ function patchCustomElements(_global) { * @fileoverview * @suppress {missingRequire} */ -Zone.__load_patch('util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; +Zone.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } }); Zone.__load_patch('timers', function (global) { var set = 'set'; @@ -3125,12 +3235,7 @@ Zone.__load_patch('blocking', function (global, Zone) { } }); Zone.__load_patch('EventTarget', function (global, Zone, api) { - // load blackListEvents from global - var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_BLACK_LISTED_EVENTS]; - } - patchEvent(global, api); + patchEvent$1(global, api); eventTargetPatch(global, api); // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; @@ -3147,17 +3252,7 @@ Zone.__load_patch('on_property', function (global, Zone, api) { propertyPatch(); }); Zone.__load_patch('customElements', function (global, Zone, api) { - registerElementPatch(global); - patchCustomElements(global); -}); -Zone.__load_patch('canvas', function (global) { - var HTMLCanvasElement = global['HTMLCanvasElement']; - if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && - HTMLCanvasElement.prototype.toBlob) { - patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; - }); - } + patchCustomElements(global, api); }); Zone.__load_patch('XHR', function (global, Zone) { // Treat XMLHttpRequest as a macrotask. diff --git a/dist/zone.js.d.ts b/dist/zone.js.d.ts index 5420fe1ba..8a033d536 100644 --- a/dist/zone.js.d.ts +++ b/dist/zone.js.d.ts @@ -93,9 +93,9 @@ * yielding. * * - * ### [TimerTask] + * ### [MacroTask] * - * [TimerTask]s represent work which will be done after some delay. (Sometimes the delay is + * [MacroTask]s represent work which will be done after some delay. (Sometimes the delay is * approximate such as on next available animation frame). Typically these methods include: * `setTimeout`, `setImmediate`, `setInterval`, `requestAnimationFrame`, and all browser specific * variants. diff --git a/dist/zone.min.js b/dist/zone.min.js index 00515ef75..3c96665e7 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1,2 +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){return Zone.current.wrap(e,t)}function t(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}function n(t,n){for(var r=t.length-1;r>=0;r--)"function"==typeof t[r]&&(t[r]=e(t[r],n+"_"+r));return t}function r(e,t){for(var r=e.constructor.name,a=function(a){var i=t[a],s=e[i];if(s){var c=L(e,i);if(!o(c))return"continue";e[i]=function(e){var t=function(){return e.apply(this,n(arguments,r+"."+i))};return f(t,e),t}(s)}},i=0;i=0&&"function"==typeof a[i.cbIdx]?t(i.name,a[i.cbIdx],i,o):e.apply(n,a)}})}function f(e,t){e[U("OriginalDelegate")]=t}function p(){try{var e=K.navigator.userAgent;if(e.indexOf("MSIE ")!==-1||e.indexOf("Trident/")!==-1)return!0}catch(t){}return!1}function h(){if(se)return ce;se=!0;try{var e=K.navigator.userAgent;return e.indexOf("MSIE ")===-1&&e.indexOf("Trident/")===-1&&e.indexOf("Edge/")===-1||(ce=!0),ce}catch(t){}}function d(e,t,n){function r(t,n){function r(e){ue||"boolean"==typeof w.options||"undefined"==typeof w.options||null===w.options||(e.options=!!w.options.capture,w.options=e.options)}if(!t)return!1;var h=!0;n&&void 0!==n.useG&&(h=n.useG);var y=n&&n.vh,m=!0;n&&void 0!==n.chkDup&&(m=n.chkDup);var k=!1;n&&void 0!==n.rt&&(k=n.rt);for(var _=t;_&&!_.hasOwnProperty(o);)_=R(_);if(!_&&t[o]&&(_=t),!_)return!1;if(_[c])return!1;var b,T=n&&n.eventNameToString,w={},E=_[c]=_[o],S=_[U(a)]=_[a],D=_[U(i)]=_[i],Z=_[U(s)]=_[s];n&&n.prepend&&(b=_[U(n.prepend)]=_[n.prepend]);var z=function(e){if(!w.isExisting)return r(e),E.call(w.target,w.eventName,w.capture?g:d,w.options)},O=function(e){if(!e.isRemoved){var t=he[e.eventName],n=void 0;t&&(n=t[e.capture?W:X]);var r=n&&e.target[n];if(r)for(var o=0;o1?new n(e,t):new n(e),s=L(a,"onmessage");return s&&s.configurable===!1?(r=H(a),o=a,[A,B,"send","close"].forEach(function(e){r[e]=function(){var t=F.call(arguments);if(e===A||e===B){var n=t.length>0?t[0]:void 0;if(n){var o=Zone.__symbol__("ON_PROPERTY"+n);a[o]=r[o]}}return a[e].apply(a,t)}})):r=a,i(r,["close","error","message","open"],o),r};var r=t.WebSocket;for(var o in n)r[o]=n[o]}function E(e,t,n){if(!n||0===n.length)return t;var r=n.filter(function(t){return t.target===e});if(!r||0===r.length)return t;var o=r[0].ignoreProperties;return t.filter(function(e){return o.indexOf(e)===-1})}function S(e,t,n,r){if(e){var o=E(e,t,n);i(e,o,r)}}function D(e,t){if(!ee||ne){var n="undefined"!=typeof WebSocket;if(Z()){var r=t.__Zone_ignore_on_properties;if(te){var o=window,a=p?[{target:o,ignoreProperties:["error"]}]:[];S(o,He.concat(["messageerror"]),r?r.concat(a):r,R(o)),S(Document.prototype,He,r),"undefined"!=typeof o.SVGElement&&S(o.SVGElement.prototype,He,r),S(Element.prototype,He,r),S(HTMLElement.prototype,He,r),S(HTMLMediaElement.prototype,De,r),S(HTMLFrameSetElement.prototype,Ee.concat(je),r),S(HTMLBodyElement.prototype,Ee.concat(je),r),S(HTMLFrameElement.prototype,Ce,r),S(HTMLIFrameElement.prototype,Ce,r);var i=o.HTMLMarqueeElement;i&&S(i.prototype,Ie,r);var c=o.Worker;c&&S(c.prototype,Re,r)}S(XMLHttpRequest.prototype,Me,r);var u=t.XMLHttpRequestEventTarget;u&&S(u&&u.prototype,Me,r),"undefined"!=typeof IDBIndex&&(S(IDBIndex.prototype,Le,r),S(IDBRequest.prototype,Le,r),S(IDBOpenDBRequest.prototype,Le,r),S(IDBDatabase.prototype,Le,r),S(IDBTransaction.prototype,Le,r),S(IDBCursor.prototype,Le,r)),n&&S(WebSocket.prototype,xe,r)}else z(),s("XMLHttpRequest"),n&&w(e,t)}}function Z(){if((te||ne)&&!L(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var e=L(Element.prototype,"onclick");if(e&&!e.configurable)return!1}var t="onreadystatechange",n=XMLHttpRequest.prototype,r=L(n,t);if(r){x(n,t,{enumerable:!0,configurable:!0,get:function(){return!0}});var o=new XMLHttpRequest,a=!!o.onreadystatechange;return x(n,t,r||{}),a}var i=U("fake");x(n,t,{enumerable:!0,configurable:!0,get:function(){return this[i]},set:function(e){this[i]=e}});var o=new XMLHttpRequest,s=function(){};o.onreadystatechange=s;var a=o[i]===s;return o.onreadystatechange=null,a}function z(){for(var t=function(t){var n=He[t],r="on"+n;self.addEventListener(n,function(t){var n,o,a=t.target;for(o=a?a.constructor.name+"."+r:"unknown."+r;a;)a[r]&&!a[r][Fe]&&(n=e(a[r],o),n[Fe]=a[r],a[r]=n),a=a.parentElement},!0)},n=0;n",this._properties=t&&t.properties||{},this._zoneDelegate=new p(this,this._parent&&this._parent._zoneDelegate,t)}return r.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(r,"root",{get:function(){for(var e=r.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(r,"current",{get:function(){return C.zone},enumerable:!0,configurable:!0}),Object.defineProperty(r,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),r.__load_patch=function(o,a){if(O.hasOwnProperty(o)){if(c)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var i="Zone:"+o;t(i),O[o]=a(e,r,P),n(i,i)}},Object.defineProperty(r.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},r.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},r.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},r.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)}},r.prototype.run=function(e,t,n,r){C={parent:C,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{C=C.parent}},r.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),C={parent:C,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(o){if(this._zoneDelegate.handleError(this,o))throw o}}finally{C=C.parent}},r.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==z&&e.type!==Z){var r=e.state!=w;r&&e._transitionTo(w,T),e.runCount++;var o=j;j=e,C={parent:C,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(a){if(this._zoneDelegate.handleError(this,a))throw a}}finally{e.state!==_&&e.state!==S&&(e.type==z||e.data&&e.data.isPeriodic?r&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,w,_))),C=C.parent,j=o}}},r.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(r){throw e._transitionTo(S,b,_),this._zoneDelegate.handleError(this,r),r}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},r.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(D,e,t,n,r,(void 0)))},r.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},r.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(z,e,t,n,r,o))},r.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,E),e.runCount=0,e},r.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;t==-1&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),h=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===z&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&o(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&"undefined"!=typeof this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),d=i("setTimeout"),v=i("Promise"),g=i("then"),y=[],m=!1,k={name:"NO ZONE"},_="notScheduled",b="scheduling",T="scheduled",w="running",E="canceling",S="unknown",D="microTask",Z="macroTask",z="eventTask",O={},P={symbol:i,currentZoneFrame:function(){return C},onUnhandledError:a,microtaskDrainDone:a,scheduleMicroTask:r,showUncaughtError:function(){return!l[i("ignoreConsoleErrorUncaughtError")]},patchEventTarget:function(){return[]},patchOnProperties:a,patchMethod:function(){return a},bindArguments:function(){return[]},patchThen:function(){return a},setNativePromise:function(e){e&&"function"==typeof e.resolve&&(u=e.resolve(0))}},C={parent:null,zone:new l(null,null)},j=null,I=0;return n("Zone","Zone"),e.Zone=l}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global),function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}});Zone.__load_patch("ZoneAwarePromise",function(e,t,n){function r(e){if(e&&e.toString===Object.prototype.toString){var t=e.constructor&&e.constructor.name;return(t?t:"")+": "+JSON.stringify(e)}return e?e.toString():Object.prototype.toString.call(e)}function o(e){n.onUnhandledError(e);try{var r=t[_];r&&"function"==typeof r&&r.call(this,e)}catch(o){}}function a(e){return e&&e.then}function i(e){return e}function s(e){return R.reject(e)}function c(e,t){return function(n){try{u(e,t,n)}catch(r){u(e,!1,r)}}}function u(e,o,a){var i=C();if(e===a)throw new TypeError(j);if(e[b]===Z){var s=null;try{"object"!=typeof a&&"function"!=typeof a||(s=a&&a.then)}catch(p){return i(function(){u(e,!1,p)})(),e}if(o!==O&&a instanceof R&&a.hasOwnProperty(b)&&a.hasOwnProperty(T)&&a[b]!==Z)l(a),u(e,a[b],a[T]);else if(o!==O&&"function"==typeof s)try{s.call(a,i(c(e,o)),i(c(e,!1)))}catch(p){i(function(){u(e,!1,p)})()}else{e[b]=o;var h=e[T];if(e[T]=a,e[w]===w&&o===z&&(e[b]=e[S],e[T]=e[E]),o===O&&a instanceof Error){var v=t.currentTask&&t.currentTask.data&&t.currentTask.data[k];v&&d(a,I,{configurable:!0,enumerable:!1,writable:!0,value:v})}for(var y=0;y1?c[1]:null,h=p&&p.signal;return new Promise(function(p,d){var v=t.current.scheduleMacroTask("fetch",f,c,function(){var s,u=t.current;try{u[i]=!0,s=r.apply(e,c)}catch(l){return void d(l)}finally{u[i]=!1}if(!(s instanceof o)){var f=s.constructor;f[a]||n.patchThen(f)}s.then(function(e){"notScheduled"!==v.state&&v.invoke(),p(e)},function(e){"notScheduled"!==v.state&&v.invoke(),d(e)})},function(){if(!u)return void d("No AbortController supported, can not cancel fetch");if(h&&h.abortController&&!h.aborted&&"function"==typeof h.abortController.abort&&l)try{t.current[s]=!0,l.call(h.abortController)}finally{t.current[s]=!1}else d("cancel fetch need a AbortController.signal")});h&&h.abortController&&(h.abortController.task=v)})}}});var L=Object.getOwnPropertyDescriptor,x=Object.defineProperty,R=Object.getPrototypeOf,H=Object.create,F=Array.prototype.slice,A="addEventListener",B="removeEventListener",q=Zone.__symbol__(A),N=Zone.__symbol__(B),W="true",X="false",G="__zone_symbol__",U=Zone.__symbol__,V="undefined"!=typeof window,K=V?window:void 0,J=V&&K||"object"==typeof self&&self||global,Y="removeAttribute",Q=[null],$="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,ee=!("nw"in J)&&"undefined"!=typeof J.process&&"[object process]"==={}.toString.call(J.process),te=!ee&&!$&&!(!V||!K.HTMLElement),ne="undefined"!=typeof J.process&&"[object process]"==={}.toString.call(J.process)&&!$&&!(!V||!K.HTMLElement),re={},oe=function(e){if(e=e||J.event){var t=re[e.type];t||(t=re[e.type]=U("ON_PROPERTY"+e.type));var n,r=this||e.target||J,o=r[t];if(te&&r===K&&"error"===e.type){var a=e;n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error),n===!0&&e.preventDefault()}else n=o&&o.apply(this,arguments),void 0==n||n||e.preventDefault();return n}},ae=U("originalInstance"),ie=!1,se=!1,ce=!1;Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=U("OriginalDelegate"),r=U("Promise"),o=U("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.apply(this[n],arguments):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.apply(i,arguments)}if(this===Error){var s=e[o];if(s)return t.apply(s,arguments)}}return t.apply(this,arguments)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString,s="[object Promise]";Object.prototype.toString=function(){return this instanceof Promise?s:i.apply(this,arguments)}});var ue=!1;if("undefined"!=typeof window)try{var le=Object.defineProperty({},"passive",{get:function(){ue=!0}});window.addEventListener("test",le,le),window.removeEventListener("test",le,le)}catch(fe){ue=!1}var pe={useG:!0},he={},de={},ve=/^__zone_symbol__(\w+)(true|false)$/,ge="__zone_symbol__propagationStopped",ye=U("zoneTask"),me=Object[U("defineProperty")]=Object.defineProperty,ke=Object[U("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_e=Object.create,be=U("unconfigurables"),Te=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],we=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],Ee=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],Se=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],De=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],Ze=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],ze=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],Oe=["autocomplete","autocompleteerror"],Pe=["toggle"],Ce=["load"],je=["blur","error","focus","load","resize","scroll","messageerror"],Ie=["bounce","finish","start"],Me=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],Le=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],xe=["close","error","open","message"],Re=["error","message"],He=Te.concat(ze,Oe,Pe,we,Ee,Se,Ze),Fe=U("unbound");Zone.__load_patch("util",function(e,t,r){r.patchOnProperties=i,r.patchMethod=u,r.bindArguments=n}),Zone.__load_patch("timers",function(e){var t="set",n="clear";y(e,t,n,"Timeout"),y(e,t,n,"Interval"),y(e,t,n,"Immediate")}),Zone.__load_patch("requestAnimationFrame",function(e){y(e,"request","cancel","AnimationFrame"),y(e,"mozRequest","mozCancel","AnimationFrame"),y(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",function(e,t){for(var n=["alert","prompt","confirm"],r=0;r0){var o=e.invoke;e.invoke=function(){for(var r=n.__zone_symbol__loadfalse,a=0;a",this._properties=t&&t.properties||{},this._zoneDelegate=new c(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return Z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),t.__load_patch=function(a,i){if(P.hasOwnProperty(a)){if(o)throw Error("Already loaded patch: "+a)}else if(!e["__Zone_disable_"+a]){var s="Zone:"+a;n(s),P[a]=i(e,t,D),r(s,s)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){Z={parent:Z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{Z=Z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),Z={parent:Z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{Z=Z.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==O&&e.type!==S){var r=e.state!=k;r&&e._transitionTo(k,b),e.runCount++;var o=j;j=e,Z={parent:Z,zone:this};try{e.type==S&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==_&&e.state!==E&&(e.type==O||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,k):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,k,_))),Z=Z.parent,j=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(m,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,m,_),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==m&&e._transitionTo(b,m),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new l(w,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new l(S,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new l(O,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");e._transitionTo(T,b,k);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,T),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,T),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),l=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===O&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&g(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,m)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),u=I("setTimeout"),f=I("Promise"),p=I("then"),h=[],d=!1;function v(t){if(0===z&&0===h.length)if(a||e[f]&&(a=e[f].resolve(0)),a){var n=a[p];n||(n=a.then),n.call(a,g)}else e[u](g,0);t&&h.push(t)}function g(){if(!d){for(d=!0;h.length;){var e=h;h=[];for(var t=0;t=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Zone.__load_patch("ZoneAwarePromise",function(t,n,r){var o=Object.getOwnPropertyDescriptor,a=Object.defineProperty;var i=r.symbol,s=[],c=i("Promise"),l=i("then"),u="__creationTrace__";r.onUnhandledError=function(e){if(r.showUncaughtError()){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)}},r.microtaskDrainDone=function(){for(;s.length;)for(var e=function(){var e=s.shift();try{e.zone.runGuarded(function(){throw e})}catch(e){p(e)}};s.length;)e()};var f=i("unhandledPromiseRejectionHandler");function p(e){r.onUnhandledError(e);try{var t=n[f];t&&"function"==typeof t&&t.call(this,e)}catch(e){}}function h(e){return e&&e.then}function d(e){return e}function v(e){return R.reject(e)}var g=i("state"),y=i("value"),_=i("finally"),m=i("parentPromiseValue"),b=i("parentPromiseState"),k="Promise.then",T=null,E=!0,w=!1,S=0;function O(e,t){return function(n){try{j(e,t,n)}catch(t){j(e,!1,t)}}}var P=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},D="Promise resolved with itself",Z=i("currentTaskTrace");function j(e,t,o){var i=P();if(e===o)throw new TypeError(D);if(e[g]===T){var c=null;try{"object"!=typeof o&&"function"!=typeof o||(c=o&&o.then)}catch(t){return i(function(){j(e,!1,t)})(),e}if(t!==w&&o instanceof R&&o.hasOwnProperty(g)&&o.hasOwnProperty(y)&&o[g]!==T)C(o),j(e,o[g],o[y]);else if(t!==w&&"function"==typeof c)try{c.call(o,i(O(e,t)),i(O(e,!1)))}catch(t){i(function(){j(e,!1,t)})()}else{e[g]=t;var l=e[y];if(e[y]=o,e[_]===_&&t===E&&(e[g]=e[b],e[y]=e[m]),t===w&&o instanceof Error){var f=n.currentTask&&n.currentTask.data&&n.currentTask.data[u];f&&a(o,Z,{configurable:!0,enumerable:!1,writable:!0,value:f})}for(var p=0;p=0;n--)"function"==typeof e[n]&&(e[n]=h(e[n],t+"_"+n));return e}function T(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in _)&&void 0!==_.process&&"[object process]"==={}.toString.call(_.process),S=!w&&!E&&!(!g||!y.HTMLElement),O=void 0!==_.process&&"[object process]"==={}.toString.call(_.process)&&!E&&!(!g||!y.HTMLElement),P={},D=function(e){if(e=e||_.event){var t=P[e.type];t||(t=P[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||_,o=r[t];if(S&&r===y&&"error"===e.type){var a=e;!0===(n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error))&&e.preventDefault()}else null==(n=o&&o.apply(this,arguments))||n||e.preventDefault();return n}};function Z(e,r,o){var a=t(e,r);!a&&o&&(t(o,r)&&(a={enumerable:!0,configurable:!0}));if(a&&a.configurable){var i=v("on"+r+"patched");if(!e.hasOwnProperty(i)||!e[i]){delete a.writable,delete a.value;var s=a.get,c=a.set,l=r.substr(2),u=P[l];u||(u=P[l]=v("ON_PROPERTY"+l)),a.set=function(t){var n=this;(n||e!==_||(n=_),n)&&(n[u]&&n.removeEventListener(l,D),c&&c.apply(n,b),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},a.get=function(){var t=this;if(t||e!==_||(t=_),!t)return null;var n=t[u];if(n)return n;if(s){var o=s&&s.call(this);if(o)return a.set.call(this,o),"function"==typeof t[m]&&t.removeAttribute(r),o}return null},n(e,r,a),e[i]=!0}}}function j(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?d(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function M(e,t){e[v("OriginalDelegate")]=t}var x=!1,N=!1;function F(){try{var e=y.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function H(){if(x)return N;x=!0;try{var e=y.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(N=!0)}catch(e){}return N}Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.call(i)}if(this===Error){var s=e[o];if(s)return t.call(s)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});var A=!1;if("undefined"!=typeof window)try{var B=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",B,B),window.removeEventListener("test",B,B)}catch(e){A=!1}var G={useG:!0},q={},W={},U=/^__zone_symbol__(\w+)(true|false)$/,X="__zone_symbol__propagationStopped";function V(e,t,n){var o=n&&n.add||i,a=n&&n.rm||s,c=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",h=v(o),d="."+o+":",g="prependListener",y="."+g+":",_=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;if(o&&"object"==typeof o&&o.once){var i=e.originalDelegate?e.originalDelegate:e.callback;t[a].call(t,n.type,i,o)}}},m=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[q[t.type][f]];if(r)if(1===r.length)_(r[0],n,t);else for(var o=r.slice(),a=0;a1?new a(t,n):new a(t),l=e.ObjectGetOwnPropertyDescriptor(c,"onmessage");return l&&!1===l.configurable?(i=e.ObjectCreate(c),s=c,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var s=Zone.__symbol__("ON_PROPERTY"+a);c[s]=i[s]}}return c[t].apply(c,n)}})):i=c,e.patchOnProperties(i,["close","error","message","open"],s),i};var i=t.WebSocket;for(var s in a)i[s]=a[s]}(e,t),Zone[e.symbol("patchEvents")]=!0)}}Zone.__load_patch("util",function(e,r,c){c.patchOnProperties=j,c.patchMethod=R,c.bindArguments=k,c.patchMacroTask=L;var l=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[l]=e[d]),e[l]&&(r[l]=r[d]=e[l]),c.patchEventPrototype=K,c.patchEventTarget=V,c.isIEOrEdge=H,c.ObjectDefineProperty=n,c.ObjectGetOwnPropertyDescriptor=t,c.ObjectCreate=o,c.ArraySlice=a,c.patchClass=C,c.wrapWithCurrentZone=h,c.filterProperties=ye,c.attachOriginToPatched=M,c._redefineProperty=re,c.patchCallbacks=J,c.getGlobalObjects=function(){return{globalSources:W,zoneSymbolEventNames:q,eventNames:ge,isBrowser:S,isMix:O,isNode:w,TRUE_STR:u,FALSE_STR:f,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:s}}}),function(e){e.__zone_symbol__legacyPatch=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.eventNames,o=n.globalSources,a=n.zoneSymbolEventNames,i=n.TRUE_STR,s=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,l="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",u="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,WebSocket".split(","),f=[],p=e.wtf,h=l.split(",");p?f=h.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget||(f=u);for(var d=e.__Zone_disable_IE_check||!1,v=e.__Zone_enable_cross_context_check||!1,g=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",_=0;_0){var o=e.invoke;e.invoke=function(){for(var n=r.__zone_symbol__loadfalse,a=0;a Date: Wed, 3 Apr 2019 11:56:35 +0900 Subject: [PATCH 098/106] element: fix #1209, check customElements is null or not (#1210) --- lib/browser/custom-elements.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/custom-elements.ts b/lib/browser/custom-elements.ts index dc8fea845..02eb35a57 100644 --- a/lib/browser/custom-elements.ts +++ b/lib/browser/custom-elements.ts @@ -8,7 +8,7 @@ export function patchCustomElements(_global: any, api: _ZonePrivate) { const {isBrowser, isMix} = api.getGlobalObjects()!; - if ((!isBrowser && !isMix) || !('customElements' in _global)) { + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } From aca472833d34bca8938e6dbcfaec14effd14ac1f Mon Sep 17 00:00:00 2001 From: jwKimo <33677140+jwKimo@users.noreply.github.com> Date: Mon, 8 Apr 2019 13:21:47 -0700 Subject: [PATCH 099/106] fix: ensure that EventTarget is patched prior to legacy property descriptor patch (#1214) If the event that EventTarget is defined on a device that also does not support patch via property descriptor, the result is that the XMLHttpRequest class would be patched prior to the event target being patched (due to returning in event-target-legacy if EventTarget is defined). This results in the wrapper that replaces XMLHttpRequest missing the patched listener fields. E.g. __zone_symbol__addEventListener and __zone_symbol__removeEventListener event-target-legacy. The result is that for any attempted http requests, a type error occurs in scheduleTask in browse.ts -> patchXhr, due to attempting call to non-existent __zone_symbol__addEventListener and __zone_symbol__removeEventListener, causing the requests to fail. Ensuring that patching of event target for legacy path takes place before legacy property descriptor patch eliminates this problem. --- lib/browser/event-target-legacy.ts | 4 ++-- lib/browser/event-target.ts | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/browser/event-target-legacy.ts b/lib/browser/event-target-legacy.ts index 9a4b025ef..420ffb2af 100644 --- a/lib/browser/event-target-legacy.ts +++ b/lib/browser/event-target-legacy.ts @@ -24,7 +24,7 @@ export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { // Workaround for: https://github.com/google/tracing-framework/issues/555 apis = WTF_ISSUE_555_ARRAY.map((v) => 'HTML' + v + 'Element').concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - // EventTarget is already patched in browser.ts + 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 @@ -101,7 +101,7 @@ export function eventTargetLegacyPatch(_global: any, api: _ZonePrivate) { // vh is validateHandler to check event handler // is valid or not(for security check) api.patchEventTarget(_global, apiTypes, {vh: checkIEAndCrossContext}); - + (Zone as any)[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; return true; } diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index abbe51837..525f52976 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -7,6 +7,10 @@ */ export function eventTargetPatch(_global: any, api: _ZonePrivate) { + if ((Zone as any)[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } const {eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX} = api.getGlobalObjects()!; // predefine all __zone_symbol__ + eventName + true/false string From 32f3a9326e8a06e9b4bd054d2156f1d843456c37 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 9 Apr 2019 05:50:17 +0900 Subject: [PATCH 100/106] xhr: fix #1212, add XMLHttpRequest availability check to avoid error in ServiceWorker (#1213) --- lib/browser/browser.ts | 5 +++++ lib/browser/property-descriptor-legacy.ts | 26 ++++++++++++++++++++--- lib/browser/property-descriptor.ts | 6 +++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index 8599ad02f..dcd334ad7 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -94,6 +94,11 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { } function patchXHR(window: any) { + const XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } const XMLHttpRequestPrototype: any = XMLHttpRequest.prototype; function findPendingTask(target: any) { diff --git a/lib/browser/property-descriptor-legacy.ts b/lib/browser/property-descriptor-legacy.ts index 8ee0ea291..536149453 100644 --- a/lib/browser/property-descriptor-legacy.ts +++ b/lib/browser/property-descriptor-legacy.ts @@ -18,8 +18,8 @@ export function propertyDescriptorLegacyPatch(api: _ZonePrivate, _global: any) { return; } - const supportsWebSocket = typeof WebSocket !== 'undefined'; - if (!canPatchViaPropertyDescriptor(api)) { + if (!canPatchViaPropertyDescriptor(api, _global)) { + const supportsWebSocket = typeof WebSocket !== 'undefined'; // Safari, Android browsers (Jelly Bean) patchViaCapturingAllTheEvents(api); api.patchClass('XMLHttpRequest'); @@ -30,7 +30,7 @@ export function propertyDescriptorLegacyPatch(api: _ZonePrivate, _global: any) { } } -function canPatchViaPropertyDescriptor(api: _ZonePrivate) { +function canPatchViaPropertyDescriptor(api: _ZonePrivate, _global: any) { const {isBrowser, isMix} = api.getGlobalObjects()!; if ((isBrowser || isMix) && !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && @@ -39,8 +39,28 @@ function canPatchViaPropertyDescriptor(api: _ZonePrivate) { // IDL interface attributes are not configurable const desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function() { + return true; + } + }); + const div = document.createElement('div'); + const result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; + } } + const XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return false; + } const ON_READY_STATE_CHANGE = 'onreadystatechange'; const XMLHttpRequestPrototype = XMLHttpRequest.prototype; diff --git a/lib/browser/property-descriptor.ts b/lib/browser/property-descriptor.ts index 5b518c00f..375a55425 100644 --- a/lib/browser/property-descriptor.ts +++ b/lib/browser/property-descriptor.ts @@ -309,7 +309,11 @@ export function propertyDescriptorPatch(api: _ZonePrivate, _global: any) { patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); } } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + const XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { patchFilteredProperties( From 62b85253184a7476858774419552bf3261ea5b9b Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 10 Apr 2019 08:45:51 +0900 Subject: [PATCH 101/106] fix: fakeAsyncTest requestAnimationFrame should pass timestamp as parameter (#1220) Close #1216 --- lib/zone-spec/fake-async-test.ts | 3 ++- test/zone-spec/fake-async-test.spec.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index babdcfec3..c2d288cbc 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -143,7 +143,8 @@ class Scheduler { if (doTick) { doTick(this._currentTime - lastCurrentTime); } - let retval = current.func.apply(global, current.args); + let retval = current.func.apply( + global, current.isRequestAnimationFrame ? [this._currentTime] : current.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index c58109ccd..9d305f297 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -741,6 +741,24 @@ describe('FakeAsyncTestZoneSpec', () => { expect(ran).toEqual(true); }); }); + it('should pass timestamp as parameter', () => { + let timestamp = 0; + let timestamp1 = 0; + fakeAsyncTestZone.run(() => { + requestAnimationFrame((ts) => { + timestamp = ts; + requestAnimationFrame(ts1 => { + timestamp1 = ts1; + }); + }); + const elapsed = testZoneSpec.flush(20, true); + const elapsed1 = testZoneSpec.flush(20, true); + expect(elapsed).toEqual(16); + expect(elapsed1).toEqual(16); + expect(timestamp).toEqual(16); + expect(timestamp1).toEqual(32); + }); + }); })); }); }); From 10e1b0c9f41b76b01aedd7ab3064cdebb74971db Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Wed, 10 Apr 2019 08:58:44 +0900 Subject: [PATCH 102/106] feat: add option to disable jasmine clock patch, also rename the flag of auto jump in FakeAsyncTest (#1222) --- lib/jasmine/jasmine.ts | 97 ++++++++++--------- test/browser-zone-setup.ts | 2 +- test/node_entry_point.ts | 4 +- test/test-env-setup-jasmine-no-patch-clock.ts | 2 +- test/zone-spec/fake-async-test.spec.ts | 3 +- 5 files changed, 58 insertions(+), 50 deletions(-) diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index 9bd387fdd..d75800992 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -40,7 +40,13 @@ const symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync - const enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + const disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + const enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); const ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; @@ -94,51 +100,52 @@ }; }); - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); - (jasmine as any)['clock'] = function() { - const clock = originalClockFn.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - const originalTick = (clock[symbol('tick')] = clock.tick); - clock.tick = function() { - const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick.apply(this, arguments); - }; - const originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function() { - const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - const dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply( - fakeAsyncZoneSpec, - dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + const originalClockFn: Function = ((jasmine as any)[symbol('clock')] = jasmine['clock']); + (jasmine as any)['clock'] = function() { + const clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + const originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function() { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); + }; + const originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function() { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + const dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply( + fakeAsyncZoneSpec, + dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(methodName => { + const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function() { + const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); } - return originalMockDate.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableClockPatch) { - ['install', 'uninstall'].forEach(methodName => { - const originalClockFn: Function = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function() { - const FakeAsyncTestZoneSpec = (Zone as any)['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - (jasmine as any)[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); } - } - return clock; - }; - + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -154,7 +161,7 @@ const testProxyZoneSpec = queueRunner.testProxyZoneSpec; const testProxyZone = queueRunner.testProxyZone; let lastDelegate; - if (isClockInstalled && enableClockPatch) { + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { // auto run a fakeAsync const fakeAsyncModule = (Zone as any)[Zone.__symbol__('fakeAsyncTest')]; if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 7982c1df5..2e157175d 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -7,7 +7,7 @@ */ if (typeof window !== 'undefined') { (window as any)['__Zone_enable_cross_context_check'] = true; - (window as any)['__zone_symbol__fakeAsyncPatchLock'] = true; + (window as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] = true; } import '../lib/common/to-string'; import '../lib/browser/api-util'; diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index 7d7c4ee79..74d27b086 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -8,8 +8,8 @@ // Must be loaded before zone loads, so that zone can detect WTF. if (typeof global !== 'undefined' && - (global as any)['__zone_symbol__fakeAsyncPatchLock'] !== false) { - (global as any)['__zone_symbol__fakeAsyncPatchLock'] = true; + (global as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] !== false) { + (global as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] = true; } import './wtf_mock'; import './test_fake_polyfill'; diff --git a/test/test-env-setup-jasmine-no-patch-clock.ts b/test/test-env-setup-jasmine-no-patch-clock.ts index 8c06e92c1..d847c2fed 100644 --- a/test/test-env-setup-jasmine-no-patch-clock.ts +++ b/test/test-env-setup-jasmine-no-patch-clock.ts @@ -5,4 +5,4 @@ * 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 */ -(global as any)['__zone_symbol__fakeAsyncPatchLock'] = false; +(global as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] = false; diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 9d305f297..6b3053558 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -22,7 +22,8 @@ function supportNode() { function supportClock() { const _global: any = typeof window === 'undefined' ? global : window; - return typeof jasmine.clock === 'function' && _global['__zone_symbol__fakeAsyncPatchLock']; + return typeof jasmine.clock === 'function' && + _global['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched']; } (supportClock as any).message = 'support patch clock'; From c555b083b902bd8370d20a35ce523302d1448492 Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Tue, 30 Apr 2019 16:43:22 +0000 Subject: [PATCH 103/106] build: release zone.js 0.9.1 --- CHANGELOG.md | 16 +++ dist/fake-async-test.js | 2 +- dist/jasmine-patch.js | 92 +++++++++-------- dist/jasmine-patch.min.js | 2 +- dist/zone-evergreen-testing-bundle.js | 113 +++++++++++--------- dist/zone-evergreen.js | 17 ++- dist/zone-evergreen.min.js | 2 +- dist/zone-legacy.js | 29 +++++- dist/zone-legacy.min.js | 2 +- dist/zone-mix.js | 17 ++- dist/zone-testing-bundle.js | 142 +++++++++++++++++--------- dist/zone-testing-node-bundle.js | 94 +++++++++-------- dist/zone-testing.js | 94 +++++++++-------- dist/zone.js | 46 +++++++-- dist/zone.min.js | 2 +- file-size-limit.json | 2 +- package.json | 2 +- 17 files changed, 429 insertions(+), 245 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06eef6011..872b2c9ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ + +## [0.9.1](https://github.com/angular/zone.js/compare/v0.9.0...0.9.1) (2019-04-30) + + +### Bug Fixes + +* ensure that EventTarget is patched prior to legacy property descriptor patch ([#1214](https://github.com/angular/zone.js/issues/1214)) ([aca4728](https://github.com/angular/zone.js/commit/aca4728)) +* fakeAsyncTest requestAnimationFrame should pass timestamp as parameter ([#1220](https://github.com/angular/zone.js/issues/1220)) ([62b8525](https://github.com/angular/zone.js/commit/62b8525)), closes [#1216](https://github.com/angular/zone.js/issues/1216) + + +### Features + +* add option to disable jasmine clock patch, also rename the flag of auto jump in FakeAsyncTest ([#1222](https://github.com/angular/zone.js/issues/1222)) ([10e1b0c](https://github.com/angular/zone.js/commit/10e1b0c)) + + + # [0.9.0](https://github.com/angular/zone.js/compare/v0.8.29...0.9.0) (2019-03-12) diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js index 63ac9898d..44c0969c2 100644 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -145,7 +145,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (doTick) { doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.args); + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js index 4191c6005..3c6958113 100644 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -51,7 +51,13 @@ var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync - var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; if (!ignoreUnhandledRejection) { var globalErrors_1 = jasmine.GlobalErrors; @@ -100,48 +106,50 @@ return originalJasmineFn.apply(this, arguments); }; }); - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableClockPatch) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); } - } - return clock; - }; + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -155,7 +163,7 @@ var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableClockPatch) { + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { // auto run a fakeAsync var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js index 505ff0c26..016466a6a 100644 --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";!function(){var e="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 n=Zone.SyncTestZoneSpec,t=Zone.ProxyZoneSpec;if(!n)throw new Error("Missing: SyncTestZoneSpec");if(!t)throw new Error("Missing: ProxyZoneSpec");var o=Zone.current,r=o.fork(new n("jasmine.describe")),i=Zone.__symbol__,s=!0===e[i("fakeAsyncPatchLock")];if(!(!0===e[i("ignoreUnhandledRejection")])){var a=jasmine.GlobalErrors;a&&!jasmine[i("GlobalErrors")]&&(jasmine[i("GlobalErrors")]=a,jasmine.GlobalErrors=function(){var e=new a,n=e.install;return n&&!e[i("install")]&&(e[i("install")]=n,e.install=function(){var e=process.listeners("unhandledRejection"),t=n.apply(this,arguments);return process.removeAllListeners("unhandledRejection"),e&&e.forEach(function(e){return process.on("unhandledRejection",e)}),t}),e})}var c=jasmine.getEnv();["describe","xdescribe","fdescribe"].forEach(function(e){var n=c[e];c[e]=function(e,t){return n.call(this,e,(o=t,function(){return r.run(o,this,arguments)}));var o}}),["it","xit","fit"].forEach(function(e){var n=c[e];c[i(e)]=n,c[e]=function(e,t,o){return arguments[1]=f(t),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=c[e];c[i(e)]=n,c[e]=function(e,t){return arguments[0]=f(e),n.apply(this,arguments)}});var u=jasmine[i("clock")]=jasmine.clock;function l(e,n,t,o){var r=!!jasmine[i("clockInstalled")],a=(t.testProxyZoneSpec,t.testProxyZone);if(r&&s){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return o?a.run(e,n,[o]):a.run(e,n)}function f(e){return e&&(e.length?function(n){return l(e,this,this.queueRunner,n)}:function(){return l(e,this,this.queueRunner)})}jasmine.clock=function(){var e=u.apply(this,arguments);if(!e[i("patched")]){e[i("patched")]=i("patched");var n=e[i("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[i("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},s&&["install","uninstall"].forEach(function(n){var t=e[i(n)]=e[n];e[n]=function(){if(!Zone.FakeAsyncTestZoneSpec)return t.apply(this,arguments);jasmine[i("clockInstalled")]="install"===n}})}return e};var p=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(t){var r,i=this;t.onComplete=(r=t.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,o.scheduleMicroTask("jasmine.onComplete",r)});var s=e.__zone_symbol__setTimeout,a=e.__zone_symbol__clearTimeout;s&&(t.timeout={setTimeout:s||e.setTimeout,clearTimeout:a||e.clearTimeout}),jasmine.UserContext?(t.userContext||(t.userContext=new jasmine.UserContext),t.userContext.queueRunner=this):(t.userContext||(t.userContext={}),t.userContext.queueRunner=this);var c=t.onException;t.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();try{e.message+=t}catch(e){}}}c&&c.call(this,e)},n.call(this,t)}return function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);function o(){this.constructor=e}e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(r,n),r.prototype.execute=function(){for(var e=this,r=Zone.current,i=!1;r;){if(r===o){i=!0;break}r=r.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new t,this.testProxyZone=o.fork(this.testProxyZoneSpec),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(e)})},r}(p)}()}); \ No newline at end of file +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";!function(){var e="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 n=Zone.SyncTestZoneSpec,t=Zone.ProxyZoneSpec;if(!n)throw new Error("Missing: SyncTestZoneSpec");if(!t)throw new Error("Missing: ProxyZoneSpec");var o=Zone.current,r=o.fork(new n("jasmine.describe")),i=Zone.__symbol__,s=!0===e[i("fakeAsyncDisablePatchingClock")],c=!s&&(!0===e[i("fakeAsyncPatchLock")]||!0===e[i("fakeAsyncAutoFakeAsyncWhenClockPatched")]);if(!(!0===e[i("ignoreUnhandledRejection")])){var a=jasmine.GlobalErrors;a&&!jasmine[i("GlobalErrors")]&&(jasmine[i("GlobalErrors")]=a,jasmine.GlobalErrors=function(){var e=new a,n=e.install;return n&&!e[i("install")]&&(e[i("install")]=n,e.install=function(){var e=process.listeners("unhandledRejection"),t=n.apply(this,arguments);return process.removeAllListeners("unhandledRejection"),e&&e.forEach(function(e){return process.on("unhandledRejection",e)}),t}),e})}var u=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(function(e){var n=u[e];u[e]=function(e,t){return n.call(this,e,(o=t,function(){return r.run(o,this,arguments)}));var o}}),["it","xit","fit"].forEach(function(e){var n=u[e];u[i(e)]=n,u[e]=function(e,t,o){return arguments[1]=p(t),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=u[e];u[i(e)]=n,u[e]=function(e,t){return arguments[0]=p(e),n.apply(this,arguments)}}),!s){var l=jasmine[i("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments);if(!e[i("patched")]){e[i("patched")]=i("patched");var n=e[i("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[i("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},c&&["install","uninstall"].forEach(function(n){var t=e[i(n)]=e[n];e[n]=function(){if(!Zone.FakeAsyncTestZoneSpec)return t.apply(this,arguments);jasmine[i("clockInstalled")]="install"===n}})}return e}}function f(e,n,t,o){var r=!!jasmine[i("clockInstalled")],s=(t.testProxyZoneSpec,t.testProxyZone);if(r&&c){var a=Zone[Zone.__symbol__("fakeAsyncTest")];a&&"function"==typeof a.fakeAsync&&(e=a.fakeAsync(e))}return o?s.run(e,n,[o]):s.run(e,n)}function p(e){return e&&(e.length?function(n){return f(e,this,this.queueRunner,n)}:function(){return f(e,this,this.queueRunner)})}var h=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(t){var r,i=this;t.onComplete=(r=t.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,o.scheduleMicroTask("jasmine.onComplete",r)});var s=e.__zone_symbol__setTimeout,c=e.__zone_symbol__clearTimeout;s&&(t.timeout={setTimeout:s||e.setTimeout,clearTimeout:c||e.clearTimeout}),jasmine.UserContext?(t.userContext||(t.userContext=new jasmine.UserContext),t.userContext.queueRunner=this):(t.userContext||(t.userContext={}),t.userContext.queueRunner=this);var a=t.onException;t.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();try{e.message+=t}catch(e){}}}a&&a.call(this,e)},n.call(this,t)}return function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);function o(){this.constructor=e}e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(r,n),r.prototype.execute=function(){for(var e=this,r=Zone.current,i=!1;r;){if(r===o){i=!0;break}r=r.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new t,this.testProxyZone=o.fork(this.testProxyZoneSpec),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(e)})},r}(h)}()}); \ No newline at end of file diff --git a/dist/zone-evergreen-testing-bundle.js b/dist/zone-evergreen-testing-bundle.js index da3dce583..2547a6396 100644 --- a/dist/zone-evergreen-testing-bundle.js +++ b/dist/zone-evergreen-testing-bundle.js @@ -2632,7 +2632,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); @@ -2849,7 +2853,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ function patchCustomElements(_global, api) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('customElements' in _global)) { + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; @@ -2864,6 +2868,10 @@ function patchCustomElements(_global, api) { * found in the LICENSE file at https://angular.io/license */ function eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; // predefine all __zone_symbol__ + eventName + true/false string for (var i = 0; i < eventNames.length; i++) { @@ -2957,6 +2965,11 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_URL = zoneSymbol('xhrURL'); var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { return target[XHR_TASK]; @@ -3555,7 +3568,13 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync - var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; if (!ignoreUnhandledRejection) { var globalErrors_1 = jasmine.GlobalErrors; @@ -3604,48 +3623,50 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableClockPatch) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } } - } - return clock; - }; + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -3659,7 +3680,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableClockPatch) { + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { // auto run a fakeAsync var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { @@ -4145,7 +4166,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (doTick) { doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.args); + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; diff --git a/dist/zone-evergreen.js b/dist/zone-evergreen.js index 6666bf1cb..691d2b91f 100644 --- a/dist/zone-evergreen.js +++ b/dist/zone-evergreen.js @@ -2540,7 +2540,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); } } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + const XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); @@ -2757,7 +2761,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ function patchCustomElements(_global, api) { const { isBrowser, isMix } = api.getGlobalObjects(); - if ((!isBrowser && !isMix) || !('customElements' in _global)) { + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; @@ -2772,6 +2776,10 @@ function patchCustomElements(_global, api) { * found in the LICENSE file at https://angular.io/license */ function eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } const { eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX } = api.getGlobalObjects(); // predefine all __zone_symbol__ + eventName + true/false string for (let i = 0; i < eventNames.length; i++) { @@ -2865,6 +2873,11 @@ Zone.__load_patch('XHR', (global, Zone) => { const XHR_URL = zoneSymbol('xhrURL'); const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { + const XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } const XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { return target[XHR_TASK]; diff --git a/dist/zone-evergreen.min.js b/dist/zone-evergreen.min.js index 7d044141c..999a289ac 100644 --- a/dist/zone-evergreen.min.js +++ b/dist/zone-evergreen.min.js @@ -1 +1 @@ -const Zone$1=function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(r||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class s{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new a(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=s.current;for(;e.parent;)e=e.parent;return e}static get current(){return D.zone}static get currentTask(){return z}static __load_patch(t,i){if(P.hasOwnProperty(t)){if(r)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const r="Zone:"+t;n(r),P[t]=i(e,s,N),o(r,r)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){D={parent:D,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{D=D.parent}}runGuarded(e,t=null,n,o){D={parent:D,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{D=D.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state===y&&(e.type===w||e.type===O))return;const o=e.state!=T;o&&e._transitionTo(T,b),e.runCount++;const r=z;z=e,D={parent:D,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==y&&e.state!==v&&(e.type==w||e.data&&e.data.isPeriodic?o&&e._transitionTo(b,T):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(y,T,y))),D=D.parent,z=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;t;){if(t===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);t=t.parent}}e._transitionTo(E,y);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(v,E,y),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==E&&e._transitionTo(b,E),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new c(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new c(O,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new c(w,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(k,b,T);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(v,k),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(y,k),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class a{constructor(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._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask,r=t&&t._hasTaskZS;(o||r)&&(this._hasTaskZS=o?n:i,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=i,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=i,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=i,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new s(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");if(0==o||0==r){const t={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,t)}}}class c{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;t===w&&r&&r.useG?this.invoke=c.invokeTask:this.invoke=function(){return c.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),Z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==Z&&m(),Z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(y,E)}_transitionTo(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(`${this.type} '${this.source}': can not transition to '${e}', expecting state '${t}'${n?" or '"+n+"'":""}, was '${this._state}'.`);this._state=e,e==y&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const l=R("setTimeout"),u=R("Promise"),p=R("then");let h,f=[],d=!1;function _(t){if(0===Z&&0===f.length)if(h||e[u]&&(h=e[u].resolve(0)),h){let e=h[p];e||(e=h.then),e.call(h,m)}else e[l](m,0);t&&f.push(t)}function m(){if(!d){for(d=!0;f.length;){const e=f;f=[];for(let t=0;tD,onUnhandledError:I,microtaskDrainDone:I,scheduleMicroTask:_,showUncaughtError:()=>!s[R("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:I,patchMethod:()=>I,bindArguments:()=>[],patchThen:()=>I,patchMacroTask:()=>I,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(h=e.resolve(0))},patchEventPrototype:()=>I,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>I,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>I,wrapWithCurrentZone:()=>I,filterProperties:()=>[],attachOriginToPatched:()=>I,_redefineProperty:()=>I,patchCallbacks:()=>I};let D={parent:null,zone:new s(null,null)},z=null,Z=0;function I(){}function R(e){return"__zone_symbol__"+e}return o("Zone","Zone"),e.Zone=s}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty;const s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const 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)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){p(e)}}});const u=s("unhandledPromiseRejectionHandler");function p(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function h(e){return e&&e.then}function f(e){return e}function d(e){return M.reject(e)}const _=s("state"),m=s("value"),g=s("finally"),y=s("parentPromiseValue"),E=s("parentPromiseState"),b="Promise.then",T=null,k=!0,v=!1,S=0;function O(e,t){return n=>{try{D(e,t,n)}catch(t){D(e,!1,t)}}}const w=function(){let e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},P="Promise resolved with itself",N=s("currentTaskTrace");function D(e,o,s){const a=w();if(e===s)throw new TypeError(P);if(e[_]===T){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{D(e,!1,t)})(),e}if(o!==v&&s instanceof M&&s.hasOwnProperty(_)&&s.hasOwnProperty(m)&&s[_]!==T)Z(s),D(e,s[_],s[m]);else if(o!==v&&"function"==typeof c)try{c.call(s,a(O(e,o)),a(O(e,!1)))}catch(t){a(()=>{D(e,!1,t)})()}else{e[_]=o;const a=e[m];if(e[m]=s,e[g]===g&&o===k&&(e[_]=e[E],e[m]=e[y]),o===v&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,N,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[m],r=n&&g===n[g];r&&(n[y]=o,n[E]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);D(n,!0,a)}catch(e){D(n,!1,e)}},n)}const R="function ZoneAwarePromise() { [native code] }";class M{constructor(e){const t=this;if(!(t instanceof M))throw new Error("Must be an instanceof Promise.");t[_]=T,t[m]=[];try{e&&e(O(t,k),O(t,v))}catch(e){D(t,!1,e)}}static toString(){return R}static resolve(e){return D(new this(null),k,e)}static reject(e){return D(new this(null),v,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)h(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){h(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0===--r&&t(i)},n),r++,s++}return 0===(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[_]==T?this[m].push(r,o,e,n):I(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[g]=g;const o=t.current;return this[_]==T?this[m].push(o,n,e,e):I(this,o,n,e,e),n}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;const j=e[a]=e.Promise,C=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[C]?e[C]:e[a]},L.set=function(t){t===M?e[C]=t:(e[a]=t,t.prototype[c]||F(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=M;const A=s("thenPatched");function F(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new M((e,t)=>{r.call(this,e,t)}).then(e,t)},e[A]=!0}if(n.patchThen=F,j){F(j);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function(e){return function(){let t=e.apply(this,arguments);if(t instanceof M)return t;let n=t.constructor;return n[A]||F(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,M});const ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ObjectDefineProperty=Object.defineProperty,ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectCreate=Object.create,ArraySlice=Array.prototype.slice,ADD_EVENT_LISTENER_STR="addEventListener",REMOVE_EVENT_LISTENER_STR="removeEventListener",ZONE_SYMBOL_ADD_EVENT_LISTENER=Zone.__symbol__(ADD_EVENT_LISTENER_STR),ZONE_SYMBOL_REMOVE_EVENT_LISTENER=Zone.__symbol__(REMOVE_EVENT_LISTENER_STR),TRUE_STR="true",FALSE_STR="false",ZONE_SYMBOL_PREFIX="__zone_symbol__";function wrapWithCurrentZone(e,t){return Zone.current.wrap(e,t)}function scheduleMacroTaskWithCurrentZone(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const zoneSymbol=Zone.__symbol__,isWindowExists="undefined"!=typeof window,internalWindow=isWindowExists?window:void 0,_global=isWindowExists&&internalWindow||"object"==typeof self&&self||global,REMOVE_ATTRIBUTE="removeAttribute",NULL_ON_PROP_VALUE=[null];function bindArguments(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=wrapWithCurrentZone(e[n],t+"_"+n));return e}function patchPrototype(e,t){const n=e.constructor.name;for(let o=0;o{const t=function(){return e.apply(this,bindArguments(arguments,n+"."+r))};return attachOriginToPatched(t,e),t})(s)}}}function isPropertyWritable(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode=!("nw"in _global)&&void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process),isBrowser=!isNode&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),isMix=void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process)&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),zoneSymbolEventNames={},wrapFn=function(e){if(!(e=e||_global.event))return;let t=zoneSymbolEventNames[e.type];t||(t=zoneSymbolEventNames[e.type]=zoneSymbol("ON_PROPERTY"+e.type));const n=this||e.target||_global,o=n[t];let r;if(isBrowser&&n===internalWindow&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function patchProperty(e,t,n){let o=ObjectGetOwnPropertyDescriptor(e,t);if(!o&&n){ObjectGetOwnPropertyDescriptor(n,t)&&(o={enumerable:!0,configurable:!0})}if(!o||!o.configurable)return;const r=zoneSymbol("on"+t+"patched");if(e.hasOwnProperty(r)&&e[r])return;delete o.writable,delete o.value;const s=o.get,i=o.set,a=t.substr(2);let c=zoneSymbolEventNames[a];c||(c=zoneSymbolEventNames[a]=zoneSymbol("ON_PROPERTY"+a)),o.set=function(t){let n=this;n||e!==_global||(n=_global),n&&(n[c]&&n.removeEventListener(a,wrapFn),i&&i.apply(n,NULL_ON_PROP_VALUE),"function"==typeof t?(n[c]=t,n.addEventListener(a,wrapFn,!1)):n[c]=null)},o.get=function(){let n=this;if(n||e!==_global||(n=_global),!n)return null;const r=n[c];if(r)return r;if(s){let e=s&&s.call(this);if(e)return o.set.call(this,e),"function"==typeof n[REMOVE_ATTRIBUTE]&&n.removeAttribute(t),e}return null},ObjectDefineProperty(e,t,o),e[r]=!0}function patchOnProperties(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}let shouldCopySymbolProperties=!1;function patchMethod(e,t,n){let o=e;for(;o&&!o.hasOwnProperty(t);)o=ObjectGetPrototypeOf(o);!o&&e[t]&&(o=e);const r=zoneSymbol(t);let s=null;if(o&&!(s=o[r])){if(s=o[r]=o[t],isPropertyWritable(o&&ObjectGetOwnPropertyDescriptor(o,t))){const e=n(s,r,t);o[t]=function(){return e(this,arguments)},attachOriginToPatched(o[t],s),shouldCopySymbolProperties&©SymbolProperties(s,o[t])}}return s}function patchMacroTask(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=patchMethod(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?scheduleMacroTaskWithCurrentZone(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function attachOriginToPatched(e,t){e[zoneSymbol("OriginalDelegate")]=t}let isDetectedIEOrEdge=!1,ieOrEdge=!1;function isIE(){try{const e=internalWindow.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function isIEOrEdge(){if(isDetectedIEOrEdge)return ieOrEdge;isDetectedIEOrEdge=!0;try{const e=internalWindow.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(ieOrEdge=!0)}catch(e){}return ieOrEdge}Zone.__load_patch("toString",e=>{const t=Function.prototype.toString,n=zoneSymbol("OriginalDelegate"),o=zoneSymbol("Promise"),r=zoneSymbol("Error"),s=function(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});let passiveSupported=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){passiveSupported=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){passiveSupported=!1}const OPTIMIZED_ZONE_EVENT_TASK_DATA={useG:!0},zoneSymbolEventNames$1={},globalSources={},EVENT_NAME_SYMBOL_REGX=/^__zone_symbol__(\w+)(true|false)$/,IMMEDIATE_PROPAGATION_SYMBOL="__zone_symbol__propagationStopped";function patchEventTarget(e,t,n){const o=n&&n.add||ADD_EVENT_LISTENER_STR,r=n&&n.rm||REMOVE_EVENT_LISTENER_STR,s=n&&n.listeners||"eventListeners",i=n&&n.rmAll||"removeAllListeners",a=zoneSymbol(o),c="."+o+":",l="prependListener",u="."+l+":",p=function(e,t,n){if(e.isRemoved)return;const o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=(e=>o.handleEvent(e)),e.originalDelegate=o),e.invoke(e,t,[n]);const s=e.options;if(s&&"object"==typeof s&&s.once){const o=e.originalDelegate?e.originalDelegate:e.callback;t[r].call(t,n.type,o,s)}},h=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[zoneSymbolEventNames$1[t.type][FALSE_STR]];if(o)if(1===o.length)p(o[0],n,t);else{const e=o.slice();for(let o=0;o(function(t,n){t[IMMEDIATE_PROPAGATION_SYMBOL]=!0,e&&e.apply(t,n)}))}function patchCallbacks(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)}const zoneSymbol$1=Zone.__symbol__,_defineProperty=Object[zoneSymbol$1("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol$1("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol$1("unconfigurables");function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,o)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=_getOwnPropertyDescriptor(e,t);return n&&isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){const o=n.configurable;return _tryDefineProperty(e,t,n=rewriteDescriptor(e,t,n),o)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[unconfigurablesKey]||Object.isFrozen(e)||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey]&&(e[unconfigurablesKey][t]=!0)),n}function _tryDefineProperty(e,t,n,o){try{return _defineProperty(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return _defineProperty(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}}const globalEventHandlersEventNames=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],documentEventNames=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],windowEventNames=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],htmlElementEventNames=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],mediaElementEventNames=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ieElementEventNames=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],webglEventNames=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],formEventNames=["autocomplete","autocompleteerror"],detailEventNames=["toggle"],frameEventNames=["load"],frameSetEventNames=["blur","error","focus","load","resize","scroll","messageerror"],marqueeEventNames=["bounce","finish","start"],XMLHttpRequestEventNames=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],IDBIndexEventNames=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],websocketEventNames=["close","error","open","message"],workerEventNames=["error","message"],eventNames=globalEventHandlersEventNames.concat(webglEventNames,formEventNames,detailEventNames,documentEventNames,windowEventNames,htmlElementEventNames,ieElementEventNames);function filterProperties(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function patchFilteredProperties(e,t,n,o){if(!e)return;patchOnProperties(e,filterProperties(e,t,n),o)}function propertyDescriptorPatch(e,t){if(isNode&&!isMix)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(isBrowser){const e=window,t=isIE?[{target:e,ignoreProperties:["error"]}]:[];patchFilteredProperties(e,eventNames.concat(["messageerror"]),o?o.concat(t):o,ObjectGetPrototypeOf(e)),patchFilteredProperties(Document.prototype,eventNames,o),void 0!==e.SVGElement&&patchFilteredProperties(e.SVGElement.prototype,eventNames,o),patchFilteredProperties(Element.prototype,eventNames,o),patchFilteredProperties(HTMLElement.prototype,eventNames,o),patchFilteredProperties(HTMLMediaElement.prototype,mediaElementEventNames,o),patchFilteredProperties(HTMLFrameSetElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLBodyElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLFrameElement.prototype,frameEventNames,o),patchFilteredProperties(HTMLIFrameElement.prototype,frameEventNames,o);const n=e.HTMLMarqueeElement;n&&patchFilteredProperties(n.prototype,marqueeEventNames,o);const r=e.Worker;r&&patchFilteredProperties(r.prototype,workerEventNames,o)}patchFilteredProperties(XMLHttpRequest.prototype,XMLHttpRequestEventNames,o);const r=t.XMLHttpRequestEventTarget;r&&patchFilteredProperties(r&&r.prototype,XMLHttpRequestEventNames,o),"undefined"!=typeof IDBIndex&&(patchFilteredProperties(IDBIndex.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBOpenDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBDatabase.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBTransaction.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBCursor.prototype,IDBIndexEventNames,o)),n&&patchFilteredProperties(WebSocket.prototype,websocketEventNames,o)}Zone.__load_patch("util",(e,t,n)=>{n.patchOnProperties=patchOnProperties,n.patchMethod=patchMethod,n.bindArguments=bindArguments,n.patchMacroTask=patchMacroTask;const o=t.__symbol__("BLACK_LISTED_EVENTS"),r=t.__symbol__("UNPATCHED_EVENTS");e[r]&&(e[o]=e[r]),e[o]&&(t[o]=t[r]=e[o]),n.patchEventPrototype=patchEventPrototype,n.patchEventTarget=patchEventTarget,n.isIEOrEdge=isIEOrEdge,n.ObjectDefineProperty=ObjectDefineProperty,n.ObjectGetOwnPropertyDescriptor=ObjectGetOwnPropertyDescriptor,n.ObjectCreate=ObjectCreate,n.ArraySlice=ArraySlice,n.patchClass=patchClass,n.wrapWithCurrentZone=wrapWithCurrentZone,n.filterProperties=filterProperties,n.attachOriginToPatched=attachOriginToPatched,n._redefineProperty=_redefineProperty,n.patchCallbacks=patchCallbacks,n.getGlobalObjects=(()=>({globalSources,zoneSymbolEventNames:zoneSymbolEventNames$1,eventNames,isBrowser,isMix,isNode,TRUE_STR,FALSE_STR,ZONE_SYMBOL_PREFIX,ADD_EVENT_LISTENER_STR,REMOVE_EVENT_LISTENER_STR}))});const taskSymbol=zoneSymbol("zoneTask");function patchTimer(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[taskSymbol]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=patchMethod(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e={isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},n=scheduleMacroTaskWithCurrentZone(t,s[0],e,a,c);if(!n)return n;const r=n.data.handleId;return"number"==typeof r?i[r]=n:r&&(r[taskSymbol]=n),r&&r.ref&&r.unref&&"function"==typeof r.ref&&"function"==typeof r.unref&&(n.ref=r.ref.bind(r),n.unref=r.unref.bind(r)),"number"==typeof r||r?r:n}return n.apply(e,s)})),s=patchMethod(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[taskSymbol])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[taskSymbol]=null),s.zone.cancelTask(s)):t.apply(e,o)}))}function patchCustomElements(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();if(!n&&!o||!("customElements"in e))return;t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}function eventTargetPatch(e,t){const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{patchTimer(e,"set","clear","Timeout"),patchTimer(e,"set","clear","Interval"),patchTimer(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{patchTimer(e,"request","cancel","AnimationFrame"),patchTimer(e,"mozRequest","mozCancel","AnimationFrame"),patchTimer(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}}),Zone.__load_patch("EventTarget",(e,t,n)=>{patchEvent(e,n),eventTargetPatch(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("IntersectionObserver"),patchClass("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{propertyDescriptorPatch(n,e),propertyPatch()}),Zone.__load_patch("customElements",(e,t,n)=>{patchCustomElements(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function(e){const c=XMLHttpRequest.prototype;let l=c[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=c[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];if(!l){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;l=e[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=e[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]}}const p="readystatechange",h="scheduled";function f(e){const t=e.data,o=t.target;o[s]=!1,o[a]=!1;const i=o[r];l||(l=o[ZONE_SYMBOL_ADD_EVENT_LISTENER],u=o[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]),i&&u.call(o,p,i);const c=o[r]=(()=>{if(o.readyState===o.DONE)if(!t.aborted&&o[s]&&e.state===h){const n=o.__zone_symbol__loadfalse;if(n&&n.length>0){const r=e.invoke;e.invoke=function(){const n=o.__zone_symbol__loadfalse;for(let t=0;t(function(e,t){return e[o]=0==t[2],e[i]=t[1],m.apply(e,t)})),g=zoneSymbol("fetchTaskAborting"),y=zoneSymbol("fetchTaskScheduling"),E=patchMethod(c,"send",()=>(function(e,n){if(!0===t.current[y])return E.apply(e,n);if(e[o])return E.apply(e,n);{const t={target:e,url:e[i],isPeriodic:!1,args:n,aborted:!1},o=scheduleMacroTaskWithCurrentZone("XMLHttpRequest.send",d,t,f,_);e&&!0===e[a]&&!t.aborted&&o.state===h&&o.invoke()}})),b=patchMethod(c,"abort",()=>(function(e,o){const r=e[n];if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[g])return b.apply(e,o)}))}(e);const n=zoneSymbol("xhrTask"),o=zoneSymbol("xhrSync"),r=zoneSymbol("xhrListener"),s=zoneSymbol("xhrScheduled"),i=zoneSymbol("xhrURL"),a=zoneSymbol("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&patchPrototype(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){findEventTasks(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[zoneSymbol("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[zoneSymbol("rejectionHandledHandler")]=n("rejectionhandled"))}); \ No newline at end of file +const Zone$1=function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(r||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class s{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new a(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=s.current;for(;e.parent;)e=e.parent;return e}static get current(){return D.zone}static get currentTask(){return z}static __load_patch(t,i){if(P.hasOwnProperty(t)){if(r)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const r="Zone:"+t;n(r),P[t]=i(e,s,N),o(r,r)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){D={parent:D,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{D=D.parent}}runGuarded(e,t=null,n,o){D={parent:D,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{D=D.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state===y&&(e.type===w||e.type===O))return;const o=e.state!=T;o&&e._transitionTo(T,b),e.runCount++;const r=z;z=e,D={parent:D,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==y&&e.state!==v&&(e.type==w||e.data&&e.data.isPeriodic?o&&e._transitionTo(b,T):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(y,T,y))),D=D.parent,z=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;t;){if(t===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);t=t.parent}}e._transitionTo(E,y);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(v,E,y),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==E&&e._transitionTo(b,E),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new c(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new c(O,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new c(w,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(k,b,T);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(v,k),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(y,k),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class a{constructor(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._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask,r=t&&t._hasTaskZS;(o||r)&&(this._hasTaskZS=o?n:i,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=i,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=i,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=i,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new s(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");if(0==o||0==r){const t={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,t)}}}class c{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;t===w&&r&&r.useG?this.invoke=c.invokeTask:this.invoke=function(){return c.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),Z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==Z&&m(),Z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(y,E)}_transitionTo(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(`${this.type} '${this.source}': can not transition to '${e}', expecting state '${t}'${n?" or '"+n+"'":""}, was '${this._state}'.`);this._state=e,e==y&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const l=R("setTimeout"),u=R("Promise"),p=R("then");let h,f=[],d=!1;function _(t){if(0===Z&&0===f.length)if(h||e[u]&&(h=e[u].resolve(0)),h){let e=h[p];e||(e=h.then),e.call(h,m)}else e[l](m,0);t&&f.push(t)}function m(){if(!d){for(d=!0;f.length;){const e=f;f=[];for(let t=0;tD,onUnhandledError:I,microtaskDrainDone:I,scheduleMicroTask:_,showUncaughtError:()=>!s[R("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:I,patchMethod:()=>I,bindArguments:()=>[],patchThen:()=>I,patchMacroTask:()=>I,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(h=e.resolve(0))},patchEventPrototype:()=>I,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>I,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>I,wrapWithCurrentZone:()=>I,filterProperties:()=>[],attachOriginToPatched:()=>I,_redefineProperty:()=>I,patchCallbacks:()=>I};let D={parent:null,zone:new s(null,null)},z=null,Z=0;function I(){}function R(e){return"__zone_symbol__"+e}return o("Zone","Zone"),e.Zone=s}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty;const s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const 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)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){p(e)}}});const u=s("unhandledPromiseRejectionHandler");function p(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function h(e){return e&&e.then}function f(e){return e}function d(e){return M.reject(e)}const _=s("state"),m=s("value"),g=s("finally"),y=s("parentPromiseValue"),E=s("parentPromiseState"),b="Promise.then",T=null,k=!0,v=!1,S=0;function O(e,t){return n=>{try{D(e,t,n)}catch(t){D(e,!1,t)}}}const w=function(){let e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},P="Promise resolved with itself",N=s("currentTaskTrace");function D(e,o,s){const a=w();if(e===s)throw new TypeError(P);if(e[_]===T){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{D(e,!1,t)})(),e}if(o!==v&&s instanceof M&&s.hasOwnProperty(_)&&s.hasOwnProperty(m)&&s[_]!==T)Z(s),D(e,s[_],s[m]);else if(o!==v&&"function"==typeof c)try{c.call(s,a(O(e,o)),a(O(e,!1)))}catch(t){a(()=>{D(e,!1,t)})()}else{e[_]=o;const a=e[m];if(e[m]=s,e[g]===g&&o===k&&(e[_]=e[E],e[m]=e[y]),o===v&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,N,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[m],r=n&&g===n[g];r&&(n[y]=o,n[E]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);D(n,!0,a)}catch(e){D(n,!1,e)}},n)}const R="function ZoneAwarePromise() { [native code] }";class M{constructor(e){const t=this;if(!(t instanceof M))throw new Error("Must be an instanceof Promise.");t[_]=T,t[m]=[];try{e&&e(O(t,k),O(t,v))}catch(e){D(t,!1,e)}}static toString(){return R}static resolve(e){return D(new this(null),k,e)}static reject(e){return D(new this(null),v,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)h(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){h(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0===--r&&t(i)},n),r++,s++}return 0===(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[_]==T?this[m].push(r,o,e,n):I(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[g]=g;const o=t.current;return this[_]==T?this[m].push(o,n,e,e):I(this,o,n,e,e),n}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;const j=e[a]=e.Promise,C=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[C]?e[C]:e[a]},L.set=function(t){t===M?e[C]=t:(e[a]=t,t.prototype[c]||F(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=M;const A=s("thenPatched");function F(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new M((e,t)=>{r.call(this,e,t)}).then(e,t)},e[A]=!0}if(n.patchThen=F,j){F(j);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function(e){return function(){let t=e.apply(this,arguments);if(t instanceof M)return t;let n=t.constructor;return n[A]||F(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,M});const ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ObjectDefineProperty=Object.defineProperty,ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectCreate=Object.create,ArraySlice=Array.prototype.slice,ADD_EVENT_LISTENER_STR="addEventListener",REMOVE_EVENT_LISTENER_STR="removeEventListener",ZONE_SYMBOL_ADD_EVENT_LISTENER=Zone.__symbol__(ADD_EVENT_LISTENER_STR),ZONE_SYMBOL_REMOVE_EVENT_LISTENER=Zone.__symbol__(REMOVE_EVENT_LISTENER_STR),TRUE_STR="true",FALSE_STR="false",ZONE_SYMBOL_PREFIX="__zone_symbol__";function wrapWithCurrentZone(e,t){return Zone.current.wrap(e,t)}function scheduleMacroTaskWithCurrentZone(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const zoneSymbol=Zone.__symbol__,isWindowExists="undefined"!=typeof window,internalWindow=isWindowExists?window:void 0,_global=isWindowExists&&internalWindow||"object"==typeof self&&self||global,REMOVE_ATTRIBUTE="removeAttribute",NULL_ON_PROP_VALUE=[null];function bindArguments(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=wrapWithCurrentZone(e[n],t+"_"+n));return e}function patchPrototype(e,t){const n=e.constructor.name;for(let o=0;o{const t=function(){return e.apply(this,bindArguments(arguments,n+"."+r))};return attachOriginToPatched(t,e),t})(s)}}}function isPropertyWritable(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode=!("nw"in _global)&&void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process),isBrowser=!isNode&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),isMix=void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process)&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),zoneSymbolEventNames={},wrapFn=function(e){if(!(e=e||_global.event))return;let t=zoneSymbolEventNames[e.type];t||(t=zoneSymbolEventNames[e.type]=zoneSymbol("ON_PROPERTY"+e.type));const n=this||e.target||_global,o=n[t];let r;if(isBrowser&&n===internalWindow&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function patchProperty(e,t,n){let o=ObjectGetOwnPropertyDescriptor(e,t);if(!o&&n){ObjectGetOwnPropertyDescriptor(n,t)&&(o={enumerable:!0,configurable:!0})}if(!o||!o.configurable)return;const r=zoneSymbol("on"+t+"patched");if(e.hasOwnProperty(r)&&e[r])return;delete o.writable,delete o.value;const s=o.get,i=o.set,a=t.substr(2);let c=zoneSymbolEventNames[a];c||(c=zoneSymbolEventNames[a]=zoneSymbol("ON_PROPERTY"+a)),o.set=function(t){let n=this;n||e!==_global||(n=_global),n&&(n[c]&&n.removeEventListener(a,wrapFn),i&&i.apply(n,NULL_ON_PROP_VALUE),"function"==typeof t?(n[c]=t,n.addEventListener(a,wrapFn,!1)):n[c]=null)},o.get=function(){let n=this;if(n||e!==_global||(n=_global),!n)return null;const r=n[c];if(r)return r;if(s){let e=s&&s.call(this);if(e)return o.set.call(this,e),"function"==typeof n[REMOVE_ATTRIBUTE]&&n.removeAttribute(t),e}return null},ObjectDefineProperty(e,t,o),e[r]=!0}function patchOnProperties(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}let shouldCopySymbolProperties=!1;function patchMethod(e,t,n){let o=e;for(;o&&!o.hasOwnProperty(t);)o=ObjectGetPrototypeOf(o);!o&&e[t]&&(o=e);const r=zoneSymbol(t);let s=null;if(o&&!(s=o[r])){if(s=o[r]=o[t],isPropertyWritable(o&&ObjectGetOwnPropertyDescriptor(o,t))){const e=n(s,r,t);o[t]=function(){return e(this,arguments)},attachOriginToPatched(o[t],s),shouldCopySymbolProperties&©SymbolProperties(s,o[t])}}return s}function patchMacroTask(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=patchMethod(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?scheduleMacroTaskWithCurrentZone(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function attachOriginToPatched(e,t){e[zoneSymbol("OriginalDelegate")]=t}let isDetectedIEOrEdge=!1,ieOrEdge=!1;function isIE(){try{const e=internalWindow.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function isIEOrEdge(){if(isDetectedIEOrEdge)return ieOrEdge;isDetectedIEOrEdge=!0;try{const e=internalWindow.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(ieOrEdge=!0)}catch(e){}return ieOrEdge}Zone.__load_patch("toString",e=>{const t=Function.prototype.toString,n=zoneSymbol("OriginalDelegate"),o=zoneSymbol("Promise"),r=zoneSymbol("Error"),s=function(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});let passiveSupported=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){passiveSupported=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){passiveSupported=!1}const OPTIMIZED_ZONE_EVENT_TASK_DATA={useG:!0},zoneSymbolEventNames$1={},globalSources={},EVENT_NAME_SYMBOL_REGX=/^__zone_symbol__(\w+)(true|false)$/,IMMEDIATE_PROPAGATION_SYMBOL="__zone_symbol__propagationStopped";function patchEventTarget(e,t,n){const o=n&&n.add||ADD_EVENT_LISTENER_STR,r=n&&n.rm||REMOVE_EVENT_LISTENER_STR,s=n&&n.listeners||"eventListeners",i=n&&n.rmAll||"removeAllListeners",a=zoneSymbol(o),c="."+o+":",l="prependListener",u="."+l+":",p=function(e,t,n){if(e.isRemoved)return;const o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=(e=>o.handleEvent(e)),e.originalDelegate=o),e.invoke(e,t,[n]);const s=e.options;if(s&&"object"==typeof s&&s.once){const o=e.originalDelegate?e.originalDelegate:e.callback;t[r].call(t,n.type,o,s)}},h=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[zoneSymbolEventNames$1[t.type][FALSE_STR]];if(o)if(1===o.length)p(o[0],n,t);else{const e=o.slice();for(let o=0;o(function(t,n){t[IMMEDIATE_PROPAGATION_SYMBOL]=!0,e&&e.apply(t,n)}))}function patchCallbacks(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)}const zoneSymbol$1=Zone.__symbol__,_defineProperty=Object[zoneSymbol$1("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol$1("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol$1("unconfigurables");function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,o)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=_getOwnPropertyDescriptor(e,t);return n&&isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){const o=n.configurable;return _tryDefineProperty(e,t,n=rewriteDescriptor(e,t,n),o)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[unconfigurablesKey]||Object.isFrozen(e)||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey]&&(e[unconfigurablesKey][t]=!0)),n}function _tryDefineProperty(e,t,n,o){try{return _defineProperty(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return _defineProperty(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}}const globalEventHandlersEventNames=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],documentEventNames=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],windowEventNames=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],htmlElementEventNames=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],mediaElementEventNames=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ieElementEventNames=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],webglEventNames=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],formEventNames=["autocomplete","autocompleteerror"],detailEventNames=["toggle"],frameEventNames=["load"],frameSetEventNames=["blur","error","focus","load","resize","scroll","messageerror"],marqueeEventNames=["bounce","finish","start"],XMLHttpRequestEventNames=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],IDBIndexEventNames=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],websocketEventNames=["close","error","open","message"],workerEventNames=["error","message"],eventNames=globalEventHandlersEventNames.concat(webglEventNames,formEventNames,detailEventNames,documentEventNames,windowEventNames,htmlElementEventNames,ieElementEventNames);function filterProperties(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function patchFilteredProperties(e,t,n,o){if(!e)return;patchOnProperties(e,filterProperties(e,t,n),o)}function propertyDescriptorPatch(e,t){if(isNode&&!isMix)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(isBrowser){const e=window,t=isIE?[{target:e,ignoreProperties:["error"]}]:[];patchFilteredProperties(e,eventNames.concat(["messageerror"]),o?o.concat(t):o,ObjectGetPrototypeOf(e)),patchFilteredProperties(Document.prototype,eventNames,o),void 0!==e.SVGElement&&patchFilteredProperties(e.SVGElement.prototype,eventNames,o),patchFilteredProperties(Element.prototype,eventNames,o),patchFilteredProperties(HTMLElement.prototype,eventNames,o),patchFilteredProperties(HTMLMediaElement.prototype,mediaElementEventNames,o),patchFilteredProperties(HTMLFrameSetElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLBodyElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLFrameElement.prototype,frameEventNames,o),patchFilteredProperties(HTMLIFrameElement.prototype,frameEventNames,o);const n=e.HTMLMarqueeElement;n&&patchFilteredProperties(n.prototype,marqueeEventNames,o);const r=e.Worker;r&&patchFilteredProperties(r.prototype,workerEventNames,o)}const r=t.XMLHttpRequest;r&&patchFilteredProperties(r.prototype,XMLHttpRequestEventNames,o);const s=t.XMLHttpRequestEventTarget;s&&patchFilteredProperties(s&&s.prototype,XMLHttpRequestEventNames,o),"undefined"!=typeof IDBIndex&&(patchFilteredProperties(IDBIndex.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBOpenDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBDatabase.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBTransaction.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBCursor.prototype,IDBIndexEventNames,o)),n&&patchFilteredProperties(WebSocket.prototype,websocketEventNames,o)}Zone.__load_patch("util",(e,t,n)=>{n.patchOnProperties=patchOnProperties,n.patchMethod=patchMethod,n.bindArguments=bindArguments,n.patchMacroTask=patchMacroTask;const o=t.__symbol__("BLACK_LISTED_EVENTS"),r=t.__symbol__("UNPATCHED_EVENTS");e[r]&&(e[o]=e[r]),e[o]&&(t[o]=t[r]=e[o]),n.patchEventPrototype=patchEventPrototype,n.patchEventTarget=patchEventTarget,n.isIEOrEdge=isIEOrEdge,n.ObjectDefineProperty=ObjectDefineProperty,n.ObjectGetOwnPropertyDescriptor=ObjectGetOwnPropertyDescriptor,n.ObjectCreate=ObjectCreate,n.ArraySlice=ArraySlice,n.patchClass=patchClass,n.wrapWithCurrentZone=wrapWithCurrentZone,n.filterProperties=filterProperties,n.attachOriginToPatched=attachOriginToPatched,n._redefineProperty=_redefineProperty,n.patchCallbacks=patchCallbacks,n.getGlobalObjects=(()=>({globalSources,zoneSymbolEventNames:zoneSymbolEventNames$1,eventNames,isBrowser,isMix,isNode,TRUE_STR,FALSE_STR,ZONE_SYMBOL_PREFIX,ADD_EVENT_LISTENER_STR,REMOVE_EVENT_LISTENER_STR}))});const taskSymbol=zoneSymbol("zoneTask");function patchTimer(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[taskSymbol]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=patchMethod(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e={isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},n=scheduleMacroTaskWithCurrentZone(t,s[0],e,a,c);if(!n)return n;const r=n.data.handleId;return"number"==typeof r?i[r]=n:r&&(r[taskSymbol]=n),r&&r.ref&&r.unref&&"function"==typeof r.ref&&"function"==typeof r.unref&&(n.ref=r.ref.bind(r),n.unref=r.unref.bind(r)),"number"==typeof r||r?r:n}return n.apply(e,s)})),s=patchMethod(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[taskSymbol])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[taskSymbol]=null),s.zone.cancelTask(s)):t.apply(e,o)}))}function patchCustomElements(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();if(!((n||o)&&e.customElements&&"customElements"in e))return;t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}function eventTargetPatch(e,t){if(Zone[t.symbol("patchEventTarget")])return;const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{patchTimer(e,"set","clear","Timeout"),patchTimer(e,"set","clear","Interval"),patchTimer(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{patchTimer(e,"request","cancel","AnimationFrame"),patchTimer(e,"mozRequest","mozCancel","AnimationFrame"),patchTimer(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}}),Zone.__load_patch("EventTarget",(e,t,n)=>{patchEvent(e,n),eventTargetPatch(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("IntersectionObserver"),patchClass("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{propertyDescriptorPatch(n,e),propertyPatch()}),Zone.__load_patch("customElements",(e,t,n)=>{patchCustomElements(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function(e){const c=e.XMLHttpRequest;if(!c)return;const l=c.prototype;let u=l[ZONE_SYMBOL_ADD_EVENT_LISTENER],p=l[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];if(!u){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;u=e[ZONE_SYMBOL_ADD_EVENT_LISTENER],p=e[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]}}const h="readystatechange",f="scheduled";function d(e){const t=e.data,o=t.target;o[s]=!1,o[a]=!1;const i=o[r];u||(u=o[ZONE_SYMBOL_ADD_EVENT_LISTENER],p=o[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]),i&&p.call(o,h,i);const c=o[r]=(()=>{if(o.readyState===o.DONE)if(!t.aborted&&o[s]&&e.state===f){const n=o.__zone_symbol__loadfalse;if(n&&n.length>0){const r=e.invoke;e.invoke=function(){const n=o.__zone_symbol__loadfalse;for(let t=0;t(function(e,t){return e[o]=0==t[2],e[i]=t[1],g.apply(e,t)})),y=zoneSymbol("fetchTaskAborting"),E=zoneSymbol("fetchTaskScheduling"),b=patchMethod(l,"send",()=>(function(e,n){if(!0===t.current[E])return b.apply(e,n);if(e[o])return b.apply(e,n);{const t={target:e,url:e[i],isPeriodic:!1,args:n,aborted:!1},o=scheduleMacroTaskWithCurrentZone("XMLHttpRequest.send",_,t,d,m);e&&!0===e[a]&&!t.aborted&&o.state===f&&o.invoke()}})),T=patchMethod(l,"abort",()=>(function(e,o){const r=e[n];if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[y])return T.apply(e,o)}))}(e);const n=zoneSymbol("xhrTask"),o=zoneSymbol("xhrSync"),r=zoneSymbol("xhrListener"),s=zoneSymbol("xhrScheduled"),i=zoneSymbol("xhrURL"),a=zoneSymbol("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&patchPrototype(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){findEventTasks(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[zoneSymbol("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[zoneSymbol("rejectionHandledHandler")]=n("rejectionhandled"))}); \ No newline at end of file diff --git a/dist/zone-legacy.js b/dist/zone-legacy.js index 69d76cd2c..ab6b76b57 100644 --- a/dist/zone-legacy.js +++ b/dist/zone-legacy.js @@ -32,7 +32,7 @@ function eventTargetLegacyPatch(_global, api) { apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - // EventTarget is already patched in browser.ts + apis.push(EVENT_TARGET); } else { // Note: EventTarget is not available in all browsers, @@ -107,6 +107,7 @@ function eventTargetLegacyPatch(_global, api) { // vh is validateHandler to check event handler // is valid or not(for security check) api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; return true; } @@ -181,8 +182,8 @@ function propertyDescriptorLegacyPatch(api, _global) { if (isNode && !isMix) { return; } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - if (!canPatchViaPropertyDescriptor(api)) { + if (!canPatchViaPropertyDescriptor(api, _global)) { + var supportsWebSocket = typeof WebSocket !== 'undefined'; // Safari, Android browsers (Jelly Bean) patchViaCapturingAllTheEvents(api); api.patchClass('XMLHttpRequest'); @@ -192,7 +193,7 @@ function propertyDescriptorLegacyPatch(api, _global) { Zone[api.symbol('patchEvents')] = true; } } -function canPatchViaPropertyDescriptor(api) { +function canPatchViaPropertyDescriptor(api, _global) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((isBrowser || isMix) && !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && @@ -202,6 +203,26 @@ function canPatchViaPropertyDescriptor(api) { var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var div = document.createElement('div'); + var result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; + } + } + var XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return false; } var ON_READY_STATE_CHANGE = 'onreadystatechange'; var XMLHttpRequestPrototype = XMLHttpRequest.prototype; diff --git a/dist/zone-legacy.min.js b/dist/zone-legacy.min.js index 7ec8b01a1..292949830 100644 --- a/dist/zone-legacy.min.js +++ b/dist/zone-legacy.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function e(e,t){var n=e.getGlobalObjects(),r=n.isNode,a=n.isMix;if(!r||a){var o="undefined"!=typeof WebSocket;(function(e){var t=e.getGlobalObjects(),n=t.isBrowser,r=t.isMix;if((n||r)&&!e.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype,"onclick")&&"undefined"!=typeof Element){var a=e.ObjectGetOwnPropertyDescriptor(Element.prototype,"onclick");if(a&&!a.configurable)return!1}var o=XMLHttpRequest.prototype,c=e.ObjectGetOwnPropertyDescriptor(o,"onreadystatechange");if(c){e.ObjectDefineProperty(o,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return!0}});var i=new XMLHttpRequest,l=!!i.onreadystatechange;return e.ObjectDefineProperty(o,"onreadystatechange",c||{}),l}var s=e.symbol("fake");e.ObjectDefineProperty(o,"onreadystatechange",{enumerable:!0,configurable:!0,get:function(){return this[s]},set:function(e){this[s]=e}});var i=new XMLHttpRequest,u=function(){};i.onreadystatechange=u;var l=i[s]===u;return i.onreadystatechange=null,l})(e)||(!function(e){for(var t=e.getGlobalObjects().eventNames,n=e.symbol("unbound"),r=function(r){var a=t[r],o="on"+a;self.addEventListener(a,function(t){var r,a,c=t.target;for(a=c?c.constructor.name+"."+o:"unknown."+o;c;)c[o]&&!c[o][n]&&((r=e.wrapWithCurrentZone(c[o],a))[n]=c[o],c[o]=r),c=c.parentElement},!0)},a=0;a1?new o(t,n):new o(t),s=e.ObjectGetOwnPropertyDescriptor(l,"onmessage");return s&&!1===s.configurable?(c=e.ObjectCreate(l),i=l,[r,a,"send","close"].forEach(function(t){c[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===a){var o=n.length>0?n[0]:void 0;if(o){var i=Zone.__symbol__("ON_PROPERTY"+o);l[i]=c[i]}}return l[t].apply(l,n)}})):c=l,e.patchOnProperties(c,["close","error","message","open"],i),c};var c=t.WebSocket;for(var i in o)c[i]=o[i]}(e,t),Zone[e.symbol("patchEvents")]=!0)}}var t;(t="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global).__zone_symbol__legacyPatch=function(){var n=t.Zone;n.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,a=n.isMix;(r||a)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),n.__load_patch("EventTargetLegacy",function(t,n,r){!function(e,t){var n=t.getGlobalObjects(),r=n.eventNames,a=n.globalSources,o=n.zoneSymbolEventNames,c=n.TRUE_STR,i=n.FALSE_STR,l=n.ZONE_SYMBOL_PREFIX,s="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",u="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,WebSocket".split(","),p=[],f=e.wtf,b=s.split(",");f?p=b.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget||(p=u);for(var d=e.__Zone_disable_IE_check||!1,g=e.__Zone_enable_cross_context_check||!1,v=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",E=0;E1?new a(t,n):new a(t),s=e.ObjectGetOwnPropertyDescriptor(l,"onmessage");return s&&!1===s.configurable?(c=e.ObjectCreate(l),i=l,[r,o,"send","close"].forEach(function(t){c[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var i=Zone.__symbol__("ON_PROPERTY"+a);l[i]=c[i]}}return l[t].apply(l,n)}})):c=l,e.patchOnProperties(c,["close","error","message","open"],i),c};var c=t.WebSocket;for(var i in a)c[i]=a[i]}(e,t),Zone[e.symbol("patchEvents")]=!0}}var n;(n="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global).__zone_symbol__legacyPatch=function(){var r=n.Zone;r.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),r.__load_patch("EventTargetLegacy",function(n,r,o){e(n,o),t(o,n)})}}); \ No newline at end of file diff --git a/dist/zone-mix.js b/dist/zone-mix.js index df2cc402c..c8354162d 100644 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -2334,7 +2334,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ function patchCustomElements(_global, api) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('customElements' in _global)) { + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; @@ -2453,6 +2453,10 @@ function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { * found in the LICENSE file at https://angular.io/license */ function eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; // predefine all __zone_symbol__ + eventName + true/false string for (var i = 0; i < eventNames.length; i++) { @@ -2757,7 +2761,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); @@ -2845,6 +2853,11 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_URL = zoneSymbol('xhrURL'); var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { return target[XHR_TASK]; diff --git a/dist/zone-testing-bundle.js b/dist/zone-testing-bundle.js index d860dc392..2eeab9077 100644 --- a/dist/zone-testing-bundle.js +++ b/dist/zone-testing-bundle.js @@ -2632,7 +2632,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); @@ -2734,7 +2738,7 @@ function eventTargetLegacyPatch(_global, api) { apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - // EventTarget is already patched in browser.ts + apis.push(EVENT_TARGET); } else { // Note: EventTarget is not available in all browsers, @@ -2809,6 +2813,7 @@ function eventTargetLegacyPatch(_global, api) { // vh is validateHandler to check event handler // is valid or not(for security check) api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; return true; } @@ -2883,8 +2888,8 @@ function propertyDescriptorLegacyPatch(api, _global) { if (isNode && !isMix) { return; } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - if (!canPatchViaPropertyDescriptor(api)) { + if (!canPatchViaPropertyDescriptor(api, _global)) { + var supportsWebSocket = typeof WebSocket !== 'undefined'; // Safari, Android browsers (Jelly Bean) patchViaCapturingAllTheEvents(api); api.patchClass('XMLHttpRequest'); @@ -2894,7 +2899,7 @@ function propertyDescriptorLegacyPatch(api, _global) { Zone[api.symbol('patchEvents')] = true; } } -function canPatchViaPropertyDescriptor(api) { +function canPatchViaPropertyDescriptor(api, _global) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((isBrowser || isMix) && !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && @@ -2904,6 +2909,26 @@ function canPatchViaPropertyDescriptor(api) { var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var div = document.createElement('div'); + var result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; + } + } + var XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return false; } var ON_READY_STATE_CHANGE = 'onreadystatechange'; var XMLHttpRequestPrototype = XMLHttpRequest.prototype; @@ -3156,7 +3181,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ function patchCustomElements(_global, api) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('customElements' in _global)) { + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; @@ -3171,6 +3196,10 @@ function patchCustomElements(_global, api) { * found in the LICENSE file at https://angular.io/license */ function eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; // predefine all __zone_symbol__ + eventName + true/false string for (var i = 0; i < eventNames.length; i++) { @@ -3264,6 +3293,11 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_URL = zoneSymbol('xhrURL'); var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { return target[XHR_TASK]; @@ -3862,7 +3896,13 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync - var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; if (!ignoreUnhandledRejection) { var globalErrors_1 = jasmine.GlobalErrors; @@ -3911,48 +3951,50 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableClockPatch) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } } - } - return clock; - }; + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -3966,7 +4008,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableClockPatch) { + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { // auto run a fakeAsync var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { @@ -4452,7 +4494,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (doTick) { doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.args); + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js index 1114a410a..58d0a7038 100644 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -2906,7 +2906,13 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync - var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; if (!ignoreUnhandledRejection) { var globalErrors_1 = jasmine.GlobalErrors; @@ -2955,48 +2961,50 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableClockPatch) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); } - } - return clock; - }; + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -3010,7 +3018,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableClockPatch) { + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { // auto run a fakeAsync var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { @@ -3496,7 +3504,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (doTick) { doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.args); + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; diff --git a/dist/zone-testing.js b/dist/zone-testing.js index 221d8d75e..59a2b0c4d 100644 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -435,7 +435,13 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); var symbol = Zone.__symbol__; // whether patch jasmine clock when in fakeAsync - var enableClockPatch = _global[symbol('fakeAsyncPatchLock')] === true; + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; if (!ignoreUnhandledRejection) { var globalErrors_1 = jasmine.GlobalErrors; @@ -484,48 +490,50 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; return originalJasmineFn.apply(this, arguments); }; }); - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableClockPatch) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); } - } - return clock; - }; + return clock; + }; + } /** * Gets a function wrapping the body of a Jasmine `describe` block to execute in a * synchronous-only zone. @@ -539,7 +547,7 @@ Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; var isClockInstalled = !!jasmine[symbol('clockInstalled')]; var testProxyZoneSpec = queueRunner.testProxyZoneSpec; var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableClockPatch) { + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { // auto run a fakeAsync var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { @@ -1025,7 +1033,7 @@ var __spread = (undefined && undefined.__spread) || function () { if (doTick) { doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.args); + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; diff --git a/dist/zone.js b/dist/zone.js index f812a3b72..75d3e835e 100644 --- a/dist/zone.js +++ b/dist/zone.js @@ -2632,7 +2632,11 @@ function propertyDescriptorPatch(api, _global) { patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); } } - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; if (XMLHttpRequestEventTarget) { patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); @@ -2734,7 +2738,7 @@ function eventTargetLegacyPatch(_global, api) { apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); } else if (_global[EVENT_TARGET]) { - // EventTarget is already patched in browser.ts + apis.push(EVENT_TARGET); } else { // Note: EventTarget is not available in all browsers, @@ -2809,6 +2813,7 @@ function eventTargetLegacyPatch(_global, api) { // vh is validateHandler to check event handler // is valid or not(for security check) api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; return true; } @@ -2883,8 +2888,8 @@ function propertyDescriptorLegacyPatch(api, _global) { if (isNode && !isMix) { return; } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - if (!canPatchViaPropertyDescriptor(api)) { + if (!canPatchViaPropertyDescriptor(api, _global)) { + var supportsWebSocket = typeof WebSocket !== 'undefined'; // Safari, Android browsers (Jelly Bean) patchViaCapturingAllTheEvents(api); api.patchClass('XMLHttpRequest'); @@ -2894,7 +2899,7 @@ function propertyDescriptorLegacyPatch(api, _global) { Zone[api.symbol('patchEvents')] = true; } } -function canPatchViaPropertyDescriptor(api) { +function canPatchViaPropertyDescriptor(api, _global) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; if ((isBrowser || isMix) && !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && @@ -2904,6 +2909,26 @@ function canPatchViaPropertyDescriptor(api) { var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); if (desc && !desc.configurable) return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var div = document.createElement('div'); + var result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; + } + } + var XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return false; } var ON_READY_STATE_CHANGE = 'onreadystatechange'; var XMLHttpRequestPrototype = XMLHttpRequest.prototype; @@ -3156,7 +3181,7 @@ function patchTimer(window, setName, cancelName, nameSuffix) { */ function patchCustomElements(_global, api) { var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('customElements' in _global)) { + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; @@ -3171,6 +3196,10 @@ function patchCustomElements(_global, api) { * found in the LICENSE file at https://angular.io/license */ function eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; // predefine all __zone_symbol__ + eventName + true/false string for (var i = 0; i < eventNames.length; i++) { @@ -3264,6 +3293,11 @@ Zone.__load_patch('XHR', function (global, Zone) { var XHR_URL = zoneSymbol('xhrURL'); var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } var XMLHttpRequestPrototype = XMLHttpRequest.prototype; function findPendingTask(target) { return target[XHR_TASK]; diff --git a/dist/zone.min.js b/dist/zone.min.js index 3c96665e7..5709b6db5 100644 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";!function(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(o||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var a,i=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new c(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return Z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),t.__load_patch=function(a,i){if(P.hasOwnProperty(a)){if(o)throw Error("Already loaded patch: "+a)}else if(!e["__Zone_disable_"+a]){var s="Zone:"+a;n(s),P[a]=i(e,t,D),r(s,s)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){Z={parent:Z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{Z=Z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),Z={parent:Z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{Z=Z.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==O&&e.type!==S){var r=e.state!=k;r&&e._transitionTo(k,b),e.runCount++;var o=j;j=e,Z={parent:Z,zone:this};try{e.type==S&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==_&&e.state!==E&&(e.type==O||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,k):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,k,_))),Z=Z.parent,j=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(m,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,m,_),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==m&&e._transitionTo(b,m),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new l(w,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new l(S,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new l(O,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");e._transitionTo(T,b,k);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,T),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,T),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),l=function(){function t(n,r,o,a,i,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=s,this.callback=o;var c=this;n===O&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&g(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,m)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),u=I("setTimeout"),f=I("Promise"),p=I("then"),h=[],d=!1;function v(t){if(0===z&&0===h.length)if(a||e[f]&&(a=e[f].resolve(0)),a){var n=a[p];n||(n=a.then),n.call(a,g)}else e[u](g,0);t&&h.push(t)}function g(){if(!d){for(d=!0;h.length;){var e=h;h=[];for(var t=0;t=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Zone.__load_patch("ZoneAwarePromise",function(t,n,r){var o=Object.getOwnPropertyDescriptor,a=Object.defineProperty;var i=r.symbol,s=[],c=i("Promise"),l=i("then"),u="__creationTrace__";r.onUnhandledError=function(e){if(r.showUncaughtError()){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)}},r.microtaskDrainDone=function(){for(;s.length;)for(var e=function(){var e=s.shift();try{e.zone.runGuarded(function(){throw e})}catch(e){p(e)}};s.length;)e()};var f=i("unhandledPromiseRejectionHandler");function p(e){r.onUnhandledError(e);try{var t=n[f];t&&"function"==typeof t&&t.call(this,e)}catch(e){}}function h(e){return e&&e.then}function d(e){return e}function v(e){return R.reject(e)}var g=i("state"),y=i("value"),_=i("finally"),m=i("parentPromiseValue"),b=i("parentPromiseState"),k="Promise.then",T=null,E=!0,w=!1,S=0;function O(e,t){return function(n){try{j(e,t,n)}catch(t){j(e,!1,t)}}}var P=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},D="Promise resolved with itself",Z=i("currentTaskTrace");function j(e,t,o){var i=P();if(e===o)throw new TypeError(D);if(e[g]===T){var c=null;try{"object"!=typeof o&&"function"!=typeof o||(c=o&&o.then)}catch(t){return i(function(){j(e,!1,t)})(),e}if(t!==w&&o instanceof R&&o.hasOwnProperty(g)&&o.hasOwnProperty(y)&&o[g]!==T)C(o),j(e,o[g],o[y]);else if(t!==w&&"function"==typeof c)try{c.call(o,i(O(e,t)),i(O(e,!1)))}catch(t){i(function(){j(e,!1,t)})()}else{e[g]=t;var l=e[y];if(e[y]=o,e[_]===_&&t===E&&(e[g]=e[b],e[y]=e[m]),t===w&&o instanceof Error){var f=n.currentTask&&n.currentTask.data&&n.currentTask.data[u];f&&a(o,Z,{configurable:!0,enumerable:!1,writable:!0,value:f})}for(var p=0;p=0;n--)"function"==typeof e[n]&&(e[n]=h(e[n],t+"_"+n));return e}function T(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in _)&&void 0!==_.process&&"[object process]"==={}.toString.call(_.process),S=!w&&!E&&!(!g||!y.HTMLElement),O=void 0!==_.process&&"[object process]"==={}.toString.call(_.process)&&!E&&!(!g||!y.HTMLElement),P={},D=function(e){if(e=e||_.event){var t=P[e.type];t||(t=P[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||_,o=r[t];if(S&&r===y&&"error"===e.type){var a=e;!0===(n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error))&&e.preventDefault()}else null==(n=o&&o.apply(this,arguments))||n||e.preventDefault();return n}};function Z(e,r,o){var a=t(e,r);!a&&o&&(t(o,r)&&(a={enumerable:!0,configurable:!0}));if(a&&a.configurable){var i=v("on"+r+"patched");if(!e.hasOwnProperty(i)||!e[i]){delete a.writable,delete a.value;var s=a.get,c=a.set,l=r.substr(2),u=P[l];u||(u=P[l]=v("ON_PROPERTY"+l)),a.set=function(t){var n=this;(n||e!==_||(n=_),n)&&(n[u]&&n.removeEventListener(l,D),c&&c.apply(n,b),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},a.get=function(){var t=this;if(t||e!==_||(t=_),!t)return null;var n=t[u];if(n)return n;if(s){var o=s&&s.call(this);if(o)return a.set.call(this,o),"function"==typeof t[m]&&t.removeAttribute(r),o}return null},n(e,r,a),e[i]=!0}}}function j(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?d(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function M(e,t){e[v("OriginalDelegate")]=t}var x=!1,N=!1;function F(){try{var e=y.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function H(){if(x)return N;x=!0;try{var e=y.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(N=!0)}catch(e){}return N}Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.call(i)}if(this===Error){var s=e[o];if(s)return t.call(s)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});var A=!1;if("undefined"!=typeof window)try{var B=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",B,B),window.removeEventListener("test",B,B)}catch(e){A=!1}var G={useG:!0},q={},W={},U=/^__zone_symbol__(\w+)(true|false)$/,X="__zone_symbol__propagationStopped";function V(e,t,n){var o=n&&n.add||i,a=n&&n.rm||s,c=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",h=v(o),d="."+o+":",g="prependListener",y="."+g+":",_=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;if(o&&"object"==typeof o&&o.once){var i=e.originalDelegate?e.originalDelegate:e.callback;t[a].call(t,n.type,i,o)}}},m=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[q[t.type][f]];if(r)if(1===r.length)_(r[0],n,t);else for(var o=r.slice(),a=0;a1?new a(t,n):new a(t),l=e.ObjectGetOwnPropertyDescriptor(c,"onmessage");return l&&!1===l.configurable?(i=e.ObjectCreate(c),s=c,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var s=Zone.__symbol__("ON_PROPERTY"+a);c[s]=i[s]}}return c[t].apply(c,n)}})):i=c,e.patchOnProperties(i,["close","error","message","open"],s),i};var i=t.WebSocket;for(var s in a)i[s]=a[s]}(e,t),Zone[e.symbol("patchEvents")]=!0)}}Zone.__load_patch("util",function(e,r,c){c.patchOnProperties=j,c.patchMethod=R,c.bindArguments=k,c.patchMacroTask=L;var l=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[l]=e[d]),e[l]&&(r[l]=r[d]=e[l]),c.patchEventPrototype=K,c.patchEventTarget=V,c.isIEOrEdge=H,c.ObjectDefineProperty=n,c.ObjectGetOwnPropertyDescriptor=t,c.ObjectCreate=o,c.ArraySlice=a,c.patchClass=C,c.wrapWithCurrentZone=h,c.filterProperties=ye,c.attachOriginToPatched=M,c._redefineProperty=re,c.patchCallbacks=J,c.getGlobalObjects=function(){return{globalSources:W,zoneSymbolEventNames:q,eventNames:ge,isBrowser:S,isMix:O,isNode:w,TRUE_STR:u,FALSE_STR:f,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:s}}}),function(e){e.__zone_symbol__legacyPatch=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.eventNames,o=n.globalSources,a=n.zoneSymbolEventNames,i=n.TRUE_STR,s=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,l="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",u="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,WebSocket".split(","),f=[],p=e.wtf,h=l.split(",");p?f=h.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget||(f=u);for(var d=e.__Zone_disable_IE_check||!1,v=e.__Zone_enable_cross_context_check||!1,g=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",_=0;_0){var o=e.invoke;e.invoke=function(){for(var n=r.__zone_symbol__loadfalse,a=0;a",this._properties=t&&t.properties||{},this._zoneDelegate=new s(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return Z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),t.__load_patch=function(a,i){if(P.hasOwnProperty(a)){if(o)throw Error("Already loaded patch: "+a)}else if(!e["__Zone_disable_"+a]){var c="Zone:"+a;n(c),P[a]=i(e,t,D),r(c,c)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){Z={parent:Z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{Z=Z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),Z={parent:Z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{Z=Z.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==S&&e.type!==O){var r=e.state!=k;r&&e._transitionTo(k,b),e.runCount++;var o=j;j=e,Z={parent:Z,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==_&&e.state!==E&&(e.type==S||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,k):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,k,_))),Z=Z.parent,j=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(m,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,m,_),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==m&&e._transitionTo(b,m),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new l(w,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new l(O,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new l(S,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");e._transitionTo(T,b,k);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,T),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,T),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),l=function(){function t(n,r,o,a,i,c){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=c,this.callback=o;var s=this;n===S&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,s,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&g(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,m)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),u=I("setTimeout"),f=I("Promise"),p=I("then"),h=[],d=!1;function v(t){if(0===z&&0===h.length)if(a||e[f]&&(a=e[f].resolve(0)),a){var n=a[p];n||(n=a.then),n.call(a,g)}else e[u](g,0);t&&h.push(t)}function g(){if(!d){for(d=!0;h.length;){var e=h;h=[];for(var t=0;t=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Zone.__load_patch("ZoneAwarePromise",function(t,n,r){var o=Object.getOwnPropertyDescriptor,a=Object.defineProperty;var i=r.symbol,c=[],s=i("Promise"),l=i("then"),u="__creationTrace__";r.onUnhandledError=function(e){if(r.showUncaughtError()){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)}},r.microtaskDrainDone=function(){for(;c.length;)for(var e=function(){var e=c.shift();try{e.zone.runGuarded(function(){throw e})}catch(e){p(e)}};c.length;)e()};var f=i("unhandledPromiseRejectionHandler");function p(e){r.onUnhandledError(e);try{var t=n[f];t&&"function"==typeof t&&t.call(this,e)}catch(e){}}function h(e){return e&&e.then}function d(e){return e}function v(e){return R.reject(e)}var g=i("state"),y=i("value"),_=i("finally"),m=i("parentPromiseValue"),b=i("parentPromiseState"),k="Promise.then",T=null,E=!0,w=!1,O=0;function S(e,t){return function(n){try{j(e,t,n)}catch(t){j(e,!1,t)}}}var P=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},D="Promise resolved with itself",Z=i("currentTaskTrace");function j(e,t,o){var i=P();if(e===o)throw new TypeError(D);if(e[g]===T){var s=null;try{"object"!=typeof o&&"function"!=typeof o||(s=o&&o.then)}catch(t){return i(function(){j(e,!1,t)})(),e}if(t!==w&&o instanceof R&&o.hasOwnProperty(g)&&o.hasOwnProperty(y)&&o[g]!==T)C(o),j(e,o[g],o[y]);else if(t!==w&&"function"==typeof s)try{s.call(o,i(S(e,t)),i(S(e,!1)))}catch(t){i(function(){j(e,!1,t)})()}else{e[g]=t;var l=e[y];if(e[y]=o,e[_]===_&&t===E&&(e[g]=e[b],e[y]=e[m]),t===w&&o instanceof Error){var f=n.currentTask&&n.currentTask.data&&n.currentTask.data[u];f&&a(o,Z,{configurable:!0,enumerable:!1,writable:!0,value:f})}for(var p=0;p=0;n--)"function"==typeof e[n]&&(e[n]=h(e[n],t+"_"+n));return e}function T(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in _)&&void 0!==_.process&&"[object process]"==={}.toString.call(_.process),O=!w&&!E&&!(!g||!y.HTMLElement),S=void 0!==_.process&&"[object process]"==={}.toString.call(_.process)&&!E&&!(!g||!y.HTMLElement),P={},D=function(e){if(e=e||_.event){var t=P[e.type];t||(t=P[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||_,o=r[t];if(O&&r===y&&"error"===e.type){var a=e;!0===(n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error))&&e.preventDefault()}else null==(n=o&&o.apply(this,arguments))||n||e.preventDefault();return n}};function Z(e,r,o){var a=t(e,r);!a&&o&&(t(o,r)&&(a={enumerable:!0,configurable:!0}));if(a&&a.configurable){var i=v("on"+r+"patched");if(!e.hasOwnProperty(i)||!e[i]){delete a.writable,delete a.value;var c=a.get,s=a.set,l=r.substr(2),u=P[l];u||(u=P[l]=v("ON_PROPERTY"+l)),a.set=function(t){var n=this;(n||e!==_||(n=_),n)&&(n[u]&&n.removeEventListener(l,D),s&&s.apply(n,b),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},a.get=function(){var t=this;if(t||e!==_||(t=_),!t)return null;var n=t[u];if(n)return n;if(c){var o=c&&c.call(this);if(o)return a.set.call(this,o),"function"==typeof t[m]&&t.removeAttribute(r),o}return null},n(e,r,a),e[i]=!0}}}function j(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?d(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function M(e,t){e[v("OriginalDelegate")]=t}var x=!1,N=!1;function F(){try{var e=y.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function H(){if(x)return N;x=!0;try{var e=y.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(N=!0)}catch(e){}return N}Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.call(i)}if(this===Error){var c=e[o];if(c)return t.call(c)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});var A=!1;if("undefined"!=typeof window)try{var B=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",B,B),window.removeEventListener("test",B,B)}catch(e){A=!1}var G={useG:!0},W={},q={},U=/^__zone_symbol__(\w+)(true|false)$/,X="__zone_symbol__propagationStopped";function V(e,t,n){var o=n&&n.add||i,a=n&&n.rm||c,s=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",h=v(o),d="."+o+":",g="prependListener",y="."+g+":",_=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;if(o&&"object"==typeof o&&o.once){var i=e.originalDelegate?e.originalDelegate:e.callback;t[a].call(t,n.type,i,o)}}},m=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[W[t.type][f]];if(r)if(1===r.length)_(r[0],n,t);else for(var o=r.slice(),a=0;a1?new a(t,n):new a(t),l=e.ObjectGetOwnPropertyDescriptor(s,"onmessage");return l&&!1===l.configurable?(i=e.ObjectCreate(s),c=s,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var c=Zone.__symbol__("ON_PROPERTY"+a);s[c]=i[c]}}return s[t].apply(s,n)}})):i=s,e.patchOnProperties(i,["close","error","message","open"],c),i};var i=t.WebSocket;for(var c in a)i[c]=a[c]}(e,t),Zone[e.symbol("patchEvents")]=!0}}Zone.__load_patch("util",function(e,r,s){s.patchOnProperties=j,s.patchMethod=R,s.bindArguments=k,s.patchMacroTask=L;var l=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[l]=e[d]),e[l]&&(r[l]=r[d]=e[l]),s.patchEventPrototype=K,s.patchEventTarget=V,s.isIEOrEdge=H,s.ObjectDefineProperty=n,s.ObjectGetOwnPropertyDescriptor=t,s.ObjectCreate=o,s.ArraySlice=a,s.patchClass=C,s.wrapWithCurrentZone=h,s.filterProperties=ye,s.attachOriginToPatched=M,s._redefineProperty=re,s.patchCallbacks=J,s.getGlobalObjects=function(){return{globalSources:q,zoneSymbolEventNames:W,eventNames:ge,isBrowser:O,isMix:S,isNode:w,TRUE_STR:u,FALSE_STR:f,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:c}}}),function(e){e.__zone_symbol__legacyPatch=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){be(e,n),ke(n,e)})}}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);var Te=v("zoneTask");function Ee(e,t,n,r){var o=null,a=null;n+=r;var i={};function c(t){var n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[Te]=null))}},n.handleId=o.apply(e,n.args),t}function s(e){return a(e.data.handleId)}o=R(e,t+=r,function(n){return function(o,a){if("function"==typeof a[0]){var l={isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?a[1]||0:void 0,args:a},u=d(t,a[0],l,c,s);if(!u)return u;var f=u.data.handleId;return"number"==typeof f?i[f]=u:f&&(f[Te]=u),f&&f.ref&&f.unref&&"function"==typeof f.ref&&"function"==typeof f.unref&&(u.ref=f.ref.bind(f),u.unref=f.unref.bind(f)),"number"==typeof f||f?f:u}return n.apply(e,a)}}),a=R(e,n,function(t){return function(n,r){var o,a=r[0];"number"==typeof a?o=i[a]:(o=a&&a[Te])||(o=a),o&&"string"==typeof o.type?"notScheduled"!==o.state&&(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&("number"==typeof a?delete i[a]:a&&(a[Te]=null),o.zone.cancelTask(o)):t.apply(e,r)}})}function we(e,t){if(!Zone[t.symbol("patchEventTarget")]){for(var n=t.getGlobalObjects(),r=n.eventNames,o=n.zoneSymbolEventNames,a=n.TRUE_STR,i=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,s=0;s0){var o=e.invoke;e.invoke=function(){for(var n=r.__zone_symbol__loadfalse,a=0;a Date: Tue, 14 May 2019 05:30:14 +0300 Subject: [PATCH 104/106] feat(core): Add an option '__Zone_symbol_prefix' to set symbol prefix used in Zone.__symbol__(). (#1219) * feat(core): Add an option '__Zone_symbol_prefix' to set symbol prefix used in Zone.__symbol__(). Add a global environment option `__Zone_symbol_prefix` to allow configuring the symbol prefix Zone.js uses to store its state data on objects. This is needed in situations where multiple instances of Zone.js may 'touch' the same object or DOM node, accessing and clobbering the other instance's data stored there, and causing unpredictable behavior. Ultimately, it would be nice if Zone.js used proper ES6 symbols or some unique idetifier as a prefix, but many products rely on being able to access the data stored by it. This change adds the env option and cleans up all hard-coded references to '__zone_symbol_XXX' to go through `Zone.__symbol__()`. In order to test the changes and protect against regressions, the tests are run with the symbol prefix changed to `__zone_symbol_test__`. While the primary purpose of this change is to be able to isolate data stored on the objects & DOM nodes, some global environment options are also specified with the `__zone_symbol__` prefix and not the usual `__Zone_` one. The current API for providing env options isn't very consistent. For example, disabling 'on' property patching is done via `__Zone_ignore_on_properties`, w/o using the symbol prefix, while disabling event patching is done via `__zone_symbol__UNPATCHED_EVENTS`, using the symbol prefix. This change only affects the options that are prefixed with `__zone_symbol__`. * Fix failing karma test. * Remove trailing whitespace. * Bump up the file size limiit. --- file-size-limit.json | 2 +- gulpfile.js | 2 ++ karma-build.conf.js | 1 + karma-dist.conf.js | 1 + karma-evergreen-dist.conf.js | 1 + lib/browser/browser-legacy.ts | 2 +- lib/browser/browser.ts | 4 ++-- lib/common/events.ts | 6 ++--- lib/common/utils.ts | 4 ++-- lib/jasmine/jasmine.ts | 4 ++-- lib/zone.ts | 24 +++++++++++++++---- promise-adapter.js | 2 +- promise.finally.spec.js | 2 +- test/browser-env-setup.ts | 2 ++ test/browser-zone-setup.ts | 3 ++- test/browser/XMLHttpRequest.spec.ts | 12 +++++----- test/browser/browser.spec.ts | 12 +++++----- test/common/Error.spec.ts | 4 ++-- test/node-env-setup.ts | 2 ++ test/node_entry_point.ts | 10 ++++---- test/test-env-setup-jasmine-no-patch-clock.ts | 2 +- test/test-util.ts | 5 +++- test/test_fake_polyfill.ts | 8 +++++-- test/zone-spec/fake-async-test.spec.ts | 4 ++-- 24 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 test/browser-env-setup.ts create mode 100644 test/node-env-setup.ts diff --git a/file-size-limit.json b/file-size-limit.json index 9e1eb5184..97c9f3a97 100644 --- a/file-size-limit.json +++ b/file-size-limit.json @@ -8,7 +8,7 @@ { "path": "dist/zone.min.js", "checkTarget": true, - "limit": 44500 + "limit": 45000 } ] } diff --git a/gulpfile.js b/gulpfile.js index d5a7eb124..8a888d9d7 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -466,6 +466,8 @@ gulp.task('build', [ ]); function nodeTest(specFiles, cb) { + require('./build/test/node-env-setup'); + // load zone-node here to let jasmine be able to use jasmine.clock().install() // without throw error require('./build/lib/node/rollup-main'); diff --git a/karma-build.conf.js b/karma-build.conf.js index 53c53fa0b..a3e2d2503 100644 --- a/karma-build.conf.js +++ b/karma-build.conf.js @@ -9,6 +9,7 @@ module.exports = function(config) { require('./karma-base.conf.js')(config); config.files.push('node_modules/core-js-bundle/index.js'); + config.files.push('build/test/browser-env-setup.js'); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/lib/zone.js'); diff --git a/karma-dist.conf.js b/karma-dist.conf.js index a1f3f5921..f592296ca 100644 --- a/karma-dist.conf.js +++ b/karma-dist.conf.js @@ -9,6 +9,7 @@ module.exports = function(config) { require('./karma-base.conf.js')(config); config.files.push('node_modules/core-js-bundle/index.js'); + config.files.push('build/test/browser-env-setup.js'); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); diff --git a/karma-evergreen-dist.conf.js b/karma-evergreen-dist.conf.js index 19f93023e..3966686af 100644 --- a/karma-evergreen-dist.conf.js +++ b/karma-evergreen-dist.conf.js @@ -16,6 +16,7 @@ module.exports = function(config) { } } + config.files.push('build/test/browser-env-setup.js'); config.files.push('build/test/wtf_mock.js'); config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/test/custom_error.js'); diff --git a/lib/browser/browser-legacy.ts b/lib/browser/browser-legacy.ts index 2637c353d..34d707012 100644 --- a/lib/browser/browser-legacy.ts +++ b/lib/browser/browser-legacy.ts @@ -15,7 +15,7 @@ import {propertyDescriptorLegacyPatch} from './property-descriptor-legacy'; import {registerElementPatch} from './register-element'; (function(_global: any) { -_global['__zone_symbol__legacyPatch'] = function() { +_global[Zone.__symbol__('legacyPatch')] = function() { const Zone = _global['Zone']; Zone.__load_patch('registerElement', (global: any, Zone: ZoneType, api: _ZonePrivate) => { registerElementPatch(global, api); diff --git a/lib/browser/browser.ts b/lib/browser/browser.ts index dcd334ad7..040d670e0 100644 --- a/lib/browser/browser.ts +++ b/lib/browser/browser.ts @@ -142,13 +142,13 @@ Zone.__load_patch('XHR', (global: any, Zone: ZoneType) => { // check whether the xhr has registered onload listener // if that is the case, the task should invoke after all // onload listeners finish. - const loadTasks = target['__zone_symbol__loadfalse']; + const loadTasks = target[Zone.__symbol__('loadfalse')]; if (loadTasks && loadTasks.length > 0) { const oriInvoke = task.invoke; task.invoke = function() { // need to load the tasks again, because in other // load listener, they may remove themselves - const loadTasks = target['__zone_symbol__loadfalse']; + const loadTasks = target[Zone.__symbol__('loadfalse')]; for (let i = 0; i < loadTasks.length; i++) { if (loadTasks[i] === task) { loadTasks.splice(i, 1); diff --git a/lib/common/events.ts b/lib/common/events.ts index ff2442dfe..0fe1b28bf 100644 --- a/lib/common/events.ts +++ b/lib/common/events.ts @@ -43,8 +43,8 @@ const OPTIMIZED_ZONE_EVENT_TASK_DATA: EventTaskData = { export const zoneSymbolEventNames: any = {}; export const globalSources: any = {}; -const EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -const IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); +const EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); +const IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); export interface PatchEventTargetOptions { // validateHandler @@ -327,7 +327,7 @@ export function patchEventTarget( const compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - const blackListedEvents: string[] = (Zone as any)[Zone.__symbol__('BLACK_LISTED_EVENTS')]; + const blackListedEvents: string[] = (Zone as any)[zoneSymbol('BLACK_LISTED_EVENTS')]; const makeAddListener = function( nativeListener: any, addSource: string, customScheduleFn: any, customCancelFn: any, diff --git a/lib/common/utils.ts b/lib/common/utils.ts index b032f3c5a..8bb86f438 100644 --- a/lib/common/utils.ts +++ b/lib/common/utils.ts @@ -34,8 +34,8 @@ export const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LI export const TRUE_STR = 'true'; /** false string const */ export const FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -export const ZONE_SYMBOL_PREFIX = '__zone_symbol__'; +/** Zone symbol prefix string const. */ +export const ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); export function wrapWithCurrentZone(callback: T, source: string): T { return Zone.current.wrap(callback, source); diff --git a/lib/jasmine/jasmine.ts b/lib/jasmine/jasmine.ts index d75800992..8fcb2832d 100644 --- a/lib/jasmine/jasmine.ts +++ b/lib/jasmine/jasmine.ts @@ -217,8 +217,8 @@ ambientZone.scheduleMicroTask('jasmine.onComplete', fn); })(attrs.onComplete); - const nativeSetTimeout = _global['__zone_symbol__setTimeout']; - const nativeClearTimeout = _global['__zone_symbol__clearTimeout']; + const nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; + const nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; if (nativeSetTimeout) { // should run setTimeout inside jasmine outside of zone attrs.timeout = { diff --git a/lib/zone.ts b/lib/zone.ts index 3c6204e65..d6ae82cec 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -154,6 +154,7 @@ interface Zone { * @returns {any} The value for the key, or `undefined` if not found. */ get(key: string): any; + /** * Returns a Zone which defines a `key`. * @@ -163,6 +164,7 @@ interface Zone { * @returns {Zone} The Zone which defines the `key`, `null` if not found. */ getZoneWith(key: string): Zone|null; + /** * Used to create a child zone. * @@ -170,6 +172,7 @@ interface Zone { * @returns {Zone} A new child zone. */ fork(zoneSpec: ZoneSpec): Zone; + /** * Wraps a callback function in a new function which will properly restore the current zone upon * invocation. @@ -184,6 +187,7 @@ interface Zone { * @returns {function(): *} A function which will invoke the `callback` through [Zone.runGuarded]. */ wrap(callback: F, source: string): F; + /** * Invokes a function in a given zone. * @@ -196,6 +200,7 @@ interface Zone { * @returns {any} Value from the `callback` function. */ run(callback: Function, applyThis?: any, applyArgs?: any[], source?: string): T; + /** * Invokes a function in a given zone and catches any exceptions. * @@ -211,6 +216,7 @@ interface Zone { * @returns {any} Value from the `callback` function. */ runGuarded(callback: Function, applyThis?: any, applyArgs?: any[], source?: string): T; + /** * Execute the Task by restoring the [Zone.currentTask] in the Task's zone. * @@ -287,6 +293,7 @@ interface ZoneType { * duration of the run method callback. */ current: Zone; + /** * @returns {Task} The task associated with the current execution. */ @@ -666,7 +673,17 @@ const Zone: ZoneType = (function(global: any) { performance && performance['measure'] && performance['measure'](name, label); } mark('Zone'); - const checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; + + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + const symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + + function __symbol__(name: string) { + return symbolPrefix + name; + } + + const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; if (global['Zone']) { // if global['Zone'] already exists (maybe zone.js was already loaded or // some other lib also registered a global object named Zone), we may need @@ -1284,6 +1301,7 @@ const Zone: ZoneType = (function(global: any) { } } + ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// /// MICROTASK QUEUE @@ -1397,10 +1415,6 @@ const Zone: ZoneType = (function(global: any) { function noop() {} - function __symbol__(name: string) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); return global['Zone'] = Zone; })(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); diff --git a/promise-adapter.js b/promise-adapter.js index ea81bddfb..ccc088c97 100644 --- a/promise-adapter.js +++ b/promise-adapter.js @@ -1,5 +1,5 @@ require('./dist/zone-node.js'); -Zone[('__zone_symbol__ignoreConsoleErrorUncaughtError')] = true; +Zone[Zone.__symbol__('ignoreConsoleErrorUncaughtError')] = true; module.exports.deferred = function() { const p = {}; p.promise = new Promise((resolve, reject) => { diff --git a/promise.finally.spec.js b/promise.finally.spec.js index 35a5c4e57..a6974bc95 100644 --- a/promise.finally.spec.js +++ b/promise.finally.spec.js @@ -2,7 +2,7 @@ var assert = require('assert'); var adapter = require('./promise-adapter'); -var P = global['__zone_symbol__Promise']; +var P = global[Zone.__symbol__('Promise')]; var someRejectionReason = {message: 'some rejection reason'}; var anotherReason = {message: 'another rejection reason'}; diff --git a/test/browser-env-setup.ts b/test/browser-env-setup.ts new file mode 100644 index 000000000..c8d657731 --- /dev/null +++ b/test/browser-env-setup.ts @@ -0,0 +1,2 @@ +// Change default symbol prefix for testing to ensure no hard-coded references. +(window as any)['__Zone_symbol_prefix'] = '_test__'; diff --git a/test/browser-zone-setup.ts b/test/browser-zone-setup.ts index 2e157175d..3b3f4a809 100644 --- a/test/browser-zone-setup.ts +++ b/test/browser-zone-setup.ts @@ -6,8 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ if (typeof window !== 'undefined') { + const zoneSymbol = (window as any).Zone.__symbol__; (window as any)['__Zone_enable_cross_context_check'] = true; - (window as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] = true; + (window as any)[zoneSymbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] = true; } import '../lib/common/to-string'; import '../lib/browser/api-util'; diff --git a/test/browser/XMLHttpRequest.spec.ts b/test/browser/XMLHttpRequest.spec.ts index 2a54e5901..7adddde4a 100644 --- a/test/browser/XMLHttpRequest.spec.ts +++ b/test/browser/XMLHttpRequest.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {ifEnvSupports, ifEnvSupportsWithDone, supportPatchXHROnProperty} from '../test-util'; +import {ifEnvSupports, ifEnvSupportsWithDone, supportPatchXHROnProperty, zoneSymbol} from '../test-util'; describe('XMLHttpRequest', function() { let testZone: Zone; @@ -45,7 +45,7 @@ describe('XMLHttpRequest', function() { .toMatch(/\> Zone\:invokeTask.*addEventListener\:load/); } // if browser can patch onload - if ((req as any)['__zone_symbol__loadfalse']) { + if ((req as any)[zoneSymbol('loadfalse')]) { expect(logs).toEqual(['onload']); } done(); @@ -278,8 +278,8 @@ describe('XMLHttpRequest', function() { } req.addEventListener('readystatechange', function(ev) { if (req.readyState === 4) { - const xhrScheduled = (req as any)['__zone_symbol__xhrScheduled']; - const task = (req as any)['__zone_symbol__xhrTask']; + const xhrScheduled = (req as any)[zoneSymbol('xhrScheduled')]; + const task = (req as any)[zoneSymbol('xhrTask')]; if (xhrScheduled === false) { expect(task.state).toEqual('scheduling'); setTimeout(() => { @@ -323,7 +323,7 @@ describe('XMLHttpRequest', function() { let isError = false; let timerId = null; try { - timerId = (window as any)['__zone_symbol__setTimeout'](() => { + timerId = (window as any)[zoneSymbol('setTimeout')](() => { expect(logs).toEqual([ `{"microTask":false,"macroTask":true,"eventTask":false,"change":"macroTask"}`, `{"microTask":false,"macroTask":false,"eventTask":false,"change":"macroTask"}` @@ -333,7 +333,7 @@ describe('XMLHttpRequest', function() { req.send(); } catch (error) { isError = true; - (window as any)['__zone_symbol__clearTimeout'](timerId); + (window as any)[zoneSymbol('clearTimeout')](timerId); done(); } }); diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index a74f3683f..96fe7151a 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -8,7 +8,7 @@ import {patchFilteredProperties} from '../../lib/browser/property-descriptor'; import {patchEventTarget} from '../../lib/common/events'; -import {isBrowser, isIEOrEdge, isMix, zoneSymbol} from '../../lib/common/utils'; +import {isIEOrEdge, zoneSymbol} from '../../lib/common/utils'; import {getEdgeVersion, getIEVersion, ifEnvSupports, ifEnvSupportsWithDone, isEdge} from '../test-util'; import Spy = jasmine.Spy; @@ -306,8 +306,8 @@ describe('Zone', function() { const logs: string[] = []; const EventTarget = (window as any)['EventTarget']; let oriAddEventListener = EventTarget && EventTarget.prototype ? - (EventTarget.prototype as any)['__zone_symbol__addEventListener'] : - (HTMLSpanElement.prototype as any)['__zone_symbol__addEventListener']; + (EventTarget.prototype as any)[zoneSymbol('addEventListener')] : + (HTMLSpanElement.prototype as any)[zoneSymbol('addEventListener')]; if (!oriAddEventListener) { // no patched addEventListener found @@ -334,7 +334,7 @@ describe('Zone', function() { return oriAddEventListener.apply(this, arguments); }; - (HTMLSpanElement.prototype as any)['__zone_symbol__addEventListener'] = null; + (HTMLSpanElement.prototype as any)[zoneSymbol('addEventListener')] = null; patchEventTarget(window, [HTMLSpanElement.prototype]); @@ -356,10 +356,10 @@ describe('Zone', function() { expect(logs).toEqual(['listener1', 'listener2']); document.body.removeChild(span); if (EventTarget) { - (EventTarget.prototype as any)['__zone_symbol__addEventListener'] = + (EventTarget.prototype as any)[zoneSymbol('addEventListener')] = oriAddEventListener; } else { - (HTMLSpanElement.prototype as any)['__zone_symbol__addEventListener'] = + (HTMLSpanElement.prototype as any)[zoneSymbol('addEventListener')] = oriAddEventListener; } })); diff --git a/test/common/Error.spec.ts b/test/common/Error.spec.ts index 0deca7c52..e59d2d8e9 100644 --- a/test/common/Error.spec.ts +++ b/test/common/Error.spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ import {isBrowser} from '../../lib/common/utils'; -import {isSafari} from '../test-util'; +import {isSafari, zoneSymbol} from '../test-util'; // simulate @angular/facade/src/error.ts class BaseError extends Error { @@ -439,7 +439,7 @@ describe('ZoneAwareError', () => { it('should be able to generate zone free stack even NativeError stack is readonly', function() { const _global: any = typeof window === 'object' && window || typeof self === 'object' && self || global; - const NativeError = _global['__zone_symbol__Error']; + const NativeError = _global[zoneSymbol('Error')]; const desc = Object.getOwnPropertyDescriptor(NativeError.prototype, 'stack'); if (desc) { const originalSet: ((value: any) => void)|undefined = desc.set; diff --git a/test/node-env-setup.ts b/test/node-env-setup.ts new file mode 100644 index 000000000..77f660683 --- /dev/null +++ b/test/node-env-setup.ts @@ -0,0 +1,2 @@ +// Change default symbol prefix for testing to ensure no hard-coded references. +(global as any)['__Zone_symbol_prefix'] = '__zone_symbol_test__'; diff --git a/test/node_entry_point.ts b/test/node_entry_point.ts index 74d27b086..099d23497 100644 --- a/test/node_entry_point.ts +++ b/test/node_entry_point.ts @@ -7,13 +7,15 @@ */ // Must be loaded before zone loads, so that zone can detect WTF. -if (typeof global !== 'undefined' && - (global as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] !== false) { - (global as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] = true; -} import './wtf_mock'; import './test_fake_polyfill'; +// Zone symbol prefix is set to '__zone_symbol2__' in node-env-setup.ts. +if (typeof global !== 'undefined' && + (global as any)['__zone_symbol_test__fakeAsyncAutoFakeAsyncWhenClockPatched'] !== false) { + (global as any)['__zone_symbol_test__fakeAsyncAutoFakeAsyncWhenClockPatched'] = true; +} + // Setup tests for Zone without microtask support import '../lib/testing/zone-testing'; import '../lib/zone-spec/task-tracking'; diff --git a/test/test-env-setup-jasmine-no-patch-clock.ts b/test/test-env-setup-jasmine-no-patch-clock.ts index d847c2fed..3697af8c9 100644 --- a/test/test-env-setup-jasmine-no-patch-clock.ts +++ b/test/test-env-setup-jasmine-no-patch-clock.ts @@ -5,4 +5,4 @@ * 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 */ -(global as any)['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched'] = false; +(global as any)[(global as any).Zone.__symbol__('fakeAsyncAutoFakeAsyncWhenClockPatched')] = false; diff --git a/test/test-util.ts b/test/test-util.ts index 1a9179725..3a3861282 100644 --- a/test/test-util.ts +++ b/test/test-util.ts @@ -21,7 +21,10 @@ * * ifEnvSupports(supportsOnClick, function() { ... }); */ -import {isNode} from '../lib/common/utils'; +import {isNode, zoneSymbol} from '../lib/common/utils'; + +// Re-export for convenience. +export {zoneSymbol}; declare const global: any; export function ifEnvSupports(test: any, block: Function): () => void { diff --git a/test/test_fake_polyfill.ts b/test/test_fake_polyfill.ts index 6a3814d02..af16eac51 100644 --- a/test/test_fake_polyfill.ts +++ b/test/test_fake_polyfill.ts @@ -72,8 +72,12 @@ Object.defineProperties(TestTarget.prototype, { } }); +// Zone symbol prefix may be set in *-env-setup.ts (browser & node), +// but this file is used in multiple scenarios, and Zone isn't loaded at this point yet. +const zoneSymbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + global['__Zone_ignore_on_properties'] = [{target: TestTarget.prototype, ignoreProperties: ['prop1']}]; -global['__zone_symbol__FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}]; -global['__zone_symbol__UNPATCHED_EVENTS'] = ['scroll']; +global[zoneSymbolPrefix + 'FakeAsyncTestMacroTask'] = [{source: 'TestClass.myTimeout'}]; +global[zoneSymbolPrefix + 'UNPATCHED_EVENTS'] = ['scroll']; })(typeof window === 'object' && window || typeof self === 'object' && self || global); diff --git a/test/zone-spec/fake-async-test.spec.ts b/test/zone-spec/fake-async-test.spec.ts index 6b3053558..915cc4e9e 100644 --- a/test/zone-spec/fake-async-test.spec.ts +++ b/test/zone-spec/fake-async-test.spec.ts @@ -11,7 +11,7 @@ import '../../lib/rxjs/rxjs-fake-async'; import {Observable} from 'rxjs'; import {delay} from 'rxjs/operators'; -import {isNode, patchMacroTask} from '../../lib/common/utils'; +import {isNode, patchMacroTask, zoneSymbol} from '../../lib/common/utils'; import {ifEnvSupports} from '../test-util'; function supportNode() { @@ -23,7 +23,7 @@ function supportNode() { function supportClock() { const _global: any = typeof window === 'undefined' ? global : window; return typeof jasmine.clock === 'function' && - _global['__zone_symbol__fakeAsyncAutoFakeAsyncWhenClockPatched']; + _global[zoneSymbol('fakeAsyncAutoFakeAsyncWhenClockPatched')]; } (supportClock as any).message = 'support patch clock'; From 71b93711806000d7788e79451478e20d6086aa8a Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Sat, 1 Jun 2019 02:14:16 +0900 Subject: [PATCH 105/106] Build: Use bazel to build and package zone.js (#1232) --- .bazelignore | 1 + .bazelrc | 11 + .gitignore | 3 +- .travis.yml | 11 +- BUILD.bazel | 43 + WORKSPACE | 37 + angular_license.txt | 7 + dist/BUILD.bazel | 121 + dist/async-test.js | 444 +- dist/async-test.min.js | 31 + dist/fake-async-test.js | 1245 ++- dist/fake-async-test.min.js | 24 + dist/jasmine-patch.js | 531 +- dist/jasmine-patch.min.js | 9 +- dist/long-stack-trace-zone.js | 322 +- dist/long-stack-trace-zone.min.js | 16 +- dist/mocha-patch.js | 286 +- dist/mocha-patch.min.js | 9 +- dist/proxy.js | 359 +- dist/proxy.min.js | 16 +- dist/sync-test.js | 69 +- dist/sync-test.min.js | 15 + dist/task-tracking.js | 153 +- dist/task-tracking.min.js | 16 +- dist/webapis-media-query.js | 137 +- dist/webapis-media-query.min.js | 16 +- dist/webapis-notification.js | 51 +- dist/webapis-notification.min.js | 16 +- dist/webapis-rtc-peer-connection.js | 59 +- dist/webapis-rtc-peer-connection.min.js | 16 +- dist/webapis-shadydom.js | 63 +- dist/webapis-shadydom.min.js | 16 +- dist/wtf.js | 229 +- dist/wtf.min.js | 24 +- dist/zone-bluebird.js | 127 +- dist/zone-bluebird.min.js | 16 +- dist/zone-error.js | 605 +- dist/zone-error.min.js | 16 +- dist/zone-evergreen-testing-bundle.js | 9334 ++++++++++---------- dist/zone-evergreen-testing-bundle.min.js | 183 + dist/zone-evergreen.js | 6057 +++++++------ dist/zone-evergreen.min.js | 106 +- dist/zone-legacy.js | 591 +- dist/zone-legacy.min.js | 53 +- dist/zone-mix.js | 6000 +++++++------ dist/zone-mix.min.js | 117 + dist/zone-node.js | 4475 +++++----- dist/zone-node.min.js | 77 + dist/zone-patch-canvas.js | 47 +- dist/zone-patch-canvas.min.js | 16 +- dist/zone-patch-cordova.js | 89 +- dist/zone-patch-cordova.min.js | 16 +- dist/zone-patch-electron.js | 75 +- dist/zone-patch-electron.min.js | 17 +- dist/zone-patch-fetch.js | 209 +- dist/zone-patch-fetch.min.js | 16 +- dist/zone-patch-jsonp.js | 149 +- dist/zone-patch-jsonp.min.js | 16 +- dist/zone-patch-promise-test.js | 139 +- dist/zone-patch-promise-test.min.js | 16 +- dist/zone-patch-resize-observer.js | 177 +- dist/zone-patch-resize-observer.min.js | 16 +- dist/zone-patch-rxjs-fake-async.js | 1095 ++- dist/zone-patch-rxjs-fake-async.min.js | 25 +- dist/zone-patch-rxjs.js | 1359 ++- dist/zone-patch-rxjs.min.js | 25 +- dist/zone-patch-socket-io.js | 63 +- dist/zone-patch-socket-io.min.js | 16 +- dist/zone-patch-user-media.js | 55 +- dist/zone-patch-user-media.min.js | 16 +- dist/zone-testing-bundle.js | 9340 ++++++++++----------- dist/zone-testing-bundle.min.js | 228 + dist/zone-testing-node-bundle.js | 7526 ++++++++--------- dist/zone-testing-node-bundle.min.js | 155 + dist/zone-testing.js | 3010 ++++--- dist/zone-testing.min.js | 71 + dist/zone.js | 6335 +++++++------- dist/zone.js.d.ts | 3 + dist/zone.min.js | 151 +- dist/zone_externs.js | 0 lib/BUILD.bazel | 21 + lib/browser/browser-legacy.ts | 4 +- lib/bundle.bzl | 43 + lib/common/promise.ts | 2 +- lib/jasmine/jasmine.ts | 6 +- lib/mocha/mocha.ts | 2 +- lib/zone-spec/async-test.ts | 4 +- lib/zone-spec/fake-async-test.ts | 2 +- lib/zone-spec/wtf.ts | 2 +- lib/zone.ts | 4 +- package.json | 24 +- sauce.conf.js | 12 +- test/browser/browser.spec.ts | 1 + test/browser/registerElement.spec.ts | 6 +- test/common/Error.spec.ts | 1 + test/npm_package/npm_package.spec.ts | 169 + test/webdriver/test.sauce.es2015.js | 4 +- test/webdriver/test.sauce.js | 3 +- tsconfig-esm-node.json | 1 + tsconfig-esm.json | 1 + tsconfig-node.json | 1 + tsconfig.json | 2 + yarn.lock | 1603 +++- 103 files changed, 34512 insertions(+), 30040 deletions(-) create mode 100644 .bazelignore create mode 100644 .bazelrc create mode 100644 BUILD.bazel create mode 100644 WORKSPACE create mode 100644 angular_license.txt create mode 100644 dist/BUILD.bazel mode change 100644 => 100755 dist/async-test.js create mode 100755 dist/async-test.min.js mode change 100644 => 100755 dist/fake-async-test.js create mode 100755 dist/fake-async-test.min.js mode change 100644 => 100755 dist/jasmine-patch.js mode change 100644 => 100755 dist/jasmine-patch.min.js mode change 100644 => 100755 dist/long-stack-trace-zone.js mode change 100644 => 100755 dist/long-stack-trace-zone.min.js mode change 100644 => 100755 dist/mocha-patch.js mode change 100644 => 100755 dist/mocha-patch.min.js mode change 100644 => 100755 dist/proxy.js mode change 100644 => 100755 dist/proxy.min.js mode change 100644 => 100755 dist/sync-test.js create mode 100755 dist/sync-test.min.js mode change 100644 => 100755 dist/task-tracking.js mode change 100644 => 100755 dist/task-tracking.min.js mode change 100644 => 100755 dist/webapis-media-query.js mode change 100644 => 100755 dist/webapis-media-query.min.js mode change 100644 => 100755 dist/webapis-notification.js mode change 100644 => 100755 dist/webapis-notification.min.js mode change 100644 => 100755 dist/webapis-rtc-peer-connection.js mode change 100644 => 100755 dist/webapis-rtc-peer-connection.min.js mode change 100644 => 100755 dist/webapis-shadydom.js mode change 100644 => 100755 dist/webapis-shadydom.min.js mode change 100644 => 100755 dist/wtf.js mode change 100644 => 100755 dist/wtf.min.js mode change 100644 => 100755 dist/zone-bluebird.js mode change 100644 => 100755 dist/zone-bluebird.min.js mode change 100644 => 100755 dist/zone-error.js mode change 100644 => 100755 dist/zone-error.min.js mode change 100644 => 100755 dist/zone-evergreen-testing-bundle.js create mode 100755 dist/zone-evergreen-testing-bundle.min.js mode change 100644 => 100755 dist/zone-evergreen.js mode change 100644 => 100755 dist/zone-evergreen.min.js mode change 100644 => 100755 dist/zone-legacy.js mode change 100644 => 100755 dist/zone-legacy.min.js mode change 100644 => 100755 dist/zone-mix.js create mode 100755 dist/zone-mix.min.js mode change 100644 => 100755 dist/zone-node.js create mode 100755 dist/zone-node.min.js mode change 100644 => 100755 dist/zone-patch-canvas.js mode change 100644 => 100755 dist/zone-patch-canvas.min.js mode change 100644 => 100755 dist/zone-patch-cordova.js mode change 100644 => 100755 dist/zone-patch-cordova.min.js mode change 100644 => 100755 dist/zone-patch-electron.js mode change 100644 => 100755 dist/zone-patch-electron.min.js mode change 100644 => 100755 dist/zone-patch-fetch.js mode change 100644 => 100755 dist/zone-patch-fetch.min.js mode change 100644 => 100755 dist/zone-patch-jsonp.js mode change 100644 => 100755 dist/zone-patch-jsonp.min.js mode change 100644 => 100755 dist/zone-patch-promise-test.js mode change 100644 => 100755 dist/zone-patch-promise-test.min.js mode change 100644 => 100755 dist/zone-patch-resize-observer.js mode change 100644 => 100755 dist/zone-patch-resize-observer.min.js mode change 100644 => 100755 dist/zone-patch-rxjs-fake-async.js mode change 100644 => 100755 dist/zone-patch-rxjs-fake-async.min.js mode change 100644 => 100755 dist/zone-patch-rxjs.js mode change 100644 => 100755 dist/zone-patch-rxjs.min.js mode change 100644 => 100755 dist/zone-patch-socket-io.js mode change 100644 => 100755 dist/zone-patch-socket-io.min.js mode change 100644 => 100755 dist/zone-patch-user-media.js mode change 100644 => 100755 dist/zone-patch-user-media.min.js mode change 100644 => 100755 dist/zone-testing-bundle.js create mode 100755 dist/zone-testing-bundle.min.js mode change 100644 => 100755 dist/zone-testing-node-bundle.js create mode 100755 dist/zone-testing-node-bundle.min.js mode change 100644 => 100755 dist/zone-testing.js create mode 100755 dist/zone-testing.min.js mode change 100644 => 100755 dist/zone.js mode change 100644 => 100755 dist/zone.js.d.ts mode change 100644 => 100755 dist/zone.min.js mode change 100644 => 100755 dist/zone_externs.js create mode 100644 lib/BUILD.bazel create mode 100644 lib/bundle.bzl create mode 100644 test/npm_package/npm_package.spec.ts diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/.bazelignore @@ -0,0 +1 @@ +node_modules diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..bbb9e8a37 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,11 @@ +build --symlink_prefix=build/ + +# Turn on --incompatible_strict_action_env which was on by default +# in Bazel 0.21.0 but turned off again in 0.22.0. Follow +# https://github.com/bazelbuild/bazel/issues/7026 for more details. +# This flag is needed to so that the bazel cache is not invalidated +# when running bazel via `yarn bazel`. +# See https://github.com/angular/angular/issues/27514. +build --incompatible_strict_action_env +run --incompatible_strict_action_env +test --incompatible_strict_action_env diff --git a/.gitignore b/.gitignore index 6a642d111..dc836408f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +bazel-out build/ build-esm/ +build-esm-2015/ blink-core/ blink-idl/ parsed-idl/ @@ -7,4 +9,3 @@ parsed-idl/ .idea .vscode npm-debug.log -build-esm/ diff --git a/.travis.yml b/.travis.yml index d93090a69..7d7a62450 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,16 @@ script: - yarn tslint - node_modules/.bin/gulp lint - node_modules/.bin/gulp format:enforce - - node_modules/.bin/gulp build - node_modules/.bin/gulp filesize - scripts/closure/closure_compiler.sh - node_modules/.bin/gulp promisetest - yarn promisefinallytest - - yarn test:phantomjs-single + - yarn build:bazel + - yarn build:bazel:test + - rm -rf dist/*.js + - cp build/bin/npm_package/dist/* dist/ + - rm -rf build + - yarn tsc - node_modules/.bin/karma start karma-dist-sauce-jasmine.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-mocha.conf.js --single-run - node_modules/.bin/karma start karma-dist-sauce-selenium3-jasmine.conf.js --single-run @@ -49,10 +53,11 @@ script: - node simple-server.js 2>&1> server.log& - node ./test/webdriver/test.sauce.js - yarn add jasmine@3.0.0 jasmine-core@3.0.0 mocha@5.0.1 - - yarn test:phantomjs-single - node_modules/.bin/karma start karma-dist-sauce-jasmine3.conf.js --single-run - node_modules/.bin/karma start karma-build-sauce-selenium3-mocha.conf.js --single-run - node_modules/.bin/gulp test/node - node_modules/.bin/gulp test/node -no-patch-clock - cp ./test/browser/custom-element.spec.js ./build/test/browser + - git checkout . + - ls build/test - node_modules/.bin/karma start karma-evergreen-dist-sauce-jasmine.conf.js --single-run diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 000000000..c256648c1 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,43 @@ +load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package", "rollup_bundle") +load("@npm_bazel_jasmine//:index.bzl", "jasmine_node_test") +load("@npm_bazel_typescript//:defs.bzl", "ts_library") +load("//lib:bundle.bzl", "ES2015_BUNDLES", "ES5_BUNDLES", "ES5_GLOBAL_BUNDLES") + +exports_files([ + "tsconfig.json", + "tsconfig-node.json", + "angular_license.txt", +]) + +npm_package( + name = "npm_package", + srcs = [ + "CHANGELOG.md", + "LICENSE", + "LICENSE.wrapped", + "README.md", + "package.json", + ], + deps = [ + "//dist:zone_externs", + "//lib", + ] + ["//dist:" + b + "-dist" for b in ES5_BUNDLES] + ["//dist:" + b + "-dist" for b in ES2015_BUNDLES] + ["//dist:" + b + "-dist" for b in ES5_GLOBAL_BUNDLES] + ["//dist:zone_d_ts"], +) + +ts_library( + name = "npm_package_spec_lib", + testonly = True, + srcs = ["test/npm_package/npm_package.spec.ts"], + deps = [ + "@npm//@types", + ], +) + +jasmine_node_test( + name = "test_npm_package", + srcs = [":npm_package_spec_lib"], + data = [ + ":npm_package", + "@npm//shelljs", + ], +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 000000000..a68e34a85 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,37 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "build_bazel_rules_nodejs", + sha256 = "4c702ffeeab2d24dd4101601b6d27cf582d2e0d4cdc3abefddd4834664669b6b", + urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/0.28.0/rules_nodejs-0.28.0.tar.gz"], +) + +load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install") + +yarn_install( + name = "npm", + exclude_packages = [ + # Don't need to run Bazel under Bazel + "@bazel/bazel", + "@bazel/ibazel", + "@bazel/buildifier", + ], + package_json = "//:package.json", + yarn_lock = "//:yarn.lock", +) + +load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies") + +install_bazel_dependencies() + +load("@npm_bazel_karma//:package.bzl", "rules_karma_dependencies") + +rules_karma_dependencies() + +load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories") + +web_test_repositories() + +load("@npm_bazel_karma//:browser_repositories.bzl", "browser_repositories") + +browser_repositories() diff --git a/angular_license.txt b/angular_license.txt new file mode 100644 index 000000000..61f6b1ff3 --- /dev/null +++ b/angular_license.txt @@ -0,0 +1,7 @@ +/** +* @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 +*/ diff --git a/dist/BUILD.bazel b/dist/BUILD.bazel new file mode 100644 index 000000000..830426977 --- /dev/null +++ b/dist/BUILD.bazel @@ -0,0 +1,121 @@ +load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle") +load("//lib:bundle.bzl", "ES2015_BUNDLES", "ES5_BUNDLES", "ES5_GLOBAL_BUNDLES") + +package(default_visibility = ["//:__subpackages__"]) + +# copy this file from //lib to //dist +genrule( + name = "zone_externs", + srcs = ["//lib:closure/zone_externs.js"], + outs = ["zone_externs.js"], + cmd = "cp $< $@", +) + +genrule( + name = "zone_d_ts", + srcs = ["//lib"], + outs = ["zone.js.d.ts"], + cmd = "rsync -ul $(SRCS) $(@D) && mv $(@D)/zone.d.ts $(@D)/zone.js.d.ts", +) + +[ + rollup_bundle( + name = b[0] + "-rollup", + entry_point = b[1], + globals = { + "electron": "electron", + }, + deps = [ + "//lib", + ], + license_banner = "//:angular_license.txt", + ) + for b in ES5_BUNDLES.items() +] + +[ + rollup_bundle( + name = b[0] + "-rollup", + entry_point = b[1], + global_name = "Zone", + deps = [ + "//lib", + ], + license_banner = "//:angular_license.txt", + ) + for b in ES5_GLOBAL_BUNDLES.items() + ES2015_BUNDLES.items() +] + +# the es5 filegroups +[ + filegroup( + name = b[0] + ".es5", + srcs = [":" + b[0] + "-rollup"], + output_group = "es5_umd", + ) + for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items() +] + +# the es5.min filegroups +[ + filegroup( + name = b[0] + ".es5.min", + srcs = [":" + b[0] + "-rollup"], + output_group = "es5_umd_min", + ) + for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items() +] + +# the es2015 filegroups +[ + filegroup( + name = b + ".umd", + srcs = [":" + b + "-rollup"], + output_group = "umd", + ) + for b in ES2015_BUNDLES +] + +# the es2015.min filegroups +[ + filegroup( + name = b + ".umd.min", + srcs = [":" + b + "-rollup"], + output_group = "umd_min", + ) + for b in ES2015_BUNDLES +] + +# Extract and rename each es5 bundle to a .js and .min.js in the dist/ dir +[ + genrule( + name = b[0] + "-dist", + srcs = [b[0] + ".es5", b[0] + ".es5.min"], + outs = [b[0] + ".js", b[0] + ".min.js"], + cmd = " && ".join([ + "mkdir -p $(@D)", + "mv $(locations :" + b[0] + ".es5) $(@D)/", + "mv $(locations :" + b[0] + ".es5.min) $(@D)/", + "mv $(@D)/" + b[0] + "-rollup.es5umd.js $(@D)/" + b[0] + ".js", + "mv $(@D)/" + b[0] + "-rollup.min.es5umd.js $(@D)/" + b[0] + ".min.js", + ]), + ) + for b in ES5_BUNDLES.items() + ES5_GLOBAL_BUNDLES.items() +] + +# Extract and rename each es2015 bundle to a .js and .min.js in the dist/ dir +[ + genrule( + name = b + "-dist", + srcs = [b + ".umd", b + ".umd.min"], + outs = [b + ".js", b + ".min.js"], + cmd = " && ".join([ + "mkdir -p $(@D)", + "mv $(locations :" + b + ".umd) $(@D)/", + "mv $(locations :" + b + ".umd.min) $(@D)/", + "mv $(@D)/" + b + "-rollup.umd.js $(@D)/" + b + ".js", + "mv $(@D)/" + b + "-rollup.min.umd.js $(@D)/" + b + ".min.js", + ]), + ) + for b in ES2015_BUNDLES +] diff --git a/dist/async-test.js b/dist/async-test.js old mode 100644 new mode 100755 index 8c1b26d48..23d87df2d --- a/dist/async-test.js +++ b/dist/async-test.js @@ -5,234 +5,234 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; -var AsyncTestZoneSpec = /** @class */ (function () { - function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { - this.finishCallback = finishCallback; - this.failCallback = failCallback; - this._pendingMicroTasks = false; - this._pendingMacroTasks = false; - this._alreadyErrored = false; - this._isSync = false; - this.runZone = Zone.current; - this.unresolvedChainedPromiseCount = 0; - this.supportWaitUnresolvedChainedPromise = false; - this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { 'AsyncTestZoneSpec': this }; - this.supportWaitUnresolvedChainedPromise = - _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; - } - AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { - return this.unresolvedChainedPromiseCount > 0; - }; - AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { - var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || - (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { - // We do this because we would like to catch unhandled rejected promises. - this.runZone.run(function () { - setTimeout(function () { - if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this.finishCallback(); - } - }, 0); - }); - } - }; - AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; - if (patchPromiseForTest) { - patchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; - if (unPatchPromiseForTest) { - unPatchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise - if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { - // chained promise is being scheduled - this.unresolvedChainedPromiseCount--; - } - } - return delegate.scheduleTask(target, task); - }; - AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.invokeTask(target, task, applyThis, applyArgs); - }; - AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.cancelTask(target, task); - }; - // 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. - // updated by(JiaLiPassion), only call finish callback when no task - // was scheduled/invoked/canceled. - AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - try { - this._isSync = true; - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - finally { - var afterTaskCounts = parentZoneDelegate._taskCounts; - if (this._isSync) { - this._finishCallbackIfDone(); - } - } - }; - AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - // Let the parent try to handle the error. - var result = parentZoneDelegate.handleError(targetZone, error); - if (result) { - this.failCallback(error); - this._alreadyErrored = true; - } - return false; - }; - AsyncTestZoneSpec.prototype.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(); - } - }; - AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); - return AsyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; - -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. + * @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[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; + (function (_global) { + var AsyncTestZoneSpec = /** @class */ (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this._isSync = false; + this.runZone = Zone.current; + this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; + this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; + } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { + _this.finishCallback(); + } + }, 0); + }); + } + }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; } - else { - done.fail(err); + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + this._isSync = true; + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); } - }); + } }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); - }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this.failCallback(error); + this._alreadyErrored = true; } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); + return false; + }; + AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + delegate.hasTask(target, hasTaskState); + if (hasTaskState.change == 'microTask') { + this._pendingMicroTasks = hasTaskState.microTask; + this._finishCallbackIfDone(); } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - failCallback(error); + else if (hasTaskState.change == 'macroTask') { + this._pendingMacroTasks = hasTaskState.macroTask; + this._finishCallbackIfDone(); + } + }; + return AsyncTestZoneSpec; + }()); + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + })(commonjsGlobal); + /** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - testZoneSpec.patchPromiseForTest(); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -}))); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } + }); +})); +//# sourceMappingURL=async-test-rollup.umd.js.map diff --git a/dist/async-test.min.js b/dist/async-test.min.js new file mode 100755 index 000000000..f956548a7 --- /dev/null +++ b/dist/async-test.min.js @@ -0,0 +1,31 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";var e,n,t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; +/** + * @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 + */ +/** + * @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 + */ +e=t,(n=function(){function n(n,t,o){this.finishCallback=n,this.failCallback=t,this._pendingMicroTasks=!1,this._pendingMacroTasks=!1,this._alreadyErrored=!1,this._isSync=!1,this.runZone=Zone.current,this.unresolvedChainedPromiseCount=0,this.supportWaitUnresolvedChainedPromise=!1,this.name="asyncTestZone for "+o,this.properties={AsyncTestZoneSpec:this},this.supportWaitUnresolvedChainedPromise=!0===e[Zone.__symbol__("supportWaitUnResolvedChainedPromise")]}return n.prototype.isUnresolvedChainedPromisePending=function(){return this.unresolvedChainedPromiseCount>0},n.prototype._finishCallbackIfDone=function(){var e=this;this._pendingMicroTasks||this._pendingMacroTasks||this.supportWaitUnresolvedChainedPromise&&this.isUnresolvedChainedPromisePending()||this.runZone.run(function(){setTimeout(function(){e._alreadyErrored||e._pendingMicroTasks||e._pendingMacroTasks||e.finishCallback()},0)})},n.prototype.patchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("patchPromiseForTest")];e&&e()}},n.prototype.unPatchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("unPatchPromiseForTest")];e&&e()}},n.prototype.onScheduleTask=function(e,t,o,s){return"eventTask"!==s.type&&(this._isSync=!1),"microTask"===s.type&&s.data&&s.data instanceof Promise&&!0===s.data[n.symbolParentUnresolved]&&this.unresolvedChainedPromiseCount--,e.scheduleTask(o,s)},n.prototype.onInvokeTask=function(e,n,t,o,s,i){return"eventTask"!==o.type&&(this._isSync=!1),e.invokeTask(t,o,s,i)},n.prototype.onCancelTask=function(e,n,t,o){return"eventTask"!==o.type&&(this._isSync=!1),e.cancelTask(t,o)},n.prototype.onInvoke=function(e,n,t,o,s,i,r){try{return this._isSync=!0,e.invoke(t,o,s,i,r)}finally{this._isSync&&this._finishCallbackIfDone()}},n.prototype.onHandleError=function(e,n,t,o){return e.handleError(t,o)&&(this.failCallback(o),this._alreadyErrored=!0),!1},n.prototype.onHasTask=function(e,n,t,o){e.hasTask(t,o),"microTask"==o.change?(this._pendingMicroTasks=o.microTask,this._finishCallbackIfDone()):"macroTask"==o.change&&(this._pendingMacroTasks=o.macroTask,this._finishCallbackIfDone())},n}()).symbolParentUnresolved=Zone.__symbol__("parentUnresolved"),Zone.AsyncTestZoneSpec=n, +/** + * @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.__load_patch("asynctest",function(e,n,t){function o(e,t,o,s){var i=n.current,r=n.AsyncTestZoneSpec;if(void 0===r)throw new Error("AsyncTestZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/async-test.js");var a=n.ProxyZoneSpec;if(void 0===a)throw new Error("ProxyZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/proxy.js");var c=a.get();a.assertPresent();var u=n.current.getZoneWith("ProxyZoneSpec"),h=c.getDelegate();return u.parent.run(function(){var e=new r(function(){c.getDelegate()==e&&c.setDelegate(h),e.unPatchPromiseForTest(),i.run(function(){o()})},function(n){c.getDelegate()==e&&c.setDelegate(h),e.unPatchPromiseForTest(),i.run(function(){s(n)})},"test");c.setDelegate(e),e.patchPromiseForTest()}),n.current.runGuarded(e,t)}n[t.symbol("asyncTest")]=function n(t){return e.jasmine?function(e){e||((e=function(){}).fail=function(e){throw e}),o(t,this,e,function(n){if("string"==typeof n)return e.fail(new Error(n));e.fail(n)})}:function(){var e=this;return new Promise(function(n,s){o(t,e,n,s)})}}})}); \ No newline at end of file diff --git a/dist/fake-async-test.js b/dist/fake-async-test.js old mode 100644 new mode 100755 index 44c0969c2..031c4bc61 --- a/dist/fake-async-test.js +++ b/dist/fake-async-test.js @@ -5,681 +5,660 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 __read = (undefined && undefined.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (undefined && undefined.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -(function (global) { - var OriginalDate = global.Date; - var FakeDate = /** @class */ (function () { - function FakeDate() { - if (arguments.length === 0) { - var d = new OriginalDate(); - d.setTime(FakeDate.now()); - return d; - } - else { - var args = Array.prototype.slice.call(arguments); - return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); - } - } - FakeDate.now = function () { - var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncTestZoneSpec) { - return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); - } - return OriginalDate.now.apply(this, arguments); - }; - return FakeDate; - }()); - FakeDate.UTC = OriginalDate.UTC; - FakeDate.parse = OriginalDate.parse; - // keep a reference for zone patched timer function - var timers = { - setTimeout: global.setTimeout, - setInterval: global.setInterval, - clearTimeout: global.clearTimeout, - clearInterval: global.clearInterval - }; - var Scheduler = /** @class */ (function () { - function Scheduler() { - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - this._schedulerQueue = []; - // Current simulated time in millis. - this._currentTime = 0; - // Current real time in millis. - this._currentRealTime = OriginalDate.now(); - } - Scheduler.prototype.getCurrentTime = function () { - return this._currentTime; - }; - Scheduler.prototype.getCurrentRealTime = function () { - return this._currentRealTime; - }; - Scheduler.prototype.setCurrentRealTime = function (realTime) { - this._currentRealTime = realTime; - }; - Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { - if (args === void 0) { args = []; } - if (isPeriodic === void 0) { isPeriodic = false; } - if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } - if (id === void 0) { id = -1; } - var currentId = id < 0 ? Scheduler.nextId++ : id; - var endTime = this._currentTime + delay; - // Insert so that scheduler queue remains sorted by end time. - var newEntry = { - endTime: endTime, - id: currentId, - func: cb, - args: args, - delay: delay, - isPeriodic: isPeriodic, - isRequestAnimationFrame: isRequestAnimationFrame - }; - var i = 0; - for (; i < this._schedulerQueue.length; i++) { - var currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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) { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; } - } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - }; - Scheduler.prototype.removeScheduledFunctionWithId = function (id) { - for (var i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, [void 0].concat(args)))(); } } - }; - Scheduler.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - var finalTime = this._currentTime + millis; - var lastCurrentTime = 0; - if (this._schedulerQueue.length === 0 && doTick) { - doTick(millis); - return; - } - while (this._schedulerQueue.length > 0) { - var current = this._schedulerQueue[0]; - if (finalTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. - break; + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + return FakeDate; + }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; + var Scheduler = /** @class */ (function () { + function Scheduler() { + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = OriginalDate.now(); + } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; + Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { + if (args === void 0) { args = []; } + if (isPeriodic === void 0) { isPeriodic = false; } + if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } + if (id === void 0) { id = -1; } + var currentId = id < 0 ? Scheduler.nextId++ : id; + var endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + var newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + var i = 0; + for (; i < this._schedulerQueue.length; i++) { + var currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } + } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + }; + Scheduler.prototype.removeScheduledFunctionWithId = function (id) { + for (var i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; + } + } + }; + Scheduler.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + var finalTime = this._currentTime + millis; + var lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + var current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; + } + else { + // Time to run scheduled function. Remove it from the head of queue. + var current_1 = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current_1.endTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + } + lastCurrentTime = this._currentTime; + this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + }; + Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { + if (limit === void 0) { limit = 20; } + if (flushPeriodic === void 0) { flushPeriodic = false; } + if (flushPeriodic) { + return this.flushPeriodic(doTick); } else { - // Time to run scheduled function. Remove it from the head of queue. - var current_1 = this._schedulerQueue.shift(); + return this.flushNonPeriodic(limit, doTick); + } + }; + Scheduler.prototype.flushPeriodic = function (doTick) { + if (this._schedulerQueue.length === 0) { + return 0; + } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + var startTime = this._currentTime; + var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + }; + Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { + var startTime = this._currentTime; + var lastCurrentTime = 0; + var count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error('flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) + .length === 0) { + break; + } + var current = this._schedulerQueue.shift(); lastCurrentTime = this._currentTime; - this._currentTime = current_1.endTime; + this._currentTime = current.endTime; if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + var retval = current.func.apply(global, current.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; } } - } - lastCurrentTime = this._currentTime; - this._currentTime = finalTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - }; - Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { - if (limit === void 0) { limit = 20; } - if (flushPeriodic === void 0) { flushPeriodic = false; } - if (flushPeriodic) { - return this.flushPeriodic(doTick); - } - else { - return this.flushNonPeriodic(limit, doTick); - } - }; - Scheduler.prototype.flushPeriodic = function (doTick) { - if (this._schedulerQueue.length === 0) { - return 0; - } - // Find the last task currently queued in the scheduler queue and tick - // till that time. - var startTime = this._currentTime; - var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; - this.tick(lastTask.endTime - startTime, doTick); - return this._currentTime - startTime; - }; - Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { - var startTime = this._currentTime; - var lastCurrentTime = 0; - var count = 0; - while (this._schedulerQueue.length > 0) { - count++; - if (count > limit) { - throw new Error('flush failed after reaching the limit of ' + limit + - ' tasks. Does your code use a polling timeout?'); - } - // flush only non-periodic timers. - // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. - if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) - .length === 0) { - break; - } - var current = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current.endTime; - if (doTick) { - // Update any secondary schedulers like Jasmine mock Date. - doTick(this._currentTime - lastCurrentTime); - } - var retval = current.func.apply(global, current.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } - return this._currentTime - startTime; - }; + return this._currentTime - startTime; + }; + return Scheduler; + }()); // Next scheduler id. Scheduler.nextId = 1; - return Scheduler; - }()); - var FakeAsyncTestZoneSpec = /** @class */ (function () { - function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { - if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } - this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; - this.macroTaskOptions = macroTaskOptions; - this._scheduler = new Scheduler(); - this._microtasks = []; - this._lastError = null; - this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; - this.pendingPeriodicTimers = []; - this.pendingTimers = []; - this.patchDateLocked = false; - this.properties = { 'FakeAsyncTestZoneSpec': this }; - this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakeAsyncTestSpec - // user can also define macroTaskOptions by define a global variable. - if (!this.macroTaskOptions) { - this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; - } - } - FakeAsyncTestZoneSpec.assertInZone = function () { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); + var FakeAsyncTestZoneSpec = /** @class */ (function () { + function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { + if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } + this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; + this.macroTaskOptions = macroTaskOptions; + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.patchDateLocked = false; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + } } - }; - FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { - var _this = this; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; + FakeAsyncTestZoneSpec.assertInZone = function () { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); } - fn.apply(global, args); - if (_this._lastError === null) { // Success - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); + }; + FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { + var _this = this; + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + fn.apply(global, args); + if (_this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + _this.flushMicrotasks(); + } + else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } } - // Flush microtasks only on success. - _this.flushMicrotasks(); + // Return true if there were no errors, false otherwise. + return _this._lastError === null; + }; + }; + FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { + var index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); } - else { // Failure - if (completers.onError != null) { - completers.onError.apply(global); + }; + FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { + var _this = this; + return function () { + // Requeue the timer callback if it's not been canceled. + if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { + _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); } + }; + }; + FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { + if (isTimer === void 0) { isTimer = true; } + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); } - // Return true if there were no errors, false otherwise. - return _this._lastError === null; + return id; }; - }; - FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { - var index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); - } - }; - FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); }; - }; - FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { - var _this = this; - return function () { - // Requeue the timer callback if it's not been canceled. - if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { - _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { + var id = Scheduler.nextId; + var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + var cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { + var error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } + if (global['Date'] === FakeDate) { + // already patched + return; } + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; - }; - FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } }; - }; - FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { - if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(Scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); - var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); - if (isTimer) { - this.pendingTimers.push(id); - } - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = Scheduler.nextId; - var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; - var cb = this._fnAndFlush(fn, completers); - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args, true); - this.pendingPeriodicTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { - var error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - }; - FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { - return this._scheduler.getCurrentTime(); - }; - FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { - return this._scheduler.getCurrentRealTime(); - }; - FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { - this._scheduler.setCurrentRealTime(realTime); - }; - FakeAsyncTestZoneSpec.patchDate = function () { - if (!!global[Zone.__symbol__('disableDatePatching')]) { - // we don't want to patch global Date - // because in some case, global Date - // is already being patched, we need to provide - // an option to let user still use their - // own version of Date. - return; - } - if (global['Date'] === FakeDate) { - // already patched - return; - } - global['Date'] = FakeDate; - FakeDate.prototype = OriginalDate.prototype; - // try check and reset timers - // because jasmine.clock().install() may - // have replaced the global timer - FakeAsyncTestZoneSpec.checkTimerPatch(); - }; - FakeAsyncTestZoneSpec.resetDate = function () { - if (global['Date'] === FakeDate) { - global['Date'] = OriginalDate; - } - }; - FakeAsyncTestZoneSpec.checkTimerPatch = function () { - if (global.setTimeout !== timers.setTimeout) { - global.setTimeout = timers.setTimeout; - global.clearTimeout = timers.clearTimeout; - } - if (global.setInterval !== timers.setInterval) { - global.setInterval = timers.setInterval; - global.clearInterval = timers.clearInterval; - } - }; - FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { - this.patchDateLocked = true; - FakeAsyncTestZoneSpec.patchDate(); - }; - FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { - this.patchDateLocked = false; - FakeAsyncTestZoneSpec.resetDate(); - }; - FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - }; - FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { - var _this = this; - FakeAsyncTestZoneSpec.assertInZone(); - var flushErrors = function () { - if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - _this._resetLastErrorAndThrow(); - } - }; - while (this._microtasks.length > 0) { - var microtask = this._microtasks.shift(); - microtask.func.apply(microtask.target, microtask.args); - } - flushErrors(); - }; - FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - return elapsed; - }; - FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - var args = task.data && task.data.args; - // should pass additional arguments to callback if have any - // currently we know process.nextTick will have such additional - // arguments - var additionalArgs = void 0; - if (args) { - var callbackIndex = task.data.cbIdx; - if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); - } + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; + FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + }; + FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { + var _this = this; + FakeAsyncTestZoneSpec.assertInZone(); + var flushErrors = function () { + if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + _this._resetLastErrorAndThrow(); } - this._microtasks.push({ - func: task.invoke, - args: additionalArgs, - target: task.data && task.data.target - }); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'setImmediate': - task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); - break; - case 'setInterval': - task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'XMLHttpRequest.send': - throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + - task.data['url']); - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. - // (60 frames per second) - task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); - break; - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var args_1 = task.data && task.data['args']; - var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; - var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; - if (!!macroTaskOption.isPeriodic) { - // periodic macroTask, use setInterval to simulate - task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data.isPeriodic = true; - } - else { - // not periodic, use setTimeout to simulate - task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); - } - break; + }; + while (this._microtasks.length > 0) { + var microtask = this._microtasks.shift(); + microtask.func.apply(microtask.target, microtask.args); + } + flushErrors(); + }; + FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + }; + FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + var args = task.data && task.data.args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + var additionalArgs = void 0; + if (args) { + var callbackIndex = task.data.cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } - throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && task.data.target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; + case 'setInterval': + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + + task.data['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var args_1 = task.data && task.data['args']; + var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; + var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data.isPeriodic = true; + } + else { + // not periodic, use setTimeout to simulate + task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + } + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var handleId = task.data['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); + } + }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - switch (task.source) { - case 'setTimeout': - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data['handleId']); - case 'setInterval': - return this._clearInterval(task.data['handleId']); - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var handleId = task.data['handleId']; - return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : - this._clearTimeout(handleId); + } + }; + FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { + if (!this.macroTaskOptions) { + return null; + } + for (var i = 0; i < this.macroTaskOptions.length; i++) { + var macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; } - return delegate.cancelTask(target, task); - } - }; - FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { - try { - FakeAsyncTestZoneSpec.patchDate(); - return delegate.invoke(target, callback, applyThis, applyArgs, source); - } - finally { - if (!this.patchDateLocked) { - FakeAsyncTestZoneSpec.resetDate(); } - } - }; - FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { - if (!this.macroTaskOptions) { return null; - } - for (var i = 0; i < this.macroTaskOptions.length; i++) { - var macroTaskOption = this.macroTaskOptions[i]; - if (macroTaskOption.source === task.source) { - return macroTaskOption; - } - } - return null; - }; - FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - this._lastError = error; - return false; // Don't propagate error to parent zone. - }; - return FakeAsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; + }; + FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + }; + return FakeAsyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; + })(commonjsGlobal); /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); + Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); try { - res = fn.apply(this, args); - flushMicrotasks(); + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; } finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); + resetFakeAsyncZone(); } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + }; + } + function _getFakeAsyncZoneSpec() { if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } } + return _fakeAsyncTestZoneSpec; } - return _fakeAsyncTestZoneSpec; - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } - /** - * Discard all remaining periodic tasks. - * - * @experimental - */ - function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } - /** - * Flush any pending microtasks. - * - * @experimental - */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - -}))); + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; + }); +})); +//# sourceMappingURL=fake-async-test-rollup.umd.js.map diff --git a/dist/fake-async-test.min.js b/dist/fake-async-test.min.js new file mode 100755 index 000000000..48aa596da --- /dev/null +++ b/dist/fake-async-test.min.js @@ -0,0 +1,24 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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(e){var t=e.Date,r=function(){function e(){if(0===arguments.length){var r=new t;return r.setTime(e.now()),r}var n=Array.prototype.slice.call(arguments);return new(t.bind.apply(t,[void 0].concat(n)))}return e.now=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.getCurrentRealTime()+e.getCurrentTime():t.now.apply(this,arguments)},e}();r.UTC=t.UTC,r.parse=t.parse;var n={setTimeout:e.setTimeout,setInterval:e.setInterval,clearTimeout:e.clearTimeout,clearInterval:e.clearInterval},i=function(){function r(){this._schedulerQueue=[],this._currentTime=0,this._currentRealTime=t.now()}return r.prototype.getCurrentTime=function(){return this._currentTime},r.prototype.getCurrentRealTime=function(){return this._currentRealTime},r.prototype.setCurrentRealTime=function(e){this._currentRealTime=e},r.prototype.scheduleFunction=function(e,t,n,i,s,o){void 0===n&&(n=[]),void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===o&&(o=-1);for(var a=o<0?r.nextId++:o,u={endTime:this._currentTime+t,id:a,func:e,args:n,delay:t,isPeriodic:i,isRequestAnimationFrame:s},c=0;c0&&!(n0;){if(++s>t)throw new Error("flush failed after reaching the limit of "+t+" tasks. Does your code use a polling timeout?");if(0===this._schedulerQueue.filter(function(e){return!e.isPeriodic&&!e.isRequestAnimationFrame}).length)break;var o=this._schedulerQueue.shift();if(i=this._currentTime,this._currentTime=o.endTime,r&&r(this._currentTime-i),!o.func.apply(e,o.args))break}return this._currentTime-n},r}();i.nextId=1;var s=function(){function s(t,r,n){void 0===r&&(r=!1),this.trackPendingRequestAnimationFrame=r,this.macroTaskOptions=n,this._scheduler=new i,this._microtasks=[],this._lastError=null,this._uncaughtPromiseErrors=Promise[Zone.__symbol__("uncaughtPromiseErrors")],this.pendingPeriodicTimers=[],this.pendingTimers=[],this.patchDateLocked=!1,this.properties={FakeAsyncTestZoneSpec:this},this.name="fakeAsyncTestZone for "+t,this.macroTaskOptions||(this.macroTaskOptions=e[Zone.__symbol__("FakeAsyncTestMacroTask")])}return s.assertInZone=function(){if(null==Zone.current.get("FakeAsyncTestZoneSpec"))throw new Error("The code should be running in the fakeAsync zone to call this function")},s.prototype._fnAndFlush=function(t,r){var n=this;return function(){for(var i=[],s=0;s-1&&e.splice(r,1)},s.prototype._dequeueTimer=function(e){var t=this;return function(){s._removeTimer(t.pendingTimers,e)}},s.prototype._requeuePeriodicTimer=function(e,t,r,n){var i=this;return function(){-1!==i.pendingPeriodicTimers.indexOf(n)&&i._scheduler.scheduleFunction(e,t,r,!0,!1,n)}},s.prototype._dequeuePeriodicTimer=function(e){var t=this;return function(){s._removeTimer(t.pendingPeriodicTimers,e)}},s.prototype._setTimeout=function(e,t,r,n){void 0===n&&(n=!0);var s=this._dequeueTimer(i.nextId),o=this._fnAndFlush(e,{onSuccess:s,onError:s}),a=this._scheduler.scheduleFunction(o,t,r,!1,!n);return n&&this.pendingTimers.push(a),a},s.prototype._clearTimeout=function(e){s._removeTimer(this.pendingTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},s.prototype._setInterval=function(e,t,r){var n=i.nextId,s={onSuccess:null,onError:this._dequeuePeriodicTimer(n)},o=this._fnAndFlush(e,s);return s.onSuccess=this._requeuePeriodicTimer(o,t,r,n),this._scheduler.scheduleFunction(o,t,r,!0),this.pendingPeriodicTimers.push(n),n},s.prototype._clearInterval=function(e){s._removeTimer(this.pendingPeriodicTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},s.prototype._resetLastErrorAndThrow=function(){var e=this._lastError||this._uncaughtPromiseErrors[0];throw this._uncaughtPromiseErrors.length=0,this._lastError=null,e},s.prototype.getCurrentTime=function(){return this._scheduler.getCurrentTime()},s.prototype.getCurrentRealTime=function(){return this._scheduler.getCurrentRealTime()},s.prototype.setCurrentRealTime=function(e){this._scheduler.setCurrentRealTime(e)},s.patchDate=function(){e[Zone.__symbol__("disableDatePatching")]||e.Date!==r&&(e.Date=r,r.prototype=t.prototype,s.checkTimerPatch())},s.resetDate=function(){e.Date===r&&(e.Date=t)},s.checkTimerPatch=function(){e.setTimeout!==n.setTimeout&&(e.setTimeout=n.setTimeout,e.clearTimeout=n.clearTimeout),e.setInterval!==n.setInterval&&(e.setInterval=n.setInterval,e.clearInterval=n.clearInterval)},s.prototype.lockDatePatch=function(){this.patchDateLocked=!0,s.patchDate()},s.prototype.unlockDatePatch=function(){this.patchDateLocked=!1,s.resetDate()},s.prototype.tick=function(e,t){void 0===e&&(e=0),s.assertInZone(),this.flushMicrotasks(),this._scheduler.tick(e,t),null!==this._lastError&&this._resetLastErrorAndThrow()},s.prototype.flushMicrotasks=function(){for(s.assertInZone();this._microtasks.length>0;){var e=this._microtasks.shift();e.func.apply(e.target,e.args)}(null!==this._lastError||this._uncaughtPromiseErrors.length)&&this._resetLastErrorAndThrow()},s.prototype.flush=function(e,t,r){s.assertInZone(),this.flushMicrotasks();var n=this._scheduler.flush(e,t,r);return null!==this._lastError&&this._resetLastErrorAndThrow(),n},s.prototype.onScheduleTask=function(e,t,r,n){switch(n.type){case"microTask":var i=n.data&&n.data.args,s=void 0;if(i){var o=n.data.cbIdx;"number"==typeof i.length&&i.length>o+1&&(s=Array.prototype.slice.call(i,o+1))}this._microtasks.push({func:n.invoke,args:s,target:n.data&&n.data.target});break;case"macroTask":switch(n.source){case"setTimeout":n.data.handleId=this._setTimeout(n.invoke,n.data.delay,Array.prototype.slice.call(n.data.args,2));break;case"setImmediate":n.data.handleId=this._setTimeout(n.invoke,0,Array.prototype.slice.call(n.data.args,1));break;case"setInterval":n.data.handleId=this._setInterval(n.invoke,n.data.delay,Array.prototype.slice.call(n.data.args,2));break;case"XMLHttpRequest.send":throw new Error("Cannot make XHRs from within a fake async test. Request URL: "+n.data.url);case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":n.data.handleId=this._setTimeout(n.invoke,16,n.data.args,this.trackPendingRequestAnimationFrame);break;default:var a=this.findMacroTaskOption(n);if(a){var u=n.data&&n.data.args,c=u&&u.length>1?u[1]:0,h=a.callbackArgs?a.callbackArgs:u;a.isPeriodic?(n.data.handleId=this._setInterval(n.invoke,c,h),n.data.isPeriodic=!0):n.data.handleId=this._setTimeout(n.invoke,c,h);break}throw new Error("Unknown macroTask scheduled in fake async test: "+n.source)}break;case"eventTask":n=e.scheduleTask(r,n)}return n},s.prototype.onCancelTask=function(e,t,r,n){switch(n.source){case"setTimeout":case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":return this._clearTimeout(n.data.handleId);case"setInterval":return this._clearInterval(n.data.handleId);default:var i=this.findMacroTaskOption(n);if(i){var s=n.data.handleId;return i.isPeriodic?this._clearInterval(s):this._clearTimeout(s)}return e.cancelTask(r,n)}},s.prototype.onInvoke=function(e,t,r,n,i,o,a){try{return s.patchDate(),e.invoke(r,n,i,o,a)}finally{this.patchDateLocked||s.resetDate()}},s.prototype.findMacroTaskOption=function(e){if(!this.macroTaskOptions)return null;for(var t=0;t0)throw new Error(s.pendingPeriodicTimers.length+" periodic timer(s) still in the queue.");if(s.pendingTimers.length>0)throw new Error(s.pendingTimers.length+" timer(s) still in the queue.");return h}finally{o()}}}}})}); \ No newline at end of file diff --git a/dist/jasmine-patch.js b/dist/jasmine-patch.js old mode 100644 new mode 100755 index 3c6958113..8de6af1d9 --- a/dist/jasmine-patch.js +++ b/dist/jasmine-patch.js @@ -6,289 +6,284 @@ * found in the LICENSE file at https://angular.io/license */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global['jasmine-patch-rollup'] = factory()); +}(this, function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + (function (_global) { + 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'."); + jasmine['__zone_patch__'] = true; + var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (!SyncTestZoneSpec) + throw new Error('Missing: SyncTestZoneSpec'); + if (!ProxyZoneSpec) + throw new Error('Missing: ProxyZoneSpec'); + var ambientZone = Zone.current; + // Create a synchronous-only zone in which to run `describe` blocks in order to raise an + // error if any asynchronous operations are attempted inside of a `describe` but outside of + // a `beforeEach` or `it`. + var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; - // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs - // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) - if (!Zone) - throw new Error('Missing: zone.js'); - if (typeof jasmine == 'undefined') - throw new Error('Missing: jasmine.js'); - if (jasmine['__zone_patch__']) - throw new Error("'jasmine' has already been patched with 'Zone'."); - jasmine['__zone_patch__'] = true; - var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (!SyncTestZoneSpec) - throw new Error('Missing: SyncTestZoneSpec'); - if (!ProxyZoneSpec) - throw new Error('Missing: ProxyZoneSpec'); - var ambientZone = Zone.current; - // Create a synchronous-only zone in which to run `describe` blocks in order to raise an - // error if any asynchronous operations are attempted inside of a `describe` but outside of - // a `beforeEach` or `it`. - var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - var symbol = Zone.__symbol__; - // whether patch jasmine clock when in fakeAsync - var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; - // the original variable name fakeAsyncPatchLock is not accurate, so the name will be - // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also - // automatically disable the auto jump into fakeAsync feature - var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && - ((_global[symbol('fakeAsyncPatchLock')] === true) || - (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); - var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; - if (!ignoreUnhandledRejection) { - var globalErrors_1 = jasmine.GlobalErrors; - if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { - jasmine[symbol('GlobalErrors')] = globalErrors_1; - jasmine.GlobalErrors = function () { - var instance = new globalErrors_1(); - var originalInstall = instance.install; - if (originalInstall && !instance[symbol('install')]) { - instance[symbol('install')] = originalInstall; - instance.install = function () { - var originalHandlers = process.listeners('unhandledRejection'); - var r = originalInstall.apply(this, arguments); - process.removeAllListeners('unhandledRejection'); - if (originalHandlers) { - originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. + var jasmineEnv = jasmine.getEnv(); + ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[methodName] = function (description, specDefinitions) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + }; + }); + ['it', 'xit', 'fit'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - return r; + return originalTick_1.apply(this, arguments); }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } } - return instance; + return clock; }; } - } - // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. - var jasmineEnv = jasmine.getEnv(); - ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[methodName] = function (description, specDefinitions) { - return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); - }; - }); - ['it', 'xit', 'fit'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (description, specDefinitions, timeout) { - arguments[1] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); - }; - }); - ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (specDefinitions, timeout) { - arguments[0] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); - }; - }); - if (!disablePatchingJasmineClock) { - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableAutoFakeAsyncWhenClockPatched) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); + /** + * Gets a function wrapping the body of a Jasmine `describe` block to execute in a + * synchronous-only zone. + */ + function wrapDescribeInZone(describeBody) { + return function () { + return syncZone.run(describeBody, this, arguments); + }; + } + function runInTestZone(testBody, applyThis, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } } - return clock; - }; - } - /** - * Gets a function wrapping the body of a Jasmine `describe` block to execute in a - * synchronous-only zone. - */ - function wrapDescribeInZone(describeBody) { - return function () { - return syncZone.run(describeBody, this, arguments); - }; - } - function runInTestZone(testBody, applyThis, queueRunner, done) { - var isClockInstalled = !!jasmine[symbol('clockInstalled')]; - var testProxyZoneSpec = queueRunner.testProxyZoneSpec; - var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { - // auto run a fakeAsync - var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; - if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { - testBody = fakeAsyncModule.fakeAsync(testBody); + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); + } + else { + return testProxyZone.run(testBody, applyThis); } } - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); + /** + * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to + * execute in a ProxyZone zone. + * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` + */ + function wrapTestInZone(testBody) { + // The `done` callback is only passed through if the function expects at least one argument. + // Note we have to make a function with correct number of arguments, otherwise jasmine will + // think that all functions are sync or async. + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this, this.queueRunner, done); + } : function () { + return runInTestZone(testBody, this, this.queueRunner); + })); } - } - /** - * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to - * execute in a ProxyZone zone. - * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` - */ - function wrapTestInZone(testBody) { - // The `done` callback is only passed through if the function expects at least one argument. - // Note we have to make a function with correct number of arguments, otherwise jasmine will - // think that all functions are sync or async. - return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this, this.queueRunner, done); - } : function () { - return runInTestZone(testBody, this, this.queueRunner); - })); - } - var QueueRunner = jasmine.QueueRunner; - jasmine.QueueRunner = (function (_super) { - __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs) { - var _this = this; - attrs.onComplete = (function (fn) { return function () { - // All functions are done, clear the test zone. - _this.testProxyZone = null; - _this.testProxyZoneSpec = null; - ambientZone.scheduleMicroTask('jasmine.onComplete', fn); - }; })(attrs.onComplete); - var nativeSetTimeout = _global['__zone_symbol__setTimeout']; - var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; - if (nativeSetTimeout) { - // should run setTimeout inside jasmine outside of zone - attrs.timeout = { - setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, - clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout - }; - } - // create a userContext to hold the queueRunner itself - // so we can access the testProxy in it/xit/beforeEach ... - if (jasmine.UserContext) { - if (!attrs.userContext) { - attrs.userContext = new jasmine.UserContext(); + var QueueRunner = jasmine.QueueRunner; + jasmine.QueueRunner = (function (_super) { + __extends(ZoneQueueRunner, _super); + function ZoneQueueRunner(attrs) { + var _this = this; + attrs.onComplete = (function (fn) { return function () { + // All functions are done, clear the test zone. + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + }; })(attrs.onComplete); + var nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; + var nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; } - attrs.userContext.queueRunner = this; - } - else { - if (!attrs.userContext) { - attrs.userContext = {}; + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; } - attrs.userContext.queueRunner = this; - } - // patch attrs.onException - var onException = attrs.onException; - attrs.onException = function (error) { - if (error && - error.message === - 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { - // jasmine timeout, we can make the error message more - // reasonable to tell what tasks are pending - var proxyZoneSpec = this && this.testProxyZoneSpec; - if (proxyZoneSpec) { - var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - try { - // try catch here in case error.message is not writable - error.message += pendingTasksInfo; - } - catch (err) { + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } } } + if (onException) { + onException.call(this, error); + } + }; + _super.call(this, attrs); + } + ZoneQueueRunner.prototype.execute = function () { + var _this = this; + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; } - if (onException) { - onException.call(this, error); + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); + if (!Zone.currentTask) { + // if we are not running in a task then if someone would register a + // element.addEventListener and then calling element.click() the + // addEventListener callback would think that it is the top most task and would + // drain the microtask queue on element.click() which would be incorrect. + // For this reason we always force a task when running jasmine tests. + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); } - }; - _super.call(this, attrs); - } - ZoneQueueRunner.prototype.execute = function () { - var _this = this; - var zone = Zone.current; - var isChildOfAmbientZone = false; - while (zone) { - if (zone === ambientZone) { - isChildOfAmbientZone = true; - break; + else { + _super.prototype.execute.call(this); } - zone = zone.parent; - } - if (!isChildOfAmbientZone) - throw new Error('Unexpected Zone: ' + Zone.current.name); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - this.testProxyZoneSpec = new ProxyZoneSpec(); - this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); - if (!Zone.currentTask) { - // if we are not running in a task then if someone would register a - // element.addEventListener and then calling element.click() the - // addEventListener callback would think that it is the top most task and would - // drain the microtask queue on element.click() which would be incorrect. - // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); - } - else { - _super.prototype.execute.call(this); - } - }; - return ZoneQueueRunner; - })(QueueRunner); -})(); - -}))); + }; + return ZoneQueueRunner; + })(QueueRunner); + })(commonjsGlobal); + var jasmine_1 = {}; + return jasmine_1; +})); +//# sourceMappingURL=jasmine-patch-rollup.umd.js.map diff --git a/dist/jasmine-patch.min.js b/dist/jasmine-patch.min.js old mode 100644 new mode 100755 index 016466a6a..c1cc4c55f --- a/dist/jasmine-patch.min.js +++ b/dist/jasmine-patch.min.js @@ -1 +1,8 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";!function(){var e="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global;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 n=Zone.SyncTestZoneSpec,t=Zone.ProxyZoneSpec;if(!n)throw new Error("Missing: SyncTestZoneSpec");if(!t)throw new Error("Missing: ProxyZoneSpec");var o=Zone.current,r=o.fork(new n("jasmine.describe")),i=Zone.__symbol__,s=!0===e[i("fakeAsyncDisablePatchingClock")],c=!s&&(!0===e[i("fakeAsyncPatchLock")]||!0===e[i("fakeAsyncAutoFakeAsyncWhenClockPatched")]);if(!(!0===e[i("ignoreUnhandledRejection")])){var a=jasmine.GlobalErrors;a&&!jasmine[i("GlobalErrors")]&&(jasmine[i("GlobalErrors")]=a,jasmine.GlobalErrors=function(){var e=new a,n=e.install;return n&&!e[i("install")]&&(e[i("install")]=n,e.install=function(){var e=process.listeners("unhandledRejection"),t=n.apply(this,arguments);return process.removeAllListeners("unhandledRejection"),e&&e.forEach(function(e){return process.on("unhandledRejection",e)}),t}),e})}var u=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(function(e){var n=u[e];u[e]=function(e,t){return n.call(this,e,(o=t,function(){return r.run(o,this,arguments)}));var o}}),["it","xit","fit"].forEach(function(e){var n=u[e];u[i(e)]=n,u[e]=function(e,t,o){return arguments[1]=p(t),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=u[e];u[i(e)]=n,u[e]=function(e,t){return arguments[0]=p(e),n.apply(this,arguments)}}),!s){var l=jasmine[i("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments);if(!e[i("patched")]){e[i("patched")]=i("patched");var n=e[i("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[i("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},c&&["install","uninstall"].forEach(function(n){var t=e[i(n)]=e[n];e[n]=function(){if(!Zone.FakeAsyncTestZoneSpec)return t.apply(this,arguments);jasmine[i("clockInstalled")]="install"===n}})}return e}}function f(e,n,t,o){var r=!!jasmine[i("clockInstalled")],s=(t.testProxyZoneSpec,t.testProxyZone);if(r&&c){var a=Zone[Zone.__symbol__("fakeAsyncTest")];a&&"function"==typeof a.fakeAsync&&(e=a.fakeAsync(e))}return o?s.run(e,n,[o]):s.run(e,n)}function p(e){return e&&(e.length?function(n){return f(e,this,this.queueRunner,n)}:function(){return f(e,this,this.queueRunner)})}var h=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(t){var r,i=this;t.onComplete=(r=t.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,o.scheduleMicroTask("jasmine.onComplete",r)});var s=e.__zone_symbol__setTimeout,c=e.__zone_symbol__clearTimeout;s&&(t.timeout={setTimeout:s||e.setTimeout,clearTimeout:c||e.clearTimeout}),jasmine.UserContext?(t.userContext||(t.userContext=new jasmine.UserContext),t.userContext.queueRunner=this):(t.userContext||(t.userContext={}),t.userContext.queueRunner=this);var a=t.onException;t.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();try{e.message+=t}catch(e){}}}a&&a.call(this,e)},n.call(this,t)}return function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);function o(){this.constructor=e}e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(r,n),r.prototype.execute=function(){for(var e=this,r=Zone.current,i=!1;r;){if(r===o){i=!0;break}r=r.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new t,this.testProxyZone=o.fork(this.testProxyZoneSpec),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(e)})},r}(h)}()}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self)["jasmine-patch-rollup"]=n()}(this,function(){"use strict";return function(e){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 n=Zone.SyncTestZoneSpec,t=Zone.ProxyZoneSpec;if(!n)throw new Error("Missing: SyncTestZoneSpec");if(!t)throw new Error("Missing: ProxyZoneSpec");var o=Zone.current,r=o.fork(new n("jasmine.describe")),i=Zone.__symbol__,s=!0===e[i("fakeAsyncDisablePatchingClock")],c=!s&&(!0===e[i("fakeAsyncPatchLock")]||!0===e[i("fakeAsyncAutoFakeAsyncWhenClockPatched")]);if(!0!==e[i("ignoreUnhandledRejection")]){var a=jasmine.GlobalErrors;a&&!jasmine[i("GlobalErrors")]&&(jasmine[i("GlobalErrors")]=a,jasmine.GlobalErrors=function(){var e=new a,n=e.install;return n&&!e[i("install")]&&(e[i("install")]=n,e.install=function(){var e=process.listeners("unhandledRejection"),t=n.apply(this,arguments);return process.removeAllListeners("unhandledRejection"),e&&e.forEach(function(e){return process.on("unhandledRejection",e)}),t}),e})}var u=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(function(e){var n=u[e];u[e]=function(e,t){return n.call(this,e,function o(e){return function(){return r.run(e,this,arguments)}}(t))}}),["it","xit","fit"].forEach(function(e){var n=u[e];u[i(e)]=n,u[e]=function(e,t,o){return arguments[1]=p(t),n.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(function(e){var n=u[e];u[i(e)]=n,u[e]=function(e,t){return arguments[0]=p(e),n.apply(this,arguments)}}),!s){var l=jasmine[i("clock")]=jasmine.clock;jasmine.clock=function(){var e=l.apply(this,arguments);if(!e[i("patched")]){e[i("patched")]=i("patched");var n=e[i("tick")]=e.tick;e.tick=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.tick.apply(e,arguments):n.apply(this,arguments)};var t=e[i("mockDate")]=e.mockDate;e.mockDate=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){var n=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,n&&"function"==typeof n.getTime?[n.getTime()]:arguments)}return t.apply(this,arguments)},c&&["install","uninstall"].forEach(function(n){var t=e[i(n)]=e[n];e[n]=function(){if(!Zone.FakeAsyncTestZoneSpec)return t.apply(this,arguments);jasmine[i("clockInstalled")]="install"===n}})}return e}}function f(e,n,t,o){var r=!!jasmine[i("clockInstalled")],s=t.testProxyZone;if(r&&c){var a=Zone[Zone.__symbol__("fakeAsyncTest")];a&&"function"==typeof a.fakeAsync&&(e=a.fakeAsync(e))}return o?s.run(e,n,[o]):s.run(e,n)}function p(e){return e&&(e.length?function(n){return f(e,this,this.queueRunner,n)}:function(){return f(e,this,this.queueRunner)})}var h=jasmine.QueueRunner;jasmine.QueueRunner=function(n){function r(t){var r,i=this;t.onComplete=(r=t.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,o.scheduleMicroTask("jasmine.onComplete",r)});var s=e[Zone.__symbol__("setTimeout")],c=e[Zone.__symbol__("clearTimeout")];s&&(t.timeout={setTimeout:s||e.setTimeout,clearTimeout:c||e.clearTimeout}),jasmine.UserContext?(t.userContext||(t.userContext=new jasmine.UserContext),t.userContext.queueRunner=this):(t.userContext||(t.userContext={}),t.userContext.queueRunner=this);var a=t.onException;t.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var n=this&&this.testProxyZoneSpec;if(n){var t=n.getAndClearPendingTasksInfo();try{e.message+=t}catch(e){}}}a&&a.call(this,e)},n.call(this,t)}return function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);function o(){this.constructor=e}e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}(r,n),r.prototype.execute=function(){for(var e=this,r=Zone.current,i=!1;r;){if(r===o){i=!0;break}r=r.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new t,this.testProxyZone=o.fork(this.testProxyZoneSpec),Zone.currentTask?n.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return h.prototype.execute.call(e)})},r}(h)}("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}),{}}); \ No newline at end of file diff --git a/dist/long-stack-trace-zone.js b/dist/long-stack-trace-zone.js old mode 100644 new mode 100755 index 9200ae7ca..479e50ed5 --- a/dist/long-stack-trace-zone.js +++ b/dist/long-stack-trace-zone.js @@ -5,189 +5,177 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var __assign = (undefined && undefined.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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 + */ + /** + * @fileoverview + * @suppress {globalThis} + */ + var NEWLINE = '\n'; + var IGNORE_FRAMES = {}; + var creationTrace = '__creationTrace__'; + var ERROR_TAG = 'STACKTRACE TRACKING'; + var SEP_TAG = '__SEP_TAG__'; + var sepTemplate = SEP_TAG + '@[native]'; + var LongStackTrace = /** @class */ (function () { + function LongStackTrace() { + this.error = getStacktrace(); + this.timestamp = new Date(); } - return t; - }; - return __assign.apply(this, arguments); -}; -var NEWLINE = '\n'; -var IGNORE_FRAMES = {}; -var creationTrace = '__creationTrace__'; -var ERROR_TAG = 'STACKTRACE TRACKING'; -var SEP_TAG = '__SEP_TAG__'; -var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = /** @class */ (function () { - function LongStackTrace() { - this.error = getStacktrace(); - this.timestamp = new Date(); + return LongStackTrace; + }()); + function getStacktraceWithUncaughtError() { + return new Error(ERROR_TAG); } - return LongStackTrace; -}()); -function getStacktraceWithUncaughtError() { - return new Error(ERROR_TAG); -} -function getStacktraceWithCaughtError() { - try { - throw getStacktraceWithUncaughtError(); + function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); + } + catch (err) { + return err; + } } - catch (err) { - return err; + // Some implementations of exception handling don't create a stack trace if the exception + // isn't thrown, however it's faster not to actually throw the exception. + var error = getStacktraceWithUncaughtError(); + var caughtError = getStacktraceWithCaughtError(); + var getStacktrace = error.stack ? + getStacktraceWithUncaughtError : + (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); + function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; } -} -// Some implementations of exception handling don't create a stack trace if the exception -// isn't thrown, however it's faster not to actually throw the exception. -var error = getStacktraceWithUncaughtError(); -var caughtError = getStacktraceWithCaughtError(); -var getStacktrace = error.stack ? - getStacktraceWithUncaughtError : - (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); -function getFrames(error) { - return error.stack ? error.stack.split(NEWLINE) : []; -} -function addErrorStack(lines, error) { - var trace = getFrames(error); - for (var i = 0; i < trace.length; i++) { - var frame = trace[i]; - // Filter out the Frames which are part of stack capturing. - if (!IGNORE_FRAMES.hasOwnProperty(frame)) { - lines.push(trace[i]); + function addErrorStack(lines, error) { + var trace = getFrames(error); + for (var i = 0; i < trace.length; i++) { + var frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!IGNORE_FRAMES.hasOwnProperty(frame)) { + lines.push(trace[i]); + } } } -} -function renderLongStackTrace(frames, stack) { - var longTrace = [stack ? stack.trim() : '']; - if (frames) { - var timestamp = new Date().getTime(); - for (var i = 0; i < frames.length; i++) { - var traceFrames = frames[i]; - var lastTime = traceFrames.timestamp; - var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; - separator = separator.replace(/[^\w\d]/g, '_'); - longTrace.push(sepTemplate.replace(SEP_TAG, separator)); - addErrorStack(longTrace, traceFrames.error); - timestamp = lastTime.getTime(); + function renderLongStackTrace(frames, stack) { + var longTrace = [stack ? stack.trim() : '']; + if (frames) { + var timestamp = new Date().getTime(); + for (var i = 0; i < frames.length; i++) { + var traceFrames = frames[i]; + var lastTime = traceFrames.timestamp; + var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; + separator = separator.replace(/[^\w\d]/g, '_'); + longTrace.push(sepTemplate.replace(SEP_TAG, separator)); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); + } } + return longTrace.join(NEWLINE); } - return longTrace.join(NEWLINE); -} -Zone['longStackTraceZoneSpec'] = { - name: 'long-stack-trace', - longStackTraceLimit: 10, - // add a getLongStackTrace method in spec to - // handle handled reject promise error. - getLongStackTrace: function (error) { - if (!error) { - return undefined; - } - var trace = error[Zone.__symbol__('currentTaskTrace')]; - if (!trace) { - return error.stack; - } - return renderLongStackTrace(trace, error.stack); - }, - onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var currentTask = Zone.currentTask; - var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; - trace = [new LongStackTrace()].concat(trace); - if (trace.length > this.longStackTraceLimit) { - trace.length = this.longStackTraceLimit; + Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + // add a getLongStackTrace method in spec to + // handle handled reject promise error. + getLongStackTrace: function (error) { + if (!error) { + return undefined; } - if (!task.data) - task.data = {}; - if (task.type === 'eventTask') { - // Fix issue https://github.com/angular/zone.js/issues/1195, - // For event task of browser, by default, all task will share a - // singleton instance of data object, we should create a new one here - // The cast to `any` is required to workaround a closure bug which wrongly applies - // URL sanitization rules to .data access. - task.data = __assign({}, task.data); + var trace = error[Zone.__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; } - task.data[creationTrace] = trace; - } - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var parentTask = Zone.currentTask || error.task; - if (error instanceof Error && parentTask) { - var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); - try { - error.stack = error.longStack = longStack; + return renderLongStackTrace(trace, error.stack); + }, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var currentTask = Zone.currentTask; + var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; } - catch (err) { + if (!task.data) + task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = Object.assign({}, task.data); } + task.data[creationTrace] = trace; } - } - return parentZoneDelegate.handleError(targetZone, error); - } -}; -function captureStackTraces(stackTraces, count) { - if (count > 0) { - stackTraces.push(getFrames((new LongStackTrace()).error)); - captureStackTraces(stackTraces, count - 1); - } -} -function computeIgnoreFrames() { - if (Error.stackTraceLimit <= 0) { - return; - } - var frames = []; - captureStackTraces(frames, 2); - var frames1 = frames[0]; - var frames2 = frames[1]; - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - if (frame1.indexOf(ERROR_TAG) == -1) { - var match = frame1.match(/^\s*at\s+/); - if (match) { - sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; - break; + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + try { + error.stack = error.longStack = longStack; + } + catch (err) { + } + } } + return parentZoneDelegate.handleError(targetZone, error); + } + }; + function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); } } - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - var frame2 = frames2[i]; - if (frame1 === frame2) { - IGNORE_FRAMES[frame1] = true; + function computeIgnoreFrames() { + if (Error.stackTraceLimit <= 0) { + return; } - else { - break; + var frames = []; + captureStackTraces(frames, 2); + var frames1 = frames[0]; + var frames2 = frames[1]; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + if (frame1.indexOf(ERROR_TAG) == -1) { + var match = frame1.match(/^\s*at\s+/); + if (match) { + sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + break; + } + } + } + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + var frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES[frame1] = true; + } + else { + break; + } } } -} -computeIgnoreFrames(); - -}))); + computeIgnoreFrames(); +})); +//# sourceMappingURL=long-stack-trace-zone-rollup.umd.js.map diff --git a/dist/long-stack-trace-zone.min.js b/dist/long-stack-trace-zone.min.js old mode 100644 new mode 100755 index fe18bf627..58cbca74b --- a/dist/long-stack-trace-zone.min.js +++ b/dist/long-stack-trace-zone.min.js @@ -1 +1,15 @@ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r():"function"==typeof define&&define.amd?define(r):r()}(0,function(){"use strict";var t=function(){return(t=Object.assign||function(t){for(var r,a=1,e=arguments.length;a0){var c=Zone.currentTask,i=c&&c.data&&c.data.__creationTrace__||[];(i=[new o].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),n.data||(n.data={}),"eventTask"===n.type&&(n.data=t({},n.data)),n.data.__creationTrace__=i}return r.scheduleTask(e,n)},onHandleError:function(t,r,a,e){if(Error.stackTraceLimit>0){var n=Zone.currentTask||e.task;if(e instanceof Error&&n){var c=h(n.data&&n.data.__creationTrace__,e.stack);try{e.stack=e.longStack=c}catch(t){}}}return t.handleError(a,e)}},function(){if(!(Error.stackTraceLimit<=0)){var t=[];!function t(r,a){a>0&&(r.push(l((new o).error)),t(r,a-1))}(t,2);for(var r=t[0],i=t[1],s=0;s0){var n=Zone.currentTask,i=n&&n.data&&n.data.__creationTrace__||[];(i=[new c].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),e.data||(e.data={}),"eventTask"===e.type&&(e.data=Object.assign({},e.data)),e.data.__creationTrace__=i}return t.scheduleTask(r,e)},onHandleError:function(t,a,r,e){if(Error.stackTraceLimit>0){var n=Zone.currentTask||e.task;if(e instanceof Error&&n){var c=T(n.data&&n.data.__creationTrace__,e.stack);try{e.stack=e.longStack=c}catch(t){}}}return t.handleError(r,e)}},function h(){if(!(Error.stackTraceLimit<=0)){var t=[];!function t(a,r){r>0&&(a.push(u((new c).error)),t(a,r-1))}(t,2);for(var i=t[0],o=t[1],s=0;s 0 ? args[0] : null; - if (typeof callback === 'function') { - var wrapperedCallback = Zone.current.wrap(callback, 'MediaQuery'); - callback[api.symbol('mediaQueryCallback')] = wrapperedCallback; - return delegate.call(self, wrapperedCallback); - } - else { - return delegate.apply(self, args); - } - }; }); - } - function patchRemoveListener(proto) { - api.patchMethod(proto, 'removeListener', function (delegate) { return function (self, args) { - var callback = args.length > 0 ? args[0] : null; - if (typeof callback === 'function') { - var wrapperedCallback = callback[api.symbol('mediaQueryCallback')]; - if (wrapperedCallback) { +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('mediaQuery', function (global, Zone, api) { + function patchAddListener(proto) { + api.patchMethod(proto, 'addListener', function (delegate) { return function (self, args) { + var callback = args.length > 0 ? args[0] : null; + if (typeof callback === 'function') { + var wrapperedCallback = Zone.current.wrap(callback, 'MediaQuery'); + callback[api.symbol('mediaQueryCallback')] = wrapperedCallback; return delegate.call(self, wrapperedCallback); } else { return delegate.apply(self, args); } - } - else { - return delegate.apply(self, args); - } - }; }); - } - if (global['MediaQueryList']) { - var proto = global['MediaQueryList'].prototype; - patchAddListener(proto); - patchRemoveListener(proto); - } - else if (global['matchMedia']) { - api.patchMethod(global, 'matchMedia', function (delegate) { return function (self, args) { - var mql = delegate.apply(self, args); - if (mql) { - // try to patch MediaQueryList.prototype - var proto = Object.getPrototypeOf(mql); - if (proto && proto['addListener']) { - // try to patch proto, don't need to worry about patch - // multiple times, because, api.patchEventTarget will check it - patchAddListener(proto); - patchRemoveListener(proto); - patchAddListener(mql); - patchRemoveListener(mql); + }; }); + } + function patchRemoveListener(proto) { + api.patchMethod(proto, 'removeListener', function (delegate) { return function (self, args) { + var callback = args.length > 0 ? args[0] : null; + if (typeof callback === 'function') { + var wrapperedCallback = callback[api.symbol('mediaQueryCallback')]; + if (wrapperedCallback) { + return delegate.call(self, wrapperedCallback); + } + else { + return delegate.apply(self, args); + } + } + else { + return delegate.apply(self, args); } - else if (mql['addListener']) { - // proto not exists, or proto has no addListener method - // try to patch mql instance - patchAddListener(mql); - patchRemoveListener(mql); + }; }); + } + if (global['MediaQueryList']) { + var proto = global['MediaQueryList'].prototype; + patchAddListener(proto); + patchRemoveListener(proto); + } + else if (global['matchMedia']) { + api.patchMethod(global, 'matchMedia', function (delegate) { return function (self, args) { + var mql = delegate.apply(self, args); + if (mql) { + // try to patch MediaQueryList.prototype + var proto = Object.getPrototypeOf(mql); + if (proto && proto['addListener']) { + // try to patch proto, don't need to worry about patch + // multiple times, because, api.patchEventTarget will check it + patchAddListener(proto); + patchRemoveListener(proto); + patchAddListener(mql); + patchRemoveListener(mql); + } + else if (mql['addListener']) { + // proto not exists, or proto has no addListener method + // try to patch mql instance + patchAddListener(mql); + patchRemoveListener(mql); + } } - } - return mql; - }; }); - } -}); - -}))); + return mql; + }; }); + } + }); +})); +//# sourceMappingURL=webapis-media-query-rollup.umd.js.map diff --git a/dist/webapis-media-query.min.js b/dist/webapis-media-query.min.js old mode 100644 new mode 100755 index ed52fa771..8559db661 --- a/dist/webapis-media-query.min.js +++ b/dist/webapis-media-query.min.js @@ -1 +1,15 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("mediaQuery",function(e,t,n){function r(e){n.patchMethod(e,"addListener",function(e){return function(r,a){var i=a.length>0?a[0]:null;if("function"==typeof i){var o=t.current.wrap(i,"MediaQuery");return i[n.symbol("mediaQueryCallback")]=o,e.call(r,o)}return e.apply(r,a)}})}function a(e){n.patchMethod(e,"removeListener",function(e){return function(t,r){var a=r.length>0?r[0]:null;if("function"==typeof a){var i=a[n.symbol("mediaQueryCallback")];return i?e.call(t,i):e.apply(t,r)}return e.apply(t,r)}})}if(e.MediaQueryList){var i=e.MediaQueryList.prototype;r(i),a(i)}else e.matchMedia&&n.patchMethod(e,"matchMedia",function(e){return function(t,n){var i=e.apply(t,n);if(i){var o=Object.getPrototypeOf(i);o&&o.addListener?(r(o),a(o),r(i),a(i)):i.addListener&&(r(i),a(i))}return i}})})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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.__load_patch("mediaQuery",function(e,t,n){function r(e){n.patchMethod(e,"addListener",function(e){return function(r,a){var i=a.length>0?a[0]:null;if("function"==typeof i){var u=t.current.wrap(i,"MediaQuery");return i[n.symbol("mediaQueryCallback")]=u,e.call(r,u)}return e.apply(r,a)}})}function a(e){n.patchMethod(e,"removeListener",function(e){return function(t,r){var a=r.length>0?r[0]:null;if("function"==typeof a){var i=a[n.symbol("mediaQueryCallback")];return i?e.call(t,i):e.apply(t,r)}return e.apply(t,r)}})}if(e.MediaQueryList){var i=e.MediaQueryList.prototype;r(i),a(i)}else e.matchMedia&&n.patchMethod(e,"matchMedia",function(e){return function(t,n){var i=e.apply(t,n);if(i){var u=Object.getPrototypeOf(i);u&&u.addListener?(r(u),a(u),r(i),a(i)):i.addListener&&(r(i),a(i))}return i}})})}); \ No newline at end of file diff --git a/dist/webapis-notification.js b/dist/webapis-notification.js old mode 100644 new mode 100755 index 476d1f929..1968082ce --- a/dist/webapis-notification.js +++ b/dist/webapis-notification.js @@ -5,29 +5,28 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('notification', function (global, Zone, api) { - var Notification = global['Notification']; - if (!Notification || !Notification.prototype) { - return; - } - var desc = Object.getOwnPropertyDescriptor(Notification.prototype, 'onerror'); - if (!desc || !desc.configurable) { - return; - } - api.patchOnProperties(Notification.prototype, null); -}); - -}))); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('notification', function (global, Zone, api) { + var Notification = global['Notification']; + if (!Notification || !Notification.prototype) { + return; + } + var desc = Object.getOwnPropertyDescriptor(Notification.prototype, 'onerror'); + if (!desc || !desc.configurable) { + return; + } + api.patchOnProperties(Notification.prototype, null); + }); +})); +//# sourceMappingURL=webapis-notification-rollup.umd.js.map diff --git a/dist/webapis-notification.min.js b/dist/webapis-notification.min.js old mode 100644 new mode 100755 index c632924e5..287874b23 --- a/dist/webapis-notification.min.js +++ b/dist/webapis-notification.min.js @@ -1 +1,15 @@ -!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("notification",function(o,t,e){var n=o.Notification;if(n&&n.prototype){var i=Object.getOwnPropertyDescriptor(n.prototype,"onerror");i&&i.configurable&&e.patchOnProperties(n.prototype,null)}})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict"; +/** + * @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.__load_patch("notification",function(t,o,e){var n=t.Notification;if(n&&n.prototype){var i=Object.getOwnPropertyDescriptor(n.prototype,"onerror");i&&i.configurable&&e.patchOnProperties(n.prototype,null)}})}); \ No newline at end of file diff --git a/dist/webapis-rtc-peer-connection.js b/dist/webapis-rtc-peer-connection.js old mode 100644 new mode 100755 index 728232d67..dfb0ec0c5 --- a/dist/webapis-rtc-peer-connection.js +++ b/dist/webapis-rtc-peer-connection.js @@ -5,33 +5,32 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('RTCPeerConnection', function (global, Zone, api) { - var RTCPeerConnection = global['RTCPeerConnection']; - if (!RTCPeerConnection) { - return; - } - var addSymbol = api.symbol('addEventListener'); - var removeSymbol = api.symbol('removeEventListener'); - RTCPeerConnection.prototype.addEventListener = RTCPeerConnection.prototype[addSymbol]; - RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol]; - // RTCPeerConnection extends EventTarget, so we must clear the symbol - // to allow patch RTCPeerConnection.prototype.addEventListener again - RTCPeerConnection.prototype[addSymbol] = null; - RTCPeerConnection.prototype[removeSymbol] = null; - api.patchEventTarget(global, [RTCPeerConnection.prototype], { useG: false }); -}); - -}))); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('RTCPeerConnection', function (global, Zone, api) { + var RTCPeerConnection = global['RTCPeerConnection']; + if (!RTCPeerConnection) { + return; + } + var addSymbol = api.symbol('addEventListener'); + var removeSymbol = api.symbol('removeEventListener'); + RTCPeerConnection.prototype.addEventListener = RTCPeerConnection.prototype[addSymbol]; + RTCPeerConnection.prototype.removeEventListener = RTCPeerConnection.prototype[removeSymbol]; + // RTCPeerConnection extends EventTarget, so we must clear the symbol + // to allow patch RTCPeerConnection.prototype.addEventListener again + RTCPeerConnection.prototype[addSymbol] = null; + RTCPeerConnection.prototype[removeSymbol] = null; + api.patchEventTarget(global, [RTCPeerConnection.prototype], { useG: false }); + }); +})); +//# sourceMappingURL=webapis-rtc-peer-connection-rollup.umd.js.map diff --git a/dist/webapis-rtc-peer-connection.min.js b/dist/webapis-rtc-peer-connection.min.js old mode 100644 new mode 100755 index ded10ecbb..18edaa7cd --- a/dist/webapis-rtc-peer-connection.min.js +++ b/dist/webapis-rtc-peer-connection.min.js @@ -1 +1,15 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("RTCPeerConnection",function(e,t,o){var n=e.RTCPeerConnection;if(n){var p=o.symbol("addEventListener"),r=o.symbol("removeEventListener");n.prototype.addEventListener=n.prototype[p],n.prototype.removeEventListener=n.prototype[r],n.prototype[p]=null,n.prototype[r]=null,o.patchEventTarget(e,[n.prototype],{useG:!1})}})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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.__load_patch("RTCPeerConnection",function(e,t,n){var o=e.RTCPeerConnection;if(o){var r=n.symbol("addEventListener"),p=n.symbol("removeEventListener");o.prototype.addEventListener=o.prototype[r],o.prototype.removeEventListener=o.prototype[p],o.prototype[r]=null,o.prototype[p]=null,n.patchEventTarget(e,[o.prototype],{useG:!1})}})}); \ No newline at end of file diff --git a/dist/webapis-shadydom.js b/dist/webapis-shadydom.js old mode 100644 new mode 100755 index 65599e673..848518f59 --- a/dist/webapis-shadydom.js +++ b/dist/webapis-shadydom.js @@ -5,35 +5,34 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('shadydom', function (global, Zone, api) { - // https://github.com/angular/zone.js/issues/782 - // in web components, shadydom will patch addEventListener/removeEventListener of - // Node.prototype and WindowPrototype, this will have conflict with zone.js - // so zone.js need to patch them again. - var windowPrototype = Object.getPrototypeOf(window); - if (windowPrototype && windowPrototype.hasOwnProperty('addEventListener')) { - windowPrototype[Zone.__symbol__('addEventListener')] = null; - windowPrototype[Zone.__symbol__('removeEventListener')] = null; - api.patchEventTarget(global, [windowPrototype]); - } - if (Node.prototype.hasOwnProperty('addEventListener')) { - Node.prototype[Zone.__symbol__('addEventListener')] = null; - Node.prototype[Zone.__symbol__('removeEventListener')] = null; - api.patchEventTarget(global, [Node.prototype]); - } -}); - -}))); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('shadydom', function (global, Zone, api) { + // https://github.com/angular/zone.js/issues/782 + // in web components, shadydom will patch addEventListener/removeEventListener of + // Node.prototype and WindowPrototype, this will have conflict with zone.js + // so zone.js need to patch them again. + var windowPrototype = Object.getPrototypeOf(window); + if (windowPrototype && windowPrototype.hasOwnProperty('addEventListener')) { + windowPrototype[Zone.__symbol__('addEventListener')] = null; + windowPrototype[Zone.__symbol__('removeEventListener')] = null; + api.patchEventTarget(global, [windowPrototype]); + } + if (Node.prototype.hasOwnProperty('addEventListener')) { + Node.prototype[Zone.__symbol__('addEventListener')] = null; + Node.prototype[Zone.__symbol__('removeEventListener')] = null; + api.patchEventTarget(global, [Node.prototype]); + } + }); +})); +//# sourceMappingURL=webapis-shadydom-rollup.umd.js.map diff --git a/dist/webapis-shadydom.min.js b/dist/webapis-shadydom.min.js old mode 100644 new mode 100755 index cbdc0c953..3fdaf30d3 --- a/dist/webapis-shadydom.min.js +++ b/dist/webapis-shadydom.min.js @@ -1 +1,15 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("shadydom",function(e,t,o){var n=Object.getPrototypeOf(window);n&&n.hasOwnProperty("addEventListener")&&(n[t.__symbol__("addEventListener")]=null,n[t.__symbol__("removeEventListener")]=null,o.patchEventTarget(e,[n])),Node.prototype.hasOwnProperty("addEventListener")&&(Node.prototype[t.__symbol__("addEventListener")]=null,Node.prototype[t.__symbol__("removeEventListener")]=null,o.patchEventTarget(e,[Node.prototype]))})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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.__load_patch("shadydom",function(e,t,n){var o=Object.getPrototypeOf(window);o&&o.hasOwnProperty("addEventListener")&&(o[t.__symbol__("addEventListener")]=null,o[t.__symbol__("removeEventListener")]=null,n.patchEventTarget(e,[o])),Node.prototype.hasOwnProperty("addEventListener")&&(Node.prototype[t.__symbol__("addEventListener")]=null,Node.prototype[t.__symbol__("removeEventListener")]=null,n.patchEventTarget(e,[Node.prototype]))})}); \ No newline at end of file diff --git a/dist/wtf.js b/dist/wtf.js old mode 100644 new mode 100755 index dfea9d170..0686a17bf --- a/dist/wtf.js +++ b/dist/wtf.js @@ -6,127 +6,130 @@ * found in the LICENSE file at https://angular.io/license */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -(function (global) { - // Detect and setup WTF. - var wtfTrace = null; - var wtfEvents = null; - var wtfEnabled = (function () { - var wtf = global['wtf']; - if (wtf) { - wtfTrace = wtf.trace; - if (wtfTrace) { - wtfEvents = wtfTrace.events; - return true; - } - } - return false; - })(); - var WtfZoneSpec = /** @class */ (function () { - function WtfZoneSpec() { - this.name = 'WTF'; - } - WtfZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { - var retValue = parentZoneDelegate.fork(targetZone, zoneSpec); - WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); - return retValue; - }; - WtfZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - var src = source || 'unknown'; - var scope = WtfZoneSpec.invokeScope[src]; - if (!scope) { - scope = WtfZoneSpec.invokeScope[src] = - wtfEvents.createScope("Zone:invoke:" + source + "(ascii zone)"); - } - return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); - }; - WtfZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - return parentZoneDelegate.handleError(targetZone, error); - }; - WtfZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { - var key = task.type + ':' + task.source; - var instance = WtfZoneSpec.scheduleInstance[key]; - if (!instance) { - instance = WtfZoneSpec.scheduleInstance[key] = - wtfEvents.createInstance("Zone:schedule:" + key + "(ascii zone, any data)"); - } - var retValue = parentZoneDelegate.scheduleTask(targetZone, task); - instance(zonePathName(targetZone), shallowObj(task.data, 2)); - return retValue; - }; - WtfZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - var source = task.source; - var scope = WtfZoneSpec.invokeTaskScope[source]; - if (!scope) { - scope = WtfZoneSpec.invokeTaskScope[source] = - wtfEvents.createScope("Zone:invokeTask:" + source + "(ascii zone)"); + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global['wtf-rollup'] = factory()); +}(this, function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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 + */ + /** + * @fileoverview + * @suppress {missingRequire} + */ + (function (global) { + // Detect and setup WTF. + var wtfTrace = null; + var wtfEvents = null; + var wtfEnabled = (function () { + var wtf = global['wtf']; + if (wtf) { + wtfTrace = wtf.trace; + if (wtfTrace) { + wtfEvents = wtfTrace.events; + return true; + } } - return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); - }; - WtfZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { - var key = task.source; - var instance = WtfZoneSpec.cancelInstance[key]; - if (!instance) { - instance = WtfZoneSpec.cancelInstance[key] = - wtfEvents.createInstance("Zone:cancel:" + key + "(ascii zone, any options)"); + return false; + })(); + var WtfZoneSpec = /** @class */ (function () { + function WtfZoneSpec() { + this.name = 'WTF'; } - var retValue = parentZoneDelegate.cancelTask(targetZone, task); - instance(zonePathName(targetZone), shallowObj(task.data, 2)); - return retValue; - }; + WtfZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { + var retValue = parentZoneDelegate.fork(targetZone, zoneSpec); + WtfZoneSpec.forkInstance(zonePathName(targetZone), retValue.name); + return retValue; + }; + WtfZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + var src = source || 'unknown'; + var scope = WtfZoneSpec.invokeScope[src]; + if (!scope) { + scope = WtfZoneSpec.invokeScope[src] = + wtfEvents.createScope("Zone:invoke:" + source + "(ascii zone)"); + } + return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source)); + }; + WtfZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + return parentZoneDelegate.handleError(targetZone, error); + }; + WtfZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + var key = task.type + ':' + task.source; + var instance = WtfZoneSpec.scheduleInstance[key]; + if (!instance) { + instance = WtfZoneSpec.scheduleInstance[key] = + wtfEvents.createInstance("Zone:schedule:" + key + "(ascii zone, any data)"); + } + var retValue = parentZoneDelegate.scheduleTask(targetZone, task); + instance(zonePathName(targetZone), shallowObj(task.data, 2)); + return retValue; + }; + WtfZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + var source = task.source; + var scope = WtfZoneSpec.invokeTaskScope[source]; + if (!scope) { + scope = WtfZoneSpec.invokeTaskScope[source] = + wtfEvents.createScope("Zone:invokeTask:" + source + "(ascii zone)"); + } + return wtfTrace.leaveScope(scope(zonePathName(targetZone)), parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs)); + }; + WtfZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + var key = task.source; + var instance = WtfZoneSpec.cancelInstance[key]; + if (!instance) { + instance = WtfZoneSpec.cancelInstance[key] = + wtfEvents.createInstance("Zone:cancel:" + key + "(ascii zone, any options)"); + } + var retValue = parentZoneDelegate.cancelTask(targetZone, task); + instance(zonePathName(targetZone), shallowObj(task.data, 2)); + return retValue; + }; + return WtfZoneSpec; + }()); WtfZoneSpec.forkInstance = wtfEnabled ? wtfEvents.createInstance('Zone:fork(ascii zone, ascii newZone)') : null; WtfZoneSpec.scheduleInstance = {}; WtfZoneSpec.cancelInstance = {}; WtfZoneSpec.invokeScope = {}; WtfZoneSpec.invokeTaskScope = {}; - return WtfZoneSpec; - }()); - function shallowObj(obj, depth) { - if (!obj || !depth) - return null; - var out = {}; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - var value = obj[key]; - switch (typeof value) { - case 'object': - var name_1 = value && value.constructor && value.constructor.name; - value = name_1 == Object.name ? shallowObj(value, depth - 1) : name_1; - break; - case 'function': - value = value.name || undefined; - break; + function shallowObj(obj, depth) { + if (!obj || !depth) + return null; + var out = {}; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + var value = obj[key]; + switch (typeof value) { + case 'object': + var name_1 = value && value.constructor && value.constructor.name; + value = name_1 == Object.name ? shallowObj(value, depth - 1) : name_1; + break; + case 'function': + value = value.name || undefined; + break; + } + out[key] = value; } - out[key] = value; } + return out; } - return out; - } - function zonePathName(zone) { - var name = zone.name; - var localZone = zone.parent; - while (localZone != null) { - name = localZone.name + '::' + name; - localZone = localZone.parent; + function zonePathName(zone) { + var name = zone.name; + var localZone = zone.parent; + while (localZone != null) { + name = localZone.name + '::' + name; + localZone = localZone.parent; + } + return name; } - return name; - } - Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); -})(typeof window === 'object' && window || typeof self === 'object' && self || global); - -}))); + Zone['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); + })(commonjsGlobal); + var wtf = {}; + return wtf; +})); +//# sourceMappingURL=wtf-rollup.umd.js.map diff --git a/dist/wtf.min.js b/dist/wtf.min.js old mode 100644 new mode 100755 index b5e62239f..fae471183 --- a/dist/wtf.min.js +++ b/dist/wtf.min.js @@ -1 +1,23 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";!function(e){var n,o=null,t=null,c=!(!(n=e.wtf)||!(o=n.trace)||(t=o.events,0)),a=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,o,t,c){var a=n.fork(t,c);return e.forkInstance(i(t),a.name),a},e.prototype.onInvoke=function(n,c,a,r,s,u,f){var p=f||"unknown",l=e.invokeScope[p];return l||(l=e.invokeScope[p]=t.createScope("Zone:invoke:"+f+"(ascii zone)")),o.leaveScope(l(i(a)),n.invoke(a,r,s,u,f))},e.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},e.prototype.onScheduleTask=function(n,o,c,a){var s=a.type+":"+a.source,u=e.scheduleInstance[s];u||(u=e.scheduleInstance[s]=t.createInstance("Zone:schedule:"+s+"(ascii zone, any data)"));var f=n.scheduleTask(c,a);return u(i(c),r(a.data,2)),f},e.prototype.onInvokeTask=function(n,c,a,r,s,u){var f=r.source,p=e.invokeTaskScope[f];return p||(p=e.invokeTaskScope[f]=t.createScope("Zone:invokeTask:"+f+"(ascii zone)")),o.leaveScope(p(i(a)),n.invokeTask(a,r,s,u))},e.prototype.onCancelTask=function(n,o,c,a){var s=a.source,u=e.cancelInstance[s];u||(u=e.cancelInstance[s]=t.createInstance("Zone:cancel:"+s+"(ascii zone, any options)"));var f=n.cancelTask(c,a);return u(i(c),r(a.data,2)),f},e.forkInstance=c?t.createInstance("Zone:fork(ascii zone, ascii newZone)"):null,e.scheduleInstance={},e.cancelInstance={},e.invokeScope={},e.invokeTaskScope={},e}();function r(e,n){if(!e||!n)return null;var o={};for(var t in e)if(e.hasOwnProperty(t)){var c=e[t];switch(typeof c){case"object":var a=c&&c.constructor&&c.constructor.name;c=a==Object.name?r(c,n-1):a;break;case"function":c=c.name||void 0}o[t]=c}return o}function i(e){for(var n=e.name,o=e.parent;null!=o;)n=o.name+"::"+n,o=o.parent;return n}Zone.wtfZoneSpec=c?new a:null}("object"==typeof window&&window||"object"==typeof self&&self||global)}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self)["wtf-rollup"]=n()}(this,function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; +/** + * @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 + */ +/** + * @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 + */ +return function(n){var o,t=null,a=null,c=!(!(o=e.wtf)||!(t=o.trace)||(a=t.events,0)),r=function(){function e(){this.name="WTF"}return e.prototype.onFork=function(n,o,t,a){var c=n.fork(t,a);return e.forkInstance(s(t),c.name),c},e.prototype.onInvoke=function(n,o,c,r,i,u,f){var l=f||"unknown",p=e.invokeScope[l];return p||(p=e.invokeScope[l]=a.createScope("Zone:invoke:"+f+"(ascii zone)")),t.leaveScope(p(s(c)),n.invoke(c,r,i,u,f))},e.prototype.onHandleError=function(e,n,o,t){return e.handleError(o,t)},e.prototype.onScheduleTask=function(n,o,t,c){var r=c.type+":"+c.source,u=e.scheduleInstance[r];u||(u=e.scheduleInstance[r]=a.createInstance("Zone:schedule:"+r+"(ascii zone, any data)"));var f=n.scheduleTask(t,c);return u(s(t),i(c.data,2)),f},e.prototype.onInvokeTask=function(n,o,c,r,i,u){var f=r.source,l=e.invokeTaskScope[f];return l||(l=e.invokeTaskScope[f]=a.createScope("Zone:invokeTask:"+f+"(ascii zone)")),t.leaveScope(l(s(c)),n.invokeTask(c,r,i,u))},e.prototype.onCancelTask=function(n,o,t,c){var r=c.source,u=e.cancelInstance[r];u||(u=e.cancelInstance[r]=a.createInstance("Zone:cancel:"+r+"(ascii zone, any options)"));var f=n.cancelTask(t,c);return u(s(t),i(c.data,2)),f},e}();function i(e,n){if(!e||!n)return null;var o={};for(var t in e)if(e.hasOwnProperty(t)){var a=e[t];switch(typeof a){case"object":var c=a&&a.constructor&&a.constructor.name;a=c==Object.name?i(a,n-1):c;break;case"function":a=a.name||void 0}o[t]=a}return o}function s(e){for(var n=e.name,o=e.parent;null!=o;)n=o.name+"::"+n,o=o.parent;return n}r.forkInstance=c?a.createInstance("Zone:fork(ascii zone, ascii newZone)"):null,r.scheduleInstance={},r.cancelInstance={},r.invokeScope={},r.invokeTaskScope={},Zone.wtfZoneSpec=c?new r:null}(),{}}); \ No newline at end of file diff --git a/dist/zone-bluebird.js b/dist/zone-bluebird.js old mode 100644 new mode 100755 index d73dac94a..47942e0f3 --- a/dist/zone-bluebird.js +++ b/dist/zone-bluebird.js @@ -5,70 +5,69 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('bluebird', function (global, Zone, api) { - // TODO: @JiaLiPassion, we can automatically patch bluebird - // if global.Promise = Bluebird, but sometimes in nodejs, - // global.Promise is not Bluebird, and Bluebird is just be - // used by other libraries such as sequelize, so I think it is - // safe to just expose a method to patch Bluebird explicitly - var BLUEBIRD = 'bluebird'; - Zone[Zone.__symbol__(BLUEBIRD)] = function patchBluebird(Bluebird) { - // patch method of Bluebird.prototype which not using `then` internally - var bluebirdApis = ['then', 'spread', 'finally']; - bluebirdApis.forEach(function (bapi) { - api.patchMethod(Bluebird.prototype, bapi, function (delegate) { return function (self, args) { - var zone = Zone.current; - var _loop_1 = function (i) { - var func = args[i]; - if (typeof func === 'function') { - args[i] = function () { - var argSelf = this; - var argArgs = arguments; - return new Bluebird(function (res, rej) { - zone.scheduleMicroTask('Promise.then', function () { - try { - res(func.apply(argSelf, argArgs)); - } - catch (error) { - rej(error); - } +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('bluebird', function (global, Zone, api) { + // TODO: @JiaLiPassion, we can automatically patch bluebird + // if global.Promise = Bluebird, but sometimes in nodejs, + // global.Promise is not Bluebird, and Bluebird is just be + // used by other libraries such as sequelize, so I think it is + // safe to just expose a method to patch Bluebird explicitly + var BLUEBIRD = 'bluebird'; + Zone[Zone.__symbol__(BLUEBIRD)] = function patchBluebird(Bluebird) { + // patch method of Bluebird.prototype which not using `then` internally + var bluebirdApis = ['then', 'spread', 'finally']; + bluebirdApis.forEach(function (bapi) { + api.patchMethod(Bluebird.prototype, bapi, function (delegate) { return function (self, args) { + var zone = Zone.current; + var _loop_1 = function (i) { + var func = args[i]; + if (typeof func === 'function') { + args[i] = function () { + var argSelf = this; + var argArgs = arguments; + return new Bluebird(function (res, rej) { + zone.scheduleMicroTask('Promise.then', function () { + try { + res(func.apply(argSelf, argArgs)); + } + catch (error) { + rej(error); + } + }); }); - }); - }; + }; + } + }; + for (var i = 0; i < args.length; i++) { + _loop_1(i); } - }; - for (var i = 0; i < args.length; i++) { - _loop_1(i); + return delegate.apply(self, args); + }; }); + }); + Bluebird.onPossiblyUnhandledRejection(function (e, promise) { + try { + Zone.current.runGuarded(function () { + throw e; + }); + } + catch (err) { + api.onUnhandledError(err); } - return delegate.apply(self, args); - }; }); - }); - Bluebird.onPossiblyUnhandledRejection(function (e, promise) { - try { - Zone.current.runGuarded(function () { - throw e; - }); - } - catch (err) { - api.onUnhandledError(err); - } - }); - // override global promise - global[api.symbol('ZoneAwarePromise')] = Bluebird; - }; -}); - -}))); + }); + // override global promise + global[api.symbol('ZoneAwarePromise')] = Bluebird; + }; + }); +})); +//# sourceMappingURL=zone-bluebird-rollup.umd.js.map diff --git a/dist/zone-bluebird.min.js b/dist/zone-bluebird.min.js old mode 100644 new mode 100755 index 9c05f0c1e..152035983 --- a/dist/zone-bluebird.min.js +++ b/dist/zone-bluebird.min.js @@ -1 +1,15 @@ -!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("bluebird",function(n,t,e){t[t.__symbol__("bluebird")]=function(o){["then","spread","finally"].forEach(function(n){e.patchMethod(o.prototype,n,function(n){return function(e,r){for(var c=t.current,i=function(n){var t=r[n];"function"==typeof t&&(r[n]=function(){var n=this,e=arguments;return new o(function(o,r){c.scheduleMicroTask("Promise.then",function(){try{o(t.apply(n,e))}catch(n){r(n)}})})})},u=0;u'; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); - } - Zone.assertZonePatched = function () { - if (global['Promise'] !== patches['ZoneAwarePromise']) { - throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + - 'has been overwritten.\n' + - 'Most likely cause is that a Promise polyfill has been loaded ' + - 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + - 'If you must load one, do so before loading zone.js.)'); - } - }; - Object.defineProperty(Zone, "root", { - get: function () { - var zone = Zone.current; - while (zone.parent) { - zone = zone.parent; - } - return zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "current", { - get: function () { - return _currentZoneFrame.zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "currentTask", { - get: function () { - return _currentTask; - }, - enumerable: true, - configurable: true - }); - Zone.__load_patch = function (name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); - } - } - else if (!global['__Zone_disable_' + name]) { - var perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - }; - Object.defineProperty(Zone.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Zone.prototype.get = function (key) { - var zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - }; - Zone.prototype.getZoneWith = function (key) { - var current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; - } - current = current._parent; - } - return null; - }; - Zone.prototype.fork = function (zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - }; - Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - var _callback = this._zoneDelegate.intercept(this, callback, source); - var zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); - }; - }; - Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = null; } - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; - } - } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runTask = function (task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - var reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - var previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; - } - try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); - } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; - } - } - } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); - } - else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); - } - } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - }; - Zone.prototype.scheduleTask = function (task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - var newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); - } - newZone = newZone.parent; - } - } - task._transitionTo(scheduling, notScheduled); - var zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - }; - Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - }; - Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.cancelTask = function (task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - }; - Zone.prototype._updateTaskCount = function (task, count) { - var zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (var i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); - } - }; - Zone.__symbol__ = __symbol__; - return Zone; - }()); - var DELEGATE_ZS = { - name: '', - onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, - onScheduleTask: function (delegate, _, target, task) { - return delegate.scheduleTask(target, task); - }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { - return delegate.invokeTask(target, task, applyThis, applyArgs); - }, - onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } - }; - var ZoneDelegate = /** @class */ (function () { - function ZoneDelegate(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; - } - } - } - ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - }; - ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; - }; - ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.handleError = function (targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - }; - ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { - var returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); - } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; - } - else { - if (task.scheduleFn) { - task.scheduleFn(task); - } - else if (task.type == microTask) { - scheduleMicroTask(task); - } - else { - throw new Error('Task is missing scheduleFn.'); - } - } - return returnTask; - }; - ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.cancelTask = function (targetZone, task) { - var value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); - } - value = task.cancelFn(task); - } - return value; - }; - ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback - try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); - } - catch (err) { - this.handleError(targetZone, err); - } - }; - ZoneDelegate.prototype._updateTaskCount = function (type, count) { - var counts = this._taskCounts; - var prev = counts[type]; - var next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - var isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type - }; - this.hasTask(this.zone, isEmpty); - } - }; - return ZoneDelegate; - }()); - var ZoneTask = /** @class */ (function () { - function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - var self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; - } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); - }; - } - } - ZoneTask.invokeTask = function (task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); - } - _numberOfNestedTaskFrames--; - } - }; - Object.defineProperty(ZoneTask.prototype, "zone", { - get: function () { - return this._zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ZoneTask.prototype, "state", { - get: function () { - return this._state; - }, - enumerable: true, - configurable: true - }); - ZoneTask.prototype.cancelScheduleRequest = function () { - this._transitionTo(notScheduled, scheduling); - }; - ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; - } - } - else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); - } - }; - ZoneTask.prototype.toString = function () { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); - } - }; - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - ZoneTask.prototype.toJSON = function () { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount - }; - }; - return ZoneTask; - }()); - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var symbolSetTimeout = __symbol__('setTimeout'); - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var _microTaskQueue = []; - var _isDrainingMicrotaskQueue = false; - var nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); - } - } - if (nativeMicroTaskQueuePromise) { - var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); - } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - var queue = _microTaskQueue; - _microTaskQueue = []; - for (var i = 0; i < queue.length; i++) { - var task = queue[i]; - try { - task.zone.runTask(task, null, null); - } - catch (error) { - _api.onUnhandledError(error); - } - } - } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var NO_ZONE = { name: 'NO ZONE' }; - var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - var patches = {}; - var _api = { - symbol: __symbol__, - currentZoneFrame: function () { return _currentZoneFrame; }, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, - patchEventTarget: function () { return []; }, - patchOnProperties: noop, - patchMethod: function () { return noop; }, - bindArguments: function () { return []; }, - patchThen: function () { return noop; }, - patchMacroTask: function () { return noop; }, - setNativePromise: function (NativePromise) { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: function () { return noop; }, - isIEOrEdge: function () { return false; }, - getGlobalObjects: function () { return undefined; }, - ObjectDefineProperty: function () { return noop; }, - ObjectGetOwnPropertyDescriptor: function () { return undefined; }, - ObjectCreate: function () { return undefined; }, - ArraySlice: function () { return []; }, - patchClass: function () { return noop; }, - wrapWithCurrentZone: function () { return noop; }, - filterProperties: function () { return []; }, - attachOriginToPatched: function () { return noop; }, - _redefineProperty: function () { return noop; }, - patchCallbacks: function () { return noop; } - }; - var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - var _currentTask = null; - var _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { - var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - var className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); - } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - var __symbol__ = api.symbol; - var _uncaughtPromiseErrors = []; - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var creationTrace = '__creationTrace__'; - api.onUnhandledError = function (e) { - if (api.showUncaughtError()) { - var rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); - } - else { - console.error(e); - } - } - }; - api.microtaskDrainDone = function () { - while (_uncaughtPromiseErrors.length) { - var _loop_1 = function () { - var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); - try { - uncaughtPromiseError.zone.runGuarded(function () { - throw uncaughtPromiseError; - }); - } - catch (error) { - handleUnhandledRejection(error); - } - }; - while (_uncaughtPromiseErrors.length) { - _loop_1(); - } - } - }; - var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); - } - } - catch (err) { - } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - var symbolState = __symbol__('state'); - var symbolValue = __symbol__('value'); - var symbolFinally = __symbol__('finally'); - var symbolParentPromiseValue = __symbol__('parentPromiseValue'); - var symbolParentPromiseState = __symbol__('parentPromiseState'); - var source = 'Promise.then'; - var UNRESOLVED = null; - var RESOLVED = true; - var REJECTED = false; - var REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return function (v) { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); - } - // Do not return value or you will break the Promise spec. - }; - } - var once = function () { - var wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; - } - wasCalled = true; - wrappedFunction.apply(null, arguments); - }; - }; - }; - var TYPE_ERROR = 'Promise resolved with itself'; - var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - var onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); - } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - var then = null; - try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; - } - } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); - return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); - } - else if (state !== REJECTED && typeof then === 'function') { - try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); - } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); - } - } - else { - promise[symbolState] = state; - var queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; - } - } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - var trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); - } - } - for (var i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); - } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; - try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); - } - catch (err) { - var error_1 = err; - error_1.rejection = value; - error_1.promise = promise; - error_1.zone = Zone.current; - error_1.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error_1); - api.scheduleMicroTask(); // to make sure that it is running - } - } - } - } - // Resolving an already resolved promise is a noop. - return promise; - } - var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); - } - } - catch (err) { - } - promise[symbolState] = REJECTED; - for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); - } - } - } - } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - var promiseState = promise[symbolState]; - var delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, function () { - try { - var parentPromiseValue = promise[symbolValue]; - var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); - } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); - } - }, chainPromise); - } - var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = /** @class */ (function () { - function ZoneAwarePromise(executor) { - var promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); - } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); - } - catch (error) { - resolvePromise(promise, false, error); - } - } - ZoneAwarePromise.toString = function () { - return ZONE_AWARE_PROMISE_TO_STRING; - }; - ZoneAwarePromise.resolve = function (value) { - return resolvePromise(new this(null), RESOLVED, value); - }; - ZoneAwarePromise.reject = function (error) { - return resolvePromise(new this(null), REJECTED, error); - }; - ZoneAwarePromise.race = function (values) { - var e_1, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); - } - function onReject(error) { - reject(error); - } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); - } - finally { if (e_1) throw e_1.error; } - } - return promise; - }; - ZoneAwarePromise.all = function (values) { - var e_2, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - var unresolvedCount = 2; - var valueIndex = 0; - var resolvedValues = []; - var _loop_2 = function (value) { - if (!isThenable(value)) { - value = this_1.resolve(value); - } - var curValueIndex = valueIndex; - value.then(function (value) { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; - }; - var this_1 = this; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - _loop_2(value); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } - } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - return promise; - }; - Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { - get: function () { - return 'Promise'; - }, - enumerable: true, - configurable: true - }); - ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { - var chainPromise = new this.constructor(null); - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); - } - return chainPromise; - }; - ZoneAwarePromise.prototype.catch = function (onRejected) { - return this.then(null, onRejected); - }; - ZoneAwarePromise.prototype.finally = function (onFinally) { - var chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); - } - return chainPromise; - }; - return ZoneAwarePromise; - }()); - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - var NativePromise = global[symbolPromise] = global['Promise']; - var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; - } - desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; - } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); - } - }; - ObjectDefineProperty(global, 'Promise', desc); - } - global['Promise'] = ZoneAwarePromise; - var symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - var proto = Ctor.prototype; - var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case - return; - } - var originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - var _this = this; - var wrapped = new ZoneAwarePromise(function (resolve, reject) { - originalThen.call(_this, resolve, reject); - }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; - } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } - if (NativePromise) { - patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global[api.symbol('fetch')] = fetch_1; - global['fetch'] = zoneify(fetch_1); - } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); + /** + * @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 Zone$1 = (function (global) { + const performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + const symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } + } + class Zone { + constructor(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); + } + static assertZonePatched() { + if (global['Promise'] !== patches['ZoneAwarePromise']) { + throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + + 'has been overwritten.\n' + + 'Most likely cause is that a Promise polyfill has been loaded ' + + 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + + 'If you must load one, do so before loading zone.js.)'); + } + } + static get root() { + let zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + } + static get current() { + return _currentZoneFrame.zone; + } + static get currentTask() { + return _currentTask; + } + static __load_patch(name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } + } + else if (!global['__Zone_disable_' + name]) { + const perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); + } + } + get parent() { + return this._parent; + } + get name() { + return this._name; + } + get(key) { + const zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + } + getZoneWith(key) { + let current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + } + fork(zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + } + wrap(callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + const _callback = this._zoneDelegate.intercept(this, callback, source); + const zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + } + run(callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + } + runGuarded(callback, applyThis = null, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + } + runTask(task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; + } + const reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + const previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + } + scheduleTask(task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + let newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${task.zone.name}`); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + const zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + } + scheduleMicroTask(source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + } + scheduleMacroTask(source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + } + scheduleEventTask(source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + } + cancelTask(task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + } + _updateTaskCount(task, count) { + const zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (let i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + } + } + Zone.__symbol__ = __symbol__; + const DELEGATE_ZS = { + name: '', + onHasTask: (delegate, _, target, hasTaskState) => delegate.hasTask(target, hasTaskState), + onScheduleTask: (delegate, _, target, task) => delegate.scheduleTask(target, task), + onInvokeTask: (delegate, _, target, task, applyThis, applyArgs) => delegate.invokeTask(target, task, applyThis, applyArgs), + onCancelTask: (delegate, _, target, task) => delegate.cancelTask(target, task) + }; + class ZoneDelegate { + constructor(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + const zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + const parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; + } + } + } + fork(targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + } + intercept(targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + } + invoke(targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + } + handleError(targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + } + scheduleTask(targetZone, task) { + let returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); + } + else { + throw new Error('Task is missing scheduleFn.'); + } + } + return returnTask; + } + invokeTask(targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + } + cancelTask(targetZone, task) { + let value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + } + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); + } + return value; + } + hasTask(targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + } + _updateTaskCount(type, count) { + const counts = this._taskCounts; + const prev = counts[type]; + const next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + const isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + } + } + class ZoneTask { + constructor(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + const self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; + } + } + static invokeTask(task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + } + get zone() { + return this._zone; + } + get state() { + return this._state; + } + cancelScheduleRequest() { + this._transitionTo(notScheduled, scheduling); + } + _transitionTo(toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(`${this.type} '${this.source}': can not transition to '${toState}', expecting state '${fromState1}'${fromState2 ? ' or \'' + fromState2 + '\'' : ''}, was '${this._state}'.`); + } + } + toString() { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + } + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + toJSON() { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + const symbolSetTimeout = __symbol__('setTimeout'); + const symbolPromise = __symbol__('Promise'); + const symbolThen = __symbol__('then'); + let _microTaskQueue = []; + let _isDrainingMicrotaskQueue = false; + let nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + let nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } + } + task && _microTaskQueue.push(task); + } + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + const queue = _microTaskQueue; + _microTaskQueue = []; + for (let i = 0; i < queue.length; i++) { + const task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + const NO_ZONE = { name: 'NO ZONE' }; + const notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + const microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + const patches = {}; + const _api = { + symbol: __symbol__, + currentZoneFrame: () => _currentZoneFrame, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: () => !Zone[__symbol__('ignoreConsoleErrorUncaughtError')], + patchEventTarget: () => [], + patchOnProperties: noop, + patchMethod: () => noop, + bindArguments: () => [], + patchThen: () => noop, + patchMacroTask: () => noop, + setNativePromise: (NativePromise) => { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); + } + }, + patchEventPrototype: () => noop, + isIEOrEdge: () => false, + getGlobalObjects: () => undefined, + ObjectDefineProperty: () => noop, + ObjectGetOwnPropertyDescriptor: () => undefined, + ObjectCreate: () => undefined, + ArraySlice: () => [], + patchClass: () => noop, + wrapWithCurrentZone: () => noop, + filterProperties: () => [], + attachOriginToPatched: () => noop, + _redefineProperty: () => noop, + patchCallbacks: () => noop + }; + let _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + let _currentTask = null; + let _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -var ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -var ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ -var ObjectCreate = Object.create; -/** Array.prototype.slice */ -var ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -var ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -var TRUE_STR = 'true'; -/** false string const */ -var FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -var zoneSymbol = Zone.__symbol__; -var isWindowExists = typeof window !== 'undefined'; -var internalWindow = isWindowExists ? window : undefined; -var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -var REMOVE_ATTRIBUTE = 'removeAttribute'; -var NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); - } - } - return args; -} -function patchPrototype(prototype, fnNames) { - var source = prototype.constructor['name']; - var _loop_1 = function (i) { - var name_1 = fnNames[i]; - var delegate = prototype[name_1]; - if (delegate) { - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); - if (!isPropertyWritable(prototypeDesc)) { - return "continue"; - } - prototype[name_1] = (function (delegate) { - var patched = function () { - return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); - }; - attachOriginToPatched(patched, delegate); - return patched; - })(delegate); - } - }; - for (var i = 0; i < fnNames.length; i++) { - _loop_1(i); - } -} -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -var zoneSymbolEventNames = {}; -var wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - var eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); - } - var target = this || event.target || _global; - var listener = target[eventNameSymbol]; - var result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - var errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); - } - } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); - } - } - return result; -}; -function patchProperty(obj, prop, prototype) { - var desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; - } - } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - var originalDescGet = desc.get; - var originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return; - } - var previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); - } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); - } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); - } - else { - target[eventNameSymbol] = null; - } - }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return null; - } - var listener = target[eventNameSymbol]; - if (listener) { - return listener; - } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); - } - return value; - } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (var i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } - } - else { - var onProperties = []; - for (var prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); - } - } - for (var j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); - } - } -} -var originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` -function patchClass(className) { - var OriginalClass = _global[className]; - if (!OriginalClass) - return; - // keep original class in global - _global[zoneSymbol(className)] = OriginalClass; - _global[className] = function () { - var a = bindArguments(arguments, className); - switch (a.length) { - case 0: - this[originalInstanceKey] = new OriginalClass(); - break; - case 1: - this[originalInstanceKey] = new OriginalClass(a[0]); - break; - case 2: - this[originalInstanceKey] = new OriginalClass(a[0], a[1]); - break; - case 3: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); - break; - case 4: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); - break; - default: - throw new Error('Arg list too long.'); - } - }; - // attach original delegate to patched function - attachOriginToPatched(_global[className], OriginalClass); - var instance = new OriginalClass(function () { }); - var prop; - for (prop in instance) { - // https://bugs.webkit.org/show_bug.cgi?id=44721 - if (className === 'XMLHttpRequest' && prop === 'responseBlob') - continue; - (function (prop) { - if (typeof instance[prop] === 'function') { - _global[className].prototype[prop] = function () { - return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); - }; - } - else { - ObjectDefineProperty(_global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); - // keep callback in wrapped function so we can - // use it in Function.prototype.toString to return - // the native one. - attachOriginToPatched(this[originalInstanceKey][prop], fn); - } - else { - this[originalInstanceKey][prop] = fn; - } - }, - get: function () { - return this[originalInstanceKey][prop]; - } - }); - } - }(prop)); - } - for (prop in OriginalClass) { - if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { - _global[className][prop] = OriginalClass[prop]; - } - } -} -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; - } - var symbols = Object.getOwnPropertySymbols(src); - symbols.forEach(function (symbol) { - var desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; - } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -var shouldCopySymbolProperties = false; + /** + * @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.__load_patch('ZoneAwarePromise', (global, Zone, api) => { + const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + const ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + const className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + const __symbol__ = api.symbol; + const _uncaughtPromiseErrors = []; + const symbolPromise = __symbol__('Promise'); + const symbolThen = __symbol__('then'); + const creationTrace = '__creationTrace__'; + api.onUnhandledError = (e) => { + if (api.showUncaughtError()) { + const rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); + } + } + }; + api.microtaskDrainDone = () => { + while (_uncaughtPromiseErrors.length) { + while (_uncaughtPromiseErrors.length) { + const uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(() => { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + } + } + }; + const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); + try { + const handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } + } + catch (err) { + } + } + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + const symbolState = __symbol__('state'); + const symbolValue = __symbol__('value'); + const symbolFinally = __symbol__('finally'); + const symbolParentPromiseValue = __symbol__('parentPromiseValue'); + const symbolParentPromiseState = __symbol__('parentPromiseState'); + const source = 'Promise.then'; + const UNRESOLVED = null; + const RESOLVED = true; + const REJECTED = false; + const REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return (v) => { + try { + resolvePromise(promise, state, v); + } + catch (err) { + resolvePromise(promise, false, err); + } + // Do not return value or you will break the Promise spec. + }; + } + const once = function () { + let wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; + }; + }; + const TYPE_ERROR = 'Promise resolved with itself'; + const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + const onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + let then = null; + try { + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } + } + catch (err) { + onceWrapper(() => { + resolvePromise(promise, false, err); + })(); + return promise; + } + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { + try { + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + } + catch (err) { + onceWrapper(() => { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + const queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + const trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (let i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + const error = err; + error.rejection = value; + error.promise = promise; + error.zone = Zone.current; + error.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error); + api.scheduleMicroTask(); // to make sure that it is running + } + } + } + } + // Resolving an already resolved promise is a noop. + return promise; + } + const REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + const handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } + } + catch (err) { + } + promise[symbolState] = REJECTED; + for (let i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } + } + } + } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + const promiseState = promise[symbolState]; + const delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, () => { + try { + const parentPromiseValue = promise[symbolValue]; + const isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); + } + const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + class ZoneAwarePromise { + constructor(executor) { + const promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } + } + static toString() { + return ZONE_AWARE_PROMISE_TO_STRING; + } + static resolve(value) { + return resolvePromise(new this(null), RESOLVED, value); + } + static reject(error) { + return resolvePromise(new this(null), REJECTED, error); + } + static race(values) { + let resolve; + let reject; + let promise = new this((res, rej) => { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (let value of values) { + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + return promise; + } + static all(values) { + let resolve; + let reject; + let promise = new this((res, rej) => { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + let unresolvedCount = 2; + let valueIndex = 0; + const resolvedValues = []; + for (let value of values) { + if (!isThenable(value)) { + value = this.resolve(value); + } + const curValueIndex = valueIndex; + value.then((value) => { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + } + get [Symbol.toStringTag]() { + return 'Promise'; + } + then(onFulfilled, onRejected) { + const chainPromise = new this.constructor(null); + const zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; + } + catch(onRejected) { + return this.then(null, onRejected); + } + finally(onFinally) { + const chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + const zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + } + } + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + const NativePromise = global[symbolPromise] = global['Promise']; + const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + const symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + const proto = Ctor.prototype; + const prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } + const originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + const wrapped = new ZoneAwarePromise((resolve, reject) => { + originalThen.call(this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; + } + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + let resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + let ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + const fetch = global['fetch']; + if (typeof fetch == 'function') { + global[api.symbol('fetch')] = fetch; + global['fetch'] = zoneify(fetch); + } + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); -function patchMethod(target, name, patchFn) { - var proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; - } - var delegateName = zoneSymbol(name); - var delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - var patchDelegate_1 = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate_1(this, arguments); - }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); - } - } - } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; - } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); - } - else { - // cause an error by calling it directly. - return delegate.apply(self, 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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + const ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + const ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Object.create */ + const ObjectCreate = Object.create; + /** Array.prototype.slice */ + const ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + const ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + const REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + const ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + const TRUE_STR = 'true'; + /** false string const */ + const FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + const ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); + } + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); + } + const zoneSymbol = Zone.__symbol__; + const isWindowExists = typeof window !== 'undefined'; + const internalWindow = isWindowExists ? window : undefined; + const _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + const REMOVE_ATTRIBUTE = 'removeAttribute'; + const NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (let i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; + } + function patchPrototype(prototype, fnNames) { + const source = prototype.constructor['name']; + for (let i = 0; i < fnNames.length; i++) { + const name = fnNames[i]; + const delegate = prototype[name]; + if (delegate) { + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name); + if (!isPropertyWritable(prototypeDesc)) { + continue; + } + prototype[name] = ((delegate) => { + const patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); + } + } + } + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; + } + if (propertyDesc.writable === false) { + return false; + } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); + } + const isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + const isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + const isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + const isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + const zoneSymbolEventNames = {}; + const wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + let eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + } + const target = this || event.target || _global; + const listener = target[eventNameSymbol]; + let result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + const errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } + } + return result; + }; + function patchProperty(obj, prop, prototype) { + let desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; + } + const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + const originalDescGet = desc.get; + const originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + const eventName = prop.substr(2); + let eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + let target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; + } + let previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); + } + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); + } + else { + target[eventNameSymbol] = null; + } + }; + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + let target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + const listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + let value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; + } + } + return null; + }; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; + } + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (let i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } + } + else { + const onProperties = []; + for (const prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); + } + } + for (let j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); + } + } + } + const originalInstanceKey = zoneSymbol('originalInstance'); + // wrap some native API on `window` + function patchClass(className) { + const OriginalClass = _global[className]; + if (!OriginalClass) + return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + const a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); + } + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + const instance = new OriginalClass(function () { }); + let prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; + } + }); + } + }(prop)); + } + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; + } + } + } + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + const symbols = Object.getOwnPropertySymbols(src); + symbols.forEach((symbol) => { + const desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); + } + let shouldCopySymbolProperties = false; + function patchMethod(target, name, patchFn) { + let proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + const delegateName = zoneSymbol(name); + let delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + const patchDelegate = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } + } + } + return delegate; + } + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + let setNative = null; + function scheduleTask(task) { + const data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; + } + setNative = patchMethod(obj, funcName, (delegate) => function (self, args) { + const meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }); + } + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; + } + let isDetectedIEOrEdge = false; + let ieOrEdge = false; + function isIE() { + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; + } + function isIEOrEdge() { + if (isDetectedIEOrEdge) { + return ieOrEdge; + } + isDetectedIEOrEdge = true; + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { + ieOrEdge = true; + } + } + catch (error) { + } + return ieOrEdge; + } -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} -var isDetectedIEOrEdge = false; -var ieOrEdge = false; -function isIE() { - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { - return true; - } - } - catch (error) { - } - return false; -} -function isIEOrEdge() { - if (isDetectedIEOrEdge) { - return ieOrEdge; - } - isDetectedIEOrEdge = true; - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { - ieOrEdge = true; - } - } - catch (error) { - } - return ieOrEdge; -} + /** + * @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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', (global) => { + // patch Func.prototype.toString to let them look like native + const originalFunctionToString = Function.prototype.toString; + const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + const PROMISE_SYMBOL = zoneSymbol('Promise'); + const ERROR_SYMBOL = zoneSymbol('Error'); + const newFunctionToString = function toString() { + if (typeof this === 'function') { + const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } + } + if (this === Promise) { + const nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } + } + if (this === Error) { + const nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } + } + } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + const originalObjectToString = Object.prototype.toString; + const PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; + }); -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', function (global) { - // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Function.prototype.toString; - var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - var PROMISE_SYMBOL = zoneSymbol('Promise'); - var ERROR_SYMBOL = zoneSymbol('Error'); - var newFunctionToString = function toString() { - if (typeof this === 'function') { - var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); - } - else { - return Object.prototype.toString.call(originalDelegate); - } - } - if (this === Promise) { - var nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); - } - } - if (this === Error) { - var nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); - } - } - } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - var originalObjectToString = Object.prototype.toString; - var PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; - } - return originalObjectToString.call(this); - }; -}); + /** + * @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 + */ + let passiveSupported = false; + if (typeof window !== 'undefined') { + try { + const options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } + } + // an identifier to tell ZoneTask do not create a new invoke closure + const OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true + }; + const zoneSymbolEventNames$1 = {}; + const globalSources = {}; + const EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + const IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + const LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + const REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + const PREPEND_EVENT_LISTENER = 'prependListener'; + const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + const invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; + } + const delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = (event) => delegate.handleEvent(event); + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + const options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + const delegate = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options); + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + const globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + const target = this || event.target || _global; + const tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + const copyTasks = tasks.slice(); + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + const globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + const target = this || event.target || _global; + const tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + const copyTasks = tasks.slice(); + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + let useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + const validateHandler = patchOptions && patchOptions.vh; + let checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + let returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + let proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + const eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + const taskData = {}; + const nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + const nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + const nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + const nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + let nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + const customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + const customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + const symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + let symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + const existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (let i = 0; i < existingTasks.length; i++) { + const existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } + } + } + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { + return; + } + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + const customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + const customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + const customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + const customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + const compareTaskCallbackVsDelegate = function (task, delegate) { + const typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + const compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + const blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + const makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget = false, prepend = false) { + return function () { + const target = this || _global; + const eventName = arguments[0]; + let delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + let isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { + return nativeListener.apply(this, arguments); + } + isHandleEvent = true; + } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + const options = arguments[2]; + if (blackListedEvents) { + // check black list + for (let i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + let capture; + let once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + const zone = Zone.current; + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + let symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + const falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + const trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + let existingTasks = target[symbolEventName]; + let isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (let i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + let source; + const constructorName = target.constructor['name']; + const targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + const task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + const options = arguments[2]; + let capture; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + } + const delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + let symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + const existingTasks = symbolEventName && target[symbolEventName]; + if (existingTasks) { + for (let i = 0; i < existingTasks.length; i++) { + const existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; + } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; + } + } + } + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + const listeners = []; + const tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (let i = 0; i < tasks.length; i++) { + const task = tasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); + } + return listeners; + }; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + if (!eventName) { + const keys = Object.keys(target); + for (let i = 0; i < keys.length; i++) { + const prop = keys[i]; + const match = EVENT_NAME_SYMBOL_REGX.exec(prop); + let evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); + } + } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); + } + else { + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + const symbolEventName = symbolEventNames[FALSE_STR]; + const symbolCaptureEventName = symbolEventNames[TRUE_STR]; + const tasks = target[symbolEventName]; + const captureTasks = target[symbolCaptureEventName]; + if (tasks) { + const removeTasks = tasks.slice(); + for (let i = 0; i < removeTasks.length; i++) { + const task = removeTasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + if (captureTasks) { + const removeTasks = captureTasks.slice(); + for (let i = 0; i < removeTasks.length; i++) { + const task = removeTasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + } + } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + } + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + } + return true; + } + let results = []; + for (let i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; + } + function findEventTasks(target, eventName) { + const foundTasks = []; + for (let prop in target) { + const match = EVENT_NAME_SYMBOL_REGX.exec(prop); + let evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + const tasks = target[prop]; + if (tasks) { + for (let i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } + } + } + } + return foundTasks; + } + function patchEventPrototype(global, api) { + const Event = global['Event']; + if (Event && Event.prototype) { + api.patchMethod(Event.prototype, 'stopImmediatePropagation', (delegate) => function (self, args) { + self[IMMEDIATE_PROPAGATION_SYMBOL] = true; + // we need to call the native stopImmediatePropagation + // in case in some hybrid application, some part of + // application will be controlled by zone, some are not + delegate && delegate.apply(self, 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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var passiveSupported = false; -if (typeof window !== 'undefined') { - try { - var options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } - }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); - } - catch (err) { - passiveSupported = false; - } -} -// an identifier to tell ZoneTask do not create a new invoke closure -var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -var zoneSymbolEventNames$1 = {}; -var globalSources = {}; -var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - var PREPEND_EVENT_LISTENER = 'prependListener'; - var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { - return; - } - var delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = function (event) { return delegate.handleEvent(event); }; - task.originalDelegate = delegate; - } - // invoke static task.invoke - task.invoke(task, target, [event]); - var options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = false - var globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); - } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } - } - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - var globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); - } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } - } - } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - var useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - var validateHandler = patchOptions && patchOptions.vh; - var checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; - } - var returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; - } - var proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; - } - if (!proto) { - return false; - } - if (proto[zoneSymbolAddEventListener]) { - return false; - } - var eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - var taskData = {}; - var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - var nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } - } - var customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { - return; - } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); - }; - var customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - var symbolEventName = void 0; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } - break; - } - } - } - } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { - return; - } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - var customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - var compareTaskCallbackVsDelegate = function (task, delegate) { - var typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); - }; - var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { - if (returnTarget === void 0) { returnTarget = false; } - if (prepend === void 0) { prepend = false; } - return function () { - var target = this || _global; - var eventName = arguments[0]; - var delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - var isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); - } - isHandleEvent = true; - } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { - return; - } - var options = arguments[2]; - if (blackListedEvents) { - // check black list - for (var i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { - return nativeListener.apply(this, arguments); - } - } - } - var capture; - var once = false; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - once = options ? !!options.once : false; - } - var zone = Zone.current; - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = target[symbolEventName]; - var isExisting = false; - if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (var i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; - } - } - } - } - else { - existingTasks = target[symbolEventName] = []; - } - var source; - var constructorName = target.constructor['name']; - var targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); - } - else { - existingTasks.unshift(task); - } - if (returnTarget) { - return target; - } - }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var options = arguments[2]; - var capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - } - var delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); - } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; - } - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; - } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; - } - return; - } - } - } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var listeners = []; - var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - if (!eventName) { - var keys = Object.keys(target); - for (var i = 0; i < keys.length; i++) { - var prop = keys[i]; - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); - } - } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - var symbolEventName = symbolEventNames[FALSE_STR]; - var symbolCaptureEventName = symbolEventNames[TRUE_STR]; - var tasks = target[symbolEventName]; - var captureTasks = target[symbolCaptureEventName]; - if (tasks) { - var removeTasks = tasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); - } - } - if (captureTasks) { - var removeTasks = captureTasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); - } - } - } - } - if (returnTarget) { - return this; - } - }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); - } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); - } - return true; - } - var results = []; - for (var i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); - } - return results; -} -function findEventTasks(target, eventName) { - var foundTasks = []; - for (var prop in target) { - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - var tasks = target[prop]; - if (tasks) { - for (var i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); - } - } - } - } - return foundTasks; -} -function patchEventPrototype(global, api) { - var Event = global['Event']; - if (Event && Event.prototype) { - api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) { return function (self, args) { - self[IMMEDIATE_PROPAGATION_SYMBOL] = true; - // we need to call the native stopImmediatePropagation - // in case in some hybrid application, some part of - // application will be controlled by zone, some are not - delegate && delegate.apply(self, 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 + */ + function patchCallbacks(api, target, targetName, method, callbacks) { + const symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + const nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + const source = `${targetName}.${method}::` + callback; + const prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); + } -/** - * @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 patchCallbacks(api, target, targetName, method, callbacks) { - var symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; - } - var nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - var source = targetName + "." + method + "::" + callback; - var prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); - api._redefineProperty(opts.prototype, callback, descriptor); - } - else if (prototype[callback]) { - prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); - } - } - else if (prototype[callback]) { - prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); - } - }); - } - return nativeDelegate.call(target, name, opts, options); - }; - api.attachOriginToPatched(target[method], nativeDelegate); -} + /** + * @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 + */ + /* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ + const zoneSymbol$1 = Zone.__symbol__; + const _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; + const _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; + const _create = Object.create; + const unconfigurablesKey = zoneSymbol$1('unconfigurables'); + function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + const originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); + } + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + const desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; + } + return desc; + }; + } + function _redefineProperty(obj, prop, desc) { + const originalConfigurableFlag = desc.configurable; + desc = rewriteDescriptor(obj, prop, desc); + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + } + function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; + } + function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; + } + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; + } + } + return desc; + } + function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; + } + else { + desc.configurable = originalConfigurableFlag; + } + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + let descJson = null; + try { + descJson = JSON.stringify(desc); + } + catch (error) { + descJson = desc.toString(); + } + console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${obj}' and got error, giving up: ${error}`); + } + } + else { + throw error; + } + } + } -/** - * @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 - */ -/* - * This is necessary for Chrome and Chrome mobile, to enable - * things like redefining `createdCallback` on an element. - */ -var zoneSymbol$1 = Zone.__symbol__; -var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; -var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = - Object.getOwnPropertyDescriptor; -var _create = Object.create; -var unconfigurablesKey = zoneSymbol$1('unconfigurables'); -function propertyPatch() { - Object.defineProperty = function (obj, prop, desc) { - if (isUnconfigurable(obj, prop)) { - throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); - } - var originalConfigurableFlag = desc.configurable; - if (prop !== 'prototype') { - desc = rewriteDescriptor(obj, prop, desc); - } - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); - }; - Object.defineProperties = function (obj, props) { - Object.keys(props).forEach(function (prop) { - Object.defineProperty(obj, prop, props[prop]); - }); - return obj; - }; - Object.create = function (obj, proto) { - if (typeof proto === 'object' && !Object.isFrozen(proto)) { - Object.keys(proto).forEach(function (prop) { - proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); - }); - } - return _create(obj, proto); - }; - Object.getOwnPropertyDescriptor = function (obj, prop) { - var desc = _getOwnPropertyDescriptor(obj, prop); - if (desc && isUnconfigurable(obj, prop)) { - desc.configurable = false; - } - return desc; - }; -} -function _redefineProperty(obj, prop, desc) { - var originalConfigurableFlag = desc.configurable; - desc = rewriteDescriptor(obj, prop, desc); - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); -} -function isUnconfigurable(obj, prop) { - return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; -} -function rewriteDescriptor(obj, prop, desc) { - // issue-927, if the desc is frozen, don't try to change the desc - if (!Object.isFrozen(desc)) { - desc.configurable = true; - } - if (!desc.configurable) { - // issue-927, if the obj is frozen, don't try to set the desc to obj - if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { - _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); - } - if (obj[unconfigurablesKey]) { - obj[unconfigurablesKey][prop] = true; - } - } - return desc; -} -function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - if (desc.configurable) { - // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's - // retry with the original flag value - if (typeof originalConfigurableFlag == 'undefined') { - delete desc.configurable; - } - else { - desc.configurable = originalConfigurableFlag; - } - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - var descJson = null; - try { - descJson = JSON.stringify(desc); - } - catch (error) { - descJson = desc.toString(); - } - console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); - } - } - else { - throw error; - } - } -} + /** + * @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 globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' + ]; + const documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' + ]; + const windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' + ]; + const htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' + ]; + const mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; + const ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' + ]; + const webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; + const formEventNames = ['autocomplete', 'autocompleteerror']; + const detailEventNames = ['toggle']; + const frameEventNames = ['load']; + const frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; + const marqueeEventNames = ['bounce', 'finish', 'start']; + const XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' + ]; + const IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; + const websocketEventNames = ['close', 'error', 'open', 'message']; + const workerEventNames = ['error', 'message']; + const eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); + function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + const tip = ignoreProperties.filter(ip => ip.target === target); + if (!tip || tip.length === 0) { + return onProperties; + } + const targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(op => targetIgnoreProperties.indexOf(op) === -1); + } + function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + const filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); + } + function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; + } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } + const supportsWebSocket = typeof WebSocket !== 'undefined'; + const ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + const internalWindow = window; + const ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement) { + patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); + } + const Worker = internalWindow['Worker']; + if (Worker) { + patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); + } + } + const XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + } + } -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var globalEventHandlersEventNames = [ - 'abort', - 'animationcancel', - 'animationend', - 'animationiteration', - 'auxclick', - 'beforeinput', - 'blur', - 'cancel', - 'canplay', - 'canplaythrough', - 'change', - 'compositionstart', - 'compositionupdate', - 'compositionend', - 'cuechange', - 'click', - 'close', - 'contextmenu', - 'curechange', - 'dblclick', - 'drag', - 'dragend', - 'dragenter', - 'dragexit', - 'dragleave', - 'dragover', - 'drop', - 'durationchange', - 'emptied', - 'ended', - 'error', - 'focus', - 'focusin', - 'focusout', - 'gotpointercapture', - 'input', - 'invalid', - 'keydown', - 'keypress', - 'keyup', - 'load', - 'loadstart', - 'loadeddata', - 'loadedmetadata', - 'lostpointercapture', - 'mousedown', - 'mouseenter', - 'mouseleave', - 'mousemove', - 'mouseout', - 'mouseover', - 'mouseup', - 'mousewheel', - 'orientationchange', - 'pause', - 'play', - 'playing', - 'pointercancel', - 'pointerdown', - 'pointerenter', - 'pointerleave', - 'pointerlockchange', - 'mozpointerlockchange', - 'webkitpointerlockerchange', - 'pointerlockerror', - 'mozpointerlockerror', - 'webkitpointerlockerror', - 'pointermove', - 'pointout', - 'pointerover', - 'pointerup', - 'progress', - 'ratechange', - 'reset', - 'resize', - 'scroll', - 'seeked', - 'seeking', - 'select', - 'selectionchange', - 'selectstart', - 'show', - 'sort', - 'stalled', - 'submit', - 'suspend', - 'timeupdate', - 'volumechange', - 'touchcancel', - 'touchmove', - 'touchstart', - 'touchend', - 'transitioncancel', - 'transitionend', - 'waiting', - 'wheel' -]; -var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', - 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', - 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange', 'resume' -]; -var windowEventNames = [ - 'absolutedeviceorientation', - 'afterinput', - 'afterprint', - 'appinstalled', - 'beforeinstallprompt', - 'beforeprint', - 'beforeunload', - 'devicelight', - 'devicemotion', - 'deviceorientation', - 'deviceorientationabsolute', - 'deviceproximity', - 'hashchange', - 'languagechange', - 'message', - 'mozbeforepaint', - 'offline', - 'online', - 'paint', - 'pageshow', - 'pagehide', - 'popstate', - 'rejectionhandled', - 'storage', - 'unhandledrejection', - 'unload', - 'userproximity', - 'vrdisplyconnected', - 'vrdisplaydisconnected', - 'vrdisplaypresentchange' -]; -var htmlElementEventNames = [ - 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', - 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', - 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' -]; -var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; -var ieElementEventNames = [ - 'activate', - 'afterupdate', - 'ariarequest', - 'beforeactivate', - 'beforedeactivate', - 'beforeeditfocus', - 'beforeupdate', - 'cellchange', - 'controlselect', - 'dataavailable', - 'datasetchanged', - 'datasetcomplete', - 'errorupdate', - 'filterchange', - 'layoutcomplete', - 'losecapture', - 'move', - 'moveend', - 'movestart', - 'propertychange', - 'resizeend', - 'resizestart', - 'rowenter', - 'rowexit', - 'rowsdelete', - 'rowsinserted', - 'command', - 'compassneedscalibration', - 'deactivate', - 'help', - 'mscontentzoom', - 'msmanipulationstatechanged', - 'msgesturechange', - 'msgesturedoubletap', - 'msgestureend', - 'msgesturehold', - 'msgesturestart', - 'msgesturetap', - 'msgotpointercapture', - 'msinertiastart', - 'mslostpointercapture', - 'mspointercancel', - 'mspointerdown', - 'mspointerenter', - 'mspointerhover', - 'mspointerleave', - 'mspointermove', - 'mspointerout', - 'mspointerover', - 'mspointerup', - 'pointerout', - 'mssitemodejumplistitemremoved', - 'msthumbnailclick', - 'stop', - 'storagecommit' -]; -var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; -var formEventNames = ['autocomplete', 'autocompleteerror']; -var detailEventNames = ['toggle']; -var frameEventNames = ['load']; -var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; -var marqueeEventNames = ['bounce', 'finish', 'start']; -var XMLHttpRequestEventNames = [ - 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', - 'readystatechange' -]; -var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; -var websocketEventNames = ['close', 'error', 'open', 'message']; -var workerEventNames = ['error', 'message']; -var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); -function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties || ignoreProperties.length === 0) { - return onProperties; - } - var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); - if (!tip || tip.length === 0) { - return onProperties; - } - var targetIgnoreProperties = tip[0].ignoreProperties; - return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); -} -function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { - // check whether target is available, sometimes target will be undefined - // because different browser or some 3rd party plugin. - if (!target) { - return; - } - var filteredProperties = filterProperties(target, onProperties, ignoreProperties); - patchOnProperties(target, filteredProperties, prototype); -} -function propertyDescriptorPatch(api, _global) { - if (isNode && !isMix) { - return; - } - if (Zone[api.symbol('patchEvents')]) { - // events are already been patched by legacy patch. - return; - } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); - } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); - } - } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (XMLHttpRequest) { - // XMLHttpRequest is not available in ServiceWorker, so we need to check here - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } -} + /** + * @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.__load_patch('util', (global, Zone, api) => { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = () => ({ + globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames, + isBrowser, + isMix, + isNode, + TRUE_STR, + FALSE_STR, + ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR + }); + }); -/** - * @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.__load_patch('util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to - // define which events will not be patched by `Zone.js`. - // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep - // the name consistent with angular repo. - // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for - // backwards compatibility. - var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); - if (global[SYMBOL_UNPATCHED_EVENTS]) { - global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; - } - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = - global[SYMBOL_BLACK_LISTED_EVENTS]; - } - api.patchEventPrototype = patchEventPrototype; - api.patchEventTarget = patchEventTarget; - api.isIEOrEdge = isIEOrEdge; - api.ObjectDefineProperty = ObjectDefineProperty; - api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; - api.ObjectCreate = ObjectCreate; - api.ArraySlice = ArraySlice; - api.patchClass = patchClass; - api.wrapWithCurrentZone = wrapWithCurrentZone; - api.filterProperties = filterProperties; - api.attachOriginToPatched = attachOriginToPatched; - api._redefineProperty = _redefineProperty; - api.patchCallbacks = patchCallbacks; - api.getGlobalObjects = function () { return ({ - globalSources: globalSources, - zoneSymbolEventNames: zoneSymbolEventNames$1, - eventNames: eventNames, - isBrowser: isBrowser, - isMix: isMix, - isNode: isNode, - TRUE_STR: TRUE_STR, - FALSE_STR: FALSE_STR, - ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, - ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, - REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR - }); }; -}); + /** + * @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 + */ -/** - * @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 - */ + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + function patchTimer(window, setName, cancelName, nameSuffix) { + let setNative = null; + let clearNative = null; + setName += nameSuffix; + cancelName += nameSuffix; + const tasksByHandleId = {}; + function scheduleTask(task) { + const data = task.data; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } + } + } + data.args[0] = timer; + data.handleId = setNative.apply(window, data.args); + return task; + } + function clearTask(task) { + return clearNative(task.data.handleId); + } + setNative = + patchMethod(window, setName, (delegate) => function (self, args) { + if (typeof args[0] === 'function') { + const options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + const task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); + if (!task) { + return task; + } + // Node.js must additionally support the ref and unref functions. + const handle = task.data.handleId; + if (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } + return task; + } + else { + // cause an error by calling it directly. + return delegate.apply(window, args); + } + }); + clearNative = + patchMethod(window, cancelName, (delegate) => function (self, args) { + const id = args[0]; + let task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // 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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; - } - } - } - } - data.args[0] = timer; - 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 options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); - } - if (typeof handle === 'number' || handle) { - return 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; - } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; - } - else if (id) { - id[taskSymbol] = null; - } - // 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 + */ + function patchCustomElements(_global, api) { + const { isBrowser, isMix } = api.getGlobalObjects(); + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { + return; + } + const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); + } -/** - * @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 patchCustomElements(_global, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { - return; - } - var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); -} + /** + * @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 eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } + const { eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX } = api.getGlobalObjects(); + // predefine all __zone_symbol__ + eventName + true/false string + for (let i = 0; i < eventNames.length; i++) { + const eventName = eventNames[i]; + const falseEventName = eventName + FALSE_STR; + const trueEventName = eventName + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + const EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; + } + function patchEvent(global, api) { + api.patchEventPrototype(global, api); + } -/** - * @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 eventTargetPatch(_global, api) { - if (Zone[api.symbol('patchEventTarget')]) { - // EventTarget is already patched. - return; - } - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - var EVENT_TARGET = _global['EventTarget']; - if (!EVENT_TARGET || !EVENT_TARGET.prototype) { - return; - } - api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); - return true; -} -function patchEvent(global, api) { - api.patchEventPrototype(global, api); -} + /** + * @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.__load_patch('legacy', (global) => { + const legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } + }); + Zone.__load_patch('timers', (global) => { + const set = 'set'; + const clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + }); + Zone.__load_patch('requestAnimationFrame', (global) => { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); + }); + Zone.__load_patch('blocking', (global, Zone) => { + const blockingMethods = ['alert', 'prompt', 'confirm']; + for (let i = 0; i < blockingMethods.length; i++) { + const name = blockingMethods[i]; + patchMethod(global, name, (delegate, symbol, name) => { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); + } + }); + Zone.__load_patch('EventTarget', (global, Zone, api) => { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + const XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); + }); + Zone.__load_patch('on_property', (global, Zone, api) => { + propertyDescriptorPatch(api, global); + propertyPatch(); + }); + Zone.__load_patch('customElements', (global, Zone, api) => { + patchCustomElements(global, api); + }); + Zone.__load_patch('XHR', (global, Zone) => { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + const XHR_TASK = zoneSymbol('xhrTask'); + const XHR_SYNC = zoneSymbol('xhrSync'); + const XHR_LISTENER = zoneSymbol('xhrListener'); + const XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + const XHR_URL = zoneSymbol('xhrURL'); + const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + const XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } + const XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; + } + let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + const READY_STATE_CHANGE = 'readystatechange'; + const SCHEDULED = 'scheduled'; + function scheduleTask(task) { + const data = task.data; + const target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + const listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + const newListener = target[XHR_LISTENER] = () => { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + const loadTasks = target[Zone.__symbol__('loadfalse')]; + if (loadTasks && loadTasks.length > 0) { + const oriInvoke = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + const loadTasks = target[Zone.__symbol__('loadfalse')]; + for (let i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; + } + } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + const storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; + } + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; + } + function placeholderCallback() { } + function clearTask(task) { + const data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + const openNative = patchMethod(XMLHttpRequestPrototype, 'open', () => function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }); + const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + const fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + const fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + const sendNative = patchMethod(XMLHttpRequestPrototype, 'send', () => function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + 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 { + const options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + const task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } + } + }); + const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function (self, args) { + const task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); + } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }); + } + }); + Zone.__load_patch('geolocation', (global) => { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); + } + }); + Zone.__load_patch('PromiseRejectionEvent', (global, Zone) => { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + const eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(eventTask => { + // windows has added unhandledrejection event listener + // trigger the event listener + const PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + const evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; + } + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); + } + }); -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -Zone.__load_patch('legacy', function (global) { - var legacyPatch = global[Zone.__symbol__('legacyPatch')]; - if (legacyPatch) { - legacyPatch(); - } -}); -Zone.__load_patch('timers', function (global) { - var set = 'set'; - var clear = 'clear'; - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); -}); -Zone.__load_patch('requestAnimationFrame', function (global) { - patchTimer(global, 'request', 'cancel', 'AnimationFrame'); - patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); - patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); -}); -Zone.__load_patch('blocking', function (global, Zone) { - var blockingMethods = ['alert', 'prompt', 'confirm']; - for (var i = 0; i < blockingMethods.length; i++) { - var name_1 = blockingMethods[i]; - patchMethod(global, name_1, function (delegate, symbol, name) { - return function (s, args) { - return Zone.current.run(delegate, global, args, name); - }; - }); - } -}); -Zone.__load_patch('EventTarget', function (global, Zone, api) { - patchEvent(global, api); - eventTargetPatch(global, api); - // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener - var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { - api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); - } - patchClass('MutationObserver'); - patchClass('WebKitMutationObserver'); - patchClass('IntersectionObserver'); - patchClass('FileReader'); -}); -Zone.__load_patch('on_property', function (global, Zone, api) { - propertyDescriptorPatch(api, global); - propertyPatch(); -}); -Zone.__load_patch('customElements', function (global, Zone, api) { - patchCustomElements(global, api); -}); -Zone.__load_patch('XHR', function (global, Zone) { - // Treat XMLHttpRequest as a macrotask. - patchXHR(global); - var XHR_TASK = zoneSymbol('xhrTask'); - var XHR_SYNC = zoneSymbol('xhrSync'); - var XHR_LISTENER = zoneSymbol('xhrListener'); - var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); - var XHR_URL = zoneSymbol('xhrURL'); - var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); - function patchXHR(window) { - var XMLHttpRequest = window['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker - return; - } - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - function findPendingTask(target) { - return target[XHR_TASK]; - } - var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - if (!oriAddListener) { - var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; - oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - } - } - var READY_STATE_CHANGE = 'readystatechange'; - var SCHEDULED = 'scheduled'; - function scheduleTask(task) { - var data = task.data; - var target = data.target; - target[XHR_SCHEDULED] = false; - target[XHR_ERROR_BEFORE_SCHEDULED] = false; - // remove existing event listener - var listener = target[XHR_LISTENER]; - if (!oriAddListener) { - oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - } - if (listener) { - oriRemoveListener.call(target, READY_STATE_CHANGE, listener); - } - var newListener = target[XHR_LISTENER] = function () { - if (target.readyState === target.DONE) { - // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with - // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { - // check whether the xhr has registered onload listener - // if that is the case, the task should invoke after all - // onload listeners finish. - var loadTasks = target['__zone_symbol__loadfalse']; - if (loadTasks && loadTasks.length > 0) { - var oriInvoke_1 = task.invoke; - task.invoke = function () { - // need to load the tasks again, because in other - // load listener, they may remove themselves - var loadTasks = target['__zone_symbol__loadfalse']; - for (var i = 0; i < loadTasks.length; i++) { - if (loadTasks[i] === task) { - loadTasks.splice(i, 1); - } - } - if (!data.aborted && task.state === SCHEDULED) { - oriInvoke_1.call(task); - } - }; - loadTasks.push(task); - } - else { - task.invoke(); - } - } - else if (!data.aborted && target[XHR_SCHEDULED] === false) { - // error occurs when xhr.send() - target[XHR_ERROR_BEFORE_SCHEDULED] = true; - } - } - }; - oriAddListener.call(target, READY_STATE_CHANGE, newListener); - var storedTask = target[XHR_TASK]; - if (!storedTask) { - target[XHR_TASK] = task; - } - sendNative.apply(target, data.args); - target[XHR_SCHEDULED] = true; - return task; - } - function placeholderCallback() { } - function clearTask(task) { - var data = task.data; - // Note - ideally, we would call data.target.removeEventListener here, but it's too late - // to prevent it from firing. So instead, we store info for the event listener. - data.aborted = true; - return abortNative.apply(data.target, data.args); - } - var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { - self[XHR_SYNC] = args[2] == false; - self[XHR_URL] = args[1]; - return openNative.apply(self, args); - }; }); - var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); - var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); - var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { - if (Zone.current[fetchTaskScheduling] === true) { - // a fetch is scheduling, so we are using xhr to polyfill fetch - // and because we already schedule macroTask for fetch, we should - // not schedule a macroTask for xhr again - return sendNative.apply(self, args); - } - if (self[XHR_SYNC]) { - // if the XHR is sync there is no task to schedule, just execute the code. - return sendNative.apply(self, args); - } - else { - var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; - var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); - if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && - task.state === SCHEDULED) { - // xhr request throw error when send - // we should invoke task instead of leaving a scheduled - // pending macroTask - task.invoke(); - } - } - }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { - var task = findPendingTask(self); - if (task && typeof task.type == 'string') { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && task.data.aborted)) { - return; - } - task.zone.cancelTask(task); - } - else if (Zone.current[fetchTaskAborting] === true) { - // the abort is called from fetch polyfill, we need to call native abort of XHR. - return abortNative.apply(self, args); - } - // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no - // task - // to cancel. Do nothing. - }; }); - } -}); -Zone.__load_patch('geolocation', function (global) { - /// GEO_LOCATION - if (global['navigator'] && global['navigator'].geolocation) { - patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { - // handle unhandled promise rejection - function findPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(global, evtName); - eventTasks.forEach(function (eventTask) { - // windows has added unhandledrejection event listener - // trigger the event listener - var PromiseRejectionEvent = global['PromiseRejectionEvent']; - if (PromiseRejectionEvent) { - var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); - eventTask.invoke(evt); - } - }); - }; - } - if (global['PromiseRejectionEvent']) { - Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = - findPromiseRejectionHandler('unhandledrejection'); - Zone[zoneSymbol('rejectionHandledHandler')] = - findPromiseRejectionHandler('rejectionhandled'); - } -}); + /** + * @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 + */ -/** - * @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 - */ + /** + * @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 + */ + /** + * @fileoverview + * @suppress {globalThis} + */ + const NEWLINE = '\n'; + const IGNORE_FRAMES = {}; + const creationTrace = '__creationTrace__'; + const ERROR_TAG = 'STACKTRACE TRACKING'; + const SEP_TAG = '__SEP_TAG__'; + let sepTemplate = SEP_TAG + '@[native]'; + class LongStackTrace { + constructor() { + this.error = getStacktrace(); + this.timestamp = new Date(); + } + } + function getStacktraceWithUncaughtError() { + return new Error(ERROR_TAG); + } + function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); + } + catch (err) { + return err; + } + } + // Some implementations of exception handling don't create a stack trace if the exception + // isn't thrown, however it's faster not to actually throw the exception. + const error = getStacktraceWithUncaughtError(); + const caughtError = getStacktraceWithCaughtError(); + const getStacktrace = error.stack ? + getStacktraceWithUncaughtError : + (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); + function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; + } + function addErrorStack(lines, error) { + let trace = getFrames(error); + for (let i = 0; i < trace.length; i++) { + const frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!IGNORE_FRAMES.hasOwnProperty(frame)) { + lines.push(trace[i]); + } + } + } + function renderLongStackTrace(frames, stack) { + const longTrace = [stack ? stack.trim() : '']; + if (frames) { + let timestamp = new Date().getTime(); + for (let i = 0; i < frames.length; i++) { + const traceFrames = frames[i]; + const lastTime = traceFrames.timestamp; + let separator = `____________________Elapsed ${timestamp - lastTime.getTime()} ms; At: ${lastTime}`; + separator = separator.replace(/[^\w\d]/g, '_'); + longTrace.push(sepTemplate.replace(SEP_TAG, separator)); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); + } + } + return longTrace.join(NEWLINE); + } + Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + // add a getLongStackTrace method in spec to + // handle handled reject promise error. + getLongStackTrace: function (error) { + if (!error) { + return undefined; + } + const trace = error[Zone.__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; + } + return renderLongStackTrace(trace, error.stack); + }, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + const currentTask = Zone.currentTask; + let trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; + } + if (!task.data) + task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = Object.assign({}, task.data); + } + task.data[creationTrace] = trace; + } + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + const parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + const longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + try { + error.stack = error.longStack = longStack; + } + catch (err) { + } + } + } + return parentZoneDelegate.handleError(targetZone, error); + } + }; + function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); + } + } + function computeIgnoreFrames() { + if (Error.stackTraceLimit <= 0) { + return; + } + const frames = []; + captureStackTraces(frames, 2); + const frames1 = frames[0]; + const frames2 = frames[1]; + for (let i = 0; i < frames1.length; i++) { + const frame1 = frames1[i]; + if (frame1.indexOf(ERROR_TAG) == -1) { + let match = frame1.match(/^\s*at\s+/); + if (match) { + sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + break; + } + } + } + for (let i = 0; i < frames1.length; i++) { + const frame1 = frames1[i]; + const frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES[frame1] = true; + } + else { + break; + } + } + } + computeIgnoreFrames(); -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var __assign = (undefined && undefined.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var NEWLINE = '\n'; -var IGNORE_FRAMES = {}; -var creationTrace = '__creationTrace__'; -var ERROR_TAG = 'STACKTRACE TRACKING'; -var SEP_TAG = '__SEP_TAG__'; -var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = /** @class */ (function () { - function LongStackTrace() { - this.error = getStacktrace(); - this.timestamp = new Date(); - } - return LongStackTrace; -}()); -function getStacktraceWithUncaughtError() { - return new Error(ERROR_TAG); -} -function getStacktraceWithCaughtError() { - try { - throw getStacktraceWithUncaughtError(); - } - catch (err) { - return err; - } -} -// Some implementations of exception handling don't create a stack trace if the exception -// isn't thrown, however it's faster not to actually throw the exception. -var error = getStacktraceWithUncaughtError(); -var caughtError = getStacktraceWithCaughtError(); -var getStacktrace = error.stack ? - getStacktraceWithUncaughtError : - (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); -function getFrames(error) { - return error.stack ? error.stack.split(NEWLINE) : []; -} -function addErrorStack(lines, error) { - var trace = getFrames(error); - for (var i = 0; i < trace.length; i++) { - var frame = trace[i]; - // Filter out the Frames which are part of stack capturing. - if (!IGNORE_FRAMES.hasOwnProperty(frame)) { - lines.push(trace[i]); - } - } -} -function renderLongStackTrace(frames, stack) { - var longTrace = [stack ? stack.trim() : '']; - if (frames) { - var timestamp = new Date().getTime(); - for (var i = 0; i < frames.length; i++) { - var traceFrames = frames[i]; - var lastTime = traceFrames.timestamp; - var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; - separator = separator.replace(/[^\w\d]/g, '_'); - longTrace.push(sepTemplate.replace(SEP_TAG, separator)); - addErrorStack(longTrace, traceFrames.error); - timestamp = lastTime.getTime(); - } - } - return longTrace.join(NEWLINE); -} -Zone['longStackTraceZoneSpec'] = { - name: 'long-stack-trace', - longStackTraceLimit: 10, - // add a getLongStackTrace method in spec to - // handle handled reject promise error. - getLongStackTrace: function (error) { - if (!error) { - return undefined; - } - var trace = error[Zone.__symbol__('currentTaskTrace')]; - if (!trace) { - return error.stack; - } - return renderLongStackTrace(trace, error.stack); - }, - onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var currentTask = Zone.currentTask; - var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; - trace = [new LongStackTrace()].concat(trace); - if (trace.length > this.longStackTraceLimit) { - trace.length = this.longStackTraceLimit; - } - if (!task.data) - task.data = {}; - if (task.type === 'eventTask') { - // Fix issue https://github.com/angular/zone.js/issues/1195, - // For event task of browser, by default, all task will share a - // singleton instance of data object, we should create a new one here - // The cast to `any` is required to workaround a closure bug which wrongly applies - // URL sanitization rules to .data access. - task.data = __assign({}, task.data); - } - task.data[creationTrace] = trace; - } - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var parentTask = Zone.currentTask || error.task; - if (error instanceof Error && parentTask) { - var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); - try { - error.stack = error.longStack = longStack; - } - catch (err) { - } - } - } - return parentZoneDelegate.handleError(targetZone, error); - } -}; -function captureStackTraces(stackTraces, count) { - if (count > 0) { - stackTraces.push(getFrames((new LongStackTrace()).error)); - captureStackTraces(stackTraces, count - 1); - } -} -function computeIgnoreFrames() { - if (Error.stackTraceLimit <= 0) { - return; - } - var frames = []; - captureStackTraces(frames, 2); - var frames1 = frames[0]; - var frames2 = frames[1]; - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - if (frame1.indexOf(ERROR_TAG) == -1) { - var match = frame1.match(/^\s*at\s+/); - if (match) { - sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; - break; - } - } - } - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - var frame2 = frames2[i]; - if (frame1 === frame2) { - IGNORE_FRAMES[frame1] = true; - } - else { - break; - } - } -} -computeIgnoreFrames(); + /** + * @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 { + constructor(defaultSpecDelegate = null) { + this.defaultSpecDelegate = defaultSpecDelegate; + this.name = 'ProxyZone'; + this._delegateSpec = null; + this.properties = { 'ProxyZoneSpec': this }; + this.propertyKeys = null; + this.lastTaskState = null; + this.isNeedToTriggerHasTask = false; + this.tasks = []; + this.setDelegate(defaultSpecDelegate); + } + static get() { + return Zone.current.get('ProxyZoneSpec'); + } + static isLoaded() { + return ProxyZoneSpec.get() instanceof ProxyZoneSpec; + } + static assertPresent() { + if (!ProxyZoneSpec.isLoaded()) { + throw new Error(`Expected to be running in 'ProxyZone', but it was not found.`); + } + return ProxyZoneSpec.get(); + } + setDelegate(delegateSpec) { + const isNewDelegate = this._delegateSpec !== delegateSpec; + this._delegateSpec = delegateSpec; + this.propertyKeys && this.propertyKeys.forEach((key) => delete this.properties[key]); + this.propertyKeys = null; + if (delegateSpec && delegateSpec.properties) { + this.propertyKeys = Object.keys(delegateSpec.properties); + this.propertyKeys.forEach((k) => this.properties[k] = delegateSpec.properties[k]); + } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } + } + getDelegate() { + return this._delegateSpec; + } + resetDelegate() { + const delegateSpec = this.getDelegate(); + this.setDelegate(this.defaultSpecDelegate); + } + tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + } + removeFromTasks(task) { + if (!this.tasks) { + return; + } + for (let i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; + } + } + } + getAndClearPendingTasksInfo() { + if (this.tasks.length === 0) { + return ''; + } + const taskInfo = this.tasks.map((task) => { + const dataInfo = task.data && + Object.keys(task.data) + .map((key) => { + return key + ':' + task.data[key]; + }) + .join(','); + return `type: ${task.type}, source: ${task.source}, args: {${dataInfo}}`; + }); + const pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; + } + onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); + } + else { + return parentZoneDelegate.fork(targetZone, zoneSpec); + } + } + onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source) { + if (this._delegateSpec && this._delegateSpec.onIntercept) { + return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); + } + else { + return parentZoneDelegate.intercept(targetZone, delegate, source); + } + } + onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvoke) { + return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); + } + else { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + } + onHandleError(parentZoneDelegate, currentZone, targetZone, error) { + if (this._delegateSpec && this._delegateSpec.onHandleError) { + return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); + } + else { + return parentZoneDelegate.handleError(targetZone, error); + } + } + onScheduleTask(parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } + if (this._delegateSpec && this._delegateSpec.onScheduleTask) { + return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.scheduleTask(targetZone, task); + } + } + onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { + return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); + } + else { + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } + } + onCancelTask(parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onCancelTask) { + return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.cancelTask(targetZone, task); + } + } + onHasTask(delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; + if (this._delegateSpec && this._delegateSpec.onHasTask) { + this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); + } + else { + delegate.hasTask(target, hasTaskState); + } + } + } + // Export the class so that new instances can be created with proper + // constructor params. + Zone['ProxyZoneSpec'] = ProxyZoneSpec; -/** - * @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 = /** @class */ (function () { - function ProxyZoneSpec(defaultSpecDelegate) { - if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } - this.defaultSpecDelegate = defaultSpecDelegate; - this.name = 'ProxyZone'; - this._delegateSpec = null; - this.properties = { 'ProxyZoneSpec': this }; - this.propertyKeys = null; - this.lastTaskState = null; - this.isNeedToTriggerHasTask = false; - this.tasks = []; - this.setDelegate(defaultSpecDelegate); - } - ProxyZoneSpec.get = function () { - return Zone.current.get('ProxyZoneSpec'); - }; - ProxyZoneSpec.isLoaded = function () { - return ProxyZoneSpec.get() instanceof ProxyZoneSpec; - }; - ProxyZoneSpec.assertPresent = function () { - if (!ProxyZoneSpec.isLoaded()) { - throw new Error("Expected to be running in 'ProxyZone', but it was not found."); - } - return ProxyZoneSpec.get(); - }; - ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { - var _this = this; - var isNewDelegate = this._delegateSpec !== delegateSpec; - this._delegateSpec = delegateSpec; - this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); - this.propertyKeys = null; - if (delegateSpec && delegateSpec.properties) { - this.propertyKeys = Object.keys(delegateSpec.properties); - this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); - } - // if set a new delegateSpec, shoulde check whether need to - // trigger hasTask or not - if (isNewDelegate && this.lastTaskState && - (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { - this.isNeedToTriggerHasTask = true; - } - }; - ProxyZoneSpec.prototype.getDelegate = function () { - return this._delegateSpec; - }; - ProxyZoneSpec.prototype.resetDelegate = function () { - var delegateSpec = this.getDelegate(); - this.setDelegate(this.defaultSpecDelegate); - }; - ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { - if (this.isNeedToTriggerHasTask && this.lastTaskState) { - // last delegateSpec has microTask or macroTask - // should call onHasTask in current delegateSpec - this.isNeedToTriggerHasTask = false; - this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); - } - }; - ProxyZoneSpec.prototype.removeFromTasks = function (task) { - if (!this.tasks) { - return; - } - for (var i = 0; i < this.tasks.length; i++) { - if (this.tasks[i] === task) { - this.tasks.splice(i, 1); - return; - } - } - }; - ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { - if (this.tasks.length === 0) { - return ''; - } - var taskInfo = this.tasks.map(function (task) { - var dataInfo = task.data && - Object.keys(task.data) - .map(function (key) { - return key + ':' + task.data[key]; - }) - .join(','); - return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; - }); - var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; - // clear tasks - this.tasks = []; - return pendingTasksInfo; - }; - ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { - if (this._delegateSpec && this._delegateSpec.onFork) { - return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); - } - else { - return parentZoneDelegate.fork(targetZone, zoneSpec); - } - }; - ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { - if (this._delegateSpec && this._delegateSpec.onIntercept) { - return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); - } - else { - return parentZoneDelegate.intercept(targetZone, delegate, source); - } - }; - ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvoke) { - return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); - } - else { - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - }; - ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - if (this._delegateSpec && this._delegateSpec.onHandleError) { - return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); - } - else { - return parentZoneDelegate.handleError(targetZone, error); - } - }; - ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.tasks.push(task); - } - if (this._delegateSpec && this._delegateSpec.onScheduleTask) { - return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.scheduleTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvokeTask) { - return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); - } - else { - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } - }; - ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onCancelTask) { - return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.cancelTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { - this.lastTaskState = hasTaskState; - if (this._delegateSpec && this._delegateSpec.onHasTask) { - this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); - } - else { - delegate.hasTask(target, hasTaskState); - } - }; - return ProxyZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['ProxyZoneSpec'] = ProxyZoneSpec; + /** + * @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 { + constructor(namePrefix) { + this.runZone = Zone.current; + this.name = 'syncTestZone for ' + namePrefix; + } + onScheduleTask(delegate, current, target, task) { + switch (task.type) { + case 'microTask': + case 'macroTask': + throw new Error(`Cannot call ${task.source} from within a sync test.`); + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + } + } + // Export the class so that new instances can be created with proper + // constructor params. + Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -var SyncTestZoneSpec = /** @class */ (function () { - function SyncTestZoneSpec(namePrefix) { - this.runZone = Zone.current; - this.name = 'syncTestZone for ' + namePrefix; - } - SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - case 'macroTask': - throw new Error("Cannot call " + task.source + " from within a sync test."); - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - return SyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; + ((_global) => { + const __extends = function (d, b) { + for (const 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'.`); + jasmine['__zone_patch__'] = true; + const SyncTestZoneSpec = Zone['SyncTestZoneSpec']; + const ProxyZoneSpec = Zone['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 + // a `beforeEach` or `it`. + const syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + const symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + const disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + const enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); + const ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + const globalErrors = jasmine.GlobalErrors; + if (globalErrors && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors; + jasmine.GlobalErrors = function () { + const instance = new globalErrors(); + const originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + const originalHandlers = process.listeners('unhandledRejection'); + const r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(h => process.on('unhandledRejection', h)); + } + return r; + }; + } + return instance; + }; + } + } + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. + const jasmineEnv = jasmine.getEnv(); + ['describe', 'xdescribe', 'fdescribe'].forEach(methodName => { + let originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[methodName] = function (description, specDefinitions) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + }; + }); + ['it', 'xit', 'fit'].forEach(methodName => { + let originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(methodName => { + let originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + const originalClockFn = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + const clock = originalClockFn.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + const originalTick = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick.apply(this, arguments); + }; + const originalMockDate = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + const fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + const dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(methodName => { + const originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + const FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } + } + return clock; + }; + } + /** + * Gets a function wrapping the body of a Jasmine `describe` block to execute in a + * synchronous-only zone. + */ + function wrapDescribeInZone(describeBody) { + return function () { + return syncZone.run(describeBody, this, arguments); + }; + } + function runInTestZone(testBody, applyThis, queueRunner, done) { + const isClockInstalled = !!jasmine[symbol('clockInstalled')]; + const testProxyZoneSpec = queueRunner.testProxyZoneSpec; + const testProxyZone = queueRunner.testProxyZone; + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { + // auto run a fakeAsync + const fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); + } + } + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); + } + else { + return testProxyZone.run(testBody, applyThis); + } + } + /** + * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to + * execute in a ProxyZone zone. + * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` + */ + function wrapTestInZone(testBody) { + // The `done` callback is only passed through if the function expects at least one argument. + // Note we have to make a function with correct number of arguments, otherwise jasmine will + // think that all functions are sync or async. + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this, this.queueRunner, done); + } : function () { + return runInTestZone(testBody, this, this.queueRunner); + })); + } + const QueueRunner = jasmine.QueueRunner; + jasmine.QueueRunner = (function (_super) { + __extends(ZoneQueueRunner, _super); + function ZoneQueueRunner(attrs) { + attrs.onComplete = (fn => () => { + // All functions are done, clear the test zone. + this.testProxyZone = null; + this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + })(attrs.onComplete); + const nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; + const nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + const onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + const proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + const pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } + } + } + if (onException) { + onException.call(this, error); + } + }; + _super.call(this, attrs); + } + ZoneQueueRunner.prototype.execute = function () { + let zone = Zone.current; + let isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); + if (!Zone.currentTask) { + // if we are not running in a task then if someone would register a + // element.addEventListener and then calling element.click() the + // addEventListener callback would think that it is the top most task and would + // drain the microtask queue on element.click() which would be incorrect. + // For this reason we always force a task when running jasmine tests. + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', () => QueueRunner.prototype.execute.call(this)); + } + else { + _super.prototype.execute.call(this); + } + }; + return ZoneQueueRunner; + })(QueueRunner); + })(commonjsGlobal); -/** - * @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 __()); - }; - var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; - // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs - // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) - if (!Zone) - throw new Error('Missing: zone.js'); - if (typeof jasmine == 'undefined') - throw new Error('Missing: jasmine.js'); - if (jasmine['__zone_patch__']) - throw new Error("'jasmine' has already been patched with 'Zone'."); - jasmine['__zone_patch__'] = true; - var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (!SyncTestZoneSpec) - throw new Error('Missing: SyncTestZoneSpec'); - if (!ProxyZoneSpec) - throw new Error('Missing: ProxyZoneSpec'); - var ambientZone = Zone.current; - // Create a synchronous-only zone in which to run `describe` blocks in order to raise an - // error if any asynchronous operations are attempted inside of a `describe` but outside of - // a `beforeEach` or `it`. - var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - var symbol = Zone.__symbol__; - // whether patch jasmine clock when in fakeAsync - var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; - // the original variable name fakeAsyncPatchLock is not accurate, so the name will be - // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also - // automatically disable the auto jump into fakeAsync feature - var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && - ((_global[symbol('fakeAsyncPatchLock')] === true) || - (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); - var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; - if (!ignoreUnhandledRejection) { - var globalErrors_1 = jasmine.GlobalErrors; - if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { - jasmine[symbol('GlobalErrors')] = globalErrors_1; - jasmine.GlobalErrors = function () { - var instance = new globalErrors_1(); - var originalInstall = instance.install; - if (originalInstall && !instance[symbol('install')]) { - instance[symbol('install')] = originalInstall; - instance.install = function () { - var originalHandlers = process.listeners('unhandledRejection'); - var r = originalInstall.apply(this, arguments); - process.removeAllListeners('unhandledRejection'); - if (originalHandlers) { - originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); - } - return r; - }; - } - return instance; - }; - } - } - // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. - var jasmineEnv = jasmine.getEnv(); - ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[methodName] = function (description, specDefinitions) { - return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); - }; - }); - ['it', 'xit', 'fit'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (description, specDefinitions, timeout) { - arguments[1] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); - }; - }); - ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (specDefinitions, timeout) { - arguments[0] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); - }; - }); - if (!disablePatchingJasmineClock) { - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableAutoFakeAsyncWhenClockPatched) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - } - } - return clock; - }; - } - /** - * Gets a function wrapping the body of a Jasmine `describe` block to execute in a - * synchronous-only zone. - */ - function wrapDescribeInZone(describeBody) { - return function () { - return syncZone.run(describeBody, this, arguments); - }; - } - function runInTestZone(testBody, applyThis, queueRunner, done) { - var isClockInstalled = !!jasmine[symbol('clockInstalled')]; - var testProxyZoneSpec = queueRunner.testProxyZoneSpec; - var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { - // auto run a fakeAsync - var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; - if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { - testBody = fakeAsyncModule.fakeAsync(testBody); - } - } - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } - } - /** - * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to - * execute in a ProxyZone zone. - * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` - */ - function wrapTestInZone(testBody) { - // The `done` callback is only passed through if the function expects at least one argument. - // Note we have to make a function with correct number of arguments, otherwise jasmine will - // think that all functions are sync or async. - return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this, this.queueRunner, done); - } : function () { - return runInTestZone(testBody, this, this.queueRunner); - })); - } - var QueueRunner = jasmine.QueueRunner; - jasmine.QueueRunner = (function (_super) { - __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs) { - var _this = this; - attrs.onComplete = (function (fn) { return function () { - // All functions are done, clear the test zone. - _this.testProxyZone = null; - _this.testProxyZoneSpec = null; - ambientZone.scheduleMicroTask('jasmine.onComplete', fn); - }; })(attrs.onComplete); - var nativeSetTimeout = _global['__zone_symbol__setTimeout']; - var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; - if (nativeSetTimeout) { - // should run setTimeout inside jasmine outside of zone - attrs.timeout = { - setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, - clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout - }; - } - // create a userContext to hold the queueRunner itself - // so we can access the testProxy in it/xit/beforeEach ... - if (jasmine.UserContext) { - if (!attrs.userContext) { - attrs.userContext = new jasmine.UserContext(); - } - attrs.userContext.queueRunner = this; - } - else { - if (!attrs.userContext) { - attrs.userContext = {}; - } - attrs.userContext.queueRunner = this; - } - // patch attrs.onException - var onException = attrs.onException; - attrs.onException = function (error) { - if (error && - error.message === - 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { - // jasmine timeout, we can make the error message more - // reasonable to tell what tasks are pending - var proxyZoneSpec = this && this.testProxyZoneSpec; - if (proxyZoneSpec) { - var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - try { - // try catch here in case error.message is not writable - error.message += pendingTasksInfo; - } - catch (err) { - } - } - } - if (onException) { - onException.call(this, error); - } - }; - _super.call(this, attrs); - } - ZoneQueueRunner.prototype.execute = function () { - var _this = this; - var zone = Zone.current; - var isChildOfAmbientZone = false; - while (zone) { - if (zone === ambientZone) { - isChildOfAmbientZone = true; - break; - } - zone = zone.parent; - } - if (!isChildOfAmbientZone) - throw new Error('Unexpected Zone: ' + Zone.current.name); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - this.testProxyZoneSpec = new ProxyZoneSpec(); - this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); - if (!Zone.currentTask) { - // if we are not running in a task then if someone would register a - // element.addEventListener and then calling element.click() the - // addEventListener callback would think that it is the top most task and would - // drain the microtask queue on element.click() which would be incorrect. - // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); - } - else { - _super.prototype.execute.call(this); - } - }; - return ZoneQueueRunner; - })(QueueRunner); -})(); + /** + * @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) { + class AsyncTestZoneSpec { + constructor(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this._isSync = false; + this.runZone = Zone.current; + this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; + this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; + } + isUnresolvedChainedPromisePending() { + return this.unresolvedChainedPromiseCount > 0; + } + _finishCallbackIfDone() { + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(() => { + setTimeout(() => { + if (!this._alreadyErrored && !(this._pendingMicroTasks || this._pendingMacroTasks)) { + this.finishCallback(); + } + }, 0); + }); + } + } + patchPromiseForTest() { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + const patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + } + unPatchPromiseForTest() { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + const unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + } + onScheduleTask(delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; + } + } + return delegate.scheduleTask(target, task); + } + onInvokeTask(delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + } + onCancelTask(delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + } + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. + onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + this._isSync = true; + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + const afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } + } + } + onHandleError(parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + const result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this.failCallback(error); + this._alreadyErrored = true; + } + return false; + } + onHasTask(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(); + } + } + } + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + })(commonjsGlobal); -/** - * @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 _global$1 = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; -var AsyncTestZoneSpec = /** @class */ (function () { - function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { - this.finishCallback = finishCallback; - this.failCallback = failCallback; - this._pendingMicroTasks = false; - this._pendingMacroTasks = false; - this._alreadyErrored = false; - this._isSync = false; - this.runZone = Zone.current; - this.unresolvedChainedPromiseCount = 0; - this.supportWaitUnresolvedChainedPromise = false; - this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { 'AsyncTestZoneSpec': this }; - this.supportWaitUnresolvedChainedPromise = - _global$1[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; - } - AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { - return this.unresolvedChainedPromiseCount > 0; - }; - AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { - var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || - (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { - // We do this because we would like to catch unhandled rejected promises. - this.runZone.run(function () { - setTimeout(function () { - if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this.finishCallback(); - } - }, 0); - }); - } - }; - AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; - if (patchPromiseForTest) { - patchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; - if (unPatchPromiseForTest) { - unPatchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise - if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { - // chained promise is being scheduled - this.unresolvedChainedPromiseCount--; - } - } - return delegate.scheduleTask(target, task); - }; - AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.invokeTask(target, task, applyThis, applyArgs); - }; - AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.cancelTask(target, task); - }; - // 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. - // updated by(JiaLiPassion), only call finish callback when no task - // was scheduled/invoked/canceled. - AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - try { - this._isSync = true; - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - finally { - var afterTaskCounts = parentZoneDelegate._taskCounts; - if (this._isSync) { - this._finishCallbackIfDone(); - } - } - }; - AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - // Let the parent try to handle the error. - var result = parentZoneDelegate.handleError(targetZone, error); - if (result) { - this.failCallback(error); - this._alreadyErrored = true; - } - return false; - }; - AsyncTestZoneSpec.prototype.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(); - } - }; - AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); - return AsyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + /** + * @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.__load_patch('asynctest', (global, Zone, api) => { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, (err) => { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + return new Promise((finishCallback, failCallback) => { + runInTestZone(fn, this, finishCallback, failCallback); + }); + }; + }; + function runInTestZone(fn, context, finishCallback, failCallback) { + const currentZone = Zone.current; + const AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + const ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + const proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + const proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + const previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(() => { + const testZoneSpec = new AsyncTestZoneSpec(() => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(() => { + finishCallback(); + }); + }, (error) => { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(() => { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); + } + }); -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { - /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ - Zone[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); - } - }); - }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); - }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - testZoneSpec.patchPromiseForTest(); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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 __read = (undefined && undefined.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (undefined && undefined.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -(function (global) { - var OriginalDate = global.Date; - var FakeDate = /** @class */ (function () { - function FakeDate() { - if (arguments.length === 0) { - var d = new OriginalDate(); - d.setTime(FakeDate.now()); - return d; - } - else { - var args = Array.prototype.slice.call(arguments); - return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); - } - } - FakeDate.now = function () { - var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncTestZoneSpec) { - return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); - } - return OriginalDate.now.apply(this, arguments); - }; - return FakeDate; - }()); - FakeDate.UTC = OriginalDate.UTC; - FakeDate.parse = OriginalDate.parse; - // keep a reference for zone patched timer function - var timers = { - setTimeout: global.setTimeout, - setInterval: global.setInterval, - clearTimeout: global.clearTimeout, - clearInterval: global.clearInterval - }; - var Scheduler = /** @class */ (function () { - function Scheduler() { - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - this._schedulerQueue = []; - // Current simulated time in millis. - this._currentTime = 0; - // Current real time in millis. - this._currentRealTime = OriginalDate.now(); - } - Scheduler.prototype.getCurrentTime = function () { - return this._currentTime; - }; - Scheduler.prototype.getCurrentRealTime = function () { - return this._currentRealTime; - }; - Scheduler.prototype.setCurrentRealTime = function (realTime) { - this._currentRealTime = realTime; - }; - Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { - if (args === void 0) { args = []; } - if (isPeriodic === void 0) { isPeriodic = false; } - if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } - if (id === void 0) { id = -1; } - var currentId = id < 0 ? Scheduler.nextId++ : id; - var endTime = this._currentTime + delay; - // Insert so that scheduler queue remains sorted by end time. - var newEntry = { - endTime: endTime, - id: currentId, - func: cb, - args: args, - delay: delay, - isPeriodic: isPeriodic, - isRequestAnimationFrame: isRequestAnimationFrame - }; - var i = 0; - for (; i < this._schedulerQueue.length; i++) { - var currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; - } - } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - }; - Scheduler.prototype.removeScheduledFunctionWithId = function (id) { - for (var i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; - } - } - }; - Scheduler.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - var finalTime = this._currentTime + millis; - var lastCurrentTime = 0; - if (this._schedulerQueue.length === 0 && doTick) { - doTick(millis); - return; - } - while (this._schedulerQueue.length > 0) { - var current = this._schedulerQueue[0]; - if (finalTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. - break; - } - else { - // Time to run scheduled function. Remove it from the head of queue. - var current_1 = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current_1.endTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } - } - lastCurrentTime = this._currentTime; - this._currentTime = finalTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - }; - Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { - if (limit === void 0) { limit = 20; } - if (flushPeriodic === void 0) { flushPeriodic = false; } - if (flushPeriodic) { - return this.flushPeriodic(doTick); - } - else { - return this.flushNonPeriodic(limit, doTick); - } - }; - Scheduler.prototype.flushPeriodic = function (doTick) { - if (this._schedulerQueue.length === 0) { - return 0; - } - // Find the last task currently queued in the scheduler queue and tick - // till that time. - var startTime = this._currentTime; - var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; - this.tick(lastTask.endTime - startTime, doTick); - return this._currentTime - startTime; - }; - Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { - var startTime = this._currentTime; - var lastCurrentTime = 0; - var count = 0; - while (this._schedulerQueue.length > 0) { - count++; - if (count > limit) { - throw new Error('flush failed after reaching the limit of ' + limit + - ' tasks. Does your code use a polling timeout?'); - } - // flush only non-periodic timers. - // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. - if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) - .length === 0) { - break; - } - var current = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current.endTime; - if (doTick) { - // Update any secondary schedulers like Jasmine mock Date. - doTick(this._currentTime - lastCurrentTime); - } - var retval = current.func.apply(global, current.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } - return this._currentTime - startTime; - }; - // Next scheduler id. - Scheduler.nextId = 1; - return Scheduler; - }()); - var FakeAsyncTestZoneSpec = /** @class */ (function () { - function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { - if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } - this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; - this.macroTaskOptions = macroTaskOptions; - this._scheduler = new Scheduler(); - this._microtasks = []; - this._lastError = null; - this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; - this.pendingPeriodicTimers = []; - this.pendingTimers = []; - this.patchDateLocked = false; - this.properties = { 'FakeAsyncTestZoneSpec': this }; - this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakeAsyncTestSpec - // user can also define macroTaskOptions by define a global variable. - if (!this.macroTaskOptions) { - this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; - } - } - FakeAsyncTestZoneSpec.assertInZone = function () { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - }; - FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { - var _this = this; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - fn.apply(global, args); - if (_this._lastError === null) { // Success - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); - } - // Flush microtasks only on success. - _this.flushMicrotasks(); - } - else { // Failure - if (completers.onError != null) { - completers.onError.apply(global); - } - } - // Return true if there were no errors, false otherwise. - return _this._lastError === null; - }; - }; - FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { - var index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); - } - }; - FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); - }; - }; - FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { - var _this = this; - return function () { - // Requeue the timer callback if it's not been canceled. - if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { - _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); - } - }; - }; - FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); - }; - }; - FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { - if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(Scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); - var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); - if (isTimer) { - this.pendingTimers.push(id); - } - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = Scheduler.nextId; - var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; - var cb = this._fnAndFlush(fn, completers); - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args, true); - this.pendingPeriodicTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { - var error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - }; - FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { - return this._scheduler.getCurrentTime(); - }; - FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { - return this._scheduler.getCurrentRealTime(); - }; - FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { - this._scheduler.setCurrentRealTime(realTime); - }; - FakeAsyncTestZoneSpec.patchDate = function () { - if (!!global[Zone.__symbol__('disableDatePatching')]) { - // we don't want to patch global Date - // because in some case, global Date - // is already being patched, we need to provide - // an option to let user still use their - // own version of Date. - return; - } - if (global['Date'] === FakeDate) { - // already patched - return; - } - global['Date'] = FakeDate; - FakeDate.prototype = OriginalDate.prototype; - // try check and reset timers - // because jasmine.clock().install() may - // have replaced the global timer - FakeAsyncTestZoneSpec.checkTimerPatch(); - }; - FakeAsyncTestZoneSpec.resetDate = function () { - if (global['Date'] === FakeDate) { - global['Date'] = OriginalDate; - } - }; - FakeAsyncTestZoneSpec.checkTimerPatch = function () { - if (global.setTimeout !== timers.setTimeout) { - global.setTimeout = timers.setTimeout; - global.clearTimeout = timers.clearTimeout; - } - if (global.setInterval !== timers.setInterval) { - global.setInterval = timers.setInterval; - global.clearInterval = timers.clearInterval; - } - }; - FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { - this.patchDateLocked = true; - FakeAsyncTestZoneSpec.patchDate(); - }; - FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { - this.patchDateLocked = false; - FakeAsyncTestZoneSpec.resetDate(); - }; - FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - }; - FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { - var _this = this; - FakeAsyncTestZoneSpec.assertInZone(); - var flushErrors = function () { - if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - _this._resetLastErrorAndThrow(); - } - }; - while (this._microtasks.length > 0) { - var microtask = this._microtasks.shift(); - microtask.func.apply(microtask.target, microtask.args); - } - flushErrors(); - }; - FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - return elapsed; - }; - FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - var args = task.data && task.data.args; - // should pass additional arguments to callback if have any - // currently we know process.nextTick will have such additional - // arguments - var additionalArgs = void 0; - if (args) { - var callbackIndex = task.data.cbIdx; - if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); - } - } - this._microtasks.push({ - func: task.invoke, - args: additionalArgs, - target: task.data && task.data.target - }); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'setImmediate': - task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); - break; - case 'setInterval': - task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'XMLHttpRequest.send': - throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + - task.data['url']); - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. - // (60 frames per second) - task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); - break; - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var args_1 = task.data && task.data['args']; - var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; - var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; - if (!!macroTaskOption.isPeriodic) { - // periodic macroTask, use setInterval to simulate - task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data.isPeriodic = true; - } - else { - // not periodic, use setTimeout to simulate - task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); - } - break; - } - throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); - } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - switch (task.source) { - case 'setTimeout': - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data['handleId']); - case 'setInterval': - return this._clearInterval(task.data['handleId']); - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var handleId = task.data['handleId']; - return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : - this._clearTimeout(handleId); - } - return delegate.cancelTask(target, task); - } - }; - FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { - try { - FakeAsyncTestZoneSpec.patchDate(); - return delegate.invoke(target, callback, applyThis, applyArgs, source); - } - finally { - if (!this.patchDateLocked) { - FakeAsyncTestZoneSpec.resetDate(); - } - } - }; - FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { - if (!this.macroTaskOptions) { - return null; - } - for (var i = 0; i < this.macroTaskOptions.length; i++) { - var macroTaskOption = this.macroTaskOptions[i]; - if (macroTaskOption.source === task.source) { - return macroTaskOption; - } - } - return null; - }; - FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - this._lastError = error; - return false; // Don't propagate error to parent zone. - }; - return FakeAsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); + /** + * @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) { + const OriginalDate = global.Date; + class FakeDate { + constructor() { + if (arguments.length === 0) { + const d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + const args = Array.prototype.slice.call(arguments); + return new OriginalDate(...args); + } + } + static now() { + const fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + } + } + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + const timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; + class Scheduler { + constructor() { + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = OriginalDate.now(); + } + getCurrentTime() { + return this._currentTime; + } + getCurrentRealTime() { + return this._currentRealTime; + } + setCurrentRealTime(realTime) { + this._currentRealTime = realTime; + } + scheduleFunction(cb, delay, args = [], isPeriodic = false, isRequestAnimationFrame = false, id = -1) { + let currentId = id < 0 ? Scheduler.nextId++ : id; + let endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + let newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + let i = 0; + for (; i < this._schedulerQueue.length; i++) { + let currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } + } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + } + removeScheduledFunctionWithId(id) { + for (let i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; + } + } + } + tick(millis = 0, doTick) { + let finalTime = this._currentTime + millis; + let lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + let current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; + } + else { + // Time to run scheduled function. Remove it from the head of queue. + let current = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current.endTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + let retval = current.func.apply(global, current.isRequestAnimationFrame ? [this._currentTime] : current.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + } + lastCurrentTime = this._currentTime; + this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + } + flush(limit = 20, flushPeriodic = false, doTick) { + if (flushPeriodic) { + return this.flushPeriodic(doTick); + } + else { + return this.flushNonPeriodic(limit, doTick); + } + } + flushPeriodic(doTick) { + if (this._schedulerQueue.length === 0) { + return 0; + } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + const startTime = this._currentTime; + const lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + } + flushNonPeriodic(limit, doTick) { + const startTime = this._currentTime; + let lastCurrentTime = 0; + let count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error('flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(task => !task.isPeriodic && !task.isRequestAnimationFrame) + .length === 0) { + break; + } + const current = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current.endTime; + if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. + doTick(this._currentTime - lastCurrentTime); + } + const retval = current.func.apply(global, current.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + return this._currentTime - startTime; + } + } + // Next scheduler id. + Scheduler.nextId = 1; + class FakeAsyncTestZoneSpec { + constructor(namePrefix, trackPendingRequestAnimationFrame = false, macroTaskOptions) { + this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; + this.macroTaskOptions = macroTaskOptions; + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.patchDateLocked = false; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + } + } + static assertInZone() { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + _fnAndFlush(fn, completers) { + return (...args) => { + fn.apply(global, args); + if (this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + this.flushMicrotasks(); + } + else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } + } + // Return true if there were no errors, false otherwise. + return this._lastError === null; + }; + } + static _removeTimer(timers, id) { + let index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); + } + } + _dequeueTimer(id) { + return () => { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + }; + } + _requeuePeriodicTimer(fn, interval, args, id) { + return () => { + // Requeue the timer callback if it's not been canceled. + if (this.pendingPeriodicTimers.indexOf(id) !== -1) { + this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + } + }; + } + _dequeuePeriodicTimer(id) { + return () => { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + }; + } + _setTimeout(fn, delay, args, isTimer = true) { + let removeTimerFn = this._dequeueTimer(Scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + let cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + let id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); + } + return id; + } + _clearTimeout(id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + } + _setInterval(fn, interval, args) { + let id = Scheduler.nextId; + let completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + let cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + } + _clearInterval(id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + } + _resetLastErrorAndThrow() { + let error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + } + getCurrentTime() { + return this._scheduler.getCurrentTime(); + } + getCurrentRealTime() { + return this._scheduler.getCurrentRealTime(); + } + setCurrentRealTime(realTime) { + this._scheduler.setCurrentRealTime(realTime); + } + static patchDate() { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); + } + static resetDate() { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + } + static checkTimerPatch() { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + } + lockDatePatch() { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + } + unlockDatePatch() { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + } + tick(millis = 0, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + } + flushMicrotasks() { + FakeAsyncTestZoneSpec.assertInZone(); + const flushErrors = () => { + if (this._lastError !== null || this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + this._resetLastErrorAndThrow(); + } + }; + while (this._microtasks.length > 0) { + let microtask = this._microtasks.shift(); + microtask.func.apply(microtask.target, microtask.args); + } + flushErrors(); + } + flush(limit, flushPeriodic, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + const elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + } + onScheduleTask(delegate, current, target, task) { + switch (task.type) { + case 'microTask': + let args = task.data && task.data.args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + let additionalArgs; + if (args) { + let callbackIndex = task.data.cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + } + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && task.data.target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; + case 'setInterval': + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + + task.data['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + const macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + const args = task.data && task.data['args']; + const delay = args && args.length > 1 ? args[1] : 0; + let callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data.isPeriodic = true; + } + else { + // not periodic, use setTimeout to simulate + task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + } + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + } + onCancelTask(delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + const macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + const handleId = task.data['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); + } + } + onInvoke(delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } + } + } + findMacroTaskOption(task) { + if (!this.macroTaskOptions) { + return null; + } + for (let i = 0; i < this.macroTaskOptions.length; i++) { + const macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; + } + } + return null; + } + onHandleError(parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + } + } + // Export the class so that new instances can be created with proper + // constructor params. + Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; + })(commonjsGlobal); -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); - } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); - try { - res = fn.apply(this, args); - flushMicrotasks(); - } - finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - } - return _fakeAsyncTestZoneSpec; - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental - */ - function tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } - /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental - */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } - /** - * Discard all remaining periodic tasks. - * - * @experimental - */ - function discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } - /** - * Flush any pending microtasks. - * - * @experimental - */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); + /** + * @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.__load_patch('fakeasync', (global, Zone, api) => { + const FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + const ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + let _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function (...args) { + const proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + let res; + const lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(`${_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length} ` + + `periodic timer(s) still in the queue.`); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(`${_fakeAsyncTestZoneSpec.pendingTimers.length} timer(s) still in the queue.`); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis = 0) { + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + const zoneSpec = _getFakeAsyncZoneSpec(); + const pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone, flushMicrotasks, discardPeriodicTasks, tick, flush, fakeAsync }; + }); -/** - * @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 - */ -/** - * Promise for async/fakeAsync zoneSpec test - * can support async operation which not supported by zone.js - * such as - * it ('test jsonp in AsyncZone', async() => { - * new Promise(res => { - * jsonp(url, (data) => { - * // success callback - * res(data); - * }); - * }).then((jsonpResult) => { - * // get jsonp result. - * - * // user will expect AsyncZoneSpec wait for - * // then, but because jsonp is not zone aware - * // AsyncZone will finish before then is called. - * }); - * }); - */ -Zone.__load_patch('promisefortest', function (global, Zone, api) { - var symbolState = api.symbol('state'); - var UNRESOLVED = null; - var symbolParentUnresolved = api.symbol('parentUnresolved'); - // patch Promise.prototype.then to keep an internal - // number for tracking unresolved chained promise - // we will decrease this number when the parent promise - // being resolved/rejected and chained promise was - // scheduled as a microTask. - // so we can know such kind of chained promise still - // not resolved in AsyncTestZone - Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - return; - } - oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; - Promise.prototype.then = function () { - var chained = oriThen.apply(this, arguments); - if (this[symbolState] === UNRESOLVED) { - // parent promise is unresolved. - var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); - if (asyncTestZoneSpec) { - asyncTestZoneSpec.unresolvedChainedPromiseCount++; - chained[symbolParentUnresolved] = true; - } - } - return chained; - }; - }; - Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { - // restore origin then - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - Promise.prototype.then = oriThen; - Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; - } - }; -}); + /** + * @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 + */ + /** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ + Zone.__load_patch('promisefortest', (global, Zone, api) => { + const symbolState = api.symbol('state'); + const UNRESOLVED = null; + const symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + let oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + const chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + const asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + const oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; + }); -/** - * @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 - */ -// load test related files into bundle in correct order + /** + * @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 + */ -/** - * @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 - */ -// load test related files into bundle + /** + * @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 + */ -}))); +})); +//# sourceMappingURL=zone-evergreen-testing-bundle-rollup.umd.js.map diff --git a/dist/zone-evergreen-testing-bundle.min.js b/dist/zone-evergreen-testing-bundle.min.js new file mode 100755 index 000000000..1919b4bb8 --- /dev/null +++ b/dist/zone-evergreen-testing-bundle.min.js @@ -0,0 +1,183 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; +/** + * @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(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const o=e.__Zone_symbol_prefix||"__zone_symbol__";function s(e){return o+e}const i=!0===e[s("forceDuplicateZoneCheck")];if(e.Zone){if(i||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class a{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==C.ZoneAwarePromise)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.)")}static get root(){let e=a.current;for(;e.parent;)e=e.parent;return e}static get current(){return j.zone}static get currentTask(){return I}static __load_patch(t,o){if(C.hasOwnProperty(t)){if(i)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const s="Zone:"+t;n(s),C[t]=o(e,a,O),r(s,s)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),r=this;return function(){return r.runGuarded(n,this,arguments,t)}}run(e,t,n,r){j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}}runGuarded(e,t=null,n,r){j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{j=j.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");if(e.state===T&&(e.type===D||e.type===Z))return;const r=e.state!=w;r&&e._transitionTo(w,v),e.runCount++;const o=I;I=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==T&&e.state!==P&&(e.type==D||e.data&&e.data.isPeriodic?r&&e._transitionTo(v,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(T,w,T))),j=j.parent,I=o}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;t;){if(t===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);t=t.parent}}e._transitionTo(b,T);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(P,b,T),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(v,b),e}scheduleMicroTask(e,t,n,r){return this.scheduleTask(new u(S,e,t,n,r,void 0))}scheduleMacroTask(e,t,n,r,o){return this.scheduleTask(new u(Z,e,t,n,r,o))}scheduleEventTask(e,t,n,r,o){return this.scheduleTask(new u(D,e,t,n,r,o))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");e._transitionTo(E,v,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(P,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(T,E),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let r=0;re.hasTask(n,r),onScheduleTask:(e,t,n,r)=>e.scheduleTask(n,r),onInvokeTask:(e,t,n,r,o,s)=>e.invokeTask(n,r,o,s),onCancelTask:(e,t,n,r)=>e.cancelTask(n,r)};class l{constructor(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._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const r=n&&n.onHasTask;(r||t&&t._hasTaskZS)&&(this._hasTaskZS=r?n:c,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=c,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=c,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=c,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new a(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,r,o){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,r,o):t.apply(n,r)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,r){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,r):t.callback.apply(n,r)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,r=n[e],o=n[e]=r+t;if(o<0)throw new Error("More tasks executed then were scheduled.");0!=r&&0!=o||this.hasTask(this.zone,{microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})}}class u{constructor(t,n,r,o,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=o,this.scheduleFn=s,this.cancelFn=i,this.callback=r;const a=this;this.invoke=t===D&&o&&o.useG?u.invokeTask:function(){return u.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&k(),z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(T,b)}_transitionTo(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(`${this.type} '${this.source}': can not transition to '${e}', expecting state '${t}'${n?" or '"+n+"'":""}, was '${this._state}'.`);this._state=e,e==T&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const h=s("setTimeout"),p=s("Promise"),d=s("then");let f,m=[],g=!1;function _(t){if(0===z&&0===m.length)if(f||e[p]&&(f=e[p].resolve(0)),f){let e=f[d];e||(e=f.then),e.call(f,k)}else e[h](k,0);t&&m.push(t)}function k(){if(!g){for(g=!0;m.length;){const e=m;m=[];for(let t=0;tj,onUnhandledError:A,microtaskDrainDone:A,scheduleMicroTask:_,showUncaughtError:()=>!a[s("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:A,patchMethod:()=>A,bindArguments:()=>[],patchThen:()=>A,patchMacroTask:()=>A,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(f=e.resolve(0))},patchEventPrototype:()=>A,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>A,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>A,wrapWithCurrentZone:()=>A,filterProperties:()=>[],attachOriginToPatched:()=>A,_redefineProperty:()=>A,patchCallbacks:()=>A};let j={parent:null,zone:new a(null,null)},I=null,z=0;function A(){}r("Zone","Zone"),e.Zone=a}(e), +/** + * @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.__load_patch("ZoneAwarePromise",(e,t,n)=>{const r=Object.getOwnPropertyDescriptor,o=Object.defineProperty,s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const 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)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){h(e)}}});const u=s("unhandledPromiseRejectionHandler");function h(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function p(e){return e&&e.then}function d(e){return e}function f(e){return A.reject(e)}const m=s("state"),g=s("value"),_=s("finally"),k=s("parentPromiseValue"),y=s("parentPromiseState"),T="Promise.then",b=null,v=!0,w=!1,E=0;function P(e,t){return n=>{try{C(e,t,n)}catch(t){C(e,!1,t)}}}const S=function(){let e=!1;return function t(n){return function(){e||(e=!0,n.apply(null,arguments))}}},Z="Promise resolved with itself",D=s("currentTaskTrace");function C(e,r,s){const a=S();if(e===s)throw new TypeError(Z);if(e[m]===b){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{C(e,!1,t)})(),e}if(r!==w&&s instanceof A&&s.hasOwnProperty(m)&&s.hasOwnProperty(g)&&s[m]!==b)j(s),C(e,s[m],s[g]);else if(r!==w&&"function"==typeof c)try{c.call(s,a(P(e,r)),a(P(e,!1)))}catch(t){a(()=>{C(e,!1,t)})()}else{e[m]=r;const a=e[g];if(e[g]=s,e[_]===_&&r===v&&(e[m]=e[y],e[g]=e[k]),r===w&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&o(s,D,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const r=e[g],o=!!n&&_===n[_];o&&(n[k]=r,n[y]=s);const a=t.run(i,void 0,o&&i!==f&&i!==d?[]:[r]);C(n,!0,a)}catch(e){C(n,!1,e)}},n)}const z="function ZoneAwarePromise() { [native code] }";class A{constructor(e){const t=this;if(!(t instanceof A))throw new Error("Must be an instanceof Promise.");t[m]=b,t[g]=[];try{e&&e(P(t,v),P(t,w))}catch(e){C(t,!1,e)}}static toString(){return z}static resolve(e){return C(new this(null),v,e)}static reject(e){return C(new this(null),w,e)}static race(e){let t,n,r=new this((e,r)=>{t=e,n=r});function o(e){t(e)}function s(e){n(e)}for(let t of e)p(t)||(t=this.resolve(t)),t.then(o,s);return r}static all(e){let t,n,r=new this((e,r)=>{t=e,n=r}),o=2,s=0;const i=[];for(let r of e){p(r)||(r=this.resolve(r));const e=s;r.then(n=>{i[e]=n,0==--o&&t(i)},n),o++,s++}return 0==(o-=2)&&t(i),r}get[Symbol.toStringTag](){return"Promise"}then(e,n){const r=new this.constructor(null),o=t.current;return this[m]==b?this[g].push(o,r,e,n):I(this,o,r,e,n),r}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[_]=_;const r=t.current;return this[m]==b?this[g].push(r,n,e,e):I(this,r,n,e,e),n}}A.resolve=A.resolve,A.reject=A.reject,A.race=A.race,A.all=A.all;const x=e[a]=e.Promise,R=t.__symbol__("ZoneAwarePromise");let F=r(e,"Promise");F&&!F.configurable||(F&&delete F.writable,F&&delete F.value,F||(F={configurable:!0,enumerable:!0}),F.get=function(){return e[R]?e[R]:e[a]},F.set=function(t){t===A?e[R]=t:(e[a]=t,t.prototype[c]||L(t),n.setNativePromise(t))},o(e,"Promise",F)),e.Promise=A;const M=s("thenPatched");function L(e){const t=e.prototype,n=r(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const o=t.then;t[c]=o,e.prototype.then=function(e,t){return new A((e,t)=>{o.call(this,e,t)}).then(e,t)},e[M]=!0}if(n.patchThen=L,x){L(x);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function H(e){return function(){let t=e.apply(this,arguments);if(t instanceof A)return t;let n=t.constructor;return n[M]||L(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,A}); +/** + * @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 t=Object.getOwnPropertyDescriptor,n=Object.defineProperty,r=Object.getPrototypeOf,o=Object.create,s=Array.prototype.slice,i="addEventListener",a="removeEventListener",c=Zone.__symbol__(i),l=Zone.__symbol__(a),u="true",h="false",p=Zone.__symbol__("");function d(e,t){return Zone.current.wrap(e,t)}function f(e,t,n,r,o){return Zone.current.scheduleMacroTask(e,t,n,r,o)}const m=Zone.__symbol__,g="undefined"!=typeof window,_=g?window:void 0,k=g&&_||"object"==typeof self&&self||global,y="removeAttribute",T=[null];function b(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=d(e[n],t+"_"+n));return e}function v(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const w="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,E=!("nw"in k)&&void 0!==k.process&&"[object process]"==={}.toString.call(k.process),P=!E&&!w&&!(!g||!_.HTMLElement),S=void 0!==k.process&&"[object process]"==={}.toString.call(k.process)&&!w&&!(!g||!_.HTMLElement),Z={},D=function(e){if(!(e=e||k.event))return;let t=Z[e.type];t||(t=Z[e.type]=m("ON_PROPERTY"+e.type));const n=this||e.target||k,r=n[t];let o;if(P&&n===_&&"error"===e.type){const t=e;!0===(o=r&&r.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(o=r&&r.apply(this,arguments))||o||e.preventDefault();return o};function C(e,r,o){let s=t(e,r);if(!s&&o&&t(o,r)&&(s={enumerable:!0,configurable:!0}),!s||!s.configurable)return;const i=m("on"+r+"patched");if(e.hasOwnProperty(i)&&e[i])return;delete s.writable,delete s.value;const a=s.get,c=s.set,l=r.substr(2);let u=Z[l];u||(u=Z[l]=m("ON_PROPERTY"+l)),s.set=function(t){let n=this;n||e!==k||(n=k),n&&(n[u]&&n.removeEventListener(l,D),c&&c.apply(n,T),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},s.get=function(){let t=this;if(t||e!==k||(t=k),!t)return null;const n=t[u];if(n)return n;if(a){let e=a&&a.call(this);if(e)return s.set.call(this,e),"function"==typeof t[y]&&t.removeAttribute(r),e}return null},n(e,r,s),e[i]=!0}function O(e,t,n){if(t)for(let r=0;r{const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!r||r.writable&&"function"==typeof r.set)&&(e[n]=t)},enumerable:!r||r.enumerable,configurable:!r||r.configurable})})}(a,s[n])}return a}function x(e,t,n){let r=null;function o(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},r.apply(t.target,t.args),e}r=A(e,t,e=>(function(t,r){const s=n(t,r);return s.cbIdx>=0&&"function"==typeof r[s.cbIdx]?f(s.name,r[s.cbIdx],s,o):e.apply(t,r)}))}function R(e,t){e[m("OriginalDelegate")]=t}let F=!1,M=!1;function L(){if(F)return M;F=!0;try{const e=_.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(M=!0)}catch(e){}return M} +/** + * @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.__load_patch("toString",e=>{const t=Function.prototype.toString,n=m("OriginalDelegate"),r=m("Promise"),o=m("Error"),s=function s(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[r];if(n)return t.call(n)}if(this===Error){const n=e[o];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}}); +/** + * @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 + */ +let H=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){H=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){H=!1}const q={useG:!0},N={},U={},G=new RegExp("^"+p+"(\\w+)(true|false)$"),W=m("propagationStopped");function $(e,t,n){const o=n&&n.add||i,s=n&&n.rm||a,c=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",d=m(o),f="."+o+":",g="prependListener",_="."+g+":",k=function(e,t,n){if(e.isRemoved)return;const r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=(e=>r.handleEvent(e)),e.originalDelegate=r),e.invoke(e,t,[n]);const o=e.options;o&&"object"==typeof o&&o.once&&t[s].call(t,n.type,e.originalDelegate?e.originalDelegate:e.callback,o)},y=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,r=n[N[t.type][h]];if(r)if(1===r.length)k(r[0],n,t);else{const e=r.slice();for(let r=0;r(function(t,n){t[W]=!0,e&&e.apply(t,n)}))} +/** + * @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 X(e,t,n,r,o){const s=Zone.__symbol__(r);if(t[s])return;const i=t[s]=t[r];t[r]=function(s,a,c){return a&&a.prototype&&o.forEach(function(t){const o=`${n}.${r}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,o),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],o))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],o))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[r],i)} +/** + * @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 K=Zone.__symbol__,V=Object[K("defineProperty")]=Object.defineProperty,Y=Object[K("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,J=Object.create,ee=K("unconfigurables");function te(e,t,n){const r=n.configurable;return oe(e,t,n=re(e,t,n),r)}function ne(e,t){return e&&e[ee]&&e[ee][t]}function re(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[ee]||Object.isFrozen(e)||V(e,ee,{writable:!0,value:{}}),e[ee]&&(e[ee][t]=!0)),n}function oe(e,t,n,r){try{return V(e,t,n)}catch(o){if(!n.configurable)throw o;void 0===r?delete n.configurable:n.configurable=r;try{return V(e,t,n)}catch(r){let o=null;try{o=JSON.stringify(n)}catch(e){o=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${o}' on object '${e}' and got error, giving up: ${r}`)}}} +/** + * @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 se=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],ie=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ae=["load"],ce=["blur","error","focus","load","resize","scroll","messageerror"],le=["bounce","finish","start"],ue=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],he=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],pe=["close","error","open","message"],de=["error","message"],fe=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"].concat(["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],["autocomplete","autocompleteerror"],["toggle"],["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],se,["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"]);function me(e,t,n){if(!n||0===n.length)return t;const r=n.filter(t=>t.target===e);if(!r||0===r.length)return t;const o=r[0].ignoreProperties;return t.filter(e=>-1===o.indexOf(e))}function ge(e,t,n,r){e&&O(e,me(e,t,n),r)}function _e(e,t){if(E&&!S)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(P){const e=window,t=function s(){try{const t=e.navigator.userAgent;if(-1!==t.indexOf("MSIE ")||-1!==t.indexOf("Trident/"))return!0}catch(e){}return!1}?[{target:e,ignoreProperties:["error"]}]:[];ge(e,fe.concat(["messageerror"]),o?o.concat(t):o,r(e)),ge(Document.prototype,fe,o),void 0!==e.SVGElement&&ge(e.SVGElement.prototype,fe,o),ge(Element.prototype,fe,o),ge(HTMLElement.prototype,fe,o),ge(HTMLMediaElement.prototype,ie,o),ge(HTMLFrameSetElement.prototype,se.concat(ce),o),ge(HTMLBodyElement.prototype,se.concat(ce),o),ge(HTMLFrameElement.prototype,ae,o),ge(HTMLIFrameElement.prototype,ae,o);const n=e.HTMLMarqueeElement;n&&ge(n.prototype,le,o);const s=e.Worker;s&&ge(s.prototype,de,o)}const i=t.XMLHttpRequest;i&&ge(i.prototype,ue,o);const a=t.XMLHttpRequestEventTarget;a&&ge(a&&a.prototype,ue,o),"undefined"!=typeof IDBIndex&&(ge(IDBIndex.prototype,he,o),ge(IDBRequest.prototype,he,o),ge(IDBOpenDBRequest.prototype,he,o),ge(IDBDatabase.prototype,he,o),ge(IDBTransaction.prototype,he,o),ge(IDBCursor.prototype,he,o)),n&&ge(WebSocket.prototype,pe,o)} +/** + * @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.__load_patch("util",(e,r,c)=>{c.patchOnProperties=O,c.patchMethod=A,c.bindArguments=b,c.patchMacroTask=x;const l=r.__symbol__("BLACK_LISTED_EVENTS"),f=r.__symbol__("UNPATCHED_EVENTS");e[f]&&(e[l]=e[f]),e[l]&&(r[l]=r[f]=e[l]),c.patchEventPrototype=B,c.patchEventTarget=$,c.isIEOrEdge=L,c.ObjectDefineProperty=n,c.ObjectGetOwnPropertyDescriptor=t,c.ObjectCreate=o,c.ArraySlice=s,c.patchClass=I,c.wrapWithCurrentZone=d,c.filterProperties=me,c.attachOriginToPatched=R,c._redefineProperty=te,c.patchCallbacks=X,c.getGlobalObjects=(()=>({globalSources:U,zoneSymbolEventNames:N,eventNames:fe,isBrowser:P,isMix:S,isNode:E,TRUE_STR:u,FALSE_STR:h,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:a}))}); +/** + * @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 + */ +/** + * @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 ke=m("zoneTask");function ye(e,t,n,r){let o=null,s=null;n+=r;const i={};function a(t){const n=t.data;return n.args[0]=function r(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[ke]=null))}},n.handleId=o.apply(e,n.args),t}function c(e){return s(e.data.handleId)}o=A(e,t+=r,n=>(function(o,s){if("function"==typeof s[0]){const e=f(t,s[0],{isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?s[1]||0:void 0,args:s},a,c);if(!e)return e;const n=e.data.handleId;return"number"==typeof n?i[n]=e:n&&(n[ke]=e),n&&n.ref&&n.unref&&"function"==typeof n.ref&&"function"==typeof n.unref&&(e.ref=n.ref.bind(n),e.unref=n.unref.bind(n)),"number"==typeof n||n?n:e}return n.apply(e,s)})),s=A(e,n,t=>(function(n,r){const o=r[0];let s;"number"==typeof o?s=i[o]:(s=o&&o[ke])||(s=o),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof o?delete i[o]:o&&(o[ke]=null),s.zone.cancelTask(s)):t.apply(e,r)}))} +/** + * @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 + */ +/** + * @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 Te(e,t){if(Zone[t.symbol("patchEventTarget")])return;const{eventNames:n,zoneSymbolEventNames:r,TRUE_STR:o,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{ye(e,"set","clear","Timeout"),ye(e,"set","clear","Interval"),ye(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{ye(e,"request","cancel","AnimationFrame"),ye(e,"mozRequest","mozCancel","AnimationFrame"),ye(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let r=0;r(function(r,s){return t.current.run(n,e,s,o)}))}),Zone.__load_patch("EventTarget",(e,t,n)=>{!function r(e,t){t.patchEventPrototype(e,t)}(e,n),Te(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),I("MutationObserver"),I("WebKitMutationObserver"),I("IntersectionObserver"),I("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{_e(n,e),function r(){Object.defineProperty=function(e,t,n){if(ne(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const r=n.configurable;return"prototype"!==t&&(n=re(e,t,n)),oe(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]=re(e,n,t[n])}),J(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=Y(e,t);return n&&ne(e,t)&&(n.configurable=!1),n}}()}),Zone.__load_patch("customElements",(e,t,n)=>{!function r(e,t){const{isBrowser:n,isMix:r}=t.getGlobalObjects();(n||r)&&e.customElements&&"customElements"in e&&t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function n(e){const n=e.XMLHttpRequest;if(!n)return;const h=n.prototype;let p=h[c],d=h[l];if(!p){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;p=e[c],d=e[l]}}const g="readystatechange",_="scheduled";function k(e){const n=e.data,o=n.target;o[i]=!1,o[u]=!1;const a=o[s];p||(p=o[c],d=o[l]),a&&d.call(o,g,a);const h=o[s]=(()=>{if(o.readyState===o.DONE)if(!n.aborted&&o[i]&&e.state===_){const r=o[t.__symbol__("loadfalse")];if(r&&r.length>0){const s=e.invoke;e.invoke=function(){const r=o[t.__symbol__("loadfalse")];for(let t=0;t(function(e,t){return e[o]=0==t[2],e[a]=t[1],b.apply(e,t)})),v=m("fetchTaskAborting"),w=m("fetchTaskScheduling"),E=A(h,"send",()=>(function(e,n){if(!0===t.current[w])return E.apply(e,n);if(e[o])return E.apply(e,n);{const t={target:e,url:e[a],isPeriodic:!1,args:n,aborted:!1},r=f("XMLHttpRequest.send",y,t,k,T);e&&!0===e[u]&&!t.aborted&&r.state===_&&r.invoke()}})),P=A(h,"abort",()=>(function(e,n){const o=function s(e){return e[r]}(e);if(o&&"string"==typeof o.type){if(null==o.cancelFn||o.data&&o.data.aborted)return;o.zone.cancelTask(o)}else if(!0===t.current[v])return P.apply(e,n)}))}(e);const r=m("xhrTask"),o=m("xhrSync"),s=m("xhrListener"),i=m("xhrScheduled"),a=m("xhrURL"),u=m("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&function n(e,r){const o=e.constructor.name;for(let n=0;n{const t=function(){return e.apply(this,b(arguments,o+"."+s))};return R(t,e),t})(i)}}}(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){Q(e,t).forEach(r=>{const o=e.PromiseRejectionEvent;if(o){const e=new o(t,{promise:n.promise,reason:n.rejection});r.invoke(e)}})}}e.PromiseRejectionEvent&&(t[m("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[m("rejectionHandledHandler")]=n("rejectionhandled"))}); +/** + * @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 + */ +/** + * @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 be="\n",ve={},we="STACKTRACE TRACKING",Ee="__SEP_TAG__";let Pe=Ee+"@[native]";class Se{constructor(){this.error=je(),this.timestamp=new Date}}function Ze(){return new Error(we)}function De(){try{throw Ze()}catch(e){return e}}const Ce=Ze(),Oe=De(),je=Ce.stack?Ze:Oe.stack?De:Ze;function Ie(e){return e.stack?e.stack.split(be):[]}function ze(e,t){let n=Ie(t);for(let t=0;t0){const e=Zone.currentTask;let t=e&&e.data&&e.data.__creationTrace__||[];(t=[new Se].concat(t)).length>this.longStackTraceLimit&&(t.length=this.longStackTraceLimit),r.data||(r.data={}),"eventTask"===r.type&&(r.data=Object.assign({},r.data)),r.data.__creationTrace__=t}return e.scheduleTask(n,r)},onHandleError:function(e,t,n,r){if(Error.stackTraceLimit>0){const e=Zone.currentTask||r.task;if(r instanceof Error&&e){const t=Ae(e.data&&e.data.__creationTrace__,r.stack);try{r.stack=r.longStack=t}catch(e){}}}return e.handleError(n,r)}},function xe(){if(Error.stackTraceLimit<=0)return;const e=[];!function e(t,n){n>0&&(t.push(Ie((new Se).error)),e(t,n-1))}(e,2);const t=e[0],n=e[1];for(let e=0;edelete this.properties[e]),this.propertyKeys=null,e&&e.properties&&(this.propertyKeys=Object.keys(e.properties),this.propertyKeys.forEach(t=>this.properties[t]=e.properties[t])),t&&this.lastTaskState&&(this.lastTaskState.macroTask||this.lastTaskState.microTask)&&(this.isNeedToTriggerHasTask=!0)}getDelegate(){return this._delegateSpec}resetDelegate(){this.getDelegate(),this.setDelegate(this.defaultSpecDelegate)}tryTriggerHasTask(e,t,n){this.isNeedToTriggerHasTask&&this.lastTaskState&&(this.isNeedToTriggerHasTask=!1,this.onHasTask(e,t,n,this.lastTaskState))}removeFromTasks(e){if(this.tasks)for(let t=0;t{const t=e.data&&Object.keys(e.data).map(t=>t+":"+e.data[t]).join(",");return`type: ${e.type}, source: ${e.source}, args: {${t}}`})+"]";return this.tasks=[],e}onFork(e,t,n,r){return this._delegateSpec&&this._delegateSpec.onFork?this._delegateSpec.onFork(e,t,n,r):e.fork(n,r)}onIntercept(e,t,n,r,o){return this._delegateSpec&&this._delegateSpec.onIntercept?this._delegateSpec.onIntercept(e,t,n,r,o):e.intercept(n,r,o)}onInvoke(e,t,n,r,o,s,i){return this.tryTriggerHasTask(e,t,n),this._delegateSpec&&this._delegateSpec.onInvoke?this._delegateSpec.onInvoke(e,t,n,r,o,s,i):e.invoke(n,r,o,s,i)}onHandleError(e,t,n,r){return this._delegateSpec&&this._delegateSpec.onHandleError?this._delegateSpec.onHandleError(e,t,n,r):e.handleError(n,r)}onScheduleTask(e,t,n,r){return"eventTask"!==r.type&&this.tasks.push(r),this._delegateSpec&&this._delegateSpec.onScheduleTask?this._delegateSpec.onScheduleTask(e,t,n,r):e.scheduleTask(n,r)}onInvokeTask(e,t,n,r,o,s){return"eventTask"!==r.type&&this.removeFromTasks(r),this.tryTriggerHasTask(e,t,n),this._delegateSpec&&this._delegateSpec.onInvokeTask?this._delegateSpec.onInvokeTask(e,t,n,r,o,s):e.invokeTask(n,r,o,s)}onCancelTask(e,t,n,r){return"eventTask"!==r.type&&this.removeFromTasks(r),this.tryTriggerHasTask(e,t,n),this._delegateSpec&&this._delegateSpec.onCancelTask?this._delegateSpec.onCancelTask(e,t,n,r):e.cancelTask(n,r)}onHasTask(e,t,n,r){this.lastTaskState=r,this._delegateSpec&&this._delegateSpec.onHasTask?this._delegateSpec.onHasTask(e,t,n,r):e.hasTask(n,r)}}Zone.ProxyZoneSpec=Re,Zone.SyncTestZoneSpec= +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +class{constructor(e){this.runZone=Zone.current,this.name="syncTestZone for "+e}onScheduleTask(e,t,n,r){switch(r.type){case"microTask":case"macroTask":throw new Error(`Cannot call ${r.source} from within a sync test.`);case"eventTask":r=e.scheduleTask(n,r)}return r}},(e=>{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;const t=Zone.SyncTestZoneSpec,n=Zone.ProxyZoneSpec;if(!t)throw new Error("Missing: SyncTestZoneSpec");if(!n)throw new Error("Missing: ProxyZoneSpec");const r=Zone.current,o=r.fork(new t("jasmine.describe")),s=Zone.__symbol__,i=!0===e[s("fakeAsyncDisablePatchingClock")],a=!i&&(!0===e[s("fakeAsyncPatchLock")]||!0===e[s("fakeAsyncAutoFakeAsyncWhenClockPatched")]);if(!0!==e[s("ignoreUnhandledRejection")]){const e=jasmine.GlobalErrors;e&&!jasmine[s("GlobalErrors")]&&(jasmine[s("GlobalErrors")]=e,jasmine.GlobalErrors=function(){const t=new e,n=t.install;return n&&!t[s("install")]&&(t[s("install")]=n,t.install=function(){const e=process.listeners("unhandledRejection"),t=n.apply(this,arguments);return process.removeAllListeners("unhandledRejection"),e&&e.forEach(e=>process.on("unhandledRejection",e)),t}),t})}const c=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(e=>{let t=c[e];c[e]=function(e,n){return t.call(this,e,function r(e){return function(){return o.run(e,this,arguments)}}(n))}}),["it","xit","fit"].forEach(e=>{let t=c[e];c[s(e)]=t,c[e]=function(e,n,r){return arguments[1]=u(n),t.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(e=>{let t=c[e];c[s(e)]=t,c[e]=function(e,n){return arguments[0]=u(e),t.apply(this,arguments)}}),!i){const e=jasmine[s("clock")]=jasmine.clock;jasmine.clock=function(){const t=e.apply(this,arguments);if(!t[s("patched")]){t[s("patched")]=s("patched");const e=t[s("tick")]=t.tick;t.tick=function(){const t=Zone.current.get("FakeAsyncTestZoneSpec");return t?t.tick.apply(t,arguments):e.apply(this,arguments)};const n=t[s("mockDate")]=t.mockDate;t.mockDate=function(){const e=Zone.current.get("FakeAsyncTestZoneSpec");if(e){const t=arguments.length>0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,t&&"function"==typeof t.getTime?[t.getTime()]:arguments)}return n.apply(this,arguments)},a&&["install","uninstall"].forEach(e=>{const n=t[s(e)]=t[e];t[e]=function(){if(!Zone.FakeAsyncTestZoneSpec)return n.apply(this,arguments);jasmine[s("clockInstalled")]="install"===e}})}return t}}function l(e,t,n,r){const o=!!jasmine[s("clockInstalled")],i=n.testProxyZone;if(o&&a){const t=Zone[Zone.__symbol__("fakeAsyncTest")];t&&"function"==typeof t.fakeAsync&&(e=t.fakeAsync(e))}return r?i.run(e,t,[r]):i.run(e,t)}function u(e){return e&&(e.length?function(t){return l(e,this,this.queueRunner,t)}:function(){return l(e,this,this.queueRunner)})}const h=jasmine.QueueRunner;jasmine.QueueRunner=function(t){function o(n){n.onComplete=(e=>()=>{this.testProxyZone=null,this.testProxyZoneSpec=null,r.scheduleMicroTask("jasmine.onComplete",e)})(n.onComplete);const o=e[Zone.__symbol__("setTimeout")],s=e[Zone.__symbol__("clearTimeout")];o&&(n.timeout={setTimeout:o||e.setTimeout,clearTimeout:s||e.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);const i=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){const t=this&&this.testProxyZoneSpec;if(t){const n=t.getAndClearPendingTasksInfo();try{e.message+=n}catch(e){}}}i&&i.call(this,e)},t.call(this,n)}return function(e,t){for(const n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);function n(){this.constructor=e}e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(o,t),o.prototype.execute=function(){let e=Zone.current,o=!1;for(;e;){if(e===r){o=!0;break}e=e.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new n,this.testProxyZone=r.fork(this.testProxyZoneSpec),Zone.currentTask?t.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",()=>h.prototype.execute.call(this))},o}(h)})(e), +/** + * @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(e){class t{constructor(t,n,r){this.finishCallback=t,this.failCallback=n,this._pendingMicroTasks=!1,this._pendingMacroTasks=!1,this._alreadyErrored=!1,this._isSync=!1,this.runZone=Zone.current,this.unresolvedChainedPromiseCount=0,this.supportWaitUnresolvedChainedPromise=!1,this.name="asyncTestZone for "+r,this.properties={AsyncTestZoneSpec:this},this.supportWaitUnresolvedChainedPromise=!0===e[Zone.__symbol__("supportWaitUnResolvedChainedPromise")]}isUnresolvedChainedPromisePending(){return this.unresolvedChainedPromiseCount>0}_finishCallbackIfDone(){this._pendingMicroTasks||this._pendingMacroTasks||this.supportWaitUnresolvedChainedPromise&&this.isUnresolvedChainedPromisePending()||this.runZone.run(()=>{setTimeout(()=>{this._alreadyErrored||this._pendingMicroTasks||this._pendingMacroTasks||this.finishCallback()},0)})}patchPromiseForTest(){if(!this.supportWaitUnresolvedChainedPromise)return;const e=Promise[Zone.__symbol__("patchPromiseForTest")];e&&e()}unPatchPromiseForTest(){if(!this.supportWaitUnresolvedChainedPromise)return;const e=Promise[Zone.__symbol__("unPatchPromiseForTest")];e&&e()}onScheduleTask(e,n,r,o){return"eventTask"!==o.type&&(this._isSync=!1),"microTask"===o.type&&o.data&&o.data instanceof Promise&&!0===o.data[t.symbolParentUnresolved]&&this.unresolvedChainedPromiseCount--,e.scheduleTask(r,o)}onInvokeTask(e,t,n,r,o,s){return"eventTask"!==r.type&&(this._isSync=!1),e.invokeTask(n,r,o,s)}onCancelTask(e,t,n,r){return"eventTask"!==r.type&&(this._isSync=!1),e.cancelTask(n,r)}onInvoke(e,t,n,r,o,s,i){try{return this._isSync=!0,e.invoke(n,r,o,s,i)}finally{this._isSync&&this._finishCallbackIfDone()}}onHandleError(e,t,n,r){return e.handleError(n,r)&&(this.failCallback(r),this._alreadyErrored=!0),!1}onHasTask(e,t,n,r){e.hasTask(n,r),"microTask"==r.change?(this._pendingMicroTasks=r.microTask,this._finishCallbackIfDone()):"macroTask"==r.change&&(this._pendingMacroTasks=r.macroTask,this._finishCallbackIfDone())}}t.symbolParentUnresolved=Zone.__symbol__("parentUnresolved"),Zone.AsyncTestZoneSpec=t}(e), +/** + * @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.__load_patch("asynctest",(e,t,n)=>{function r(e,n,r,o){const s=t.current,i=t.AsyncTestZoneSpec;if(void 0===i)throw new Error("AsyncTestZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/async-test.js");const a=t.ProxyZoneSpec;if(void 0===a)throw new Error("ProxyZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/proxy.js");const c=a.get();a.assertPresent();const l=t.current.getZoneWith("ProxyZoneSpec"),u=c.getDelegate();return l.parent.run(()=>{const e=new i(()=>{c.getDelegate()==e&&c.setDelegate(u),e.unPatchPromiseForTest(),s.run(()=>{r()})},t=>{c.getDelegate()==e&&c.setDelegate(u),e.unPatchPromiseForTest(),s.run(()=>{o(t)})},"test");c.setDelegate(e),e.patchPromiseForTest()}),t.current.runGuarded(e,n)}t[n.symbol("asyncTest")]=function t(n){return e.jasmine?function(e){e||((e=function(){}).fail=function(e){throw e}),r(n,this,e,t=>{if("string"==typeof t)return e.fail(new Error(t));e.fail(t)})}:function(){return new Promise((e,t)=>{r(n,this,e,t)})}}}), +/** + * @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(e){const t=e.Date;class n{constructor(){if(0===arguments.length){const e=new t;return e.setTime(n.now()),e}{const e=Array.prototype.slice.call(arguments);return new t(...e)}}static now(){const e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.getCurrentRealTime()+e.getCurrentTime():t.now.apply(this,arguments)}}n.UTC=t.UTC,n.parse=t.parse;const r={setTimeout:e.setTimeout,setInterval:e.setInterval,clearTimeout:e.clearTimeout,clearInterval:e.clearInterval};class o{constructor(){this._schedulerQueue=[],this._currentTime=0,this._currentRealTime=t.now()}getCurrentTime(){return this._currentTime}getCurrentRealTime(){return this._currentRealTime}setCurrentRealTime(e){this._currentRealTime=e}scheduleFunction(e,t,n=[],r=!1,s=!1,i=-1){let a=i<0?o.nextId++:i,c={endTime:this._currentTime+t,id:a,func:e,args:n,delay:t,isPeriodic:r,isRequestAnimationFrame:s},l=0;for(;l0&&!(r0;){if(++s>t)throw new Error("flush failed after reaching the limit of "+t+" tasks. Does your code use a polling timeout?");if(0===this._schedulerQueue.filter(e=>!e.isPeriodic&&!e.isRequestAnimationFrame).length)break;const r=this._schedulerQueue.shift();if(o=this._currentTime,this._currentTime=r.endTime,n&&n(this._currentTime-o),!r.func.apply(e,r.args))break}return this._currentTime-r}}o.nextId=1;class s{constructor(t,n=!1,r){this.trackPendingRequestAnimationFrame=n,this.macroTaskOptions=r,this._scheduler=new o,this._microtasks=[],this._lastError=null,this._uncaughtPromiseErrors=Promise[Zone.__symbol__("uncaughtPromiseErrors")],this.pendingPeriodicTimers=[],this.pendingTimers=[],this.patchDateLocked=!1,this.properties={FakeAsyncTestZoneSpec:this},this.name="fakeAsyncTestZone for "+t,this.macroTaskOptions||(this.macroTaskOptions=e[Zone.__symbol__("FakeAsyncTestMacroTask")])}static assertInZone(){if(null==Zone.current.get("FakeAsyncTestZoneSpec"))throw new Error("The code should be running in the fakeAsync zone to call this function")}_fnAndFlush(t,n){return(...r)=>(t.apply(e,r),null===this._lastError?(null!=n.onSuccess&&n.onSuccess.apply(e),this.flushMicrotasks()):null!=n.onError&&n.onError.apply(e),null===this._lastError)}static _removeTimer(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}_dequeueTimer(e){return()=>{s._removeTimer(this.pendingTimers,e)}}_requeuePeriodicTimer(e,t,n,r){return()=>{-1!==this.pendingPeriodicTimers.indexOf(r)&&this._scheduler.scheduleFunction(e,t,n,!0,!1,r)}}_dequeuePeriodicTimer(e){return()=>{s._removeTimer(this.pendingPeriodicTimers,e)}}_setTimeout(e,t,n,r=!0){let s=this._dequeueTimer(o.nextId),i=this._fnAndFlush(e,{onSuccess:s,onError:s}),a=this._scheduler.scheduleFunction(i,t,n,!1,!r);return r&&this.pendingTimers.push(a),a}_clearTimeout(e){s._removeTimer(this.pendingTimers,e),this._scheduler.removeScheduledFunctionWithId(e)}_setInterval(e,t,n){let r=o.nextId,s={onSuccess:null,onError:this._dequeuePeriodicTimer(r)},i=this._fnAndFlush(e,s);return s.onSuccess=this._requeuePeriodicTimer(i,t,n,r),this._scheduler.scheduleFunction(i,t,n,!0),this.pendingPeriodicTimers.push(r),r}_clearInterval(e){s._removeTimer(this.pendingPeriodicTimers,e),this._scheduler.removeScheduledFunctionWithId(e)}_resetLastErrorAndThrow(){let e=this._lastError||this._uncaughtPromiseErrors[0];throw this._uncaughtPromiseErrors.length=0,this._lastError=null,e}getCurrentTime(){return this._scheduler.getCurrentTime()}getCurrentRealTime(){return this._scheduler.getCurrentRealTime()}setCurrentRealTime(e){this._scheduler.setCurrentRealTime(e)}static patchDate(){e[Zone.__symbol__("disableDatePatching")]||e.Date!==n&&(e.Date=n,n.prototype=t.prototype,s.checkTimerPatch())}static resetDate(){e.Date===n&&(e.Date=t)}static checkTimerPatch(){e.setTimeout!==r.setTimeout&&(e.setTimeout=r.setTimeout,e.clearTimeout=r.clearTimeout),e.setInterval!==r.setInterval&&(e.setInterval=r.setInterval,e.clearInterval=r.clearInterval)}lockDatePatch(){this.patchDateLocked=!0,s.patchDate()}unlockDatePatch(){this.patchDateLocked=!1,s.resetDate()}tick(e=0,t){s.assertInZone(),this.flushMicrotasks(),this._scheduler.tick(e,t),null!==this._lastError&&this._resetLastErrorAndThrow()}flushMicrotasks(){for(s.assertInZone();this._microtasks.length>0;){let e=this._microtasks.shift();e.func.apply(e.target,e.args)}(()=>{(null!==this._lastError||this._uncaughtPromiseErrors.length)&&this._resetLastErrorAndThrow()})()}flush(e,t,n){s.assertInZone(),this.flushMicrotasks();const r=this._scheduler.flush(e,t,n);return null!==this._lastError&&this._resetLastErrorAndThrow(),r}onScheduleTask(e,t,n,r){switch(r.type){case"microTask":let t,o=r.data&&r.data.args;if(o){let e=r.data.cbIdx;"number"==typeof o.length&&o.length>e+1&&(t=Array.prototype.slice.call(o,e+1))}this._microtasks.push({func:r.invoke,args:t,target:r.data&&r.data.target});break;case"macroTask":switch(r.source){case"setTimeout":r.data.handleId=this._setTimeout(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"setImmediate":r.data.handleId=this._setTimeout(r.invoke,0,Array.prototype.slice.call(r.data.args,1));break;case"setInterval":r.data.handleId=this._setInterval(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"XMLHttpRequest.send":throw new Error("Cannot make XHRs from within a fake async test. Request URL: "+r.data.url);case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":r.data.handleId=this._setTimeout(r.invoke,16,r.data.args,this.trackPendingRequestAnimationFrame);break;default:const e=this.findMacroTaskOption(r);if(e){const t=r.data&&r.data.args,n=t&&t.length>1?t[1]:0;let o=e.callbackArgs?e.callbackArgs:t;e.isPeriodic?(r.data.handleId=this._setInterval(r.invoke,n,o),r.data.isPeriodic=!0):r.data.handleId=this._setTimeout(r.invoke,n,o);break}throw new Error("Unknown macroTask scheduled in fake async test: "+r.source)}break;case"eventTask":r=e.scheduleTask(n,r)}return r}onCancelTask(e,t,n,r){switch(r.source){case"setTimeout":case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":return this._clearTimeout(r.data.handleId);case"setInterval":return this._clearInterval(r.data.handleId);default:const t=this.findMacroTaskOption(r);if(t){const e=r.data.handleId;return t.isPeriodic?this._clearInterval(e):this._clearTimeout(e)}return e.cancelTask(n,r)}}onInvoke(e,t,n,r,o,i,a){try{return s.patchDate(),e.invoke(n,r,o,i,a)}finally{this.patchDateLocked||s.resetDate()}}findMacroTaskOption(e){if(!this.macroTaskOptions)return null;for(let t=0;t{const r=t&&t.FakeAsyncTestZoneSpec,o=t&&t.ProxyZoneSpec;let s=null;function i(){s&&s.unlockDatePatch(),s=null,o&&o.assertPresent().resetDelegate()}function a(){if(null==s&&null==(s=t.current.get("FakeAsyncTestZoneSpec")))throw new Error("The code should be running in the fakeAsync zone to call this function");return s}function c(){a().flushMicrotasks()}t[n.symbol("fakeAsyncTest")]={resetFakeAsyncZone:i,flushMicrotasks:c,discardPeriodicTasks:function l(){a().pendingPeriodicTimers.length=0},tick:function u(e=0){a().tick(e)},flush:function h(e){return a().flush(e)},fakeAsync:function p(e){return function(...n){const a=o.assertPresent();if(t.current.get("FakeAsyncTestZoneSpec"))throw new Error("fakeAsync() calls can not be nested");try{if(!s){if(a.getDelegate()instanceof r)throw new Error("fakeAsync() calls can not be nested");s=new r}let t;const o=a.getDelegate();a.setDelegate(s),s.lockDatePatch();try{t=e.apply(this,n),c()}finally{a.setDelegate(o)}if(s.pendingPeriodicTimers.length>0)throw new Error(`${s.pendingPeriodicTimers.length} `+"periodic timer(s) still in the queue.");if(s.pendingTimers.length>0)throw new Error(`${s.pendingTimers.length} timer(s) still in the queue.`);return t}finally{i()}}}}}), +/** + * @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.__load_patch("promisefortest",(e,t,n)=>{const r=n.symbol("state"),o=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function e(){let n=Promise[t.__symbol__("ZonePromiseThen")];n||(n=Promise[t.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){const e=n.apply(this,arguments);if(null===this[r]){const n=t.current.get("AsyncTestZoneSpec");n&&(n.unresolvedChainedPromiseCount++,e[o]=!0)}return e})},Promise[n.symbol("unPatchPromiseForTest")]=function e(){const n=Promise[t.__symbol__("ZonePromiseThen")];n&&(Promise.prototype.then=n,Promise[t.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone-evergreen.js b/dist/zone-evergreen.js old mode 100644 new mode 100755 index 691d2b91f..0bb08a6cc --- a/dist/zone-evergreen.js +++ b/dist/zone-evergreen.js @@ -5,3049 +5,3046 @@ * 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 */ -/** - * @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 Zone$1 = (function (global) { - const performance = global['performance']; - function mark(name) { - performance && performance['mark'] && performance['mark'](name); - } - function performanceMeasure(name, label) { - performance && performance['measure'] && performance['measure'](name, label); - } - mark('Zone'); - const checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; - if (global['Zone']) { - // if global['Zone'] already exists (maybe zone.js was already loaded or - // some other lib also registered a global object named Zone), we may need - // to throw an error, but sometimes user may not want this error. - // For example, - // we have two web pages, page1 includes zone.js, page2 doesn't. - // and the 1st time user load page1 and page2, everything work fine, - // but when user load page2 again, error occurs because global['Zone'] already exists. - // so we add a flag to let user choose whether to throw this error or not. - // By default, if existing Zone is from zone.js, we will not throw the error. - if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { - throw new Error('Zone already loaded.'); - } - else { - return global['Zone']; - } - } - class Zone { - constructor(parent, zoneSpec) { - this._parent = parent; - this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); - } - static assertZonePatched() { - if (global['Promise'] !== patches['ZoneAwarePromise']) { - throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + - 'has been overwritten.\n' + - 'Most likely cause is that a Promise polyfill has been loaded ' + - 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + - 'If you must load one, do so before loading zone.js.)'); - } - } - static get root() { - let zone = Zone.current; - while (zone.parent) { - zone = zone.parent; - } - return zone; - } - static get current() { - return _currentZoneFrame.zone; - } - static get currentTask() { - return _currentTask; - } - static __load_patch(name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); - } - } - else if (!global['__Zone_disable_' + name]) { - const perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - } - get parent() { - return this._parent; - } - get name() { - return this._name; - } - get(key) { - const zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - } - getZoneWith(key) { - let current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; - } - current = current._parent; - } - return null; - } - fork(zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - } - wrap(callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - const _callback = this._zoneDelegate.intercept(this, callback, source); - const zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); - }; - } - run(callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - } - runGuarded(callback, applyThis = null, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; - } - } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - } - runTask(task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - const reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - const previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; - } - try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); - } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; - } - } - } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); - } - else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); - } - } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - } - scheduleTask(task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - let newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${task.zone.name}`); - } - newZone = newZone.parent; - } - } - task._transitionTo(scheduling, notScheduled); - const zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - } - scheduleMicroTask(source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - } - scheduleMacroTask(source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - } - scheduleEventTask(source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - } - cancelTask(task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - } - _updateTaskCount(task, count) { - const zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (let i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); - } - } - } - Zone.__symbol__ = __symbol__; - const DELEGATE_ZS = { - name: '', - onHasTask: (delegate, _, target, hasTaskState) => delegate.hasTask(target, hasTaskState), - onScheduleTask: (delegate, _, target, task) => delegate.scheduleTask(target, task), - onInvokeTask: (delegate, _, target, task, applyThis, applyArgs) => delegate.invokeTask(target, task, applyThis, applyArgs), - onCancelTask: (delegate, _, target, task) => delegate.cancelTask(target, task) - }; - class ZoneDelegate { - constructor(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - const zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - const parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; - } - } - } - fork(targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - } - intercept(targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; - } - invoke(targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - } - handleError(targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - } - scheduleTask(targetZone, task) { - let returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); - } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; - } - else { - if (task.scheduleFn) { - task.scheduleFn(task); - } - else if (task.type == microTask) { - scheduleMicroTask(task); - } - else { - throw new Error('Task is missing scheduleFn.'); - } - } - return returnTask; - } - invokeTask(targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - } - cancelTask(targetZone, task) { - let value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); - } - value = task.cancelFn(task); - } - return value; - } - hasTask(targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback - try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); - } - catch (err) { - this.handleError(targetZone, err); - } - } - _updateTaskCount(type, count) { - const counts = this._taskCounts; - const prev = counts[type]; - const next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - const isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type - }; - this.hasTask(this.zone, isEmpty); - } - } - } - class ZoneTask { - constructor(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - const self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; - } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); - }; - } - } - static invokeTask(task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); - } - _numberOfNestedTaskFrames--; - } - } - get zone() { - return this._zone; - } - get state() { - return this._state; - } - cancelScheduleRequest() { - this._transitionTo(notScheduled, scheduling); - } - _transitionTo(toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; - } - } - else { - throw new Error(`${this.type} '${this.source}': can not transition to '${toState}', expecting state '${fromState1}'${fromState2 ? ' or \'' + fromState2 + '\'' : ''}, was '${this._state}'.`); - } - } - toString() { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); - } - } - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - toJSON() { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount - }; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - const symbolSetTimeout = __symbol__('setTimeout'); - const symbolPromise = __symbol__('Promise'); - const symbolThen = __symbol__('then'); - let _microTaskQueue = []; - let _isDrainingMicrotaskQueue = false; - let nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); - } - } - if (nativeMicroTaskQueuePromise) { - let nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); - } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - const queue = _microTaskQueue; - _microTaskQueue = []; - for (let i = 0; i < queue.length; i++) { - const task = queue[i]; - try { - task.zone.runTask(task, null, null); - } - catch (error) { - _api.onUnhandledError(error); - } - } - } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - const NO_ZONE = { name: 'NO ZONE' }; - const notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - const microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - const patches = {}; - const _api = { - symbol: __symbol__, - currentZoneFrame: () => _currentZoneFrame, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: () => !Zone[__symbol__('ignoreConsoleErrorUncaughtError')], - patchEventTarget: () => [], - patchOnProperties: noop, - patchMethod: () => noop, - bindArguments: () => [], - patchThen: () => noop, - patchMacroTask: () => noop, - setNativePromise: (NativePromise) => { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: () => noop, - isIEOrEdge: () => false, - getGlobalObjects: () => undefined, - ObjectDefineProperty: () => noop, - ObjectGetOwnPropertyDescriptor: () => undefined, - ObjectCreate: () => undefined, - ArraySlice: () => [], - patchClass: () => noop, - wrapWithCurrentZone: () => noop, - filterProperties: () => [], - attachOriginToPatched: () => noop, - _redefineProperty: () => noop, - patchCallbacks: () => noop - }; - let _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - let _currentTask = null; - let _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); -/** - * @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.__load_patch('ZoneAwarePromise', (global, Zone, api) => { - const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - const ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - const className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); - } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - const __symbol__ = api.symbol; - const _uncaughtPromiseErrors = []; - const symbolPromise = __symbol__('Promise'); - const symbolThen = __symbol__('then'); - const creationTrace = '__creationTrace__'; - api.onUnhandledError = (e) => { - if (api.showUncaughtError()) { - const rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); - } - else { - console.error(e); - } - } - }; - api.microtaskDrainDone = () => { - while (_uncaughtPromiseErrors.length) { - while (_uncaughtPromiseErrors.length) { - const uncaughtPromiseError = _uncaughtPromiseErrors.shift(); - try { - uncaughtPromiseError.zone.runGuarded(() => { - throw uncaughtPromiseError; - }); - } - catch (error) { - handleUnhandledRejection(error); - } - } - } - }; - const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - const handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); - } - } - catch (err) { - } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - const symbolState = __symbol__('state'); - const symbolValue = __symbol__('value'); - const symbolFinally = __symbol__('finally'); - const symbolParentPromiseValue = __symbol__('parentPromiseValue'); - const symbolParentPromiseState = __symbol__('parentPromiseState'); - const source = 'Promise.then'; - const UNRESOLVED = null; - const RESOLVED = true; - const REJECTED = false; - const REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return (v) => { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); - } - // Do not return value or you will break the Promise spec. - }; - } - const once = function () { - let wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; - } - wasCalled = true; - wrappedFunction.apply(null, arguments); - }; - }; - }; - const TYPE_ERROR = 'Promise resolved with itself'; - const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - const onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); - } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - let then = null; - try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; - } - } - catch (err) { - onceWrapper(() => { - resolvePromise(promise, false, err); - })(); - return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); - } - else if (state !== REJECTED && typeof then === 'function') { - try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); - } - catch (err) { - onceWrapper(() => { - resolvePromise(promise, false, err); - })(); - } - } - else { - promise[symbolState] = state; - const queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; - } - } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - const trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); - } - } - for (let i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); - } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; - try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); - } - catch (err) { - const error = err; - error.rejection = value; - error.promise = promise; - error.zone = Zone.current; - error.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error); - api.scheduleMicroTask(); // to make sure that it is running - } - } - } - } - // Resolving an already resolved promise is a noop. - return promise; - } - const REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - const handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); - } - } - catch (err) { - } - promise[symbolState] = REJECTED; - for (let i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); - } - } - } - } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - const promiseState = promise[symbolState]; - const delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, () => { - try { - const parentPromiseValue = promise[symbolValue]; - const isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); - } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); - } - }, chainPromise); - } - const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - class ZoneAwarePromise { - constructor(executor) { - const promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); - } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); - } - catch (error) { - resolvePromise(promise, false, error); - } - } - static toString() { - return ZONE_AWARE_PROMISE_TO_STRING; - } - static resolve(value) { - return resolvePromise(new this(null), RESOLVED, value); - } - static reject(error) { - return resolvePromise(new this(null), REJECTED, error); - } - static race(values) { - let resolve; - let reject; - let promise = new this((res, rej) => { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); - } - function onReject(error) { - reject(error); - } - for (let value of values) { - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - return promise; - } - static all(values) { - let resolve; - let reject; - let promise = new this((res, rej) => { - resolve = res; - reject = rej; - }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - let unresolvedCount = 2; - let valueIndex = 0; - const resolvedValues = []; - for (let value of values) { - if (!isThenable(value)) { - value = this.resolve(value); - } - const curValueIndex = valueIndex; - value.then((value) => { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; - } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - return promise; - } - get [Symbol.toStringTag]() { - return 'Promise'; - } - then(onFulfilled, onRejected) { - const chainPromise = new this.constructor(null); - const zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); - } - return chainPromise; - } - catch(onRejected) { - return this.then(null, onRejected); - } - finally(onFinally) { - const chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - const zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); - } - return chainPromise; - } - } - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - const NativePromise = global[symbolPromise] = global['Promise']; - const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; - } - desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; - } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); - } - }; - ObjectDefineProperty(global, 'Promise', desc); - } - global['Promise'] = ZoneAwarePromise; - const symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - const proto = Ctor.prototype; - const prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case - return; - } - const originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - const wrapped = new ZoneAwarePromise((resolve, reject) => { - originalThen.call(this, resolve, reject); - }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; - } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - let resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - let ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } - if (NativePromise) { - patchThen(NativePromise); - const fetch = global['fetch']; - if (typeof fetch == 'function') { - global[api.symbol('fetch')] = fetch; - global['fetch'] = zoneify(fetch); - } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { 'use strict'; -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -const ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -const ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ -const ObjectCreate = Object.create; -/** Array.prototype.slice */ -const ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -const ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -const REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -const ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -const TRUE_STR = 'true'; -/** false string const */ -const FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -const ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -const zoneSymbol = Zone.__symbol__; -const isWindowExists = typeof window !== 'undefined'; -const internalWindow = isWindowExists ? window : undefined; -const _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -const REMOVE_ATTRIBUTE = 'removeAttribute'; -const NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (let i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); - } - } - return args; -} -function patchPrototype(prototype, fnNames) { - const source = prototype.constructor['name']; - for (let i = 0; i < fnNames.length; i++) { - const name = fnNames[i]; - const delegate = prototype[name]; - if (delegate) { - const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name); - if (!isPropertyWritable(prototypeDesc)) { - continue; - } - prototype[name] = ((delegate) => { - const patched = function () { - return delegate.apply(this, bindArguments(arguments, source + '.' + name)); - }; - attachOriginToPatched(patched, delegate); - return patched; - })(delegate); - } - } -} -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -const isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -const isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -const isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -const isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -const zoneSymbolEventNames = {}; -const wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - let eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); - } - const target = this || event.target || _global; - const listener = target[eventNameSymbol]; - let result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - const errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); - } - } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); - } - } - return result; -}; -function patchProperty(obj, prop, prototype) { - let desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; - } - } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - const originalDescGet = desc.get; - const originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - const eventName = prop.substr(2); - let eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - let target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return; - } - let previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); - } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); - } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); - } - else { - target[eventNameSymbol] = null; - } - }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - let target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return null; - } - const listener = target[eventNameSymbol]; - if (listener) { - return listener; - } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - let value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); - } - return value; - } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (let i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } - } - else { - const onProperties = []; - for (const prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); - } - } - for (let j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); - } - } -} -const originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` -function patchClass(className) { - const OriginalClass = _global[className]; - if (!OriginalClass) - return; - // keep original class in global - _global[zoneSymbol(className)] = OriginalClass; - _global[className] = function () { - const a = bindArguments(arguments, className); - switch (a.length) { - case 0: - this[originalInstanceKey] = new OriginalClass(); - break; - case 1: - this[originalInstanceKey] = new OriginalClass(a[0]); - break; - case 2: - this[originalInstanceKey] = new OriginalClass(a[0], a[1]); - break; - case 3: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); - break; - case 4: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); - break; - default: - throw new Error('Arg list too long.'); - } - }; - // attach original delegate to patched function - attachOriginToPatched(_global[className], OriginalClass); - const instance = new OriginalClass(function () { }); - let prop; - for (prop in instance) { - // https://bugs.webkit.org/show_bug.cgi?id=44721 - if (className === 'XMLHttpRequest' && prop === 'responseBlob') - continue; - (function (prop) { - if (typeof instance[prop] === 'function') { - _global[className].prototype[prop] = function () { - return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); - }; - } - else { - ObjectDefineProperty(_global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); - // keep callback in wrapped function so we can - // use it in Function.prototype.toString to return - // the native one. - attachOriginToPatched(this[originalInstanceKey][prop], fn); - } - else { - this[originalInstanceKey][prop] = fn; - } - }, - get: function () { - return this[originalInstanceKey][prop]; - } - }); - } - }(prop)); - } - for (prop in OriginalClass) { - if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { - _global[className][prop] = OriginalClass[prop]; - } - } -} -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; - } - const symbols = Object.getOwnPropertySymbols(src); - symbols.forEach((symbol) => { - const desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; - } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -let shouldCopySymbolProperties = false; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; -function patchMethod(target, name, patchFn) { - let proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; - } - const delegateName = zoneSymbol(name); - let delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - const patchDelegate = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate(this, arguments); - }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); - } - } - } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - let setNative = null; - function scheduleTask(task) { - const data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; - } - setNative = patchMethod(obj, funcName, (delegate) => function (self, args) { - const meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); - } - else { - // cause an error by calling it directly. - return delegate.apply(self, 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 + */ + const Zone$1 = (function (global) { + const performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + const symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + const checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } + } + class Zone { + constructor(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); + } + static assertZonePatched() { + if (global['Promise'] !== patches['ZoneAwarePromise']) { + throw new Error('Zone.js has detected that ZoneAwarePromise `(window|global).Promise` ' + + 'has been overwritten.\n' + + 'Most likely cause is that a Promise polyfill has been loaded ' + + 'after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. ' + + 'If you must load one, do so before loading zone.js.)'); + } + } + static get root() { + let zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + } + static get current() { + return _currentZoneFrame.zone; + } + static get currentTask() { + return _currentTask; + } + static __load_patch(name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } + } + else if (!global['__Zone_disable_' + name]) { + const perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); + } + } + get parent() { + return this._parent; + } + get name() { + return this._name; + } + get(key) { + const zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + } + getZoneWith(key) { + let current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + } + fork(zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + } + wrap(callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + const _callback = this._zoneDelegate.intercept(this, callback, source); + const zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + } + run(callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + } + runGuarded(callback, applyThis = null, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + } + runTask(task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; + } + const reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + const previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } + } + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + } + scheduleTask(task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + let newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${task.zone.name}`); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + const zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + } + scheduleMicroTask(source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + } + scheduleMacroTask(source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + } + scheduleEventTask(source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + } + cancelTask(task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + } + _updateTaskCount(task, count) { + const zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (let i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + } + } + Zone.__symbol__ = __symbol__; + const DELEGATE_ZS = { + name: '', + onHasTask: (delegate, _, target, hasTaskState) => delegate.hasTask(target, hasTaskState), + onScheduleTask: (delegate, _, target, task) => delegate.scheduleTask(target, task), + onInvokeTask: (delegate, _, target, task, applyThis, applyArgs) => delegate.invokeTask(target, task, applyThis, applyArgs), + onCancelTask: (delegate, _, target, task) => delegate.cancelTask(target, task) + }; + class ZoneDelegate { + constructor(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + const zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + const parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; + } + } + } + fork(targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + } + intercept(targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + } + invoke(targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + } + handleError(targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + } + scheduleTask(targetZone, task) { + let returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); + } + else { + throw new Error('Task is missing scheduleFn.'); + } + } + return returnTask; + } + invokeTask(targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + } + cancelTask(targetZone, task) { + let value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + } + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); + } + return value; + } + hasTask(targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + } + _updateTaskCount(type, count) { + const counts = this._taskCounts; + const prev = counts[type]; + const next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + const isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + } + } + class ZoneTask { + constructor(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + const self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; + } + } + static invokeTask(task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + } + get zone() { + return this._zone; + } + get state() { + return this._state; + } + cancelScheduleRequest() { + this._transitionTo(notScheduled, scheduling); + } + _transitionTo(toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(`${this.type} '${this.source}': can not transition to '${toState}', expecting state '${fromState1}'${fromState2 ? ' or \'' + fromState2 + '\'' : ''}, was '${this._state}'.`); + } + } + toString() { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + } + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + toJSON() { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + const symbolSetTimeout = __symbol__('setTimeout'); + const symbolPromise = __symbol__('Promise'); + const symbolThen = __symbol__('then'); + let _microTaskQueue = []; + let _isDrainingMicrotaskQueue = false; + let nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + let nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } + } + task && _microTaskQueue.push(task); + } + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + const queue = _microTaskQueue; + _microTaskQueue = []; + for (let i = 0; i < queue.length; i++) { + const task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + const NO_ZONE = { name: 'NO ZONE' }; + const notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + const microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + const patches = {}; + const _api = { + symbol: __symbol__, + currentZoneFrame: () => _currentZoneFrame, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: () => !Zone[__symbol__('ignoreConsoleErrorUncaughtError')], + patchEventTarget: () => [], + patchOnProperties: noop, + patchMethod: () => noop, + bindArguments: () => [], + patchThen: () => noop, + patchMacroTask: () => noop, + setNativePromise: (NativePromise) => { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); + } + }, + patchEventPrototype: () => noop, + isIEOrEdge: () => false, + getGlobalObjects: () => undefined, + ObjectDefineProperty: () => noop, + ObjectGetOwnPropertyDescriptor: () => undefined, + ObjectCreate: () => undefined, + ArraySlice: () => [], + patchClass: () => noop, + wrapWithCurrentZone: () => noop, + filterProperties: () => [], + attachOriginToPatched: () => noop, + _redefineProperty: () => noop, + patchCallbacks: () => noop + }; + let _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + let _currentTask = null; + let _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} -let isDetectedIEOrEdge = false; -let ieOrEdge = false; -function isIE() { - try { - const ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { - return true; - } - } - catch (error) { - } - return false; -} -function isIEOrEdge() { - if (isDetectedIEOrEdge) { - return ieOrEdge; - } - isDetectedIEOrEdge = true; - try { - const ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { - ieOrEdge = true; - } - } - catch (error) { - } - return ieOrEdge; -} + /** + * @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.__load_patch('ZoneAwarePromise', (global, Zone, api) => { + const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + const ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + const className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + const __symbol__ = api.symbol; + const _uncaughtPromiseErrors = []; + const symbolPromise = __symbol__('Promise'); + const symbolThen = __symbol__('then'); + const creationTrace = '__creationTrace__'; + api.onUnhandledError = (e) => { + if (api.showUncaughtError()) { + const rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); + } + } + }; + api.microtaskDrainDone = () => { + while (_uncaughtPromiseErrors.length) { + while (_uncaughtPromiseErrors.length) { + const uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(() => { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + } + } + }; + const UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); + try { + const handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } + } + catch (err) { + } + } + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + const symbolState = __symbol__('state'); + const symbolValue = __symbol__('value'); + const symbolFinally = __symbol__('finally'); + const symbolParentPromiseValue = __symbol__('parentPromiseValue'); + const symbolParentPromiseState = __symbol__('parentPromiseState'); + const source = 'Promise.then'; + const UNRESOLVED = null; + const RESOLVED = true; + const REJECTED = false; + const REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return (v) => { + try { + resolvePromise(promise, state, v); + } + catch (err) { + resolvePromise(promise, false, err); + } + // Do not return value or you will break the Promise spec. + }; + } + const once = function () { + let wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; + }; + }; + const TYPE_ERROR = 'Promise resolved with itself'; + const CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + const onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + let then = null; + try { + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } + } + catch (err) { + onceWrapper(() => { + resolvePromise(promise, false, err); + })(); + return promise; + } + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { + try { + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + } + catch (err) { + onceWrapper(() => { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + const queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + const trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (let i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + const error = err; + error.rejection = value; + error.promise = promise; + error.zone = Zone.current; + error.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error); + api.scheduleMicroTask(); // to make sure that it is running + } + } + } + } + // Resolving an already resolved promise is a noop. + return promise; + } + const REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + const handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } + } + catch (err) { + } + promise[symbolState] = REJECTED; + for (let i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } + } + } + } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + const promiseState = promise[symbolState]; + const delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, () => { + try { + const parentPromiseValue = promise[symbolValue]; + const isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + const value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); + } + const ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + class ZoneAwarePromise { + constructor(executor) { + const promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } + } + static toString() { + return ZONE_AWARE_PROMISE_TO_STRING; + } + static resolve(value) { + return resolvePromise(new this(null), RESOLVED, value); + } + static reject(error) { + return resolvePromise(new this(null), REJECTED, error); + } + static race(values) { + let resolve; + let reject; + let promise = new this((res, rej) => { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (let value of values) { + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); + } + return promise; + } + static all(values) { + let resolve; + let reject; + let promise = new this((res, rej) => { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + let unresolvedCount = 2; + let valueIndex = 0; + const resolvedValues = []; + for (let value of values) { + if (!isThenable(value)) { + value = this.resolve(value); + } + const curValueIndex = valueIndex; + value.then((value) => { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + } + get [Symbol.toStringTag]() { + return 'Promise'; + } + then(onFulfilled, onRejected) { + const chainPromise = new this.constructor(null); + const zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; + } + catch(onRejected) { + return this.then(null, onRejected); + } + finally(onFinally) { + const chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + const zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + } + } + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + const NativePromise = global[symbolPromise] = global['Promise']; + const ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + let desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + const symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + const proto = Ctor.prototype; + const prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; + } + const originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + const wrapped = new ZoneAwarePromise((resolve, reject) => { + originalThen.call(this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; + } + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + let resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + let ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } + return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + const fetch = global['fetch']; + if (typeof fetch == 'function') { + global[api.symbol('fetch')] = fetch; + global['fetch'] = zoneify(fetch); + } + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', (global) => { - // patch Func.prototype.toString to let them look like native - const originalFunctionToString = Function.prototype.toString; - const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - const PROMISE_SYMBOL = zoneSymbol('Promise'); - const ERROR_SYMBOL = zoneSymbol('Error'); - const newFunctionToString = function toString() { - if (typeof this === 'function') { - const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); - } - else { - return Object.prototype.toString.call(originalDelegate); - } - } - if (this === Promise) { - const nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); - } - } - if (this === Error) { - const nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); - } - } - } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - const originalObjectToString = Object.prototype.toString; - const PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; - } - return originalObjectToString.call(this); - }; -}); + /** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + const ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + const ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + const ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Object.create */ + const ObjectCreate = Object.create; + /** Array.prototype.slice */ + const ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + const ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + const REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + const ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + const ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + const TRUE_STR = 'true'; + /** false string const */ + const FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + const ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); + } + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); + } + const zoneSymbol = Zone.__symbol__; + const isWindowExists = typeof window !== 'undefined'; + const internalWindow = isWindowExists ? window : undefined; + const _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + const REMOVE_ATTRIBUTE = 'removeAttribute'; + const NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (let i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; + } + function patchPrototype(prototype, fnNames) { + const source = prototype.constructor['name']; + for (let i = 0; i < fnNames.length; i++) { + const name = fnNames[i]; + const delegate = prototype[name]; + if (delegate) { + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name); + if (!isPropertyWritable(prototypeDesc)) { + continue; + } + prototype[name] = ((delegate) => { + const patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); + } + } + } + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; + } + if (propertyDesc.writable === false) { + return false; + } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); + } + const isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + const isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + const isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + const isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + const zoneSymbolEventNames = {}; + const wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + let eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + } + const target = this || event.target || _global; + const listener = target[eventNameSymbol]; + let result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + const errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } + } + return result; + }; + function patchProperty(obj, prop, prototype) { + let desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + const prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; + } + const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + const originalDescGet = desc.get; + const originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + const eventName = prop.substr(2); + let eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + let target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; + } + let previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); + } + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); + } + else { + target[eventNameSymbol] = null; + } + }; + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + let target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + const listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + let value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; + } + } + return null; + }; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; + } + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (let i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } + } + else { + const onProperties = []; + for (const prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); + } + } + for (let j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); + } + } + } + const originalInstanceKey = zoneSymbol('originalInstance'); + // wrap some native API on `window` + function patchClass(className) { + const OriginalClass = _global[className]; + if (!OriginalClass) + return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + const a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); + } + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + const instance = new OriginalClass(function () { }); + let prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; + } + }); + } + }(prop)); + } + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; + } + } + } + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; + } + const symbols = Object.getOwnPropertySymbols(src); + symbols.forEach((symbol) => { + const desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); + } + let shouldCopySymbolProperties = false; + function patchMethod(target, name, patchFn) { + let proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + const delegateName = zoneSymbol(name); + let delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + const desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + const patchDelegate = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } + } + } + return delegate; + } + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + let setNative = null; + function scheduleTask(task) { + const data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; + } + setNative = patchMethod(obj, funcName, (delegate) => function (self, args) { + const meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }); + } + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; + } + let isDetectedIEOrEdge = false; + let ieOrEdge = false; + function isIE() { + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } + } + catch (error) { + } + return false; + } + function isIEOrEdge() { + if (isDetectedIEOrEdge) { + return ieOrEdge; + } + isDetectedIEOrEdge = true; + try { + const ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { + ieOrEdge = true; + } + } + catch (error) { + } + return ieOrEdge; + } -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -let passiveSupported = false; -if (typeof window !== 'undefined') { - try { - const options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } - }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); - } - catch (err) { - passiveSupported = false; - } -} -// an identifier to tell ZoneTask do not create a new invoke closure -const OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -const zoneSymbolEventNames$1 = {}; -const globalSources = {}; -const EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -const IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - const LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - const REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - const PREPEND_EVENT_LISTENER = 'prependListener'; - const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - const invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { - return; - } - const delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = (event) => delegate.handleEvent(event); - task.originalDelegate = delegate; - } - // invoke static task.invoke - task.invoke(task, target, [event]); - const options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - const delegate = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options); - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = false - const globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - const target = this || event.target || _global; - const tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); - } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - const copyTasks = tasks.slice(); - for (let i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } - } - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - const globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - const target = this || event.target || _global; - const tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); - } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - const copyTasks = tasks.slice(); - for (let i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } - } - } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - let useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - const validateHandler = patchOptions && patchOptions.vh; - let checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; - } - let returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; - } - let proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; - } - if (!proto) { - return false; - } - if (proto[zoneSymbolAddEventListener]) { - return false; - } - const eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - const taskData = {}; - const nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - const nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - const nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - const nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - let nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } - } - const customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { - return; - } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); - }; - const customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - const symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - let symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; - } - const existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (let i = 0; i < existingTasks.length; i++) { - const existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } - break; - } - } - } - } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { - return; - } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - const customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - const customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - const customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - const customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - const compareTaskCallbackVsDelegate = function (task, delegate) { - const typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); - }; - const compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - const blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - const makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget = false, prepend = false) { - return function () { - const target = this || _global; - const eventName = arguments[0]; - let delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - let isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); - } - isHandleEvent = true; - } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { - return; - } - const options = arguments[2]; - if (blackListedEvents) { - // check black list - for (let i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { - return nativeListener.apply(this, arguments); - } - } - } - let capture; - let once = false; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - once = options ? !!options.once : false; - } - const zone = Zone.current; - const symbolEventNames = zoneSymbolEventNames$1[eventName]; - let symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - const falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - const trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - const symbol = ZONE_SYMBOL_PREFIX + falseEventName; - const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - let existingTasks = target[symbolEventName]; - let isExisting = false; - if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (let i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; - } - } - } - } - else { - existingTasks = target[symbolEventName] = []; - } - let source; - const constructorName = target.constructor['name']; - const targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - const task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); - } - else { - existingTasks.unshift(task); - } - if (returnTarget) { - return target; - } - }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - const target = this || _global; - const eventName = arguments[0]; - const options = arguments[2]; - let capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - } - const delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); - } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; - } - const symbolEventNames = zoneSymbolEventNames$1[eventName]; - let symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - const existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (let i = 0; i < existingTasks.length; i++) { - const existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; - } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; - } - return; - } - } - } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - const target = this || _global; - const eventName = arguments[0]; - const listeners = []; - const tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (let i = 0; i < tasks.length; i++) { - const task = tasks[i]; - let delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - const target = this || _global; - const eventName = arguments[0]; - if (!eventName) { - const keys = Object.keys(target); - for (let i = 0; i < keys.length; i++) { - const prop = keys[i]; - const match = EVENT_NAME_SYMBOL_REGX.exec(prop); - let evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); - } - } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - const symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - const symbolEventName = symbolEventNames[FALSE_STR]; - const symbolCaptureEventName = symbolEventNames[TRUE_STR]; - const tasks = target[symbolEventName]; - const captureTasks = target[symbolCaptureEventName]; - if (tasks) { - const removeTasks = tasks.slice(); - for (let i = 0; i < removeTasks.length; i++) { - const task = removeTasks[i]; - let delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); - } - } - if (captureTasks) { - const removeTasks = captureTasks.slice(); - for (let i = 0; i < removeTasks.length; i++) { - const task = removeTasks[i]; - let delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); - } - } - } - } - if (returnTarget) { - return this; - } - }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); - } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); - } - return true; - } - let results = []; - for (let i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); - } - return results; -} -function findEventTasks(target, eventName) { - const foundTasks = []; - for (let prop in target) { - const match = EVENT_NAME_SYMBOL_REGX.exec(prop); - let evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - const tasks = target[prop]; - if (tasks) { - for (let i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); - } - } - } - } - return foundTasks; -} -function patchEventPrototype(global, api) { - const Event = global['Event']; - if (Event && Event.prototype) { - api.patchMethod(Event.prototype, 'stopImmediatePropagation', (delegate) => function (self, args) { - self[IMMEDIATE_PROPAGATION_SYMBOL] = true; - // we need to call the native stopImmediatePropagation - // in case in some hybrid application, some part of - // application will be controlled by zone, some are not - delegate && delegate.apply(self, 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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', (global) => { + // patch Func.prototype.toString to let them look like native + const originalFunctionToString = Function.prototype.toString; + const ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + const PROMISE_SYMBOL = zoneSymbol('Promise'); + const ERROR_SYMBOL = zoneSymbol('Error'); + const newFunctionToString = function toString() { + if (typeof this === 'function') { + const originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } + } + if (this === Promise) { + const nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } + } + if (this === Error) { + const nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } + } + } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + const originalObjectToString = Object.prototype.toString; + const PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; + }); -/** - * @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 patchCallbacks(api, target, targetName, method, callbacks) { - const symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; - } - const nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - const source = `${targetName}.${method}::` + callback; - const prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); - api._redefineProperty(opts.prototype, callback, descriptor); - } - else if (prototype[callback]) { - prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); - } - } - else if (prototype[callback]) { - prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); - } - }); - } - return nativeDelegate.call(target, name, opts, options); - }; - api.attachOriginToPatched(target[method], nativeDelegate); -} + /** + * @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 + */ + let passiveSupported = false; + if (typeof window !== 'undefined') { + try { + const options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); + } + catch (err) { + passiveSupported = false; + } + } + // an identifier to tell ZoneTask do not create a new invoke closure + const OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true + }; + const zoneSymbolEventNames$1 = {}; + const globalSources = {}; + const EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + const IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + const ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + const REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + const LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + const REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + const zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + const ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + const PREPEND_EVENT_LISTENER = 'prependListener'; + const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + const invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; + } + const delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = (event) => delegate.handleEvent(event); + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + const options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + const delegate = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options); + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + const globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + const target = this || event.target || _global; + const tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + const copyTasks = tasks.slice(); + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + const globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + const target = this || event.target || _global; + const tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + const copyTasks = tasks.slice(); + for (let i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + let useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + const validateHandler = patchOptions && patchOptions.vh; + let checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + let returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + let proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + const eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + const taskData = {}; + const nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + const nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + const nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + const nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + let nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + const customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + const customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + const symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + let symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + const existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (let i = 0; i < existingTasks.length; i++) { + const existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } + } + } + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { + return; + } + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + const customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + const customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + const customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + const customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + const customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + const compareTaskCallbackVsDelegate = function (task, delegate) { + const typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + const compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + const blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + const makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget = false, prepend = false) { + return function () { + const target = this || _global; + const eventName = arguments[0]; + let delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + let isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { + return nativeListener.apply(this, arguments); + } + isHandleEvent = true; + } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + const options = arguments[2]; + if (blackListedEvents) { + // check black list + for (let i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + let capture; + let once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + const zone = Zone.current; + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + let symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + const falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + const trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + let existingTasks = target[symbolEventName]; + let isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (let i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + let source; + const constructorName = target.constructor['name']; + const targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + const data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + const task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + const options = arguments[2]; + let capture; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + } + const delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + let symbolEventName; + if (symbolEventNames) { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + const existingTasks = symbolEventName && target[symbolEventName]; + if (existingTasks) { + for (let i = 0; i < existingTasks.length; i++) { + const existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; + } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; + } + } + } + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + const listeners = []; + const tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (let i = 0; i < tasks.length; i++) { + const task = tasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); + } + return listeners; + }; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + const target = this || _global; + const eventName = arguments[0]; + if (!eventName) { + const keys = Object.keys(target); + for (let i = 0; i < keys.length; i++) { + const prop = keys[i]; + const match = EVENT_NAME_SYMBOL_REGX.exec(prop); + let evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); + } + } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); + } + else { + const symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + const symbolEventName = symbolEventNames[FALSE_STR]; + const symbolCaptureEventName = symbolEventNames[TRUE_STR]; + const tasks = target[symbolEventName]; + const captureTasks = target[symbolCaptureEventName]; + if (tasks) { + const removeTasks = tasks.slice(); + for (let i = 0; i < removeTasks.length; i++) { + const task = removeTasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + if (captureTasks) { + const removeTasks = captureTasks.slice(); + for (let i = 0; i < removeTasks.length; i++) { + const task = removeTasks[i]; + let delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + } + } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + } + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + } + return true; + } + let results = []; + for (let i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; + } + function findEventTasks(target, eventName) { + const foundTasks = []; + for (let prop in target) { + const match = EVENT_NAME_SYMBOL_REGX.exec(prop); + let evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + const tasks = target[prop]; + if (tasks) { + for (let i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } + } + } + } + return foundTasks; + } + function patchEventPrototype(global, api) { + const Event = global['Event']; + if (Event && Event.prototype) { + api.patchMethod(Event.prototype, 'stopImmediatePropagation', (delegate) => function (self, args) { + self[IMMEDIATE_PROPAGATION_SYMBOL] = true; + // we need to call the native stopImmediatePropagation + // in case in some hybrid application, some part of + // application will be controlled by zone, some are not + delegate && delegate.apply(self, 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 - */ -/* - * This is necessary for Chrome and Chrome mobile, to enable - * things like redefining `createdCallback` on an element. - */ -const zoneSymbol$1 = Zone.__symbol__; -const _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; -const _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = - Object.getOwnPropertyDescriptor; -const _create = Object.create; -const unconfigurablesKey = zoneSymbol$1('unconfigurables'); -function propertyPatch() { - Object.defineProperty = function (obj, prop, desc) { - if (isUnconfigurable(obj, prop)) { - throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); - } - const originalConfigurableFlag = desc.configurable; - if (prop !== 'prototype') { - desc = rewriteDescriptor(obj, prop, desc); - } - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); - }; - Object.defineProperties = function (obj, props) { - Object.keys(props).forEach(function (prop) { - Object.defineProperty(obj, prop, props[prop]); - }); - return obj; - }; - Object.create = function (obj, proto) { - if (typeof proto === 'object' && !Object.isFrozen(proto)) { - Object.keys(proto).forEach(function (prop) { - proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); - }); - } - return _create(obj, proto); - }; - Object.getOwnPropertyDescriptor = function (obj, prop) { - const desc = _getOwnPropertyDescriptor(obj, prop); - if (desc && isUnconfigurable(obj, prop)) { - desc.configurable = false; - } - return desc; - }; -} -function _redefineProperty(obj, prop, desc) { - const originalConfigurableFlag = desc.configurable; - desc = rewriteDescriptor(obj, prop, desc); - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); -} -function isUnconfigurable(obj, prop) { - return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; -} -function rewriteDescriptor(obj, prop, desc) { - // issue-927, if the desc is frozen, don't try to change the desc - if (!Object.isFrozen(desc)) { - desc.configurable = true; - } - if (!desc.configurable) { - // issue-927, if the obj is frozen, don't try to set the desc to obj - if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { - _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); - } - if (obj[unconfigurablesKey]) { - obj[unconfigurablesKey][prop] = true; - } - } - return desc; -} -function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - if (desc.configurable) { - // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's - // retry with the original flag value - if (typeof originalConfigurableFlag == 'undefined') { - delete desc.configurable; - } - else { - desc.configurable = originalConfigurableFlag; - } - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - let descJson = null; - try { - descJson = JSON.stringify(desc); - } - catch (error) { - descJson = desc.toString(); - } - console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${obj}' and got error, giving up: ${error}`); - } - } - else { - throw error; - } - } -} + /** + * @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 patchCallbacks(api, target, targetName, method, callbacks) { + const symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + const nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + const source = `${targetName}.${method}::` + callback; + const prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + const descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); + } -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -const globalEventHandlersEventNames = [ - 'abort', - 'animationcancel', - 'animationend', - 'animationiteration', - 'auxclick', - 'beforeinput', - 'blur', - 'cancel', - 'canplay', - 'canplaythrough', - 'change', - 'compositionstart', - 'compositionupdate', - 'compositionend', - 'cuechange', - 'click', - 'close', - 'contextmenu', - 'curechange', - 'dblclick', - 'drag', - 'dragend', - 'dragenter', - 'dragexit', - 'dragleave', - 'dragover', - 'drop', - 'durationchange', - 'emptied', - 'ended', - 'error', - 'focus', - 'focusin', - 'focusout', - 'gotpointercapture', - 'input', - 'invalid', - 'keydown', - 'keypress', - 'keyup', - 'load', - 'loadstart', - 'loadeddata', - 'loadedmetadata', - 'lostpointercapture', - 'mousedown', - 'mouseenter', - 'mouseleave', - 'mousemove', - 'mouseout', - 'mouseover', - 'mouseup', - 'mousewheel', - 'orientationchange', - 'pause', - 'play', - 'playing', - 'pointercancel', - 'pointerdown', - 'pointerenter', - 'pointerleave', - 'pointerlockchange', - 'mozpointerlockchange', - 'webkitpointerlockerchange', - 'pointerlockerror', - 'mozpointerlockerror', - 'webkitpointerlockerror', - 'pointermove', - 'pointout', - 'pointerover', - 'pointerup', - 'progress', - 'ratechange', - 'reset', - 'resize', - 'scroll', - 'seeked', - 'seeking', - 'select', - 'selectionchange', - 'selectstart', - 'show', - 'sort', - 'stalled', - 'submit', - 'suspend', - 'timeupdate', - 'volumechange', - 'touchcancel', - 'touchmove', - 'touchstart', - 'touchend', - 'transitioncancel', - 'transitionend', - 'waiting', - 'wheel' -]; -const documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', - 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', - 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange', 'resume' -]; -const windowEventNames = [ - 'absolutedeviceorientation', - 'afterinput', - 'afterprint', - 'appinstalled', - 'beforeinstallprompt', - 'beforeprint', - 'beforeunload', - 'devicelight', - 'devicemotion', - 'deviceorientation', - 'deviceorientationabsolute', - 'deviceproximity', - 'hashchange', - 'languagechange', - 'message', - 'mozbeforepaint', - 'offline', - 'online', - 'paint', - 'pageshow', - 'pagehide', - 'popstate', - 'rejectionhandled', - 'storage', - 'unhandledrejection', - 'unload', - 'userproximity', - 'vrdisplyconnected', - 'vrdisplaydisconnected', - 'vrdisplaypresentchange' -]; -const htmlElementEventNames = [ - 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', - 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', - 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' -]; -const mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; -const ieElementEventNames = [ - 'activate', - 'afterupdate', - 'ariarequest', - 'beforeactivate', - 'beforedeactivate', - 'beforeeditfocus', - 'beforeupdate', - 'cellchange', - 'controlselect', - 'dataavailable', - 'datasetchanged', - 'datasetcomplete', - 'errorupdate', - 'filterchange', - 'layoutcomplete', - 'losecapture', - 'move', - 'moveend', - 'movestart', - 'propertychange', - 'resizeend', - 'resizestart', - 'rowenter', - 'rowexit', - 'rowsdelete', - 'rowsinserted', - 'command', - 'compassneedscalibration', - 'deactivate', - 'help', - 'mscontentzoom', - 'msmanipulationstatechanged', - 'msgesturechange', - 'msgesturedoubletap', - 'msgestureend', - 'msgesturehold', - 'msgesturestart', - 'msgesturetap', - 'msgotpointercapture', - 'msinertiastart', - 'mslostpointercapture', - 'mspointercancel', - 'mspointerdown', - 'mspointerenter', - 'mspointerhover', - 'mspointerleave', - 'mspointermove', - 'mspointerout', - 'mspointerover', - 'mspointerup', - 'pointerout', - 'mssitemodejumplistitemremoved', - 'msthumbnailclick', - 'stop', - 'storagecommit' -]; -const webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; -const formEventNames = ['autocomplete', 'autocompleteerror']; -const detailEventNames = ['toggle']; -const frameEventNames = ['load']; -const frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; -const marqueeEventNames = ['bounce', 'finish', 'start']; -const XMLHttpRequestEventNames = [ - 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', - 'readystatechange' -]; -const IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; -const websocketEventNames = ['close', 'error', 'open', 'message']; -const workerEventNames = ['error', 'message']; -const eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); -function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties || ignoreProperties.length === 0) { - return onProperties; - } - const tip = ignoreProperties.filter(ip => ip.target === target); - if (!tip || tip.length === 0) { - return onProperties; - } - const targetIgnoreProperties = tip[0].ignoreProperties; - return onProperties.filter(op => targetIgnoreProperties.indexOf(op) === -1); -} -function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { - // check whether target is available, sometimes target will be undefined - // because different browser or some 3rd party plugin. - if (!target) { - return; - } - const filteredProperties = filterProperties(target, onProperties, ignoreProperties); - patchOnProperties(target, filteredProperties, prototype); -} -function propertyDescriptorPatch(api, _global) { - if (isNode && !isMix) { - return; - } - if (Zone[api.symbol('patchEvents')]) { - // events are already been patched by legacy patch. - return; - } - const supportsWebSocket = typeof WebSocket !== 'undefined'; - const ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - const internalWindow = window; - const ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement) { - patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); - } - const Worker = internalWindow['Worker']; - if (Worker) { - patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); - } - } - const XMLHttpRequest = _global['XMLHttpRequest']; - if (XMLHttpRequest) { - // XMLHttpRequest is not available in ServiceWorker, so we need to check here - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } -} + /** + * @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 + */ + /* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ + const zoneSymbol$1 = Zone.__symbol__; + const _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; + const _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; + const _create = Object.create; + const unconfigurablesKey = zoneSymbol$1('unconfigurables'); + function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + const originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); + } + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + const desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; + } + return desc; + }; + } + function _redefineProperty(obj, prop, desc) { + const originalConfigurableFlag = desc.configurable; + desc = rewriteDescriptor(obj, prop, desc); + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + } + function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; + } + function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; + } + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; + } + } + return desc; + } + function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; + } + else { + desc.configurable = originalConfigurableFlag; + } + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + let descJson = null; + try { + descJson = JSON.stringify(desc); + } + catch (error) { + descJson = desc.toString(); + } + console.log(`Attempting to configure '${prop}' with descriptor '${descJson}' on object '${obj}' and got error, giving up: ${error}`); + } + } + else { + throw error; + } + } + } -/** - * @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.__load_patch('util', (global, Zone, api) => { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to - // define which events will not be patched by `Zone.js`. - // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep - // the name consistent with angular repo. - // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for - // backwards compatibility. - const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); - if (global[SYMBOL_UNPATCHED_EVENTS]) { - global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; - } - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = - global[SYMBOL_BLACK_LISTED_EVENTS]; - } - api.patchEventPrototype = patchEventPrototype; - api.patchEventTarget = patchEventTarget; - api.isIEOrEdge = isIEOrEdge; - api.ObjectDefineProperty = ObjectDefineProperty; - api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; - api.ObjectCreate = ObjectCreate; - api.ArraySlice = ArraySlice; - api.patchClass = patchClass; - api.wrapWithCurrentZone = wrapWithCurrentZone; - api.filterProperties = filterProperties; - api.attachOriginToPatched = attachOriginToPatched; - api._redefineProperty = _redefineProperty; - api.patchCallbacks = patchCallbacks; - api.getGlobalObjects = () => ({ - globalSources, - zoneSymbolEventNames: zoneSymbolEventNames$1, - eventNames, - isBrowser, - isMix, - isNode, - TRUE_STR, - FALSE_STR, - ZONE_SYMBOL_PREFIX, - ADD_EVENT_LISTENER_STR, - REMOVE_EVENT_LISTENER_STR - }); -}); + /** + * @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 globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' + ]; + const documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' + ]; + const windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' + ]; + const htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' + ]; + const mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; + const ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' + ]; + const webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; + const formEventNames = ['autocomplete', 'autocompleteerror']; + const detailEventNames = ['toggle']; + const frameEventNames = ['load']; + const frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; + const marqueeEventNames = ['bounce', 'finish', 'start']; + const XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' + ]; + const IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; + const websocketEventNames = ['close', 'error', 'open', 'message']; + const workerEventNames = ['error', 'message']; + const eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); + function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + const tip = ignoreProperties.filter(ip => ip.target === target); + if (!tip || tip.length === 0) { + return onProperties; + } + const targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(op => targetIgnoreProperties.indexOf(op) === -1); + } + function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + const filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); + } + function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; + } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } + const supportsWebSocket = typeof WebSocket !== 'undefined'; + const ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + const internalWindow = window; + const ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + const HTMLMarqueeElement = internalWindow['HTMLMarqueeElement']; + if (HTMLMarqueeElement) { + patchFilteredProperties(HTMLMarqueeElement.prototype, marqueeEventNames, ignoreProperties); + } + const Worker = internalWindow['Worker']; + if (Worker) { + patchFilteredProperties(Worker.prototype, workerEventNames, ignoreProperties); + } + } + const XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + const XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + } + } -/** - * @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 - */ + /** + * @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.__load_patch('util', (global, Zone, api) => { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + const SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + const SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = () => ({ + globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames, + isBrowser, + isMix, + isNode, + TRUE_STR, + FALSE_STR, + ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR + }); + }); -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -const taskSymbol = zoneSymbol('zoneTask'); -function patchTimer(window, setName, cancelName, nameSuffix) { - let setNative = null; - let clearNative = null; - setName += nameSuffix; - cancelName += nameSuffix; - const tasksByHandleId = {}; - function scheduleTask(task) { - const data = task.data; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; - } - } - } - } - data.args[0] = timer; - data.handleId = setNative.apply(window, data.args); - return task; - } - function clearTask(task) { - return clearNative(task.data.handleId); - } - setNative = - patchMethod(window, setName, (delegate) => function (self, args) { - if (typeof args[0] === 'function') { - const options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - const task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); - if (!task) { - return task; - } - // Node.js must additionally support the ref and unref functions. - const handle = task.data.handleId; - if (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); - } - if (typeof handle === 'number' || handle) { - return handle; - } - return task; - } - else { - // cause an error by calling it directly. - return delegate.apply(window, args); - } - }); - clearNative = - patchMethod(window, cancelName, (delegate) => function (self, args) { - const id = args[0]; - let task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; - } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; - } - else if (id) { - id[taskSymbol] = null; - } - // 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 + */ -/** - * @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 patchCustomElements(_global, api) { - const { isBrowser, isMix } = api.getGlobalObjects(); - if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { - return; - } - const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); -} + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + function patchTimer(window, setName, cancelName, nameSuffix) { + let setNative = null; + let clearNative = null; + setName += nameSuffix; + cancelName += nameSuffix; + const tasksByHandleId = {}; + function scheduleTask(task) { + const data = task.data; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } + } + } + data.args[0] = timer; + data.handleId = setNative.apply(window, data.args); + return task; + } + function clearTask(task) { + return clearNative(task.data.handleId); + } + setNative = + patchMethod(window, setName, (delegate) => function (self, args) { + if (typeof args[0] === 'function') { + const options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + const task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); + if (!task) { + return task; + } + // Node.js must additionally support the ref and unref functions. + const handle = task.data.handleId; + if (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } + return task; + } + else { + // cause an error by calling it directly. + return delegate.apply(window, args); + } + }); + clearNative = + patchMethod(window, cancelName, (delegate) => function (self, args) { + const id = args[0]; + let task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // 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 - */ -function eventTargetPatch(_global, api) { - if (Zone[api.symbol('patchEventTarget')]) { - // EventTarget is already patched. - return; - } - const { eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX } = api.getGlobalObjects(); - // predefine all __zone_symbol__ + eventName + true/false string - for (let i = 0; i < eventNames.length; i++) { - const eventName = eventNames[i]; - const falseEventName = eventName + FALSE_STR; - const trueEventName = eventName + TRUE_STR; - const symbol = ZONE_SYMBOL_PREFIX + falseEventName; - const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - const EVENT_TARGET = _global['EventTarget']; - if (!EVENT_TARGET || !EVENT_TARGET.prototype) { - return; - } - api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); - return true; -} -function patchEvent(global, api) { - api.patchEventPrototype(global, api); -} + /** + * @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 patchCustomElements(_global, api) { + const { isBrowser, isMix } = api.getGlobalObjects(); + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { + return; + } + const callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); + } -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -Zone.__load_patch('legacy', (global) => { - const legacyPatch = global[Zone.__symbol__('legacyPatch')]; - if (legacyPatch) { - legacyPatch(); - } -}); -Zone.__load_patch('timers', (global) => { - const set = 'set'; - const clear = 'clear'; - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); -}); -Zone.__load_patch('requestAnimationFrame', (global) => { - patchTimer(global, 'request', 'cancel', 'AnimationFrame'); - patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); - patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); -}); -Zone.__load_patch('blocking', (global, Zone) => { - const blockingMethods = ['alert', 'prompt', 'confirm']; - for (let i = 0; i < blockingMethods.length; i++) { - const name = blockingMethods[i]; - patchMethod(global, name, (delegate, symbol, name) => { - return function (s, args) { - return Zone.current.run(delegate, global, args, name); - }; - }); - } -}); -Zone.__load_patch('EventTarget', (global, Zone, api) => { - patchEvent(global, api); - eventTargetPatch(global, api); - // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener - const XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { - api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); - } - patchClass('MutationObserver'); - patchClass('WebKitMutationObserver'); - patchClass('IntersectionObserver'); - patchClass('FileReader'); -}); -Zone.__load_patch('on_property', (global, Zone, api) => { - propertyDescriptorPatch(api, global); - propertyPatch(); -}); -Zone.__load_patch('customElements', (global, Zone, api) => { - patchCustomElements(global, api); -}); -Zone.__load_patch('XHR', (global, Zone) => { - // Treat XMLHttpRequest as a macrotask. - patchXHR(global); - const XHR_TASK = zoneSymbol('xhrTask'); - const XHR_SYNC = zoneSymbol('xhrSync'); - const XHR_LISTENER = zoneSymbol('xhrListener'); - const XHR_SCHEDULED = zoneSymbol('xhrScheduled'); - const XHR_URL = zoneSymbol('xhrURL'); - const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); - function patchXHR(window) { - const XMLHttpRequest = window['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker - return; - } - const XMLHttpRequestPrototype = XMLHttpRequest.prototype; - function findPendingTask(target) { - return target[XHR_TASK]; - } - let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - if (!oriAddListener) { - const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; - oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - } - } - const READY_STATE_CHANGE = 'readystatechange'; - const SCHEDULED = 'scheduled'; - function scheduleTask(task) { - const data = task.data; - const target = data.target; - target[XHR_SCHEDULED] = false; - target[XHR_ERROR_BEFORE_SCHEDULED] = false; - // remove existing event listener - const listener = target[XHR_LISTENER]; - if (!oriAddListener) { - oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - } - if (listener) { - oriRemoveListener.call(target, READY_STATE_CHANGE, listener); - } - const newListener = target[XHR_LISTENER] = () => { - if (target.readyState === target.DONE) { - // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with - // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { - // check whether the xhr has registered onload listener - // if that is the case, the task should invoke after all - // onload listeners finish. - const loadTasks = target['__zone_symbol__loadfalse']; - if (loadTasks && loadTasks.length > 0) { - const oriInvoke = task.invoke; - task.invoke = function () { - // need to load the tasks again, because in other - // load listener, they may remove themselves - const loadTasks = target['__zone_symbol__loadfalse']; - for (let i = 0; i < loadTasks.length; i++) { - if (loadTasks[i] === task) { - loadTasks.splice(i, 1); - } - } - if (!data.aborted && task.state === SCHEDULED) { - oriInvoke.call(task); - } - }; - loadTasks.push(task); - } - else { - task.invoke(); - } - } - else if (!data.aborted && target[XHR_SCHEDULED] === false) { - // error occurs when xhr.send() - target[XHR_ERROR_BEFORE_SCHEDULED] = true; - } - } - }; - oriAddListener.call(target, READY_STATE_CHANGE, newListener); - const storedTask = target[XHR_TASK]; - if (!storedTask) { - target[XHR_TASK] = task; - } - sendNative.apply(target, data.args); - target[XHR_SCHEDULED] = true; - return task; - } - function placeholderCallback() { } - function clearTask(task) { - const data = task.data; - // Note - ideally, we would call data.target.removeEventListener here, but it's too late - // to prevent it from firing. So instead, we store info for the event listener. - data.aborted = true; - return abortNative.apply(data.target, data.args); - } - const openNative = patchMethod(XMLHttpRequestPrototype, 'open', () => function (self, args) { - self[XHR_SYNC] = args[2] == false; - self[XHR_URL] = args[1]; - return openNative.apply(self, args); - }); - const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - const fetchTaskAborting = zoneSymbol('fetchTaskAborting'); - const fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); - const sendNative = patchMethod(XMLHttpRequestPrototype, 'send', () => function (self, args) { - if (Zone.current[fetchTaskScheduling] === true) { - // a fetch is scheduling, so we are using xhr to polyfill fetch - // and because we already schedule macroTask for fetch, we should - // not schedule a macroTask for xhr again - return sendNative.apply(self, args); - } - 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 { - const options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; - const task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); - if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && - task.state === SCHEDULED) { - // xhr request throw error when send - // we should invoke task instead of leaving a scheduled - // pending macroTask - task.invoke(); - } - } - }); - const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function (self, args) { - const task = findPendingTask(self); - if (task && typeof task.type == 'string') { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && task.data.aborted)) { - return; - } - task.zone.cancelTask(task); - } - else if (Zone.current[fetchTaskAborting] === true) { - // the abort is called from fetch polyfill, we need to call native abort of XHR. - return abortNative.apply(self, args); - } - // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no - // task - // to cancel. Do nothing. - }); - } -}); -Zone.__load_patch('geolocation', (global) => { - /// GEO_LOCATION - if (global['navigator'] && global['navigator'].geolocation) { - patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); - } -}); -Zone.__load_patch('PromiseRejectionEvent', (global, Zone) => { - // handle unhandled promise rejection - function findPromiseRejectionHandler(evtName) { - return function (e) { - const eventTasks = findEventTasks(global, evtName); - eventTasks.forEach(eventTask => { - // windows has added unhandledrejection event listener - // trigger the event listener - const PromiseRejectionEvent = global['PromiseRejectionEvent']; - if (PromiseRejectionEvent) { - const evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); - eventTask.invoke(evt); - } - }); - }; - } - if (global['PromiseRejectionEvent']) { - Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = - findPromiseRejectionHandler('unhandledrejection'); - Zone[zoneSymbol('rejectionHandledHandler')] = - findPromiseRejectionHandler('rejectionhandled'); - } -}); + /** + * @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 eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } + const { eventNames, zoneSymbolEventNames, TRUE_STR, FALSE_STR, ZONE_SYMBOL_PREFIX } = api.getGlobalObjects(); + // predefine all __zone_symbol__ + eventName + true/false string + for (let i = 0; i < eventNames.length; i++) { + const eventName = eventNames[i]; + const falseEventName = eventName + FALSE_STR; + const trueEventName = eventName + TRUE_STR; + const symbol = ZONE_SYMBOL_PREFIX + falseEventName; + const symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + const EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; + } + function patchEvent(global, api) { + api.patchEventPrototype(global, api); + } -/** - * @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 - */ + /** + * @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.__load_patch('legacy', (global) => { + const legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } + }); + Zone.__load_patch('timers', (global) => { + const set = 'set'; + const clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + }); + Zone.__load_patch('requestAnimationFrame', (global) => { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); + }); + Zone.__load_patch('blocking', (global, Zone) => { + const blockingMethods = ['alert', 'prompt', 'confirm']; + for (let i = 0; i < blockingMethods.length; i++) { + const name = blockingMethods[i]; + patchMethod(global, name, (delegate, symbol, name) => { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); + } + }); + Zone.__load_patch('EventTarget', (global, Zone, api) => { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + const XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); + }); + Zone.__load_patch('on_property', (global, Zone, api) => { + propertyDescriptorPatch(api, global); + propertyPatch(); + }); + Zone.__load_patch('customElements', (global, Zone, api) => { + patchCustomElements(global, api); + }); + Zone.__load_patch('XHR', (global, Zone) => { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + const XHR_TASK = zoneSymbol('xhrTask'); + const XHR_SYNC = zoneSymbol('xhrSync'); + const XHR_LISTENER = zoneSymbol('xhrListener'); + const XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + const XHR_URL = zoneSymbol('xhrURL'); + const XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + const XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; + } + const XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; + } + let oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + let oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + const XMLHttpRequestEventTarget = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + const XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + const READY_STATE_CHANGE = 'readystatechange'; + const SCHEDULED = 'scheduled'; + function scheduleTask(task) { + const data = task.data; + const target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + const listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + const newListener = target[XHR_LISTENER] = () => { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + const loadTasks = target[Zone.__symbol__('loadfalse')]; + if (loadTasks && loadTasks.length > 0) { + const oriInvoke = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + const loadTasks = target[Zone.__symbol__('loadfalse')]; + for (let i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } + } + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } + } + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; + } + } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + const storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; + } + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; + } + function placeholderCallback() { } + function clearTask(task) { + const data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + const openNative = patchMethod(XMLHttpRequestPrototype, 'open', () => function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }); + const XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + const fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + const fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + const sendNative = patchMethod(XMLHttpRequestPrototype, 'send', () => function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + 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 { + const options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + const task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } + } + }); + const abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', () => function (self, args) { + const task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); + } + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }); + } + }); + Zone.__load_patch('geolocation', (global) => { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); + } + }); + Zone.__load_patch('PromiseRejectionEvent', (global, Zone) => { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + const eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(eventTask => { + // windows has added unhandledrejection event listener + // trigger the event listener + const PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + const evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; + } + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); + } + }); + + /** + * @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 + */ + +})); +//# sourceMappingURL=zone-evergreen-rollup.umd.js.map diff --git a/dist/zone-evergreen.min.js b/dist/zone-evergreen.min.js old mode 100644 new mode 100755 index 999a289ac..bbf2a240a --- a/dist/zone-evergreen.min.js +++ b/dist/zone-evergreen.min.js @@ -1 +1,105 @@ -const Zone$1=function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(r||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class s{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new a(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=s.current;for(;e.parent;)e=e.parent;return e}static get current(){return D.zone}static get currentTask(){return z}static __load_patch(t,i){if(P.hasOwnProperty(t)){if(r)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const r="Zone:"+t;n(r),P[t]=i(e,s,N),o(r,r)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){D={parent:D,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{D=D.parent}}runGuarded(e,t=null,n,o){D={parent:D,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{D=D.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state===y&&(e.type===w||e.type===O))return;const o=e.state!=T;o&&e._transitionTo(T,b),e.runCount++;const r=z;z=e,D={parent:D,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==y&&e.state!==v&&(e.type==w||e.data&&e.data.isPeriodic?o&&e._transitionTo(b,T):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(y,T,y))),D=D.parent,z=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;t;){if(t===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);t=t.parent}}e._transitionTo(E,y);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(v,E,y),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==E&&e._transitionTo(b,E),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new c(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new c(O,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new c(w,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(k,b,T);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(v,k),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(y,k),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class a{constructor(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._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask,r=t&&t._hasTaskZS;(o||r)&&(this._hasTaskZS=o?n:i,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=i,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=i,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=i,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new s(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");_(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");if(0==o||0==r){const t={microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,t)}}}class c{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;t===w&&r&&r.useG?this.invoke=c.invokeTask:this.invoke=function(){return c.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),Z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==Z&&m(),Z--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(y,E)}_transitionTo(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(`${this.type} '${this.source}': can not transition to '${e}', expecting state '${t}'${n?" or '"+n+"'":""}, was '${this._state}'.`);this._state=e,e==y&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const l=R("setTimeout"),u=R("Promise"),p=R("then");let h,f=[],d=!1;function _(t){if(0===Z&&0===f.length)if(h||e[u]&&(h=e[u].resolve(0)),h){let e=h[p];e||(e=h.then),e.call(h,m)}else e[l](m,0);t&&f.push(t)}function m(){if(!d){for(d=!0;f.length;){const e=f;f=[];for(let t=0;tD,onUnhandledError:I,microtaskDrainDone:I,scheduleMicroTask:_,showUncaughtError:()=>!s[R("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:I,patchMethod:()=>I,bindArguments:()=>[],patchThen:()=>I,patchMacroTask:()=>I,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(h=e.resolve(0))},patchEventPrototype:()=>I,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>I,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>I,wrapWithCurrentZone:()=>I,filterProperties:()=>[],attachOriginToPatched:()=>I,_redefineProperty:()=>I,patchCallbacks:()=>I};let D={parent:null,zone:new s(null,null)},z=null,Z=0;function I(){}function R(e){return"__zone_symbol__"+e}return o("Zone","Zone"),e.Zone=s}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);Zone.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty;const s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const 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)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){p(e)}}});const u=s("unhandledPromiseRejectionHandler");function p(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function h(e){return e&&e.then}function f(e){return e}function d(e){return M.reject(e)}const _=s("state"),m=s("value"),g=s("finally"),y=s("parentPromiseValue"),E=s("parentPromiseState"),b="Promise.then",T=null,k=!0,v=!1,S=0;function O(e,t){return n=>{try{D(e,t,n)}catch(t){D(e,!1,t)}}}const w=function(){let e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},P="Promise resolved with itself",N=s("currentTaskTrace");function D(e,o,s){const a=w();if(e===s)throw new TypeError(P);if(e[_]===T){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{D(e,!1,t)})(),e}if(o!==v&&s instanceof M&&s.hasOwnProperty(_)&&s.hasOwnProperty(m)&&s[_]!==T)Z(s),D(e,s[_],s[m]);else if(o!==v&&"function"==typeof c)try{c.call(s,a(O(e,o)),a(O(e,!1)))}catch(t){a(()=>{D(e,!1,t)})()}else{e[_]=o;const a=e[m];if(e[m]=s,e[g]===g&&o===k&&(e[_]=e[E],e[m]=e[y]),o===v&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,N,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[m],r=n&&g===n[g];r&&(n[y]=o,n[E]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);D(n,!0,a)}catch(e){D(n,!1,e)}},n)}const R="function ZoneAwarePromise() { [native code] }";class M{constructor(e){const t=this;if(!(t instanceof M))throw new Error("Must be an instanceof Promise.");t[_]=T,t[m]=[];try{e&&e(O(t,k),O(t,v))}catch(e){D(t,!1,e)}}static toString(){return R}static resolve(e){return D(new this(null),k,e)}static reject(e){return D(new this(null),v,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)h(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){h(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0===--r&&t(i)},n),r++,s++}return 0===(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[_]==T?this[m].push(r,o,e,n):I(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[g]=g;const o=t.current;return this[_]==T?this[m].push(o,n,e,e):I(this,o,n,e,e),n}}M.resolve=M.resolve,M.reject=M.reject,M.race=M.race,M.all=M.all;const j=e[a]=e.Promise,C=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[C]?e[C]:e[a]},L.set=function(t){t===M?e[C]=t:(e[a]=t,t.prototype[c]||F(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=M;const A=s("thenPatched");function F(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new M((e,t)=>{r.call(this,e,t)}).then(e,t)},e[A]=!0}if(n.patchThen=F,j){F(j);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function(e){return function(){let t=e.apply(this,arguments);if(t instanceof M)return t;let n=t.constructor;return n[A]||F(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,M});const ObjectGetOwnPropertyDescriptor=Object.getOwnPropertyDescriptor,ObjectDefineProperty=Object.defineProperty,ObjectGetPrototypeOf=Object.getPrototypeOf,ObjectCreate=Object.create,ArraySlice=Array.prototype.slice,ADD_EVENT_LISTENER_STR="addEventListener",REMOVE_EVENT_LISTENER_STR="removeEventListener",ZONE_SYMBOL_ADD_EVENT_LISTENER=Zone.__symbol__(ADD_EVENT_LISTENER_STR),ZONE_SYMBOL_REMOVE_EVENT_LISTENER=Zone.__symbol__(REMOVE_EVENT_LISTENER_STR),TRUE_STR="true",FALSE_STR="false",ZONE_SYMBOL_PREFIX="__zone_symbol__";function wrapWithCurrentZone(e,t){return Zone.current.wrap(e,t)}function scheduleMacroTaskWithCurrentZone(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const zoneSymbol=Zone.__symbol__,isWindowExists="undefined"!=typeof window,internalWindow=isWindowExists?window:void 0,_global=isWindowExists&&internalWindow||"object"==typeof self&&self||global,REMOVE_ATTRIBUTE="removeAttribute",NULL_ON_PROP_VALUE=[null];function bindArguments(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=wrapWithCurrentZone(e[n],t+"_"+n));return e}function patchPrototype(e,t){const n=e.constructor.name;for(let o=0;o{const t=function(){return e.apply(this,bindArguments(arguments,n+"."+r))};return attachOriginToPatched(t,e),t})(s)}}}function isPropertyWritable(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const isWebWorker="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,isNode=!("nw"in _global)&&void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process),isBrowser=!isNode&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),isMix=void 0!==_global.process&&"[object process]"==={}.toString.call(_global.process)&&!isWebWorker&&!(!isWindowExists||!internalWindow.HTMLElement),zoneSymbolEventNames={},wrapFn=function(e){if(!(e=e||_global.event))return;let t=zoneSymbolEventNames[e.type];t||(t=zoneSymbolEventNames[e.type]=zoneSymbol("ON_PROPERTY"+e.type));const n=this||e.target||_global,o=n[t];let r;if(isBrowser&&n===internalWindow&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function patchProperty(e,t,n){let o=ObjectGetOwnPropertyDescriptor(e,t);if(!o&&n){ObjectGetOwnPropertyDescriptor(n,t)&&(o={enumerable:!0,configurable:!0})}if(!o||!o.configurable)return;const r=zoneSymbol("on"+t+"patched");if(e.hasOwnProperty(r)&&e[r])return;delete o.writable,delete o.value;const s=o.get,i=o.set,a=t.substr(2);let c=zoneSymbolEventNames[a];c||(c=zoneSymbolEventNames[a]=zoneSymbol("ON_PROPERTY"+a)),o.set=function(t){let n=this;n||e!==_global||(n=_global),n&&(n[c]&&n.removeEventListener(a,wrapFn),i&&i.apply(n,NULL_ON_PROP_VALUE),"function"==typeof t?(n[c]=t,n.addEventListener(a,wrapFn,!1)):n[c]=null)},o.get=function(){let n=this;if(n||e!==_global||(n=_global),!n)return null;const r=n[c];if(r)return r;if(s){let e=s&&s.call(this);if(e)return o.set.call(this,e),"function"==typeof n[REMOVE_ATTRIBUTE]&&n.removeAttribute(t),e}return null},ObjectDefineProperty(e,t,o),e[r]=!0}function patchOnProperties(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}let shouldCopySymbolProperties=!1;function patchMethod(e,t,n){let o=e;for(;o&&!o.hasOwnProperty(t);)o=ObjectGetPrototypeOf(o);!o&&e[t]&&(o=e);const r=zoneSymbol(t);let s=null;if(o&&!(s=o[r])){if(s=o[r]=o[t],isPropertyWritable(o&&ObjectGetOwnPropertyDescriptor(o,t))){const e=n(s,r,t);o[t]=function(){return e(this,arguments)},attachOriginToPatched(o[t],s),shouldCopySymbolProperties&©SymbolProperties(s,o[t])}}return s}function patchMacroTask(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=patchMethod(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?scheduleMacroTaskWithCurrentZone(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function attachOriginToPatched(e,t){e[zoneSymbol("OriginalDelegate")]=t}let isDetectedIEOrEdge=!1,ieOrEdge=!1;function isIE(){try{const e=internalWindow.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function isIEOrEdge(){if(isDetectedIEOrEdge)return ieOrEdge;isDetectedIEOrEdge=!0;try{const e=internalWindow.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(ieOrEdge=!0)}catch(e){}return ieOrEdge}Zone.__load_patch("toString",e=>{const t=Function.prototype.toString,n=zoneSymbol("OriginalDelegate"),o=zoneSymbol("Promise"),r=zoneSymbol("Error"),s=function(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});let passiveSupported=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){passiveSupported=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){passiveSupported=!1}const OPTIMIZED_ZONE_EVENT_TASK_DATA={useG:!0},zoneSymbolEventNames$1={},globalSources={},EVENT_NAME_SYMBOL_REGX=/^__zone_symbol__(\w+)(true|false)$/,IMMEDIATE_PROPAGATION_SYMBOL="__zone_symbol__propagationStopped";function patchEventTarget(e,t,n){const o=n&&n.add||ADD_EVENT_LISTENER_STR,r=n&&n.rm||REMOVE_EVENT_LISTENER_STR,s=n&&n.listeners||"eventListeners",i=n&&n.rmAll||"removeAllListeners",a=zoneSymbol(o),c="."+o+":",l="prependListener",u="."+l+":",p=function(e,t,n){if(e.isRemoved)return;const o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=(e=>o.handleEvent(e)),e.originalDelegate=o),e.invoke(e,t,[n]);const s=e.options;if(s&&"object"==typeof s&&s.once){const o=e.originalDelegate?e.originalDelegate:e.callback;t[r].call(t,n.type,o,s)}},h=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[zoneSymbolEventNames$1[t.type][FALSE_STR]];if(o)if(1===o.length)p(o[0],n,t);else{const e=o.slice();for(let o=0;o(function(t,n){t[IMMEDIATE_PROPAGATION_SYMBOL]=!0,e&&e.apply(t,n)}))}function patchCallbacks(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)}const zoneSymbol$1=Zone.__symbol__,_defineProperty=Object[zoneSymbol$1("defineProperty")]=Object.defineProperty,_getOwnPropertyDescriptor=Object[zoneSymbol$1("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,_create=Object.create,unconfigurablesKey=zoneSymbol$1("unconfigurables");function propertyPatch(){Object.defineProperty=function(e,t,n){if(isUnconfigurable(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=rewriteDescriptor(e,t,n)),_tryDefineProperty(e,t,n,o)},Object.defineProperties=function(e,t){return Object.keys(t).forEach(function(n){Object.defineProperty(e,n,t[n])}),e},Object.create=function(e,t){return"object"!=typeof t||Object.isFrozen(t)||Object.keys(t).forEach(function(n){t[n]=rewriteDescriptor(e,n,t[n])}),_create(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=_getOwnPropertyDescriptor(e,t);return n&&isUnconfigurable(e,t)&&(n.configurable=!1),n}}function _redefineProperty(e,t,n){const o=n.configurable;return _tryDefineProperty(e,t,n=rewriteDescriptor(e,t,n),o)}function isUnconfigurable(e,t){return e&&e[unconfigurablesKey]&&e[unconfigurablesKey][t]}function rewriteDescriptor(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[unconfigurablesKey]||Object.isFrozen(e)||_defineProperty(e,unconfigurablesKey,{writable:!0,value:{}}),e[unconfigurablesKey]&&(e[unconfigurablesKey][t]=!0)),n}function _tryDefineProperty(e,t,n,o){try{return _defineProperty(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return _defineProperty(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}}const globalEventHandlersEventNames=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"],documentEventNames=["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],windowEventNames=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],htmlElementEventNames=["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],mediaElementEventNames=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ieElementEventNames=["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"],webglEventNames=["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],formEventNames=["autocomplete","autocompleteerror"],detailEventNames=["toggle"],frameEventNames=["load"],frameSetEventNames=["blur","error","focus","load","resize","scroll","messageerror"],marqueeEventNames=["bounce","finish","start"],XMLHttpRequestEventNames=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],IDBIndexEventNames=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],websocketEventNames=["close","error","open","message"],workerEventNames=["error","message"],eventNames=globalEventHandlersEventNames.concat(webglEventNames,formEventNames,detailEventNames,documentEventNames,windowEventNames,htmlElementEventNames,ieElementEventNames);function filterProperties(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function patchFilteredProperties(e,t,n,o){if(!e)return;patchOnProperties(e,filterProperties(e,t,n),o)}function propertyDescriptorPatch(e,t){if(isNode&&!isMix)return;if(Zone[e.symbol("patchEvents")])return;const n="undefined"!=typeof WebSocket,o=t.__Zone_ignore_on_properties;if(isBrowser){const e=window,t=isIE?[{target:e,ignoreProperties:["error"]}]:[];patchFilteredProperties(e,eventNames.concat(["messageerror"]),o?o.concat(t):o,ObjectGetPrototypeOf(e)),patchFilteredProperties(Document.prototype,eventNames,o),void 0!==e.SVGElement&&patchFilteredProperties(e.SVGElement.prototype,eventNames,o),patchFilteredProperties(Element.prototype,eventNames,o),patchFilteredProperties(HTMLElement.prototype,eventNames,o),patchFilteredProperties(HTMLMediaElement.prototype,mediaElementEventNames,o),patchFilteredProperties(HTMLFrameSetElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLBodyElement.prototype,windowEventNames.concat(frameSetEventNames),o),patchFilteredProperties(HTMLFrameElement.prototype,frameEventNames,o),patchFilteredProperties(HTMLIFrameElement.prototype,frameEventNames,o);const n=e.HTMLMarqueeElement;n&&patchFilteredProperties(n.prototype,marqueeEventNames,o);const r=e.Worker;r&&patchFilteredProperties(r.prototype,workerEventNames,o)}const r=t.XMLHttpRequest;r&&patchFilteredProperties(r.prototype,XMLHttpRequestEventNames,o);const s=t.XMLHttpRequestEventTarget;s&&patchFilteredProperties(s&&s.prototype,XMLHttpRequestEventNames,o),"undefined"!=typeof IDBIndex&&(patchFilteredProperties(IDBIndex.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBOpenDBRequest.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBDatabase.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBTransaction.prototype,IDBIndexEventNames,o),patchFilteredProperties(IDBCursor.prototype,IDBIndexEventNames,o)),n&&patchFilteredProperties(WebSocket.prototype,websocketEventNames,o)}Zone.__load_patch("util",(e,t,n)=>{n.patchOnProperties=patchOnProperties,n.patchMethod=patchMethod,n.bindArguments=bindArguments,n.patchMacroTask=patchMacroTask;const o=t.__symbol__("BLACK_LISTED_EVENTS"),r=t.__symbol__("UNPATCHED_EVENTS");e[r]&&(e[o]=e[r]),e[o]&&(t[o]=t[r]=e[o]),n.patchEventPrototype=patchEventPrototype,n.patchEventTarget=patchEventTarget,n.isIEOrEdge=isIEOrEdge,n.ObjectDefineProperty=ObjectDefineProperty,n.ObjectGetOwnPropertyDescriptor=ObjectGetOwnPropertyDescriptor,n.ObjectCreate=ObjectCreate,n.ArraySlice=ArraySlice,n.patchClass=patchClass,n.wrapWithCurrentZone=wrapWithCurrentZone,n.filterProperties=filterProperties,n.attachOriginToPatched=attachOriginToPatched,n._redefineProperty=_redefineProperty,n.patchCallbacks=patchCallbacks,n.getGlobalObjects=(()=>({globalSources,zoneSymbolEventNames:zoneSymbolEventNames$1,eventNames,isBrowser,isMix,isNode,TRUE_STR,FALSE_STR,ZONE_SYMBOL_PREFIX,ADD_EVENT_LISTENER_STR,REMOVE_EVENT_LISTENER_STR}))});const taskSymbol=zoneSymbol("zoneTask");function patchTimer(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[taskSymbol]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=patchMethod(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e={isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},n=scheduleMacroTaskWithCurrentZone(t,s[0],e,a,c);if(!n)return n;const r=n.data.handleId;return"number"==typeof r?i[r]=n:r&&(r[taskSymbol]=n),r&&r.ref&&r.unref&&"function"==typeof r.ref&&"function"==typeof r.unref&&(n.ref=r.ref.bind(r),n.unref=r.unref.bind(r)),"number"==typeof r||r?r:n}return n.apply(e,s)})),s=patchMethod(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[taskSymbol])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[taskSymbol]=null),s.zone.cancelTask(s)):t.apply(e,o)}))}function patchCustomElements(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();if(!((n||o)&&e.customElements&&"customElements"in e))return;t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}function eventTargetPatch(e,t){if(Zone[t.symbol("patchEventTarget")])return;const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{patchTimer(e,"set","clear","Timeout"),patchTimer(e,"set","clear","Interval"),patchTimer(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{patchTimer(e,"request","cancel","AnimationFrame"),patchTimer(e,"mozRequest","mozCancel","AnimationFrame"),patchTimer(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}}),Zone.__load_patch("EventTarget",(e,t,n)=>{patchEvent(e,n),eventTargetPatch(e,n);const o=e.XMLHttpRequestEventTarget;o&&o.prototype&&n.patchEventTarget(e,[o.prototype]),patchClass("MutationObserver"),patchClass("WebKitMutationObserver"),patchClass("IntersectionObserver"),patchClass("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{propertyDescriptorPatch(n,e),propertyPatch()}),Zone.__load_patch("customElements",(e,t,n)=>{patchCustomElements(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function(e){const c=e.XMLHttpRequest;if(!c)return;const l=c.prototype;let u=l[ZONE_SYMBOL_ADD_EVENT_LISTENER],p=l[ZONE_SYMBOL_REMOVE_EVENT_LISTENER];if(!u){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;u=e[ZONE_SYMBOL_ADD_EVENT_LISTENER],p=e[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]}}const h="readystatechange",f="scheduled";function d(e){const t=e.data,o=t.target;o[s]=!1,o[a]=!1;const i=o[r];u||(u=o[ZONE_SYMBOL_ADD_EVENT_LISTENER],p=o[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]),i&&p.call(o,h,i);const c=o[r]=(()=>{if(o.readyState===o.DONE)if(!t.aborted&&o[s]&&e.state===f){const n=o.__zone_symbol__loadfalse;if(n&&n.length>0){const r=e.invoke;e.invoke=function(){const n=o.__zone_symbol__loadfalse;for(let t=0;t(function(e,t){return e[o]=0==t[2],e[i]=t[1],g.apply(e,t)})),y=zoneSymbol("fetchTaskAborting"),E=zoneSymbol("fetchTaskScheduling"),b=patchMethod(l,"send",()=>(function(e,n){if(!0===t.current[E])return b.apply(e,n);if(e[o])return b.apply(e,n);{const t={target:e,url:e[i],isPeriodic:!1,args:n,aborted:!1},o=scheduleMacroTaskWithCurrentZone("XMLHttpRequest.send",_,t,d,m);e&&!0===e[a]&&!t.aborted&&o.state===f&&o.invoke()}})),T=patchMethod(l,"abort",()=>(function(e,o){const r=e[n];if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[y])return T.apply(e,o)}))}(e);const n=zoneSymbol("xhrTask"),o=zoneSymbol("xhrSync"),r=zoneSymbol("xhrListener"),s=zoneSymbol("xhrScheduled"),i=zoneSymbol("xhrURL"),a=zoneSymbol("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",e=>{e.navigator&&e.navigator.geolocation&&patchPrototype(e.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){findEventTasks(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[zoneSymbol("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[zoneSymbol("rejectionHandledHandler")]=n("rejectionhandled"))}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";!function(e){const t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function o(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");const r=e.__Zone_symbol_prefix||"__zone_symbol__";function s(e){return r+e}const i=!0===e[s("forceDuplicateZoneCheck")];if(e.Zone){if(i||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}class a{constructor(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}static assertZonePatched(){if(e.Promise!==P.ZoneAwarePromise)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.)")}static get root(){let e=a.current;for(;e.parent;)e=e.parent;return e}static get current(){return j.zone}static get currentTask(){return C}static __load_patch(t,r){if(P.hasOwnProperty(t)){if(i)throw Error("Already loaded patch: "+t)}else if(!e["__Zone_disable_"+t]){const s="Zone:"+t;n(s),P[t]=r(e,a,z),o(s,s)}}get parent(){return this._parent}get name(){return this._name}get(e){const t=this.getZoneWith(e);if(t)return t._properties[e]}getZoneWith(e){let t=this;for(;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null}fork(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)}wrap(e,t){if("function"!=typeof e)throw new Error("Expecting function got: "+e);const n=this._zoneDelegate.intercept(this,e,t),o=this;return function(){return o.runGuarded(n,this,arguments,t)}}run(e,t,n,o){j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,o)}finally{j=j.parent}}runGuarded(e,t=null,n,o){j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,o)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{j=j.parent}}runTask(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");if(e.state===b&&(e.type===O||e.type===D))return;const o=e.state!=w;o&&e._transitionTo(w,T),e.runCount++;const r=C;C=e,j={parent:j,zone:this};try{e.type==D&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==b&&e.state!==Z&&(e.type==O||e.data&&e.data.isPeriodic?o&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),o&&e._transitionTo(b,w,b))),j=j.parent,C=r}}scheduleTask(e){if(e.zone&&e.zone!==this){let t=this;for(;t;){if(t===e.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${e.zone.name}`);t=t.parent}}e._transitionTo(v,b);const t=[];e._zoneDelegates=t,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(Z,v,b),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===t&&this._updateTaskCount(e,1),e.state==v&&e._transitionTo(T,v),e}scheduleMicroTask(e,t,n,o){return this.scheduleTask(new u(S,e,t,n,o,void 0))}scheduleMacroTask(e,t,n,o,r){return this.scheduleTask(new u(D,e,t,n,o,r))}scheduleEventTask(e,t,n,o,r){return this.scheduleTask(new u(O,e,t,n,o,r))}cancelTask(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||k).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(Z,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(b,E),e.runCount=0,e}_updateTaskCount(e,t){const n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(let o=0;oe.hasTask(n,o),onScheduleTask:(e,t,n,o)=>e.scheduleTask(n,o),onInvokeTask:(e,t,n,o,r,s)=>e.invokeTask(n,o,r,s),onCancelTask:(e,t,n,o)=>e.cancelTask(n,o)};class l{constructor(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._forkCurrZone=n&&(n.onFork?this.zone:t.zone),this._interceptZS=n&&(n.onIntercept?n:t._interceptZS),this._interceptDlgt=n&&(n.onIntercept?t:t._interceptDlgt),this._interceptCurrZone=n&&(n.onIntercept?this.zone:t.zone),this._invokeZS=n&&(n.onInvoke?n:t._invokeZS),this._invokeDlgt=n&&(n.onInvoke?t:t._invokeDlgt),this._invokeCurrZone=n&&(n.onInvoke?this.zone:t.zone),this._handleErrorZS=n&&(n.onHandleError?n:t._handleErrorZS),this._handleErrorDlgt=n&&(n.onHandleError?t:t._handleErrorDlgt),this._handleErrorCurrZone=n&&(n.onHandleError?this.zone:t.zone),this._scheduleTaskZS=n&&(n.onScheduleTask?n:t._scheduleTaskZS),this._scheduleTaskDlgt=n&&(n.onScheduleTask?t:t._scheduleTaskDlgt),this._scheduleTaskCurrZone=n&&(n.onScheduleTask?this.zone:t.zone),this._invokeTaskZS=n&&(n.onInvokeTask?n:t._invokeTaskZS),this._invokeTaskDlgt=n&&(n.onInvokeTask?t:t._invokeTaskDlgt),this._invokeTaskCurrZone=n&&(n.onInvokeTask?this.zone:t.zone),this._cancelTaskZS=n&&(n.onCancelTask?n:t._cancelTaskZS),this._cancelTaskDlgt=n&&(n.onCancelTask?t:t._cancelTaskDlgt),this._cancelTaskCurrZone=n&&(n.onCancelTask?this.zone:t.zone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const o=n&&n.onHasTask;(o||t&&t._hasTaskZS)&&(this._hasTaskZS=o?n:c,this._hasTaskDlgt=t,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=e,n.onScheduleTask||(this._scheduleTaskZS=c,this._scheduleTaskDlgt=t,this._scheduleTaskCurrZone=this.zone),n.onInvokeTask||(this._invokeTaskZS=c,this._invokeTaskDlgt=t,this._invokeTaskCurrZone=this.zone),n.onCancelTask||(this._cancelTaskZS=c,this._cancelTaskDlgt=t,this._cancelTaskCurrZone=this.zone))}fork(e,t){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,e,t):new a(e,t)}intercept(e,t,n){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,e,t,n):t}invoke(e,t,n,o,r){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,e,t,n,o,r):t.apply(n,o)}handleError(e,t){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,e,t)}scheduleTask(e,t){let n=t;if(this._scheduleTaskZS)this._hasTaskZS&&n._zoneDelegates.push(this._hasTaskDlgtOwner),(n=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,e,t))||(n=t);else if(t.scheduleFn)t.scheduleFn(t);else{if(t.type!=S)throw new Error("Task is missing scheduleFn.");y(t)}return n}invokeTask(e,t,n,o){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,e,t,n,o):t.callback.apply(n,o)}cancelTask(e,t){let n;if(this._cancelTaskZS)n=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,e,t);else{if(!t.cancelFn)throw Error("Task is not cancelable");n=t.cancelFn(t)}return n}hasTask(e,t){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,e,t)}catch(t){this.handleError(e,t)}}_updateTaskCount(e,t){const n=this._taskCounts,o=n[e],r=n[e]=o+t;if(r<0)throw new Error("More tasks executed then were scheduled.");0!=o&&0!=r||this.hasTask(this.zone,{microTask:n.microTask>0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})}}class u{constructor(t,n,o,r,s,i){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=t,this.source=n,this.data=r,this.scheduleFn=s,this.cancelFn=i,this.callback=o;const a=this;this.invoke=t===O&&r&&r.useG?u.invokeTask:function(){return u.invokeTask.call(e,a,this,arguments)}}static invokeTask(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&m(),I--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(b,v)}_transitionTo(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(`${this.type} '${this.source}': can not transition to '${e}', expecting state '${t}'${n?" or '"+n+"'":""}, was '${this._state}'.`);this._state=e,e==b&&(this._zoneDelegates=null)}toString(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const h=s("setTimeout"),p=s("Promise"),f=s("then");let d,g=[],_=!1;function y(t){if(0===I&&0===g.length)if(d||e[p]&&(d=e[p].resolve(0)),d){let e=d[f];e||(e=d.then),e.call(d,m)}else e[h](m,0);t&&g.push(t)}function m(){if(!_){for(_=!0;g.length;){const e=g;g=[];for(let t=0;tj,onUnhandledError:R,microtaskDrainDone:R,scheduleMicroTask:y,showUncaughtError:()=>!a[s("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:R,patchMethod:()=>R,bindArguments:()=>[],patchThen:()=>R,patchMacroTask:()=>R,setNativePromise:e=>{e&&"function"==typeof e.resolve&&(d=e.resolve(0))},patchEventPrototype:()=>R,isIEOrEdge:()=>!1,getGlobalObjects:()=>void 0,ObjectDefineProperty:()=>R,ObjectGetOwnPropertyDescriptor:()=>void 0,ObjectCreate:()=>void 0,ArraySlice:()=>[],patchClass:()=>R,wrapWithCurrentZone:()=>R,filterProperties:()=>[],attachOriginToPatched:()=>R,_redefineProperty:()=>R,patchCallbacks:()=>R};let j={parent:null,zone:new a(null,null)},C=null,I=0;function R(){}o("Zone","Zone"),e.Zone=a}("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}), +/** + * @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.__load_patch("ZoneAwarePromise",(e,t,n)=>{const o=Object.getOwnPropertyDescriptor,r=Object.defineProperty,s=n.symbol,i=[],a=s("Promise"),c=s("then"),l="__creationTrace__";n.onUnhandledError=(e=>{if(n.showUncaughtError()){const 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)}}),n.microtaskDrainDone=(()=>{for(;i.length;)for(;i.length;){const e=i.shift();try{e.zone.runGuarded(()=>{throw e})}catch(e){h(e)}}});const u=s("unhandledPromiseRejectionHandler");function h(e){n.onUnhandledError(e);try{const n=t[u];n&&"function"==typeof n&&n.call(this,e)}catch(e){}}function p(e){return e&&e.then}function f(e){return e}function d(e){return R.reject(e)}const g=s("state"),_=s("value"),y=s("finally"),m=s("parentPromiseValue"),k=s("parentPromiseState"),b="Promise.then",v=null,T=!0,w=!1,E=0;function Z(e,t){return n=>{try{P(e,t,n)}catch(t){P(e,!1,t)}}}const S=function(){let e=!1;return function t(n){return function(){e||(e=!0,n.apply(null,arguments))}}},D="Promise resolved with itself",O=s("currentTaskTrace");function P(e,o,s){const a=S();if(e===s)throw new TypeError(D);if(e[g]===v){let c=null;try{"object"!=typeof s&&"function"!=typeof s||(c=s&&s.then)}catch(t){return a(()=>{P(e,!1,t)})(),e}if(o!==w&&s instanceof R&&s.hasOwnProperty(g)&&s.hasOwnProperty(_)&&s[g]!==v)j(s),P(e,s[g],s[_]);else if(o!==w&&"function"==typeof c)try{c.call(s,a(Z(e,o)),a(Z(e,!1)))}catch(t){a(()=>{P(e,!1,t)})()}else{e[g]=o;const a=e[_];if(e[_]=s,e[y]===y&&o===T&&(e[g]=e[k],e[_]=e[m]),o===w&&s instanceof Error){const e=t.currentTask&&t.currentTask.data&&t.currentTask.data[l];e&&r(s,O,{configurable:!0,enumerable:!1,writable:!0,value:e})}for(let t=0;t{try{const o=e[_],r=!!n&&y===n[y];r&&(n[m]=o,n[k]=s);const a=t.run(i,void 0,r&&i!==d&&i!==f?[]:[o]);P(n,!0,a)}catch(e){P(n,!1,e)}},n)}const I="function ZoneAwarePromise() { [native code] }";class R{constructor(e){const t=this;if(!(t instanceof R))throw new Error("Must be an instanceof Promise.");t[g]=v,t[_]=[];try{e&&e(Z(t,T),Z(t,w))}catch(e){P(t,!1,e)}}static toString(){return I}static resolve(e){return P(new this(null),T,e)}static reject(e){return P(new this(null),w,e)}static race(e){let t,n,o=new this((e,o)=>{t=e,n=o});function r(e){t(e)}function s(e){n(e)}for(let t of e)p(t)||(t=this.resolve(t)),t.then(r,s);return o}static all(e){let t,n,o=new this((e,o)=>{t=e,n=o}),r=2,s=0;const i=[];for(let o of e){p(o)||(o=this.resolve(o));const e=s;o.then(n=>{i[e]=n,0==--r&&t(i)},n),r++,s++}return 0==(r-=2)&&t(i),o}get[Symbol.toStringTag](){return"Promise"}then(e,n){const o=new this.constructor(null),r=t.current;return this[g]==v?this[_].push(r,o,e,n):C(this,r,o,e,n),o}catch(e){return this.then(null,e)}finally(e){const n=new this.constructor(null);n[y]=y;const o=t.current;return this[g]==v?this[_].push(o,n,e,e):C(this,o,n,e,e),n}}R.resolve=R.resolve,R.reject=R.reject,R.race=R.race,R.all=R.all;const x=e[a]=e.Promise,M=t.__symbol__("ZoneAwarePromise");let L=o(e,"Promise");L&&!L.configurable||(L&&delete L.writable,L&&delete L.value,L||(L={configurable:!0,enumerable:!0}),L.get=function(){return e[M]?e[M]:e[a]},L.set=function(t){t===R?e[M]=t:(e[a]=t,t.prototype[c]||A(t),n.setNativePromise(t))},r(e,"Promise",L)),e.Promise=R;const N=s("thenPatched");function A(e){const t=e.prototype,n=o(t,"then");if(n&&(!1===n.writable||!n.configurable))return;const r=t.then;t[c]=r,e.prototype.then=function(e,t){return new R((e,t)=>{r.call(this,e,t)}).then(e,t)},e[N]=!0}if(n.patchThen=A,x){A(x);const t=e.fetch;"function"==typeof t&&(e[n.symbol("fetch")]=t,e.fetch=function F(e){return function(){let t=e.apply(this,arguments);if(t instanceof R)return t;let n=t.constructor;return n[N]||A(n),t}}(t))}return Promise[t.__symbol__("uncaughtPromiseErrors")]=i,R}); +/** + * @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 e=Object.getOwnPropertyDescriptor,t=Object.defineProperty,n=Object.getPrototypeOf,o=Object.create,r=Array.prototype.slice,s="addEventListener",i="removeEventListener",a=Zone.__symbol__(s),c=Zone.__symbol__(i),l="true",u="false",h=Zone.__symbol__("");function p(e,t){return Zone.current.wrap(e,t)}function f(e,t,n,o,r){return Zone.current.scheduleMacroTask(e,t,n,o,r)}const d=Zone.__symbol__,g="undefined"!=typeof window,_=g?window:void 0,y=g&&_||"object"==typeof self&&self||global,m="removeAttribute",k=[null];function b(e,t){for(let n=e.length-1;n>=0;n--)"function"==typeof e[n]&&(e[n]=p(e[n],t+"_"+n));return e}function v(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}const T="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in y)&&void 0!==y.process&&"[object process]"==={}.toString.call(y.process),E=!w&&!T&&!(!g||!_.HTMLElement),Z=void 0!==y.process&&"[object process]"==={}.toString.call(y.process)&&!T&&!(!g||!_.HTMLElement),S={},D=function(e){if(!(e=e||y.event))return;let t=S[e.type];t||(t=S[e.type]=d("ON_PROPERTY"+e.type));const n=this||e.target||y,o=n[t];let r;if(E&&n===_&&"error"===e.type){const t=e;!0===(r=o&&o.call(this,t.message,t.filename,t.lineno,t.colno,t.error))&&e.preventDefault()}else null==(r=o&&o.apply(this,arguments))||r||e.preventDefault();return r};function O(n,o,r){let s=e(n,o);if(!s&&r&&e(r,o)&&(s={enumerable:!0,configurable:!0}),!s||!s.configurable)return;const i=d("on"+o+"patched");if(n.hasOwnProperty(i)&&n[i])return;delete s.writable,delete s.value;const a=s.get,c=s.set,l=o.substr(2);let u=S[l];u||(u=S[l]=d("ON_PROPERTY"+l)),s.set=function(e){let t=this;t||n!==y||(t=y),t&&(t[u]&&t.removeEventListener(l,D),c&&c.apply(t,k),"function"==typeof e?(t[u]=e,t.addEventListener(l,D,!1)):t[u]=null)},s.get=function(){let e=this;if(e||n!==y||(e=y),!e)return null;const t=e[u];if(t)return t;if(a){let t=a&&a.call(this);if(t)return s.set.call(this,t),"function"==typeof e[m]&&e.removeAttribute(o),t}return null},t(n,o,s),n[i]=!0}function P(e,t,n){if(t)for(let o=0;o{const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){(!o||o.writable&&"function"==typeof o.set)&&(e[n]=t)},enumerable:!o||o.enumerable,configurable:!o||o.configurable})})}(a,s[o])}return a}function R(e,t,n){let o=null;function r(e){const t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=I(e,t,e=>(function(t,o){const s=n(t,o);return s.cbIdx>=0&&"function"==typeof o[s.cbIdx]?f(s.name,o[s.cbIdx],s,r):e.apply(t,o)}))}function x(e,t){e[d("OriginalDelegate")]=t}let M=!1,L=!1;function N(){if(M)return L;M=!0;try{const e=_.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(L=!0)}catch(e){}return L} +/** + * @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.__load_patch("toString",e=>{const t=Function.prototype.toString,n=d("OriginalDelegate"),o=d("Promise"),r=d("Error"),s=function s(){if("function"==typeof this){const s=this[n];if(s)return"function"==typeof s?t.call(s):Object.prototype.toString.call(s);if(this===Promise){const n=e[o];if(n)return t.call(n)}if(this===Error){const n=e[r];if(n)return t.call(n)}}return t.call(this)};s[n]=t,Function.prototype.toString=s;const i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}}); +/** + * @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 + */ +let A=!1;if("undefined"!=typeof window)try{const e=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",e,e),window.removeEventListener("test",e,e)}catch(e){A=!1}const F={useG:!0},H={},G={},q=new RegExp("^"+h+"(\\w+)(true|false)$"),B=d("propagationStopped");function $(e,t,o){const r=o&&o.add||s,a=o&&o.rm||i,c=o&&o.listeners||"eventListeners",p=o&&o.rmAll||"removeAllListeners",f=d(r),g="."+r+":",_="prependListener",y="."+_+":",m=function(e,t,n){if(e.isRemoved)return;const o=e.callback;"object"==typeof o&&o.handleEvent&&(e.callback=(e=>o.handleEvent(e)),e.originalDelegate=o),e.invoke(e,t,[n]);const r=e.options;r&&"object"==typeof r&&r.once&&t[a].call(t,n.type,e.originalDelegate?e.originalDelegate:e.callback,r)},k=function(t){if(!(t=t||e.event))return;const n=this||t.target||e,o=n[H[t.type][u]];if(o)if(1===o.length)m(o[0],n,t);else{const e=o.slice();for(let o=0;o(function(t,n){t[B]=!0,e&&e.apply(t,n)}))} +/** + * @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 V(e,t,n,o,r){const s=Zone.__symbol__(o);if(t[s])return;const i=t[s]=t[o];t[o]=function(s,a,c){return a&&a.prototype&&r.forEach(function(t){const r=`${n}.${o}::`+t,s=a.prototype;if(s.hasOwnProperty(t)){const n=e.ObjectGetOwnPropertyDescriptor(s,t);n&&n.value?(n.value=e.wrapWithCurrentZone(n.value,r),e._redefineProperty(a.prototype,t,n)):s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}else s[t]&&(s[t]=e.wrapWithCurrentZone(s[t],r))}),i.call(t,s,a,c)},e.attachOriginToPatched(t[o],i)} +/** + * @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 X=Zone.__symbol__,Y=Object[X("defineProperty")]=Object.defineProperty,J=Object[X("getOwnPropertyDescriptor")]=Object.getOwnPropertyDescriptor,K=Object.create,Q=X("unconfigurables");function ee(e,t,n){const o=n.configurable;return oe(e,t,n=ne(e,t,n),o)}function te(e,t){return e&&e[Q]&&e[Q][t]}function ne(e,t,n){return Object.isFrozen(n)||(n.configurable=!0),n.configurable||(e[Q]||Object.isFrozen(e)||Y(e,Q,{writable:!0,value:{}}),e[Q]&&(e[Q][t]=!0)),n}function oe(e,t,n,o){try{return Y(e,t,n)}catch(r){if(!n.configurable)throw r;void 0===o?delete n.configurable:n.configurable=o;try{return Y(e,t,n)}catch(o){let r=null;try{r=JSON.stringify(n)}catch(e){r=n.toString()}console.log(`Attempting to configure '${t}' with descriptor '${r}' on object '${e}' and got error, giving up: ${o}`)}}} +/** + * @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 re=["absolutedeviceorientation","afterinput","afterprint","appinstalled","beforeinstallprompt","beforeprint","beforeunload","devicelight","devicemotion","deviceorientation","deviceorientationabsolute","deviceproximity","hashchange","languagechange","message","mozbeforepaint","offline","online","paint","pageshow","pagehide","popstate","rejectionhandled","storage","unhandledrejection","unload","userproximity","vrdisplyconnected","vrdisplaydisconnected","vrdisplaypresentchange"],se=["encrypted","waitingforkey","msneedkey","mozinterruptbegin","mozinterruptend"],ie=["load"],ae=["blur","error","focus","load","resize","scroll","messageerror"],ce=["bounce","finish","start"],le=["loadstart","progress","abort","error","load","progress","timeout","loadend","readystatechange"],ue=["upgradeneeded","complete","abort","success","error","blocked","versionchange","close"],he=["close","error","open","message"],pe=["error","message"],fe=["abort","animationcancel","animationend","animationiteration","auxclick","beforeinput","blur","cancel","canplay","canplaythrough","change","compositionstart","compositionupdate","compositionend","cuechange","click","close","contextmenu","curechange","dblclick","drag","dragend","dragenter","dragexit","dragleave","dragover","drop","durationchange","emptied","ended","error","focus","focusin","focusout","gotpointercapture","input","invalid","keydown","keypress","keyup","load","loadstart","loadeddata","loadedmetadata","lostpointercapture","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","mousewheel","orientationchange","pause","play","playing","pointercancel","pointerdown","pointerenter","pointerleave","pointerlockchange","mozpointerlockchange","webkitpointerlockerchange","pointerlockerror","mozpointerlockerror","webkitpointerlockerror","pointermove","pointout","pointerover","pointerup","progress","ratechange","reset","resize","scroll","seeked","seeking","select","selectionchange","selectstart","show","sort","stalled","submit","suspend","timeupdate","volumechange","touchcancel","touchmove","touchstart","touchend","transitioncancel","transitionend","waiting","wheel"].concat(["webglcontextrestored","webglcontextlost","webglcontextcreationerror"],["autocomplete","autocompleteerror"],["toggle"],["afterscriptexecute","beforescriptexecute","DOMContentLoaded","freeze","fullscreenchange","mozfullscreenchange","webkitfullscreenchange","msfullscreenchange","fullscreenerror","mozfullscreenerror","webkitfullscreenerror","msfullscreenerror","readystatechange","visibilitychange","resume"],re,["beforecopy","beforecut","beforepaste","copy","cut","paste","dragstart","loadend","animationstart","search","transitionrun","transitionstart","webkitanimationend","webkitanimationiteration","webkitanimationstart","webkittransitionend"],["activate","afterupdate","ariarequest","beforeactivate","beforedeactivate","beforeeditfocus","beforeupdate","cellchange","controlselect","dataavailable","datasetchanged","datasetcomplete","errorupdate","filterchange","layoutcomplete","losecapture","move","moveend","movestart","propertychange","resizeend","resizestart","rowenter","rowexit","rowsdelete","rowsinserted","command","compassneedscalibration","deactivate","help","mscontentzoom","msmanipulationstatechanged","msgesturechange","msgesturedoubletap","msgestureend","msgesturehold","msgesturestart","msgesturetap","msgotpointercapture","msinertiastart","mslostpointercapture","mspointercancel","mspointerdown","mspointerenter","mspointerhover","mspointerleave","mspointermove","mspointerout","mspointerover","mspointerup","pointerout","mssitemodejumplistitemremoved","msthumbnailclick","stop","storagecommit"]);function de(e,t,n){if(!n||0===n.length)return t;const o=n.filter(t=>t.target===e);if(!o||0===o.length)return t;const r=o[0].ignoreProperties;return t.filter(e=>-1===r.indexOf(e))}function ge(e,t,n,o){e&&P(e,de(e,t,n),o)}function _e(e,t){if(w&&!Z)return;if(Zone[e.symbol("patchEvents")])return;const o="undefined"!=typeof WebSocket,r=t.__Zone_ignore_on_properties;if(E){const e=window,t=function s(){try{const t=e.navigator.userAgent;if(-1!==t.indexOf("MSIE ")||-1!==t.indexOf("Trident/"))return!0}catch(e){}return!1}?[{target:e,ignoreProperties:["error"]}]:[];ge(e,fe.concat(["messageerror"]),r?r.concat(t):r,n(e)),ge(Document.prototype,fe,r),void 0!==e.SVGElement&&ge(e.SVGElement.prototype,fe,r),ge(Element.prototype,fe,r),ge(HTMLElement.prototype,fe,r),ge(HTMLMediaElement.prototype,se,r),ge(HTMLFrameSetElement.prototype,re.concat(ae),r),ge(HTMLBodyElement.prototype,re.concat(ae),r),ge(HTMLFrameElement.prototype,ie,r),ge(HTMLIFrameElement.prototype,ie,r);const o=e.HTMLMarqueeElement;o&&ge(o.prototype,ce,r);const s=e.Worker;s&&ge(s.prototype,pe,r)}const i=t.XMLHttpRequest;i&&ge(i.prototype,le,r);const a=t.XMLHttpRequestEventTarget;a&&ge(a&&a.prototype,le,r),"undefined"!=typeof IDBIndex&&(ge(IDBIndex.prototype,ue,r),ge(IDBRequest.prototype,ue,r),ge(IDBOpenDBRequest.prototype,ue,r),ge(IDBDatabase.prototype,ue,r),ge(IDBTransaction.prototype,ue,r),ge(IDBCursor.prototype,ue,r)),o&&ge(WebSocket.prototype,he,r)} +/** + * @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.__load_patch("util",(n,a,c)=>{c.patchOnProperties=P,c.patchMethod=I,c.bindArguments=b,c.patchMacroTask=R;const f=a.__symbol__("BLACK_LISTED_EVENTS"),d=a.__symbol__("UNPATCHED_EVENTS");n[d]&&(n[f]=n[d]),n[f]&&(a[f]=a[d]=n[f]),c.patchEventPrototype=W,c.patchEventTarget=$,c.isIEOrEdge=N,c.ObjectDefineProperty=t,c.ObjectGetOwnPropertyDescriptor=e,c.ObjectCreate=o,c.ArraySlice=r,c.patchClass=j,c.wrapWithCurrentZone=p,c.filterProperties=de,c.attachOriginToPatched=x,c._redefineProperty=ee,c.patchCallbacks=V,c.getGlobalObjects=(()=>({globalSources:G,zoneSymbolEventNames:H,eventNames:fe,isBrowser:E,isMix:Z,isNode:w,TRUE_STR:l,FALSE_STR:u,ZONE_SYMBOL_PREFIX:h,ADD_EVENT_LISTENER_STR:s,REMOVE_EVENT_LISTENER_STR:i}))}); +/** + * @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 + */ +/** + * @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 ye=d("zoneTask");function me(e,t,n,o){let r=null,s=null;n+=o;const i={};function a(t){const n=t.data;return n.args[0]=function o(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[ye]=null))}},n.handleId=r.apply(e,n.args),t}function c(e){return s(e.data.handleId)}r=I(e,t+=o,n=>(function(r,s){if("function"==typeof s[0]){const e=f(t,s[0],{isPeriodic:"Interval"===o,delay:"Timeout"===o||"Interval"===o?s[1]||0:void 0,args:s},a,c);if(!e)return e;const n=e.data.handleId;return"number"==typeof n?i[n]=e:n&&(n[ye]=e),n&&n.ref&&n.unref&&"function"==typeof n.ref&&"function"==typeof n.unref&&(e.ref=n.ref.bind(n),e.unref=n.unref.bind(n)),"number"==typeof n||n?n:e}return n.apply(e,s)})),s=I(e,n,t=>(function(n,o){const r=o[0];let s;"number"==typeof r?s=i[r]:(s=r&&r[ye])||(s=r),s&&"string"==typeof s.type?"notScheduled"!==s.state&&(s.cancelFn&&s.data.isPeriodic||0===s.runCount)&&("number"==typeof r?delete i[r]:r&&(r[ye]=null),s.zone.cancelTask(s)):t.apply(e,o)}))} +/** + * @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 + */ +/** + * @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 ke(e,t){if(Zone[t.symbol("patchEventTarget")])return;const{eventNames:n,zoneSymbolEventNames:o,TRUE_STR:r,FALSE_STR:s,ZONE_SYMBOL_PREFIX:i}=t.getGlobalObjects();for(let e=0;e{const t=e[Zone.__symbol__("legacyPatch")];t&&t()}),Zone.__load_patch("timers",e=>{me(e,"set","clear","Timeout"),me(e,"set","clear","Interval"),me(e,"set","clear","Immediate")}),Zone.__load_patch("requestAnimationFrame",e=>{me(e,"request","cancel","AnimationFrame"),me(e,"mozRequest","mozCancel","AnimationFrame"),me(e,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(e,t)=>{const n=["alert","prompt","confirm"];for(let o=0;o(function(o,s){return t.current.run(n,e,s,r)}))}),Zone.__load_patch("EventTarget",(e,t,n)=>{!function o(e,t){t.patchEventPrototype(e,t)}(e,n),ke(e,n);const r=e.XMLHttpRequestEventTarget;r&&r.prototype&&n.patchEventTarget(e,[r.prototype]),j("MutationObserver"),j("WebKitMutationObserver"),j("IntersectionObserver"),j("FileReader")}),Zone.__load_patch("on_property",(e,t,n)=>{_e(n,e),function o(){Object.defineProperty=function(e,t,n){if(te(e,t))throw new TypeError("Cannot assign to read only property '"+t+"' of "+e);const o=n.configurable;return"prototype"!==t&&(n=ne(e,t,n)),oe(e,t,n,o)},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]=ne(e,n,t[n])}),K(e,t)},Object.getOwnPropertyDescriptor=function(e,t){const n=J(e,t);return n&&te(e,t)&&(n.configurable=!1),n}}()}),Zone.__load_patch("customElements",(e,t,n)=>{!function o(e,t){const{isBrowser:n,isMix:o}=t.getGlobalObjects();(n||o)&&e.customElements&&"customElements"in e&&t.patchCallbacks(t,e.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(e,n)}),Zone.__load_patch("XHR",(e,t)=>{!function n(e){const n=e.XMLHttpRequest;if(!n)return;const h=n.prototype;let p=h[a],g=h[c];if(!p){const t=e.XMLHttpRequestEventTarget;if(t){const e=t.prototype;p=e[a],g=e[c]}}const _="readystatechange",y="scheduled";function m(e){const n=e.data,r=n.target;r[i]=!1,r[u]=!1;const l=r[s];p||(p=r[a],g=r[c]),l&&g.call(r,_,l);const h=r[s]=(()=>{if(r.readyState===r.DONE)if(!n.aborted&&r[i]&&e.state===y){const o=r[t.__symbol__("loadfalse")];if(o&&o.length>0){const s=e.invoke;e.invoke=function(){const o=r[t.__symbol__("loadfalse")];for(let t=0;t(function(e,t){return e[r]=0==t[2],e[l]=t[1],v.apply(e,t)})),T=d("fetchTaskAborting"),w=d("fetchTaskScheduling"),E=I(h,"send",()=>(function(e,n){if(!0===t.current[w])return E.apply(e,n);if(e[r])return E.apply(e,n);{const t={target:e,url:e[l],isPeriodic:!1,args:n,aborted:!1},o=f("XMLHttpRequest.send",k,t,m,b);e&&!0===e[u]&&!t.aborted&&o.state===y&&o.invoke()}})),Z=I(h,"abort",()=>(function(e,n){const r=function s(e){return e[o]}(e);if(r&&"string"==typeof r.type){if(null==r.cancelFn||r.data&&r.data.aborted)return;r.zone.cancelTask(r)}else if(!0===t.current[T])return Z.apply(e,n)}))}(e);const o=d("xhrTask"),r=d("xhrSync"),s=d("xhrListener"),i=d("xhrScheduled"),l=d("xhrURL"),u=d("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",t=>{t.navigator&&t.navigator.geolocation&&function n(t,o){const r=t.constructor.name;for(let n=0;n{const t=function(){return e.apply(this,b(arguments,r+"."+s))};return x(t,e),t})(i)}}}(t.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(e,t)=>{function n(t){return function(n){U(e,t).forEach(o=>{const r=e.PromiseRejectionEvent;if(r){const e=new r(t,{promise:n.promise,reason:n.rejection});o.invoke(e)}})}}e.PromiseRejectionEvent&&(t[d("unhandledPromiseRejectionHandler")]=n("unhandledrejection"),t[d("rejectionHandledHandler")]=n("rejectionhandled"))})}); \ No newline at end of file diff --git a/dist/zone-legacy.js b/dist/zone-legacy.js old mode 100644 new mode 100755 index ab6b76b57..0da889011 --- a/dist/zone-legacy.js +++ b/dist/zone-legacy.js @@ -5,338 +5,327 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 eventTargetLegacyPatch(_global, api) { - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - 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,WebSocket' - .split(','); - var EVENT_TARGET = 'EventTarget'; - var apis = []; - var isWtf = _global['wtf']; - var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); - if (isWtf) { - // Workaround for: https://github.com/google/tracing-framework/issues/555 - apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); - } - else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); - } - else { - // Note: EventTarget is not available in all browsers, - // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget - apis = NO_EVENT_TARGET; - } - var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; - var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - var ieOrEdge = api.isIEOrEdge(); - var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; - var FUNCTION_WRAPPER = '[object FunctionWrapper]'; - var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - // predefine all task.source string - for (var i = 0; i < WTF_ISSUE_555.length; i++) { - var target = WTF_ISSUE_555_ARRAY[i]; - var targets = globalSources[target] = {}; - for (var j = 0; j < eventNames.length; j++) { - var eventName = eventNames[j]; - targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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 eventTargetLegacyPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + 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,WebSocket' + .split(','); + var EVENT_TARGET = 'EventTarget'; + var apis = []; + var isWtf = _global['wtf']; + var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); + if (isWtf) { + // Workaround for: https://github.com/google/tracing-framework/issues/555 + apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); } - } - var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { - if (!isDisableIECheck && ieOrEdge) { - if (isEnableCrossContextCheck) { - try { + 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; + } + var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; + var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; + var ieOrEdge = api.isIEOrEdge(); + var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; + var FUNCTION_WRAPPER = '[object FunctionWrapper]'; + var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + // predefine all task.source string + for (var i = 0; i < WTF_ISSUE_555.length; i++) { + var target = WTF_ISSUE_555_ARRAY[i]; + var targets = globalSources[target] = {}; + for (var j = 0; j < eventNames.length; j++) { + var eventName = eventNames[j]; + targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + } + } + var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { + if (!isDisableIECheck && ieOrEdge) { + if (isEnableCrossContextCheck) { + try { + var testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } + catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } + else { var testString = delegate.toString(); if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { nativeDelegate.apply(target, args); return false; } } - catch (error) { - nativeDelegate.apply(target, args); - return false; - } } - else { - var testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + else if (isEnableCrossContextCheck) { + try { + delegate.toString(); + } + catch (error) { nativeDelegate.apply(target, args); return false; } } + return true; + }; + var apiTypes = []; + for (var i = 0; i < apis.length; i++) { + var type = _global[apis[i]]; + apiTypes.push(type && type.prototype); } - else if (isEnableCrossContextCheck) { - try { - delegate.toString(); + // vh is validateHandler to check event handler + // is valid or not(for security check) + api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; + return true; + } + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + // we have to patch the instance since the proto is non-configurable + function apply(api, _global) { + var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; + var WS = _global.WebSocket; + // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener + // On older Chrome, no need since EventTarget was already patched + if (!_global.EventTarget) { + api.patchEventTarget(_global, [WS.prototype]); + } + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); + var proxySocket; + var proxySocketProto; + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = api.ObjectCreate(socket); + // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' + // but proxySocket not, so we will keep socket as prototype and pass it to + // patchOnProperties method + proxySocketProto = socket; + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { + proxySocket[propName] = function () { + var args = api.ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { + var eventName = args.length > 0 ? args[0] : undefined; + if (eventName) { + var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + socket[propertySymbol] = proxySocket[propertySymbol]; + } + } + return socket[propName].apply(socket, args); + }; + }); } - catch (error) { - nativeDelegate.apply(target, args); - return false; + else { + // we can patch the real socket + proxySocket = socket; } + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + return proxySocket; + }; + var globalWebSocket = _global['WebSocket']; + for (var prop in WS) { + globalWebSocket[prop] = WS[prop]; } - return true; - }; - var apiTypes = []; - for (var i = 0; i < apis.length; i++) { - var type = _global[apis[i]]; - apiTypes.push(type && type.prototype); } - // vh is validateHandler to check event handler - // is valid or not(for security check) - api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); - Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; - return true; -} - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -// we have to patch the instance since the proto is non-configurable -function apply(api, _global) { - var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; - var WS = _global.WebSocket; - // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener - // On older Chrome, no need since EventTarget was already patched - if (!_global.EventTarget) { - api.patchEventTarget(_global, [WS.prototype]); - } - _global.WebSocket = function (x, y) { - var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); - var proxySocket; - var proxySocketProto; - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = api.ObjectCreate(socket); - // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' - // but proxySocket not, so we will keep socket as prototype and pass it to - // patchOnProperties method - proxySocketProto = socket; - [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { - proxySocket[propName] = function () { - var args = api.ArraySlice.call(arguments); - if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { - var eventName = args.length > 0 ? args[0] : undefined; - if (eventName) { - var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); - socket[propertySymbol] = proxySocket[propertySymbol]; - } - } - return socket[propName].apply(socket, 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 + */ + function propertyDescriptorLegacyPatch(api, _global) { + var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; + if (isNode && !isMix) { + return; } - else { - // we can patch the real socket - proxySocket = socket; + if (!canPatchViaPropertyDescriptor(api, _global)) { + var supportsWebSocket = typeof WebSocket !== 'undefined'; + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + apply(api, _global); + } + Zone[api.symbol('patchEvents')] = true; } - api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); - return proxySocket; - }; - var globalWebSocket = _global['WebSocket']; - for (var prop in WS) { - globalWebSocket[prop] = WS[prop]; - } -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -function propertyDescriptorLegacyPatch(api, _global) { - var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; - if (isNode && !isMix) { - return; } - if (!canPatchViaPropertyDescriptor(api, _global)) { - var supportsWebSocket = typeof WebSocket !== 'undefined'; - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(api); - api.patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - apply(api, _global); + function canPatchViaPropertyDescriptor(api, _global) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) + return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var div = document.createElement('div'); + var result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; + } } - Zone[api.symbol('patchEvents')] = true; - } -} -function canPatchViaPropertyDescriptor(api, _global) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((isBrowser || isMix) && - !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) + var XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker return false; - // try to use onclick to detect whether we can patch via propertyDescriptor - // because XMLHttpRequest is not available in service worker - if (desc) { - api.ObjectDefineProperty(Element.prototype, 'onclick', { + } + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { return true; } }); - var div = document.createElement('div'); - var result = !!div.onclick; - api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + var req = new XMLHttpRequest(); + var result = !!req.onreadystatechange; + // restore original desc + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + return result; + } + else { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; + }, + set: function (value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; + } + }); + var req = new XMLHttpRequest(); + var detectFunc = function () { }; + req.onreadystatechange = detectFunc; + var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = null; return result; } } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker - return false; - } - var ON_READY_STATE_CHANGE = 'onreadystatechange'; - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return true; - } - }); - var req = new XMLHttpRequest(); - var result = !!req.onreadystatechange; - // restore original desc - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } - else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; - }, - set: function (value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; - } - }); - var req = new XMLHttpRequest(); - var detectFunc = function () { }; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; - req.onreadystatechange = null; - return result; - } -} -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents(api) { - var eventNames = api.getGlobalObjects().eventNames; - var unboundKey = api.symbol('unbound'); - var _loop_1 = function (i) { - var property = eventNames[i]; - var onproperty = 'on' + property; - self.addEventListener(property, function (event) { - var elt = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } - else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = api.wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; + // Whenever any eventListener fires, we check the eventListener target and all parents + // for `onwhatever` properties and replace them with zone-bound functions + // - Chrome (for now) + function patchViaCapturingAllTheEvents(api) { + var eventNames = api.getGlobalObjects().eventNames; + var unboundKey = api.symbol('unbound'); + var _loop_1 = function (i) { + var property = eventNames[i]; + var onproperty = 'on' + property; + self.addEventListener(property, function (event) { + var elt = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; } - elt = elt.parentElement; - } - }, true); - }; - for (var i = 0; i < eventNames.length; i++) { - _loop_1(i); + else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = api.wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; + } + elt = elt.parentElement; + } + }, true); + }; + for (var i = 0; i < eventNames.length; i++) { + _loop_1(i); + } } -} - -/** - * @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, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('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 + */ + function registerElementPatch(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); } - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -(function (_global) { - _global['__zone_symbol__legacyPatch'] = function () { - var Zone = _global['Zone']; - Zone.__load_patch('registerElement', function (global, Zone, api) { - registerElementPatch(global, api); - }); - Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { - eventTargetLegacyPatch(global, api); - propertyDescriptorLegacyPatch(api, global); - }); - }; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -}))); + /** + * @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) { + _global[Zone.__symbol__('legacyPatch')] = function () { + var Zone = _global['Zone']; + Zone.__load_patch('registerElement', function (global, Zone, api) { + registerElementPatch(global, api); + }); + Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); + }; + })(typeof window !== 'undefined' ? + window : + typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); +})); +//# sourceMappingURL=zone-legacy-rollup.umd.js.map diff --git a/dist/zone-legacy.min.js b/dist/zone-legacy.min.js old mode 100644 new mode 100755 index 292949830..146fdcf9c --- a/dist/zone-legacy.min.js +++ b/dist/zone-legacy.min.js @@ -1 +1,52 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";function e(e,t){var n=t.getGlobalObjects(),r=n.eventNames,o=n.globalSources,a=n.zoneSymbolEventNames,c=n.TRUE_STR,i=n.FALSE_STR,l=n.ZONE_SYMBOL_PREFIX,s="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",u="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,WebSocket".split(","),p=[],f=e.wtf,b=s.split(",");f?p=b.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget?p.push("EventTarget"):p=u;for(var d=e.__Zone_disable_IE_check||!1,g=e.__Zone_enable_cross_context_check||!1,v=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",E=0;E1?new a(t,n):new a(t),s=e.ObjectGetOwnPropertyDescriptor(l,"onmessage");return s&&!1===s.configurable?(c=e.ObjectCreate(l),i=l,[r,o,"send","close"].forEach(function(t){c[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var i=Zone.__symbol__("ON_PROPERTY"+a);l[i]=c[i]}}return l[t].apply(l,n)}})):c=l,e.patchOnProperties(c,["close","error","message","open"],i),c};var c=t.WebSocket;for(var i in a)c[i]=a[i]}(e,t),Zone[e.symbol("patchEvents")]=!0}}var n;(n="undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global).__zone_symbol__legacyPatch=function(){var r=n.Zone;r.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),r.__load_patch("EventTargetLegacy",function(n,r,o){e(n,o),t(o,n)})}}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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 e(e,t){var n=t.getGlobalObjects(),r=n.eventNames,a=n.globalSources,o=n.zoneSymbolEventNames,c=n.TRUE_STR,i=n.FALSE_STR,l=n.ZONE_SYMBOL_PREFIX,s="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",u="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,WebSocket".split(","),p=[],f=e.wtf,b=s.split(",");f?p=b.map(function(e){return"HTML"+e+"Element"}).concat(u):e.EventTarget?p.push("EventTarget"):p=u;for(var d=e.__Zone_disable_IE_check||!1,g=e.__Zone_enable_cross_context_check||!1,v=t.isIEOrEdge(),y="function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }",E=0;E1?new o(t,n):new o(t),s=e.ObjectGetOwnPropertyDescriptor(l,"onmessage");return s&&!1===s.configurable?(c=e.ObjectCreate(l),i=l,[r,a,"send","close"].forEach(function(t){c[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===a){var o=n.length>0?n[0]:void 0;if(o){var i=Zone.__symbol__("ON_PROPERTY"+o);l[i]=c[i]}}return l[t].apply(l,n)}})):c=l,e.patchOnProperties(c,["close","error","message","open"],i),c};var c=t.WebSocket;for(var i in o)c[i]=o[i]}(e,t),Zone[e.symbol("patchEvents")]=!0}} +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +var n;(n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{})[Zone.__symbol__("legacyPatch")]=function(){var r=n.Zone;r.__load_patch("registerElement",function(e,t,n){!function r(e,t){var n=t.getGlobalObjects();(n.isBrowser||n.isMix)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])} +/** + * @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 + */(e,n)}),r.__load_patch("EventTargetLegacy",function(n,r,a){e(n,a),t(a,n)})}}); \ No newline at end of file diff --git a/dist/zone-mix.js b/dist/zone-mix.js old mode 100644 new mode 100755 index c8354162d..120f55a61 --- a/dist/zone-mix.js +++ b/dist/zone-mix.js @@ -5,1931 +5,2011 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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) { - var performance = global['performance']; - function mark(name) { - performance && performance['mark'] && performance['mark'](name); - } - function performanceMeasure(name, label) { - performance && performance['measure'] && performance['measure'](name, label); - } - mark('Zone'); - var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; - if (global['Zone']) { - // if global['Zone'] already exists (maybe zone.js was already loaded or - // some other lib also registered a global object named Zone), we may need - // to throw an error, but sometimes user may not want this error. - // For example, - // we have two web pages, page1 includes zone.js, page2 doesn't. - // and the 1st time user load page1 and page2, everything work fine, - // but when user load page2 again, error occurs because global['Zone'] already exists. - // so we add a flag to let user choose whether to throw this error or not. - // By default, if existing Zone is from zone.js, we will not throw the error. - if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { - throw new Error('Zone already loaded.'); - } - else { - return global['Zone']; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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) { + var performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + var symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + var checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } - } - var Zone = /** @class */ (function () { - function Zone(parent, zoneSpec) { - this._parent = parent; - this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); - } - Zone.assertZonePatched = function () { - if (global['Promise'] !== patches['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.)'); + var Zone = /** @class */ (function () { + function Zone(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); } - }; - Object.defineProperty(Zone, "root", { - get: function () { - var zone = Zone.current; - while (zone.parent) { - zone = zone.parent; + Zone.assertZonePatched = function () { + if (global['Promise'] !== patches['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.)'); } - return zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "current", { - get: function () { - return _currentZoneFrame.zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "currentTask", { - get: function () { - return _currentTask; - }, - enumerable: true, - configurable: true - }); - Zone.__load_patch = function (name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); + }; + Object.defineProperty(Zone, "root", { + get: function () { + var zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "current", { + get: function () { + return _currentZoneFrame.zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "currentTask", { + get: function () { + return _currentTask; + }, + enumerable: true, + configurable: true + }); + Zone.__load_patch = function (name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } - } - else if (!global['__Zone_disable_' + name]) { - var perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - }; - Object.defineProperty(Zone.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Zone.prototype.get = function (key) { - var zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - }; - Zone.prototype.getZoneWith = function (key) { - var current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; + else if (!global['__Zone_disable_' + name]) { + var perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); } - current = current._parent; - } - return null; - }; - Zone.prototype.fork = function (zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - }; - Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - var _callback = this._zoneDelegate.intercept(this, callback, source); - var zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); }; - }; - Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = null; } - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { + Object.defineProperty(Zone.prototype, "parent", { + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Zone.prototype.get = function (key) { + var zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + }; + Zone.prototype.getZoneWith = function (key) { + var current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + }; + Zone.prototype.fork = function (zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + }; + Zone.prototype.wrap = function (callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + var _callback = this._zoneDelegate.intercept(this, callback, source); + var zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + }; + Zone.prototype.run = function (callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { + if (applyThis === void 0) { applyThis = null; } + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runTask = function (task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - var reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - var previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; + finally { + _currentZoneFrame = _currentZoneFrame.parent; } - try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + }; + Zone.prototype.runTask = function (task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + var reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + var previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } } - else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + }; + Zone.prototype.scheduleTask = function (task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + var newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + } + newZone = newZone.parent; } } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - }; - Zone.prototype.scheduleTask = function (task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - var newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); - } - newZone = newZone.parent; - } - } - task._transitionTo(scheduling, notScheduled); - var zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - }; - Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - }; - Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.cancelTask = function (task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - }; - Zone.prototype._updateTaskCount = function (task, count) { - var zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (var i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); - } - }; + task._transitionTo(scheduling, notScheduled); + var zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + }; + Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + }; + Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.cancelTask = function (task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + }; + Zone.prototype._updateTaskCount = function (task, count) { + var zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (var i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + }; + return Zone; + }()); Zone.__symbol__ = __symbol__; - return Zone; - }()); - var DELEGATE_ZS = { - name: '', - onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, - onScheduleTask: function (delegate, _, target, task) { - return delegate.scheduleTask(target, task); - }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { - return delegate.invokeTask(target, task, applyThis, applyArgs); - }, - onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } - }; - var ZoneDelegate = /** @class */ (function () { - function ZoneDelegate(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; - } - } - } - ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - }; - ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; + var DELEGATE_ZS = { + name: '', + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, + onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; - ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.handleError = function (targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - }; - ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { - var returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + var ZoneDelegate = /** @class */ (function () { + function ZoneDelegate(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; + } } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; } - else { - if (task.scheduleFn) { - task.scheduleFn(task); + ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + }; + ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + }; + ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.handleError = function (targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + }; + ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { + var returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); + } + else { + throw new Error('Task is missing scheduleFn.'); + } } - else if (task.type == microTask) { - scheduleMicroTask(task); + return returnTask; + }; + ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.cancelTask = function (targetZone, task) { + var value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); } else { - throw new Error('Task is missing scheduleFn.'); + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); } - } - return returnTask; - }; - ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.cancelTask = function (targetZone, task) { - var value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); + return value; + }; + ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } - value = task.cancelFn(task); - } - return value; - }; - ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback - try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); - } - catch (err) { - this.handleError(targetZone, err); - } - }; - ZoneDelegate.prototype._updateTaskCount = function (type, count) { - var counts = this._taskCounts; - var prev = counts[type]; - var next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - var isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type - }; - this.hasTask(this.zone, isEmpty); - } - }; - return ZoneDelegate; - }()); - var ZoneTask = /** @class */ (function () { - function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - var self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; - } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); - }; - } - } - ZoneTask.invokeTask = function (task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); + catch (err) { + this.handleError(targetZone, err); } - _numberOfNestedTaskFrames--; - } - }; - Object.defineProperty(ZoneTask.prototype, "zone", { - get: function () { - return this._zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ZoneTask.prototype, "state", { - get: function () { - return this._state; - }, - enumerable: true, - configurable: true - }); - ZoneTask.prototype.cancelScheduleRequest = function () { - this._transitionTo(notScheduled, scheduling); - }; - ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; + }; + ZoneDelegate.prototype._updateTaskCount = function (type, count) { + var counts = this._taskCounts; + var prev = counts[type]; + var next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + var isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); } - } - else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); - } - }; - ZoneTask.prototype.toString = function () { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); - } - }; - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - ZoneTask.prototype.toJSON = function () { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount }; - }; - return ZoneTask; - }()); - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var symbolSetTimeout = __symbol__('setTimeout'); - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var _microTaskQueue = []; - var _isDrainingMicrotaskQueue = false; - var nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); - } - } - if (nativeMicroTaskQueuePromise) { - var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); + return ZoneDelegate; + }()); + var ZoneTask = /** @class */ (function () { + function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + var self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; + } } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - var queue = _microTaskQueue; - _microTaskQueue = []; - for (var i = 0; i < queue.length; i++) { - var task = queue[i]; - try { - task.zone.runTask(task, null, null); + ZoneTask.invokeTask = function (task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); } - catch (error) { - _api.onUnhandledError(error); + _numberOfNestedTaskFrames--; + } + }; + Object.defineProperty(ZoneTask.prototype, "zone", { + get: function () { + return this._zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ZoneTask.prototype, "state", { + get: function () { + return this._state; + }, + enumerable: true, + configurable: true + }); + ZoneTask.prototype.cancelScheduleRequest = function () { + this._transitionTo(notScheduled, scheduling); + }; + ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; } } - } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var NO_ZONE = { name: 'NO ZONE' }; - var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - var patches = {}; - var _api = { - symbol: __symbol__, - currentZoneFrame: function () { return _currentZoneFrame; }, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, - patchEventTarget: function () { return []; }, - patchOnProperties: noop, - patchMethod: function () { return noop; }, - bindArguments: function () { return []; }, - patchThen: function () { return noop; }, - patchMacroTask: function () { return noop; }, - setNativePromise: function (NativePromise) { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: function () { return noop; }, - isIEOrEdge: function () { return false; }, - getGlobalObjects: function () { return undefined; }, - ObjectDefineProperty: function () { return noop; }, - ObjectGetOwnPropertyDescriptor: function () { return undefined; }, - ObjectCreate: function () { return undefined; }, - ArraySlice: function () { return []; }, - patchClass: function () { return noop; }, - wrapWithCurrentZone: function () { return noop; }, - filterProperties: function () { return []; }, - attachOriginToPatched: function () { return noop; }, - _redefineProperty: function () { return noop; }, - patchCallbacks: function () { return noop; } - }; - var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - var _currentTask = null; - var _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { - var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - var className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); - } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - var __symbol__ = api.symbol; - var _uncaughtPromiseErrors = []; - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var creationTrace = '__creationTrace__'; - api.onUnhandledError = function (e) { - if (api.showUncaughtError()) { - var rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); - } - else { - console.error(e); - } - } - }; - api.microtaskDrainDone = function () { - while (_uncaughtPromiseErrors.length) { - var _loop_1 = function () { - var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); - try { - uncaughtPromiseError.zone.runGuarded(function () { - throw uncaughtPromiseError; - }); + else { + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); } - catch (error) { - handleUnhandledRejection(error); + }; + ZoneTask.prototype.toString = function () { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); } }; - while (_uncaughtPromiseErrors.length) { - _loop_1(); - } - } - }; - var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + ZoneTask.prototype.toJSON = function () { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + }; + return ZoneTask; + }()); + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var symbolSetTimeout = __symbol__('setTimeout'); + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var _microTaskQueue = []; + var _isDrainingMicrotaskQueue = false; + var nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } } + task && _microTaskQueue.push(task); } - catch (err) { - } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - var symbolState = __symbol__('state'); - var symbolValue = __symbol__('value'); - var symbolFinally = __symbol__('finally'); - var symbolParentPromiseValue = __symbol__('parentPromiseValue'); - var symbolParentPromiseState = __symbol__('parentPromiseState'); - var source = 'Promise.then'; - var UNRESOLVED = null; - var RESOLVED = true; - var REJECTED = false; - var REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return function (v) { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + var queue = _microTaskQueue; + _microTaskQueue = []; + for (var i = 0; i < queue.length; i++) { + var task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var NO_ZONE = { name: 'NO ZONE' }; + var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + var patches = {}; + var _api = { + symbol: __symbol__, + currentZoneFrame: function () { return _currentZoneFrame; }, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, + patchEventTarget: function () { return []; }, + patchOnProperties: noop, + patchMethod: function () { return noop; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, + setNativePromise: function (NativePromise) { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); + } + }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } + }; + var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + var _currentTask = null; + var _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); + /** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + var className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + var __symbol__ = api.symbol; + var _uncaughtPromiseErrors = []; + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var creationTrace = '__creationTrace__'; + api.onUnhandledError = function (e) { + if (api.showUncaughtError()) { + var rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); + } } - // Do not return value or you will break the Promise spec. }; - } - var once = function () { - var wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; + api.microtaskDrainDone = function () { + while (_uncaughtPromiseErrors.length) { + var _loop_1 = function () { + var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(function () { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + }; + while (_uncaughtPromiseErrors.length) { + _loop_1(); } - wasCalled = true; - wrappedFunction.apply(null, arguments); - }; + } }; - }; - var TYPE_ERROR = 'Promise resolved with itself'; - var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - var onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); - } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - var then = null; + var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; + var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); } } catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); - return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); } - else if (state !== REJECTED && typeof then === 'function') { + } + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + var symbolState = __symbol__('state'); + var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); + var source = 'Promise.then'; + var UNRESOLVED = null; + var RESOLVED = true; + var REJECTED = false; + var REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return function (v) { + try { + resolvePromise(promise, state, v); + } + catch (err) { + resolvePromise(promise, false, err); + } + // Do not return value or you will break the Promise spec. + }; + } + var once = function () { + var wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; + }; + }; + var TYPE_ERROR = 'Promise resolved with itself'; + var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + var onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + var then = null; try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } } catch (err) { onceWrapper(function () { resolvePromise(promise, false, err); })(); + return promise; } - } - else { - promise[symbolState] = state; - var queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; - } - } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - var trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); - } - } - for (var i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); - } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { - var error_1 = err; - error_1.rejection = value; - error_1.promise = promise; - error_1.zone = Zone.current; - error_1.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error_1); - api.scheduleMicroTask(); // to make sure that it is running + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + var queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + var trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (var i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + var error = err; + error.rejection = value; + error.promise = promise; + error.zone = Zone.current; + error.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error); + api.scheduleMicroTask(); // to make sure that it is running + } } } } + // Resolving an already resolved promise is a noop. + return promise; } - // Resolving an already resolved promise is a noop. - return promise; - } - var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); + var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + var handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } } - } - catch (err) { - } - promise[symbolState] = REJECTED; - for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); + catch (err) { + } + promise[symbolState] = REJECTED; + for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } } } } - } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - var promiseState = promise[symbolState]; - var delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, function () { - try { - var parentPromiseValue = promise[symbolValue]; - var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); - } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); - } - }, chainPromise); - } - var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = /** @class */ (function () { - function ZoneAwarePromise(executor) { - var promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); - } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); - } - catch (error) { - resolvePromise(promise, false, error); - } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + var promiseState = promise[symbolState]; + var delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, function () { + try { + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); } - ZoneAwarePromise.toString = function () { - return ZONE_AWARE_PROMISE_TO_STRING; - }; - ZoneAwarePromise.resolve = function (value) { - return resolvePromise(new this(null), RESOLVED, value); - }; - ZoneAwarePromise.reject = function (error) { - return resolvePromise(new this(null), REJECTED, error); - }; - ZoneAwarePromise.race = function (values) { - var e_1, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); - } - function onReject(error) { - reject(error); + var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + var ZoneAwarePromise = /** @class */ (function () { + function ZoneAwarePromise(executor) { + var promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; + ZoneAwarePromise.toString = function () { + return ZONE_AWARE_PROMISE_TO_STRING; + }; + ZoneAwarePromise.resolve = function (value) { + return resolvePromise(new this(null), RESOLVED, value); + }; + ZoneAwarePromise.reject = function (error) { + return resolvePromise(new this(null), REJECTED, error); + }; + ZoneAwarePromise.race = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; if (!isThenable(value)) { value = this.resolve(value); } value.then(onResolve, onReject); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + return promise; + }; + ZoneAwarePromise.all = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; + var resolvedValues = []; + var _loop_2 = function (value) { + if (!isThenable(value)) { + value = this_1.resolve(value); + } + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + _loop_2(value); } - finally { if (e_1) throw e_1.error; } - } - return promise; - }; - ZoneAwarePromise.all = function (values) { - var e_2, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - var unresolvedCount = 2; - var valueIndex = 0; - var resolvedValues = []; - var _loop_2 = function (value) { - if (!isThenable(value)) { - value = this_1.resolve(value); - } - var curValueIndex = valueIndex; - value.then(function (value) { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; + ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { + var chainPromise = new this.constructor(null); + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; }; - var this_1 = this; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - _loop_2(value); + ZoneAwarePromise.prototype.catch = function (onRejected) { + return this.then(null, onRejected); + }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); } - finally { if (e_2) throw e_2.error; } - } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - return promise; - }; - Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { - get: function () { - return 'Promise'; - }, - enumerable: true, - configurable: true - }); - ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { - var chainPromise = new this.constructor(null); - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); - } - return chainPromise; - }; - ZoneAwarePromise.prototype.catch = function (onRejected) { - return this.then(null, onRejected); - }; - ZoneAwarePromise.prototype.finally = function (onFinally) { - var chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); - } - return chainPromise; - }; - return ZoneAwarePromise; - }()); - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - var NativePromise = global[symbolPromise] = global['Promise']; - var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; - } - desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; - } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); + return chainPromise; + }; + return ZoneAwarePromise; + }()); + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + var NativePromise = global[symbolPromise] = global['Promise']; + var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + var symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; } - }; - ObjectDefineProperty(global, 'Promise', desc); - } - global['Promise'] = ZoneAwarePromise; - var symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - var proto = Ctor.prototype; - var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case - return; + var originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + var _this = this; + var wrapped = new ZoneAwarePromise(function (resolve, reject) { + originalThen.call(_this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; } - var originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - var _this = this; - var wrapped = new ZoneAwarePromise(function (resolve, reject) { - originalThen.call(_this, resolve, reject); - }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; - } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); + /** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + var ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + var ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Array.prototype.slice */ + var ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + var ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + var TRUE_STR = 'true'; + /** false string const */ + var FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + var ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); + } + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); + } + var zoneSymbol = Zone.__symbol__; + var isWindowExists = typeof window !== 'undefined'; + var internalWindow = isWindowExists ? window : undefined; + var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + var REMOVE_ATTRIBUTE = 'removeAttribute'; + var NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; + } + function patchPrototype(prototype, fnNames) { + var source = prototype.constructor['name']; + var _loop_3 = function (i) { + var name_1 = fnNames[i]; + var delegate = prototype[name_1]; + if (delegate) { + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); + if (!isPropertyWritable(prototypeDesc)) { + return "continue"; + } + prototype[name_1] = (function (delegate) { + var patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); } - return resultPromise; }; - } - if (NativePromise) { - patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global[api.symbol('fetch')] = fetch_1; - global['fetch'] = zoneify(fetch_1); - } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); - -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -var ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -var ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ - -/** Array.prototype.slice */ -var ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -var ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -var TRUE_STR = 'true'; -/** false string const */ -var FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -var zoneSymbol = Zone.__symbol__; -var isWindowExists = typeof window !== 'undefined'; -var internalWindow = isWindowExists ? window : undefined; -var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -var REMOVE_ATTRIBUTE = 'removeAttribute'; -var NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); - } - } - return args; -} -function patchPrototype(prototype, fnNames) { - var source = prototype.constructor['name']; - var _loop_1 = function (i) { - var name_1 = fnNames[i]; - var delegate = prototype[name_1]; - if (delegate) { - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); - if (!isPropertyWritable(prototypeDesc)) { - return "continue"; - } - prototype[name_1] = (function (delegate) { - var patched = function () { - return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); - }; - attachOriginToPatched(patched, delegate); - return patched; - })(delegate); - } - }; - for (var i = 0; i < fnNames.length; i++) { - _loop_1(i); - } -} -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -var zoneSymbolEventNames = {}; -var wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - var eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); - } - var target = this || event.target || _global; - var listener = target[eventNameSymbol]; - var result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - var errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); - } - } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + for (var i = 0; i < fnNames.length; i++) { + _loop_3(i); } } - return result; -}; -function patchProperty(obj, prop, prototype) { - var desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; } - } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - var originalDescGet = desc.get; - var originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; + if (propertyDesc.writable === false) { + return false; } - if (!target) { + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); + } + var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + var zoneSymbolEventNames = {}; + var wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - var previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); + var eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); - } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); + var target = this || event.target || _global; + var listener = target[eventNameSymbol]; + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } } else { - target[eventNameSymbol] = null; + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } + return result; }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; + function patchProperty(obj, prop, prototype) { + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; } - if (!target) { - return null; + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; } - var listener = target[eventNameSymbol]; - if (listener) { - return listener; - } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + var originalDescGet = desc.get; + var originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; + } + var previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); + } + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); + } + else { + target[eventNameSymbol] = null; + } + }; + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + var listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + var value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; } - return value; } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (var i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } + return null; + }; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } - else { - var onProperties = []; - for (var prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (var i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); } } - for (var j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); + else { + var onProperties = []; + for (var prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); + } + } + for (var j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); + } } } -} -var originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` -function patchClass(className) { - var OriginalClass = _global[className]; - if (!OriginalClass) - return; - // keep original class in global - _global[zoneSymbol(className)] = OriginalClass; - _global[className] = function () { - var a = bindArguments(arguments, className); - switch (a.length) { - case 0: - this[originalInstanceKey] = new OriginalClass(); - break; - case 1: - this[originalInstanceKey] = new OriginalClass(a[0]); - break; - case 2: - this[originalInstanceKey] = new OriginalClass(a[0], a[1]); - break; - case 3: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); - break; - case 4: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); - break; - default: - throw new Error('Arg list too long.'); - } - }; - // attach original delegate to patched function - attachOriginToPatched(_global[className], OriginalClass); - var instance = new OriginalClass(function () { }); - var prop; - for (prop in instance) { - // https://bugs.webkit.org/show_bug.cgi?id=44721 - if (className === 'XMLHttpRequest' && prop === 'responseBlob') - continue; - (function (prop) { - if (typeof instance[prop] === 'function') { - _global[className].prototype[prop] = function () { - return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); - }; + var originalInstanceKey = zoneSymbol('originalInstance'); + // wrap some native API on `window` + function patchClass(className) { + var OriginalClass = _global[className]; + if (!OriginalClass) + return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + var a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); } - else { - ObjectDefineProperty(_global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); - // keep callback in wrapped function so we can - // use it in Function.prototype.toString to return - // the native one. - attachOriginToPatched(this[originalInstanceKey][prop], fn); - } - else { - this[originalInstanceKey][prop] = fn; + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + var instance = new OriginalClass(function () { }); + var prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; } - }, - get: function () { - return this[originalInstanceKey][prop]; - } - }); + }); + } + }(prop)); + } + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; } - }(prop)); + } } - for (prop in OriginalClass) { - if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { - _global[className][prop] = OriginalClass[prop]; + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); } -} -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; + var shouldCopySymbolProperties = false; + function setShouldCopySymbolProperties(flag) { + shouldCopySymbolProperties = flag; } - var symbols = Object.getOwnPropertySymbols(src); - symbols.forEach(function (symbol) { - var desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; + function patchMethod(target, name, patchFn) { + var proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + var delegateName = zoneSymbol(name); + var delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + var patchDelegate_1 = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate_1(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -var shouldCopySymbolProperties = false; -function setShouldCopySymbolProperties(flag) { - shouldCopySymbolProperties = flag; -} -function patchMethod(target, name, patchFn) { - var proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); + } + } + return delegate; } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; + } + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }; }); } - var delegateName = zoneSymbol(name); - var delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - var patchDelegate_1 = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate_1(this, arguments); + function patchMicroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); - } + setNative.apply(data.target, data.args); + return task; } + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }; }); } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; - } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); - } - else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} -function patchMicroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); + function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; + } } - else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} -function isIE() { - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { - return true; + catch (error) { } + return false; } - catch (error) { - } - return false; -} - -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', function (global) { - // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Function.prototype.toString; - var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - var PROMISE_SYMBOL = zoneSymbol('Promise'); - var ERROR_SYMBOL = zoneSymbol('Error'); - var newFunctionToString = function toString() { - if (typeof this === 'function') { - var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); + /** + * @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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', function (global) { + // patch Func.prototype.toString to let them look like native + var originalFunctionToString = Function.prototype.toString; + var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + var PROMISE_SYMBOL = zoneSymbol('Promise'); + var ERROR_SYMBOL = zoneSymbol('Error'); + var newFunctionToString = function toString() { + if (typeof this === 'function') { + var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } } - else { - return Object.prototype.toString.call(originalDelegate); + if (this === Promise) { + var nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } } - } - if (this === Promise) { - var nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); + if (this === Error) { + var nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } } } - if (this === Error) { - var nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + var originalObjectToString = Object.prototype.toString; + var PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; + }); + /** + * @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 passiveSupported = false; + if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; } - } - } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - var originalObjectToString = Object.prototype.toString; - var PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; - } - return originalObjectToString.call(this); - }; -}); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var passiveSupported = false; -if (typeof window !== 'undefined') { - try { - var options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } - }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); - } - catch (err) { - passiveSupported = false; - } -} -// an identifier to tell ZoneTask do not create a new invoke closure -var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -var zoneSymbolEventNames$1 = {}; -var globalSources = {}; -var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - var PREPEND_EVENT_LISTENER = 'prependListener'; - var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { - return; + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); } - var delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = function (event) { return delegate.handleEvent(event); }; - task.originalDelegate = delegate; - } - // invoke static task.invoke - task.invoke(task, target, [event]); - var options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + catch (err) { + passiveSupported = false; } + } + // an identifier to tell ZoneTask do not create a new invoke closure + var OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true }; - // global shared zoneAwareCallback to handle all event callback with capture = false - var globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + var zoneSymbolEventNames$1 = {}; + var globalSources = {}; + var EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + var PREPEND_EVENT_LISTENER = 'prependListener'; + var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + var invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } + var delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = function (event) { return delegate.handleEvent(event); }; + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + var options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - var globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + var globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); } - invokeTask(copyTasks[i], target, event); } } - } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - var useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - var validateHandler = patchOptions && patchOptions.vh; - var checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; - } - var returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; - } - var proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; - } - if (!proto) { - return false; - } - if (proto[zoneSymbolAddEventListener]) { - return false; - } - var eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - var taskData = {}; - var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - var nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } - } - var customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + var globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); - }; - var customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - var symbolEventName = void 0; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); } - var existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { break; } + invokeTask(copyTasks[i], target, event); } } } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { - return; - } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - var customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - var compareTaskCallbackVsDelegate = function (task, delegate) { - var typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { - if (returnTarget === void 0) { returnTarget = false; } - if (prepend === void 0) { prepend = false; } - return function () { - var target = this || _global; - var eventName = arguments[0]; - var delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - var isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + var useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + var validateHandler = patchOptions && patchOptions.vh; + var checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + var returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + var proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + var eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + var taskData = {}; + var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + var nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + var customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + var symbolEventName = void 0; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } } - isHandleEvent = true; } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { return; } - var options = arguments[2]; - if (blackListedEvents) { - // check black list - for (var i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + var customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + var compareTaskCallbackVsDelegate = function (task, delegate) { + var typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + var blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { + if (returnTarget === void 0) { returnTarget = false; } + if (prepend === void 0) { prepend = false; } + return function () { + var target = this || _global; + var eventName = arguments[0]; + var delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + var isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } + isHandleEvent = true; } - } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + var options = arguments[2]; + if (blackListedEvents) { + // check black list + for (var i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + var capture; + var once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + var zone = Zone.current; + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = target[symbolEventName]; + var isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (var i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + var source; + var constructorName = target.constructor['name']; + var targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var options = arguments[2]; var capture; - var once = false; if (options === undefined) { capture = false; } @@ -1941,1345 +2021,1201 @@ function patchEventTarget(_global, apis, patchOptions) { } else { capture = options ? !!options.capture : false; - once = options ? !!options.once : false; } - var zone = Zone.current; + var delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } var symbolEventNames = zoneSymbolEventNames$1[eventName]; var symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { + if (symbolEventNames) { symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } - var existingTasks = target[symbolEventName]; - var isExisting = false; + var existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (var i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; + } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; } + return; } } } - else { - existingTasks = target[symbolEventName] = []; - } - var source; - var constructorName = target.constructor['name']; - var targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var listeners = []; + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (var i = 0; i < tasks.length; i++) { + var task = tasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); + } + return listeners; + }; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + if (!eventName) { + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); + } + } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } else { - existingTasks.unshift(task); + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + var symbolEventName = symbolEventNames[FALSE_STR]; + var symbolCaptureEventName = symbolEventNames[TRUE_STR]; + var tasks = target[symbolEventName]; + var captureTasks = target[symbolCaptureEventName]; + if (tasks) { + var removeTasks = tasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + if (captureTasks) { + var removeTasks = captureTasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } + } + } } if (returnTarget) { - return target; + return this; } }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var options = arguments[2]; - var capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); } - var delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; + return true; + } + var results = []; + for (var i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; + } + function findEventTasks(target, eventName) { + var foundTasks = []; + for (var prop in target) { + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + var tasks = target[prop]; + if (tasks) { + for (var i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } + } } - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; + } + return foundTasks; + } + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + 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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; } - return; } } } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var listeners = []; - var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - if (!eventName) { - var keys = Object.keys(target); - for (var i = 0; i < keys.length; i++) { - var prop = keys[i]; - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); - } - } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - var symbolEventName = symbolEventNames[FALSE_STR]; - var symbolCaptureEventName = symbolEventNames[TRUE_STR]; - var tasks = target[symbolEventName]; - var captureTasks = target[symbolCaptureEventName]; - if (tasks) { - var removeTasks = tasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); - } + data.args[0] = timer; + 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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); + if (!task) { + return task; } - if (captureTasks) { - var removeTasks = captureTasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + // Node.js must additionally support the ref and unref functions. + var handle = task.data.handleId; + if (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return 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 id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; } + // 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 + */ + function patchCustomElements(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { + return; + } + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); + } + /** + * @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 + */ + /* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ + var zoneSymbol$1 = Zone.__symbol__; + var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; + var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; + var _create = Object.create; + var unconfigurablesKey = zoneSymbol$1('unconfigurables'); + function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + var originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); } - if (returnTarget) { - return this; + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + var desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; } + return desc; }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); - } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); - } - return true; } - var results = []; - for (var i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); + function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; } - return results; -} -function findEventTasks(target, eventName) { - var foundTasks = []; - for (var prop in target) { - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - var tasks = target[prop]; - if (tasks) { - for (var i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); - } - } + function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; } - } - return foundTasks; -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; - } - } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; } } - data.args[0] = timer; - data.handleId = setNative.apply(window, data.args); - return task; - } - function clearTask(task) { - return clearNative(task.data.handleId); + return desc; } - setNative = - patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === 'function') { - var options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); + function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; } - if (typeof handle === 'number' || handle) { - return handle; + else { + desc.configurable = originalConfigurableFlag; } - 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; + try { + return _defineProperty(obj, prop, desc); } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + catch (error) { + var descJson = null; + try { + descJson = JSON.stringify(desc); } - else if (id) { - id[taskSymbol] = null; + catch (error) { + descJson = desc.toString(); } - // Do not cancel already canceled functions - task.zone.cancelTask(task); + console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); } } else { - // cause an error by calling it directly. - delegate.apply(window, args); + throw error; } - }; }); -} - -/** - * @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 patchCustomElements(_global, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { - return; - } - var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); -} - -/** - * @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 - */ -/* - * This is necessary for Chrome and Chrome mobile, to enable - * things like redefining `createdCallback` on an element. - */ -var zoneSymbol$1 = Zone.__symbol__; -var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; -var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = - Object.getOwnPropertyDescriptor; -var _create = Object.create; -var unconfigurablesKey = zoneSymbol$1('unconfigurables'); -function propertyPatch() { - Object.defineProperty = function (obj, prop, desc) { - if (isUnconfigurable(obj, prop)) { - throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); - } - var originalConfigurableFlag = desc.configurable; - if (prop !== 'prototype') { - desc = rewriteDescriptor(obj, prop, desc); - } - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); - }; - Object.defineProperties = function (obj, props) { - Object.keys(props).forEach(function (prop) { - Object.defineProperty(obj, prop, props[prop]); - }); - return obj; - }; - Object.create = function (obj, proto) { - if (typeof proto === 'object' && !Object.isFrozen(proto)) { - Object.keys(proto).forEach(function (prop) { - proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); - }); - } - return _create(obj, proto); - }; - Object.getOwnPropertyDescriptor = function (obj, prop) { - var desc = _getOwnPropertyDescriptor(obj, prop); - if (desc && isUnconfigurable(obj, prop)) { - desc.configurable = false; } - return desc; - }; -} - -function isUnconfigurable(obj, prop) { - return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; -} -function rewriteDescriptor(obj, prop, desc) { - // issue-927, if the desc is frozen, don't try to change the desc - if (!Object.isFrozen(desc)) { - desc.configurable = true; } - if (!desc.configurable) { - // issue-927, if the obj is frozen, don't try to set the desc to obj - if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { - _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + /** + * @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 eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; } - if (obj[unconfigurablesKey]) { - obj[unconfigurablesKey][prop] = true; + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; } - return desc; -} -function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - if (desc.configurable) { - // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's - // retry with the original flag value - if (typeof originalConfigurableFlag == 'undefined') { - delete desc.configurable; - } - else { - desc.configurable = originalConfigurableFlag; - } - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - var descJson = null; - try { - descJson = JSON.stringify(desc); - } - catch (error) { - descJson = desc.toString(); - } - console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); - } - } - else { - throw error; + function patchEvent(global, api) { + api.patchEventPrototype(global, api); + } + /** + * @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 globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' + ]; + var documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' + ]; + var windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' + ]; + var htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' + ]; + var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; + var ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' + ]; + var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; + var formEventNames = ['autocomplete', 'autocompleteerror']; + var detailEventNames = ['toggle']; + var frameEventNames = ['load']; + var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; + var marqueeEventNames = ['bounce', 'finish', 'start']; + var XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' + ]; + var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; + var websocketEventNames = ['close', 'error', 'open', 'message']; + var workerEventNames = ['error', 'message']; + var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); + function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); + if (!tip || tip.length === 0) { + return onProperties; + } + var targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); + } + function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; } + var filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, 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 - */ -function eventTargetPatch(_global, api) { - if (Zone[api.symbol('patchEventTarget')]) { - // EventTarget is already patched. - return; - } - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - var EVENT_TARGET = _global['EventTarget']; - if (!EVENT_TARGET || !EVENT_TARGET.prototype) { - return; - } - api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); - return true; -} -function patchEvent(global, api) { - api.patchEventPrototype(global, api); -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var globalEventHandlersEventNames = [ - 'abort', - 'animationcancel', - 'animationend', - 'animationiteration', - 'auxclick', - 'beforeinput', - 'blur', - 'cancel', - 'canplay', - 'canplaythrough', - 'change', - 'compositionstart', - 'compositionupdate', - 'compositionend', - 'cuechange', - 'click', - 'close', - 'contextmenu', - 'curechange', - 'dblclick', - 'drag', - 'dragend', - 'dragenter', - 'dragexit', - 'dragleave', - 'dragover', - 'drop', - 'durationchange', - 'emptied', - 'ended', - 'error', - 'focus', - 'focusin', - 'focusout', - 'gotpointercapture', - 'input', - 'invalid', - 'keydown', - 'keypress', - 'keyup', - 'load', - 'loadstart', - 'loadeddata', - 'loadedmetadata', - 'lostpointercapture', - 'mousedown', - 'mouseenter', - 'mouseleave', - 'mousemove', - 'mouseout', - 'mouseover', - 'mouseup', - 'mousewheel', - 'orientationchange', - 'pause', - 'play', - 'playing', - 'pointercancel', - 'pointerdown', - 'pointerenter', - 'pointerleave', - 'pointerlockchange', - 'mozpointerlockchange', - 'webkitpointerlockerchange', - 'pointerlockerror', - 'mozpointerlockerror', - 'webkitpointerlockerror', - 'pointermove', - 'pointout', - 'pointerover', - 'pointerup', - 'progress', - 'ratechange', - 'reset', - 'resize', - 'scroll', - 'seeked', - 'seeking', - 'select', - 'selectionchange', - 'selectstart', - 'show', - 'sort', - 'stalled', - 'submit', - 'suspend', - 'timeupdate', - 'volumechange', - 'touchcancel', - 'touchmove', - 'touchstart', - 'touchend', - 'transitioncancel', - 'transitionend', - 'waiting', - 'wheel' -]; -var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', - 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', - 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange', 'resume' -]; -var windowEventNames = [ - 'absolutedeviceorientation', - 'afterinput', - 'afterprint', - 'appinstalled', - 'beforeinstallprompt', - 'beforeprint', - 'beforeunload', - 'devicelight', - 'devicemotion', - 'deviceorientation', - 'deviceorientationabsolute', - 'deviceproximity', - 'hashchange', - 'languagechange', - 'message', - 'mozbeforepaint', - 'offline', - 'online', - 'paint', - 'pageshow', - 'pagehide', - 'popstate', - 'rejectionhandled', - 'storage', - 'unhandledrejection', - 'unload', - 'userproximity', - 'vrdisplyconnected', - 'vrdisplaydisconnected', - 'vrdisplaypresentchange' -]; -var htmlElementEventNames = [ - 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', - 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', - 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' -]; -var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; -var ieElementEventNames = [ - 'activate', - 'afterupdate', - 'ariarequest', - 'beforeactivate', - 'beforedeactivate', - 'beforeeditfocus', - 'beforeupdate', - 'cellchange', - 'controlselect', - 'dataavailable', - 'datasetchanged', - 'datasetcomplete', - 'errorupdate', - 'filterchange', - 'layoutcomplete', - 'losecapture', - 'move', - 'moveend', - 'movestart', - 'propertychange', - 'resizeend', - 'resizestart', - 'rowenter', - 'rowexit', - 'rowsdelete', - 'rowsinserted', - 'command', - 'compassneedscalibration', - 'deactivate', - 'help', - 'mscontentzoom', - 'msmanipulationstatechanged', - 'msgesturechange', - 'msgesturedoubletap', - 'msgestureend', - 'msgesturehold', - 'msgesturestart', - 'msgesturetap', - 'msgotpointercapture', - 'msinertiastart', - 'mslostpointercapture', - 'mspointercancel', - 'mspointerdown', - 'mspointerenter', - 'mspointerhover', - 'mspointerleave', - 'mspointermove', - 'mspointerout', - 'mspointerover', - 'mspointerup', - 'pointerout', - 'mssitemodejumplistitemremoved', - 'msthumbnailclick', - 'stop', - 'storagecommit' -]; -var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; -var formEventNames = ['autocomplete', 'autocompleteerror']; -var detailEventNames = ['toggle']; -var frameEventNames = ['load']; -var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; -var marqueeEventNames = ['bounce', 'finish', 'start']; -var XMLHttpRequestEventNames = [ - 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', - 'readystatechange' -]; -var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; -var websocketEventNames = ['close', 'error', 'open', 'message']; -var workerEventNames = ['error', 'message']; -var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); -function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties || ignoreProperties.length === 0) { - return onProperties; - } - var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); - if (!tip || tip.length === 0) { - return onProperties; - } - var targetIgnoreProperties = tip[0].ignoreProperties; - return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); -} -function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { - // check whether target is available, sometimes target will be undefined - // because different browser or some 3rd party plugin. - if (!target) { - return; - } - var filteredProperties = filterProperties(target, onProperties, ignoreProperties); - patchOnProperties(target, filteredProperties, prototype); -} -function propertyDescriptorPatch(api, _global) { - if (isNode && !isMix) { - return; - } - if (Zone[api.symbol('patchEvents')]) { - // events are already been patched by legacy patch. - return; - } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); - } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; } - } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (XMLHttpRequest) { - // XMLHttpRequest is not available in ServiceWorker, so we need to check here - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -Zone.__load_patch('legacy', function (global) { - var legacyPatch = global[Zone.__symbol__('legacyPatch')]; - if (legacyPatch) { - legacyPatch(); - } -}); -Zone.__load_patch('timers', function (global) { - var set = 'set'; - var clear = 'clear'; - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); -}); -Zone.__load_patch('requestAnimationFrame', function (global) { - patchTimer(global, 'request', 'cancel', 'AnimationFrame'); - patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); - patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); -}); -Zone.__load_patch('blocking', function (global, Zone) { - var blockingMethods = ['alert', 'prompt', 'confirm']; - for (var i = 0; i < blockingMethods.length; i++) { - var name_1 = blockingMethods[i]; - patchMethod(global, name_1, function (delegate, symbol, name) { - return function (s, args) { - return Zone.current.run(delegate, global, args, name); - }; - }); - } -}); -Zone.__load_patch('EventTarget', function (global, Zone, api) { - patchEvent(global, api); - eventTargetPatch(global, api); - // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener - var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { - api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); - } - patchClass('MutationObserver'); - patchClass('WebKitMutationObserver'); - patchClass('IntersectionObserver'); - patchClass('FileReader'); -}); -Zone.__load_patch('on_property', function (global, Zone, api) { - propertyDescriptorPatch(api, global); - propertyPatch(); -}); -Zone.__load_patch('customElements', function (global, Zone, api) { - patchCustomElements(global, api); -}); -Zone.__load_patch('XHR', function (global, Zone) { - // Treat XMLHttpRequest as a macrotask. - patchXHR(global); - var XHR_TASK = zoneSymbol('xhrTask'); - var XHR_SYNC = zoneSymbol('xhrSync'); - var XHR_LISTENER = zoneSymbol('xhrListener'); - var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); - var XHR_URL = zoneSymbol('xhrURL'); - var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); - function patchXHR(window) { - var XMLHttpRequest = window['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. return; } - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - function findPendingTask(target) { - return target[XHR_TASK]; + var supportsWebSocket = typeof WebSocket !== 'undefined'; + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow_1 = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow_1, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow_1, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow_1)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow_1['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow_1['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow_1['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow_1['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + } + } + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + } + } + /** + * @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.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); } - var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - if (!oriAddListener) { - var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; - oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - } + }); + Zone.__load_patch('timers', function (global) { + var set = 'set'; + var clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + }); + Zone.__load_patch('requestAnimationFrame', function (global) { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); + }); + Zone.__load_patch('blocking', function (global, Zone) { + var blockingMethods = ['alert', 'prompt', 'confirm']; + for (var i = 0; i < blockingMethods.length; i++) { + var name_2 = blockingMethods[i]; + patchMethod(global, name_2, function (delegate, symbol, name) { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); } - var READY_STATE_CHANGE = 'readystatechange'; - var SCHEDULED = 'scheduled'; - function scheduleTask(task) { - var data = task.data; - var target = data.target; - target[XHR_SCHEDULED] = false; - target[XHR_ERROR_BEFORE_SCHEDULED] = false; - // remove existing event listener - var listener = target[XHR_LISTENER]; - if (!oriAddListener) { - oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + }); + Zone.__load_patch('EventTarget', function (global, Zone, api) { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); + }); + Zone.__load_patch('on_property', function (global, Zone, api) { + propertyDescriptorPatch(api, global); + propertyPatch(); + }); + Zone.__load_patch('customElements', function (global, Zone, api) { + patchCustomElements(global, api); + }); + Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + var XHR_TASK = zoneSymbol('xhrTask'); + var XHR_SYNC = zoneSymbol('xhrSync'); + var XHR_LISTENER = zoneSymbol('xhrListener'); + var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; } - if (listener) { - oriRemoveListener.call(target, READY_STATE_CHANGE, listener); - } - var newListener = target[XHR_LISTENER] = function () { - if (target.readyState === target.DONE) { - // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with - // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { - // check whether the xhr has registered onload listener - // if that is the case, the task should invoke after all - // onload listeners finish. - var loadTasks = target['__zone_symbol__loadfalse']; - if (loadTasks && loadTasks.length > 0) { - var oriInvoke_1 = task.invoke; - task.invoke = function () { - // need to load the tasks again, because in other - // load listener, they may remove themselves - var loadTasks = target['__zone_symbol__loadfalse']; - for (var i = 0; i < loadTasks.length; i++) { - if (loadTasks[i] === task) { - loadTasks.splice(i, 1); + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; + } + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + var READY_STATE_CHANGE = 'readystatechange'; + var SCHEDULED = 'scheduled'; + function scheduleTask(task) { + var data = task.data; + var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + var listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + var newListener = target[XHR_LISTENER] = function () { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target[Zone.__symbol__('loadfalse')]; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target[Zone.__symbol__('loadfalse')]; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } } - } - if (!data.aborted && task.state === SCHEDULED) { - oriInvoke_1.call(task); - } - }; - loadTasks.push(task); + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } } - else { - task.invoke(); + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } - else if (!data.aborted && target[XHR_SCHEDULED] === false) { - // error occurs when xhr.send() - target[XHR_ERROR_BEFORE_SCHEDULED] = true; - } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + var storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; } - }; - oriAddListener.call(target, READY_STATE_CHANGE, newListener); - var storedTask = target[XHR_TASK]; - if (!storedTask) { - target[XHR_TASK] = task; - } - sendNative.apply(target, data.args); - target[XHR_SCHEDULED] = true; - return task; - } - function placeholderCallback() { } - function clearTask(task) { - var data = task.data; - // Note - ideally, we would call data.target.removeEventListener here, but it's too late - // to prevent it from firing. So instead, we store info for the event listener. - data.aborted = true; - return abortNative.apply(data.target, data.args); - } - var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { - self[XHR_SYNC] = args[2] == false; - self[XHR_URL] = args[1]; - return openNative.apply(self, args); - }; }); - var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); - var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); - var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { - if (Zone.current[fetchTaskScheduling] === true) { - // a fetch is scheduling, so we are using xhr to polyfill fetch - // and because we already schedule macroTask for fetch, we should - // not schedule a macroTask for xhr again - return sendNative.apply(self, args); - } - if (self[XHR_SYNC]) { - // if the XHR is sync there is no task to schedule, just execute the code. - return sendNative.apply(self, args); + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; } - else { - var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; - var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); - if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && - task.state === SCHEDULED) { - // xhr request throw error when send - // we should invoke task instead of leaving a scheduled - // pending macroTask - task.invoke(); + function placeholderCallback() { } + function clearTask(task) { + var data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }; }); + var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + if (self[XHR_SYNC]) { + // if the XHR is sync there is no task to schedule, just execute the code. + return sendNative.apply(self, args); } - } - }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { - var task = findPendingTask(self); - if (task && typeof task.type == 'string') { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && task.data.aborted)) { - return; + else { + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } + } + }; }); + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { + var task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); } - task.zone.cancelTask(task); + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }; }); + } + }); + Zone.__load_patch('geolocation', function (global) { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); + } + }); + Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(function (eventTask) { + // windows has added unhandledrejection event listener + // trigger the event listener + var PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; + } + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); + } + }); + /** + * @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.__load_patch('node_util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + setShouldCopySymbolProperties(true); + }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + Zone.__load_patch('EventEmitter', function (global) { + // For EventEmitter + var EE_ADD_LISTENER = 'addListener'; + var EE_PREPEND_LISTENER = 'prependListener'; + var EE_REMOVE_LISTENER = 'removeListener'; + var EE_REMOVE_ALL_LISTENER = 'removeAllListeners'; + var EE_LISTENERS = 'listeners'; + var EE_ON = 'on'; + var compareTaskCallbackVsDelegate = function (task, delegate) { + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; + }; + var eventNameToString = function (eventName) { + if (typeof eventName === 'string') { + return eventName; } - else if (Zone.current[fetchTaskAborting] === true) { - // the abort is called from fetch polyfill, we need to call native abort of XHR. - return abortNative.apply(self, args); + if (!eventName) { + return ''; } - // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no - // task - // to cancel. Do nothing. - }; }); - } -}); -Zone.__load_patch('geolocation', function (global) { - /// GEO_LOCATION - if (global['navigator'] && global['navigator'].geolocation) { - patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { - // handle unhandled promise rejection - function findPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(global, evtName); - eventTasks.forEach(function (eventTask) { - // windows has added unhandledrejection event listener - // trigger the event listener - var PromiseRejectionEvent = global['PromiseRejectionEvent']; - if (PromiseRejectionEvent) { - var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); - eventTask.invoke(evt); - } - }); + return eventName.toString().replace('(', '_').replace(')', '_'); }; - } - if (global['PromiseRejectionEvent']) { - Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = - findPromiseRejectionHandler('unhandledrejection'); - Zone[zoneSymbol('rejectionHandledHandler')] = - findPromiseRejectionHandler('rejectionhandled'); - } -}); - -/** - * @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.__load_patch('node_util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - setShouldCopySymbolProperties(true); -}); - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -Zone.__load_patch('EventEmitter', function (global) { - // For EventEmitter - var EE_ADD_LISTENER = 'addListener'; - var EE_PREPEND_LISTENER = 'prependListener'; - var EE_REMOVE_LISTENER = 'removeListener'; - var EE_REMOVE_ALL_LISTENER = 'removeAllListeners'; - var EE_LISTENERS = 'listeners'; - var EE_ON = 'on'; - var compareTaskCallbackVsDelegate = function (task, delegate) { - // same callback, same capture, same event name, just return - return task.callback === delegate || task.callback.listener === delegate; - }; - var eventNameToString = function (eventName) { - if (typeof eventName === 'string') { - return eventName; + function patchEventEmitterMethods(obj) { + var result = patchEventTarget(global, [obj], { + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString + }); + if (result && result[0]) { + obj[EE_ON] = obj[EE_ADD_LISTENER]; + } } - if (!eventName) { - return ''; + // EventEmitter + var events; + try { + events = require('events'); } - return eventName.toString().replace('(', '_').replace(')', '_'); - }; - function patchEventEmitterMethods(obj) { - var result = patchEventTarget(global, [obj], { - useG: false, - add: EE_ADD_LISTENER, - rm: EE_REMOVE_LISTENER, - prepend: EE_PREPEND_LISTENER, - rmAll: EE_REMOVE_ALL_LISTENER, - listeners: EE_LISTENERS, - chkDup: false, - rt: true, - diff: compareTaskCallbackVsDelegate, - eventNameToString: eventNameToString - }); - if (result && result[0]) { - obj[EE_ON] = obj[EE_ADD_LISTENER]; + catch (err) { } - } - // EventEmitter - var events; - try { - events = require('events'); - } - catch (err) { - } - if (events && events.EventEmitter) { - 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 - */ -Zone.__load_patch('fs', function () { - var fs; - try { - fs = require('fs'); - } - catch (err) { - } - // watch, watchFile, unwatchFile has been patched - // because EventEmitter has been patched - var TO_PATCH_MACROTASK_METHODS = [ - '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_MACROTASK_METHODS.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }) - .forEach(function (name) { - patchMacroTask(fs, name, function (self, args) { - return { - name: 'fs.' + name, - args: args, - cbIdx: args.length > 0 ? args.length - 1 : -1, - target: self - }; + if (events && events.EventEmitter) { + 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 + */ + Zone.__load_patch('fs', function () { + var fs; + try { + fs = require('fs'); + } + catch (err) { + } + // watch, watchFile, unwatchFile has been patched + // because EventEmitter has been patched + var TO_PATCH_MACROTASK_METHODS = [ + '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_MACROTASK_METHODS.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }) + .forEach(function (name) { + patchMacroTask(fs, name, function (self, args) { + return { + name: 'fs.' + name, + args: args, + cbIdx: args.length > 0 ? args.length - 1 : -1, + target: self + }; + }); }); + } + }); + /** + * @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'; + var clear = 'clear'; + Zone.__load_patch('node_timers', function (global, Zone) { + // Timers + var globalUseTimeoutFromTimer = false; + try { + var timers = require('timers'); + var globalEqualTimersTimeout = global.setTimeout === timers.setTimeout; + if (!globalEqualTimersTimeout && !isMix) { + // 1. if isMix, then we are in mix environment such as Electron + // we should only patch timers.setTimeout because global.setTimeout + // have been patched + // 2. if global.setTimeout not equal timers.setTimeout, check + // whether global.setTimeout use timers.setTimeout or not + var originSetTimeout_1 = timers.setTimeout; + timers.setTimeout = function () { + globalUseTimeoutFromTimer = true; + return originSetTimeout_1.apply(this, arguments); + }; + var detectTimeout = global.setTimeout(function () { }, 100); + clearTimeout(detectTimeout); + timers.setTimeout = originSetTimeout_1; + } + patchTimer(timers, set, clear, 'Timeout'); + patchTimer(timers, set, clear, 'Interval'); + patchTimer(timers, set, clear, 'Immediate'); + } + catch (error) { + // timers module not exists, for example, when we using nativeScript + // timers is not available + } + if (isMix) { + // if we are in mix environment, such as Electron, + // the global.setTimeout has already been patched, + // so we just patch timers.setTimeout + return; + } + if (!globalUseTimeoutFromTimer) { + // 1. global setTimeout equals timers setTimeout + // 2. or global don't use timers setTimeout(maybe some other library patch setTimeout) + // 3. or load timers module error happens, we should patch global setTimeout + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + } + else { + // global use timers setTimeout, but not equals + // this happens when use nodejs v0.10.x, global setTimeout will + // use a lazy load version of timers setTimeout + // we should not double patch timer's setTimeout + // so we only store the __symbol__ for consistency + global[Zone.__symbol__('setTimeout')] = global.setTimeout; + global[Zone.__symbol__('setInterval')] = global.setInterval; + global[Zone.__symbol__('setImmediate')] = global.setImmediate; + } + }); + // patch process related methods + Zone.__load_patch('nextTick', function () { + // patch nextTick as microTask + patchMicroTask(process, 'nextTick', function (self, args) { + return { + name: 'process.nextTick', + args: args, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + target: process + }; }); - } -}); - -/** - * @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'; -var clear = 'clear'; -Zone.__load_patch('node_timers', function (global, Zone) { - // Timers - var globalUseTimeoutFromTimer = false; - try { - var timers = require('timers'); - var globalEqualTimersTimeout = global.setTimeout === timers.setTimeout; - if (!globalEqualTimersTimeout && !isMix) { - // 1. if isMix, then we are in mix environment such as Electron - // we should only patch timers.setTimeout because global.setTimeout - // have been patched - // 2. if global.setTimeout not equal timers.setTimeout, check - // whether global.setTimeout use timers.setTimeout or not - var originSetTimeout_1 = timers.setTimeout; - timers.setTimeout = function () { - globalUseTimeoutFromTimer = true; - return originSetTimeout_1.apply(this, arguments); + }); + Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api) { + Zone[api.symbol('unhandledPromiseRejectionHandler')] = + findProcessPromiseRejectionHandler('unhandledRejection'); + Zone[api.symbol('rejectionHandledHandler')] = + findProcessPromiseRejectionHandler('rejectionHandled'); + // handle unhandled promise rejection + function findProcessPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(process, evtName); + eventTasks.forEach(function (eventTask) { + // process has added unhandledrejection event listener + // trigger the event listener + if (evtName === 'unhandledRejection') { + eventTask.invoke(e.rejection, e.promise); + } + else if (evtName === 'rejectionHandled') { + eventTask.invoke(e.promise); + } + }); }; - var detectTimeout = global.setTimeout(function () { }, 100); - clearTimeout(detectTimeout); - timers.setTimeout = originSetTimeout_1; } - patchTimer(timers, set, clear, 'Timeout'); - patchTimer(timers, set, clear, 'Interval'); - patchTimer(timers, set, clear, 'Immediate'); - } - catch (error) { - // timers module not exists, for example, when we using nativeScript - // timers is not available - } - if (isMix) { - // if we are in mix environment, such as Electron, - // the global.setTimeout has already been patched, - // so we just patch timers.setTimeout - return; - } - if (!globalUseTimeoutFromTimer) { - // 1. global setTimeout equals timers setTimeout - // 2. or global don't use timers setTimeout(maybe some other library patch setTimeout) - // 3. or load timers module error happens, we should patch global setTimeout - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); - } - else { - // global use timers setTimeout, but not equals - // this happens when use nodejs v0.10.x, global setTimeout will - // use a lazy load version of timers setTimeout - // we should not double patch timer's setTimeout - // so we only store the __symbol__ for consistency - global[Zone.__symbol__('setTimeout')] = global.setTimeout; - global[Zone.__symbol__('setInterval')] = global.setInterval; - global[Zone.__symbol__('setImmediate')] = global.setImmediate; - } -}); -// patch process related methods -Zone.__load_patch('nextTick', function () { - // patch nextTick as microTask - patchMicroTask(process, 'nextTick', function (self, args) { - return { - name: 'process.nextTick', - args: args, - cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, - target: process - }; }); -}); -Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api) { - Zone[api.symbol('unhandledPromiseRejectionHandler')] = - findProcessPromiseRejectionHandler('unhandledRejection'); - Zone[api.symbol('rejectionHandledHandler')] = - findProcessPromiseRejectionHandler('rejectionHandled'); - // handle unhandled promise rejection - function findProcessPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(process, evtName); - eventTasks.forEach(function (eventTask) { - // process has added unhandledrejection event listener - // trigger the event listener - if (evtName === 'unhandledRejection') { - eventTask.invoke(e.rejection, e.promise); - } - else if (evtName === 'rejectionHandled') { - eventTask.invoke(e.promise); - } + // Crypto + Zone.__load_patch('crypto', function () { + var crypto; + try { + crypto = require('crypto'); + } + catch (err) { + } + // use the generic patchMacroTask to patch crypto + if (crypto) { + var methodNames = ['randomBytes', 'pbkdf2']; + methodNames.forEach(function (name) { + patchMacroTask(crypto, name, function (self, args) { + return { + name: 'crypto.' + name, + args: args, + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + args.length - 1 : + -1, + target: crypto + }; + }); }); - }; - } -}); -// Crypto -Zone.__load_patch('crypto', function () { - var crypto; - try { - crypto = require('crypto'); - } - catch (err) { - } - // use the generic patchMacroTask to patch crypto - if (crypto) { - var methodNames = ['randomBytes', 'pbkdf2']; - methodNames.forEach(function (name) { - patchMacroTask(crypto, name, function (self, args) { - return { - name: 'crypto.' + name, - args: args, - cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? - args.length - 1 : - -1, - target: crypto + } + }); + Zone.__load_patch('console', function (global, Zone) { + var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; + consoleMethods.forEach(function (m) { + var originalMethod = console[Zone.__symbol__(m)] = console[m]; + if (originalMethod) { + console[m] = function () { + var args = ArraySlice.call(arguments); + if (Zone.current === Zone.root) { + return originalMethod.apply(this, args); + } + else { + return Zone.root.run(originalMethod, this, args); + } }; - }); + } }); - } -}); -Zone.__load_patch('console', function (global, Zone) { - var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; - consoleMethods.forEach(function (m) { - var originalMethod = console[Zone.__symbol__(m)] = console[m]; - if (originalMethod) { - console[m] = function () { - var args = ArraySlice.call(arguments); - if (Zone.current === Zone.root) { - return originalMethod.apply(this, args); - } - else { - return Zone.root.run(originalMethod, this, 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 - */ - -}))); + /** + * @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 + */ +})); +//# sourceMappingURL=zone-mix-rollup.umd.js.map diff --git a/dist/zone-mix.min.js b/dist/zone-mix.min.js new file mode 100755 index 000000000..debb93d4e --- /dev/null +++ b/dist/zone-mix.min.js @@ -0,0 +1,117 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";!function(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=e.__Zone_symbol_prefix||"__zone_symbol__";function i(e){return o+e}var a=!0===e[i("forceDuplicateZoneCheck")];if(e.Zone){if(a||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var s=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==z.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return I},enumerable:!0,configurable:!0}),t.__load_patch=function(o,i){if(z.hasOwnProperty(o)){if(a)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var s="Zone:"+o;n(s),z[o]=i(e,t,O),r(s,s)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{j=j.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||_).name+"; Execution: "+this.name+")");if(e.state!==k||e.type!==S&&e.type!==P){var r=e.state!=w;r&&e._transitionTo(w,T),e.runCount++;var o=I;I=e,j={parent:j,zone:this};try{e.type==P&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==k&&e.state!==Z&&(e.type==S||e.data&&e.data.isPeriodic?r&&e._transitionTo(T,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(k,w,k))),j=j.parent,I=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(b,k);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(Z,b,k),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==b&&e._transitionTo(T,b),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new f(D,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new f(P,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new f(S,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||_).name+"; Execution: "+this.name+")");e._transitionTo(E,T,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(Z,E),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(k,E),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})},e}(),f=function(){function t(n,r,o,i,a,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=i,this.scheduleFn=a,this.cancelFn=s,this.callback=o;var c=this;this.invoke=n===S&&i&&i.useG?t.invokeTask:function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),C++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==C&&y(),C--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(k,b)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==k&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),p=i("setTimeout"),h=i("Promise"),d=i("then"),v=[],g=!1;function m(t){if(0===C&&0===v.length)if(c||e[h]&&(c=e[h].resolve(0)),c){var n=c[d];n||(n=c.then),n.call(c,y)}else e[p](y,0);t&&v.push(t)}function y(){if(!g){for(g=!0;v.length;){var e=v;v=[];for(var t=0;t=0;n--)"function"==typeof e[n]&&(e[n]=u(e[n],t+"_"+n));return e}function y(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var _="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,k=!("nw"in d)&&void 0!==d.process&&"[object process]"==={}.toString.call(d.process),b=!k&&!_&&!(!p||!h.HTMLElement),T=void 0!==d.process&&"[object process]"==={}.toString.call(d.process)&&!_&&!(!p||!h.HTMLElement),w={},E=function(e){if(e=e||d.event){var t=w[e.type];t||(t=w[e.type]=f("ON_PROPERTY"+e.type));var n,r=this||e.target||d,o=r[t];return b&&r===h&&"error"===e.type?!0===(n=o&&o.call(this,e.message,e.filename,e.lineno,e.colno,e.error))&&e.preventDefault():null==(n=o&&o.apply(this,arguments))||n||e.preventDefault(),n}};function Z(n,r,o){var i=e(n,r);if(!i&&o&&e(o,r)&&(i={enumerable:!0,configurable:!0}),i&&i.configurable){var a=f("on"+r+"patched");if(!n.hasOwnProperty(a)||!n[a]){delete i.writable,delete i.value;var s=i.get,c=i.set,u=r.substr(2),l=w[u];l||(l=w[u]=f("ON_PROPERTY"+u)),i.set=function(e){var t=this;t||n!==d||(t=d),t&&(t[l]&&t.removeEventListener(u,E),c&&c.apply(t,g),"function"==typeof e?(t[l]=e,t.addEventListener(u,E,!1)):t[l]=null)},i.get=function(){var e=this;if(e||n!==d||(e=d),!e)return null;var t=e[l];if(t)return t;if(s){var o=s&&s.call(this);if(o)return i.set.call(this,o),"function"==typeof e[v]&&e.removeAttribute(r),o}return null},t(n,r,i),n[a]=!0}}}function D(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[i.cbIdx]?l(i.name,r[i.cbIdx],i,o):e.apply(t,r)}})}function I(e,t){e[f("OriginalDelegate")]=t} +/** + * @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.__load_patch("toString",function(e){var t=Function.prototype.toString,n=f("OriginalDelegate"),r=f("Promise"),o=f("Error"),i=function i(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var s=e[r];if(s)return t.call(s)}if(this===Error){var c=e[o];if(c)return t.call(c)}}return t.call(this)};i[n]=t,Function.prototype.toString=i;var a=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":a.call(this)}}); +/** + * @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 C=!1;if("undefined"!=typeof window)try{var x=Object.defineProperty({},"passive",{get:function(){C=!0}});window.addEventListener("test",x,x),window.removeEventListener("test",x,x)}catch(e){C=!1}var L={useG:!0},R={},M={},H=new RegExp("^"+c+"(\\w+)(true|false)$"),F=f("propagationStopped");function A(e,t){var n=[];for(var r in e){var o=H.exec(r),i=o&&o[1];if(i&&(!t||i===t)){var a=e[r];if(a)for(var s=0;s0){var o=e.invoke;e.invoke=function(){for(var r=a[t.__symbol__("loadfalse")],i=0;i0?n.length-1:-1,target:e}})})}); +/** + * @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 ue="set";Zone.__load_patch("node_timers",function(e,t){var n=!1;try{var r=require("timers");if(e.setTimeout!==r.setTimeout&&!T){var o=r.setTimeout;r.setTimeout=function(){return n=!0,o.apply(this,arguments)};var i=e.setTimeout(function(){},100);clearTimeout(i),r.setTimeout=o}q(r,ue,"clear","Timeout"),q(r,ue,"clear","Interval"),q(r,ue,"clear","Immediate")}catch(e){}T||(n?(e[t.__symbol__("setTimeout")]=e.setTimeout,e[t.__symbol__("setInterval")]=e.setInterval,e[t.__symbol__("setImmediate")]=e.setImmediate):(q(e,ue,"clear","Timeout"),q(e,ue,"clear","Interval"),q(e,ue,"clear","Immediate")))}),Zone.__load_patch("nextTick",function(){!function e(t,n,r){var o=null;function i(e){var t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=O(t,n,function(e){return function(t,n){var o=r(t,n);return o.cbIdx>=0&&"function"==typeof n[o.cbIdx]?Zone.current.scheduleMicroTask(o.name,n[o.cbIdx],o,i):e.apply(t,n)}})}(process,"nextTick",function(e,t){return{name:"process.nextTick",args:t,cbIdx:t.length>0&&"function"==typeof t[0]?0:-1,target:process}})}),Zone.__load_patch("handleUnhandledPromiseRejection",function(e,t,n){function r(e){return function(t){A(process,e).forEach(function(n){"unhandledRejection"===e?n.invoke(t.rejection,t.promise):"rejectionHandled"===e&&n.invoke(t.promise)})}}t[n.symbol("unhandledPromiseRejectionHandler")]=r("unhandledRejection"),t[n.symbol("rejectionHandledHandler")]=r("rejectionHandled")}),Zone.__load_patch("crypto",function(){var e;try{e=require("crypto")}catch(e){}e&&["randomBytes","pbkdf2"].forEach(function(t){j(e,t,function(n,r){return{name:"crypto."+t,args:r,cbIdx:r.length>0&&"function"==typeof r[r.length-1]?r.length-1:-1,target:e}})})}),Zone.__load_patch("console",function(e,t){["dir","log","info","error","warn","assert","debug","timeEnd","trace"].forEach(function(e){var n=console[t.__symbol__(e)]=console[e];n&&(console[e]=function(){var e=r.call(arguments);return t.current===t.root?n.apply(this,e):t.root.run(n,this,e)})})})}); \ No newline at end of file diff --git a/dist/zone-node.js b/dist/zone-node.js old mode 100644 new mode 100755 index 9f90c8cd6..3e7075f75 --- a/dist/zone-node.js +++ b/dist/zone-node.js @@ -5,1845 +5,1921 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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) { - var performance = global['performance']; - function mark(name) { - performance && performance['mark'] && performance['mark'](name); - } - function performanceMeasure(name, label) { - performance && performance['measure'] && performance['measure'](name, label); - } - mark('Zone'); - var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; - if (global['Zone']) { - // if global['Zone'] already exists (maybe zone.js was already loaded or - // some other lib also registered a global object named Zone), we may need - // to throw an error, but sometimes user may not want this error. - // For example, - // we have two web pages, page1 includes zone.js, page2 doesn't. - // and the 1st time user load page1 and page2, everything work fine, - // but when user load page2 again, error occurs because global['Zone'] already exists. - // so we add a flag to let user choose whether to throw this error or not. - // By default, if existing Zone is from zone.js, we will not throw the error. - if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { - throw new Error('Zone already loaded.'); - } - else { - return global['Zone']; - } - } - var Zone = /** @class */ (function () { - function Zone(parent, zoneSpec) { - this._parent = parent; - this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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) { + var performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + var symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + var checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } - Zone.assertZonePatched = function () { - if (global['Promise'] !== patches['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.)'); + var Zone = /** @class */ (function () { + function Zone(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); } - }; - Object.defineProperty(Zone, "root", { - get: function () { - var zone = Zone.current; - while (zone.parent) { - zone = zone.parent; + Zone.assertZonePatched = function () { + if (global['Promise'] !== patches['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.)'); } - return zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "current", { - get: function () { - return _currentZoneFrame.zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "currentTask", { - get: function () { - return _currentTask; - }, - enumerable: true, - configurable: true - }); - Zone.__load_patch = function (name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); + }; + Object.defineProperty(Zone, "root", { + get: function () { + var zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "current", { + get: function () { + return _currentZoneFrame.zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "currentTask", { + get: function () { + return _currentTask; + }, + enumerable: true, + configurable: true + }); + Zone.__load_patch = function (name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } - } - else if (!global['__Zone_disable_' + name]) { - var perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - }; - Object.defineProperty(Zone.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Zone.prototype.get = function (key) { - var zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - }; - Zone.prototype.getZoneWith = function (key) { - var current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; + else if (!global['__Zone_disable_' + name]) { + var perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); } - current = current._parent; - } - return null; - }; - Zone.prototype.fork = function (zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - }; - Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - var _callback = this._zoneDelegate.intercept(this, callback, source); - var zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); }; - }; - Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = null; } - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { + Object.defineProperty(Zone.prototype, "parent", { + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Zone.prototype.get = function (key) { + var zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + }; + Zone.prototype.getZoneWith = function (key) { + var current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + }; + Zone.prototype.fork = function (zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + }; + Zone.prototype.wrap = function (callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + var _callback = this._zoneDelegate.intercept(this, callback, source); + var zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + }; + Zone.prototype.run = function (callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { + if (applyThis === void 0) { applyThis = null; } + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runTask = function (task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - var reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - var previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; + finally { + _currentZoneFrame = _currentZoneFrame.parent; } + }; + Zone.prototype.runTask = function (task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; + } + var reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + var previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + }; + Zone.prototype.scheduleTask = function (task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + var newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + var zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + }; + Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + }; + Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.cancelTask = function (task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + }; + Zone.prototype._updateTaskCount = function (task, count) { + var zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (var i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + }; + return Zone; + }()); + Zone.__symbol__ = __symbol__; + var DELEGATE_ZS = { + name: '', + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, + onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } + }; + var ZoneDelegate = /** @class */ (function () { + function ZoneDelegate(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; } } } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); + ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + }; + ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + }; + ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.handleError = function (targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + }; + ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { + var returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); } else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); + throw new Error('Task is missing scheduleFn.'); } } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - }; - Zone.prototype.scheduleTask = function (task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - var newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); - } - newZone = newZone.parent; - } - } - task._transitionTo(scheduling, notScheduled); - var zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - }; - Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - }; - Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.cancelTask = function (task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - }; - Zone.prototype._updateTaskCount = function (task, count) { - var zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (var i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); - } - }; - Zone.__symbol__ = __symbol__; - return Zone; - }()); - var DELEGATE_ZS = { - name: '', - onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, - onScheduleTask: function (delegate, _, target, task) { - return delegate.scheduleTask(target, task); - }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { - return delegate.invokeTask(target, task, applyThis, applyArgs); - }, - onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } - }; - var ZoneDelegate = /** @class */ (function () { - function ZoneDelegate(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; + return returnTask; + }; + ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.cancelTask = function (targetZone, task) { + var value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); } - } - } - ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - }; - ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; - }; - ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.handleError = function (targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - }; - ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { - var returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; - } - else { - if (task.scheduleFn) { - task.scheduleFn(task); + return value; + }; + ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); } - else if (task.type == microTask) { - scheduleMicroTask(task); + catch (err) { + this.handleError(targetZone, err); + } + }; + ZoneDelegate.prototype._updateTaskCount = function (type, count) { + var counts = this._taskCounts; + var prev = counts[type]; + var next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + var isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + }; + return ZoneDelegate; + }()); + var ZoneTask = /** @class */ (function () { + function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + var self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; } else { - throw new Error('Task is missing scheduleFn.'); + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; } } - return returnTask; - }; - ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.cancelTask = function (targetZone, task) { - var value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); + ZoneTask.invokeTask = function (task, target, args) { + if (!task) { + task = this; } - value = task.cancelFn(task); - } - return value; - }; - ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback - try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); - } - catch (err) { - this.handleError(targetZone, err); - } - }; - ZoneDelegate.prototype._updateTaskCount = function (type, count) { - var counts = this._taskCounts; - var prev = counts[type]; - var next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - var isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type - }; - this.hasTask(this.zone, isEmpty); - } - }; - return ZoneDelegate; - }()); - var ZoneTask = /** @class */ (function () { - function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - var self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; - } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + }; + Object.defineProperty(ZoneTask.prototype, "zone", { + get: function () { + return this._zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ZoneTask.prototype, "state", { + get: function () { + return this._state; + }, + enumerable: true, + configurable: true + }); + ZoneTask.prototype.cancelScheduleRequest = function () { + this._transitionTo(notScheduled, scheduling); + }; + ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); + } + }; + ZoneTask.prototype.toString = function () { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + }; + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + ZoneTask.prototype.toJSON = function () { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount }; + }; + return ZoneTask; + }()); + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var symbolSetTimeout = __symbol__('setTimeout'); + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var _microTaskQueue = []; + var _isDrainingMicrotaskQueue = false; + var nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } } + task && _microTaskQueue.push(task); } - ZoneTask.invokeTask = function (task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + var queue = _microTaskQueue; + _microTaskQueue = []; + for (var i = 0; i < queue.length; i++) { + var task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var NO_ZONE = { name: 'NO ZONE' }; + var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + var patches = {}; + var _api = { + symbol: __symbol__, + currentZoneFrame: function () { return _currentZoneFrame; }, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, + patchEventTarget: function () { return []; }, + patchOnProperties: noop, + patchMethod: function () { return noop; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, + setNativePromise: function (NativePromise) { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); } - _numberOfNestedTaskFrames--; - } - }; - Object.defineProperty(ZoneTask.prototype, "zone", { - get: function () { - return this._zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ZoneTask.prototype, "state", { - get: function () { - return this._state; }, - enumerable: true, - configurable: true - }); - ZoneTask.prototype.cancelScheduleRequest = function () { - this._transitionTo(notScheduled, scheduling); + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } }; - ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; + var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + var _currentTask = null; + var _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); + /** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + var className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + var __symbol__ = api.symbol; + var _uncaughtPromiseErrors = []; + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var creationTrace = '__creationTrace__'; + api.onUnhandledError = function (e) { + if (api.showUncaughtError()) { + var rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); } } - else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); - } - }; - ZoneTask.prototype.toString = function () { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); - } - }; - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - ZoneTask.prototype.toJSON = function () { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount - }; }; - return ZoneTask; - }()); - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var symbolSetTimeout = __symbol__('setTimeout'); - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var _microTaskQueue = []; - var _isDrainingMicrotaskQueue = false; - var nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); - } - } - if (nativeMicroTaskQueuePromise) { - var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); - } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - var queue = _microTaskQueue; - _microTaskQueue = []; - for (var i = 0; i < queue.length; i++) { - var task = queue[i]; + api.microtaskDrainDone = function () { + while (_uncaughtPromiseErrors.length) { + var _loop_1 = function () { + var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); try { - task.zone.runTask(task, null, null); + uncaughtPromiseError.zone.runGuarded(function () { + throw uncaughtPromiseError; + }); } catch (error) { - _api.onUnhandledError(error); + handleUnhandledRejection(error); } + }; + while (_uncaughtPromiseErrors.length) { + _loop_1(); } } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var NO_ZONE = { name: 'NO ZONE' }; - var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - var patches = {}; - var _api = { - symbol: __symbol__, - currentZoneFrame: function () { return _currentZoneFrame; }, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, - patchEventTarget: function () { return []; }, - patchOnProperties: noop, - patchMethod: function () { return noop; }, - bindArguments: function () { return []; }, - patchThen: function () { return noop; }, - patchMacroTask: function () { return noop; }, - setNativePromise: function (NativePromise) { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: function () { return noop; }, - isIEOrEdge: function () { return false; }, - getGlobalObjects: function () { return undefined; }, - ObjectDefineProperty: function () { return noop; }, - ObjectGetOwnPropertyDescriptor: function () { return undefined; }, - ObjectCreate: function () { return undefined; }, - ArraySlice: function () { return []; }, - patchClass: function () { return noop; }, - wrapWithCurrentZone: function () { return noop; }, - filterProperties: function () { return []; }, - attachOriginToPatched: function () { return noop; }, - _redefineProperty: function () { return noop; }, - patchCallbacks: function () { return noop; } - }; - var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - var _currentTask = null; - var _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { - var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - var className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); - } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - var __symbol__ = api.symbol; - var _uncaughtPromiseErrors = []; - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var creationTrace = '__creationTrace__'; - api.onUnhandledError = function (e) { - if (api.showUncaughtError()) { - var rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + }; + var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); + try { + var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } } - else { - console.error(e); + catch (err) { } } - }; - api.microtaskDrainDone = function () { - while (_uncaughtPromiseErrors.length) { - var _loop_1 = function () { - var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + var symbolState = __symbol__('state'); + var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); + var source = 'Promise.then'; + var UNRESOLVED = null; + var RESOLVED = true; + var REJECTED = false; + var REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return function (v) { try { - uncaughtPromiseError.zone.runGuarded(function () { - throw uncaughtPromiseError; - }); + resolvePromise(promise, state, v); } - catch (error) { - handleUnhandledRejection(error); + catch (err) { + resolvePromise(promise, false, err); } + // Do not return value or you will break the Promise spec. }; - while (_uncaughtPromiseErrors.length) { - _loop_1(); - } } - }; - var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); - } - } - catch (err) { - } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - var symbolState = __symbol__('state'); - var symbolValue = __symbol__('value'); - var symbolFinally = __symbol__('finally'); - var symbolParentPromiseValue = __symbol__('parentPromiseValue'); - var symbolParentPromiseState = __symbol__('parentPromiseState'); - var source = 'Promise.then'; - var UNRESOLVED = null; - var RESOLVED = true; - var REJECTED = false; - var REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return function (v) { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); - } - // Do not return value or you will break the Promise spec. - }; - } - var once = function () { - var wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; - } - wasCalled = true; - wrappedFunction.apply(null, arguments); + var once = function () { + var wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; }; }; - }; - var TYPE_ERROR = 'Promise resolved with itself'; - var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - var onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); - } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - var then = null; - try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; - } - } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); - return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); - } - else if (state !== REJECTED && typeof then === 'function') { + var TYPE_ERROR = 'Promise resolved with itself'; + var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + var onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + var then = null; try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } } catch (err) { onceWrapper(function () { resolvePromise(promise, false, err); })(); + return promise; } - } - else { - promise[symbolState] = state; - var queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; - } - } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - var trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); - } - } - for (var i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); - } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { - var error_1 = err; - error_1.rejection = value; - error_1.promise = promise; - error_1.zone = Zone.current; - error_1.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error_1); - api.scheduleMicroTask(); // to make sure that it is running + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + var queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + var trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (var i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + var error = err; + error.rejection = value; + error.promise = promise; + error.zone = Zone.current; + error.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error); + api.scheduleMicroTask(); // to make sure that it is running + } } } } + // Resolving an already resolved promise is a noop. + return promise; } - // Resolving an already resolved promise is a noop. - return promise; - } - var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); + var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + var handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } } - } - catch (err) { - } - promise[symbolState] = REJECTED; - for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); + catch (err) { + } + promise[symbolState] = REJECTED; + for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } } } } - } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - var promiseState = promise[symbolState]; - var delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, function () { - try { - var parentPromiseValue = promise[symbolValue]; - var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); - } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); - } - }, chainPromise); - } - var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = /** @class */ (function () { - function ZoneAwarePromise(executor) { - var promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); - } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); - } - catch (error) { - resolvePromise(promise, false, error); - } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + var promiseState = promise[symbolState]; + var delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, function () { + try { + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); } - ZoneAwarePromise.toString = function () { - return ZONE_AWARE_PROMISE_TO_STRING; - }; - ZoneAwarePromise.resolve = function (value) { - return resolvePromise(new this(null), RESOLVED, value); - }; - ZoneAwarePromise.reject = function (error) { - return resolvePromise(new this(null), REJECTED, error); - }; - ZoneAwarePromise.race = function (values) { - var e_1, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); - } - function onReject(error) { - reject(error); + var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + var ZoneAwarePromise = /** @class */ (function () { + function ZoneAwarePromise(executor) { + var promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; + ZoneAwarePromise.toString = function () { + return ZONE_AWARE_PROMISE_TO_STRING; + }; + ZoneAwarePromise.resolve = function (value) { + return resolvePromise(new this(null), RESOLVED, value); + }; + ZoneAwarePromise.reject = function (error) { + return resolvePromise(new this(null), REJECTED, error); + }; + ZoneAwarePromise.race = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; if (!isThenable(value)) { value = this.resolve(value); } value.then(onResolve, onReject); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + return promise; + }; + ZoneAwarePromise.all = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; + var resolvedValues = []; + var _loop_2 = function (value) { + if (!isThenable(value)) { + value = this_1.resolve(value); + } + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + _loop_2(value); } - finally { if (e_1) throw e_1.error; } - } - return promise; - }; - ZoneAwarePromise.all = function (values) { - var e_2, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - var unresolvedCount = 2; - var valueIndex = 0; - var resolvedValues = []; - var _loop_2 = function (value) { - if (!isThenable(value)) { - value = this_1.resolve(value); - } - var curValueIndex = valueIndex; - value.then(function (value) { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; + ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { + var chainPromise = new this.constructor(null); + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; }; - var this_1 = this; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - _loop_2(value); + ZoneAwarePromise.prototype.catch = function (onRejected) { + return this.then(null, onRejected); + }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); } - finally { if (e_2) throw e_2.error; } - } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - return promise; - }; - Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { - get: function () { - return 'Promise'; - }, - enumerable: true, - configurable: true - }); - ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { - var chainPromise = new this.constructor(null); - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); - } - return chainPromise; - }; - ZoneAwarePromise.prototype.catch = function (onRejected) { - return this.then(null, onRejected); - }; - ZoneAwarePromise.prototype.finally = function (onFinally) { - var chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); - } - return chainPromise; - }; - return ZoneAwarePromise; - }()); - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - var NativePromise = global[symbolPromise] = global['Promise']; - var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; - } - desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; - } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); + return chainPromise; + }; + return ZoneAwarePromise; + }()); + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + var NativePromise = global[symbolPromise] = global['Promise']; + var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + var symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; } - }; - ObjectDefineProperty(global, 'Promise', desc); - } - global['Promise'] = ZoneAwarePromise; - var symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - var proto = Ctor.prototype; - var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case - return; + var originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + var _this = this; + var wrapped = new ZoneAwarePromise(function (resolve, reject) { + originalThen.call(_this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; } - var originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - var _this = this; - var wrapped = new ZoneAwarePromise(function (resolve, reject) { - originalThen.call(_this, resolve, reject); - }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; - } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; - } - if (NativePromise) { - patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global[api.symbol('fetch')] = fetch_1; - global['fetch'] = zoneify(fetch_1); + }; } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); - -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -var ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -var ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ - -/** Array.prototype.slice */ -var ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -var ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -var TRUE_STR = 'true'; -/** false string const */ -var FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -var zoneSymbol = Zone.__symbol__; -var isWindowExists = typeof window !== 'undefined'; -var internalWindow = isWindowExists ? window : undefined; -var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -var REMOVE_ATTRIBUTE = 'removeAttribute'; -var NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + if (NativePromise) { + patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); + } } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); + /** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + var ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + var ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Array.prototype.slice */ + var ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + var ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + var TRUE_STR = 'true'; + /** false string const */ + var FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + var ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); } - return args; -} - -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -var zoneSymbolEventNames = {}; -var wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - var eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); } - var target = this || event.target || _global; - var listener = target[eventNameSymbol]; - var result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - var errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); - } + var zoneSymbol = Zone.__symbol__; + var isWindowExists = typeof window !== 'undefined'; + var internalWindow = isWindowExists ? window : undefined; + var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + var REMOVE_ATTRIBUTE = 'removeAttribute'; + var NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; } - } - return result; -}; -function patchProperty(obj, prop, prototype) { - var desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; + if (propertyDesc.writable === false) { + return false; } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - var originalDescGet = desc.get; - var originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { + var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + var zoneSymbolEventNames = {}; + var wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - var previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); - } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); + var eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); + var target = this || event.target || _global; + var listener = target[eventNameSymbol]; + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } } else { - target[eventNameSymbol] = null; + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } + return result; }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return null; + function patchProperty(obj, prop, prototype) { + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; } - var listener = target[eventNameSymbol]; - if (listener) { - return listener; + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); - } - return value; + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + var originalDescGet = desc.get; + var originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (var i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } - } - else { - var onProperties = []; - for (var prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); + var previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); } - } - for (var j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); - } - } -} -var originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` - -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; - } - var symbols = Object.getOwnPropertySymbols(src); - symbols.forEach(function (symbol) { - var desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; - } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -var shouldCopySymbolProperties = false; -function setShouldCopySymbolProperties(flag) { - shouldCopySymbolProperties = flag; -} -function patchMethod(target, name, patchFn) { - var proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; - } - var delegateName = zoneSymbol(name); - var delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - var patchDelegate_1 = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate_1(this, arguments); - }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); + } + else { + target[eventNameSymbol] = null; } - } - } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); }; - setNative.apply(data.target, data.args); - return task; - } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); - } - else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} -function patchMicroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + var listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + var value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; + } + } + return null; }; - setNative.apply(data.target, data.args); - return task; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (var i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } } else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} - -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', function (global) { - // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Function.prototype.toString; - var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - var PROMISE_SYMBOL = zoneSymbol('Promise'); - var ERROR_SYMBOL = zoneSymbol('Error'); - var newFunctionToString = function toString() { - if (typeof this === 'function') { - var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); - } - else { - return Object.prototype.toString.call(originalDelegate); - } - } - if (this === Promise) { - var nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); + var onProperties = []; + for (var prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); } } - if (this === Error) { - var nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); - } + for (var j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); } } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - var originalObjectToString = Object.prototype.toString; - var PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; + } + var originalInstanceKey = zoneSymbol('originalInstance'); + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { + return; } - return originalObjectToString.call(this); - }; -}); - -/** - * @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.__load_patch('node_util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - setShouldCopySymbolProperties(true); -}); - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var passiveSupported = false; -if (typeof window !== 'undefined') { - try { - var options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); } - catch (err) { - passiveSupported = false; + var shouldCopySymbolProperties = false; + function setShouldCopySymbolProperties(flag) { + shouldCopySymbolProperties = flag; } -} -// an identifier to tell ZoneTask do not create a new invoke closure -var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -var zoneSymbolEventNames$1 = {}; -var globalSources = {}; -var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - var PREPEND_EVENT_LISTENER = 'prependListener'; - var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { - return; - } - var delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = function (event) { return delegate.handleEvent(event); }; - task.originalDelegate = delegate; + function patchMethod(target, name, patchFn) { + var proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); } - // invoke static task.invoke - task.invoke(task, target, [event]); - var options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + var delegateName = zoneSymbol(name); + var delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + var patchDelegate_1 = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate_1(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } + } } - }; - // global shared zoneAwareCallback to handle all event callback with capture = false - var globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; + return delegate; + } + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } + // cause an error by calling it directly. + return delegate.apply(self, args); } + }; }); + } + function patchMicroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - var globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }; }); + } + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; + } + /** + * @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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', function (global) { + // patch Func.prototype.toString to let them look like native + var originalFunctionToString = Function.prototype.toString; + var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + var PROMISE_SYMBOL = zoneSymbol('Promise'); + var ERROR_SYMBOL = zoneSymbol('Error'); + var newFunctionToString = function toString() { + if (typeof this === 'function') { + var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } + } + if (this === Promise) { + var nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } + } + if (this === Error) { + var nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); } - invokeTask(copyTasks[i], target, event); } } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + var originalObjectToString = Object.prototype.toString; + var PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; + }); + /** + * @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.__load_patch('node_util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + setShouldCopySymbolProperties(true); + }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var passiveSupported = false; + if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - var useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - var validateHandler = patchOptions && patchOptions.vh; - var checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; - } - var returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; - } - var proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; - } - if (!proto) { - return false; - } - if (proto[zoneSymbolAddEventListener]) { - return false; - } - var eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - var taskData = {}; - var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - var nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } + catch (err) { + passiveSupported = false; } - var customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { + } + // an identifier to tell ZoneTask do not create a new invoke closure + var OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true + }; + var zoneSymbolEventNames$1 = {}; + var globalSources = {}; + var EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + var PREPEND_EVENT_LISTENER = 'prependListener'; + var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + var invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { return; } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + var delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = function (event) { return delegate.handleEvent(event); }; + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + var options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + } }; - var customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - var symbolEventName = void 0; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + // global shared zoneAwareCallback to handle all event callback with capture = false + var globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); } - var existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + var globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { break; } + invokeTask(copyTasks[i], target, event); } } } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { - return; - } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - var customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); }; - var customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - var compareTaskCallbackVsDelegate = function (task, delegate) { - var typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); - }; - var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { - if (returnTarget === void 0) { returnTarget = false; } - if (prepend === void 0) { prepend = false; } - return function () { - var target = this || _global; - var eventName = arguments[0]; - var delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - var isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + var useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + var validateHandler = patchOptions && patchOptions.vh; + var checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + var returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + var proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + var eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + var taskData = {}; + var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + var nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + var customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + var symbolEventName = void 0; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } } - isHandleEvent = true; } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { return; } - var options = arguments[2]; - if (blackListedEvents) { - // check black list - for (var i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + var customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + var compareTaskCallbackVsDelegate = function (task, delegate) { + var typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + var blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { + if (returnTarget === void 0) { returnTarget = false; } + if (prepend === void 0) { prepend = false; } + return function () { + var target = this || _global; + var eventName = arguments[0]; + var delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + var isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } + isHandleEvent = true; } - } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + var options = arguments[2]; + if (blackListedEvents) { + // check black list + for (var i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + var capture; + var once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + var zone = Zone.current; + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = target[symbolEventName]; + var isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (var i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + var source; + var constructorName = target.constructor['name']; + var targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var options = arguments[2]; var capture; - var once = false; if (options === undefined) { capture = false; } @@ -1855,631 +1931,502 @@ function patchEventTarget(_global, apis, patchOptions) { } else { capture = options ? !!options.capture : false; - once = options ? !!options.once : false; } - var zone = Zone.current; + var delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } var symbolEventNames = zoneSymbolEventNames$1[eventName]; var symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { + if (symbolEventNames) { symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } - var existingTasks = target[symbolEventName]; - var isExisting = false; + var existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (var i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; } } } - else { - existingTasks = target[symbolEventName] = []; - } - var source; - var constructorName = target.constructor['name']; - var targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); - } - else { - existingTasks.unshift(task); - } - if (returnTarget) { - return target; + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var listeners = []; + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (var i = 0; i < tasks.length; i++) { + var task = tasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); } + return listeners; }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var options = arguments[2]; - var capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - } - var delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); - } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; - } - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; - } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + if (!eventName) { + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } - return; } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } - } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var listeners = []; - var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - if (!eventName) { - var keys = Object.keys(target); - for (var i = 0; i < keys.length; i++) { - var prop = keys[i]; - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); - } - } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - var symbolEventName = symbolEventNames[FALSE_STR]; - var symbolCaptureEventName = symbolEventNames[TRUE_STR]; - var tasks = target[symbolEventName]; - var captureTasks = target[symbolCaptureEventName]; - if (tasks) { - var removeTasks = tasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + else { + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + var symbolEventName = symbolEventNames[FALSE_STR]; + var symbolCaptureEventName = symbolEventNames[TRUE_STR]; + var tasks = target[symbolEventName]; + var captureTasks = target[symbolCaptureEventName]; + if (tasks) { + var removeTasks = tasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } - } - if (captureTasks) { - var removeTasks = captureTasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + if (captureTasks) { + var removeTasks = captureTasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } } } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); } - if (returnTarget) { - return this; + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); } - }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + return true; } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + var results = []; + for (var i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); } - return true; + return results; } - var results = []; - for (var i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); - } - return results; -} -function findEventTasks(target, eventName) { - var foundTasks = []; - for (var prop in target) { - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - var tasks = target[prop]; - if (tasks) { - for (var i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); + function findEventTasks(target, eventName) { + var foundTasks = []; + for (var prop in target) { + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + var tasks = target[prop]; + if (tasks) { + for (var i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } } } } + return foundTasks; } - return foundTasks; -} - -/** - * @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.__load_patch('EventEmitter', function (global) { - // For EventEmitter - var EE_ADD_LISTENER = 'addListener'; - var EE_PREPEND_LISTENER = 'prependListener'; - var EE_REMOVE_LISTENER = 'removeListener'; - var EE_REMOVE_ALL_LISTENER = 'removeAllListeners'; - var EE_LISTENERS = 'listeners'; - var EE_ON = 'on'; - var compareTaskCallbackVsDelegate = function (task, delegate) { - // same callback, same capture, same event name, just return - return task.callback === delegate || task.callback.listener === delegate; - }; - var eventNameToString = function (eventName) { - if (typeof eventName === 'string') { - return eventName; + /** + * @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.__load_patch('EventEmitter', function (global) { + // For EventEmitter + var EE_ADD_LISTENER = 'addListener'; + var EE_PREPEND_LISTENER = 'prependListener'; + var EE_REMOVE_LISTENER = 'removeListener'; + var EE_REMOVE_ALL_LISTENER = 'removeAllListeners'; + var EE_LISTENERS = 'listeners'; + var EE_ON = 'on'; + var compareTaskCallbackVsDelegate = function (task, delegate) { + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; + }; + var eventNameToString = function (eventName) { + if (typeof eventName === 'string') { + return eventName; + } + if (!eventName) { + return ''; + } + return eventName.toString().replace('(', '_').replace(')', '_'); + }; + function patchEventEmitterMethods(obj) { + var result = patchEventTarget(global, [obj], { + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString + }); + if (result && result[0]) { + obj[EE_ON] = obj[EE_ADD_LISTENER]; + } } - if (!eventName) { - return ''; + // EventEmitter + var events; + try { + events = require('events'); } - return eventName.toString().replace('(', '_').replace(')', '_'); - }; - function patchEventEmitterMethods(obj) { - var result = patchEventTarget(global, [obj], { - useG: false, - add: EE_ADD_LISTENER, - rm: EE_REMOVE_LISTENER, - prepend: EE_PREPEND_LISTENER, - rmAll: EE_REMOVE_ALL_LISTENER, - listeners: EE_LISTENERS, - chkDup: false, - rt: true, - diff: compareTaskCallbackVsDelegate, - eventNameToString: eventNameToString - }); - if (result && result[0]) { - obj[EE_ON] = obj[EE_ADD_LISTENER]; + catch (err) { } - } - // EventEmitter - var events; - try { - events = require('events'); - } - catch (err) { - } - if (events && events.EventEmitter) { - 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 - */ -Zone.__load_patch('fs', function () { - var fs; - try { - fs = require('fs'); - } - catch (err) { - } - // watch, watchFile, unwatchFile has been patched - // because EventEmitter has been patched - var TO_PATCH_MACROTASK_METHODS = [ - '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_MACROTASK_METHODS.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }) - .forEach(function (name) { - patchMacroTask(fs, name, function (self, args) { - return { - name: 'fs.' + name, - args: args, - cbIdx: args.length > 0 ? args.length - 1 : -1, - target: self - }; + if (events && events.EventEmitter) { + 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 + */ + Zone.__load_patch('fs', function () { + var fs; + try { + fs = require('fs'); + } + catch (err) { + } + // watch, watchFile, unwatchFile has been patched + // because EventEmitter has been patched + var TO_PATCH_MACROTASK_METHODS = [ + '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_MACROTASK_METHODS.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }) + .forEach(function (name) { + patchMacroTask(fs, name, function (self, args) { + return { + name: 'fs.' + name, + args: args, + cbIdx: args.length > 0 ? args.length - 1 : -1, + target: self + }; + }); }); - }); - } -}); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + } + }); + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + 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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } + data.args[0] = timer; + data.handleId = setNative.apply(window, data.args); + return task; } - data.args[0] = timer; - 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 options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); - if (!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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } return task; } - // Node.js must additionally support the ref and unref functions. - var handle = task.data.handleId; - if (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = 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 id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; + } } - if (typeof handle === 'number' || handle) { - return handle; + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // Do not cancel already canceled functions + task.zone.cancelTask(task); + } } - 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; + else { + // cause an error by calling it directly. + delegate.apply(window, args); } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + }; }); + } + /** + * @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'; + var clear = 'clear'; + Zone.__load_patch('node_timers', function (global, Zone) { + // Timers + var globalUseTimeoutFromTimer = false; + try { + var timers = require('timers'); + var globalEqualTimersTimeout = global.setTimeout === timers.setTimeout; + if (!globalEqualTimersTimeout && !isMix) { + // 1. if isMix, then we are in mix environment such as Electron + // we should only patch timers.setTimeout because global.setTimeout + // have been patched + // 2. if global.setTimeout not equal timers.setTimeout, check + // whether global.setTimeout use timers.setTimeout or not + var originSetTimeout_1 = timers.setTimeout; + timers.setTimeout = function () { + globalUseTimeoutFromTimer = true; + return originSetTimeout_1.apply(this, arguments); + }; + var detectTimeout = global.setTimeout(function () { }, 100); + clearTimeout(detectTimeout); + timers.setTimeout = originSetTimeout_1; + } + patchTimer(timers, set, clear, 'Timeout'); + patchTimer(timers, set, clear, 'Interval'); + patchTimer(timers, set, clear, 'Immediate'); + } + catch (error) { + // timers module not exists, for example, when we using nativeScript + // timers is not available + } + if (isMix) { + // if we are in mix environment, such as Electron, + // the global.setTimeout has already been patched, + // so we just patch timers.setTimeout + return; + } + if (!globalUseTimeoutFromTimer) { + // 1. global setTimeout equals timers setTimeout + // 2. or global don't use timers setTimeout(maybe some other library patch setTimeout) + // 3. or load timers module error happens, we should patch global setTimeout + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + } + else { + // global use timers setTimeout, but not equals + // this happens when use nodejs v0.10.x, global setTimeout will + // use a lazy load version of timers setTimeout + // we should not double patch timer's setTimeout + // so we only store the __symbol__ for consistency + global[Zone.__symbol__('setTimeout')] = global.setTimeout; + global[Zone.__symbol__('setInterval')] = global.setInterval; + global[Zone.__symbol__('setImmediate')] = global.setImmediate; + } + }); + // patch process related methods + Zone.__load_patch('nextTick', function () { + // patch nextTick as microTask + patchMicroTask(process, 'nextTick', function (self, args) { + return { + name: 'process.nextTick', + args: args, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + target: process + }; + }); + }); + Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api) { + Zone[api.symbol('unhandledPromiseRejectionHandler')] = + findProcessPromiseRejectionHandler('unhandledRejection'); + Zone[api.symbol('rejectionHandledHandler')] = + findProcessPromiseRejectionHandler('rejectionHandled'); + // handle unhandled promise rejection + function findProcessPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(process, evtName); + eventTasks.forEach(function (eventTask) { + // process has added unhandledrejection event listener + // trigger the event listener + if (evtName === 'unhandledRejection') { + eventTask.invoke(e.rejection, e.promise); } - else if (id) { - id[taskSymbol] = null; + else if (evtName === 'rejectionHandled') { + eventTask.invoke(e.promise); } - // 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'; -var clear = 'clear'; -Zone.__load_patch('node_timers', function (global, Zone) { - // Timers - var globalUseTimeoutFromTimer = false; - try { - var timers = require('timers'); - var globalEqualTimersTimeout = global.setTimeout === timers.setTimeout; - if (!globalEqualTimersTimeout && !isMix) { - // 1. if isMix, then we are in mix environment such as Electron - // we should only patch timers.setTimeout because global.setTimeout - // have been patched - // 2. if global.setTimeout not equal timers.setTimeout, check - // whether global.setTimeout use timers.setTimeout or not - var originSetTimeout_1 = timers.setTimeout; - timers.setTimeout = function () { - globalUseTimeoutFromTimer = true; - return originSetTimeout_1.apply(this, arguments); + }); }; - var detectTimeout = global.setTimeout(function () { }, 100); - clearTimeout(detectTimeout); - timers.setTimeout = originSetTimeout_1; } - patchTimer(timers, set, clear, 'Timeout'); - patchTimer(timers, set, clear, 'Interval'); - patchTimer(timers, set, clear, 'Immediate'); - } - catch (error) { - // timers module not exists, for example, when we using nativeScript - // timers is not available - } - if (isMix) { - // if we are in mix environment, such as Electron, - // the global.setTimeout has already been patched, - // so we just patch timers.setTimeout - return; - } - if (!globalUseTimeoutFromTimer) { - // 1. global setTimeout equals timers setTimeout - // 2. or global don't use timers setTimeout(maybe some other library patch setTimeout) - // 3. or load timers module error happens, we should patch global setTimeout - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); - } - else { - // global use timers setTimeout, but not equals - // this happens when use nodejs v0.10.x, global setTimeout will - // use a lazy load version of timers setTimeout - // we should not double patch timer's setTimeout - // so we only store the __symbol__ for consistency - global[Zone.__symbol__('setTimeout')] = global.setTimeout; - global[Zone.__symbol__('setInterval')] = global.setInterval; - global[Zone.__symbol__('setImmediate')] = global.setImmediate; - } -}); -// patch process related methods -Zone.__load_patch('nextTick', function () { - // patch nextTick as microTask - patchMicroTask(process, 'nextTick', function (self, args) { - return { - name: 'process.nextTick', - args: args, - cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, - target: process - }; }); -}); -Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api) { - Zone[api.symbol('unhandledPromiseRejectionHandler')] = - findProcessPromiseRejectionHandler('unhandledRejection'); - Zone[api.symbol('rejectionHandledHandler')] = - findProcessPromiseRejectionHandler('rejectionHandled'); - // handle unhandled promise rejection - function findProcessPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(process, evtName); - eventTasks.forEach(function (eventTask) { - // process has added unhandledrejection event listener - // trigger the event listener - if (evtName === 'unhandledRejection') { - eventTask.invoke(e.rejection, e.promise); - } - else if (evtName === 'rejectionHandled') { - eventTask.invoke(e.promise); - } + // Crypto + Zone.__load_patch('crypto', function () { + var crypto; + try { + crypto = require('crypto'); + } + catch (err) { + } + // use the generic patchMacroTask to patch crypto + if (crypto) { + var methodNames = ['randomBytes', 'pbkdf2']; + methodNames.forEach(function (name) { + patchMacroTask(crypto, name, function (self, args) { + return { + name: 'crypto.' + name, + args: args, + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + args.length - 1 : + -1, + target: crypto + }; + }); }); - }; - } -}); -// Crypto -Zone.__load_patch('crypto', function () { - var crypto; - try { - crypto = require('crypto'); - } - catch (err) { - } - // use the generic patchMacroTask to patch crypto - if (crypto) { - var methodNames = ['randomBytes', 'pbkdf2']; - methodNames.forEach(function (name) { - patchMacroTask(crypto, name, function (self, args) { - return { - name: 'crypto.' + name, - args: args, - cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? - args.length - 1 : - -1, - target: crypto + } + }); + Zone.__load_patch('console', function (global, Zone) { + var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; + consoleMethods.forEach(function (m) { + var originalMethod = console[Zone.__symbol__(m)] = console[m]; + if (originalMethod) { + console[m] = function () { + var args = ArraySlice.call(arguments); + if (Zone.current === Zone.root) { + return originalMethod.apply(this, args); + } + else { + return Zone.root.run(originalMethod, this, args); + } }; - }); + } }); - } -}); -Zone.__load_patch('console', function (global, Zone) { - var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; - consoleMethods.forEach(function (m) { - var originalMethod = console[Zone.__symbol__(m)] = console[m]; - if (originalMethod) { - console[m] = function () { - var args = ArraySlice.call(arguments); - if (Zone.current === Zone.root) { - return originalMethod.apply(this, args); - } - else { - return Zone.root.run(originalMethod, this, 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 - */ - -}))); + /** + * @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 + */ +})); +//# sourceMappingURL=zone-node-rollup.umd.js.map diff --git a/dist/zone-node.min.js b/dist/zone-node.min.js new file mode 100755 index 000000000..6d40af88d --- /dev/null +++ b/dist/zone-node.min.js @@ -0,0 +1,77 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";!function(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=e.__Zone_symbol_prefix||"__zone_symbol__";function i(e){return o+e}var a=!0===e[i("forceDuplicateZoneCheck")];if(e.Zone){if(a||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var s=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==z.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),t.__load_patch=function(o,i){if(z.hasOwnProperty(o)){if(a)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var s="Zone:"+o;n(s),z[o]=i(e,t,O),r(s,s)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{j=j.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");if(e.state!==m||e.type!==P&&e.type!==S){var r=e.state!=w;r&&e._transitionTo(w,b),e.runCount++;var o=C;C=e,j={parent:j,zone:this};try{e.type==S&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==m&&e.state!==E&&(e.type==P||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,w):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(m,w,m))),j=j.parent,C=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(T,m);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,T,m),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==T&&e._transitionTo(b,T),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new f(D,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new f(S,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new f(P,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||g).name+"; Execution: "+this.name+")");e._transitionTo(Z,b,w);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,Z),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(m,Z),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})},e}(),f=function(){function t(n,r,o,i,a,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=i,this.scheduleFn=a,this.cancelFn=s,this.callback=o;var c=this;this.invoke=n===P&&i&&i.useG?t.invokeTask:function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&y(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(m,T)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==m&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),h=i("setTimeout"),p=i("Promise"),d=i("then"),v=[],_=!1;function k(t){if(0===I&&0===v.length)if(c||e[p]&&(c=e[p].resolve(0)),c){var n=c[d];n||(n=c.then),n.call(c,y)}else e[h](y,0);t&&v.push(t)}function y(){if(!_){for(_=!0;v.length;){var e=v;v=[];for(var t=0;t=0;n--)"function"==typeof e[n]&&(e[n]=s(e[n],t+"_"+n));return e}var _="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,k=!("nw"in h)&&void 0!==h.process&&"[object process]"==={}.toString.call(h.process),y=!k&&!_&&!(!l||!f.HTMLElement),g=void 0!==h.process&&"[object process]"==={}.toString.call(h.process)&&!_&&!(!l||!f.HTMLElement),m={},T=function(e){if(e=e||h.event){var t=m[e.type];t||(t=m[e.type]=u("ON_PROPERTY"+e.type));var n,r=this||e.target||h,o=r[t];return y&&r===f&&"error"===e.type?!0===(n=o&&o.call(this,e.message,e.filename,e.lineno,e.colno,e.error))&&e.preventDefault():null==(n=o&&o.apply(this,arguments))||n||e.preventDefault(),n}};function b(n,r,o){var i=e(n,r);if(!i&&o&&e(o,r)&&(i={enumerable:!0,configurable:!0}),i&&i.configurable){var a=u("on"+r+"patched");if(!n.hasOwnProperty(a)||!n[a]){delete i.writable,delete i.value;var s=i.get,c=i.set,l=r.substr(2),f=m[l];f||(f=m[l]=u("ON_PROPERTY"+l)),i.set=function(e){var t=this;t||n!==h||(t=h),t&&(t[f]&&t.removeEventListener(l,T),c&&c.apply(t,d),"function"==typeof e?(t[f]=e,t.addEventListener(l,T,!1)):t[f]=null)},i.get=function(){var e=this;if(e||n!==h||(e=h),!e)return null;var t=e[f];if(t)return t;if(s){var o=s&&s.call(this);if(o)return i.set.call(this,o),"function"==typeof e[p]&&e.removeAttribute(r),o}return null},t(n,r,i),n[a]=!0}}}function w(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[i.cbIdx]?c(i.name,r[i.cbIdx],i,o):e.apply(t,r)}})}function S(e,t){e[u("OriginalDelegate")]=t} +/** + * @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.__load_patch("toString",function(e){var t=Function.prototype.toString,n=u("OriginalDelegate"),r=u("Promise"),o=u("Error"),i=function i(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var s=e[r];if(s)return t.call(s)}if(this===Error){var c=e[o];if(c)return t.call(c)}}return t.call(this)};i[n]=t,Function.prototype.toString=i;var a=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":a.call(this)}}), +/** + * @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.__load_patch("node_util",function(e,t,n){n.patchOnProperties=w,n.patchMethod=E,n.bindArguments=v,n.patchMacroTask=D,function r(e){Z=e}(!0)}); +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +var P=!1;if("undefined"!=typeof window)try{var z=Object.defineProperty({},"passive",{get:function(){P=!0}});window.addEventListener("test",z,z),window.removeEventListener("test",z,z)}catch(e){P=!1}var O={useG:!0},j={},C={},I=new RegExp("^"+a+"(\\w+)(true|false)$"),x=u("propagationStopped");function L(e,t){var n=[];for(var r in e){var o=I.exec(r),i=o&&o[1];if(i&&(!t||i===t)){var a=e[r];if(a)for(var s=0;s0?n.length-1:-1,target:e}})})}); +/** + * @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 A=u("zoneTask");function F(e,t,n,r){var o=null,i=null;n+=r;var a={};function s(t){var n=t.data;return n.args[0]=function r(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete a[n.handleId]:n.handleId&&(n.handleId[A]=null))}},n.handleId=o.apply(e,n.args),t}function u(e){return i(e.data.handleId)}o=E(e,t+=r,function(n){return function(o,i){if("function"==typeof i[0]){var l=c(t,i[0],{isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?i[1]||0:void 0,args:i},s,u);if(!l)return l;var f=l.data.handleId;return"number"==typeof f?a[f]=l:f&&(f[A]=l),f&&f.ref&&f.unref&&"function"==typeof f.ref&&"function"==typeof f.unref&&(l.ref=f.ref.bind(f),l.unref=f.unref.bind(f)),"number"==typeof f||f?f:l}return n.apply(e,i)}}),i=E(e,n,function(t){return function(n,r){var o,i=r[0];"number"==typeof i?o=a[i]:(o=i&&i[A])||(o=i),o&&"string"==typeof o.type?"notScheduled"!==o.state&&(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&("number"==typeof i?delete a[i]:i&&(i[A]=null),o.zone.cancelTask(o)):t.apply(e,r)}})} +/** + * @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 N="set";Zone.__load_patch("node_timers",function(e,t){var n=!1;try{var r=require("timers");if(e.setTimeout!==r.setTimeout&&!g){var o=r.setTimeout;r.setTimeout=function(){return n=!0,o.apply(this,arguments)};var i=e.setTimeout(function(){},100);clearTimeout(i),r.setTimeout=o}F(r,N,"clear","Timeout"),F(r,N,"clear","Interval"),F(r,N,"clear","Immediate")}catch(e){}g||(n?(e[t.__symbol__("setTimeout")]=e.setTimeout,e[t.__symbol__("setInterval")]=e.setInterval,e[t.__symbol__("setImmediate")]=e.setImmediate):(F(e,N,"clear","Timeout"),F(e,N,"clear","Interval"),F(e,N,"clear","Immediate")))}),Zone.__load_patch("nextTick",function(){!function e(t,n,r){var o=null;function i(e){var t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=E(t,n,function(e){return function(t,n){var o=r(t,n);return o.cbIdx>=0&&"function"==typeof n[o.cbIdx]?Zone.current.scheduleMicroTask(o.name,n[o.cbIdx],o,i):e.apply(t,n)}})}(process,"nextTick",function(e,t){return{name:"process.nextTick",args:t,cbIdx:t.length>0&&"function"==typeof t[0]?0:-1,target:process}})}),Zone.__load_patch("handleUnhandledPromiseRejection",function(e,t,n){function r(e){return function(t){L(process,e).forEach(function(n){"unhandledRejection"===e?n.invoke(t.rejection,t.promise):"rejectionHandled"===e&&n.invoke(t.promise)})}}t[n.symbol("unhandledPromiseRejectionHandler")]=r("unhandledRejection"),t[n.symbol("rejectionHandledHandler")]=r("rejectionHandled")}),Zone.__load_patch("crypto",function(){var e;try{e=require("crypto")}catch(e){}e&&["randomBytes","pbkdf2"].forEach(function(t){D(e,t,function(n,r){return{name:"crypto."+t,args:r,cbIdx:r.length>0&&"function"==typeof r[r.length-1]?r.length-1:-1,target:e}})})}),Zone.__load_patch("console",function(e,t){["dir","log","info","error","warn","assert","debug","timeEnd","trace"].forEach(function(e){var n=console[t.__symbol__(e)]=console[e];n&&(console[e]=function(){var e=r.call(arguments);return t.current===t.root?n.apply(this,e):t.root.run(n,this,e)})})})}); \ No newline at end of file diff --git a/dist/zone-patch-canvas.js b/dist/zone-patch-canvas.js old mode 100644 new mode 100755 index 593f4cc26..be418a14f --- a/dist/zone-patch-canvas.js +++ b/dist/zone-patch-canvas.js @@ -5,27 +5,26 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('canvas', function (global, Zone, api) { - var HTMLCanvasElement = global['HTMLCanvasElement']; - if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && - HTMLCanvasElement.prototype.toBlob) { - api.patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { - return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; - }); - } -}); - -}))); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('canvas', function (global, Zone, api) { + var HTMLCanvasElement = global['HTMLCanvasElement']; + if (typeof HTMLCanvasElement !== 'undefined' && HTMLCanvasElement.prototype && + HTMLCanvasElement.prototype.toBlob) { + api.patchMacroTask(HTMLCanvasElement.prototype, 'toBlob', function (self, args) { + return { name: 'HTMLCanvasElement.toBlob', target: self, cbIdx: 0, args: args }; + }); + } + }); +})); +//# sourceMappingURL=zone-patch-canvas-rollup.umd.js.map diff --git a/dist/zone-patch-canvas.min.js b/dist/zone-patch-canvas.min.js old mode 100644 new mode 100755 index 94168d1d4..89081bef8 --- a/dist/zone-patch-canvas.min.js +++ b/dist/zone-patch-canvas.min.js @@ -1 +1,15 @@ -!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("canvas",function(t,o,e){var n=t.HTMLCanvasElement;void 0!==n&&n.prototype&&n.prototype.toBlob&&e.patchMacroTask(n.prototype,"toBlob",function(t,o){return{name:"HTMLCanvasElement.toBlob",target:t,cbIdx:0,args:o}})})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict"; +/** + * @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.__load_patch("canvas",function(t,o,n){var e=t.HTMLCanvasElement;void 0!==e&&e.prototype&&e.prototype.toBlob&&n.patchMacroTask(e.prototype,"toBlob",function(t,o){return{name:"HTMLCanvasElement.toBlob",target:t,cbIdx:0,args:o}})})}); \ No newline at end of file diff --git a/dist/zone-patch-cordova.js b/dist/zone-patch-cordova.js old mode 100644 new mode 100755 index 187f219f2..d0d2b33fe --- a/dist/zone-patch-cordova.js +++ b/dist/zone-patch-cordova.js @@ -5,50 +5,49 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('cordova', function (global, Zone, api) { - if (global.cordova) { - var SUCCESS_SOURCE_1 = 'cordova.exec.success'; - var ERROR_SOURCE_1 = 'cordova.exec.error'; - var FUNCTION_1 = 'function'; - var nativeExec_1 = api.patchMethod(global.cordova, 'exec', function () { return function (self, args) { - if (args.length > 0 && typeof args[0] === FUNCTION_1) { - args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE_1); - } - if (args.length > 1 && typeof args[1] === FUNCTION_1) { - args[1] = Zone.current.wrap(args[1], ERROR_SOURCE_1); - } - return nativeExec_1.apply(self, args); - }; }); - } -}); -Zone.__load_patch('cordova.FileReader', function (global, Zone) { - if (global.cordova && typeof global['FileReader'] !== 'undefined') { - document.addEventListener('deviceReady', function () { - var FileReader = global['FileReader']; - ['abort', 'error', 'load', 'loadstart', 'loadend', 'progress'].forEach(function (prop) { - var eventNameSymbol = Zone.__symbol__('ON_PROPERTY' + prop); - Object.defineProperty(FileReader.prototype, eventNameSymbol, { - configurable: true, - get: function () { - return this._realReader && this._realReader[eventNameSymbol]; - } +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('cordova', function (global, Zone, api) { + if (global.cordova) { + var SUCCESS_SOURCE_1 = 'cordova.exec.success'; + var ERROR_SOURCE_1 = 'cordova.exec.error'; + var FUNCTION_1 = 'function'; + var nativeExec_1 = api.patchMethod(global.cordova, 'exec', function () { return function (self, args) { + if (args.length > 0 && typeof args[0] === FUNCTION_1) { + args[0] = Zone.current.wrap(args[0], SUCCESS_SOURCE_1); + } + if (args.length > 1 && typeof args[1] === FUNCTION_1) { + args[1] = Zone.current.wrap(args[1], ERROR_SOURCE_1); + } + return nativeExec_1.apply(self, args); + }; }); + } + }); + Zone.__load_patch('cordova.FileReader', function (global, Zone) { + if (global.cordova && typeof global['FileReader'] !== 'undefined') { + document.addEventListener('deviceReady', function () { + var FileReader = global['FileReader']; + ['abort', 'error', 'load', 'loadstart', 'loadend', 'progress'].forEach(function (prop) { + var eventNameSymbol = Zone.__symbol__('ON_PROPERTY' + prop); + Object.defineProperty(FileReader.prototype, eventNameSymbol, { + configurable: true, + get: function () { + return this._realReader && this._realReader[eventNameSymbol]; + } + }); }); }); - }); - } -}); - -}))); + } + }); +})); +//# sourceMappingURL=zone-patch-cordova-rollup.umd.js.map diff --git a/dist/zone-patch-cordova.min.js b/dist/zone-patch-cordova.min.js old mode 100644 new mode 100755 index 6f6dad108..503fb27c4 --- a/dist/zone-patch-cordova.min.js +++ b/dist/zone-patch-cordova.min.js @@ -1 +1,15 @@ -!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("cordova",function(e,o,r){if(e.cordova)var t=r.patchMethod(e.cordova,"exec",function(){return function(e,r){return r.length>0&&"function"==typeof r[0]&&(r[0]=o.current.wrap(r[0],"cordova.exec.success")),r.length>1&&"function"==typeof r[1]&&(r[1]=o.current.wrap(r[1],"cordova.exec.error")),t.apply(e,r)}})}),Zone.__load_patch("cordova.FileReader",function(e,o){e.cordova&&void 0!==e.FileReader&&document.addEventListener("deviceReady",function(){var r=e.FileReader;["abort","error","load","loadstart","loadend","progress"].forEach(function(e){var t=o.__symbol__("ON_PROPERTY"+e);Object.defineProperty(r.prototype,t,{configurable:!0,get:function(){return this._realReader&&this._realReader[t]}})})})})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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.__load_patch("cordova",function(e,o,r){if(e.cordova)var n=r.patchMethod(e.cordova,"exec",function(){return function(e,r){return r.length>0&&"function"==typeof r[0]&&(r[0]=o.current.wrap(r[0],"cordova.exec.success")),r.length>1&&"function"==typeof r[1]&&(r[1]=o.current.wrap(r[1],"cordova.exec.error")),n.apply(e,r)}})}),Zone.__load_patch("cordova.FileReader",function(e,o){e.cordova&&void 0!==e.FileReader&&document.addEventListener("deviceReady",function(){var r=e.FileReader;["abort","error","load","loadstart","loadend","progress"].forEach(function(e){var n=o.__symbol__("ON_PROPERTY"+e);Object.defineProperty(r.prototype,n,{configurable:!0,get:function(){return this._realReader&&this._realReader[n]}})})})})}); \ No newline at end of file diff --git a/dist/zone-patch-electron.js b/dist/zone-patch-electron.js old mode 100644 new mode 100755 index 2efb290cd..e2708391f --- a/dist/zone-patch-electron.js +++ b/dist/zone-patch-electron.js @@ -6,39 +6,42 @@ * found in the LICENSE file at https://angular.io/license */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('electron', function (global, Zone, api) { - function patchArguments(target, name, source) { - return api.patchMethod(target, name, function (delegate) { return function (self, args) { - return delegate && delegate.apply(self, api.bindArguments(args, source)); - }; }); - } - var _a = require('electron'), desktopCapturer = _a.desktopCapturer, shell = _a.shell, CallbacksRegistry = _a.CallbacksRegistry; - // patch api in renderer process directly - // desktopCapturer - if (desktopCapturer) { - patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources'); - } - // shell - if (shell) { - patchArguments(shell, 'openExternal', 'electron.shell.openExternal'); - } - // patch api in main process through CallbackRegistry - if (!CallbacksRegistry) { - return; - } - patchArguments(CallbacksRegistry.prototype, 'add', 'CallbackRegistry.add'); -}); - -}))); + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('electron')) : + typeof define === 'function' && define.amd ? define(['electron'], factory) : + (global = global || self, global['zone-patch-electron-rollup'] = factory(global.electron)); +}(this, function (electron$1) { + 'use strict'; + electron$1 = electron$1 && electron$1.hasOwnProperty('default') ? electron$1['default'] : electron$1; + /** + * @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.__load_patch('electron', function (global, Zone, api) { + function patchArguments(target, name, source) { + return api.patchMethod(target, name, function (delegate) { return function (self, args) { + return delegate && delegate.apply(self, api.bindArguments(args, source)); + }; }); + } + var desktopCapturer = electron$1.desktopCapturer, shell = electron$1.shell, CallbacksRegistry = electron$1.CallbacksRegistry; + // patch api in renderer process directly + // desktopCapturer + if (desktopCapturer) { + patchArguments(desktopCapturer, 'getSources', 'electron.desktopCapturer.getSources'); + } + // shell + if (shell) { + patchArguments(shell, 'openExternal', 'electron.shell.openExternal'); + } + // patch api in main process through CallbackRegistry + if (!CallbacksRegistry) { + return; + } + patchArguments(CallbacksRegistry.prototype, 'add', 'CallbackRegistry.add'); + }); + var electron = {}; + return electron; +})); +//# sourceMappingURL=zone-patch-electron-rollup.umd.js.map diff --git a/dist/zone-patch-electron.min.js b/dist/zone-patch-electron.min.js old mode 100644 new mode 100755 index e23b6d97e..0e9413d1e --- a/dist/zone-patch-electron.min.js +++ b/dist/zone-patch-electron.min.js @@ -1 +1,16 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";Zone.__load_patch("electron",function(e,t,n){function o(e,t,o){return n.patchMethod(e,t,function(e){return function(t,r){return e&&e.apply(t,n.bindArguments(r,o))}})}var r=require("electron"),c=r.desktopCapturer,u=r.shell,l=r.CallbacksRegistry;c&&o(c,"getSources","electron.desktopCapturer.getSources"),u&&o(u,"openExternal","electron.shell.openExternal"),l&&o(l.prototype,"add","CallbackRegistry.add")})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("electron")):"function"==typeof define&&define.amd?define(["electron"],t):(e=e||self)["zone-patch-electron-rollup"]=t(e.electron)}(this,function(e){"use strict";return e=e&&e.hasOwnProperty("default")?e.default:e, +/** + * @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.__load_patch("electron",function(t,n,o){function r(e,t,n){return o.patchMethod(e,t,function(e){return function(t,r){return e&&e.apply(t,o.bindArguments(r,n))}})}var l=e.desktopCapturer,u=e.shell,c=e.CallbacksRegistry;l&&r(l,"getSources","electron.desktopCapturer.getSources"),u&&r(u,"openExternal","electron.shell.openExternal"),c&&r(c.prototype,"add","CallbackRegistry.add")}),{}}); \ No newline at end of file diff --git a/dist/zone-patch-fetch.js b/dist/zone-patch-fetch.js old mode 100644 new mode 100755 index 5fe62a84a..455705108 --- a/dist/zone-patch-fetch.js +++ b/dist/zone-patch-fetch.js @@ -5,116 +5,115 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -Zone.__load_patch('fetch', function (global, Zone, api) { - var fetch = global['fetch']; - if (typeof fetch !== 'function') { - return; - } - var originalFetch = global[api.symbol('fetch')]; - if (originalFetch) { - // restore unpatched fetch first - fetch = originalFetch; - } - var ZoneAwarePromise = global.Promise; - var symbolThenPatched = api.symbol('thenPatched'); - var fetchTaskScheduling = api.symbol('fetchTaskScheduling'); - var fetchTaskAborting = api.symbol('fetchTaskAborting'); - var OriginalAbortController = global['AbortController']; - var supportAbort = typeof OriginalAbortController === 'function'; - var abortNative = null; - if (supportAbort) { - global['AbortController'] = function () { - var abortController = new OriginalAbortController(); - var signal = abortController.signal; - signal.abortController = abortController; - return abortController; - }; - abortNative = api.patchMethod(OriginalAbortController.prototype, 'abort', function (delegate) { return function (self, args) { - if (self.task) { - return self.task.zone.cancelTask(self.task); - } - return delegate.apply(self, args); - }; }); - } - var placeholder = function () { }; - global['fetch'] = function () { - var _this = this; - var args = Array.prototype.slice.call(arguments); - var options = args.length > 1 ? args[1] : null; - var signal = options && options.signal; - return new Promise(function (res, rej) { - var task = Zone.current.scheduleMacroTask('fetch', placeholder, { fetchArgs: args }, function () { - var fetchPromise; - var zone = Zone.current; - try { - zone[fetchTaskScheduling] = true; - fetchPromise = fetch.apply(_this, args); - } - catch (error) { - rej(error); - return; - } - finally { - zone[fetchTaskScheduling] = false; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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 + */ + /** + * @fileoverview + * @suppress {missingRequire} + */ + Zone.__load_patch('fetch', function (global, Zone, api) { + var fetch = global['fetch']; + if (typeof fetch !== 'function') { + return; + } + var originalFetch = global[api.symbol('fetch')]; + if (originalFetch) { + // restore unpatched fetch first + fetch = originalFetch; + } + var ZoneAwarePromise = global.Promise; + var symbolThenPatched = api.symbol('thenPatched'); + var fetchTaskScheduling = api.symbol('fetchTaskScheduling'); + var fetchTaskAborting = api.symbol('fetchTaskAborting'); + var OriginalAbortController = global['AbortController']; + var supportAbort = typeof OriginalAbortController === 'function'; + var abortNative = null; + if (supportAbort) { + global['AbortController'] = function () { + var abortController = new OriginalAbortController(); + var signal = abortController.signal; + signal.abortController = abortController; + return abortController; + }; + abortNative = api.patchMethod(OriginalAbortController.prototype, 'abort', function (delegate) { return function (self, args) { + if (self.task) { + return self.task.zone.cancelTask(self.task); } - if (!(fetchPromise instanceof ZoneAwarePromise)) { - var ctor = fetchPromise.constructor; - if (!ctor[symbolThenPatched]) { - api.patchThen(ctor); + return delegate.apply(self, args); + }; }); + } + var placeholder = function () { }; + global['fetch'] = function () { + var _this = this; + var args = Array.prototype.slice.call(arguments); + var options = args.length > 1 ? args[1] : null; + var signal = options && options.signal; + return new Promise(function (res, rej) { + var task = Zone.current.scheduleMacroTask('fetch', placeholder, { fetchArgs: args }, function () { + var fetchPromise; + var zone = Zone.current; + try { + zone[fetchTaskScheduling] = true; + fetchPromise = fetch.apply(_this, args); } - } - fetchPromise.then(function (resource) { - if (task.state !== 'notScheduled') { - task.invoke(); + catch (error) { + rej(error); + return; } - res(resource); - }, function (error) { - if (task.state !== 'notScheduled') { - task.invoke(); + finally { + zone[fetchTaskScheduling] = false; } - rej(error); - }); - }, function () { - if (!supportAbort) { - rej('No AbortController supported, can not cancel fetch'); - return; - } - if (signal && signal.abortController && !signal.aborted && - typeof signal.abortController.abort === 'function' && abortNative) { - try { - Zone.current[fetchTaskAborting] = true; - abortNative.call(signal.abortController); + if (!(fetchPromise instanceof ZoneAwarePromise)) { + var ctor = fetchPromise.constructor; + if (!ctor[symbolThenPatched]) { + api.patchThen(ctor); + } } - finally { - Zone.current[fetchTaskAborting] = false; + fetchPromise.then(function (resource) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + res(resource); + }, function (error) { + if (task.state !== 'notScheduled') { + task.invoke(); + } + rej(error); + }); + }, function () { + if (!supportAbort) { + rej('No AbortController supported, can not cancel fetch'); + return; } - } - else { - rej('cancel fetch need a AbortController.signal'); + if (signal && signal.abortController && !signal.aborted && + typeof signal.abortController.abort === 'function' && abortNative) { + try { + Zone.current[fetchTaskAborting] = true; + abortNative.call(signal.abortController); + } + finally { + Zone.current[fetchTaskAborting] = false; + } + } + else { + rej('cancel fetch need a AbortController.signal'); + } + }); + if (signal && signal.abortController) { + signal.abortController.task = task; } }); - if (signal && signal.abortController) { - signal.abortController.task = task; - } - }); - }; -}); - -}))); + }; + }); +})); +//# sourceMappingURL=zone-patch-fetch-rollup.umd.js.map diff --git a/dist/zone-patch-fetch.min.js b/dist/zone-patch-fetch.min.js old mode 100644 new mode 100755 index 29c5d0db0..063865547 --- a/dist/zone-patch-fetch.min.js +++ b/dist/zone-patch-fetch.min.js @@ -1 +1,15 @@ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";Zone.__load_patch("fetch",function(t,n,o){var e=t.fetch;if("function"==typeof e){var r=t[o.symbol("fetch")];r&&(e=r);var c=t.Promise,l=o.symbol("thenPatched"),a=o.symbol("fetchTaskScheduling"),f=o.symbol("fetchTaskAborting"),i=t.AbortController,u="function"==typeof i,s=null;u&&(t.AbortController=function(){var t=new i;return t.signal.abortController=t,t},s=o.patchMethod(i.prototype,"abort",function(t){return function(n,o){return n.task?n.task.zone.cancelTask(n.task):t.apply(n,o)}}));var h=function(){};t.fetch=function(){var t=this,r=Array.prototype.slice.call(arguments),i=r.length>1?r[1]:null,d=i&&i.signal;return new Promise(function(i,p){var b=n.current.scheduleMacroTask("fetch",h,{fetchArgs:r},function(){var f,u=n.current;try{u[a]=!0,f=e.apply(t,r)}catch(t){return void p(t)}finally{u[a]=!1}if(!(f instanceof c)){var s=f.constructor;s[l]||o.patchThen(s)}f.then(function(t){"notScheduled"!==b.state&&b.invoke(),i(t)},function(t){"notScheduled"!==b.state&&b.invoke(),p(t)})},function(){if(u)if(d&&d.abortController&&!d.aborted&&"function"==typeof d.abortController.abort&&s)try{n.current[f]=!0,s.call(d.abortController)}finally{n.current[f]=!1}else p("cancel fetch need a AbortController.signal");else p("No AbortController supported, can not cancel fetch")});d&&d.abortController&&(d.abortController.task=b)})}}})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict"; +/** + * @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.__load_patch("fetch",function(t,n,o){var e=t.fetch;if("function"==typeof e){var r=t[o.symbol("fetch")];r&&(e=r);var c=t.Promise,l=o.symbol("thenPatched"),a=o.symbol("fetchTaskScheduling"),f=o.symbol("fetchTaskAborting"),i=t.AbortController,u="function"==typeof i,s=null;u&&(t.AbortController=function(){var t=new i;return t.signal.abortController=t,t},s=o.patchMethod(i.prototype,"abort",function(t){return function(n,o){return n.task?n.task.zone.cancelTask(n.task):t.apply(n,o)}}));var h=function(){};t.fetch=function(){var t=this,r=Array.prototype.slice.call(arguments),i=r.length>1?r[1]:null,b=i&&i.signal;return new Promise(function(i,d){var p=n.current.scheduleMacroTask("fetch",h,{fetchArgs:r},function(){var f,u=n.current;try{u[a]=!0,f=e.apply(t,r)}catch(t){return void d(t)}finally{u[a]=!1}if(!(f instanceof c)){var s=f.constructor;s[l]||o.patchThen(s)}f.then(function(t){"notScheduled"!==p.state&&p.invoke(),i(t)},function(t){"notScheduled"!==p.state&&p.invoke(),d(t)})},function(){if(u)if(b&&b.abortController&&!b.aborted&&"function"==typeof b.abortController.abort&&s)try{n.current[f]=!0,s.call(b.abortController)}finally{n.current[f]=!1}else d("cancel fetch need a AbortController.signal");else d("No AbortController supported, can not cancel fetch")});b&&b.abortController&&(b.abortController.task=p)})}}})}); \ No newline at end of file diff --git a/dist/zone-patch-jsonp.js b/dist/zone-patch-jsonp.js old mode 100644 new mode 100755 index d7e75f2b8..4c31ec8a2 --- a/dist/zone-patch-jsonp.js +++ b/dist/zone-patch-jsonp.js @@ -5,78 +5,85 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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.__load_patch('jsonp', function (global, Zone, api) { - Zone[Zone.__symbol__('jsonp')] = function patchJsonp(options) { - if (!options || !options.jsonp || !options.sendFuncName) { - return; - } - var noop = function () { }; - [options.successFuncName, options.failedFuncName].forEach(function (methodName) { - if (!methodName) { +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('jsonp', function (global, Zone, api) { + // because jsonp is not a standard api, there are a lot of + // implementations, so zone.js just provide a helper util to + // patch the jsonp send and onSuccess/onError callback + // the options is an object which contains + // - jsonp, the jsonp object which hold the send function + // - sendFuncName, the name of the send function + // - successFuncName, success func name + // - failedFuncName, failed func name + Zone[Zone.__symbol__('jsonp')] = function patchJsonp(options) { + if (!options || !options.jsonp || !options.sendFuncName) { return; } - var oriFunc = global[methodName]; - if (oriFunc) { - api.patchMethod(global, methodName, function (delegate) { return function (self, args) { - var task = global[api.symbol('jsonTask')]; - if (task) { - task.callback = delegate; - return task.invoke.apply(self, args); - } - else { - return delegate.apply(self, args); - } - }; }); - } - else { - Object.defineProperty(global, methodName, { - configurable: true, - enumerable: true, - get: function () { - return function () { - var task = global[api.symbol('jsonpTask')]; - var delegate = global[api.symbol("jsonp" + methodName + "callback")]; - if (task) { - if (delegate) { - task.callback = delegate; + var noop = function () { }; + [options.successFuncName, options.failedFuncName].forEach(function (methodName) { + if (!methodName) { + return; + } + var oriFunc = global[methodName]; + if (oriFunc) { + api.patchMethod(global, methodName, function (delegate) { return function (self, args) { + var task = global[api.symbol('jsonTask')]; + if (task) { + task.callback = delegate; + return task.invoke.apply(self, args); + } + else { + return delegate.apply(self, args); + } + }; }); + } + else { + Object.defineProperty(global, methodName, { + configurable: true, + enumerable: true, + get: function () { + return function () { + var task = global[api.symbol('jsonpTask')]; + var delegate = global[api.symbol("jsonp" + methodName + "callback")]; + if (task) { + if (delegate) { + task.callback = delegate; + } + global[api.symbol('jsonpTask')] = undefined; + return task.invoke.apply(this, arguments); } - global[api.symbol('jsonpTask')] = undefined; - return task.invoke.apply(this, arguments); - } - else { - if (delegate) { - return delegate.apply(this, arguments); + else { + if (delegate) { + return delegate.apply(this, arguments); + } } - } - return null; - }; - }, - set: function (callback) { - this[api.symbol("jsonp" + methodName + "callback")] = callback; - } - }); - } - }); - api.patchMethod(options.jsonp, options.sendFuncName, function (delegate) { return function (self, args) { - global[api.symbol('jsonpTask')] = - Zone.current.scheduleMacroTask('jsonp', noop, {}, function (task) { - return delegate.apply(self, args); - }, noop); - }; }); - }; -}); - -}))); + return null; + }; + }, + set: function (callback) { + this[api.symbol("jsonp" + methodName + "callback")] = callback; + } + }); + } + }); + api.patchMethod(options.jsonp, options.sendFuncName, function (delegate) { return function (self, args) { + global[api.symbol('jsonpTask')] = + Zone.current.scheduleMacroTask('jsonp', noop, {}, function (task) { + return delegate.apply(self, args); + }, noop); + }; }); + }; + }); +})); +//# sourceMappingURL=zone-patch-jsonp-rollup.umd.js.map diff --git a/dist/zone-patch-jsonp.min.js b/dist/zone-patch-jsonp.min.js old mode 100644 new mode 100755 index 854d97b9b..d85058452 --- a/dist/zone-patch-jsonp.min.js +++ b/dist/zone-patch-jsonp.min.js @@ -1 +1,15 @@ -!function(n,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("jsonp",function(n,o,e){o[o.__symbol__("jsonp")]=function(t){if(t&&t.jsonp&&t.sendFuncName){var c=function(){};[t.successFuncName,t.failedFuncName].forEach(function(o){o&&(n[o]?e.patchMethod(n,o,function(o){return function(t,c){var s=n[e.symbol("jsonTask")];return s?(s.callback=o,s.invoke.apply(t,c)):o.apply(t,c)}}):Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:function(){return function(){var t=n[e.symbol("jsonpTask")],c=n[e.symbol("jsonp"+o+"callback")];return t?(c&&(t.callback=c),n[e.symbol("jsonpTask")]=void 0,t.invoke.apply(this,arguments)):c?c.apply(this,arguments):null}},set:function(n){this[e.symbol("jsonp"+o+"callback")]=n}}))}),e.patchMethod(t.jsonp,t.sendFuncName,function(t){return function(s,a){n[e.symbol("jsonpTask")]=o.current.scheduleMacroTask("jsonp",c,{},function(n){return t.apply(s,a)},c)}})}}})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(n){"function"==typeof define&&define.amd?define(n):n()}(function(){"use strict"; +/** + * @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.__load_patch("jsonp",function(n,o,e){o[o.__symbol__("jsonp")]=function c(t){if(t&&t.jsonp&&t.sendFuncName){var a=function(){};[t.successFuncName,t.failedFuncName].forEach(function(o){o&&(n[o]?e.patchMethod(n,o,function(o){return function(c,t){var a=n[e.symbol("jsonTask")];return a?(a.callback=o,a.invoke.apply(c,t)):o.apply(c,t)}}):Object.defineProperty(n,o,{configurable:!0,enumerable:!0,get:function(){return function(){var c=n[e.symbol("jsonpTask")],t=n[e.symbol("jsonp"+o+"callback")];return c?(t&&(c.callback=t),n[e.symbol("jsonpTask")]=void 0,c.invoke.apply(this,arguments)):t?t.apply(this,arguments):null}},set:function(n){this[e.symbol("jsonp"+o+"callback")]=n}}))}),e.patchMethod(t.jsonp,t.sendFuncName,function(c){return function(t,s){n[e.symbol("jsonpTask")]=o.current.scheduleMacroTask("jsonp",a,{},function(n){return c.apply(t,s)},a)}})}}})}); \ No newline at end of file diff --git a/dist/zone-patch-promise-test.js b/dist/zone-patch-promise-test.js old mode 100644 new mode 100755 index 45a7db12d..e0574f049 --- a/dist/zone-patch-promise-test.js +++ b/dist/zone-patch-promise-test.js @@ -5,76 +5,75 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 - */ -/** - * Promise for async/fakeAsync zoneSpec test - * can support async operation which not supported by zone.js - * such as - * it ('test jsonp in AsyncZone', async() => { - * new Promise(res => { - * jsonp(url, (data) => { - * // success callback - * res(data); - * }); - * }).then((jsonpResult) => { - * // get jsonp result. - * - * // user will expect AsyncZoneSpec wait for - * // then, but because jsonp is not zone aware - * // AsyncZone will finish before then is called. - * }); - * }); - */ -Zone.__load_patch('promisefortest', function (global, Zone, api) { - var symbolState = api.symbol('state'); - var UNRESOLVED = null; - var symbolParentUnresolved = api.symbol('parentUnresolved'); - // patch Promise.prototype.then to keep an internal - // number for tracking unresolved chained promise - // we will decrease this number when the parent promise - // being resolved/rejected and chained promise was - // scheduled as a microTask. - // so we can know such kind of chained promise still - // not resolved in AsyncTestZone - Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - return; - } - oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; - Promise.prototype.then = function () { - var chained = oriThen.apply(this, arguments); - if (this[symbolState] === UNRESOLVED) { - // parent promise is unresolved. - var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); - if (asyncTestZoneSpec) { - asyncTestZoneSpec.unresolvedChainedPromiseCount++; - chained[symbolParentUnresolved] = true; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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 + */ + /** + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. + * + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); + */ + Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; } - return chained; }; - }; - Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { - // restore origin then - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - Promise.prototype.then = oriThen; - Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; - } - }; -}); - -}))); + }); +})); +//# sourceMappingURL=zone-patch-promise-test-rollup.umd.js.map diff --git a/dist/zone-patch-promise-test.min.js b/dist/zone-patch-promise-test.min.js old mode 100644 new mode 100755 index 276e491e8..a483fd88c --- a/dist/zone-patch-promise-test.min.js +++ b/dist/zone-patch-promise-test.min.js @@ -1 +1,15 @@ -!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o():"function"==typeof define&&define.amd?define(o):o()}(0,function(){"use strict";Zone.__load_patch("promisefortest",function(e,o,n){var t=n.symbol("state"),s=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e||(e=Promise[o.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var n=e.apply(this,arguments);if(null===this[t]){var r=o.current.get("AsyncTestZoneSpec");r&&(r.unresolvedChainedPromiseCount++,n[s]=!0)}return n})},Promise[n.symbol("unPatchPromiseForTest")]=function(){var e=Promise[o.__symbol__("ZonePromiseThen")];e&&(Promise.prototype.then=e,Promise[o.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file +/** +* @license +* Copyright Google Inc. All Rights Reserved. +* +* Use of this source code is governed by an MIT-style license that can be +* found in the LICENSE file at https://angular.io/license +*/ +!function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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.__load_patch("promisefortest",function(e,o,n){var s=n.symbol("state"),r=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function e(){var n=Promise[o.__symbol__("ZonePromiseThen")];n||(n=Promise[o.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var e=n.apply(this,arguments);if(null===this[s]){var t=o.current.get("AsyncTestZoneSpec");t&&(t.unresolvedChainedPromiseCount++,e[r]=!0)}return e})},Promise[n.symbol("unPatchPromiseForTest")]=function e(){var n=Promise[o.__symbol__("ZonePromiseThen")];n&&(Promise.prototype.then=n,Promise[o.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone-patch-resize-observer.js b/dist/zone-patch-resize-observer.js old mode 100644 new mode 100755 index b85d7ee9f..22372c353 --- a/dist/zone-patch-resize-observer.js +++ b/dist/zone-patch-resize-observer.js @@ -5,46 +5,33 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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.__load_patch('ResizeObserver', function (global, Zone, api) { + var ResizeObserver = global['ResizeObserver']; + if (!ResizeObserver) { + 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 - */ -Zone.__load_patch('ResizeObserver', function (global, Zone, api) { - var ResizeObserver = global['ResizeObserver']; - if (!ResizeObserver) { - return; - } - var resizeObserverSymbol = api.symbol('ResizeObserver'); - api.patchMethod(global, 'ResizeObserver', function (delegate) { return function (self, args) { - var callback = args.length > 0 ? args[0] : null; - if (callback) { - args[0] = function (entries, observer) { - var _this = this; - var e_1, _a; - var zones = {}; - var currZone = Zone.current; - try { - for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { - var entry = entries_1_1.value; + var resizeObserverSymbol = api.symbol('ResizeObserver'); + api.patchMethod(global, 'ResizeObserver', function (delegate) { return function (self, args) { + var callback = args.length > 0 ? args[0] : null; + if (callback) { + args[0] = function (entries, observer) { + var _this = this; + var zones = {}; + var currZone = Zone.current; + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; var zone = entry.target[resizeObserverSymbol]; if (!zone) { zone = currZone; @@ -55,67 +42,59 @@ Zone.__load_patch('ResizeObserver', function (global, Zone, api) { } zoneEntriesInfo.entries.push(entry); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); + Object.keys(zones).forEach(function (zoneName) { + var zoneEntriesInfo = zones[zoneName]; + if (zoneEntriesInfo.zone !== Zone.current) { + zoneEntriesInfo.zone.run(callback, _this, [zoneEntriesInfo.entries, observer], 'ResizeObserver'); + } + else { + callback.call(_this, zoneEntriesInfo.entries, observer); + } + }); + }; + } + return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); + }; }); + api.patchMethod(ResizeObserver.prototype, 'observe', function (delegate) { return function (self, args) { + var target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + var targets = self[resizeObserverSymbol]; + if (!targets) { + targets = self[resizeObserverSymbol] = []; + } + targets.push(target); + target[resizeObserverSymbol] = Zone.current; + return delegate.apply(self, args); + }; }); + api.patchMethod(ResizeObserver.prototype, 'unobserve', function (delegate) { return function (self, args) { + var target = args.length > 0 ? args[0] : null; + if (!target) { + return delegate.apply(self, args); + } + var targets = self[resizeObserverSymbol]; + if (targets) { + for (var i = 0; i < targets.length; i++) { + if (targets[i] === target) { + targets.splice(i, 1); + break; } - finally { if (e_1) throw e_1.error; } } - Object.keys(zones).forEach(function (zoneName) { - var zoneEntriesInfo = zones[zoneName]; - if (zoneEntriesInfo.zone !== Zone.current) { - zoneEntriesInfo.zone.run(callback, _this, [zoneEntriesInfo.entries, observer], 'ResizeObserver'); - } - else { - callback.call(_this, zoneEntriesInfo.entries, observer); - } - }); - }; - } - return args.length > 0 ? new ResizeObserver(args[0]) : new ResizeObserver(); - }; }); - api.patchMethod(ResizeObserver.prototype, 'observe', function (delegate) { return function (self, args) { - var target = args.length > 0 ? args[0] : null; - if (!target) { - return delegate.apply(self, args); - } - var targets = self[resizeObserverSymbol]; - if (!targets) { - targets = self[resizeObserverSymbol] = []; - } - targets.push(target); - target[resizeObserverSymbol] = Zone.current; - return delegate.apply(self, args); - }; }); - api.patchMethod(ResizeObserver.prototype, 'unobserve', function (delegate) { return function (self, args) { - var target = args.length > 0 ? args[0] : null; - if (!target) { + } + target[resizeObserverSymbol] = undefined; return delegate.apply(self, args); - } - var targets = self[resizeObserverSymbol]; - if (targets) { - for (var i = 0; i < targets.length; i++) { - if (targets[i] === target) { - targets.splice(i, 1); - break; - } + }; }); + api.patchMethod(ResizeObserver.prototype, 'disconnect', function (delegate) { return function (self, args) { + var targets = self[resizeObserverSymbol]; + if (targets) { + targets.forEach(function (target) { + target[resizeObserverSymbol] = undefined; + }); + self[resizeObserverSymbol] = undefined; } - } - target[resizeObserverSymbol] = undefined; - return delegate.apply(self, args); - }; }); - api.patchMethod(ResizeObserver.prototype, 'disconnect', function (delegate) { return function (self, args) { - var targets = self[resizeObserverSymbol]; - if (targets) { - targets.forEach(function (target) { - target[resizeObserverSymbol] = undefined; - }); - self[resizeObserverSymbol] = undefined; - } - return delegate.apply(self, args); - }; }); -}); - -}))); + return delegate.apply(self, args); + }; }); + }); +})); +//# sourceMappingURL=zone-patch-resize-observer-rollup.umd.js.map diff --git a/dist/zone-patch-resize-observer.min.js b/dist/zone-patch-resize-observer.min.js old mode 100644 new mode 100755 index b118bc8d4..f43fc6f4a --- a/dist/zone-patch-resize-observer.min.js +++ b/dist/zone-patch-resize-observer.min.js @@ -1 +1,15 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";var e=function(e){var n="function"==typeof Symbol&&e[Symbol.iterator],r=0;return n?n.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}};Zone.__load_patch("ResizeObserver",function(n,r,t){var o=n.ResizeObserver;if(o){var i=t.symbol("ResizeObserver");t.patchMethod(n,"ResizeObserver",function(n){return function(n,t){var u=t.length>0?t[0]:null;return u&&(t[0]=function(n,t){var o,a,c=this,f={},l=r.current;try{for(var p=e(n),v=p.next();!v.done;v=p.next()){var s=v.value,h=s.target[i];h||(h=l);var d=f[h.name];d||(f[h.name]=d={entries:[],zone:h}),d.entries.push(s)}}catch(e){o={error:e}}finally{try{v&&!v.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}Object.keys(f).forEach(function(e){var n=f[e];n.zone!==r.current?n.zone.run(u,c,[n.entries,t],"ResizeObserver"):u.call(c,n.entries,t)})}),t.length>0?new o(t[0]):new o}}),t.patchMethod(o.prototype,"observe",function(e){return function(n,t){var o=t.length>0?t[0]:null;if(!o)return e.apply(n,t);var u=n[i];return u||(u=n[i]=[]),u.push(o),o[i]=r.current,e.apply(n,t)}}),t.patchMethod(o.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var o=n[i];if(o)for(var u=0;u0?r[0]:null;return i&&(r[0]=function(e,r){for(var t=this,u={},a=n.current,c=0,f=e;c0?new t(r[0]):new t}}),r.patchMethod(t.prototype,"observe",function(e){return function(r,t){var i=t.length>0?t[0]:null;if(!i)return e.apply(r,t);var u=r[o];return u||(u=r[o]=[]),u.push(i),i[o]=n.current,e.apply(r,t)}}),r.patchMethod(t.prototype,"unobserve",function(e){return function(n,r){var t=r.length>0?r[0]:null;if(!t)return e.apply(n,r);var i=n[o];if(i)for(var u=0;u 1) { + this.connection = null; + return; + } + var connection = this.connection; + var sharedConnection = connectable._connection; + this.connection = null; + if (sharedConnection && (!connection || sharedConnection === connection)) { + sharedConnection.unsubscribe(); + } + }; + return RefCountSubscriber; + }(Subscriber)); + var ConnectableObservable = /** @class */ (function (_super) { + __extends(ConnectableObservable, _super); + function ConnectableObservable(source, subjectFactory) { + var _this = _super.call(this) || this; + _this.source = source; + _this.subjectFactory = subjectFactory; + _this._refCount = 0; + _this._isComplete = false; + return _this; + } + ConnectableObservable.prototype._subscribe = function (subscriber) { + return this.getSubject().subscribe(subscriber); + }; + ConnectableObservable.prototype.getSubject = function () { + var subject = this._subject; + if (!subject || subject.isStopped) { + this._subject = this.subjectFactory(); + } + return this._subject; + }; + ConnectableObservable.prototype.connect = function () { + var connection = this._connection; + if (!connection) { + this._isComplete = false; + connection = this._connection = new Subscription(); + connection.add(this.source + .subscribe(new ConnectableSubscriber(this.getSubject(), this))); + if (connection.closed) { + this._connection = null; + connection = Subscription.EMPTY; + } + else { + this._connection = connection; + } + } + return connection; + }; + ConnectableObservable.prototype.refCount = function () { + return refCount()(this); + }; + return ConnectableObservable; + }(Observable)); + var connectableProto = ConnectableObservable.prototype; + var connectableObservableDescriptor = { + operator: { value: null }, + _refCount: { value: 0, writable: true }, + _subject: { value: null, writable: true }, + _connection: { value: null, writable: true }, + _subscribe: { value: connectableProto._subscribe }, + _isComplete: { value: connectableProto._isComplete, writable: true }, + getSubject: { value: connectableProto.getSubject }, + connect: { value: connectableProto.connect }, + refCount: { value: connectableProto.refCount } + }; + var ConnectableSubscriber = /** @class */ (function (_super) { + __extends(ConnectableSubscriber, _super); + function ConnectableSubscriber(destination, connectable) { + var _this = _super.call(this, destination) || this; + _this.connectable = connectable; + return _this; + } + ConnectableSubscriber.prototype._error = function (err) { + this._unsubscribe(); + _super.prototype._error.call(this, err); + }; + ConnectableSubscriber.prototype._complete = function () { + this.connectable._isComplete = true; + this._unsubscribe(); + _super.prototype._complete.call(this); + }; + ConnectableSubscriber.prototype._unsubscribe = function () { + var connectable = this.connectable; + if (connectable) { + this.connectable = null; + var connection = connectable._connection; + connectable._refCount = 0; + connectable._subject = null; + connectable._connection = null; + if (connection) { + connection.unsubscribe(); + } + } + }; + return ConnectableSubscriber; + }(SubjectSubscriber)); + var Action = /** @class */ (function (_super) { + __extends(Action, _super); + function Action(scheduler, work) { + return _super.call(this) || this; + } + Action.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + return this; + }; + return Action; + }(Subscription)); + var AsyncAction = /** @class */ (function (_super) { + __extends(AsyncAction, _super); + function AsyncAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + _this.pending = false; + return _this; + } + AsyncAction.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + if (this.closed) { + return this; + } + this.state = state; + var id = this.id; + var scheduler = this.scheduler; + if (id != null) { + this.id = this.recycleAsyncId(scheduler, id, delay); + } + this.pending = true; + this.delay = delay; + this.id = this.id || this.requestAsyncId(scheduler, this.id, delay); + return this; + }; + AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + return setInterval(scheduler.flush.bind(scheduler, this), delay); + }; + AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if (delay !== null && this.delay === delay && this.pending === false) { + return id; + } + return clearInterval(id) && undefined || undefined; + }; + AsyncAction.prototype.execute = function (state, delay) { + if (this.closed) { + return new Error('executing a cancelled action'); + } + this.pending = false; + var error = this._execute(state, delay); + if (error) { + return error; + } + else if (this.pending === false && this.id != null) { + this.id = this.recycleAsyncId(this.scheduler, this.id, null); + } + }; + AsyncAction.prototype._execute = function (state, delay) { + var errored = false; + var errorValue = undefined; + try { + this.work(state); + } + catch (e) { + errored = true; + errorValue = !!e && e || new Error(e); + } + if (errored) { + this.unsubscribe(); + return errorValue; + } + }; + AsyncAction.prototype._unsubscribe = function () { + var id = this.id; + var scheduler = this.scheduler; + var actions = scheduler.actions; + var index = actions.indexOf(this); + this.work = null; + this.state = null; + this.pending = false; + this.scheduler = null; + if (index !== -1) { + actions.splice(index, 1); + } + if (id != null) { + this.id = this.recycleAsyncId(scheduler, id, null); + } + this.delay = null; + }; + return AsyncAction; + }(Action)); + var QueueAction = /** @class */ (function (_super) { + __extends(QueueAction, _super); + function QueueAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + QueueAction.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + if (delay > 0) { + return _super.prototype.schedule.call(this, state, delay); + } + this.delay = delay; + this.state = state; + this.scheduler.flush(this); + return this; + }; + QueueAction.prototype.execute = function (state, delay) { + return (delay > 0 || this.closed) ? + _super.prototype.execute.call(this, state, delay) : + this._execute(state, delay); + }; + QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + return scheduler.flush(this); + }; + return QueueAction; + }(AsyncAction)); + var Scheduler = /** @class */ (function () { + function Scheduler(SchedulerAction, now) { + if (now === void 0) { now = Scheduler.now; } + this.SchedulerAction = SchedulerAction; + this.now = now; + } + Scheduler.prototype.schedule = function (work, delay, state) { + if (delay === void 0) { delay = 0; } + return new this.SchedulerAction(this, work).schedule(state, delay); + }; + return Scheduler; + }()); + Scheduler.now = function () { return Date.now(); }; + var AsyncScheduler = /** @class */ (function (_super) { + __extends(AsyncScheduler, _super); + function AsyncScheduler(SchedulerAction, now) { + if (now === void 0) { now = Scheduler.now; } + var _this = _super.call(this, SchedulerAction, function () { + if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) { + return AsyncScheduler.delegate.now(); + } + else { + return now(); + } + }) || this; + _this.actions = []; + _this.active = false; + _this.scheduled = undefined; + return _this; + } + AsyncScheduler.prototype.schedule = function (work, delay, state) { + if (delay === void 0) { delay = 0; } + if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) { + return AsyncScheduler.delegate.schedule(work, delay, state); + } + else { + return _super.prototype.schedule.call(this, work, delay, state); + } + }; + AsyncScheduler.prototype.flush = function (action) { + var actions = this.actions; + if (this.active) { + actions.push(action); + return; + } + var error; + this.active = true; + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (action = actions.shift()); + this.active = false; + if (error) { + while (action = actions.shift()) { + action.unsubscribe(); + } + throw error; + } + }; + return AsyncScheduler; + }(Scheduler)); + var QueueScheduler = /** @class */ (function (_super) { + __extends(QueueScheduler, _super); + function QueueScheduler() { + return _super !== null && _super.apply(this, arguments) || this; + } + return QueueScheduler; + }(AsyncScheduler)); + var queue = new QueueScheduler(QueueAction); + var nextHandle = 1; + var tasksByHandle = {}; + function runIfPresent(handle) { + var cb = tasksByHandle[handle]; + if (cb) { + cb(); + } + } + var Immediate = { + setImmediate: function (cb) { + var handle = nextHandle++; + tasksByHandle[handle] = cb; + Promise.resolve().then(function () { return runIfPresent(handle); }); + return handle; + }, + clearImmediate: function (handle) { + delete tasksByHandle[handle]; + }, + }; + var AsapAction = /** @class */ (function (_super) { + __extends(AsapAction, _super); + function AsapAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if (delay !== null && delay > 0) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + scheduler.actions.push(this); + return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null))); + }; + AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); + } + if (scheduler.actions.length === 0) { + Immediate.clearImmediate(id); + scheduler.scheduled = undefined; + } + return undefined; + }; + return AsapAction; + }(AsyncAction)); + var AsapScheduler = /** @class */ (function (_super) { + __extends(AsapScheduler, _super); + function AsapScheduler() { + return _super !== null && _super.apply(this, arguments) || this; + } + AsapScheduler.prototype.flush = function (action) { + this.active = true; + this.scheduled = undefined; + var actions = this.actions; + var error; + var index = -1; + var count = actions.length; + action = action || actions.shift(); + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (++index < count && (action = actions.shift())); + this.active = false; + if (error) { + while (++index < count && (action = actions.shift())) { + action.unsubscribe(); + } + throw error; + } + }; + return AsapScheduler; + }(AsyncScheduler)); + var asap = new AsapScheduler(AsapAction); + var async = new AsyncScheduler(AsyncAction); + var AnimationFrameAction = /** @class */ (function (_super) { + __extends(AnimationFrameAction, _super); + function AnimationFrameAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if (delay !== null && delay > 0) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + scheduler.actions.push(this); + return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); })); + }; + AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); + } + if (scheduler.actions.length === 0) { + cancelAnimationFrame(id); + scheduler.scheduled = undefined; + } + return undefined; + }; + return AnimationFrameAction; + }(AsyncAction)); + var AnimationFrameScheduler = /** @class */ (function (_super) { + __extends(AnimationFrameScheduler, _super); + function AnimationFrameScheduler() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationFrameScheduler.prototype.flush = function (action) { + this.active = true; + this.scheduled = undefined; + var actions = this.actions; + var error; + var index = -1; + var count = actions.length; + action = action || actions.shift(); + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (++index < count && (action = actions.shift())); + this.active = false; + if (error) { + while (++index < count && (action = actions.shift())) { + action.unsubscribe(); + } + throw error; + } + }; + return AnimationFrameScheduler; + }(AsyncScheduler)); + var animationFrame = new AnimationFrameScheduler(AnimationFrameAction); + /** + * @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.__load_patch('rxjs.Scheduler.now', function (global, Zone, api) { + api.patchMethod(Scheduler, 'now', function (delegate) { return function (self, args) { + return Date.now.call(self); + }; }); + api.patchMethod(async, 'now', function (delegate) { return function (self, args) { + return Date.now.call(self); + }; }); + api.patchMethod(asap, 'now', function (delegate) { return function (self, args) { + return Date.now.call(self); + }; }); + }); +})); +//# sourceMappingURL=zone-patch-rxjs-fake-async-rollup.umd.js.map diff --git a/dist/zone-patch-rxjs-fake-async.min.js b/dist/zone-patch-rxjs-fake-async.min.js old mode 100644 new mode 100755 index 222420ad3..3771c9490 --- a/dist/zone-patch-rxjs-fake-async.min.js +++ b/dist/zone-patch-rxjs-fake-async.min.js @@ -1 +1,24 @@ -!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("rxjs")):"function"==typeof define&&define.amd?define(["rxjs"],e):e(n.rxjs)}(this,function(n){"use strict";Zone.__load_patch("rxjs.Scheduler.now",function(e,t,o){o.patchMethod(n.Scheduler,"now",function(n){return function(n,e){return Date.now.call(n)}}),o.patchMethod(n.asyncScheduler,"now",function(n){return function(n,e){return Date.now.call(n)}}),o.patchMethod(n.asapScheduler,"now",function(n){return function(n,e){return Date.now.call(n)}})})}); \ No newline at end of file +var __extends=this&&this.__extends||function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(); +/** +* @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 +*/ +/** +* @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(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";function t(t){return"function"==typeof t}var e=!1,n={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){if(t){var n=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+n.stack)}else e&&console.log("RxJS: Back to a better error behavior. Thank you. <3");e=t},get useDeprecatedSynchronousErrorHandling(){return e}};function r(t){setTimeout(function(){throw t})}var i,o={closed:!0,next:function(t){},error:function(t){if(n.useDeprecatedSynchronousErrorHandling)throw t;r(t)},complete:function(){}},s=Array.isArray||function(t){return t&&"number"==typeof t.length},c={e:{}};function u(){try{return i.apply(this,arguments)}catch(t){return c.e=t,c}}function h(t){return i=t,u}var l=function(t){function e(n){var r=t.call(this,n?n.length+" errors occurred during unsubscription:\n "+n.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"")||this;return r.errors=n,r.name="UnsubscriptionError",Object.setPrototypeOf(r,e.prototype),r}return __extends(e,t),e}(Error),a=function(){function e(t){this.closed=!1,this._parent=null,this._parents=null,this._subscriptions=null,t&&(this._unsubscribe=t)}return e.prototype.unsubscribe=function(){var e,n=!1;if(!this.closed){var r=this._parent,i=this._parents,o=this._unsubscribe,u=this._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var a,f=-1,d=i?i.length:0;r;)r.remove(this),r=++f1)this.connection=null;else{var n=this.connection,r=t._connection;this.connection=null,!r||n&&r!==n||r.unsubscribe()}}else this.connection=null},e}(d),m=(function(t){function e(e,n){var r=t.call(this)||this;return r.source=e,r.subjectFactory=n,r._refCount=0,r._isComplete=!1,r}__extends(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a).add(this.source.subscribe(new m(this.getSubject(),this))),t.closed?(this._connection=null,t=a.EMPTY):this._connection=t),t},e.prototype.refCount=function(){return function t(){return function t(e){return e.lift(new x(e))}}()(this)}}(w),function(t){function e(e,n){var r=t.call(this,e)||this;return r.connectable=n,r}return __extends(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(S)),T=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r.pending=!1,r}return __extends(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var n=this.id,r=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(r,n,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(r,this.id,e),this},e.prototype.requestAsyncId=function(t,e,n){return void 0===n&&(n=0),setInterval(t.flush.bind(t,this),n)},e.prototype.recycleAsyncId=function(t,e,n){if(void 0===n&&(n=0),null!==n&&this.delay===n&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(t,e);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var n=!1,r=void 0;try{this.work(t)}catch(t){n=!0,r=!!t&&t||new Error(t)}if(n)return this.unsubscribe(),r},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,n=e.actions,r=n.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==r&&n.splice(r,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,n){return t.call(this)||this}return __extends(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(a)),A=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return __extends(e,t),e.prototype.schedule=function(e,n){return void 0===n&&(n=0),n>0?t.prototype.schedule.call(this,e,n):(this.delay=n,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,n){return n>0||this.closed?t.prototype.execute.call(this,e,n):this._execute(e,n)},e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0?t.prototype.requestAsyncId.call(this,e,n,r):e.flush(this)},e}(T),j=function(){function t(e,n){void 0===n&&(n=t.now),this.SchedulerAction=e,this.now=n}return t.prototype.schedule=function(t,e,n){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(n,e)},t}();j.now=function(){return Date.now()};var D=function(t){function e(n,r){void 0===r&&(r=j.now);var i=t.call(this,n,function(){return e.delegate&&e.delegate!==i?e.delegate.now():r()})||this;return i.actions=[],i.active=!1,i.scheduled=void 0,i}return __extends(e,t),e.prototype.schedule=function(n,r,i){return void 0===r&&(r=0),e.delegate&&e.delegate!==this?e.delegate.schedule(n,r,i):t.prototype.schedule.call(this,n,r,i)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var n;this.active=!0;do{if(n=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,n){for(;t=e.shift();)t.unsubscribe();throw n}}},e}(j),I=(new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(D))(A),1),O={},P=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.scheduler=e,r.work=n,r}return __extends(e,t),e.prototype.requestAsyncId=function(e,n,r){return void 0===r&&(r=0),null!==r&&r>0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=(i=e.flush.bind(e,null),o=I++,O[o]=i,Promise.resolve().then(function(){return function t(e){var n=O[e];n&&n()}(o)}),o)));var i,o},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(delete O[n],e.scheduled=void 0)},e}(T),k=new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r0?t.prototype.requestAsyncId.call(this,e,n,r):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame(function(){return e.flush(null)})))},e.prototype.recycleAsyncId=function(e,n,r){if(void 0===r&&(r=0),null!==r&&r>0||null===r&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,n,r);0===e.actions.length&&(cancelAnimationFrame(n),e.scheduled=void 0)},e}(T);new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,n=this.actions,r=-1,i=n.length;t=t||n.shift();do{if(e=t.execute(t.state,t.delay))break}while(++r 1) { + this.connection = null; + return; + } + var connection = this.connection; + var sharedConnection = connectable._connection; + this.connection = null; + if (sharedConnection && (!connection || sharedConnection === connection)) { + sharedConnection.unsubscribe(); + } + }; + return RefCountSubscriber; + }(Subscriber)); + var ConnectableObservable = /** @class */ (function (_super) { + __extends(ConnectableObservable, _super); + function ConnectableObservable(source, subjectFactory) { + var _this = _super.call(this) || this; + _this.source = source; + _this.subjectFactory = subjectFactory; + _this._refCount = 0; + _this._isComplete = false; + return _this; + } + ConnectableObservable.prototype._subscribe = function (subscriber) { + return this.getSubject().subscribe(subscriber); + }; + ConnectableObservable.prototype.getSubject = function () { + var subject = this._subject; + if (!subject || subject.isStopped) { + this._subject = this.subjectFactory(); + } + return this._subject; + }; + ConnectableObservable.prototype.connect = function () { + var connection = this._connection; + if (!connection) { + this._isComplete = false; + connection = this._connection = new Subscription(); + connection.add(this.source + .subscribe(new ConnectableSubscriber(this.getSubject(), this))); + if (connection.closed) { + this._connection = null; + connection = Subscription.EMPTY; + } + else { + this._connection = connection; } } - }); + return connection; + }; + ConnectableObservable.prototype.refCount = function () { + return refCount()(this); + }; + return ConnectableObservable; + }(Observable)); + var connectableProto = ConnectableObservable.prototype; + var connectableObservableDescriptor = { + operator: { value: null }, + _refCount: { value: 0, writable: true }, + _subject: { value: null, writable: true }, + _connection: { value: null, writable: true }, + _subscribe: { value: connectableProto._subscribe }, + _isComplete: { value: connectableProto._isComplete, writable: true }, + getSubject: { value: connectableProto.getSubject }, + connect: { value: connectableProto.connect }, + refCount: { value: connectableProto.refCount } }; - var patchSubscriber = function () { - var next = rxjs.Subscriber.prototype.next; - var error = rxjs.Subscriber.prototype.error; - var complete = rxjs.Subscriber.prototype.complete; - Object.defineProperty(rxjs.Subscriber.prototype, 'destination', { - configurable: true, - get: function () { - return this._zoneDestination; - }, - set: function (destination) { - this._zone = Zone.current; - this._zoneDestination = destination; - } - }); - // patch Subscriber.next to make sure it run - // into SubscriptionZone - rxjs.Subscriber.prototype.next = function () { - var currentZone = Zone.current; - var subscriptionZone = this._zone; - // for performance concern, check Zone.current - // equal with this._zone(SubscriptionZone) or not - if (subscriptionZone && subscriptionZone !== currentZone) { - return subscriptionZone.run(next, this, arguments, nextSource); + var ConnectableSubscriber = /** @class */ (function (_super) { + __extends(ConnectableSubscriber, _super); + function ConnectableSubscriber(destination, connectable) { + var _this = _super.call(this, destination) || this; + _this.connectable = connectable; + return _this; + } + ConnectableSubscriber.prototype._error = function (err) { + this._unsubscribe(); + _super.prototype._error.call(this, err); + }; + ConnectableSubscriber.prototype._complete = function () { + this.connectable._isComplete = true; + this._unsubscribe(); + _super.prototype._complete.call(this); + }; + ConnectableSubscriber.prototype._unsubscribe = function () { + var connectable = this.connectable; + if (connectable) { + this.connectable = null; + var connection = connectable._connection; + connectable._refCount = 0; + connectable._subject = null; + connectable._connection = null; + if (connection) { + connection.unsubscribe(); + } } - else { - return next.apply(this, arguments); + }; + return ConnectableSubscriber; + }(SubjectSubscriber)); + var Action = /** @class */ (function (_super) { + __extends(Action, _super); + function Action(scheduler, work) { + return _super.call(this) || this; + } + Action.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + return this; + }; + return Action; + }(Subscription)); + var AsyncAction = /** @class */ (function (_super) { + __extends(AsyncAction, _super); + function AsyncAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + _this.pending = false; + return _this; + } + AsyncAction.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + if (this.closed) { + return this; + } + this.state = state; + var id = this.id; + var scheduler = this.scheduler; + if (id != null) { + this.id = this.recycleAsyncId(scheduler, id, delay); + } + this.pending = true; + this.delay = delay; + this.id = this.id || this.requestAsyncId(scheduler, this.id, delay); + return this; + }; + AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + return setInterval(scheduler.flush.bind(scheduler, this), delay); + }; + AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if (delay !== null && this.delay === delay && this.pending === false) { + return id; } + return clearInterval(id) && undefined || undefined; }; - rxjs.Subscriber.prototype.error = function () { - var currentZone = Zone.current; - var subscriptionZone = this._zone; - // for performance concern, check Zone.current - // equal with this._zone(SubscriptionZone) or not - if (subscriptionZone && subscriptionZone !== currentZone) { - return subscriptionZone.run(error, this, arguments, errorSource); + AsyncAction.prototype.execute = function (state, delay) { + if (this.closed) { + return new Error('executing a cancelled action'); } - else { - return error.apply(this, arguments); + this.pending = false; + var error = this._execute(state, delay); + if (error) { + return error; + } + else if (this.pending === false && this.id != null) { + this.id = this.recycleAsyncId(this.scheduler, this.id, null); } }; - rxjs.Subscriber.prototype.complete = function () { - var currentZone = Zone.current; - var subscriptionZone = this._zone; - // for performance concern, check Zone.current - // equal with this._zone(SubscriptionZone) or not - if (subscriptionZone && subscriptionZone !== currentZone) { - return subscriptionZone.run(complete, this, arguments, completeSource); + AsyncAction.prototype._execute = function (state, delay) { + var errored = false; + var errorValue = undefined; + try { + this.work(state); + } + catch (e) { + errored = true; + errorValue = !!e && e || new Error(e); + } + if (errored) { + this.unsubscribe(); + return errorValue; + } + }; + AsyncAction.prototype._unsubscribe = function () { + var id = this.id; + var scheduler = this.scheduler; + var actions = scheduler.actions; + var index = actions.indexOf(this); + this.work = null; + this.state = null; + this.pending = false; + this.scheduler = null; + if (index !== -1) { + actions.splice(index, 1); + } + if (id != null) { + this.id = this.recycleAsyncId(scheduler, id, null); + } + this.delay = null; + }; + return AsyncAction; + }(Action)); + var QueueAction = /** @class */ (function (_super) { + __extends(QueueAction, _super); + function QueueAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + QueueAction.prototype.schedule = function (state, delay) { + if (delay === void 0) { delay = 0; } + if (delay > 0) { + return _super.prototype.schedule.call(this, state, delay); + } + this.delay = delay; + this.state = state; + this.scheduler.flush(this); + return this; + }; + QueueAction.prototype.execute = function (state, delay) { + return (delay > 0 || this.closed) ? + _super.prototype.execute.call(this, state, delay) : + this._execute(state, delay); + }; + QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + return scheduler.flush(this); + }; + return QueueAction; + }(AsyncAction)); + var Scheduler = /** @class */ (function () { + function Scheduler(SchedulerAction, now) { + if (now === void 0) { now = Scheduler.now; } + this.SchedulerAction = SchedulerAction; + this.now = now; + } + Scheduler.prototype.schedule = function (work, delay, state) { + if (delay === void 0) { delay = 0; } + return new this.SchedulerAction(this, work).schedule(state, delay); + }; + return Scheduler; + }()); + Scheduler.now = function () { return Date.now(); }; + var AsyncScheduler = /** @class */ (function (_super) { + __extends(AsyncScheduler, _super); + function AsyncScheduler(SchedulerAction, now) { + if (now === void 0) { now = Scheduler.now; } + var _this = _super.call(this, SchedulerAction, function () { + if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) { + return AsyncScheduler.delegate.now(); + } + else { + return now(); + } + }) || this; + _this.actions = []; + _this.active = false; + _this.scheduled = undefined; + return _this; + } + AsyncScheduler.prototype.schedule = function (work, delay, state) { + if (delay === void 0) { delay = 0; } + if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) { + return AsyncScheduler.delegate.schedule(work, delay, state); } else { - return complete.call(this); + return _super.prototype.schedule.call(this, work, delay, state); + } + }; + AsyncScheduler.prototype.flush = function (action) { + var actions = this.actions; + if (this.active) { + actions.push(action); + return; + } + var error; + this.active = true; + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (action = actions.shift()); + this.active = false; + if (error) { + while (action = actions.shift()) { + action.unsubscribe(); + } + throw error; } }; + return AsyncScheduler; + }(Scheduler)); + var QueueScheduler = /** @class */ (function (_super) { + __extends(QueueScheduler, _super); + function QueueScheduler() { + return _super !== null && _super.apply(this, arguments) || this; + } + return QueueScheduler; + }(AsyncScheduler)); + var queue = new QueueScheduler(QueueAction); + var nextHandle = 1; + var tasksByHandle = {}; + function runIfPresent(handle) { + var cb = tasksByHandle[handle]; + if (cb) { + cb(); + } + } + var Immediate = { + setImmediate: function (cb) { + var handle = nextHandle++; + tasksByHandle[handle] = cb; + Promise.resolve().then(function () { return runIfPresent(handle); }); + return handle; + }, + clearImmediate: function (handle) { + delete tasksByHandle[handle]; + }, }; - patchObservable(); - patchSubscription(); - patchSubscriber(); -}); - -}))); + var AsapAction = /** @class */ (function (_super) { + __extends(AsapAction, _super); + function AsapAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if (delay !== null && delay > 0) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + scheduler.actions.push(this); + return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null))); + }; + AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); + } + if (scheduler.actions.length === 0) { + Immediate.clearImmediate(id); + scheduler.scheduled = undefined; + } + return undefined; + }; + return AsapAction; + }(AsyncAction)); + var AsapScheduler = /** @class */ (function (_super) { + __extends(AsapScheduler, _super); + function AsapScheduler() { + return _super !== null && _super.apply(this, arguments) || this; + } + AsapScheduler.prototype.flush = function (action) { + this.active = true; + this.scheduled = undefined; + var actions = this.actions; + var error; + var index = -1; + var count = actions.length; + action = action || actions.shift(); + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (++index < count && (action = actions.shift())); + this.active = false; + if (error) { + while (++index < count && (action = actions.shift())) { + action.unsubscribe(); + } + throw error; + } + }; + return AsapScheduler; + }(AsyncScheduler)); + var asap = new AsapScheduler(AsapAction); + var async = new AsyncScheduler(AsyncAction); + var AnimationFrameAction = /** @class */ (function (_super) { + __extends(AnimationFrameAction, _super); + function AnimationFrameAction(scheduler, work) { + var _this = _super.call(this, scheduler, work) || this; + _this.scheduler = scheduler; + _this.work = work; + return _this; + } + AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if (delay !== null && delay > 0) { + return _super.prototype.requestAsyncId.call(this, scheduler, id, delay); + } + scheduler.actions.push(this); + return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); })); + }; + AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) { + if (delay === void 0) { delay = 0; } + if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) { + return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay); + } + if (scheduler.actions.length === 0) { + cancelAnimationFrame(id); + scheduler.scheduled = undefined; + } + return undefined; + }; + return AnimationFrameAction; + }(AsyncAction)); + var AnimationFrameScheduler = /** @class */ (function (_super) { + __extends(AnimationFrameScheduler, _super); + function AnimationFrameScheduler() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationFrameScheduler.prototype.flush = function (action) { + this.active = true; + this.scheduled = undefined; + var actions = this.actions; + var error; + var index = -1; + var count = actions.length; + action = action || actions.shift(); + do { + if (error = action.execute(action.state, action.delay)) { + break; + } + } while (++index < count && (action = actions.shift())); + this.active = false; + if (error) { + while (++index < count && (action = actions.shift())) { + action.unsubscribe(); + } + throw error; + } + }; + return AnimationFrameScheduler; + }(AsyncScheduler)); + var animationFrame = new AnimationFrameScheduler(AnimationFrameAction); + /** + * @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.__load_patch('rxjs', function (global, Zone, api) { + var symbol = Zone.__symbol__; + var nextSource = 'rxjs.Subscriber.next'; + var errorSource = 'rxjs.Subscriber.error'; + var completeSource = 'rxjs.Subscriber.complete'; + var ObjectDefineProperties = Object.defineProperties; + var patchObservable = function () { + var ObservablePrototype = Observable.prototype; + var _symbolSubscribe = symbol('_subscribe'); + var _subscribe = ObservablePrototype[_symbolSubscribe] = ObservablePrototype._subscribe; + ObjectDefineProperties(Observable.prototype, { + _zone: { value: null, writable: true, configurable: true }, + _zoneSource: { value: null, writable: true, configurable: true }, + _zoneSubscribe: { value: null, writable: true, configurable: true }, + source: { + configurable: true, + get: function () { + return this._zoneSource; + }, + set: function (source) { + this._zone = Zone.current; + this._zoneSource = source; + } + }, + _subscribe: { + configurable: true, + get: function () { + if (this._zoneSubscribe) { + return this._zoneSubscribe; + } + else if (this.constructor === Observable) { + return _subscribe; + } + var proto = Object.getPrototypeOf(this); + return proto && proto._subscribe; + }, + set: function (subscribe) { + this._zone = Zone.current; + this._zoneSubscribe = function () { + if (this._zone && this._zone !== Zone.current) { + var tearDown_1 = this._zone.run(subscribe, this, arguments); + if (tearDown_1 && typeof tearDown_1 === 'function') { + var zone_1 = this._zone; + return function () { + if (zone_1 !== Zone.current) { + return zone_1.run(tearDown_1, this, arguments); + } + return tearDown_1.apply(this, arguments); + }; + } + return tearDown_1; + } + return subscribe.apply(this, arguments); + }; + } + }, + subjectFactory: { + get: function () { + return this._zoneSubjectFactory; + }, + set: function (factory) { + var zone = this._zone; + this._zoneSubjectFactory = function () { + if (zone && zone !== Zone.current) { + return zone.run(factory, this, arguments); + } + return factory.apply(this, arguments); + }; + } + } + }); + }; + api.patchMethod(Observable.prototype, 'lift', function (delegate) { return function (self, args) { + var observable = delegate.apply(self, args); + if (observable.operator) { + observable.operator._zone = Zone.current; + api.patchMethod(observable.operator, 'call', function (operatorDelegate) { return function (operatorSelf, operatorArgs) { + if (operatorSelf._zone && operatorSelf._zone !== Zone.current) { + return operatorSelf._zone.run(operatorDelegate, operatorSelf, operatorArgs); + } + return operatorDelegate.apply(operatorSelf, operatorArgs); + }; }); + } + return observable; + }; }); + var patchSubscription = function () { + ObjectDefineProperties(Subscription.prototype, { + _zone: { value: null, writable: true, configurable: true }, + _zoneUnsubscribe: { value: null, writable: true, configurable: true }, + _unsubscribe: { + get: function () { + if (this._zoneUnsubscribe) { + return this._zoneUnsubscribe; + } + var proto = Object.getPrototypeOf(this); + return proto && proto._unsubscribe; + }, + set: function (unsubscribe) { + this._zone = Zone.current; + this._zoneUnsubscribe = function () { + if (this._zone && this._zone !== Zone.current) { + return this._zone.run(unsubscribe, this, arguments); + } + return unsubscribe.apply(this, arguments); + }; + } + } + }); + }; + var patchSubscriber = function () { + var next = Subscriber.prototype.next; + var error = Subscriber.prototype.error; + var complete = Subscriber.prototype.complete; + Object.defineProperty(Subscriber.prototype, 'destination', { + configurable: true, + get: function () { + return this._zoneDestination; + }, + set: function (destination) { + this._zone = Zone.current; + this._zoneDestination = destination; + } + }); + // patch Subscriber.next to make sure it run + // into SubscriptionZone + Subscriber.prototype.next = function () { + var currentZone = Zone.current; + var subscriptionZone = this._zone; + // for performance concern, check Zone.current + // equal with this._zone(SubscriptionZone) or not + if (subscriptionZone && subscriptionZone !== currentZone) { + return subscriptionZone.run(next, this, arguments, nextSource); + } + else { + return next.apply(this, arguments); + } + }; + Subscriber.prototype.error = function () { + var currentZone = Zone.current; + var subscriptionZone = this._zone; + // for performance concern, check Zone.current + // equal with this._zone(SubscriptionZone) or not + if (subscriptionZone && subscriptionZone !== currentZone) { + return subscriptionZone.run(error, this, arguments, errorSource); + } + else { + return error.apply(this, arguments); + } + }; + Subscriber.prototype.complete = function () { + var currentZone = Zone.current; + var subscriptionZone = this._zone; + // for performance concern, check Zone.current + // equal with this._zone(SubscriptionZone) or not + if (subscriptionZone && subscriptionZone !== currentZone) { + return subscriptionZone.run(complete, this, arguments, completeSource); + } + else { + return complete.call(this); + } + }; + }; + patchObservable(); + patchSubscription(); + patchSubscriber(); + }); +})); +//# sourceMappingURL=zone-patch-rxjs-rollup.umd.js.map diff --git a/dist/zone-patch-rxjs.min.js b/dist/zone-patch-rxjs.min.js old mode 100644 new mode 100755 index 1c13f8a08..dc21f5d27 --- a/dist/zone-patch-rxjs.min.js +++ b/dist/zone-patch-rxjs.min.js @@ -1 +1,24 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("rxjs")):"function"==typeof define&&define.amd?define(["rxjs"],t):t(e.rxjs)}(this,function(e){"use strict";Zone.__load_patch("rxjs",function(t,r,n){var o=r.__symbol__,i=Object.defineProperties;n.patchMethod(e.Observable.prototype,"lift",function(e){return function(t,o){var i=e.apply(t,o);return i.operator&&(i.operator._zone=r.current,n.patchMethod(i.operator,"call",function(e){return function(t,n){return t._zone&&t._zone!==r.current?t._zone.run(e,t,n):e.apply(t,n)}})),i}});var u,s,c,b,a;u=e.Observable.prototype,s=u[o("_subscribe")]=u._subscribe,i(e.Observable.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneSource:{value:null,writable:!0,configurable:!0},_zoneSubscribe:{value:null,writable:!0,configurable:!0},source:{configurable:!0,get:function(){return this._zoneSource},set:function(e){this._zone=r.current,this._zoneSource=e}},_subscribe:{configurable:!0,get:function(){if(this._zoneSubscribe)return this._zoneSubscribe;if(this.constructor===e.Observable)return s;var t=Object.getPrototypeOf(this);return t&&t._subscribe},set:function(e){this._zone=r.current,this._zoneSubscribe=function(){if(this._zone&&this._zone!==r.current){var t=this._zone.run(e,this,arguments);if(t&&"function"==typeof t){var n=this._zone;return function(){return n!==r.current?n.run(t,this,arguments):t.apply(this,arguments)}}return t}return e.apply(this,arguments)}}},subjectFactory:{get:function(){return this._zoneSubjectFactory},set:function(e){var t=this._zone;this._zoneSubjectFactory=function(){return t&&t!==r.current?t.run(e,this,arguments):e.apply(this,arguments)}}}}),i(e.Subscription.prototype,{_zone:{value:null,writable:!0,configurable:!0},_zoneUnsubscribe:{value:null,writable:!0,configurable:!0},_unsubscribe:{get:function(){if(this._zoneUnsubscribe)return this._zoneUnsubscribe;var e=Object.getPrototypeOf(this);return e&&e._unsubscribe},set:function(e){this._zone=r.current,this._zoneUnsubscribe=function(){return this._zone&&this._zone!==r.current?this._zone.run(e,this,arguments):e.apply(this,arguments)}}}}),c=e.Subscriber.prototype.next,b=e.Subscriber.prototype.error,a=e.Subscriber.prototype.complete,Object.defineProperty(e.Subscriber.prototype,"destination",{configurable:!0,get:function(){return this._zoneDestination},set:function(e){this._zone=r.current,this._zoneDestination=e}}),e.Subscriber.prototype.next=function(){var e=r.current,t=this._zone;return t&&t!==e?t.run(c,this,arguments,"rxjs.Subscriber.next"):c.apply(this,arguments)},e.Subscriber.prototype.error=function(){var e=r.current,t=this._zone;return t&&t!==e?t.run(b,this,arguments,"rxjs.Subscriber.error"):b.apply(this,arguments)},e.Subscriber.prototype.complete=function(){var e=r.current,t=this._zone;return t&&t!==e?t.run(a,this,arguments,"rxjs.Subscriber.complete"):a.call(this)}})}); \ No newline at end of file +var __extends=this&&this.__extends||function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(); +/** +* @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 +*/ +/** +* @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(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";function t(t){return"function"==typeof t}var e=!1,r={Promise:void 0,set useDeprecatedSynchronousErrorHandling(t){if(t){var r=new Error;console.warn("DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n"+r.stack)}else e&&console.log("RxJS: Back to a better error behavior. Thank you. <3");e=t},get useDeprecatedSynchronousErrorHandling(){return e}};function n(t){setTimeout(function(){throw t})}var i,o={closed:!0,next:function(t){},error:function(t){if(r.useDeprecatedSynchronousErrorHandling)throw t;n(t)},complete:function(){}},s=Array.isArray||function(t){return t&&"number"==typeof t.length},u={e:{}};function c(){try{return i.apply(this,arguments)}catch(t){return u.e=t,u}}function h(t){return i=t,c}var l=function(t){function e(r){var n=t.call(this,r?r.length+" errors occurred during unsubscription:\n "+r.map(function(t,e){return e+1+") "+t.toString()}).join("\n "):"")||this;return n.errors=r,n.name="UnsubscriptionError",Object.setPrototypeOf(n,e.prototype),n}return __extends(e,t),e}(Error),a=function(){function e(t){this.closed=!1,this._parent=null,this._parents=null,this._subscriptions=null,t&&(this._unsubscribe=t)}return e.prototype.unsubscribe=function(){var e,r=!1;if(!this.closed){var n=this._parent,i=this._parents,o=this._unsubscribe,c=this._subscriptions;this.closed=!0,this._parent=null,this._parents=null,this._subscriptions=null;for(var a,f=-1,b=i?i.length:0;n;)n.remove(this),n=++f1)this.connection=null;else{var r=this.connection,n=t._connection;this.connection=null,!n||r&&n!==r||n.unsubscribe()}}else this.connection=null},e}(b),m=(function(t){function e(e,r){var n=t.call(this)||this;return n.source=e,n.subjectFactory=r,n._refCount=0,n._isComplete=!1,n}__extends(e,t),e.prototype._subscribe=function(t){return this.getSubject().subscribe(t)},e.prototype.getSubject=function(){var t=this._subject;return t&&!t.isStopped||(this._subject=this.subjectFactory()),this._subject},e.prototype.connect=function(){var t=this._connection;return t||(this._isComplete=!1,(t=this._connection=new a).add(this.source.subscribe(new m(this.getSubject(),this))),t.closed?(this._connection=null,t=a.EMPTY):this._connection=t),t},e.prototype.refCount=function(){return function t(){return function t(e){return e.lift(new x(e))}}()(this)}}(w),function(t){function e(e,r){var n=t.call(this,e)||this;return n.connectable=r,n}return __extends(e,t),e.prototype._error=function(e){this._unsubscribe(),t.prototype._error.call(this,e)},e.prototype._complete=function(){this.connectable._isComplete=!0,this._unsubscribe(),t.prototype._complete.call(this)},e.prototype._unsubscribe=function(){var t=this.connectable;if(t){this.connectable=null;var e=t._connection;t._refCount=0,t._subject=null,t._connection=null,e&&e.unsubscribe()}},e}(g)),z=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n.pending=!1,n}return __extends(e,t),e.prototype.schedule=function(t,e){if(void 0===e&&(e=0),this.closed)return this;this.state=t;var r=this.id,n=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(n,r,e)),this.pending=!0,this.delay=e,this.id=this.id||this.requestAsyncId(n,this.id,e),this},e.prototype.requestAsyncId=function(t,e,r){return void 0===r&&(r=0),setInterval(t.flush.bind(t,this),r)},e.prototype.recycleAsyncId=function(t,e,r){if(void 0===r&&(r=0),null!==r&&this.delay===r&&!1===this.pending)return e;clearInterval(e)},e.prototype.execute=function(t,e){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,e);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,e){var r=!1,n=void 0;try{this.work(t)}catch(t){r=!0,n=!!t&&t||new Error(t)}if(r)return this.unsubscribe(),n},e.prototype._unsubscribe=function(){var t=this.id,e=this.scheduler,r=e.actions,n=r.indexOf(this);this.work=null,this.state=null,this.pending=!1,this.scheduler=null,-1!==n&&r.splice(n,1),null!=t&&(this.id=this.recycleAsyncId(e,t,null)),this.delay=null},e}(function(t){function e(e,r){return t.call(this)||this}return __extends(e,t),e.prototype.schedule=function(t,e){return void 0===e&&(e=0),this},e}(a)),j=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return __extends(e,t),e.prototype.schedule=function(e,r){return void 0===r&&(r=0),r>0?t.prototype.schedule.call(this,e,r):(this.delay=r,this.state=e,this.scheduler.flush(this),this)},e.prototype.execute=function(e,r){return r>0||this.closed?t.prototype.execute.call(this,e,r):this._execute(e,r)},e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0?t.prototype.requestAsyncId.call(this,e,r,n):e.flush(this)},e}(z),T=function(){function t(e,r){void 0===r&&(r=t.now),this.SchedulerAction=e,this.now=r}return t.prototype.schedule=function(t,e,r){return void 0===e&&(e=0),new this.SchedulerAction(this,t).schedule(r,e)},t}();T.now=function(){return Date.now()};var A=function(t){function e(r,n){void 0===n&&(n=T.now);var i=t.call(this,r,function(){return e.delegate&&e.delegate!==i?e.delegate.now():n()})||this;return i.actions=[],i.active=!1,i.scheduled=void 0,i}return __extends(e,t),e.prototype.schedule=function(r,n,i){return void 0===n&&(n=0),e.delegate&&e.delegate!==this?e.delegate.schedule(r,n,i):t.prototype.schedule.call(this,r,n,i)},e.prototype.flush=function(t){var e=this.actions;if(this.active)e.push(t);else{var r;this.active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=e.shift());if(this.active=!1,r){for(;t=e.shift();)t.unsubscribe();throw r}}},e}(T),O=(new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(A))(j),1),P={},I=function(t){function e(e,r){var n=t.call(this,e,r)||this;return n.scheduler=e,n.work=r,n}return __extends(e,t),e.prototype.requestAsyncId=function(e,r,n){return void 0===n&&(n=0),null!==n&&n>0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e.scheduled||(e.scheduled=(i=e.flush.bind(e,null),o=O++,P[o]=i,Promise.resolve().then(function(){return function t(e){var r=P[e];r&&r()}(o)}),o)));var i,o},e.prototype.recycleAsyncId=function(e,r,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);0===e.actions.length&&(delete P[r],e.scheduled=void 0)},e}(z),D=(new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,n=-1,i=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++n0?t.prototype.requestAsyncId.call(this,e,r,n):(e.actions.push(this),e.scheduled||(e.scheduled=requestAnimationFrame(function(){return e.flush(null)})))},e.prototype.recycleAsyncId=function(e,r,n){if(void 0===n&&(n=0),null!==n&&n>0||null===n&&this.delay>0)return t.prototype.recycleAsyncId.call(this,e,r,n);0===e.actions.length&&(cancelAnimationFrame(r),e.scheduled=void 0)},e}(z));new(function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.flush=function(t){this.active=!0,this.scheduled=void 0;var e,r=this.actions,n=-1,i=r.length;t=t||r.shift();do{if(e=t.execute(t.state,t.delay))break}while(++n'; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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) { + var performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + var symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + var checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } - Zone.assertZonePatched = function () { - if (global['Promise'] !== patches['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.)'); + var Zone = /** @class */ (function () { + function Zone(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); } - }; - Object.defineProperty(Zone, "root", { - get: function () { - var zone = Zone.current; - while (zone.parent) { - zone = zone.parent; + Zone.assertZonePatched = function () { + if (global['Promise'] !== patches['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.)'); } - return zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "current", { - get: function () { - return _currentZoneFrame.zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "currentTask", { - get: function () { - return _currentTask; - }, - enumerable: true, - configurable: true - }); - Zone.__load_patch = function (name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); + }; + Object.defineProperty(Zone, "root", { + get: function () { + var zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "current", { + get: function () { + return _currentZoneFrame.zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "currentTask", { + get: function () { + return _currentTask; + }, + enumerable: true, + configurable: true + }); + Zone.__load_patch = function (name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } - } - else if (!global['__Zone_disable_' + name]) { - var perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - }; - Object.defineProperty(Zone.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Zone.prototype.get = function (key) { - var zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - }; - Zone.prototype.getZoneWith = function (key) { - var current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; + else if (!global['__Zone_disable_' + name]) { + var perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); } - current = current._parent; - } - return null; - }; - Zone.prototype.fork = function (zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - }; - Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - var _callback = this._zoneDelegate.intercept(this, callback, source); - var zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); }; - }; - Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = null; } - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { + Object.defineProperty(Zone.prototype, "parent", { + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Zone.prototype.get = function (key) { + var zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + }; + Zone.prototype.getZoneWith = function (key) { + var current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + }; + Zone.prototype.fork = function (zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + }; + Zone.prototype.wrap = function (callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + var _callback = this._zoneDelegate.intercept(this, callback, source); + var zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + }; + Zone.prototype.run = function (callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { + if (applyThis === void 0) { applyThis = null; } + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runTask = function (task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - var reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - var previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runTask = function (task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; } + var reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + var previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + }; + Zone.prototype.scheduleTask = function (task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + var newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + var zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + }; + Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + }; + Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.cancelTask = function (task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + }; + Zone.prototype._updateTaskCount = function (task, count) { + var zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (var i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + }; + return Zone; + }()); + Zone.__symbol__ = __symbol__; + var DELEGATE_ZS = { + name: '', + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, + onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } + }; + var ZoneDelegate = /** @class */ (function () { + function ZoneDelegate(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; } } } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); + ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + }; + ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + }; + ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.handleError = function (targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + }; + ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { + var returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); } else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); + throw new Error('Task is missing scheduleFn.'); } } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - }; - Zone.prototype.scheduleTask = function (task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - var newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); - } - newZone = newZone.parent; - } - } - task._transitionTo(scheduling, notScheduled); - var zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - }; - Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - }; - Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.cancelTask = function (task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - }; - Zone.prototype._updateTaskCount = function (task, count) { - var zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (var i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); + return returnTask; + }; + ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.cancelTask = function (targetZone, task) { + var value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + } + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); + } + return value; + }; + ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + }; + ZoneDelegate.prototype._updateTaskCount = function (type, count) { + var counts = this._taskCounts; + var prev = counts[type]; + var next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + var isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + }; + return ZoneDelegate; + }()); + var ZoneTask = /** @class */ (function () { + function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + var self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; + } } - }; - Zone.__symbol__ = __symbol__; - return Zone; - }()); - var DELEGATE_ZS = { - name: '', - onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, - onScheduleTask: function (delegate, _, target, task) { - return delegate.scheduleTask(target, task); - }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { - return delegate.invokeTask(target, task, applyThis, applyArgs); - }, - onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } - }; - var ZoneDelegate = /** @class */ (function () { - function ZoneDelegate(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; + ZoneTask.invokeTask = function (task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + }; + Object.defineProperty(ZoneTask.prototype, "zone", { + get: function () { + return this._zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ZoneTask.prototype, "state", { + get: function () { + return this._state; + }, + enumerable: true, + configurable: true + }); + ZoneTask.prototype.cancelScheduleRequest = function () { + this._transitionTo(notScheduled, scheduling); + }; + ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); + } + }; + ZoneTask.prototype.toString = function () { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + }; + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + ZoneTask.prototype.toJSON = function () { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + }; + return ZoneTask; + }()); + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var symbolSetTimeout = __symbol__('setTimeout'); + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var _microTaskQueue = []; + var _isDrainingMicrotaskQueue = false; + var nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); } } + task && _microTaskQueue.push(task); } - ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - }; - ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; - }; - ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.handleError = function (targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - }; - ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { - var returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + var queue = _microTaskQueue; + _microTaskQueue = []; + for (var i = 0; i < queue.length; i++) { + var task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; - } - else { - if (task.scheduleFn) { - task.scheduleFn(task); + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var NO_ZONE = { name: 'NO ZONE' }; + var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + var patches = {}; + var _api = { + symbol: __symbol__, + currentZoneFrame: function () { return _currentZoneFrame; }, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, + patchEventTarget: function () { return []; }, + patchOnProperties: noop, + patchMethod: function () { return noop; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, + setNativePromise: function (NativePromise) { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); } - else if (task.type == microTask) { - scheduleMicroTask(task); + }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } + }; + var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + var _currentTask = null; + var _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); + /** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + var className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + var __symbol__ = api.symbol; + var _uncaughtPromiseErrors = []; + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var creationTrace = '__creationTrace__'; + api.onUnhandledError = function (e) { + if (api.showUncaughtError()) { + var rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); } else { - throw new Error('Task is missing scheduleFn.'); + console.error(e); } } - return returnTask; }; - ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.cancelTask = function (targetZone, task) { - var value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); + api.microtaskDrainDone = function () { + while (_uncaughtPromiseErrors.length) { + var _loop_1 = function () { + var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(function () { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + }; + while (_uncaughtPromiseErrors.length) { + _loop_1(); } - value = task.cancelFn(task); } - return value; }; - ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback + var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } } catch (err) { - this.handleError(targetZone, err); } - }; - ZoneDelegate.prototype._updateTaskCount = function (type, count) { - var counts = this._taskCounts; - var prev = counts[type]; - var next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - var isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type + } + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + var symbolState = __symbol__('state'); + var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); + var source = 'Promise.then'; + var UNRESOLVED = null; + var RESOLVED = true; + var REJECTED = false; + var REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return function (v) { + try { + resolvePromise(promise, state, v); + } + catch (err) { + resolvePromise(promise, false, err); + } + // Do not return value or you will break the Promise spec. + }; + } + var once = function () { + var wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); }; - this.hasTask(this.zone, isEmpty); - } + }; }; - return ZoneDelegate; - }()); - var ZoneTask = /** @class */ (function () { - function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - var self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; - } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); - }; - } - } - ZoneTask.invokeTask = function (task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); + var TYPE_ERROR = 'Promise resolved with itself'; + var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + var onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + var then = null; + try { + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } } - _numberOfNestedTaskFrames--; - } - }; - Object.defineProperty(ZoneTask.prototype, "zone", { - get: function () { - return this._zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ZoneTask.prototype, "state", { - get: function () { - return this._state; - }, - enumerable: true, - configurable: true - }); - ZoneTask.prototype.cancelScheduleRequest = function () { - this._transitionTo(notScheduled, scheduling); - }; - ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; + catch (err) { + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + return promise; } - } - else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); - } - }; - ZoneTask.prototype.toString = function () { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); - } - }; - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - ZoneTask.prototype.toJSON = function () { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount - }; - }; - return ZoneTask; - }()); - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var symbolSetTimeout = __symbol__('setTimeout'); - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var _microTaskQueue = []; - var _isDrainingMicrotaskQueue = false; - var nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); - } - } - if (nativeMicroTaskQueuePromise) { - var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); - } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - var queue = _microTaskQueue; - _microTaskQueue = []; - for (var i = 0; i < queue.length; i++) { - var task = queue[i]; + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { try { - task.zone.runTask(task, null, null); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } - catch (error) { - _api.onUnhandledError(error); + catch (err) { + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + var queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + var trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (var i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + var error_1 = err; + error_1.rejection = value; + error_1.promise = promise; + error_1.zone = Zone.current; + error_1.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error_1); + api.scheduleMicroTask(); // to make sure that it is running + } } } } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var NO_ZONE = { name: 'NO ZONE' }; - var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - var patches = {}; - var _api = { - symbol: __symbol__, - currentZoneFrame: function () { return _currentZoneFrame; }, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, - patchEventTarget: function () { return []; }, - patchOnProperties: noop, - patchMethod: function () { return noop; }, - bindArguments: function () { return []; }, - patchThen: function () { return noop; }, - patchMacroTask: function () { return noop; }, - setNativePromise: function (NativePromise) { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: function () { return noop; }, - isIEOrEdge: function () { return false; }, - getGlobalObjects: function () { return undefined; }, - ObjectDefineProperty: function () { return noop; }, - ObjectGetOwnPropertyDescriptor: function () { return undefined; }, - ObjectCreate: function () { return undefined; }, - ArraySlice: function () { return []; }, - patchClass: function () { return noop; }, - wrapWithCurrentZone: function () { return noop; }, - filterProperties: function () { return []; }, - attachOriginToPatched: function () { return noop; }, - _redefineProperty: function () { return noop; }, - patchCallbacks: function () { return noop; } - }; - var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - var _currentTask = null; - var _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { - var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - var className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); + // Resolving an already resolved promise is a noop. + return promise; } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - var __symbol__ = api.symbol; - var _uncaughtPromiseErrors = []; - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var creationTrace = '__creationTrace__'; - api.onUnhandledError = function (e) { - if (api.showUncaughtError()) { - var rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); - } - else { - console.error(e); + var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + var handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } + } + catch (err) { + } + promise[symbolState] = REJECTED; + for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } + } } } - }; - api.microtaskDrainDone = function () { - while (_uncaughtPromiseErrors.length) { - var _loop_1 = function () { - var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + var promiseState = promise[symbolState]; + var delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, function () { try { - uncaughtPromiseError.zone.runGuarded(function () { - throw uncaughtPromiseError; - }); + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); } catch (error) { - handleUnhandledRejection(error); + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); } - }; - while (_uncaughtPromiseErrors.length) { - _loop_1(); - } - } - }; - var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); - } - } - catch (err) { + }, chainPromise); } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - var symbolState = __symbol__('state'); - var symbolValue = __symbol__('value'); - var symbolFinally = __symbol__('finally'); - var symbolParentPromiseValue = __symbol__('parentPromiseValue'); - var symbolParentPromiseState = __symbol__('parentPromiseState'); - var source = 'Promise.then'; - var UNRESOLVED = null; - var RESOLVED = true; - var REJECTED = false; - var REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return function (v) { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); + var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + var ZoneAwarePromise = /** @class */ (function () { + function ZoneAwarePromise(executor) { + var promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } } - // Do not return value or you will break the Promise spec. - }; - } - var once = function () { - var wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; + ZoneAwarePromise.toString = function () { + return ZONE_AWARE_PROMISE_TO_STRING; + }; + ZoneAwarePromise.resolve = function (value) { + return resolvePromise(new this(null), RESOLVED, value); + }; + ZoneAwarePromise.reject = function (error) { + return resolvePromise(new this(null), REJECTED, error); + }; + ZoneAwarePromise.race = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); + } + value.then(onResolve, onReject); } - wasCalled = true; - wrappedFunction.apply(null, arguments); + return promise; }; - }; - }; - var TYPE_ERROR = 'Promise resolved with itself'; - var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - var onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); - } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - var then = null; - try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; + ZoneAwarePromise.all = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; + var resolvedValues = []; + var _loop_2 = function (value) { + if (!isThenable(value)) { + value = this_1.resolve(value); + } + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + _loop_2(value); + } + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); } - } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); - } - else if (state !== REJECTED && typeof then === 'function') { - try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true + }); + ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { + var chainPromise = new this.constructor(null); + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); } - } - else { - promise[symbolState] = state; - var queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; - } - } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - var trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); - } - } - for (var i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); - } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; - try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); - } - catch (err) { - var error_1 = err; - error_1.rejection = value; - error_1.promise = promise; - error_1.zone = Zone.current; - error_1.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error_1); - api.scheduleMicroTask(); // to make sure that it is running + return chainPromise; + }; + ZoneAwarePromise.prototype.catch = function (onRejected) { + return this.then(null, onRejected); + }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + }; + return ZoneAwarePromise; + }()); + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + var NativePromise = global[symbolPromise] = global['Promise']; + var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); } + api.setNativePromise(NewNativePromise); } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + var symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; } + var originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + var _this = this; + var wrapped = new ZoneAwarePromise(function (resolve, reject) { + originalThen.call(_this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; } - // Resolving an already resolved promise is a noop. - return promise; - } - var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; } - } - catch (err) { - } - promise[symbolState] = REJECTED; - for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); } + return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); } } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); + /** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + var ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + var ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Object.create */ + var ObjectCreate = Object.create; + /** Array.prototype.slice */ + var ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + var ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + var TRUE_STR = 'true'; + /** false string const */ + var FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + var ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - var promiseState = promise[symbolState]; - var delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, function () { - try { - var parentPromiseValue = promise[symbolValue]; - var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); - } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); - } - }, chainPromise); + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); } - var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = /** @class */ (function () { - function ZoneAwarePromise(executor) { - var promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); - } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); - } - catch (error) { - resolvePromise(promise, false, error); - } - } - ZoneAwarePromise.toString = function () { - return ZONE_AWARE_PROMISE_TO_STRING; - }; - ZoneAwarePromise.resolve = function (value) { - return resolvePromise(new this(null), RESOLVED, value); - }; - ZoneAwarePromise.reject = function (error) { - return resolvePromise(new this(null), REJECTED, error); - }; - ZoneAwarePromise.race = function (values) { - var e_1, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); - } - function onReject(error) { - reject(error); - } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); - } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); - } - finally { if (e_1) throw e_1.error; } + var zoneSymbol = Zone.__symbol__; + var isWindowExists = typeof window !== 'undefined'; + var internalWindow = isWindowExists ? window : undefined; + var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + var REMOVE_ATTRIBUTE = 'removeAttribute'; + var NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; + } + function patchPrototype(prototype, fnNames) { + var source = prototype.constructor['name']; + var _loop_3 = function (i) { + var name_1 = fnNames[i]; + var delegate = prototype[name_1]; + if (delegate) { + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); + if (!isPropertyWritable(prototypeDesc)) { + return "continue"; + } + prototype[name_1] = (function (delegate) { + var patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); } - return promise; }; - ZoneAwarePromise.all = function (values) { - var e_2, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - var unresolvedCount = 2; - var valueIndex = 0; - var resolvedValues = []; - var _loop_2 = function (value) { - if (!isThenable(value)) { - value = this_1.resolve(value); - } - var curValueIndex = valueIndex; - value.then(function (value) { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; - }; - var this_1 = this; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - _loop_2(value); - } + for (var i = 0; i < fnNames.length; i++) { + _loop_3(i); + } + } + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; + } + if (propertyDesc.writable === false) { + return false; + } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); + } + var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + var zoneSymbolEventNames = {}; + var wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + var eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + } + var target = this || event.target || _global; + var listener = target[eventNameSymbol]; + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); - } - finally { if (e_2) throw e_2.error; } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); + } + return result; + }; + function patchProperty(obj, prop, prototype) { + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; + } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + var originalDescGet = desc.get; + var originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; } - return promise; - }; - Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { - get: function () { - return 'Promise'; - }, - enumerable: true, - configurable: true - }); - ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { - var chainPromise = new this.constructor(null); - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + var previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); } - return chainPromise; - }; - ZoneAwarePromise.prototype.catch = function (onRejected) { - return this.then(null, onRejected); - }; - ZoneAwarePromise.prototype.finally = function (onFinally) { - var chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); } else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + target[eventNameSymbol] = null; } - return chainPromise; }; - return ZoneAwarePromise; - }()); - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - var NativePromise = global[symbolPromise] = global['Promise']; - var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; - } + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); + if (!target) { + return null; + } + var listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + var value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; + } } + return null; }; - ObjectDefineProperty(global, 'Promise', desc); + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } - global['Promise'] = ZoneAwarePromise; - var symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - var proto = Ctor.prototype; - var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case - return; + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (var i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } } - var originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - var _this = this; - var wrapped = new ZoneAwarePromise(function (resolve, reject) { - originalThen.call(_this, resolve, reject); - }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; - } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; + else { + var onProperties = []; + for (var prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); + } } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); + for (var j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); } - return resultPromise; - }; - } - if (NativePromise) { - patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global[api.symbol('fetch')] = fetch_1; - global['fetch'] = zoneify(fetch_1); - } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); - -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -var ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -var ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ -var ObjectCreate = Object.create; -/** Array.prototype.slice */ -var ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -var ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -var TRUE_STR = 'true'; -/** false string const */ -var FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -var zoneSymbol = Zone.__symbol__; -var isWindowExists = typeof window !== 'undefined'; -var internalWindow = isWindowExists ? window : undefined; -var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -var REMOVE_ATTRIBUTE = 'removeAttribute'; -var NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); - } - } - return args; -} -function patchPrototype(prototype, fnNames) { - var source = prototype.constructor['name']; - var _loop_1 = function (i) { - var name_1 = fnNames[i]; - var delegate = prototype[name_1]; - if (delegate) { - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); - if (!isPropertyWritable(prototypeDesc)) { - return "continue"; - } - prototype[name_1] = (function (delegate) { - var patched = function () { - return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); - }; - attachOriginToPatched(patched, delegate); - return patched; - })(delegate); - } - }; - for (var i = 0; i < fnNames.length; i++) { - _loop_1(i); - } -} -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -var zoneSymbolEventNames = {}; -var wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - var eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); - } - var target = this || event.target || _global; - var listener = target[eventNameSymbol]; - var result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - var errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); } } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); + var originalInstanceKey = zoneSymbol('originalInstance'); + // wrap some native API on `window` + function patchClass(className) { + var OriginalClass = _global[className]; + if (!OriginalClass) + return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + var a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); + } + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + var instance = new OriginalClass(function () { }); + var prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; + } + }); + } + }(prop)); } - } - return result; -}; -function patchProperty(obj, prop, prototype) { - var desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; + } } } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - var originalDescGet = desc.get; - var originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { return; } - var previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); - } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); - } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); - } - else { - target[eventNameSymbol] = null; - } - }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return null; - } - var listener = target[eventNameSymbol]; - if (listener) { - return listener; + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); + } + var shouldCopySymbolProperties = false; + function patchMethod(target, name, patchFn) { + var proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + var delegateName = zoneSymbol(name); + var delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + var patchDelegate_1 = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate_1(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); } - return value; - } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (var i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } - } - else { - var onProperties = []; - for (var prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); } } - for (var j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); - } + return delegate; } -} -var originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` -function patchClass(className) { - var OriginalClass = _global[className]; - if (!OriginalClass) - return; - // keep original class in global - _global[zoneSymbol(className)] = OriginalClass; - _global[className] = function () { - var a = bindArguments(arguments, className); - switch (a.length) { - case 0: - this[originalInstanceKey] = new OriginalClass(); - break; - case 1: - this[originalInstanceKey] = new OriginalClass(a[0]); - break; - case 2: - this[originalInstanceKey] = new OriginalClass(a[0], a[1]); - break; - case 3: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); - break; - case 4: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); - break; - default: - throw new Error('Arg list too long.'); + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; } - }; - // attach original delegate to patched function - attachOriginToPatched(_global[className], OriginalClass); - var instance = new OriginalClass(function () { }); - var prop; - for (prop in instance) { - // https://bugs.webkit.org/show_bug.cgi?id=44721 - if (className === 'XMLHttpRequest' && prop === 'responseBlob') - continue; - (function (prop) { - if (typeof instance[prop] === 'function') { - _global[className].prototype[prop] = function () { - return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); - }; + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { - ObjectDefineProperty(_global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); - // keep callback in wrapped function so we can - // use it in Function.prototype.toString to return - // the native one. - attachOriginToPatched(this[originalInstanceKey][prop], fn); - } - else { - this[originalInstanceKey][prop] = fn; - } - }, - get: function () { - return this[originalInstanceKey][prop]; - } - }); + // cause an error by calling it directly. + return delegate.apply(self, args); } - }(prop)); - } - for (prop in OriginalClass) { - if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { - _global[className][prop] = OriginalClass[prop]; - } - } -} -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; - } - var symbols = Object.getOwnPropertySymbols(src); - symbols.forEach(function (symbol) { - var desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; - } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -var shouldCopySymbolProperties = false; - -function patchMethod(target, name, patchFn) { - var proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); + }; }); } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; } - var delegateName = zoneSymbol(name); - var delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - var patchDelegate_1 = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate_1(this, arguments); - }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); + var isDetectedIEOrEdge = false; + var ieOrEdge = false; + function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; } } + catch (error) { + } + return false; } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; - } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + function isIEOrEdge() { + if (isDetectedIEOrEdge) { + return ieOrEdge; } - else { - // cause an error by calling it directly. - return delegate.apply(self, args); + isDetectedIEOrEdge = true; + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { + ieOrEdge = true; + } } - }; }); -} - -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} -var isDetectedIEOrEdge = false; -var ieOrEdge = false; -function isIE() { - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { - return true; + catch (error) { } - } - catch (error) { - } - return false; -} -function isIEOrEdge() { - if (isDetectedIEOrEdge) { return ieOrEdge; } - isDetectedIEOrEdge = true; - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { - ieOrEdge = true; - } - } - catch (error) { - } - return ieOrEdge; -} - -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', function (global) { - // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Function.prototype.toString; - var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - var PROMISE_SYMBOL = zoneSymbol('Promise'); - var ERROR_SYMBOL = zoneSymbol('Error'); - var newFunctionToString = function toString() { - if (typeof this === 'function') { - var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); + /** + * @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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', function (global) { + // patch Func.prototype.toString to let them look like native + var originalFunctionToString = Function.prototype.toString; + var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + var PROMISE_SYMBOL = zoneSymbol('Promise'); + var ERROR_SYMBOL = zoneSymbol('Error'); + var newFunctionToString = function toString() { + if (typeof this === 'function') { + var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } } - else { - return Object.prototype.toString.call(originalDelegate); + if (this === Promise) { + var nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } } - } - if (this === Promise) { - var nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); + if (this === Error) { + var nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } } } - if (this === Error) { - var nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + var originalObjectToString = Object.prototype.toString; + var PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; + }); + /** + * @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 passiveSupported = false; + if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; } - } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - var originalObjectToString = Object.prototype.toString; - var PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; + catch (err) { + passiveSupported = false; } - return originalObjectToString.call(this); - }; -}); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var passiveSupported = false; -if (typeof window !== 'undefined') { - try { - var options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } - }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); - } - catch (err) { - passiveSupported = false; } -} -// an identifier to tell ZoneTask do not create a new invoke closure -var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -var zoneSymbolEventNames$1 = {}; -var globalSources = {}; -var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - var PREPEND_EVENT_LISTENER = 'prependListener'; - var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { - return; - } - var delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = function (event) { return delegate.handleEvent(event); }; - task.originalDelegate = delegate; - } - // invoke static task.invoke - task.invoke(task, target, [event]); - var options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); - } + // an identifier to tell ZoneTask do not create a new invoke closure + var OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true }; - // global shared zoneAwareCallback to handle all event callback with capture = false - var globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + var zoneSymbolEventNames$1 = {}; + var globalSources = {}; + var EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + var PREPEND_EVENT_LISTENER = 'prependListener'; + var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + var invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } + var delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = function (event) { return delegate.handleEvent(event); }; + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + var options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); } - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - var globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + var globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); } - invokeTask(copyTasks[i], target, event); } } - } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - var useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - var validateHandler = patchOptions && patchOptions.vh; - var checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; - } - var returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; - } - var proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; - } - if (!proto) { - return false; - } - if (proto[zoneSymbolAddEventListener]) { - return false; - } - var eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - var taskData = {}; - var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - var nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } - } - var customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + var globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); - }; - var customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - var symbolEventName = void 0; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); } - var existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { break; } + invokeTask(copyTasks[i], target, event); } } } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { - return; - } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - var customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - var compareTaskCallbackVsDelegate = function (task, delegate) { - var typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { - if (returnTarget === void 0) { returnTarget = false; } - if (prepend === void 0) { prepend = false; } - return function () { - var target = this || _global; - var eventName = arguments[0]; - var delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - var isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); - } - isHandleEvent = true; - } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + var useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + var validateHandler = patchOptions && patchOptions.vh; + var checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + var returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + var proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + var eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + var taskData = {}; + var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + var nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { return; } - var options = arguments[2]; - if (blackListedEvents) { - // check black list - for (var i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { - return nativeListener.apply(this, arguments); + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + var customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + var symbolEventName = void 0; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } } } } - var capture; - var once = false; - if (options === undefined) { - capture = false; + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { + return; } - else if (options === true) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + var customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + var compareTaskCallbackVsDelegate = function (task, delegate) { + var typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + var blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { + if (returnTarget === void 0) { returnTarget = false; } + if (prepend === void 0) { prepend = false; } + return function () { + var target = this || _global; + var eventName = arguments[0]; + var delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + var isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { + return nativeListener.apply(this, arguments); + } + isHandleEvent = true; + } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + var options = arguments[2]; + if (blackListedEvents) { + // check black list + for (var i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + var capture; + var once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + var zone = Zone.current; + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = target[symbolEventName]; + var isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (var i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + var source; + var constructorName = target.constructor['name']; + var targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var options = arguments[2]; + var capture; + if (options === undefined) { + capture = false; + } + else if (options === true) { capture = true; } else if (options === false) { @@ -1936,3183 +2016,2979 @@ function patchEventTarget(_global, apis, patchOptions) { } else { capture = options ? !!options.capture : false; - once = options ? !!options.once : false; } - var zone = Zone.current; + var delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } var symbolEventNames = zoneSymbolEventNames$1[eventName]; var symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { + if (symbolEventNames) { symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } - var existingTasks = target[symbolEventName]; - var isExisting = false; + var existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (var i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; } } } - else { - existingTasks = target[symbolEventName] = []; - } - var source; - var constructorName = target.constructor['name']; - var targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); - } - else { - existingTasks.unshift(task); - } - if (returnTarget) { - return target; + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var listeners = []; + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (var i = 0; i < tasks.length; i++) { + var task = tasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); } + return listeners; }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var options = arguments[2]; - var capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - } - var delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); - } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; - } - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; - } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + if (!eventName) { + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } - return; } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } - } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var listeners = []; - var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - if (!eventName) { - var keys = Object.keys(target); - for (var i = 0; i < keys.length; i++) { - var prop = keys[i]; - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); - } - } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - var symbolEventName = symbolEventNames[FALSE_STR]; - var symbolCaptureEventName = symbolEventNames[TRUE_STR]; - var tasks = target[symbolEventName]; - var captureTasks = target[symbolCaptureEventName]; - if (tasks) { - var removeTasks = tasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + else { + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + var symbolEventName = symbolEventNames[FALSE_STR]; + var symbolCaptureEventName = symbolEventNames[TRUE_STR]; + var tasks = target[symbolEventName]; + var captureTasks = target[symbolCaptureEventName]; + if (tasks) { + var removeTasks = tasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } - } - if (captureTasks) { - var removeTasks = captureTasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + if (captureTasks) { + var removeTasks = captureTasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } } } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); } - if (returnTarget) { - return this; + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); } - }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + return true; } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + var results = []; + for (var i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); } - return true; - } - var results = []; - for (var i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); + return results; } - return results; -} -function findEventTasks(target, eventName) { - var foundTasks = []; - for (var prop in target) { - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - var tasks = target[prop]; - if (tasks) { - for (var i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); + function findEventTasks(target, eventName) { + var foundTasks = []; + for (var prop in target) { + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + var tasks = target[prop]; + if (tasks) { + for (var i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } } } } + return foundTasks; } - return foundTasks; -} -function patchEventPrototype(global, api) { - var Event = global['Event']; - if (Event && Event.prototype) { - api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) { return function (self, args) { - self[IMMEDIATE_PROPAGATION_SYMBOL] = true; - // we need to call the native stopImmediatePropagation - // in case in some hybrid application, some part of - // application will be controlled by zone, some are not - delegate && delegate.apply(self, 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 - */ -function patchCallbacks(api, target, targetName, method, callbacks) { - var symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; + function patchEventPrototype(global, api) { + var Event = global['Event']; + if (Event && Event.prototype) { + api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) { return function (self, args) { + self[IMMEDIATE_PROPAGATION_SYMBOL] = true; + // we need to call the native stopImmediatePropagation + // in case in some hybrid application, some part of + // application will be controlled by zone, some are not + delegate && delegate.apply(self, args); + }; }); + } } - var nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - var source = targetName + "." + method + "::" + callback; - var prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); - api._redefineProperty(opts.prototype, callback, descriptor); + /** + * @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 patchCallbacks(api, target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + var source = targetName + "." + method + "::" + callback; + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } } else if (prototype[callback]) { prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); } - } - else if (prototype[callback]) { - prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); - } + }); + } + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); + } + /** + * @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 + */ + /* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ + var zoneSymbol$1 = Zone.__symbol__; + var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; + var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; + var _create = Object.create; + var unconfigurablesKey = zoneSymbol$1('unconfigurables'); + function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + var originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); }); - } - return nativeDelegate.call(target, name, opts, options); - }; - api.attachOriginToPatched(target[method], nativeDelegate); -} - -/** - * @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 - */ -/* - * This is necessary for Chrome and Chrome mobile, to enable - * things like redefining `createdCallback` on an element. - */ -var zoneSymbol$1 = Zone.__symbol__; -var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; -var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = - Object.getOwnPropertyDescriptor; -var _create = Object.create; -var unconfigurablesKey = zoneSymbol$1('unconfigurables'); -function propertyPatch() { - Object.defineProperty = function (obj, prop, desc) { - if (isUnconfigurable(obj, prop)) { - throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); - } + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); + } + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + var desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; + } + return desc; + }; + } + function _redefineProperty(obj, prop, desc) { var originalConfigurableFlag = desc.configurable; - if (prop !== 'prototype') { - desc = rewriteDescriptor(obj, prop, desc); - } + desc = rewriteDescriptor(obj, prop, desc); return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); - }; - Object.defineProperties = function (obj, props) { - Object.keys(props).forEach(function (prop) { - Object.defineProperty(obj, prop, props[prop]); - }); - return obj; - }; - Object.create = function (obj, proto) { - if (typeof proto === 'object' && !Object.isFrozen(proto)) { - Object.keys(proto).forEach(function (prop) { - proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); - }); + } + function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; + } + function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; } - return _create(obj, proto); - }; - Object.getOwnPropertyDescriptor = function (obj, prop) { - var desc = _getOwnPropertyDescriptor(obj, prop); - if (desc && isUnconfigurable(obj, prop)) { - desc.configurable = false; + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; + } } return desc; - }; -} -function _redefineProperty(obj, prop, desc) { - var originalConfigurableFlag = desc.configurable; - desc = rewriteDescriptor(obj, prop, desc); - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); -} -function isUnconfigurable(obj, prop) { - return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; -} -function rewriteDescriptor(obj, prop, desc) { - // issue-927, if the desc is frozen, don't try to change the desc - if (!Object.isFrozen(desc)) { - desc.configurable = true; } - if (!desc.configurable) { - // issue-927, if the obj is frozen, don't try to set the desc to obj - if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { - _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); - } - if (obj[unconfigurablesKey]) { - obj[unconfigurablesKey][prop] = true; + function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); } - } - return desc; -} -function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - if (desc.configurable) { - // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's - // retry with the original flag value - if (typeof originalConfigurableFlag == 'undefined') { - delete desc.configurable; - } - else { - desc.configurable = originalConfigurableFlag; - } - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - var descJson = null; + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; + } + else { + desc.configurable = originalConfigurableFlag; + } try { - descJson = JSON.stringify(desc); + return _defineProperty(obj, prop, desc); } catch (error) { - descJson = desc.toString(); + var descJson = null; + try { + descJson = JSON.stringify(desc); + } + catch (error) { + descJson = desc.toString(); + } + console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); } - console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); + } + else { + throw error; } } - else { - throw error; - } - } -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var globalEventHandlersEventNames = [ - 'abort', - 'animationcancel', - 'animationend', - 'animationiteration', - 'auxclick', - 'beforeinput', - 'blur', - 'cancel', - 'canplay', - 'canplaythrough', - 'change', - 'compositionstart', - 'compositionupdate', - 'compositionend', - 'cuechange', - 'click', - 'close', - 'contextmenu', - 'curechange', - 'dblclick', - 'drag', - 'dragend', - 'dragenter', - 'dragexit', - 'dragleave', - 'dragover', - 'drop', - 'durationchange', - 'emptied', - 'ended', - 'error', - 'focus', - 'focusin', - 'focusout', - 'gotpointercapture', - 'input', - 'invalid', - 'keydown', - 'keypress', - 'keyup', - 'load', - 'loadstart', - 'loadeddata', - 'loadedmetadata', - 'lostpointercapture', - 'mousedown', - 'mouseenter', - 'mouseleave', - 'mousemove', - 'mouseout', - 'mouseover', - 'mouseup', - 'mousewheel', - 'orientationchange', - 'pause', - 'play', - 'playing', - 'pointercancel', - 'pointerdown', - 'pointerenter', - 'pointerleave', - 'pointerlockchange', - 'mozpointerlockchange', - 'webkitpointerlockerchange', - 'pointerlockerror', - 'mozpointerlockerror', - 'webkitpointerlockerror', - 'pointermove', - 'pointout', - 'pointerover', - 'pointerup', - 'progress', - 'ratechange', - 'reset', - 'resize', - 'scroll', - 'seeked', - 'seeking', - 'select', - 'selectionchange', - 'selectstart', - 'show', - 'sort', - 'stalled', - 'submit', - 'suspend', - 'timeupdate', - 'volumechange', - 'touchcancel', - 'touchmove', - 'touchstart', - 'touchend', - 'transitioncancel', - 'transitionend', - 'waiting', - 'wheel' -]; -var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', - 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', - 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange', 'resume' -]; -var windowEventNames = [ - 'absolutedeviceorientation', - 'afterinput', - 'afterprint', - 'appinstalled', - 'beforeinstallprompt', - 'beforeprint', - 'beforeunload', - 'devicelight', - 'devicemotion', - 'deviceorientation', - 'deviceorientationabsolute', - 'deviceproximity', - 'hashchange', - 'languagechange', - 'message', - 'mozbeforepaint', - 'offline', - 'online', - 'paint', - 'pageshow', - 'pagehide', - 'popstate', - 'rejectionhandled', - 'storage', - 'unhandledrejection', - 'unload', - 'userproximity', - 'vrdisplyconnected', - 'vrdisplaydisconnected', - 'vrdisplaypresentchange' -]; -var htmlElementEventNames = [ - 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', - 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', - 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' -]; -var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; -var ieElementEventNames = [ - 'activate', - 'afterupdate', - 'ariarequest', - 'beforeactivate', - 'beforedeactivate', - 'beforeeditfocus', - 'beforeupdate', - 'cellchange', - 'controlselect', - 'dataavailable', - 'datasetchanged', - 'datasetcomplete', - 'errorupdate', - 'filterchange', - 'layoutcomplete', - 'losecapture', - 'move', - 'moveend', - 'movestart', - 'propertychange', - 'resizeend', - 'resizestart', - 'rowenter', - 'rowexit', - 'rowsdelete', - 'rowsinserted', - 'command', - 'compassneedscalibration', - 'deactivate', - 'help', - 'mscontentzoom', - 'msmanipulationstatechanged', - 'msgesturechange', - 'msgesturedoubletap', - 'msgestureend', - 'msgesturehold', - 'msgesturestart', - 'msgesturetap', - 'msgotpointercapture', - 'msinertiastart', - 'mslostpointercapture', - 'mspointercancel', - 'mspointerdown', - 'mspointerenter', - 'mspointerhover', - 'mspointerleave', - 'mspointermove', - 'mspointerout', - 'mspointerover', - 'mspointerup', - 'pointerout', - 'mssitemodejumplistitemremoved', - 'msthumbnailclick', - 'stop', - 'storagecommit' -]; -var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; -var formEventNames = ['autocomplete', 'autocompleteerror']; -var detailEventNames = ['toggle']; -var frameEventNames = ['load']; -var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; -var marqueeEventNames = ['bounce', 'finish', 'start']; -var XMLHttpRequestEventNames = [ - 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', - 'readystatechange' -]; -var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; -var websocketEventNames = ['close', 'error', 'open', 'message']; -var workerEventNames = ['error', 'message']; -var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); -function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties || ignoreProperties.length === 0) { - return onProperties; - } - var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); - if (!tip || tip.length === 0) { - return onProperties; - } - var targetIgnoreProperties = tip[0].ignoreProperties; - return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); -} -function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { - // check whether target is available, sometimes target will be undefined - // because different browser or some 3rd party plugin. - if (!target) { - return; } - var filteredProperties = filterProperties(target, onProperties, ignoreProperties); - patchOnProperties(target, filteredProperties, prototype); -} -function propertyDescriptorPatch(api, _global) { - if (isNode && !isMix) { - 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 globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' + ]; + var documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' + ]; + var windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' + ]; + var htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' + ]; + var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; + var ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' + ]; + var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; + var formEventNames = ['autocomplete', 'autocompleteerror']; + var detailEventNames = ['toggle']; + var frameEventNames = ['load']; + var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; + var marqueeEventNames = ['bounce', 'finish', 'start']; + var XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' + ]; + var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; + var websocketEventNames = ['close', 'error', 'open', 'message']; + var workerEventNames = ['error', 'message']; + var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); + function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); + if (!tip || tip.length === 0) { + return onProperties; + } + var targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); } - if (Zone[api.symbol('patchEvents')]) { - // events are already been patched by legacy patch. - return; + function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + var filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); + function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + var supportsWebSocket = typeof WebSocket !== 'undefined'; + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow_1 = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow_1, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow_1, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow_1)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow_1['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow_1['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow_1['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow_1['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + } + } + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); } - } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (XMLHttpRequest) { - // XMLHttpRequest is not available in ServiceWorker, so we need to check here - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } -} - -/** - * @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.__load_patch('util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to - // define which events will not be patched by `Zone.js`. - // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep - // the name consistent with angular repo. - // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for - // backwards compatibility. - var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); - if (global[SYMBOL_UNPATCHED_EVENTS]) { - global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; - } - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = - global[SYMBOL_BLACK_LISTED_EVENTS]; - } - api.patchEventPrototype = patchEventPrototype; - api.patchEventTarget = patchEventTarget; - api.isIEOrEdge = isIEOrEdge; - api.ObjectDefineProperty = ObjectDefineProperty; - api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; - api.ObjectCreate = ObjectCreate; - api.ArraySlice = ArraySlice; - api.patchClass = patchClass; - api.wrapWithCurrentZone = wrapWithCurrentZone; - api.filterProperties = filterProperties; - api.attachOriginToPatched = attachOriginToPatched; - api._redefineProperty = _redefineProperty; - api.patchCallbacks = patchCallbacks; - api.getGlobalObjects = function () { return ({ - globalSources: globalSources, - zoneSymbolEventNames: zoneSymbolEventNames$1, - eventNames: eventNames, - isBrowser: isBrowser, - isMix: isMix, - isNode: isNode, - TRUE_STR: TRUE_STR, - FALSE_STR: FALSE_STR, - ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, - ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, - REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR - }); }; -}); - -/** - * @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 - */ - -/** - * @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 eventTargetLegacyPatch(_global, api) { - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - 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,WebSocket' - .split(','); - var EVENT_TARGET = 'EventTarget'; - var apis = []; - var isWtf = _global['wtf']; - var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); - if (isWtf) { - // Workaround for: https://github.com/google/tracing-framework/issues/555 - apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); - } - else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); - } - else { - // Note: EventTarget is not available in all browsers, - // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget - apis = NO_EVENT_TARGET; - } - var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; - var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - var ieOrEdge = api.isIEOrEdge(); - var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; - var FUNCTION_WRAPPER = '[object FunctionWrapper]'; - var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - // predefine all task.source string - for (var i = 0; i < WTF_ISSUE_555.length; i++) { - var target = WTF_ISSUE_555_ARRAY[i]; - var targets = globalSources[target] = {}; - for (var j = 0; j < eventNames.length; j++) { - var eventName = eventNames[j]; - targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); } } - var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { - if (!isDisableIECheck && ieOrEdge) { - if (isEnableCrossContextCheck) { - try { + /** + * @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.__load_patch('util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = function () { return ({ + globalSources: globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames: eventNames, + isBrowser: isBrowser, + isMix: isMix, + isNode: isNode, + TRUE_STR: TRUE_STR, + FALSE_STR: FALSE_STR, + ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR + }); }; + }); + /** + * @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 + */ + /** + * @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 eventTargetLegacyPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + 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,WebSocket' + .split(','); + var EVENT_TARGET = 'EventTarget'; + var apis = []; + var isWtf = _global['wtf']; + var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); + if (isWtf) { + // Workaround for: https://github.com/google/tracing-framework/issues/555 + apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); + } + else if (_global[EVENT_TARGET]) { + apis.push(EVENT_TARGET); + } + else { + // Note: EventTarget is not available in all browsers, + // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget + apis = NO_EVENT_TARGET; + } + var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; + var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; + var ieOrEdge = api.isIEOrEdge(); + var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; + var FUNCTION_WRAPPER = '[object FunctionWrapper]'; + var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + // predefine all task.source string + for (var i = 0; i < WTF_ISSUE_555.length; i++) { + var target = WTF_ISSUE_555_ARRAY[i]; + var targets = globalSources[target] = {}; + for (var j = 0; j < eventNames.length; j++) { + var eventName = eventNames[j]; + targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + } + } + var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { + if (!isDisableIECheck && ieOrEdge) { + if (isEnableCrossContextCheck) { + try { + var testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } + catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } + else { var testString = delegate.toString(); if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { nativeDelegate.apply(target, args); return false; } } + } + else if (isEnableCrossContextCheck) { + try { + delegate.toString(); + } catch (error) { nativeDelegate.apply(target, args); return false; } } + return true; + }; + var apiTypes = []; + for (var i = 0; i < apis.length; i++) { + var type = _global[apis[i]]; + apiTypes.push(type && type.prototype); + } + // vh is validateHandler to check event handler + // is valid or not(for security check) + api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; + return true; + } + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + // we have to patch the instance since the proto is non-configurable + function apply(api, _global) { + var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; + var WS = _global.WebSocket; + // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener + // On older Chrome, no need since EventTarget was already patched + if (!_global.EventTarget) { + api.patchEventTarget(_global, [WS.prototype]); + } + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); + var proxySocket; + var proxySocketProto; + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = api.ObjectCreate(socket); + // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' + // but proxySocket not, so we will keep socket as prototype and pass it to + // patchOnProperties method + proxySocketProto = socket; + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { + proxySocket[propName] = function () { + var args = api.ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { + var eventName = args.length > 0 ? args[0] : undefined; + if (eventName) { + var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + socket[propertySymbol] = proxySocket[propertySymbol]; + } + } + return socket[propName].apply(socket, args); + }; + }); + } else { - var testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { - nativeDelegate.apply(target, args); - return false; - } + // we can patch the real socket + proxySocket = socket; } + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + return proxySocket; + }; + var globalWebSocket = _global['WebSocket']; + for (var prop in WS) { + globalWebSocket[prop] = WS[prop]; } - else if (isEnableCrossContextCheck) { - try { - delegate.toString(); - } - catch (error) { - nativeDelegate.apply(target, args); - return false; - } - } - return true; - }; - var apiTypes = []; - for (var i = 0; i < apis.length; i++) { - var type = _global[apis[i]]; - apiTypes.push(type && type.prototype); } - // vh is validateHandler to check event handler - // is valid or not(for security check) - api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); - Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; - return true; -} - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -// we have to patch the instance since the proto is non-configurable -function apply(api, _global) { - var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; - var WS = _global.WebSocket; - // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener - // On older Chrome, no need since EventTarget was already patched - if (!_global.EventTarget) { - api.patchEventTarget(_global, [WS.prototype]); - } - _global.WebSocket = function (x, y) { - var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); - var proxySocket; - var proxySocketProto; - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = api.ObjectCreate(socket); - // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' - // but proxySocket not, so we will keep socket as prototype and pass it to - // patchOnProperties method - proxySocketProto = socket; - [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { - proxySocket[propName] = function () { - var args = api.ArraySlice.call(arguments); - if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { - var eventName = args.length > 0 ? args[0] : undefined; - if (eventName) { - var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); - socket[propertySymbol] = proxySocket[propertySymbol]; - } - } - return socket[propName].apply(socket, 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 + */ + function propertyDescriptorLegacyPatch(api, _global) { + var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; + if (isNode && !isMix) { + return; } - else { - // we can patch the real socket - proxySocket = socket; + if (!canPatchViaPropertyDescriptor(api, _global)) { + var supportsWebSocket = typeof WebSocket !== 'undefined'; + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + apply(api, _global); + } + Zone[api.symbol('patchEvents')] = true; } - api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); - return proxySocket; - }; - var globalWebSocket = _global['WebSocket']; - for (var prop in WS) { - globalWebSocket[prop] = WS[prop]; - } -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -function propertyDescriptorLegacyPatch(api, _global) { - var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; - if (isNode && !isMix) { - return; } - if (!canPatchViaPropertyDescriptor(api, _global)) { - var supportsWebSocket = typeof WebSocket !== 'undefined'; - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(api); - api.patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - apply(api, _global); + function canPatchViaPropertyDescriptor(api, _global) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) + return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var div = document.createElement('div'); + var result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; + } } - Zone[api.symbol('patchEvents')] = true; - } -} -function canPatchViaPropertyDescriptor(api, _global) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((isBrowser || isMix) && - !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) + var XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker return false; - // try to use onclick to detect whether we can patch via propertyDescriptor - // because XMLHttpRequest is not available in service worker - if (desc) { - api.ObjectDefineProperty(Element.prototype, 'onclick', { + } + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { return true; } }); - var div = document.createElement('div'); - var result = !!div.onclick; - api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + var req = new XMLHttpRequest(); + var result = !!req.onreadystatechange; + // restore original desc + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); return result; } - } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker - return false; - } - var ON_READY_STATE_CHANGE = 'onreadystatechange'; - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return true; - } - }); - var req = new XMLHttpRequest(); - var result = !!req.onreadystatechange; - // restore original desc - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } - else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; - }, - set: function (value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; - } - }); - var req = new XMLHttpRequest(); - var detectFunc = function () { }; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; - req.onreadystatechange = null; - return result; - } -} -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents(api) { - var eventNames = api.getGlobalObjects().eventNames; - var unboundKey = api.symbol('unbound'); - var _loop_1 = function (i) { - var property = eventNames[i]; - var onproperty = 'on' + property; - self.addEventListener(property, function (event) { - var elt = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } - else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = api.wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; + else { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; + }, + set: function (value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; } - elt = elt.parentElement; - } - }, true); - }; - for (var i = 0; i < eventNames.length; i++) { - _loop_1(i); - } -} - -/** - * @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, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { - return; + }); + var req = new XMLHttpRequest(); + var detectFunc = function () { }; + req.onreadystatechange = detectFunc; + var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = null; + return result; + } } - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -(function (_global) { - _global['__zone_symbol__legacyPatch'] = function () { - var Zone = _global['Zone']; - Zone.__load_patch('registerElement', function (global, Zone, api) { - registerElementPatch(global, api); - }); - Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { - eventTargetLegacyPatch(global, api); - propertyDescriptorLegacyPatch(api, global); - }); - }; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + // Whenever any eventListener fires, we check the eventListener target and all parents + // for `onwhatever` properties and replace them with zone-bound functions + // - Chrome (for now) + function patchViaCapturingAllTheEvents(api) { + var eventNames = api.getGlobalObjects().eventNames; + var unboundKey = api.symbol('unbound'); + var _loop_4 = function (i) { + var property = eventNames[i]; + var onproperty = 'on' + property; + self.addEventListener(property, function (event) { + var elt = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; + } + else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = api.wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; } + elt = elt.parentElement; } - } + }, true); + }; + for (var i = 0; i < eventNames.length; i++) { + _loop_4(i); } - data.args[0] = timer; - data.handleId = setNative.apply(window, data.args); - return task; } - function clearTask(task) { - return clearNative(task.data.handleId); + /** + * @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, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); } - setNative = - patchMethod(window, setName, function (delegate) { return function (self, args) { - if (typeof args[0] === 'function') { - var options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); + /** + * @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) { + _global[Zone.__symbol__('legacyPatch')] = function () { + var Zone = _global['Zone']; + Zone.__load_patch('registerElement', function (global, Zone, api) { + registerElementPatch(global, api); + }); + Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); + }; + })(typeof window !== 'undefined' ? + window : + typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + 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; + function timer() { + try { + task.invoke.apply(this, arguments); } - if (typeof handle === 'number' || handle) { - return handle; + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } + } } - 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; + data.args[0] = timer; + 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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } + return task; } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + else { + // cause an error by calling it directly. + return delegate.apply(window, args); + } + }; }); + clearNative = + patchMethod(window, cancelName, function (delegate) { return function (self, args) { + var id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; + } + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; } - else if (id) { - id[taskSymbol] = null; + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // Do not cancel already canceled functions + task.zone.cancelTask(task); } - // 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 - */ -function patchCustomElements(_global, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { - return; - } - var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); -} - -/** - * @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 eventTargetPatch(_global, api) { - if (Zone[api.symbol('patchEventTarget')]) { - // EventTarget is already patched. - return; - } - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - var EVENT_TARGET = _global['EventTarget']; - if (!EVENT_TARGET || !EVENT_TARGET.prototype) { - return; + else { + // cause an error by calling it directly. + delegate.apply(window, args); + } + }; }); } - api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); - return true; -} -function patchEvent$1(global, api) { - api.patchEventPrototype(global, api); -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -Zone.__load_patch('legacy', function (global) { - var legacyPatch = global[Zone.__symbol__('legacyPatch')]; - if (legacyPatch) { - legacyPatch(); + /** + * @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 patchCustomElements(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { + return; + } + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); } -}); -Zone.__load_patch('timers', function (global) { - var set = 'set'; - var clear = 'clear'; - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); -}); -Zone.__load_patch('requestAnimationFrame', function (global) { - patchTimer(global, 'request', 'cancel', 'AnimationFrame'); - patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); - patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); -}); -Zone.__load_patch('blocking', function (global, Zone) { - var blockingMethods = ['alert', 'prompt', 'confirm']; - for (var i = 0; i < blockingMethods.length; i++) { - var name_1 = blockingMethods[i]; - patchMethod(global, name_1, function (delegate, symbol, name) { - return function (s, args) { - return Zone.current.run(delegate, global, args, name); - }; - }); + /** + * @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 eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; + } + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; + } + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; } -}); -Zone.__load_patch('EventTarget', function (global, Zone, api) { - patchEvent$1(global, api); - eventTargetPatch(global, api); - // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener - var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { - api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + function patchEvent(global, api) { + api.patchEventPrototype(global, api); } - patchClass('MutationObserver'); - patchClass('WebKitMutationObserver'); - patchClass('IntersectionObserver'); - patchClass('FileReader'); -}); -Zone.__load_patch('on_property', function (global, Zone, api) { - propertyDescriptorPatch(api, global); - propertyPatch(); -}); -Zone.__load_patch('customElements', function (global, Zone, api) { - patchCustomElements(global, api); -}); -Zone.__load_patch('XHR', function (global, Zone) { - // Treat XMLHttpRequest as a macrotask. - patchXHR(global); - var XHR_TASK = zoneSymbol('xhrTask'); - var XHR_SYNC = zoneSymbol('xhrSync'); - var XHR_LISTENER = zoneSymbol('xhrListener'); - var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); - var XHR_URL = zoneSymbol('xhrURL'); - var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); - function patchXHR(window) { - var XMLHttpRequest = window['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker - 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 + */ + Zone.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); } - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - function findPendingTask(target) { - return target[XHR_TASK]; + }); + Zone.__load_patch('timers', function (global) { + var set = 'set'; + var clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + }); + Zone.__load_patch('requestAnimationFrame', function (global) { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); + }); + Zone.__load_patch('blocking', function (global, Zone) { + var blockingMethods = ['alert', 'prompt', 'confirm']; + for (var i = 0; i < blockingMethods.length; i++) { + var name_2 = blockingMethods[i]; + patchMethod(global, name_2, function (delegate, symbol, name) { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); } - var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - if (!oriAddListener) { - var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; - oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + }); + Zone.__load_patch('EventTarget', function (global, Zone, api) { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); + }); + Zone.__load_patch('on_property', function (global, Zone, api) { + propertyDescriptorPatch(api, global); + propertyPatch(); + }); + Zone.__load_patch('customElements', function (global, Zone, api) { + patchCustomElements(global, api); + }); + Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + var XHR_TASK = zoneSymbol('xhrTask'); + var XHR_SYNC = zoneSymbol('xhrSync'); + var XHR_LISTENER = zoneSymbol('xhrListener'); + var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; } - } - var READY_STATE_CHANGE = 'readystatechange'; - var SCHEDULED = 'scheduled'; - function scheduleTask(task) { - var data = task.data; - var target = data.target; - target[XHR_SCHEDULED] = false; - target[XHR_ERROR_BEFORE_SCHEDULED] = false; - // remove existing event listener - var listener = target[XHR_LISTENER]; - if (!oriAddListener) { - oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; } - if (listener) { - oriRemoveListener.call(target, READY_STATE_CHANGE, listener); - } - var newListener = target[XHR_LISTENER] = function () { - if (target.readyState === target.DONE) { - // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with - // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { - // check whether the xhr has registered onload listener - // if that is the case, the task should invoke after all - // onload listeners finish. - var loadTasks = target['__zone_symbol__loadfalse']; - if (loadTasks && loadTasks.length > 0) { - var oriInvoke_1 = task.invoke; - task.invoke = function () { - // need to load the tasks again, because in other - // load listener, they may remove themselves - var loadTasks = target['__zone_symbol__loadfalse']; - for (var i = 0; i < loadTasks.length; i++) { - if (loadTasks[i] === task) { - loadTasks.splice(i, 1); + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + var READY_STATE_CHANGE = 'readystatechange'; + var SCHEDULED = 'scheduled'; + function scheduleTask(task) { + var data = task.data; + var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + var listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + var newListener = target[XHR_LISTENER] = function () { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target[Zone.__symbol__('loadfalse')]; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target[Zone.__symbol__('loadfalse')]; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } } - } - if (!data.aborted && task.state === SCHEDULED) { - oriInvoke_1.call(task); - } - }; - loadTasks.push(task); + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } } - else { - task.invoke(); + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } - else if (!data.aborted && target[XHR_SCHEDULED] === false) { - // error occurs when xhr.send() - target[XHR_ERROR_BEFORE_SCHEDULED] = true; - } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + var storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; } - }; - oriAddListener.call(target, READY_STATE_CHANGE, newListener); - var storedTask = target[XHR_TASK]; - if (!storedTask) { - target[XHR_TASK] = task; - } - sendNative.apply(target, data.args); - target[XHR_SCHEDULED] = true; - return task; - } - function placeholderCallback() { } - function clearTask(task) { - var data = task.data; - // Note - ideally, we would call data.target.removeEventListener here, but it's too late - // to prevent it from firing. So instead, we store info for the event listener. - data.aborted = true; - return abortNative.apply(data.target, data.args); - } - var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { - self[XHR_SYNC] = args[2] == false; - self[XHR_URL] = args[1]; - return openNative.apply(self, args); - }; }); - var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); - var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); - var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { - if (Zone.current[fetchTaskScheduling] === true) { - // a fetch is scheduling, so we are using xhr to polyfill fetch - // and because we already schedule macroTask for fetch, we should - // not schedule a macroTask for xhr again - return sendNative.apply(self, args); - } - if (self[XHR_SYNC]) { - // if the XHR is sync there is no task to schedule, just execute the code. - return sendNative.apply(self, args); + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; } - else { - var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; - var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); - if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && - task.state === SCHEDULED) { - // xhr request throw error when send - // we should invoke task instead of leaving a scheduled - // pending macroTask - task.invoke(); + function placeholderCallback() { } + function clearTask(task) { + var data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }; }); + var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + if (self[XHR_SYNC]) { + // if the XHR is sync there is no task to schedule, just execute the code. + return sendNative.apply(self, args); } - } - }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { - var task = findPendingTask(self); - if (task && typeof task.type == 'string') { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && task.data.aborted)) { - return; + else { + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } } - task.zone.cancelTask(task); - } - else if (Zone.current[fetchTaskAborting] === true) { - // the abort is called from fetch polyfill, we need to call native abort of XHR. - return abortNative.apply(self, args); - } - // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no - // task - // to cancel. Do nothing. - }; }); - } -}); -Zone.__load_patch('geolocation', function (global) { - /// GEO_LOCATION - if (global['navigator'] && global['navigator'].geolocation) { - patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { - // handle unhandled promise rejection - function findPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(global, evtName); - eventTasks.forEach(function (eventTask) { - // windows has added unhandledrejection event listener - // trigger the event listener - var PromiseRejectionEvent = global['PromiseRejectionEvent']; - if (PromiseRejectionEvent) { - var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); - eventTask.invoke(evt); + }; }); + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { + var task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); } - }); - }; - } - if (global['PromiseRejectionEvent']) { - Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = - findPromiseRejectionHandler('unhandledrejection'); - Zone[zoneSymbol('rejectionHandledHandler')] = - findPromiseRejectionHandler('rejectionhandled'); - } -}); - -/** - * @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 - */ - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var __assign = (undefined && undefined.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var NEWLINE = '\n'; -var IGNORE_FRAMES = {}; -var creationTrace = '__creationTrace__'; -var ERROR_TAG = 'STACKTRACE TRACKING'; -var SEP_TAG = '__SEP_TAG__'; -var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = /** @class */ (function () { - function LongStackTrace() { - this.error = getStacktrace(); - this.timestamp = new Date(); - } - return LongStackTrace; -}()); -function getStacktraceWithUncaughtError() { - return new Error(ERROR_TAG); -} -function getStacktraceWithCaughtError() { - try { - throw getStacktraceWithUncaughtError(); - } - catch (err) { - return err; - } -} -// Some implementations of exception handling don't create a stack trace if the exception -// isn't thrown, however it's faster not to actually throw the exception. -var error = getStacktraceWithUncaughtError(); -var caughtError = getStacktraceWithCaughtError(); -var getStacktrace = error.stack ? - getStacktraceWithUncaughtError : - (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); -function getFrames(error) { - return error.stack ? error.stack.split(NEWLINE) : []; -} -function addErrorStack(lines, error) { - var trace = getFrames(error); - for (var i = 0; i < trace.length; i++) { - var frame = trace[i]; - // Filter out the Frames which are part of stack capturing. - if (!IGNORE_FRAMES.hasOwnProperty(frame)) { - lines.push(trace[i]); + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }; }); } - } -} -function renderLongStackTrace(frames, stack) { - var longTrace = [stack ? stack.trim() : '']; - if (frames) { - var timestamp = new Date().getTime(); - for (var i = 0; i < frames.length; i++) { - var traceFrames = frames[i]; - var lastTime = traceFrames.timestamp; - var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; - separator = separator.replace(/[^\w\d]/g, '_'); - longTrace.push(sepTemplate.replace(SEP_TAG, separator)); - addErrorStack(longTrace, traceFrames.error); - timestamp = lastTime.getTime(); + }); + Zone.__load_patch('geolocation', function (global) { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); } - } - return longTrace.join(NEWLINE); -} -Zone['longStackTraceZoneSpec'] = { - name: 'long-stack-trace', - longStackTraceLimit: 10, - // add a getLongStackTrace method in spec to - // handle handled reject promise error. - getLongStackTrace: function (error) { - if (!error) { - return undefined; + }); + Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(function (eventTask) { + // windows has added unhandledrejection event listener + // trigger the event listener + var PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; } - var trace = error[Zone.__symbol__('currentTaskTrace')]; - if (!trace) { - return error.stack; + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); } - return renderLongStackTrace(trace, error.stack); - }, - onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var currentTask = Zone.currentTask; - var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; - trace = [new LongStackTrace()].concat(trace); - if (trace.length > this.longStackTraceLimit) { - trace.length = this.longStackTraceLimit; - } - if (!task.data) - task.data = {}; - if (task.type === 'eventTask') { - // Fix issue https://github.com/angular/zone.js/issues/1195, - // For event task of browser, by default, all task will share a - // singleton instance of data object, we should create a new one here - // The cast to `any` is required to workaround a closure bug which wrongly applies - // URL sanitization rules to .data access. - task.data = __assign({}, task.data); - } - task.data[creationTrace] = trace; + }); + /** + * @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 + */ + /** + * @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 + */ + /** + * @fileoverview + * @suppress {globalThis} + */ + var NEWLINE = '\n'; + var IGNORE_FRAMES = {}; + var creationTrace = '__creationTrace__'; + var ERROR_TAG = 'STACKTRACE TRACKING'; + var SEP_TAG = '__SEP_TAG__'; + var sepTemplate = SEP_TAG + '@[native]'; + var LongStackTrace = /** @class */ (function () { + function LongStackTrace() { + this.error = getStacktrace(); + this.timestamp = new Date(); + } + return LongStackTrace; + }()); + function getStacktraceWithUncaughtError() { + return new Error(ERROR_TAG); + } + function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); } - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var parentTask = Zone.currentTask || error.task; - if (error instanceof Error && parentTask) { - var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); - try { - error.stack = error.longStack = longStack; - } - catch (err) { - } - } + catch (err) { + return err; } - return parentZoneDelegate.handleError(targetZone, error); - } -}; -function captureStackTraces(stackTraces, count) { - if (count > 0) { - stackTraces.push(getFrames((new LongStackTrace()).error)); - captureStackTraces(stackTraces, count - 1); } -} -function computeIgnoreFrames() { - if (Error.stackTraceLimit <= 0) { - return; + // Some implementations of exception handling don't create a stack trace if the exception + // isn't thrown, however it's faster not to actually throw the exception. + var error = getStacktraceWithUncaughtError(); + var caughtError = getStacktraceWithCaughtError(); + var getStacktrace = error.stack ? + getStacktraceWithUncaughtError : + (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); + function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; } - var frames = []; - captureStackTraces(frames, 2); - var frames1 = frames[0]; - var frames2 = frames[1]; - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - if (frame1.indexOf(ERROR_TAG) == -1) { - var match = frame1.match(/^\s*at\s+/); - if (match) { - sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; - break; + function addErrorStack(lines, error) { + var trace = getFrames(error); + for (var i = 0; i < trace.length; i++) { + var frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!IGNORE_FRAMES.hasOwnProperty(frame)) { + lines.push(trace[i]); } } } - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - var frame2 = frames2[i]; - if (frame1 === frame2) { - IGNORE_FRAMES[frame1] = true; - } - else { - break; - } + function renderLongStackTrace(frames, stack) { + var longTrace = [stack ? stack.trim() : '']; + if (frames) { + var timestamp = new Date().getTime(); + for (var i = 0; i < frames.length; i++) { + var traceFrames = frames[i]; + var lastTime = traceFrames.timestamp; + var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; + separator = separator.replace(/[^\w\d]/g, '_'); + longTrace.push(sepTemplate.replace(SEP_TAG, separator)); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); + } + } + return longTrace.join(NEWLINE); } -} -computeIgnoreFrames(); - -/** - * @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 = /** @class */ (function () { - function ProxyZoneSpec(defaultSpecDelegate) { - if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } - this.defaultSpecDelegate = defaultSpecDelegate; - this.name = 'ProxyZone'; - this._delegateSpec = null; - this.properties = { 'ProxyZoneSpec': this }; - this.propertyKeys = null; - this.lastTaskState = null; - this.isNeedToTriggerHasTask = false; - this.tasks = []; - this.setDelegate(defaultSpecDelegate); - } - ProxyZoneSpec.get = function () { - return Zone.current.get('ProxyZoneSpec'); - }; - ProxyZoneSpec.isLoaded = function () { - return ProxyZoneSpec.get() instanceof ProxyZoneSpec; - }; - ProxyZoneSpec.assertPresent = function () { - if (!ProxyZoneSpec.isLoaded()) { - throw new Error("Expected to be running in 'ProxyZone', but it was not found."); - } - return ProxyZoneSpec.get(); - }; - ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { - var _this = this; - var isNewDelegate = this._delegateSpec !== delegateSpec; - this._delegateSpec = delegateSpec; - this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); - this.propertyKeys = null; - if (delegateSpec && delegateSpec.properties) { - this.propertyKeys = Object.keys(delegateSpec.properties); - this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); - } - // if set a new delegateSpec, shoulde check whether need to - // trigger hasTask or not - if (isNewDelegate && this.lastTaskState && - (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { - this.isNeedToTriggerHasTask = true; - } - }; - ProxyZoneSpec.prototype.getDelegate = function () { - return this._delegateSpec; - }; - ProxyZoneSpec.prototype.resetDelegate = function () { - var delegateSpec = this.getDelegate(); - this.setDelegate(this.defaultSpecDelegate); - }; - ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { - if (this.isNeedToTriggerHasTask && this.lastTaskState) { - // last delegateSpec has microTask or macroTask - // should call onHasTask in current delegateSpec - this.isNeedToTriggerHasTask = false; - this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); - } - }; - ProxyZoneSpec.prototype.removeFromTasks = function (task) { - if (!this.tasks) { - return; - } - for (var i = 0; i < this.tasks.length; i++) { - if (this.tasks[i] === task) { - this.tasks.splice(i, 1); - return; + Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + // add a getLongStackTrace method in spec to + // handle handled reject promise error. + getLongStackTrace: function (error) { + if (!error) { + return undefined; + } + var trace = error[Zone.__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; + } + return renderLongStackTrace(trace, error.stack); + }, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var currentTask = Zone.currentTask; + var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; + } + if (!task.data) + task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = Object.assign({}, task.data); + } + task.data[creationTrace] = trace; } - } - }; - ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { - if (this.tasks.length === 0) { - return ''; - } - var taskInfo = this.tasks.map(function (task) { - var dataInfo = task.data && - Object.keys(task.data) - .map(function (key) { - return key + ':' + task.data[key]; - }) - .join(','); - return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; - }); - var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; - // clear tasks - this.tasks = []; - return pendingTasksInfo; - }; - ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { - if (this._delegateSpec && this._delegateSpec.onFork) { - return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); - } - else { - return parentZoneDelegate.fork(targetZone, zoneSpec); - } - }; - ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { - if (this._delegateSpec && this._delegateSpec.onIntercept) { - return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); - } - else { - return parentZoneDelegate.intercept(targetZone, delegate, source); - } - }; - ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvoke) { - return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); - } - else { - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - }; - ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - if (this._delegateSpec && this._delegateSpec.onHandleError) { - return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); - } - else { - return parentZoneDelegate.handleError(targetZone, error); - } - }; - ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.tasks.push(task); - } - if (this._delegateSpec && this._delegateSpec.onScheduleTask) { - return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + try { + error.stack = error.longStack = longStack; + } + catch (err) { + } + } + } + return parentZoneDelegate.handleError(targetZone, error); } }; - ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvokeTask) { - return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); - } - else { - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } - }; - ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onCancelTask) { - return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.cancelTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { - this.lastTaskState = hasTaskState; - if (this._delegateSpec && this._delegateSpec.onHasTask) { - this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); + function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); } - else { - delegate.hasTask(target, hasTaskState); - } - }; - return ProxyZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['ProxyZoneSpec'] = ProxyZoneSpec; - -/** - * @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 = /** @class */ (function () { - function SyncTestZoneSpec(namePrefix) { - this.runZone = Zone.current; - this.name = 'syncTestZone for ' + namePrefix; } - SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - case 'macroTask': - throw new Error("Cannot call " + task.source + " from within a sync test."); - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - return SyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; - -/** - * @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; + function computeIgnoreFrames() { + if (Error.stackTraceLimit <= 0) { + return; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; - // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs - // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) - if (!Zone) - throw new Error('Missing: zone.js'); - if (typeof jasmine == 'undefined') - throw new Error('Missing: jasmine.js'); - if (jasmine['__zone_patch__']) - throw new Error("'jasmine' has already been patched with 'Zone'."); - jasmine['__zone_patch__'] = true; - var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (!SyncTestZoneSpec) - throw new Error('Missing: SyncTestZoneSpec'); - if (!ProxyZoneSpec) - throw new Error('Missing: ProxyZoneSpec'); - var ambientZone = Zone.current; - // Create a synchronous-only zone in which to run `describe` blocks in order to raise an - // error if any asynchronous operations are attempted inside of a `describe` but outside of - // a `beforeEach` or `it`. - var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - var symbol = Zone.__symbol__; - // whether patch jasmine clock when in fakeAsync - var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; - // the original variable name fakeAsyncPatchLock is not accurate, so the name will be - // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also - // automatically disable the auto jump into fakeAsync feature - var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && - ((_global[symbol('fakeAsyncPatchLock')] === true) || - (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); - var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; - if (!ignoreUnhandledRejection) { - var globalErrors_1 = jasmine.GlobalErrors; - if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { - jasmine[symbol('GlobalErrors')] = globalErrors_1; - jasmine.GlobalErrors = function () { - var instance = new globalErrors_1(); - var originalInstall = instance.install; - if (originalInstall && !instance[symbol('install')]) { - instance[symbol('install')] = originalInstall; - instance.install = function () { - var originalHandlers = process.listeners('unhandledRejection'); - var r = originalInstall.apply(this, arguments); - process.removeAllListeners('unhandledRejection'); - if (originalHandlers) { - originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); - } - return r; - }; + var frames = []; + captureStackTraces(frames, 2); + var frames1 = frames[0]; + var frames2 = frames[1]; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + if (frame1.indexOf(ERROR_TAG) == -1) { + var match = frame1.match(/^\s*at\s+/); + if (match) { + sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + break; } - return instance; - }; + } + } + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + var frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES[frame1] = true; + } + else { + break; + } } } - // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. - var jasmineEnv = jasmine.getEnv(); - ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[methodName] = function (description, specDefinitions) { - return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + computeIgnoreFrames(); + /** + * @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 = /** @class */ (function () { + function ProxyZoneSpec(defaultSpecDelegate) { + if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } + this.defaultSpecDelegate = defaultSpecDelegate; + this.name = 'ProxyZone'; + this._delegateSpec = null; + this.properties = { 'ProxyZoneSpec': this }; + this.propertyKeys = null; + this.lastTaskState = null; + this.isNeedToTriggerHasTask = false; + this.tasks = []; + this.setDelegate(defaultSpecDelegate); + } + ProxyZoneSpec.get = function () { + return Zone.current.get('ProxyZoneSpec'); }; - }); - ['it', 'xit', 'fit'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (description, specDefinitions, timeout) { - arguments[1] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); + ProxyZoneSpec.isLoaded = function () { + return ProxyZoneSpec.get() instanceof ProxyZoneSpec; }; - }); - ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (specDefinitions, timeout) { - arguments[0] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); + ProxyZoneSpec.assertPresent = function () { + if (!ProxyZoneSpec.isLoaded()) { + throw new Error("Expected to be running in 'ProxyZone', but it was not found."); + } + return ProxyZoneSpec.get(); }; - }); - if (!disablePatchingJasmineClock) { - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableAutoFakeAsyncWhenClockPatched) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); + ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { + var _this = this; + var isNewDelegate = this._delegateSpec !== delegateSpec; + this._delegateSpec = delegateSpec; + this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); + this.propertyKeys = null; + if (delegateSpec && delegateSpec.properties) { + this.propertyKeys = Object.keys(delegateSpec.properties); + this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); + } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } + }; + ProxyZoneSpec.prototype.getDelegate = function () { + return this._delegateSpec; + }; + ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); + this.setDelegate(this.defaultSpecDelegate); + }; + ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + }; + ProxyZoneSpec.prototype.removeFromTasks = function (task) { + if (!this.tasks) { + return; + } + for (var i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; } } - return clock; }; - } - /** - * Gets a function wrapping the body of a Jasmine `describe` block to execute in a - * synchronous-only zone. - */ - function wrapDescribeInZone(describeBody) { - return function () { - return syncZone.run(describeBody, this, arguments); + ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { + if (this.tasks.length === 0) { + return ''; + } + var taskInfo = this.tasks.map(function (task) { + var dataInfo = task.data && + Object.keys(task.data) + .map(function (key) { + return key + ':' + task.data[key]; + }) + .join(','); + return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; + }); + var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; }; - } - function runInTestZone(testBody, applyThis, queueRunner, done) { - var isClockInstalled = !!jasmine[symbol('clockInstalled')]; - var testProxyZoneSpec = queueRunner.testProxyZoneSpec; - var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { - // auto run a fakeAsync - var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; - if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { - testBody = fakeAsyncModule.fakeAsync(testBody); + ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); } - } - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } - } + else { + return parentZoneDelegate.fork(targetZone, zoneSpec); + } + }; + ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { + if (this._delegateSpec && this._delegateSpec.onIntercept) { + return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); + } + else { + return parentZoneDelegate.intercept(targetZone, delegate, source); + } + }; + ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvoke) { + return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); + } + else { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + }; + ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + if (this._delegateSpec && this._delegateSpec.onHandleError) { + return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); + } + else { + return parentZoneDelegate.handleError(targetZone, error); + } + }; + ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } + if (this._delegateSpec && this._delegateSpec.onScheduleTask) { + return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.scheduleTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { + return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); + } + else { + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } + }; + ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onCancelTask) { + return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.cancelTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; + if (this._delegateSpec && this._delegateSpec.onHasTask) { + this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); + } + else { + delegate.hasTask(target, hasTaskState); + } + }; + return ProxyZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['ProxyZoneSpec'] = ProxyZoneSpec; /** - * 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` + * @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 wrapTestInZone(testBody) { - // The `done` callback is only passed through if the function expects at least one argument. - // Note we have to make a function with correct number of arguments, otherwise jasmine will - // think that all functions are sync or async. - return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this, this.queueRunner, done); - } : function () { - return runInTestZone(testBody, this, this.queueRunner); - })); - } - var QueueRunner = jasmine.QueueRunner; - jasmine.QueueRunner = (function (_super) { - __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs) { - var _this = this; - attrs.onComplete = (function (fn) { return function () { - // All functions are done, clear the test zone. - _this.testProxyZone = null; - _this.testProxyZoneSpec = null; - ambientZone.scheduleMicroTask('jasmine.onComplete', fn); - }; })(attrs.onComplete); - var nativeSetTimeout = _global['__zone_symbol__setTimeout']; - var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; - if (nativeSetTimeout) { - // should run setTimeout inside jasmine outside of zone - attrs.timeout = { - setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, - clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout - }; + var SyncTestZoneSpec = /** @class */ (function () { + function SyncTestZoneSpec(namePrefix) { + this.runZone = Zone.current; + this.name = 'syncTestZone for ' + namePrefix; + } + SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + case 'macroTask': + throw new Error("Cannot call " + task.source + " from within a sync test."); + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; } - // create a userContext to hold the queueRunner itself - // so we can access the testProxy in it/xit/beforeEach ... - if (jasmine.UserContext) { - if (!attrs.userContext) { - attrs.userContext = new jasmine.UserContext(); - } - attrs.userContext.queueRunner = this; + return task; + }; + return SyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; + (function (_global) { + 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'."); + jasmine['__zone_patch__'] = true; + var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (!SyncTestZoneSpec) + throw new Error('Missing: SyncTestZoneSpec'); + if (!ProxyZoneSpec) + throw new Error('Missing: ProxyZoneSpec'); + var ambientZone = Zone.current; + // Create a synchronous-only zone in which to run `describe` blocks in order to raise an + // error if any asynchronous operations are attempted inside of a `describe` but outside of + // a `beforeEach` or `it`. + var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; } - else { - if (!attrs.userContext) { - attrs.userContext = {}; - } - attrs.userContext.queueRunner = this; - } - // patch attrs.onException - var onException = attrs.onException; - attrs.onException = function (error) { - if (error && - error.message === - 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { - // jasmine timeout, we can make the error message more - // reasonable to tell what tasks are pending - var proxyZoneSpec = this && this.testProxyZoneSpec; - if (proxyZoneSpec) { - var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - try { - // try catch here in case error.message is not writable - error.message += pendingTasksInfo; + } + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. + var jasmineEnv = jasmine.getEnv(); + ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[methodName] = function (description, specDefinitions) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + }; + }); + ['it', 'xit', 'fit'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - catch (err) { + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); } } - if (onException) { - onException.call(this, error); - } + return clock; }; - _super.call(this, attrs); } - ZoneQueueRunner.prototype.execute = function () { - var _this = this; - var zone = Zone.current; - var isChildOfAmbientZone = false; - while (zone) { - if (zone === ambientZone) { - isChildOfAmbientZone = true; - break; + /** + * Gets a function wrapping the body of a Jasmine `describe` block to execute in a + * synchronous-only zone. + */ + function wrapDescribeInZone(describeBody) { + return function () { + return syncZone.run(describeBody, this, arguments); + }; + } + function runInTestZone(testBody, applyThis, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } - zone = zone.parent; - } - if (!isChildOfAmbientZone) - throw new Error('Unexpected Zone: ' + Zone.current.name); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - this.testProxyZoneSpec = new ProxyZoneSpec(); - this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); - if (!Zone.currentTask) { - // if we are not running in a task then if someone would register a - // element.addEventListener and then calling element.click() the - // addEventListener callback would think that it is the top most task and would - // drain the microtask queue on element.click() which would be incorrect. - // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); } - else { - _super.prototype.execute.call(this); - } - }; - return ZoneQueueRunner; - })(QueueRunner); -})(); - -/** - * @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 _global$1 = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; -var AsyncTestZoneSpec = /** @class */ (function () { - function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { - this.finishCallback = finishCallback; - this.failCallback = failCallback; - this._pendingMicroTasks = false; - this._pendingMacroTasks = false; - this._alreadyErrored = false; - this._isSync = false; - this.runZone = Zone.current; - this.unresolvedChainedPromiseCount = 0; - this.supportWaitUnresolvedChainedPromise = false; - this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { 'AsyncTestZoneSpec': this }; - this.supportWaitUnresolvedChainedPromise = - _global$1[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; - } - AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { - return this.unresolvedChainedPromiseCount > 0; - }; - AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { - var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || - (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { - // We do this because we would like to catch unhandled rejected promises. - this.runZone.run(function () { - setTimeout(function () { - if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this.finishCallback(); - } - }, 0); - }); - } - }; - AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; - if (patchPromiseForTest) { - patchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; - if (unPatchPromiseForTest) { - unPatchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise - if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { - // chained promise is being scheduled - this.unresolvedChainedPromiseCount--; + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } - } - return delegate.scheduleTask(target, task); - }; - AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.invokeTask(target, task, applyThis, applyArgs); - }; - AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.cancelTask(target, task); - }; - // 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. - // updated by(JiaLiPassion), only call finish callback when no task - // was scheduled/invoked/canceled. - AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - try { - this._isSync = true; - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - finally { - var afterTaskCounts = parentZoneDelegate._taskCounts; - if (this._isSync) { - this._finishCallbackIfDone(); + else { + return testProxyZone.run(testBody, applyThis); + } + } + /** + * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to + * execute in a ProxyZone zone. + * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` + */ + function wrapTestInZone(testBody) { + // The `done` callback is only passed through if the function expects at least one argument. + // Note we have to make a function with correct number of arguments, otherwise jasmine will + // think that all functions are sync or async. + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this, this.queueRunner, done); + } : function () { + return runInTestZone(testBody, this, this.queueRunner); + })); + } + var QueueRunner = jasmine.QueueRunner; + jasmine.QueueRunner = (function (_super) { + __extends(ZoneQueueRunner, _super); + function ZoneQueueRunner(attrs) { + var _this = this; + attrs.onComplete = (function (fn) { return function () { + // All functions are done, clear the test zone. + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + }; })(attrs.onComplete); + var nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; + var nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); + } + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } + } + } + if (onException) { + onException.call(this, error); + } + }; + _super.call(this, attrs); } - } - }; - AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - // Let the parent try to handle the error. - var result = parentZoneDelegate.handleError(targetZone, error); - if (result) { - this.failCallback(error); - this._alreadyErrored = true; - } - return false; - }; - AsyncTestZoneSpec.prototype.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(); - } - }; - AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); - return AsyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; - -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { + ZoneQueueRunner.prototype.execute = function () { + var _this = this; + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); + if (!Zone.currentTask) { + // if we are not running in a task then if someone would register a + // element.addEventListener and then calling element.click() the + // addEventListener callback would think that it is the top most task and would + // drain the microtask queue on element.click() which would be incorrect. + // For this reason we always force a task when running jasmine tests. + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); + } + else { + _super.prototype.execute.call(this); + } + }; + return ZoneQueueRunner; + })(QueueRunner); + })(commonjsGlobal); /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. + * @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[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; + (function (_global) { + var AsyncTestZoneSpec = /** @class */ (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this._isSync = false; + this.runZone = Zone.current; + this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; + this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; + } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { + _this.finishCallback(); + } + }, 0); + }); + } + }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; } - else { - done.fail(err); + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + this._isSync = true; + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } + } + }; + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this.failCallback(error); + this._alreadyErrored = true; + } + return false; + }; + AsyncTestZoneSpec.prototype.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; + }()); + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + })(commonjsGlobal); + /** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); }); }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - testZoneSpec.patchPromiseForTest(); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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 __read = (undefined && undefined.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (undefined && undefined.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -(function (global) { - var OriginalDate = global.Date; - var FakeDate = /** @class */ (function () { - function FakeDate() { - if (arguments.length === 0) { - var d = new OriginalDate(); - d.setTime(FakeDate.now()); - return d; - } - else { - var args = Array.prototype.slice.call(arguments); - return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); - } + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); } - FakeDate.now = function () { - var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncTestZoneSpec) { - return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + }); + /** + * @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) { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, [void 0].concat(args)))(); + } } - return OriginalDate.now.apply(this, arguments); - }; - return FakeDate; - }()); - FakeDate.UTC = OriginalDate.UTC; - FakeDate.parse = OriginalDate.parse; - // keep a reference for zone patched timer function - var timers = { - setTimeout: global.setTimeout, - setInterval: global.setInterval, - clearTimeout: global.clearTimeout, - clearInterval: global.clearInterval - }; - var Scheduler = /** @class */ (function () { - function Scheduler() { - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - this._schedulerQueue = []; - // Current simulated time in millis. - this._currentTime = 0; - // Current real time in millis. - this._currentRealTime = OriginalDate.now(); - } - Scheduler.prototype.getCurrentTime = function () { - return this._currentTime; - }; - Scheduler.prototype.getCurrentRealTime = function () { - return this._currentRealTime; - }; - Scheduler.prototype.setCurrentRealTime = function (realTime) { - this._currentRealTime = realTime; + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + return FakeDate; + }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval }; - Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { - if (args === void 0) { args = []; } - if (isPeriodic === void 0) { isPeriodic = false; } - if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } - if (id === void 0) { id = -1; } - var currentId = id < 0 ? Scheduler.nextId++ : id; - var endTime = this._currentTime + delay; - // Insert so that scheduler queue remains sorted by end time. - var newEntry = { - endTime: endTime, - id: currentId, - func: cb, - args: args, - delay: delay, - isPeriodic: isPeriodic, - isRequestAnimationFrame: isRequestAnimationFrame + var Scheduler = /** @class */ (function () { + function Scheduler() { + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = OriginalDate.now(); + } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; }; - var i = 0; - for (; i < this._schedulerQueue.length; i++) { - var currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; + Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { + if (args === void 0) { args = []; } + if (isPeriodic === void 0) { isPeriodic = false; } + if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } + if (id === void 0) { id = -1; } + var currentId = id < 0 ? Scheduler.nextId++ : id; + var endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + var newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + var i = 0; + for (; i < this._schedulerQueue.length; i++) { + var currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } + } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + }; + Scheduler.prototype.removeScheduledFunctionWithId = function (id) { + for (var i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; + } + } + }; + Scheduler.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + var finalTime = this._currentTime + millis; + var lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + var current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; + } + else { + // Time to run scheduled function. Remove it from the head of queue. + var current_1 = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current_1.endTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } } - } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - }; - Scheduler.prototype.removeScheduledFunctionWithId = function (id) { - for (var i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; + lastCurrentTime = this._currentTime; + this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); } - } - }; - Scheduler.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - var finalTime = this._currentTime + millis; - var lastCurrentTime = 0; - if (this._schedulerQueue.length === 0 && doTick) { - doTick(millis); - return; - } - while (this._schedulerQueue.length > 0) { - var current = this._schedulerQueue[0]; - if (finalTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. - break; + }; + Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { + if (limit === void 0) { limit = 20; } + if (flushPeriodic === void 0) { flushPeriodic = false; } + if (flushPeriodic) { + return this.flushPeriodic(doTick); } else { - // Time to run scheduled function. Remove it from the head of queue. - var current_1 = this._schedulerQueue.shift(); + return this.flushNonPeriodic(limit, doTick); + } + }; + Scheduler.prototype.flushPeriodic = function (doTick) { + if (this._schedulerQueue.length === 0) { + return 0; + } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + var startTime = this._currentTime; + var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + }; + Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { + var startTime = this._currentTime; + var lastCurrentTime = 0; + var count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error('flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) + .length === 0) { + break; + } + var current = this._schedulerQueue.shift(); lastCurrentTime = this._currentTime; - this._currentTime = current_1.endTime; + this._currentTime = current.endTime; if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + var retval = current.func.apply(global, current.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; } } - } - lastCurrentTime = this._currentTime; - this._currentTime = finalTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - }; - Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { - if (limit === void 0) { limit = 20; } - if (flushPeriodic === void 0) { flushPeriodic = false; } - if (flushPeriodic) { - return this.flushPeriodic(doTick); - } - else { - return this.flushNonPeriodic(limit, doTick); - } - }; - Scheduler.prototype.flushPeriodic = function (doTick) { - if (this._schedulerQueue.length === 0) { - return 0; - } - // Find the last task currently queued in the scheduler queue and tick - // till that time. - var startTime = this._currentTime; - var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; - this.tick(lastTask.endTime - startTime, doTick); - return this._currentTime - startTime; - }; - Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { - var startTime = this._currentTime; - var lastCurrentTime = 0; - var count = 0; - while (this._schedulerQueue.length > 0) { - count++; - if (count > limit) { - throw new Error('flush failed after reaching the limit of ' + limit + - ' tasks. Does your code use a polling timeout?'); - } - // flush only non-periodic timers. - // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. - if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) - .length === 0) { - break; - } - var current = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current.endTime; - if (doTick) { - // Update any secondary schedulers like Jasmine mock Date. - doTick(this._currentTime - lastCurrentTime); - } - var retval = current.func.apply(global, current.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } - return this._currentTime - startTime; - }; + return this._currentTime - startTime; + }; + return Scheduler; + }()); // Next scheduler id. Scheduler.nextId = 1; - return Scheduler; - }()); - var FakeAsyncTestZoneSpec = /** @class */ (function () { - function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { - if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } - this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; - this.macroTaskOptions = macroTaskOptions; - this._scheduler = new Scheduler(); - this._microtasks = []; - this._lastError = null; - this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; - this.pendingPeriodicTimers = []; - this.pendingTimers = []; - this.patchDateLocked = false; - this.properties = { 'FakeAsyncTestZoneSpec': this }; - this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakeAsyncTestSpec - // user can also define macroTaskOptions by define a global variable. - if (!this.macroTaskOptions) { - this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; - } - } - FakeAsyncTestZoneSpec.assertInZone = function () { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - }; - FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { - var _this = this; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; + var FakeAsyncTestZoneSpec = /** @class */ (function () { + function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { + if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } + this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; + this.macroTaskOptions = macroTaskOptions; + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.patchDateLocked = false; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + } + } + FakeAsyncTestZoneSpec.assertInZone = function () { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); } - fn.apply(global, args); - if (_this._lastError === null) { // Success - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); + }; + FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { + var _this = this; + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + fn.apply(global, args); + if (_this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + _this.flushMicrotasks(); + } + else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } } - // Flush microtasks only on success. - _this.flushMicrotasks(); + // Return true if there were no errors, false otherwise. + return _this._lastError === null; + }; + }; + FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { + var index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); } - else { // Failure - if (completers.onError != null) { - completers.onError.apply(global); + }; + FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { + var _this = this; + return function () { + // Requeue the timer callback if it's not been canceled. + if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { + _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); } + }; + }; + FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { + if (isTimer === void 0) { isTimer = true; } + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); + } + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { + var id = Scheduler.nextId; + var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + var cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { + var error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } + if (global['Date'] === FakeDate) { + // already patched + return; } - // Return true if there were no errors, false otherwise. - return _this._lastError === null; + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; - }; - FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { - var index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); - } - }; - FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } }; - }; - FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { - var _this = this; - return function () { - // Requeue the timer callback if it's not been canceled. - if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { - _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; } }; - }; - FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); }; - }; - FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { - if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(Scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); - var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); - if (isTimer) { - this.pendingTimers.push(id); - } - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = Scheduler.nextId; - var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; - var cb = this._fnAndFlush(fn, completers); - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args, true); - this.pendingPeriodicTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { - var error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - }; - FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { - return this._scheduler.getCurrentTime(); - }; - FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { - return this._scheduler.getCurrentRealTime(); - }; - FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { - this._scheduler.setCurrentRealTime(realTime); - }; - FakeAsyncTestZoneSpec.patchDate = function () { - if (!!global[Zone.__symbol__('disableDatePatching')]) { - // we don't want to patch global Date - // because in some case, global Date - // is already being patched, we need to provide - // an option to let user still use their - // own version of Date. - return; - } - if (global['Date'] === FakeDate) { - // already patched - return; - } - global['Date'] = FakeDate; - FakeDate.prototype = OriginalDate.prototype; - // try check and reset timers - // because jasmine.clock().install() may - // have replaced the global timer - FakeAsyncTestZoneSpec.checkTimerPatch(); - }; - FakeAsyncTestZoneSpec.resetDate = function () { - if (global['Date'] === FakeDate) { - global['Date'] = OriginalDate; - } - }; - FakeAsyncTestZoneSpec.checkTimerPatch = function () { - if (global.setTimeout !== timers.setTimeout) { - global.setTimeout = timers.setTimeout; - global.clearTimeout = timers.clearTimeout; - } - if (global.setInterval !== timers.setInterval) { - global.setInterval = timers.setInterval; - global.clearInterval = timers.clearInterval; - } - }; - FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { - this.patchDateLocked = true; - FakeAsyncTestZoneSpec.patchDate(); - }; - FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { - this.patchDateLocked = false; - FakeAsyncTestZoneSpec.resetDate(); - }; - FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - }; - FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { - var _this = this; - FakeAsyncTestZoneSpec.assertInZone(); - var flushErrors = function () { - if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - _this._resetLastErrorAndThrow(); + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; + FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); } }; - while (this._microtasks.length > 0) { - var microtask = this._microtasks.shift(); - microtask.func.apply(microtask.target, microtask.args); - } - flushErrors(); - }; - FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - return elapsed; - }; - FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - var args = task.data && task.data.args; - // should pass additional arguments to callback if have any - // currently we know process.nextTick will have such additional - // arguments - var additionalArgs = void 0; - if (args) { - var callbackIndex = task.data.cbIdx; - if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); - } + FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { + var _this = this; + FakeAsyncTestZoneSpec.assertInZone(); + var flushErrors = function () { + if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + _this._resetLastErrorAndThrow(); } - this._microtasks.push({ - func: task.invoke, - args: additionalArgs, - target: task.data && task.data.target - }); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'setImmediate': - task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); - break; - case 'setInterval': - task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'XMLHttpRequest.send': - throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + - task.data['url']); - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. - // (60 frames per second) - task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); - break; - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var args_1 = task.data && task.data['args']; - var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; - var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; - if (!!macroTaskOption.isPeriodic) { - // periodic macroTask, use setInterval to simulate - task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data.isPeriodic = true; - } - else { - // not periodic, use setTimeout to simulate - task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); - } - break; + }; + while (this._microtasks.length > 0) { + var microtask = this._microtasks.shift(); + microtask.func.apply(microtask.target, microtask.args); + } + flushErrors(); + }; + FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + }; + FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + var args = task.data && task.data.args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + var additionalArgs = void 0; + if (args) { + var callbackIndex = task.data.cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } - throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && task.data.target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; + case 'setInterval': + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + + task.data['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var args_1 = task.data && task.data['args']; + var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; + var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data.isPeriodic = true; + } + else { + // not periodic, use setTimeout to simulate + task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + } + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var handleId = task.data['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); + } + }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - switch (task.source) { - case 'setTimeout': - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data['handleId']); - case 'setInterval': - return this._clearInterval(task.data['handleId']); - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var handleId = task.data['handleId']; - return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : - this._clearTimeout(handleId); + } + }; + FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { + if (!this.macroTaskOptions) { + return null; + } + for (var i = 0; i < this.macroTaskOptions.length; i++) { + var macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; } - return delegate.cancelTask(target, task); - } - }; - FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { - try { - FakeAsyncTestZoneSpec.patchDate(); - return delegate.invoke(target, callback, applyThis, applyArgs, source); - } - finally { - if (!this.patchDateLocked) { - FakeAsyncTestZoneSpec.resetDate(); } - } - }; - FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { - if (!this.macroTaskOptions) { return null; - } - for (var i = 0; i < this.macroTaskOptions.length; i++) { - var macroTaskOption = this.macroTaskOptions[i]; - if (macroTaskOption.source === task.source) { - return macroTaskOption; - } - } - return null; - }; - FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - this._lastError = error; - return false; // Don't propagate error to parent zone. - }; - return FakeAsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } + }; + FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + }; + return FakeAsyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; + })(commonjsGlobal); /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. + * @license + * Copyright Google Inc. All Rights Reserved. * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental + * 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 fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); try { - res = fn.apply(this, args); - flushMicrotasks(); + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; } finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); + resetFakeAsyncZone(); } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); - } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } + }; } - return _fakeAsyncTestZoneSpec; - } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; + }); /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. * - * @experimental + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } + Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; + }); /** - * Discard all remaining periodic tasks. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } /** - * Flush any pending microtasks. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - -/** - * @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 - */ -/** - * Promise for async/fakeAsync zoneSpec test - * can support async operation which not supported by zone.js - * such as - * it ('test jsonp in AsyncZone', async() => { - * new Promise(res => { - * jsonp(url, (data) => { - * // success callback - * res(data); - * }); - * }).then((jsonpResult) => { - * // get jsonp result. - * - * // user will expect AsyncZoneSpec wait for - * // then, but because jsonp is not zone aware - * // AsyncZone will finish before then is called. - * }); - * }); - */ -Zone.__load_patch('promisefortest', function (global, Zone, api) { - var symbolState = api.symbol('state'); - var UNRESOLVED = null; - var symbolParentUnresolved = api.symbol('parentUnresolved'); - // patch Promise.prototype.then to keep an internal - // number for tracking unresolved chained promise - // we will decrease this number when the parent promise - // being resolved/rejected and chained promise was - // scheduled as a microTask. - // so we can know such kind of chained promise still - // not resolved in AsyncTestZone - Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - return; - } - oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; - Promise.prototype.then = function () { - var chained = oriThen.apply(this, arguments); - if (this[symbolState] === UNRESOLVED) { - // parent promise is unresolved. - var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); - if (asyncTestZoneSpec) { - asyncTestZoneSpec.unresolvedChainedPromiseCount++; - chained[symbolParentUnresolved] = true; - } - } - return chained; - }; - }; - Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { - // restore origin then - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - Promise.prototype.then = oriThen; - Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; - } - }; -}); - -/** - * @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 - */ -// load test related files into bundle in correct order - -/** - * @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 - */ -// load test related files into bundle - -}))); +})); +//# sourceMappingURL=zone-testing-bundle-rollup.umd.js.map diff --git a/dist/zone-testing-bundle.min.js b/dist/zone-testing-bundle.min.js new file mode 100755 index 000000000..001c20fcc --- /dev/null +++ b/dist/zone-testing-bundle.min.js @@ -0,0 +1,228 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; +/** + * @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(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=e.__Zone_symbol_prefix||"__zone_symbol__";function i(e){return o+e}var a=!0===e[i("forceDuplicateZoneCheck")];if(e.Zone){if(a||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var s=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==O.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return I},enumerable:!0,configurable:!0}),t.__load_patch=function(o,i){if(O.hasOwnProperty(o)){if(a)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var s="Zone:"+o;n(s),O[o]=i(e,t,C),r(s,s)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{j=j.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||_).name+"; Execution: "+this.name+")");if(e.state!==k||e.type!==D&&e.type!==Z){var r=e.state!=E;r&&e._transitionTo(E,b),e.runCount++;var o=I;I=e,j={parent:j,zone:this};try{e.type==Z&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==k&&e.state!==S&&(e.type==D||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,E):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(k,E,k))),j=j.parent,I=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(T,k);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(S,T,k),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==T&&e._transitionTo(b,T),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(P,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(Z,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(D,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||_).name+"; Execution: "+this.name+")");e._transitionTo(w,b,E);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(S,w),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(k,w),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})},e}(),h=function(){function t(n,r,o,i,a,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=i,this.scheduleFn=a,this.cancelFn=s,this.callback=o;var c=this;this.invoke=n===D&&i&&i.useG?t.invokeTask:function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),A++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==A&&y(),A--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(k,T)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==k&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),p=i("setTimeout"),f=i("Promise"),d=i("then"),v=[],g=!1;function m(t){if(0===A&&0===v.length)if(c||e[f]&&(c=e[f].resolve(0)),c){var n=c[d];n||(n=c.then),n.call(c,y)}else e[p](y,0);t&&v.push(t)}function y(){if(!g){for(g=!0;v.length;){var e=v;v=[];for(var t=0;t=0;n--)"function"==typeof e[n]&&(e[n]=f(e[n],t+"_"+n));return e}function b(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in y)&&void 0!==y.process&&"[object process]"==={}.toString.call(y.process),S=!w&&!E&&!(!g||!m.HTMLElement),P=void 0!==y.process&&"[object process]"==={}.toString.call(y.process)&&!E&&!(!g||!m.HTMLElement),Z={},D=function(e){if(e=e||y.event){var t=Z[e.type];t||(t=Z[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||y,o=r[t];return S&&r===m&&"error"===e.type?!0===(n=o&&o.call(this,e.message,e.filename,e.lineno,e.colno,e.error))&&e.preventDefault():null==(n=o&&o.apply(this,arguments))||n||e.preventDefault(),n}};function O(e,r,o){var i=t(e,r);if(!i&&o&&t(o,r)&&(i={enumerable:!0,configurable:!0}),i&&i.configurable){var a=v("on"+r+"patched");if(!e.hasOwnProperty(a)||!e[a]){delete i.writable,delete i.value;var s=i.get,c=i.set,u=r.substr(2),l=Z[u];l||(l=Z[u]=v("ON_PROPERTY"+u)),i.set=function(t){var n=this;n||e!==y||(n=y),n&&(n[l]&&n.removeEventListener(u,D),c&&c.apply(n,k),"function"==typeof t?(n[l]=t,n.addEventListener(u,D,!1)):n[l]=null)},i.get=function(){var t=this;if(t||e!==y||(t=y),!t)return null;var n=t[l];if(n)return n;if(s){var o=s&&s.call(this);if(o)return i.set.call(this,o),"function"==typeof t[_]&&t.removeAttribute(r),o}return null},n(e,r,i),e[a]=!0}}}function C(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[i.cbIdx]?d(i.name,r[i.cbIdx],i,o):e.apply(t,r)}})}function x(e,t){e[v("OriginalDelegate")]=t}var F=!1,M=!1;function L(){if(F)return M;F=!0;try{var e=m.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(M=!0)}catch(e){}return M} +/** + * @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.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),i=function i(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var s=e[r];if(s)return t.call(s)}if(this===Error){var c=e[o];if(c)return t.call(c)}}return t.call(this)};i[n]=t,Function.prototype.toString=i;var a=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":a.call(this)}}); +/** + * @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 H=!1;if("undefined"!=typeof window)try{var N=Object.defineProperty({},"passive",{get:function(){H=!0}});window.addEventListener("test",N,N),window.removeEventListener("test",N,N)}catch(e){H=!1}var q={useG:!0},U={},G={},W=new RegExp("^"+p+"(\\w+)(true|false)$"),B=v("propagationStopped");function Q(e,t,n){var o=n&&n.add||a,i=n&&n.rm||s,c=n&&n.listeners||"eventListeners",u=n&&n.rmAll||"removeAllListeners",f=v(o),d="."+o+":",g="prependListener",m="."+g+":",y=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;o&&"object"==typeof o&&o.once&&t[i].call(t,n.type,e.originalDelegate?e.originalDelegate:e.callback,o)}},_=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[U[t.type][h]];if(r)if(1===r.length)y(r[0],n,t);else for(var o=r.slice(),i=0;i1?new i(t,n):new i(t),u=e.ObjectGetOwnPropertyDescriptor(c,"onmessage");return u&&!1===u.configurable?(a=e.ObjectCreate(c),s=c,[r,o,"send","close"].forEach(function(t){a[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var i=n.length>0?n[0]:void 0;if(i){var s=Zone.__symbol__("ON_PROPERTY"+i);c[s]=a[s]}}return c[t].apply(c,n)}})):a=c,e.patchOnProperties(a,["close","error","message","open"],s),a};var a=t.WebSocket;for(var s in i)a[s]=i[s]}(e,t),Zone[e.symbol("patchEvents")]=!0}}Zone.__load_patch("util",function(e,r,c){c.patchOnProperties=C,c.patchMethod=R,c.bindArguments=T,c.patchMacroTask=z;var u=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[u]=e[d]),e[u]&&(r[u]=r[d]=e[u]),c.patchEventPrototype=V,c.patchEventTarget=Q,c.isIEOrEdge=L,c.ObjectDefineProperty=n,c.ObjectGetOwnPropertyDescriptor=t,c.ObjectCreate=o,c.ArraySlice=i,c.patchClass=I,c.wrapWithCurrentZone=f,c.filterProperties=ge,c.attachOriginToPatched=x,c._redefineProperty=ne,c.patchCallbacks=K,c.getGlobalObjects=function(){return{globalSources:G,zoneSymbolEventNames:U,eventNames:ve,isBrowser:S,isMix:P,isNode:w,TRUE_STR:l,FALSE_STR:h,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:a,REMOVE_EVENT_LISTENER_STR:s}}}), +/** + * @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(e){e[Zone.__symbol__("legacyPatch")]=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function r(e,t){var n=t.getGlobalObjects();(n.isBrowser||n.isMix)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])} +/** + * @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 + */(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){_e(e,n),ke(n,e)})}}("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}); +/** + * @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 Te=v("zoneTask");function be(e,t,n,r){var o=null,i=null;n+=r;var a={};function s(t){var n=t.data;return n.args[0]=function r(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete a[n.handleId]:n.handleId&&(n.handleId[Te]=null))}},n.handleId=o.apply(e,n.args),t}function c(e){return i(e.data.handleId)}o=R(e,t+=r,function(n){return function(o,i){if("function"==typeof i[0]){var u=d(t,i[0],{isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?i[1]||0:void 0,args:i},s,c);if(!u)return u;var l=u.data.handleId;return"number"==typeof l?a[l]=u:l&&(l[Te]=u),l&&l.ref&&l.unref&&"function"==typeof l.ref&&"function"==typeof l.unref&&(u.ref=l.ref.bind(l),u.unref=l.unref.bind(l)),"number"==typeof l||l?l:u}return n.apply(e,i)}}),i=R(e,n,function(t){return function(n,r){var o,i=r[0];"number"==typeof i?o=a[i]:(o=i&&i[Te])||(o=i),o&&"string"==typeof o.type?"notScheduled"!==o.state&&(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&("number"==typeof i?delete a[i]:i&&(i[Te]=null),o.zone.cancelTask(o)):t.apply(e,r)}})} +/** + * @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 + */ +/** + * @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 Ee(e,t){if(!Zone[t.symbol("patchEventTarget")]){for(var n=t.getGlobalObjects(),r=n.eventNames,o=n.zoneSymbolEventNames,i=n.TRUE_STR,a=n.FALSE_STR,s=n.ZONE_SYMBOL_PREFIX,c=0;c0){var i=e.invoke;e.invoke=function(){for(var r=o[t.__symbol__("loadfalse")],a=0;a0){var o=Zone.currentTask,i=o&&o.data&&o.data.__creationTrace__||[];(i=[new Oe].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),r.data||(r.data={}),"eventTask"===r.type&&(r.data=Object.assign({},r.data)),r.data.__creationTrace__=i}return e.scheduleTask(n,r)},onHandleError:function(e,t,n,r){if(Error.stackTraceLimit>0){var o=Zone.currentTask||r.task;if(r instanceof Error&&o){var i=Fe(o.data&&o.data.__creationTrace__,r.stack);try{r.stack=r.longStack=i}catch(e){}}}return e.handleError(n,r)}},function Me(){if(!(Error.stackTraceLimit<=0)){var e=[];!function e(t,n){n>0&&(t.push(ze((new Oe).error)),e(t,n-1))}(e,2);for(var t=e[0],n=e[1],r=0;r0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,t&&"function"==typeof t.getTime?[t.getTime()]:arguments)}return n.apply(this,arguments)},s&&["install","uninstall"].forEach(function(t){var n=e[i(t)]=e[t];e[t]=function(){if(!Zone.FakeAsyncTestZoneSpec)return n.apply(this,arguments);jasmine[i("clockInstalled")]="install"===t}})}return e}}function h(e,t,n,r){var o=!!jasmine[i("clockInstalled")],a=n.testProxyZone;if(o&&s){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return r?a.run(e,t,[r]):a.run(e,t)}function p(e){return e&&(e.length?function(t){return h(e,this,this.queueRunner,t)}:function(){return h(e,this,this.queueRunner)})}var f=jasmine.QueueRunner;jasmine.QueueRunner=function(t){function o(n){var o,i=this;n.onComplete=(o=n.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,r.scheduleMicroTask("jasmine.onComplete",o)});var a=e[Zone.__symbol__("setTimeout")],s=e[Zone.__symbol__("clearTimeout")];a&&(n.timeout={setTimeout:a||e.setTimeout,clearTimeout:s||e.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var t=this&&this.testProxyZoneSpec;if(t){var n=t.getAndClearPendingTasksInfo();try{e.message+=n}catch(e){}}}c&&c.call(this,e)},t.call(this,n)}return function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);function r(){this.constructor=e}e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(o,t),o.prototype.execute=function(){for(var e=this,o=Zone.current,i=!1;o;){if(o===r){i=!0;break}o=o.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new n,this.testProxyZone=r.fork(this.testProxyZoneSpec),Zone.currentTask?t.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return f.prototype.execute.call(e)})},o}(f)}(e), +/** + * @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(e){var t=function(){function t(t,n,r){this.finishCallback=t,this.failCallback=n,this._pendingMicroTasks=!1,this._pendingMacroTasks=!1,this._alreadyErrored=!1,this._isSync=!1,this.runZone=Zone.current,this.unresolvedChainedPromiseCount=0,this.supportWaitUnresolvedChainedPromise=!1,this.name="asyncTestZone for "+r,this.properties={AsyncTestZoneSpec:this},this.supportWaitUnresolvedChainedPromise=!0===e[Zone.__symbol__("supportWaitUnResolvedChainedPromise")]}return t.prototype.isUnresolvedChainedPromisePending=function(){return this.unresolvedChainedPromiseCount>0},t.prototype._finishCallbackIfDone=function(){var e=this;this._pendingMicroTasks||this._pendingMacroTasks||this.supportWaitUnresolvedChainedPromise&&this.isUnresolvedChainedPromisePending()||this.runZone.run(function(){setTimeout(function(){e._alreadyErrored||e._pendingMicroTasks||e._pendingMacroTasks||e.finishCallback()},0)})},t.prototype.patchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("patchPromiseForTest")];e&&e()}},t.prototype.unPatchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("unPatchPromiseForTest")];e&&e()}},t.prototype.onScheduleTask=function(e,n,r,o){return"eventTask"!==o.type&&(this._isSync=!1),"microTask"===o.type&&o.data&&o.data instanceof Promise&&!0===o.data[t.symbolParentUnresolved]&&this.unresolvedChainedPromiseCount--,e.scheduleTask(r,o)},t.prototype.onInvokeTask=function(e,t,n,r,o,i){return"eventTask"!==r.type&&(this._isSync=!1),e.invokeTask(n,r,o,i)},t.prototype.onCancelTask=function(e,t,n,r){return"eventTask"!==r.type&&(this._isSync=!1),e.cancelTask(n,r)},t.prototype.onInvoke=function(e,t,n,r,o,i,a){try{return this._isSync=!0,e.invoke(n,r,o,i,a)}finally{this._isSync&&this._finishCallbackIfDone()}},t.prototype.onHandleError=function(e,t,n,r){return e.handleError(n,r)&&(this.failCallback(r),this._alreadyErrored=!0),!1},t.prototype.onHasTask=function(e,t,n,r){e.hasTask(n,r),"microTask"==r.change?(this._pendingMicroTasks=r.microTask,this._finishCallbackIfDone()):"macroTask"==r.change&&(this._pendingMacroTasks=r.macroTask,this._finishCallbackIfDone())},t}();t.symbolParentUnresolved=Zone.__symbol__("parentUnresolved"),Zone.AsyncTestZoneSpec=t}(e), +/** + * @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.__load_patch("asynctest",function(e,t,n){function r(e,n,r,o){var i=t.current,a=t.AsyncTestZoneSpec;if(void 0===a)throw new Error("AsyncTestZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/async-test.js");var s=t.ProxyZoneSpec;if(void 0===s)throw new Error("ProxyZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/proxy.js");var c=s.get();s.assertPresent();var u=t.current.getZoneWith("ProxyZoneSpec"),l=c.getDelegate();return u.parent.run(function(){var e=new a(function(){c.getDelegate()==e&&c.setDelegate(l),e.unPatchPromiseForTest(),i.run(function(){r()})},function(t){c.getDelegate()==e&&c.setDelegate(l),e.unPatchPromiseForTest(),i.run(function(){o(t)})},"test");c.setDelegate(e),e.patchPromiseForTest()}),t.current.runGuarded(e,n)}t[n.symbol("asyncTest")]=function t(n){return e.jasmine?function(e){e||((e=function(){}).fail=function(e){throw e}),r(n,this,e,function(t){if("string"==typeof t)return e.fail(new Error(t));e.fail(t)})}:function(){var e=this;return new Promise(function(t,o){r(n,e,t,o)})}}}), +/** + * @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(e){var t=e.Date,n=function(){function e(){if(0===arguments.length){var n=new t;return n.setTime(e.now()),n}var r=Array.prototype.slice.call(arguments);return new(t.bind.apply(t,[void 0].concat(r)))}return e.now=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.getCurrentRealTime()+e.getCurrentTime():t.now.apply(this,arguments)},e}();n.UTC=t.UTC,n.parse=t.parse;var r={setTimeout:e.setTimeout,setInterval:e.setInterval,clearTimeout:e.clearTimeout,clearInterval:e.clearInterval},o=function(){function n(){this._schedulerQueue=[],this._currentTime=0,this._currentRealTime=t.now()}return n.prototype.getCurrentTime=function(){return this._currentTime},n.prototype.getCurrentRealTime=function(){return this._currentRealTime},n.prototype.setCurrentRealTime=function(e){this._currentRealTime=e},n.prototype.scheduleFunction=function(e,t,r,o,i,a){void 0===r&&(r=[]),void 0===o&&(o=!1),void 0===i&&(i=!1),void 0===a&&(a=-1);for(var s=a<0?n.nextId++:a,c={endTime:this._currentTime+t,id:s,func:e,args:r,delay:t,isPeriodic:o,isRequestAnimationFrame:i},u=0;u0&&!(r0;){if(++i>t)throw new Error("flush failed after reaching the limit of "+t+" tasks. Does your code use a polling timeout?");if(0===this._schedulerQueue.filter(function(e){return!e.isPeriodic&&!e.isRequestAnimationFrame}).length)break;var a=this._schedulerQueue.shift();if(o=this._currentTime,this._currentTime=a.endTime,n&&n(this._currentTime-o),!a.func.apply(e,a.args))break}return this._currentTime-r},n}();o.nextId=1;var i=function(){function i(t,n,r){void 0===n&&(n=!1),this.trackPendingRequestAnimationFrame=n,this.macroTaskOptions=r,this._scheduler=new o,this._microtasks=[],this._lastError=null,this._uncaughtPromiseErrors=Promise[Zone.__symbol__("uncaughtPromiseErrors")],this.pendingPeriodicTimers=[],this.pendingTimers=[],this.patchDateLocked=!1,this.properties={FakeAsyncTestZoneSpec:this},this.name="fakeAsyncTestZone for "+t,this.macroTaskOptions||(this.macroTaskOptions=e[Zone.__symbol__("FakeAsyncTestMacroTask")])}return i.assertInZone=function(){if(null==Zone.current.get("FakeAsyncTestZoneSpec"))throw new Error("The code should be running in the fakeAsync zone to call this function")},i.prototype._fnAndFlush=function(t,n){var r=this;return function(){for(var o=[],i=0;i-1&&e.splice(n,1)},i.prototype._dequeueTimer=function(e){var t=this;return function(){i._removeTimer(t.pendingTimers,e)}},i.prototype._requeuePeriodicTimer=function(e,t,n,r){var o=this;return function(){-1!==o.pendingPeriodicTimers.indexOf(r)&&o._scheduler.scheduleFunction(e,t,n,!0,!1,r)}},i.prototype._dequeuePeriodicTimer=function(e){var t=this;return function(){i._removeTimer(t.pendingPeriodicTimers,e)}},i.prototype._setTimeout=function(e,t,n,r){void 0===r&&(r=!0);var i=this._dequeueTimer(o.nextId),a=this._fnAndFlush(e,{onSuccess:i,onError:i}),s=this._scheduler.scheduleFunction(a,t,n,!1,!r);return r&&this.pendingTimers.push(s),s},i.prototype._clearTimeout=function(e){i._removeTimer(this.pendingTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},i.prototype._setInterval=function(e,t,n){var r=o.nextId,i={onSuccess:null,onError:this._dequeuePeriodicTimer(r)},a=this._fnAndFlush(e,i);return i.onSuccess=this._requeuePeriodicTimer(a,t,n,r),this._scheduler.scheduleFunction(a,t,n,!0),this.pendingPeriodicTimers.push(r),r},i.prototype._clearInterval=function(e){i._removeTimer(this.pendingPeriodicTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},i.prototype._resetLastErrorAndThrow=function(){var e=this._lastError||this._uncaughtPromiseErrors[0];throw this._uncaughtPromiseErrors.length=0,this._lastError=null,e},i.prototype.getCurrentTime=function(){return this._scheduler.getCurrentTime()},i.prototype.getCurrentRealTime=function(){return this._scheduler.getCurrentRealTime()},i.prototype.setCurrentRealTime=function(e){this._scheduler.setCurrentRealTime(e)},i.patchDate=function(){e[Zone.__symbol__("disableDatePatching")]||e.Date!==n&&(e.Date=n,n.prototype=t.prototype,i.checkTimerPatch())},i.resetDate=function(){e.Date===n&&(e.Date=t)},i.checkTimerPatch=function(){e.setTimeout!==r.setTimeout&&(e.setTimeout=r.setTimeout,e.clearTimeout=r.clearTimeout),e.setInterval!==r.setInterval&&(e.setInterval=r.setInterval,e.clearInterval=r.clearInterval)},i.prototype.lockDatePatch=function(){this.patchDateLocked=!0,i.patchDate()},i.prototype.unlockDatePatch=function(){this.patchDateLocked=!1,i.resetDate()},i.prototype.tick=function(e,t){void 0===e&&(e=0),i.assertInZone(),this.flushMicrotasks(),this._scheduler.tick(e,t),null!==this._lastError&&this._resetLastErrorAndThrow()},i.prototype.flushMicrotasks=function(){for(i.assertInZone();this._microtasks.length>0;){var e=this._microtasks.shift();e.func.apply(e.target,e.args)}(null!==this._lastError||this._uncaughtPromiseErrors.length)&&this._resetLastErrorAndThrow()},i.prototype.flush=function(e,t,n){i.assertInZone(),this.flushMicrotasks();var r=this._scheduler.flush(e,t,n);return null!==this._lastError&&this._resetLastErrorAndThrow(),r},i.prototype.onScheduleTask=function(e,t,n,r){switch(r.type){case"microTask":var o=r.data&&r.data.args,i=void 0;if(o){var a=r.data.cbIdx;"number"==typeof o.length&&o.length>a+1&&(i=Array.prototype.slice.call(o,a+1))}this._microtasks.push({func:r.invoke,args:i,target:r.data&&r.data.target});break;case"macroTask":switch(r.source){case"setTimeout":r.data.handleId=this._setTimeout(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"setImmediate":r.data.handleId=this._setTimeout(r.invoke,0,Array.prototype.slice.call(r.data.args,1));break;case"setInterval":r.data.handleId=this._setInterval(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"XMLHttpRequest.send":throw new Error("Cannot make XHRs from within a fake async test. Request URL: "+r.data.url);case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":r.data.handleId=this._setTimeout(r.invoke,16,r.data.args,this.trackPendingRequestAnimationFrame);break;default:var s=this.findMacroTaskOption(r);if(s){var c=r.data&&r.data.args,u=c&&c.length>1?c[1]:0,l=s.callbackArgs?s.callbackArgs:c;s.isPeriodic?(r.data.handleId=this._setInterval(r.invoke,u,l),r.data.isPeriodic=!0):r.data.handleId=this._setTimeout(r.invoke,u,l);break}throw new Error("Unknown macroTask scheduled in fake async test: "+r.source)}break;case"eventTask":r=e.scheduleTask(n,r)}return r},i.prototype.onCancelTask=function(e,t,n,r){switch(r.source){case"setTimeout":case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":return this._clearTimeout(r.data.handleId);case"setInterval":return this._clearInterval(r.data.handleId);default:var o=this.findMacroTaskOption(r);if(o){var i=r.data.handleId;return o.isPeriodic?this._clearInterval(i):this._clearTimeout(i)}return e.cancelTask(n,r)}},i.prototype.onInvoke=function(e,t,n,r,o,a,s){try{return i.patchDate(),e.invoke(n,r,o,a,s)}finally{this.patchDateLocked||i.resetDate()}},i.prototype.findMacroTaskOption=function(e){if(!this.macroTaskOptions)return null;for(var t=0;t0)throw new Error(i.pendingPeriodicTimers.length+" periodic timer(s) still in the queue.");if(i.pendingTimers.length>0)throw new Error(i.pendingTimers.length+" timer(s) still in the queue.");return l}finally{a()}}}}}), +/** + * @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.__load_patch("promisefortest",function(e,t,n){var r=n.symbol("state"),o=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function e(){var n=Promise[t.__symbol__("ZonePromiseThen")];n||(n=Promise[t.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var e=n.apply(this,arguments);if(null===this[r]){var i=t.current.get("AsyncTestZoneSpec");i&&(i.unresolvedChainedPromiseCount++,e[o]=!0)}return e})},Promise[n.symbol("unPatchPromiseForTest")]=function e(){var n=Promise[t.__symbol__("ZonePromiseThen")];n&&(Promise.prototype.then=n,Promise[t.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone-testing-node-bundle.js b/dist/zone-testing-node-bundle.js old mode 100644 new mode 100755 index 58d0a7038..3734849a2 --- a/dist/zone-testing-node-bundle.js +++ b/dist/zone-testing-node-bundle.js @@ -5,1845 +5,1921 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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) { - var performance = global['performance']; - function mark(name) { - performance && performance['mark'] && performance['mark'](name); - } - function performanceMeasure(name, label) { - performance && performance['measure'] && performance['measure'](name, label); - } - mark('Zone'); - var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; - if (global['Zone']) { - // if global['Zone'] already exists (maybe zone.js was already loaded or - // some other lib also registered a global object named Zone), we may need - // to throw an error, but sometimes user may not want this error. - // For example, - // we have two web pages, page1 includes zone.js, page2 doesn't. - // and the 1st time user load page1 and page2, everything work fine, - // but when user load page2 again, error occurs because global['Zone'] already exists. - // so we add a flag to let user choose whether to throw this error or not. - // By default, if existing Zone is from zone.js, we will not throw the error. - if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { - throw new Error('Zone already loaded.'); - } - else { - return global['Zone']; - } - } - var Zone = /** @class */ (function () { - function Zone(parent, zoneSpec) { - this._parent = parent; - this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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) { + var performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + var symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + var checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } - Zone.assertZonePatched = function () { - if (global['Promise'] !== patches['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.)'); + var Zone = /** @class */ (function () { + function Zone(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); } - }; - Object.defineProperty(Zone, "root", { - get: function () { - var zone = Zone.current; - while (zone.parent) { - zone = zone.parent; + Zone.assertZonePatched = function () { + if (global['Promise'] !== patches['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.)'); } - return zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "current", { - get: function () { - return _currentZoneFrame.zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "currentTask", { - get: function () { - return _currentTask; - }, - enumerable: true, - configurable: true - }); - Zone.__load_patch = function (name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); + }; + Object.defineProperty(Zone, "root", { + get: function () { + var zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "current", { + get: function () { + return _currentZoneFrame.zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "currentTask", { + get: function () { + return _currentTask; + }, + enumerable: true, + configurable: true + }); + Zone.__load_patch = function (name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } - } - else if (!global['__Zone_disable_' + name]) { - var perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - }; - Object.defineProperty(Zone.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Zone.prototype.get = function (key) { - var zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - }; - Zone.prototype.getZoneWith = function (key) { - var current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; + else if (!global['__Zone_disable_' + name]) { + var perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); } - current = current._parent; - } - return null; - }; - Zone.prototype.fork = function (zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - }; - Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - var _callback = this._zoneDelegate.intercept(this, callback, source); - var zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); }; - }; - Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = null; } - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { + Object.defineProperty(Zone.prototype, "parent", { + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Zone.prototype.get = function (key) { + var zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + }; + Zone.prototype.getZoneWith = function (key) { + var current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + }; + Zone.prototype.fork = function (zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + }; + Zone.prototype.wrap = function (callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + var _callback = this._zoneDelegate.intercept(this, callback, source); + var zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + }; + Zone.prototype.run = function (callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { + if (applyThis === void 0) { applyThis = null; } + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runTask = function (task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - var reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - var previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; + finally { + _currentZoneFrame = _currentZoneFrame.parent; } + }; + Zone.prototype.runTask = function (task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; + } + var reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + var previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } + } } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } + } + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + }; + Zone.prototype.scheduleTask = function (task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + var newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + } + newZone = newZone.parent; + } + } + task._transitionTo(scheduling, notScheduled); + var zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + }; + Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + }; + Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.cancelTask = function (task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + }; + Zone.prototype._updateTaskCount = function (task, count) { + var zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (var i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + }; + return Zone; + }()); + Zone.__symbol__ = __symbol__; + var DELEGATE_ZS = { + name: '', + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, + onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } + }; + var ZoneDelegate = /** @class */ (function () { + function ZoneDelegate(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; } } } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); + ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + }; + ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + }; + ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.handleError = function (targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + }; + ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { + var returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); } else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); + throw new Error('Task is missing scheduleFn.'); } } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - }; - Zone.prototype.scheduleTask = function (task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - var newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + return returnTask; + }; + ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.cancelTask = function (targetZone, task) { + var value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); + } + else { + if (!task.cancelFn) { + throw Error('Task is not cancelable'); } - newZone = newZone.parent; + value = task.cancelFn(task); + } + return value; + }; + ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + }; + ZoneDelegate.prototype._updateTaskCount = function (type, count) { + var counts = this._taskCounts; + var prev = counts[type]; + var next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + var isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + }; + return ZoneDelegate; + }()); + var ZoneTask = /** @class */ (function () { + function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + var self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; } } - task._transitionTo(scheduling, notScheduled); - var zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - }; - Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - }; - Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.cancelTask = function (task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - }; - Zone.prototype._updateTaskCount = function (task, count) { - var zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (var i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); - } - }; - Zone.__symbol__ = __symbol__; - return Zone; - }()); - var DELEGATE_ZS = { - name: '', - onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, - onScheduleTask: function (delegate, _, target, task) { - return delegate.scheduleTask(target, task); - }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { - return delegate.invokeTask(target, task, applyThis, applyArgs); - }, - onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } - }; - var ZoneDelegate = /** @class */ (function () { - function ZoneDelegate(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; + ZoneTask.invokeTask = function (task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + }; + Object.defineProperty(ZoneTask.prototype, "zone", { + get: function () { + return this._zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ZoneTask.prototype, "state", { + get: function () { + return this._state; + }, + enumerable: true, + configurable: true + }); + ZoneTask.prototype.cancelScheduleRequest = function () { + this._transitionTo(notScheduled, scheduling); + }; + ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); + } + }; + ZoneTask.prototype.toString = function () { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + }; + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + ZoneTask.prototype.toJSON = function () { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount + }; + }; + return ZoneTask; + }()); + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var symbolSetTimeout = __symbol__('setTimeout'); + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var _microTaskQueue = []; + var _isDrainingMicrotaskQueue = false; + var nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); } } + task && _microTaskQueue.push(task); } - ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - }; - ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; - }; - ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.handleError = function (targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - }; - ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { - var returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); - } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; - } - else { - if (task.scheduleFn) { - task.scheduleFn(task); + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + var queue = _microTaskQueue; + _microTaskQueue = []; + for (var i = 0; i < queue.length; i++) { + var task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var NO_ZONE = { name: 'NO ZONE' }; + var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + var patches = {}; + var _api = { + symbol: __symbol__, + currentZoneFrame: function () { return _currentZoneFrame; }, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, + patchEventTarget: function () { return []; }, + patchOnProperties: noop, + patchMethod: function () { return noop; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, + setNativePromise: function (NativePromise) { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); } - else if (task.type == microTask) { - scheduleMicroTask(task); + }, + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } + }; + var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + var _currentTask = null; + var _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); + /** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + var className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + var __symbol__ = api.symbol; + var _uncaughtPromiseErrors = []; + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var creationTrace = '__creationTrace__'; + api.onUnhandledError = function (e) { + if (api.showUncaughtError()) { + var rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); } else { - throw new Error('Task is missing scheduleFn.'); + console.error(e); } } - return returnTask; }; - ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.cancelTask = function (targetZone, task) { - var value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); + api.microtaskDrainDone = function () { + while (_uncaughtPromiseErrors.length) { + var _loop_1 = function () { + var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + try { + uncaughtPromiseError.zone.runGuarded(function () { + throw uncaughtPromiseError; + }); + } + catch (error) { + handleUnhandledRejection(error); + } + }; + while (_uncaughtPromiseErrors.length) { + _loop_1(); } - value = task.cancelFn(task); } - return value; }; - ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback + var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } } catch (err) { - this.handleError(targetZone, err); - } - }; - ZoneDelegate.prototype._updateTaskCount = function (type, count) { - var counts = this._taskCounts; - var prev = counts[type]; - var next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - var isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type - }; - this.hasTask(this.zone, isEmpty); - } - }; - return ZoneDelegate; - }()); - var ZoneTask = /** @class */ (function () { - function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - var self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; - } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); - }; } } - ZoneTask.invokeTask = function (task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + var symbolState = __symbol__('state'); + var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); + var source = 'Promise.then'; + var UNRESOLVED = null; + var RESOLVED = true; + var REJECTED = false; + var REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return function (v) { + try { + resolvePromise(promise, state, v); } - _numberOfNestedTaskFrames--; - } - }; - Object.defineProperty(ZoneTask.prototype, "zone", { - get: function () { - return this._zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ZoneTask.prototype, "state", { - get: function () { - return this._state; - }, - enumerable: true, - configurable: true - }); - ZoneTask.prototype.cancelScheduleRequest = function () { - this._transitionTo(notScheduled, scheduling); - }; - ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; + catch (err) { + resolvePromise(promise, false, err); } - } - else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); - } - }; - ZoneTask.prototype.toString = function () { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); - } - }; - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - ZoneTask.prototype.toJSON = function () { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount + // Do not return value or you will break the Promise spec. + }; + } + var once = function () { + var wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; }; }; - return ZoneTask; - }()); - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var symbolSetTimeout = __symbol__('setTimeout'); - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var _microTaskQueue = []; - var _isDrainingMicrotaskQueue = false; - var nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + var TYPE_ERROR = 'Promise resolved with itself'; + var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + var onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + var then = null; + try { + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } } - } - if (nativeMicroTaskQueuePromise) { - var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); - } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - var queue = _microTaskQueue; - _microTaskQueue = []; - for (var i = 0; i < queue.length; i++) { - var task = queue[i]; + catch (err) { + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + return promise; + } + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { try { - task.zone.runTask(task, null, null); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } - catch (error) { - _api.onUnhandledError(error); + catch (err) { + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + var queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + var trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (var i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + var error_1 = err; + error_1.rejection = value; + error_1.promise = promise; + error_1.zone = Zone.current; + error_1.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error_1); + api.scheduleMicroTask(); // to make sure that it is running + } } } } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var NO_ZONE = { name: 'NO ZONE' }; - var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - var patches = {}; - var _api = { - symbol: __symbol__, - currentZoneFrame: function () { return _currentZoneFrame; }, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, - patchEventTarget: function () { return []; }, - patchOnProperties: noop, - patchMethod: function () { return noop; }, - bindArguments: function () { return []; }, - patchThen: function () { return noop; }, - patchMacroTask: function () { return noop; }, - setNativePromise: function (NativePromise) { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: function () { return noop; }, - isIEOrEdge: function () { return false; }, - getGlobalObjects: function () { return undefined; }, - ObjectDefineProperty: function () { return noop; }, - ObjectGetOwnPropertyDescriptor: function () { return undefined; }, - ObjectCreate: function () { return undefined; }, - ArraySlice: function () { return []; }, - patchClass: function () { return noop; }, - wrapWithCurrentZone: function () { return noop; }, - filterProperties: function () { return []; }, - attachOriginToPatched: function () { return noop; }, - _redefineProperty: function () { return noop; }, - patchCallbacks: function () { return noop; } - }; - var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - var _currentTask = null; - var _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { - var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - var className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); - } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - var __symbol__ = api.symbol; - var _uncaughtPromiseErrors = []; - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var creationTrace = '__creationTrace__'; - api.onUnhandledError = function (e) { - if (api.showUncaughtError()) { - var rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); - } - else { - console.error(e); - } + // Resolving an already resolved promise is a noop. + return promise; } - }; - api.microtaskDrainDone = function () { - while (_uncaughtPromiseErrors.length) { - var _loop_1 = function () { - var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler try { - uncaughtPromiseError.zone.runGuarded(function () { - throw uncaughtPromiseError; - }); + var handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } } - catch (error) { - handleUnhandledRejection(error); + catch (err) { + } + promise[symbolState] = REJECTED; + for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } } - }; - while (_uncaughtPromiseErrors.length) { - _loop_1(); - } - } - }; - var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); } } - catch (err) { - } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - var symbolState = __symbol__('state'); - var symbolValue = __symbol__('value'); - var symbolFinally = __symbol__('finally'); - var symbolParentPromiseValue = __symbol__('parentPromiseValue'); - var symbolParentPromiseState = __symbol__('parentPromiseState'); - var source = 'Promise.then'; - var UNRESOLVED = null; - var RESOLVED = true; - var REJECTED = false; - var REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return function (v) { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); - } - // Do not return value or you will break the Promise spec. - }; - } - var once = function () { - var wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + var promiseState = promise[symbolState]; + var delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, function () { + try { + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); } - wasCalled = true; - wrappedFunction.apply(null, arguments); - }; - }; - }; - var TYPE_ERROR = 'Promise resolved with itself'; - var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - var onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - var then = null; - try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; + var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + var ZoneAwarePromise = /** @class */ (function () { + function ZoneAwarePromise(executor) { + var promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); } - } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); - return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); - } - else if (state !== REJECTED && typeof then === 'function') { + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); + catch (error) { + resolvePromise(promise, false, error); } } - else { - promise[symbolState] = state; - var queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; + ZoneAwarePromise.toString = function () { + return ZONE_AWARE_PROMISE_TO_STRING; + }; + ZoneAwarePromise.resolve = function (value) { + return resolvePromise(new this(null), RESOLVED, value); + }; + ZoneAwarePromise.reject = function (error) { + return resolvePromise(new this(null), REJECTED, error); + }; + ZoneAwarePromise.race = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + if (!isThenable(value)) { + value = this.resolve(value); } + value.then(onResolve, onReject); } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - var trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + return promise; + }; + ZoneAwarePromise.all = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; + var resolvedValues = []; + var _loop_2 = function (value) { + if (!isThenable(value)) { + value = this_1.resolve(value); } + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + _loop_2(value); } - for (var i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; - try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); - } - catch (err) { - var error_1 = err; - error_1.rejection = value; - error_1.promise = promise; - error_1.zone = Zone.current; - error_1.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error_1); - api.scheduleMicroTask(); // to make sure that it is running + return promise; + }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true + }); + ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { + var chainPromise = new this.constructor(null); + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; + }; + ZoneAwarePromise.prototype.catch = function (onRejected) { + return this.then(null, onRejected); + }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + } + return chainPromise; + }; + return ZoneAwarePromise; + }()); + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + var NativePromise = global[symbolPromise] = global['Promise']; + var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); } + api.setNativePromise(NewNativePromise); } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + var symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; } + var originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + var _this = this; + var wrapped = new ZoneAwarePromise(function (resolve, reject) { + originalThen.call(_this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; } - // Resolving an already resolved promise is a noop. - return promise; - } - var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); } + return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); } - catch (err) { + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); + /** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + var ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + var ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Array.prototype.slice */ + var ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + var ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + var TRUE_STR = 'true'; + /** false string const */ + var FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + var ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); + } + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); + } + var zoneSymbol = Zone.__symbol__; + var isWindowExists = typeof window !== 'undefined'; + var internalWindow = isWindowExists ? window : undefined; + var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + var REMOVE_ATTRIBUTE = 'removeAttribute'; + var NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; + } + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; + } + if (propertyDesc.writable === false) { + return false; + } + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); + } + var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + var zoneSymbolEventNames = {}; + var wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + var eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); + } + var target = this || event.target || _global; + var listener = target[eventNameSymbol]; + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); } - promise[symbolState] = REJECTED; - for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); - } + } + else { + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); } } - } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - var promiseState = promise[symbolState]; - var delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, function () { - try { - var parentPromiseValue = promise[symbolValue]; - var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); + return result; + }; + function patchProperty(obj, prop, prototype) { + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; + } + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; + } + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + var originalDescGet = desc.get; + var originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); + var previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); } - }, chainPromise); - } - var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = /** @class */ (function () { - function ZoneAwarePromise(executor) { - var promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); } - catch (error) { - resolvePromise(promise, false, error); + else { + target[eventNameSymbol] = null; } - } - ZoneAwarePromise.toString = function () { - return ZONE_AWARE_PROMISE_TO_STRING; - }; - ZoneAwarePromise.resolve = function (value) { - return resolvePromise(new this(null), RESOLVED, value); - }; - ZoneAwarePromise.reject = function (error) { - return resolvePromise(new this(null), REJECTED, error); }; - ZoneAwarePromise.race = function (values) { - var e_1, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; } - function onReject(error) { - reject(error); + if (!target) { + return null; } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; - if (!isThenable(value)) { - value = this.resolve(value); + var listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + var value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); } - value.then(onResolve, onReject); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + return value; } - finally { if (e_1) throw e_1.error; } } - return promise; + return null; }; - ZoneAwarePromise.all = function (values) { - var e_2, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - var unresolvedCount = 2; - var valueIndex = 0; - var resolvedValues = []; - var _loop_2 = function (value) { - if (!isThenable(value)) { - value = this_1.resolve(value); - } - var curValueIndex = valueIndex; - value.then(function (value) { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; - }; - var this_1 = this; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - _loop_2(value); - } + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; + } + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (var i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + } + else { + var onProperties = []; + for (var prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); } - finally { if (e_2) throw e_2.error; } - } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - return promise; - }; - Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { - get: function () { - return 'Promise'; - }, - enumerable: true, - configurable: true - }); - ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { - var chainPromise = new this.constructor(null); - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); - } - return chainPromise; - }; - ZoneAwarePromise.prototype.catch = function (onRejected) { - return this.then(null, onRejected); - }; - ZoneAwarePromise.prototype.finally = function (onFinally) { - var chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); + for (var j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); } - return chainPromise; - }; - return ZoneAwarePromise; - }()); - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - var NativePromise = global[symbolPromise] = global['Promise']; - var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; } - desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; - } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); - } - }; - ObjectDefineProperty(global, 'Promise', desc); } - global['Promise'] = ZoneAwarePromise; - var symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - var proto = Ctor.prototype; - var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case + var originalInstanceKey = zoneSymbol('originalInstance'); + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { return; } - var originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - var _this = this; - var wrapped = new ZoneAwarePromise(function (resolve, reject) { - originalThen.call(_this, resolve, reject); + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; + } + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; + }); } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { - return resultPromise; - } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); - } - return resultPromise; - }; + var shouldCopySymbolProperties = false; + function setShouldCopySymbolProperties(flag) { + shouldCopySymbolProperties = flag; } - if (NativePromise) { - patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global[api.symbol('fetch')] = fetch_1; - global['fetch'] = zoneify(fetch_1); + function patchMethod(target, name, patchFn) { + var proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); - -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -var ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -var ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ - -/** Array.prototype.slice */ -var ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -var ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -var TRUE_STR = 'true'; -/** false string const */ -var FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -var zoneSymbol = Zone.__symbol__; -var isWindowExists = typeof window !== 'undefined'; -var internalWindow = isWindowExists ? window : undefined; -var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -var REMOVE_ATTRIBUTE = 'removeAttribute'; -var NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + var delegateName = zoneSymbol(name); + var delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + var patchDelegate_1 = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate_1(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); + } + } } + return delegate; } - return args; -} - -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -var zoneSymbolEventNames = {}; -var wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - var eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); - } - var target = this || event.target || _global; - var listener = target[eventNameSymbol]; - var result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - var errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); - } - } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); - } - } - return result; -}; -function patchProperty(obj, prop, prototype) { - var desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; - } - } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - var originalDescGet = desc.get; - var originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return; - } - var previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); - } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); - } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); - } - else { - target[eventNameSymbol] = null; - } - }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; - } - if (!target) { - return null; - } - var listener = target[eventNameSymbol]; - if (listener) { - return listener; + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); - } - return value; + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (var i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } - } - else { - var onProperties = []; - for (var prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); + else { + // cause an error by calling it directly. + return delegate.apply(self, args); } - } - for (var j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); - } - } -} -var originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` - -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; - } - var symbols = Object.getOwnPropertySymbols(src); - symbols.forEach(function (symbol) { - var desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; - } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -var shouldCopySymbolProperties = false; -function setShouldCopySymbolProperties(flag) { - shouldCopySymbolProperties = flag; -} -function patchMethod(target, name, patchFn) { - var proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; + }; }); } - var delegateName = zoneSymbol(name); - var delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - var patchDelegate_1 = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate_1(this, arguments); + function patchMicroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); - } + setNative.apply(data.target, data.args); + return task; } + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); + } + else { + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }; }); } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; - } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); - } - else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} -function patchMicroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); - }; - setNative.apply(data.target, data.args); - return task; + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return Zone.current.scheduleMicroTask(meta.name, args[meta.cbIdx], meta, scheduleTask); - } - else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} - -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', function (global) { - // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Function.prototype.toString; - var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - var PROMISE_SYMBOL = zoneSymbol('Promise'); - var ERROR_SYMBOL = zoneSymbol('Error'); - var newFunctionToString = function toString() { - if (typeof this === 'function') { - var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); + /** + * @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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', function (global) { + // patch Func.prototype.toString to let them look like native + var originalFunctionToString = Function.prototype.toString; + var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + var PROMISE_SYMBOL = zoneSymbol('Promise'); + var ERROR_SYMBOL = zoneSymbol('Error'); + var newFunctionToString = function toString() { + if (typeof this === 'function') { + var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } } - else { - return Object.prototype.toString.call(originalDelegate); + if (this === Promise) { + var nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } } - } - if (this === Promise) { - var nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); + if (this === Error) { + var nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } } } - if (this === Error) { - var nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); - } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + var originalObjectToString = Object.prototype.toString; + var PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; } + return originalObjectToString.call(this); + }; + }); + /** + * @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.__load_patch('node_util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + setShouldCopySymbolProperties(true); + }); + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + var passiveSupported = false; + if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - var originalObjectToString = Object.prototype.toString; - var PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; + catch (err) { + passiveSupported = false; } - return originalObjectToString.call(this); - }; -}); - -/** - * @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.__load_patch('node_util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - setShouldCopySymbolProperties(true); -}); - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var passiveSupported = false; -if (typeof window !== 'undefined') { - try { - var options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } - }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); - } - catch (err) { - passiveSupported = false; } -} -// an identifier to tell ZoneTask do not create a new invoke closure -var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -var zoneSymbolEventNames$1 = {}; -var globalSources = {}; -var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - var PREPEND_EVENT_LISTENER = 'prependListener'; - var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { - return; - } - var delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = function (event) { return delegate.handleEvent(event); }; - task.originalDelegate = delegate; - } - // invoke static task.invoke - task.invoke(task, target, [event]); - var options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); - } + // an identifier to tell ZoneTask do not create a new invoke closure + var OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true }; - // global shared zoneAwareCallback to handle all event callback with capture = false - var globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); - } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } + var zoneSymbolEventNames$1 = {}; + var globalSources = {}; + var EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + var PREPEND_EVENT_LISTENER = 'prependListener'; + var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + var invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { + return; } - } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - var globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + var delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = function (event) { return delegate.handleEvent(event); }; + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + var options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + } + }; + // global shared zoneAwareCallback to handle all event callback with capture = false + var globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); } - invokeTask(copyTasks[i], target, event); } } - } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - var useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - var validateHandler = patchOptions && patchOptions.vh; - var checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; - } - var returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; - } - var proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; - } - if (!proto) { - return false; - } - if (proto[zoneSymbolAddEventListener]) { - return false; - } - var eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - var taskData = {}; - var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - var nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } - } - var customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + var globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); - }; - var customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - var symbolEventName = void 0; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); } - var existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { break; } + invokeTask(copyTasks[i], target, event); } } } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { - return; - } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - var customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - var compareTaskCallbackVsDelegate = function (task, delegate) { - var typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); }; - var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { - if (returnTarget === void 0) { returnTarget = false; } - if (prepend === void 0) { prepend = false; } - return function () { - var target = this || _global; - var eventName = arguments[0]; - var delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - var isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + var useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + var validateHandler = patchOptions && patchOptions.vh; + var checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + var returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + var proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + var eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + var taskData = {}; + var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + var nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + var customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + var symbolEventName = void 0; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } } - isHandleEvent = true; } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { return; } - var options = arguments[2]; - if (blackListedEvents) { - // check black list - for (var i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + var customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + var compareTaskCallbackVsDelegate = function (task, delegate) { + var typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + var blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { + if (returnTarget === void 0) { returnTarget = false; } + if (prepend === void 0) { prepend = false; } + return function () { + var target = this || _global; + var eventName = arguments[0]; + var delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + var isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } + isHandleEvent = true; } - } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + var options = arguments[2]; + if (blackListedEvents) { + // check black list + for (var i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + var capture; + var once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + var zone = Zone.current; + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = target[symbolEventName]; + var isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (var i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + var source; + var constructorName = target.constructor['name']; + var targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var options = arguments[2]; var capture; - var once = false; if (options === undefined) { capture = false; } @@ -1855,2274 +1931,2094 @@ function patchEventTarget(_global, apis, patchOptions) { } else { capture = options ? !!options.capture : false; - once = options ? !!options.once : false; } - var zone = Zone.current; + var delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } var symbolEventNames = zoneSymbolEventNames$1[eventName]; var symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { + if (symbolEventNames) { symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } - var existingTasks = target[symbolEventName]; - var isExisting = false; + var existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (var i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; } } } - else { - existingTasks = target[symbolEventName] = []; - } - var source; - var constructorName = target.constructor['name']; - var targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); - } - else { - existingTasks.unshift(task); - } - if (returnTarget) { - return target; + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var listeners = []; + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (var i = 0; i < tasks.length; i++) { + var task = tasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); } + return listeners; }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var options = arguments[2]; - var capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - } - var delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); - } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; - } - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; - } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + if (!eventName) { + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } - return; - } - } - } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var listeners = []; - var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - if (!eventName) { - var keys = Object.keys(target); - for (var i = 0; i < keys.length; i++) { - var prop = keys[i]; - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - var symbolEventName = symbolEventNames[FALSE_STR]; - var symbolCaptureEventName = symbolEventNames[TRUE_STR]; - var tasks = target[symbolEventName]; - var captureTasks = target[symbolCaptureEventName]; - if (tasks) { - var removeTasks = tasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + else { + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + var symbolEventName = symbolEventNames[FALSE_STR]; + var symbolCaptureEventName = symbolEventNames[TRUE_STR]; + var tasks = target[symbolEventName]; + var captureTasks = target[symbolCaptureEventName]; + if (tasks) { + var removeTasks = tasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } - } - if (captureTasks) { - var removeTasks = captureTasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + if (captureTasks) { + var removeTasks = captureTasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } } } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); + } + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + } + return true; + } + var results = []; + for (var i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; + } + function findEventTasks(target, eventName) { + var foundTasks = []; + for (var prop in target) { + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + var tasks = target[prop]; + if (tasks) { + for (var i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } + } } - if (returnTarget) { - return this; - } - }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); - } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); } - return true; + return foundTasks; } - var results = []; - for (var i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); - } - return results; -} -function findEventTasks(target, eventName) { - var foundTasks = []; - for (var prop in target) { - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - var tasks = target[prop]; - if (tasks) { - for (var i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); - } + /** + * @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.__load_patch('EventEmitter', function (global) { + // For EventEmitter + var EE_ADD_LISTENER = 'addListener'; + var EE_PREPEND_LISTENER = 'prependListener'; + var EE_REMOVE_LISTENER = 'removeListener'; + var EE_REMOVE_ALL_LISTENER = 'removeAllListeners'; + var EE_LISTENERS = 'listeners'; + var EE_ON = 'on'; + var compareTaskCallbackVsDelegate = function (task, delegate) { + // same callback, same capture, same event name, just return + return task.callback === delegate || task.callback.listener === delegate; + }; + var eventNameToString = function (eventName) { + if (typeof eventName === 'string') { + return eventName; + } + if (!eventName) { + return ''; + } + return eventName.toString().replace('(', '_').replace(')', '_'); + }; + function patchEventEmitterMethods(obj) { + var result = patchEventTarget(global, [obj], { + useG: false, + add: EE_ADD_LISTENER, + rm: EE_REMOVE_LISTENER, + prepend: EE_PREPEND_LISTENER, + rmAll: EE_REMOVE_ALL_LISTENER, + listeners: EE_LISTENERS, + chkDup: false, + rt: true, + diff: compareTaskCallbackVsDelegate, + eventNameToString: eventNameToString + }); + if (result && result[0]) { + obj[EE_ON] = obj[EE_ADD_LISTENER]; } } - } - return foundTasks; -} - -/** - * @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.__load_patch('EventEmitter', function (global) { - // For EventEmitter - var EE_ADD_LISTENER = 'addListener'; - var EE_PREPEND_LISTENER = 'prependListener'; - var EE_REMOVE_LISTENER = 'removeListener'; - var EE_REMOVE_ALL_LISTENER = 'removeAllListeners'; - var EE_LISTENERS = 'listeners'; - var EE_ON = 'on'; - var compareTaskCallbackVsDelegate = function (task, delegate) { - // same callback, same capture, same event name, just return - return task.callback === delegate || task.callback.listener === delegate; - }; - var eventNameToString = function (eventName) { - if (typeof eventName === 'string') { - return eventName; + // EventEmitter + var events; + try { + events = require('events'); } - if (!eventName) { - return ''; + catch (err) { } - return eventName.toString().replace('(', '_').replace(')', '_'); - }; - function patchEventEmitterMethods(obj) { - var result = patchEventTarget(global, [obj], { - useG: false, - add: EE_ADD_LISTENER, - rm: EE_REMOVE_LISTENER, - prepend: EE_PREPEND_LISTENER, - rmAll: EE_REMOVE_ALL_LISTENER, - listeners: EE_LISTENERS, - chkDup: false, - rt: true, - diff: compareTaskCallbackVsDelegate, - eventNameToString: eventNameToString - }); - if (result && result[0]) { - obj[EE_ON] = obj[EE_ADD_LISTENER]; + if (events && events.EventEmitter) { + patchEventEmitterMethods(events.EventEmitter.prototype); } - } - // EventEmitter - var events; - try { - events = require('events'); - } - catch (err) { - } - if (events && events.EventEmitter) { - 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 - */ -Zone.__load_patch('fs', function () { - var fs; - try { - fs = require('fs'); - } - catch (err) { - } - // watch, watchFile, unwatchFile has been patched - // because EventEmitter has been patched - var TO_PATCH_MACROTASK_METHODS = [ - '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_MACROTASK_METHODS.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }) - .forEach(function (name) { - patchMacroTask(fs, name, function (self, args) { - return { - name: 'fs.' + name, - args: args, - cbIdx: args.length > 0 ? args.length - 1 : -1, - target: self - }; + }); + /** + * @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.__load_patch('fs', function () { + var fs; + try { + fs = require('fs'); + } + catch (err) { + } + // watch, watchFile, unwatchFile has been patched + // because EventEmitter has been patched + var TO_PATCH_MACROTASK_METHODS = [ + '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_MACROTASK_METHODS.filter(function (name) { return !!fs[name] && typeof fs[name] === 'function'; }) + .forEach(function (name) { + patchMacroTask(fs, name, function (self, args) { + return { + name: 'fs.' + name, + args: args, + cbIdx: args.length > 0 ? args.length - 1 : -1, + target: self + }; + }); }); - }); - } -}); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; - } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + } + }); + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + 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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } + data.args[0] = timer; + data.handleId = setNative.apply(window, data.args); + return task; } - data.args[0] = timer; - 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 options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); - if (!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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } return task; } - // Node.js must additionally support the ref and unref functions. - var handle = task.data.handleId; - if (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); - } - if (typeof handle === 'number' || handle) { - return 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; + else { + // cause an error by calling it directly. + return delegate.apply(window, args); + } + }; }); + clearNative = + patchMethod(window, cancelName, function (delegate) { return function (self, args) { + var id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; } - else if (id) { - id[taskSymbol] = null; + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // Do not cancel already canceled functions + task.zone.cancelTask(task); } - // 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'; -var clear = 'clear'; -Zone.__load_patch('node_timers', function (global, Zone) { - // Timers - var globalUseTimeoutFromTimer = false; - try { - var timers = require('timers'); - var globalEqualTimersTimeout = global.setTimeout === timers.setTimeout; - if (!globalEqualTimersTimeout && !isMix) { - // 1. if isMix, then we are in mix environment such as Electron - // we should only patch timers.setTimeout because global.setTimeout - // have been patched - // 2. if global.setTimeout not equal timers.setTimeout, check - // whether global.setTimeout use timers.setTimeout or not - var originSetTimeout_1 = timers.setTimeout; - timers.setTimeout = function () { - globalUseTimeoutFromTimer = true; - return originSetTimeout_1.apply(this, arguments); - }; - var detectTimeout = global.setTimeout(function () { }, 100); - clearTimeout(detectTimeout); - timers.setTimeout = originSetTimeout_1; - } - patchTimer(timers, set, clear, 'Timeout'); - patchTimer(timers, set, clear, 'Interval'); - patchTimer(timers, set, clear, 'Immediate'); - } - catch (error) { - // timers module not exists, for example, when we using nativeScript - // timers is not available - } - if (isMix) { - // if we are in mix environment, such as Electron, - // the global.setTimeout has already been patched, - // so we just patch timers.setTimeout - return; - } - if (!globalUseTimeoutFromTimer) { - // 1. global setTimeout equals timers setTimeout - // 2. or global don't use timers setTimeout(maybe some other library patch setTimeout) - // 3. or load timers module error happens, we should patch global setTimeout - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); - } - else { - // global use timers setTimeout, but not equals - // this happens when use nodejs v0.10.x, global setTimeout will - // use a lazy load version of timers setTimeout - // we should not double patch timer's setTimeout - // so we only store the __symbol__ for consistency - global[Zone.__symbol__('setTimeout')] = global.setTimeout; - global[Zone.__symbol__('setInterval')] = global.setInterval; - global[Zone.__symbol__('setImmediate')] = global.setImmediate; - } -}); -// patch process related methods -Zone.__load_patch('nextTick', function () { - // patch nextTick as microTask - patchMicroTask(process, 'nextTick', function (self, args) { - return { - name: 'process.nextTick', - args: args, - cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, - target: process - }; - }); -}); -Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api) { - Zone[api.symbol('unhandledPromiseRejectionHandler')] = - findProcessPromiseRejectionHandler('unhandledRejection'); - Zone[api.symbol('rejectionHandledHandler')] = - findProcessPromiseRejectionHandler('rejectionHandled'); - // handle unhandled promise rejection - function findProcessPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(process, evtName); - eventTasks.forEach(function (eventTask) { - // process has added unhandledrejection event listener - // trigger the event listener - if (evtName === 'unhandledRejection') { - eventTask.invoke(e.rejection, e.promise); - } - else if (evtName === 'rejectionHandled') { - eventTask.invoke(e.promise); + else { + // cause an error by calling it directly. + delegate.apply(window, args); } - }); - }; - } -}); -// Crypto -Zone.__load_patch('crypto', function () { - var crypto; - try { - crypto = require('crypto'); + }; }); } - catch (err) { - } - // use the generic patchMacroTask to patch crypto - if (crypto) { - var methodNames = ['randomBytes', 'pbkdf2']; - methodNames.forEach(function (name) { - patchMacroTask(crypto, name, function (self, args) { - return { - name: 'crypto.' + name, - args: args, - cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? - args.length - 1 : - -1, - target: crypto + /** + * @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'; + var clear = 'clear'; + Zone.__load_patch('node_timers', function (global, Zone) { + // Timers + var globalUseTimeoutFromTimer = false; + try { + var timers = require('timers'); + var globalEqualTimersTimeout = global.setTimeout === timers.setTimeout; + if (!globalEqualTimersTimeout && !isMix) { + // 1. if isMix, then we are in mix environment such as Electron + // we should only patch timers.setTimeout because global.setTimeout + // have been patched + // 2. if global.setTimeout not equal timers.setTimeout, check + // whether global.setTimeout use timers.setTimeout or not + var originSetTimeout_1 = timers.setTimeout; + timers.setTimeout = function () { + globalUseTimeoutFromTimer = true; + return originSetTimeout_1.apply(this, arguments); }; - }); + var detectTimeout = global.setTimeout(function () { }, 100); + clearTimeout(detectTimeout); + timers.setTimeout = originSetTimeout_1; + } + patchTimer(timers, set, clear, 'Timeout'); + patchTimer(timers, set, clear, 'Interval'); + patchTimer(timers, set, clear, 'Immediate'); + } + catch (error) { + // timers module not exists, for example, when we using nativeScript + // timers is not available + } + if (isMix) { + // if we are in mix environment, such as Electron, + // the global.setTimeout has already been patched, + // so we just patch timers.setTimeout + return; + } + if (!globalUseTimeoutFromTimer) { + // 1. global setTimeout equals timers setTimeout + // 2. or global don't use timers setTimeout(maybe some other library patch setTimeout) + // 3. or load timers module error happens, we should patch global setTimeout + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + } + else { + // global use timers setTimeout, but not equals + // this happens when use nodejs v0.10.x, global setTimeout will + // use a lazy load version of timers setTimeout + // we should not double patch timer's setTimeout + // so we only store the __symbol__ for consistency + global[Zone.__symbol__('setTimeout')] = global.setTimeout; + global[Zone.__symbol__('setInterval')] = global.setInterval; + global[Zone.__symbol__('setImmediate')] = global.setImmediate; + } + }); + // patch process related methods + Zone.__load_patch('nextTick', function () { + // patch nextTick as microTask + patchMicroTask(process, 'nextTick', function (self, args) { + return { + name: 'process.nextTick', + args: args, + cbIdx: (args.length > 0 && typeof args[0] === 'function') ? 0 : -1, + target: process + }; }); - } -}); -Zone.__load_patch('console', function (global, Zone) { - var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; - consoleMethods.forEach(function (m) { - var originalMethod = console[Zone.__symbol__(m)] = console[m]; - if (originalMethod) { - console[m] = function () { - var args = ArraySlice.call(arguments); - if (Zone.current === Zone.root) { - return originalMethod.apply(this, args); - } - else { - return Zone.root.run(originalMethod, this, args); - } + }); + Zone.__load_patch('handleUnhandledPromiseRejection', function (global, Zone, api) { + Zone[api.symbol('unhandledPromiseRejectionHandler')] = + findProcessPromiseRejectionHandler('unhandledRejection'); + Zone[api.symbol('rejectionHandledHandler')] = + findProcessPromiseRejectionHandler('rejectionHandled'); + // handle unhandled promise rejection + function findProcessPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(process, evtName); + eventTasks.forEach(function (eventTask) { + // process has added unhandledrejection event listener + // trigger the event listener + if (evtName === 'unhandledRejection') { + eventTask.invoke(e.rejection, e.promise); + } + else if (evtName === 'rejectionHandled') { + eventTask.invoke(e.promise); + } + }); }; } }); -}); - -/** - * @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 - */ - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var __assign = (undefined && undefined.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; + // Crypto + Zone.__load_patch('crypto', function () { + var crypto; + try { + crypto = require('crypto'); } - return t; - }; - return __assign.apply(this, arguments); -}; -var NEWLINE = '\n'; -var IGNORE_FRAMES = {}; -var creationTrace = '__creationTrace__'; -var ERROR_TAG = 'STACKTRACE TRACKING'; -var SEP_TAG = '__SEP_TAG__'; -var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = /** @class */ (function () { - function LongStackTrace() { - this.error = getStacktrace(); - this.timestamp = new Date(); - } - return LongStackTrace; -}()); -function getStacktraceWithUncaughtError() { - return new Error(ERROR_TAG); -} -function getStacktraceWithCaughtError() { - try { - throw getStacktraceWithUncaughtError(); - } - catch (err) { - return err; - } -} -// Some implementations of exception handling don't create a stack trace if the exception -// isn't thrown, however it's faster not to actually throw the exception. -var error = getStacktraceWithUncaughtError(); -var caughtError = getStacktraceWithCaughtError(); -var getStacktrace = error.stack ? - getStacktraceWithUncaughtError : - (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); -function getFrames(error) { - return error.stack ? error.stack.split(NEWLINE) : []; -} -function addErrorStack(lines, error) { - var trace = getFrames(error); - for (var i = 0; i < trace.length; i++) { - var frame = trace[i]; - // Filter out the Frames which are part of stack capturing. - if (!IGNORE_FRAMES.hasOwnProperty(frame)) { - lines.push(trace[i]); + catch (err) { } - } -} -function renderLongStackTrace(frames, stack) { - var longTrace = [stack ? stack.trim() : '']; - if (frames) { - var timestamp = new Date().getTime(); - for (var i = 0; i < frames.length; i++) { - var traceFrames = frames[i]; - var lastTime = traceFrames.timestamp; - var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; - separator = separator.replace(/[^\w\d]/g, '_'); - longTrace.push(sepTemplate.replace(SEP_TAG, separator)); - addErrorStack(longTrace, traceFrames.error); - timestamp = lastTime.getTime(); + // use the generic patchMacroTask to patch crypto + if (crypto) { + var methodNames = ['randomBytes', 'pbkdf2']; + methodNames.forEach(function (name) { + patchMacroTask(crypto, name, function (self, args) { + return { + name: 'crypto.' + name, + args: args, + cbIdx: (args.length > 0 && typeof args[args.length - 1] === 'function') ? + args.length - 1 : + -1, + target: crypto + }; + }); + }); } + }); + Zone.__load_patch('console', function (global, Zone) { + var consoleMethods = ['dir', 'log', 'info', 'error', 'warn', 'assert', 'debug', 'timeEnd', 'trace']; + consoleMethods.forEach(function (m) { + var originalMethod = console[Zone.__symbol__(m)] = console[m]; + if (originalMethod) { + console[m] = function () { + var args = ArraySlice.call(arguments); + if (Zone.current === Zone.root) { + return originalMethod.apply(this, args); + } + else { + return Zone.root.run(originalMethod, this, 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 + */ + /** + * @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 + */ + /** + * @fileoverview + * @suppress {globalThis} + */ + var NEWLINE = '\n'; + var IGNORE_FRAMES = {}; + var creationTrace = '__creationTrace__'; + var ERROR_TAG = 'STACKTRACE TRACKING'; + var SEP_TAG = '__SEP_TAG__'; + var sepTemplate = SEP_TAG + '@[native]'; + var LongStackTrace = /** @class */ (function () { + function LongStackTrace() { + this.error = getStacktrace(); + this.timestamp = new Date(); + } + return LongStackTrace; + }()); + function getStacktraceWithUncaughtError() { + return new Error(ERROR_TAG); } - return longTrace.join(NEWLINE); -} -Zone['longStackTraceZoneSpec'] = { - name: 'long-stack-trace', - longStackTraceLimit: 10, - // add a getLongStackTrace method in spec to - // handle handled reject promise error. - getLongStackTrace: function (error) { - if (!error) { - return undefined; - } - var trace = error[Zone.__symbol__('currentTaskTrace')]; - if (!trace) { - return error.stack; + function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); } - return renderLongStackTrace(trace, error.stack); - }, - onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var currentTask = Zone.currentTask; - var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; - trace = [new LongStackTrace()].concat(trace); - if (trace.length > this.longStackTraceLimit) { - trace.length = this.longStackTraceLimit; + catch (err) { + return err; + } + } + // Some implementations of exception handling don't create a stack trace if the exception + // isn't thrown, however it's faster not to actually throw the exception. + var error = getStacktraceWithUncaughtError(); + var caughtError = getStacktraceWithCaughtError(); + var getStacktrace = error.stack ? + getStacktraceWithUncaughtError : + (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); + function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; + } + function addErrorStack(lines, error) { + var trace = getFrames(error); + for (var i = 0; i < trace.length; i++) { + var frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!IGNORE_FRAMES.hasOwnProperty(frame)) { + lines.push(trace[i]); + } + } + } + function renderLongStackTrace(frames, stack) { + var longTrace = [stack ? stack.trim() : '']; + if (frames) { + var timestamp = new Date().getTime(); + for (var i = 0; i < frames.length; i++) { + var traceFrames = frames[i]; + var lastTime = traceFrames.timestamp; + var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; + separator = separator.replace(/[^\w\d]/g, '_'); + longTrace.push(sepTemplate.replace(SEP_TAG, separator)); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); + } + } + return longTrace.join(NEWLINE); + } + Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + // add a getLongStackTrace method in spec to + // handle handled reject promise error. + getLongStackTrace: function (error) { + if (!error) { + return undefined; + } + var trace = error[Zone.__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; + } + return renderLongStackTrace(trace, error.stack); + }, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var currentTask = Zone.currentTask; + var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; + } + if (!task.data) + task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = Object.assign({}, task.data); + } + task.data[creationTrace] = trace; } - if (!task.data) - task.data = {}; - if (task.type === 'eventTask') { - // Fix issue https://github.com/angular/zone.js/issues/1195, - // For event task of browser, by default, all task will share a - // singleton instance of data object, we should create a new one here - // The cast to `any` is required to workaround a closure bug which wrongly applies - // URL sanitization rules to .data access. - task.data = __assign({}, task.data); + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + try { + error.stack = error.longStack = longStack; + } + catch (err) { + } + } } - task.data[creationTrace] = trace; + return parentZoneDelegate.handleError(targetZone, error); } - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var parentTask = Zone.currentTask || error.task; - if (error instanceof Error && parentTask) { - var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); - try { - error.stack = error.longStack = longStack; - } - catch (err) { + }; + function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); + } + } + function computeIgnoreFrames() { + if (Error.stackTraceLimit <= 0) { + return; + } + var frames = []; + captureStackTraces(frames, 2); + var frames1 = frames[0]; + var frames2 = frames[1]; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + if (frame1.indexOf(ERROR_TAG) == -1) { + var match = frame1.match(/^\s*at\s+/); + if (match) { + sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + break; } } } - return parentZoneDelegate.handleError(targetZone, error); - } -}; -function captureStackTraces(stackTraces, count) { - if (count > 0) { - stackTraces.push(getFrames((new LongStackTrace()).error)); - captureStackTraces(stackTraces, count - 1); - } -} -function computeIgnoreFrames() { - if (Error.stackTraceLimit <= 0) { - return; - } - var frames = []; - captureStackTraces(frames, 2); - var frames1 = frames[0]; - var frames2 = frames[1]; - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - if (frame1.indexOf(ERROR_TAG) == -1) { - var match = frame1.match(/^\s*at\s+/); - if (match) { - sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + var frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES[frame1] = true; + } + else { break; } } } - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - var frame2 = frames2[i]; - if (frame1 === frame2) { - IGNORE_FRAMES[frame1] = true; - } - else { - break; - } - } -} -computeIgnoreFrames(); - -/** - * @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 = /** @class */ (function () { - function ProxyZoneSpec(defaultSpecDelegate) { - if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } - this.defaultSpecDelegate = defaultSpecDelegate; - this.name = 'ProxyZone'; - this._delegateSpec = null; - this.properties = { 'ProxyZoneSpec': this }; - this.propertyKeys = null; - this.lastTaskState = null; - this.isNeedToTriggerHasTask = false; - this.tasks = []; - this.setDelegate(defaultSpecDelegate); - } - ProxyZoneSpec.get = function () { - return Zone.current.get('ProxyZoneSpec'); - }; - ProxyZoneSpec.isLoaded = function () { - return ProxyZoneSpec.get() instanceof ProxyZoneSpec; - }; - ProxyZoneSpec.assertPresent = function () { - if (!ProxyZoneSpec.isLoaded()) { - throw new Error("Expected to be running in 'ProxyZone', but it was not found."); - } - return ProxyZoneSpec.get(); - }; - ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { - var _this = this; - var isNewDelegate = this._delegateSpec !== delegateSpec; - this._delegateSpec = delegateSpec; - this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); - this.propertyKeys = null; - if (delegateSpec && delegateSpec.properties) { - this.propertyKeys = Object.keys(delegateSpec.properties); - this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); - } - // if set a new delegateSpec, shoulde check whether need to - // trigger hasTask or not - if (isNewDelegate && this.lastTaskState && - (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { - this.isNeedToTriggerHasTask = true; - } - }; - ProxyZoneSpec.prototype.getDelegate = function () { - return this._delegateSpec; - }; - ProxyZoneSpec.prototype.resetDelegate = function () { - var delegateSpec = this.getDelegate(); - this.setDelegate(this.defaultSpecDelegate); - }; - ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { - if (this.isNeedToTriggerHasTask && this.lastTaskState) { - // last delegateSpec has microTask or macroTask - // should call onHasTask in current delegateSpec + computeIgnoreFrames(); + /** + * @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 = /** @class */ (function () { + function ProxyZoneSpec(defaultSpecDelegate) { + if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } + this.defaultSpecDelegate = defaultSpecDelegate; + this.name = 'ProxyZone'; + this._delegateSpec = null; + this.properties = { 'ProxyZoneSpec': this }; + this.propertyKeys = null; + this.lastTaskState = null; this.isNeedToTriggerHasTask = false; - this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); - } - }; - ProxyZoneSpec.prototype.removeFromTasks = function (task) { - if (!this.tasks) { - return; + this.tasks = []; + this.setDelegate(defaultSpecDelegate); } - for (var i = 0; i < this.tasks.length; i++) { - if (this.tasks[i] === task) { - this.tasks.splice(i, 1); - return; + ProxyZoneSpec.get = function () { + return Zone.current.get('ProxyZoneSpec'); + }; + ProxyZoneSpec.isLoaded = function () { + return ProxyZoneSpec.get() instanceof ProxyZoneSpec; + }; + ProxyZoneSpec.assertPresent = function () { + if (!ProxyZoneSpec.isLoaded()) { + throw new Error("Expected to be running in 'ProxyZone', but it was not found."); } - } - }; - ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { - if (this.tasks.length === 0) { - return ''; - } - var taskInfo = this.tasks.map(function (task) { - var dataInfo = task.data && - Object.keys(task.data) - .map(function (key) { - return key + ':' + task.data[key]; - }) - .join(','); - return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; - }); - var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; - // clear tasks - this.tasks = []; - return pendingTasksInfo; - }; - ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { - if (this._delegateSpec && this._delegateSpec.onFork) { - return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); - } - else { - return parentZoneDelegate.fork(targetZone, zoneSpec); - } - }; - ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { - if (this._delegateSpec && this._delegateSpec.onIntercept) { - return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); - } - else { - return parentZoneDelegate.intercept(targetZone, delegate, source); - } - }; - ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvoke) { - return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); - } - else { - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - }; - ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - if (this._delegateSpec && this._delegateSpec.onHandleError) { - return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); - } - else { - return parentZoneDelegate.handleError(targetZone, error); - } - }; - ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.tasks.push(task); - } - if (this._delegateSpec && this._delegateSpec.onScheduleTask) { - return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.scheduleTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvokeTask) { - return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); - } - else { - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } - }; - ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onCancelTask) { - return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.cancelTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { - this.lastTaskState = hasTaskState; - if (this._delegateSpec && this._delegateSpec.onHasTask) { - this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); - } - else { - delegate.hasTask(target, hasTaskState); - } - }; - return ProxyZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['ProxyZoneSpec'] = ProxyZoneSpec; - -/** - * @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 = /** @class */ (function () { - function SyncTestZoneSpec(namePrefix) { - this.runZone = Zone.current; - this.name = 'syncTestZone for ' + namePrefix; - } - SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - case 'macroTask': - throw new Error("Cannot call " + task.source + " from within a sync test."); - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - return SyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; - -/** - * @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 __()); - }; - var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; - // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs - // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) - if (!Zone) - throw new Error('Missing: zone.js'); - if (typeof jasmine == 'undefined') - throw new Error('Missing: jasmine.js'); - if (jasmine['__zone_patch__']) - throw new Error("'jasmine' has already been patched with 'Zone'."); - jasmine['__zone_patch__'] = true; - var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (!SyncTestZoneSpec) - throw new Error('Missing: SyncTestZoneSpec'); - if (!ProxyZoneSpec) - throw new Error('Missing: ProxyZoneSpec'); - var ambientZone = Zone.current; - // Create a synchronous-only zone in which to run `describe` blocks in order to raise an - // error if any asynchronous operations are attempted inside of a `describe` but outside of - // a `beforeEach` or `it`. - var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - var symbol = Zone.__symbol__; - // whether patch jasmine clock when in fakeAsync - var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; - // the original variable name fakeAsyncPatchLock is not accurate, so the name will be - // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also - // automatically disable the auto jump into fakeAsync feature - var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && - ((_global[symbol('fakeAsyncPatchLock')] === true) || - (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); - var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; - if (!ignoreUnhandledRejection) { - var globalErrors_1 = jasmine.GlobalErrors; - if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { - jasmine[symbol('GlobalErrors')] = globalErrors_1; - jasmine.GlobalErrors = function () { - var instance = new globalErrors_1(); - var originalInstall = instance.install; - if (originalInstall && !instance[symbol('install')]) { - instance[symbol('install')] = originalInstall; - instance.install = function () { - var originalHandlers = process.listeners('unhandledRejection'); - var r = originalInstall.apply(this, arguments); - process.removeAllListeners('unhandledRejection'); - if (originalHandlers) { - originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); - } - return r; - }; + return ProxyZoneSpec.get(); + }; + ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { + var _this = this; + var isNewDelegate = this._delegateSpec !== delegateSpec; + this._delegateSpec = delegateSpec; + this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); + this.propertyKeys = null; + if (delegateSpec && delegateSpec.properties) { + this.propertyKeys = Object.keys(delegateSpec.properties); + this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); + } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; + } + }; + ProxyZoneSpec.prototype.getDelegate = function () { + return this._delegateSpec; + }; + ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); + this.setDelegate(this.defaultSpecDelegate); + }; + ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + } + }; + ProxyZoneSpec.prototype.removeFromTasks = function (task) { + if (!this.tasks) { + return; + } + for (var i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; } - return instance; - }; - } - } - // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. - var jasmineEnv = jasmine.getEnv(); - ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[methodName] = function (description, specDefinitions) { - return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + } }; - }); - ['it', 'xit', 'fit'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (description, specDefinitions, timeout) { - arguments[1] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); + ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { + if (this.tasks.length === 0) { + return ''; + } + var taskInfo = this.tasks.map(function (task) { + var dataInfo = task.data && + Object.keys(task.data) + .map(function (key) { + return key + ':' + task.data[key]; + }) + .join(','); + return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; + }); + var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; }; - }); - ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (specDefinitions, timeout) { - arguments[0] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); + ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); + } + else { + return parentZoneDelegate.fork(targetZone, zoneSpec); + } }; - }); - if (!disablePatchingJasmineClock) { - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableAutoFakeAsyncWhenClockPatched) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - } + ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { + if (this._delegateSpec && this._delegateSpec.onIntercept) { + return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); + } + else { + return parentZoneDelegate.intercept(targetZone, delegate, source); } - return clock; }; - } - /** - * Gets a function wrapping the body of a Jasmine `describe` block to execute in a - * synchronous-only zone. - */ - function wrapDescribeInZone(describeBody) { - return function () { - return syncZone.run(describeBody, this, arguments); + ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvoke) { + return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); + } + else { + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } }; - } - function runInTestZone(testBody, applyThis, queueRunner, done) { - var isClockInstalled = !!jasmine[symbol('clockInstalled')]; - var testProxyZoneSpec = queueRunner.testProxyZoneSpec; - var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { - // auto run a fakeAsync - var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; - if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { - testBody = fakeAsyncModule.fakeAsync(testBody); + ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + if (this._delegateSpec && this._delegateSpec.onHandleError) { + return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); } - } - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } - } - /** - * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to - * execute in a ProxyZone zone. - * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` - */ - function wrapTestInZone(testBody) { - // The `done` callback is only passed through if the function expects at least one argument. - // Note we have to make a function with correct number of arguments, otherwise jasmine will - // think that all functions are sync or async. - return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this, this.queueRunner, done); - } : function () { - return runInTestZone(testBody, this, this.queueRunner); - })); - } - var QueueRunner = jasmine.QueueRunner; - jasmine.QueueRunner = (function (_super) { - __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs) { - var _this = this; - attrs.onComplete = (function (fn) { return function () { - // All functions are done, clear the test zone. - _this.testProxyZone = null; - _this.testProxyZoneSpec = null; - ambientZone.scheduleMicroTask('jasmine.onComplete', fn); - }; })(attrs.onComplete); - var nativeSetTimeout = _global['__zone_symbol__setTimeout']; - var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; - if (nativeSetTimeout) { - // should run setTimeout inside jasmine outside of zone - attrs.timeout = { - setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, - clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout - }; + else { + return parentZoneDelegate.handleError(targetZone, error); } - // create a userContext to hold the queueRunner itself - // so we can access the testProxy in it/xit/beforeEach ... - if (jasmine.UserContext) { - if (!attrs.userContext) { - attrs.userContext = new jasmine.UserContext(); - } - attrs.userContext.queueRunner = this; + }; + ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); + } + if (this._delegateSpec && this._delegateSpec.onScheduleTask) { + return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); } else { - if (!attrs.userContext) { - attrs.userContext = {}; - } - attrs.userContext.queueRunner = this; + return parentZoneDelegate.scheduleTask(targetZone, task); } - // patch attrs.onException - var onException = attrs.onException; - attrs.onException = function (error) { - if (error && - error.message === - 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { - // jasmine timeout, we can make the error message more - // reasonable to tell what tasks are pending - var proxyZoneSpec = this && this.testProxyZoneSpec; - if (proxyZoneSpec) { - var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - try { - // try catch here in case error.message is not writable - error.message += pendingTasksInfo; + }; + ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { + return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); + } + else { + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); + } + }; + ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onCancelTask) { + return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.cancelTask(targetZone, task); + } + }; + ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; + if (this._delegateSpec && this._delegateSpec.onHasTask) { + this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); + } + else { + delegate.hasTask(target, hasTaskState); + } + }; + return ProxyZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['ProxyZoneSpec'] = ProxyZoneSpec; + /** + * @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 = /** @class */ (function () { + function SyncTestZoneSpec(namePrefix) { + this.runZone = Zone.current; + this.name = 'syncTestZone for ' + namePrefix; + } + SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + case 'macroTask': + throw new Error("Cannot call " + task.source + " from within a sync test."); + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + return SyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; + (function (_global) { + 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'."); + jasmine['__zone_patch__'] = true; + var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (!SyncTestZoneSpec) + throw new Error('Missing: SyncTestZoneSpec'); + if (!ProxyZoneSpec) + throw new Error('Missing: ProxyZoneSpec'); + var ambientZone = Zone.current; + // Create a synchronous-only zone in which to run `describe` blocks in order to raise an + // error if any asynchronous operations are attempted inside of a `describe` but outside of + // a `beforeEach` or `it`. + var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. + var jasmineEnv = jasmine.getEnv(); + ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[methodName] = function (description, specDefinitions) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + }; + }); + ['it', 'xit', 'fit'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); } - catch (err) { + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); } } - if (onException) { - onException.call(this, error); - } + return clock; }; - _super.call(this, attrs); } - ZoneQueueRunner.prototype.execute = function () { - var _this = this; - var zone = Zone.current; - var isChildOfAmbientZone = false; - while (zone) { - if (zone === ambientZone) { - isChildOfAmbientZone = true; - break; + /** + * Gets a function wrapping the body of a Jasmine `describe` block to execute in a + * synchronous-only zone. + */ + function wrapDescribeInZone(describeBody) { + return function () { + return syncZone.run(describeBody, this, arguments); + }; + } + function runInTestZone(testBody, applyThis, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); } - zone = zone.parent; } - if (!isChildOfAmbientZone) - throw new Error('Unexpected Zone: ' + Zone.current.name); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - this.testProxyZoneSpec = new ProxyZoneSpec(); - this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); - if (!Zone.currentTask) { - // if we are not running in a task then if someone would register a - // element.addEventListener and then calling element.click() the - // addEventListener callback would think that it is the top most task and would - // drain the microtask queue on element.click() which would be incorrect. - // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } else { - _super.prototype.execute.call(this); - } - }; - return ZoneQueueRunner; - })(QueueRunner); -})(); - -/** - * @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 _global$1 = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; -var AsyncTestZoneSpec = /** @class */ (function () { - function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { - this.finishCallback = finishCallback; - this.failCallback = failCallback; - this._pendingMicroTasks = false; - this._pendingMacroTasks = false; - this._alreadyErrored = false; - this._isSync = false; - this.runZone = Zone.current; - this.unresolvedChainedPromiseCount = 0; - this.supportWaitUnresolvedChainedPromise = false; - this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { 'AsyncTestZoneSpec': this }; - this.supportWaitUnresolvedChainedPromise = - _global$1[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; - } - AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { - return this.unresolvedChainedPromiseCount > 0; - }; - AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { - var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || - (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { - // We do this because we would like to catch unhandled rejected promises. - this.runZone.run(function () { - setTimeout(function () { - if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this.finishCallback(); + return testProxyZone.run(testBody, applyThis); + } + } + /** + * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to + * execute in a ProxyZone zone. + * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` + */ + function wrapTestInZone(testBody) { + // The `done` callback is only passed through if the function expects at least one argument. + // Note we have to make a function with correct number of arguments, otherwise jasmine will + // think that all functions are sync or async. + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this, this.queueRunner, done); + } : function () { + return runInTestZone(testBody, this, this.queueRunner); + })); + } + var QueueRunner = jasmine.QueueRunner; + jasmine.QueueRunner = (function (_super) { + __extends(ZoneQueueRunner, _super); + function ZoneQueueRunner(attrs) { + var _this = this; + attrs.onComplete = (function (fn) { return function () { + // All functions are done, clear the test zone. + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + }; })(attrs.onComplete); + var nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; + var nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; + } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); } - }, 0); - }); - } - }; - AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; - if (patchPromiseForTest) { - patchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; - if (unPatchPromiseForTest) { - unPatchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise - if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { - // chained promise is being scheduled - this.unresolvedChainedPromiseCount--; - } - } - return delegate.scheduleTask(target, task); - }; - AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.invokeTask(target, task, applyThis, applyArgs); - }; - AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.cancelTask(target, task); - }; - // 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. - // updated by(JiaLiPassion), only call finish callback when no task - // was scheduled/invoked/canceled. - AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - try { - this._isSync = true; - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - finally { - var afterTaskCounts = parentZoneDelegate._taskCounts; - if (this._isSync) { - this._finishCallbackIfDone(); + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; + } + catch (err) { + } + } + } + if (onException) { + onException.call(this, error); + } + }; + _super.call(this, attrs); } - } - }; - AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - // Let the parent try to handle the error. - var result = parentZoneDelegate.handleError(targetZone, error); - if (result) { - this.failCallback(error); - this._alreadyErrored = true; - } - return false; - }; - AsyncTestZoneSpec.prototype.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(); - } - }; - AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); - return AsyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; - -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { + ZoneQueueRunner.prototype.execute = function () { + var _this = this; + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; + } + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); + if (!Zone.currentTask) { + // if we are not running in a task then if someone would register a + // element.addEventListener and then calling element.click() the + // addEventListener callback would think that it is the top most task and would + // drain the microtask queue on element.click() which would be incorrect. + // For this reason we always force a task when running jasmine tests. + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); + } + else { + _super.prototype.execute.call(this); + } + }; + return ZoneQueueRunner; + })(QueueRunner); + })(commonjsGlobal); /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. + * @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[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; + (function (_global) { + var AsyncTestZoneSpec = /** @class */ (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this._isSync = false; + this.runZone = Zone.current; + this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; + this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; + } + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { + _this.finishCallback(); + } + }, 0); + }); + } + }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; } - else { - done.fail(err); + } + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + try { + this._isSync = true; + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); + } + finally { + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } + } + }; + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this.failCallback(error); + this._alreadyErrored = true; + } + return false; + }; + AsyncTestZoneSpec.prototype.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; + }()); + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + })(commonjsGlobal); + /** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; + } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); }); }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - testZoneSpec.patchPromiseForTest(); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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 __read = (undefined && undefined.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (undefined && undefined.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -(function (global) { - var OriginalDate = global.Date; - var FakeDate = /** @class */ (function () { - function FakeDate() { - if (arguments.length === 0) { - var d = new OriginalDate(); - d.setTime(FakeDate.now()); - return d; - } - else { - var args = Array.prototype.slice.call(arguments); - return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); - } + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); + } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); } - FakeDate.now = function () { - var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncTestZoneSpec) { - return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + }); + /** + * @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) { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, [void 0].concat(args)))(); + } } - return OriginalDate.now.apply(this, arguments); - }; - return FakeDate; - }()); - FakeDate.UTC = OriginalDate.UTC; - FakeDate.parse = OriginalDate.parse; - // keep a reference for zone patched timer function - var timers = { - setTimeout: global.setTimeout, - setInterval: global.setInterval, - clearTimeout: global.clearTimeout, - clearInterval: global.clearInterval - }; - var Scheduler = /** @class */ (function () { - function Scheduler() { - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - this._schedulerQueue = []; - // Current simulated time in millis. - this._currentTime = 0; - // Current real time in millis. - this._currentRealTime = OriginalDate.now(); - } - Scheduler.prototype.getCurrentTime = function () { - return this._currentTime; - }; - Scheduler.prototype.getCurrentRealTime = function () { - return this._currentRealTime; - }; - Scheduler.prototype.setCurrentRealTime = function (realTime) { - this._currentRealTime = realTime; - }; - Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { - if (args === void 0) { args = []; } - if (isPeriodic === void 0) { isPeriodic = false; } - if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } - if (id === void 0) { id = -1; } - var currentId = id < 0 ? Scheduler.nextId++ : id; - var endTime = this._currentTime + delay; - // Insert so that scheduler queue remains sorted by end time. - var newEntry = { - endTime: endTime, - id: currentId, - func: cb, - args: args, - delay: delay, - isPeriodic: isPeriodic, - isRequestAnimationFrame: isRequestAnimationFrame + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); }; - var i = 0; - for (; i < this._schedulerQueue.length; i++) { - var currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; + return FakeDate; + }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; + var Scheduler = /** @class */ (function () { + function Scheduler() { + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = OriginalDate.now(); + } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; + Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { + if (args === void 0) { args = []; } + if (isPeriodic === void 0) { isPeriodic = false; } + if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } + if (id === void 0) { id = -1; } + var currentId = id < 0 ? Scheduler.nextId++ : id; + var endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + var newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + var i = 0; + for (; i < this._schedulerQueue.length; i++) { + var currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } + } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + }; + Scheduler.prototype.removeScheduledFunctionWithId = function (id) { + for (var i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; + } + } + }; + Scheduler.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + var finalTime = this._currentTime + millis; + var lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + var current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; + } + else { + // Time to run scheduled function. Remove it from the head of queue. + var current_1 = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current_1.endTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } } - } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - }; - Scheduler.prototype.removeScheduledFunctionWithId = function (id) { - for (var i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; + lastCurrentTime = this._currentTime; + this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); } - } - }; - Scheduler.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - var finalTime = this._currentTime + millis; - var lastCurrentTime = 0; - if (this._schedulerQueue.length === 0 && doTick) { - doTick(millis); - return; - } - while (this._schedulerQueue.length > 0) { - var current = this._schedulerQueue[0]; - if (finalTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. - break; + }; + Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { + if (limit === void 0) { limit = 20; } + if (flushPeriodic === void 0) { flushPeriodic = false; } + if (flushPeriodic) { + return this.flushPeriodic(doTick); } else { - // Time to run scheduled function. Remove it from the head of queue. - var current_1 = this._schedulerQueue.shift(); + return this.flushNonPeriodic(limit, doTick); + } + }; + Scheduler.prototype.flushPeriodic = function (doTick) { + if (this._schedulerQueue.length === 0) { + return 0; + } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + var startTime = this._currentTime; + var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + }; + Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { + var startTime = this._currentTime; + var lastCurrentTime = 0; + var count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error('flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) + .length === 0) { + break; + } + var current = this._schedulerQueue.shift(); lastCurrentTime = this._currentTime; - this._currentTime = current_1.endTime; + this._currentTime = current.endTime; if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. doTick(this._currentTime - lastCurrentTime); } - var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + var retval = current.func.apply(global, current.args); if (!retval) { // Uncaught exception in the current scheduled function. Stop processing the queue. break; } } - } - lastCurrentTime = this._currentTime; - this._currentTime = finalTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - }; - Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { - if (limit === void 0) { limit = 20; } - if (flushPeriodic === void 0) { flushPeriodic = false; } - if (flushPeriodic) { - return this.flushPeriodic(doTick); - } - else { - return this.flushNonPeriodic(limit, doTick); - } - }; - Scheduler.prototype.flushPeriodic = function (doTick) { - if (this._schedulerQueue.length === 0) { - return 0; - } - // Find the last task currently queued in the scheduler queue and tick - // till that time. - var startTime = this._currentTime; - var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; - this.tick(lastTask.endTime - startTime, doTick); - return this._currentTime - startTime; - }; - Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { - var startTime = this._currentTime; - var lastCurrentTime = 0; - var count = 0; - while (this._schedulerQueue.length > 0) { - count++; - if (count > limit) { - throw new Error('flush failed after reaching the limit of ' + limit + - ' tasks. Does your code use a polling timeout?'); - } - // flush only non-periodic timers. - // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. - if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) - .length === 0) { - break; - } - var current = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current.endTime; - if (doTick) { - // Update any secondary schedulers like Jasmine mock Date. - doTick(this._currentTime - lastCurrentTime); - } - var retval = current.func.apply(global, current.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } - return this._currentTime - startTime; - }; + return this._currentTime - startTime; + }; + return Scheduler; + }()); // Next scheduler id. Scheduler.nextId = 1; - return Scheduler; - }()); - var FakeAsyncTestZoneSpec = /** @class */ (function () { - function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { - if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } - this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; - this.macroTaskOptions = macroTaskOptions; - this._scheduler = new Scheduler(); - this._microtasks = []; - this._lastError = null; - this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; - this.pendingPeriodicTimers = []; - this.pendingTimers = []; - this.patchDateLocked = false; - this.properties = { 'FakeAsyncTestZoneSpec': this }; - this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakeAsyncTestSpec - // user can also define macroTaskOptions by define a global variable. - if (!this.macroTaskOptions) { - this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; - } - } - FakeAsyncTestZoneSpec.assertInZone = function () { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } - }; - FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { - var _this = this; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; + var FakeAsyncTestZoneSpec = /** @class */ (function () { + function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { + if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } + this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; + this.macroTaskOptions = macroTaskOptions; + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.patchDateLocked = false; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + } + } + FakeAsyncTestZoneSpec.assertInZone = function () { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); } - fn.apply(global, args); - if (_this._lastError === null) { // Success - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); + }; + FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { + var _this = this; + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + fn.apply(global, args); + if (_this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + _this.flushMicrotasks(); } - // Flush microtasks only on success. - _this.flushMicrotasks(); + else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } + } + // Return true if there were no errors, false otherwise. + return _this._lastError === null; + }; + }; + FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { + var index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); } - else { // Failure - if (completers.onError != null) { - completers.onError.apply(global); + }; + FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { + var _this = this; + return function () { + // Requeue the timer callback if it's not been canceled. + if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { + _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); } + }; + }; + FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { + if (isTimer === void 0) { isTimer = true; } + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); + } + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { + var id = Scheduler.nextId; + var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + var cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { + var error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; } - // Return true if there were no errors, false otherwise. - return _this._lastError === null; + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); }; - }; - FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { - var index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); - } - }; - FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } }; - }; - FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { - var _this = this; - return function () { - // Requeue the timer callback if it's not been canceled. - if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { - _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; } }; - }; - FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); }; - }; - FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { - if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(Scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); - var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); - if (isTimer) { - this.pendingTimers.push(id); - } - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = Scheduler.nextId; - var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; - var cb = this._fnAndFlush(fn, completers); - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args, true); - this.pendingPeriodicTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { - var error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - }; - FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { - return this._scheduler.getCurrentTime(); - }; - FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { - return this._scheduler.getCurrentRealTime(); - }; - FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { - this._scheduler.setCurrentRealTime(realTime); - }; - FakeAsyncTestZoneSpec.patchDate = function () { - if (!!global[Zone.__symbol__('disableDatePatching')]) { - // we don't want to patch global Date - // because in some case, global Date - // is already being patched, we need to provide - // an option to let user still use their - // own version of Date. - return; - } - if (global['Date'] === FakeDate) { - // already patched - return; - } - global['Date'] = FakeDate; - FakeDate.prototype = OriginalDate.prototype; - // try check and reset timers - // because jasmine.clock().install() may - // have replaced the global timer - FakeAsyncTestZoneSpec.checkTimerPatch(); - }; - FakeAsyncTestZoneSpec.resetDate = function () { - if (global['Date'] === FakeDate) { - global['Date'] = OriginalDate; - } - }; - FakeAsyncTestZoneSpec.checkTimerPatch = function () { - if (global.setTimeout !== timers.setTimeout) { - global.setTimeout = timers.setTimeout; - global.clearTimeout = timers.clearTimeout; - } - if (global.setInterval !== timers.setInterval) { - global.setInterval = timers.setInterval; - global.clearInterval = timers.clearInterval; - } - }; - FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { - this.patchDateLocked = true; - FakeAsyncTestZoneSpec.patchDate(); - }; - FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { - this.patchDateLocked = false; - FakeAsyncTestZoneSpec.resetDate(); - }; - FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - }; - FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { - var _this = this; - FakeAsyncTestZoneSpec.assertInZone(); - var flushErrors = function () { - if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - _this._resetLastErrorAndThrow(); + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; + FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); } }; - while (this._microtasks.length > 0) { - var microtask = this._microtasks.shift(); - microtask.func.apply(microtask.target, microtask.args); - } - flushErrors(); - }; - FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - return elapsed; - }; - FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - var args = task.data && task.data.args; - // should pass additional arguments to callback if have any - // currently we know process.nextTick will have such additional - // arguments - var additionalArgs = void 0; - if (args) { - var callbackIndex = task.data.cbIdx; - if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); - } + FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { + var _this = this; + FakeAsyncTestZoneSpec.assertInZone(); + var flushErrors = function () { + if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + _this._resetLastErrorAndThrow(); } - this._microtasks.push({ - func: task.invoke, - args: additionalArgs, - target: task.data && task.data.target - }); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'setImmediate': - task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); - break; - case 'setInterval': - task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'XMLHttpRequest.send': - throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + - task.data['url']); - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. - // (60 frames per second) - task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); - break; - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var args_1 = task.data && task.data['args']; - var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; - var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; - if (!!macroTaskOption.isPeriodic) { - // periodic macroTask, use setInterval to simulate - task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data.isPeriodic = true; - } - else { - // not periodic, use setTimeout to simulate - task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); - } - break; + }; + while (this._microtasks.length > 0) { + var microtask = this._microtasks.shift(); + microtask.func.apply(microtask.target, microtask.args); + } + flushErrors(); + }; + FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + }; + FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + var args = task.data && task.data.args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + var additionalArgs = void 0; + if (args) { + var callbackIndex = task.data.cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); } - throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && task.data.target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; + case 'setInterval': + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + + task.data['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var args_1 = task.data && task.data['args']; + var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; + var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data.isPeriodic = true; + } + else { + // not periodic, use setTimeout to simulate + task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + } + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var handleId = task.data['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); + } + }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - switch (task.source) { - case 'setTimeout': - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data['handleId']); - case 'setInterval': - return this._clearInterval(task.data['handleId']); - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var handleId = task.data['handleId']; - return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : - this._clearTimeout(handleId); + } + }; + FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { + if (!this.macroTaskOptions) { + return null; + } + for (var i = 0; i < this.macroTaskOptions.length; i++) { + var macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; } - return delegate.cancelTask(target, task); - } - }; - FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { - try { - FakeAsyncTestZoneSpec.patchDate(); - return delegate.invoke(target, callback, applyThis, applyArgs, source); - } - finally { - if (!this.patchDateLocked) { - FakeAsyncTestZoneSpec.resetDate(); } - } - }; - FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { - if (!this.macroTaskOptions) { return null; - } - for (var i = 0; i < this.macroTaskOptions.length; i++) { - var macroTaskOption = this.macroTaskOptions[i]; - if (macroTaskOption.source === task.source) { - return macroTaskOption; - } - } - return null; - }; - FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - this._lastError = error; - return false; // Don't propagate error to parent zone. - }; - return FakeAsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; - /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. - * - * @experimental - */ - function resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } + }; + FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + }; + return FakeAsyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; + })(commonjsGlobal); /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * @license + * Copyright Google Inc. All Rights Reserved. * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental + * 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 fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); - } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); - } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); try { - res = fn.apply(this, args); - flushMicrotasks(); + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; } finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); - } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); - } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + resetFakeAsyncZone(); } - return res; - } - finally { - resetFakeAsyncZone(); - } - }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); - } + }; } - return _fakeAsyncTestZoneSpec; - } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; + }); /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. + * @license + * Copyright Google Inc. All Rights Reserved. * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental + * 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 tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. - * - * @param maxTurns - * @returns The simulated time elapsed, in millis. + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. * - * @experimental + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); */ - function flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } + Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } + } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; + } + }; + }); /** - * Discard all remaining periodic tasks. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } /** - * Flush any pending microtasks. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - -/** - * @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 - */ -/** - * Promise for async/fakeAsync zoneSpec test - * can support async operation which not supported by zone.js - * such as - * it ('test jsonp in AsyncZone', async() => { - * new Promise(res => { - * jsonp(url, (data) => { - * // success callback - * res(data); - * }); - * }).then((jsonpResult) => { - * // get jsonp result. - * - * // user will expect AsyncZoneSpec wait for - * // then, but because jsonp is not zone aware - * // AsyncZone will finish before then is called. - * }); - * }); - */ -Zone.__load_patch('promisefortest', function (global, Zone, api) { - var symbolState = api.symbol('state'); - var UNRESOLVED = null; - var symbolParentUnresolved = api.symbol('parentUnresolved'); - // patch Promise.prototype.then to keep an internal - // number for tracking unresolved chained promise - // we will decrease this number when the parent promise - // being resolved/rejected and chained promise was - // scheduled as a microTask. - // so we can know such kind of chained promise still - // not resolved in AsyncTestZone - Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - return; - } - oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; - Promise.prototype.then = function () { - var chained = oriThen.apply(this, arguments); - if (this[symbolState] === UNRESOLVED) { - // parent promise is unresolved. - var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); - if (asyncTestZoneSpec) { - asyncTestZoneSpec.unresolvedChainedPromiseCount++; - chained[symbolParentUnresolved] = true; - } - } - return chained; - }; - }; - Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { - // restore origin then - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - Promise.prototype.then = oriThen; - Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; - } - }; -}); - -/** - * @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 - */ -// load test related files into bundle in correct order - -/** - * @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 - */ -// load test related files into bundle - -}))); +})); +//# sourceMappingURL=zone-testing-node-bundle-rollup.umd.js.map diff --git a/dist/zone-testing-node-bundle.min.js b/dist/zone-testing-node-bundle.min.js new file mode 100755 index 000000000..931cb1ca2 --- /dev/null +++ b/dist/zone-testing-node-bundle.min.js @@ -0,0 +1,155 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; +/** + * @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(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=e.__Zone_symbol_prefix||"__zone_symbol__";function i(e){return o+e}var a=!0===e[i("forceDuplicateZoneCheck")];if(e.Zone){if(a||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var s=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==C.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return j.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return A},enumerable:!0,configurable:!0}),t.__load_patch=function(o,i){if(C.hasOwnProperty(o)){if(a)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var s="Zone:"+o;n(s),C[o]=i(e,t,I),r(s,s)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){j={parent:j,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{j=j.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),j={parent:j,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{j=j.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");if(e.state!==T||e.type!==D&&e.type!==E){var r=e.state!=Z;r&&e._transitionTo(Z,b),e.runCount++;var o=A;A=e,j={parent:j,zone:this};try{e.type==E&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==T&&e.state!==w&&(e.type==D||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,Z):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(T,Z,T))),j=j.parent,A=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(g,T);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(w,g,T),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==g&&e._transitionTo(b,g),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new h(S,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new h(E,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new h(D,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");e._transitionTo(P,b,Z);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(w,P),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(T,P),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})},e}(),h=function(){function t(n,r,o,i,a,s){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=i,this.scheduleFn=a,this.cancelFn=s,this.callback=o;var c=this;this.invoke=n===D&&i&&i.useG?t.invokeTask:function(){return t.invokeTask.call(e,c,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&m(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(T,g)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==T&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),f=i("setTimeout"),p=i("Promise"),d=i("then"),_=[],v=!1;function k(t){if(0===z&&0===_.length)if(c||e[p]&&(c=e[p].resolve(0)),c){var n=c[d];n||(n=c.then),n.call(c,m)}else e[f](m,0);t&&_.push(t)}function m(){if(!v){for(v=!0;_.length;){var e=_;_=[];for(var t=0;t=0;n--)"function"==typeof e[n]&&(e[n]=c(e[n],t+"_"+n));return e}var k="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,m=!("nw"in p)&&void 0!==p.process&&"[object process]"==={}.toString.call(p.process),y=!m&&!k&&!(!h||!f.HTMLElement),T=void 0!==p.process&&"[object process]"==={}.toString.call(p.process)&&!k&&!(!h||!f.HTMLElement),g={},b=function(e){if(e=e||p.event){var t=g[e.type];t||(t=g[e.type]=l("ON_PROPERTY"+e.type));var n,r=this||e.target||p,o=r[t];return y&&r===f&&"error"===e.type?!0===(n=o&&o.call(this,e.message,e.filename,e.lineno,e.colno,e.error))&&e.preventDefault():null==(n=o&&o.apply(this,arguments))||n||e.preventDefault(),n}};function Z(e,r,o){var i=t(e,r);if(!i&&o&&t(o,r)&&(i={enumerable:!0,configurable:!0}),i&&i.configurable){var a=l("on"+r+"patched");if(!e.hasOwnProperty(a)||!e[a]){delete i.writable,delete i.value;var s=i.get,c=i.set,u=r.substr(2),h=g[u];h||(h=g[u]=l("ON_PROPERTY"+u)),i.set=function(t){var n=this;n||e!==p||(n=p),n&&(n[h]&&n.removeEventListener(u,b),c&&c.apply(n,_),"function"==typeof t?(n[h]=t,n.addEventListener(u,b,!1)):n[h]=null)},i.get=function(){var t=this;if(t||e!==p||(t=p),!t)return null;var n=t[h];if(n)return n;if(s){var o=s&&s.call(this);if(o)return i.set.call(this,o),"function"==typeof t[d]&&t.removeAttribute(r),o}return null},n(e,r,i),e[a]=!0}}}function P(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[i.cbIdx]?u(i.name,r[i.cbIdx],i,o):e.apply(t,r)}})}function D(e,t){e[l("OriginalDelegate")]=t} +/** + * @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.__load_patch("toString",function(e){var t=Function.prototype.toString,n=l("OriginalDelegate"),r=l("Promise"),o=l("Error"),i=function i(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var s=e[r];if(s)return t.call(s)}if(this===Error){var c=e[o];if(c)return t.call(c)}}return t.call(this)};i[n]=t,Function.prototype.toString=i;var a=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":a.call(this)}}), +/** + * @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.__load_patch("node_util",function(e,t,n){n.patchOnProperties=P,n.patchMethod=S,n.bindArguments=v,n.patchMacroTask=E,function r(e){w=e}(!0)}); +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +var C=!1;if("undefined"!=typeof window)try{var I=Object.defineProperty({},"passive",{get:function(){C=!0}});window.addEventListener("test",I,I),window.removeEventListener("test",I,I)}catch(e){C=!1}var j={useG:!0},A={},z={},O=new RegExp("^"+s+"(\\w+)(true|false)$"),x=l("propagationStopped");function F(e,t){var n=[];for(var r in e){var o=O.exec(r),i=o&&o[1];if(i&&(!t||i===t)){var a=e[r];if(a)for(var s=0;s0?n.length-1:-1,target:e}})})}); +/** + * @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 R=l("zoneTask");function L(e,t,n,r){var o=null,i=null;n+=r;var a={};function s(t){var n=t.data;return n.args[0]=function r(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete a[n.handleId]:n.handleId&&(n.handleId[R]=null))}},n.handleId=o.apply(e,n.args),t}function c(e){return i(e.data.handleId)}o=S(e,t+=r,function(n){return function(o,i){if("function"==typeof i[0]){var l=u(t,i[0],{isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?i[1]||0:void 0,args:i},s,c);if(!l)return l;var h=l.data.handleId;return"number"==typeof h?a[h]=l:h&&(h[R]=l),h&&h.ref&&h.unref&&"function"==typeof h.ref&&"function"==typeof h.unref&&(l.ref=h.ref.bind(h),l.unref=h.unref.bind(h)),"number"==typeof h||h?h:l}return n.apply(e,i)}}),i=S(e,n,function(t){return function(n,r){var o,i=r[0];"number"==typeof i?o=a[i]:(o=i&&i[R])||(o=i),o&&"string"==typeof o.type?"notScheduled"!==o.state&&(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&("number"==typeof i?delete a[i]:i&&(i[R]=null),o.zone.cancelTask(o)):t.apply(e,r)}})} +/** + * @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 M="set";Zone.__load_patch("node_timers",function(e,t){var n=!1;try{var r=require("timers");if(e.setTimeout!==r.setTimeout&&!T){var o=r.setTimeout;r.setTimeout=function(){return n=!0,o.apply(this,arguments)};var i=e.setTimeout(function(){},100);clearTimeout(i),r.setTimeout=o}L(r,M,"clear","Timeout"),L(r,M,"clear","Interval"),L(r,M,"clear","Immediate")}catch(e){}T||(n?(e[t.__symbol__("setTimeout")]=e.setTimeout,e[t.__symbol__("setInterval")]=e.setInterval,e[t.__symbol__("setImmediate")]=e.setImmediate):(L(e,M,"clear","Timeout"),L(e,M,"clear","Interval"),L(e,M,"clear","Immediate")))}),Zone.__load_patch("nextTick",function(){!function e(t,n,r){var o=null;function i(e){var t=e.data;return t.args[t.cbIdx]=function(){e.invoke.apply(this,arguments)},o.apply(t.target,t.args),e}o=S(t,n,function(e){return function(t,n){var o=r(t,n);return o.cbIdx>=0&&"function"==typeof n[o.cbIdx]?Zone.current.scheduleMicroTask(o.name,n[o.cbIdx],o,i):e.apply(t,n)}})}(process,"nextTick",function(e,t){return{name:"process.nextTick",args:t,cbIdx:t.length>0&&"function"==typeof t[0]?0:-1,target:process}})}),Zone.__load_patch("handleUnhandledPromiseRejection",function(e,t,n){function r(e){return function(t){F(process,e).forEach(function(n){"unhandledRejection"===e?n.invoke(t.rejection,t.promise):"rejectionHandled"===e&&n.invoke(t.promise)})}}t[n.symbol("unhandledPromiseRejectionHandler")]=r("unhandledRejection"),t[n.symbol("rejectionHandledHandler")]=r("rejectionHandled")}),Zone.__load_patch("crypto",function(){var e;try{e=require("crypto")}catch(e){}e&&["randomBytes","pbkdf2"].forEach(function(t){E(e,t,function(n,r){return{name:"crypto."+t,args:r,cbIdx:r.length>0&&"function"==typeof r[r.length-1]?r.length-1:-1,target:e}})})}),Zone.__load_patch("console",function(e,t){["dir","log","info","error","warn","assert","debug","timeEnd","trace"].forEach(function(e){var n=console[t.__symbol__(e)]=console[e];n&&(console[e]=function(){var e=o.call(arguments);return t.current===t.root?n.apply(this,e):t.root.run(n,this,e)})})}); +/** + * @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 + */ +/** + * @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 H="\n",U={},q="STACKTRACE TRACKING",N="__SEP_TAG__",G=N+"@[native]",Q=function Q(){this.error=J(),this.timestamp=new Date};function W(){return new Error(q)}function K(){try{throw W()}catch(e){return e}}var V=W(),B=K(),J=V.stack?W:B.stack?K:W;function X(e){return e.stack?e.stack.split(H):[]}function Y(e,t){for(var n=X(t),r=0;r0){var o=Zone.currentTask,i=o&&o.data&&o.data.__creationTrace__||[];(i=[new Q].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),r.data||(r.data={}),"eventTask"===r.type&&(r.data=Object.assign({},r.data)),r.data.__creationTrace__=i}return e.scheduleTask(n,r)},onHandleError:function(e,t,n,r){if(Error.stackTraceLimit>0){var o=Zone.currentTask||r.task;if(r instanceof Error&&o){var i=$(o.data&&o.data.__creationTrace__,r.stack);try{r.stack=r.longStack=i}catch(e){}}}return e.handleError(n,r)}},function ee(){if(!(Error.stackTraceLimit<=0)){var e=[];!function e(t,n){n>0&&(t.push(X((new Q).error)),e(t,n-1))}(e,2);for(var t=e[0],n=e[1],r=0;r0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,t&&"function"==typeof t.getTime?[t.getTime()]:arguments)}return n.apply(this,arguments)},s&&["install","uninstall"].forEach(function(t){var n=e[i(t)]=e[t];e[t]=function(){if(!Zone.FakeAsyncTestZoneSpec)return n.apply(this,arguments);jasmine[i("clockInstalled")]="install"===t}})}return e}}function h(e,t,n,r){var o=!!jasmine[i("clockInstalled")],a=n.testProxyZone;if(o&&s){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return r?a.run(e,t,[r]):a.run(e,t)}function f(e){return e&&(e.length?function(t){return h(e,this,this.queueRunner,t)}:function(){return h(e,this,this.queueRunner)})}var p=jasmine.QueueRunner;jasmine.QueueRunner=function(t){function o(n){var o,i=this;n.onComplete=(o=n.onComplete,function(){i.testProxyZone=null,i.testProxyZoneSpec=null,r.scheduleMicroTask("jasmine.onComplete",o)});var a=e[Zone.__symbol__("setTimeout")],s=e[Zone.__symbol__("clearTimeout")];a&&(n.timeout={setTimeout:a||e.setTimeout,clearTimeout:s||e.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var t=this&&this.testProxyZoneSpec;if(t){var n=t.getAndClearPendingTasksInfo();try{e.message+=n}catch(e){}}}c&&c.call(this,e)},t.call(this,n)}return function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);function r(){this.constructor=e}e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(o,t),o.prototype.execute=function(){for(var e=this,o=Zone.current,i=!1;o;){if(o===r){i=!0;break}o=o.parent}if(!i)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new n,this.testProxyZone=r.fork(this.testProxyZoneSpec),Zone.currentTask?t.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return p.prototype.execute.call(e)})},o}(p)}(e), +/** + * @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(e){var t=function(){function t(t,n,r){this.finishCallback=t,this.failCallback=n,this._pendingMicroTasks=!1,this._pendingMacroTasks=!1,this._alreadyErrored=!1,this._isSync=!1,this.runZone=Zone.current,this.unresolvedChainedPromiseCount=0,this.supportWaitUnresolvedChainedPromise=!1,this.name="asyncTestZone for "+r,this.properties={AsyncTestZoneSpec:this},this.supportWaitUnresolvedChainedPromise=!0===e[Zone.__symbol__("supportWaitUnResolvedChainedPromise")]}return t.prototype.isUnresolvedChainedPromisePending=function(){return this.unresolvedChainedPromiseCount>0},t.prototype._finishCallbackIfDone=function(){var e=this;this._pendingMicroTasks||this._pendingMacroTasks||this.supportWaitUnresolvedChainedPromise&&this.isUnresolvedChainedPromisePending()||this.runZone.run(function(){setTimeout(function(){e._alreadyErrored||e._pendingMicroTasks||e._pendingMacroTasks||e.finishCallback()},0)})},t.prototype.patchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("patchPromiseForTest")];e&&e()}},t.prototype.unPatchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("unPatchPromiseForTest")];e&&e()}},t.prototype.onScheduleTask=function(e,n,r,o){return"eventTask"!==o.type&&(this._isSync=!1),"microTask"===o.type&&o.data&&o.data instanceof Promise&&!0===o.data[t.symbolParentUnresolved]&&this.unresolvedChainedPromiseCount--,e.scheduleTask(r,o)},t.prototype.onInvokeTask=function(e,t,n,r,o,i){return"eventTask"!==r.type&&(this._isSync=!1),e.invokeTask(n,r,o,i)},t.prototype.onCancelTask=function(e,t,n,r){return"eventTask"!==r.type&&(this._isSync=!1),e.cancelTask(n,r)},t.prototype.onInvoke=function(e,t,n,r,o,i,a){try{return this._isSync=!0,e.invoke(n,r,o,i,a)}finally{this._isSync&&this._finishCallbackIfDone()}},t.prototype.onHandleError=function(e,t,n,r){return e.handleError(n,r)&&(this.failCallback(r),this._alreadyErrored=!0),!1},t.prototype.onHasTask=function(e,t,n,r){e.hasTask(n,r),"microTask"==r.change?(this._pendingMicroTasks=r.microTask,this._finishCallbackIfDone()):"macroTask"==r.change&&(this._pendingMacroTasks=r.macroTask,this._finishCallbackIfDone())},t}();t.symbolParentUnresolved=Zone.__symbol__("parentUnresolved"),Zone.AsyncTestZoneSpec=t}(e), +/** + * @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.__load_patch("asynctest",function(e,t,n){function r(e,n,r,o){var i=t.current,a=t.AsyncTestZoneSpec;if(void 0===a)throw new Error("AsyncTestZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/async-test.js");var s=t.ProxyZoneSpec;if(void 0===s)throw new Error("ProxyZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/proxy.js");var c=s.get();s.assertPresent();var u=t.current.getZoneWith("ProxyZoneSpec"),l=c.getDelegate();return u.parent.run(function(){var e=new a(function(){c.getDelegate()==e&&c.setDelegate(l),e.unPatchPromiseForTest(),i.run(function(){r()})},function(t){c.getDelegate()==e&&c.setDelegate(l),e.unPatchPromiseForTest(),i.run(function(){o(t)})},"test");c.setDelegate(e),e.patchPromiseForTest()}),t.current.runGuarded(e,n)}t[n.symbol("asyncTest")]=function t(n){return e.jasmine?function(e){e||((e=function(){}).fail=function(e){throw e}),r(n,this,e,function(t){if("string"==typeof t)return e.fail(new Error(t));e.fail(t)})}:function(){var e=this;return new Promise(function(t,o){r(n,e,t,o)})}}}), +/** + * @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(e){var t=e.Date,n=function(){function e(){if(0===arguments.length){var n=new t;return n.setTime(e.now()),n}var r=Array.prototype.slice.call(arguments);return new(t.bind.apply(t,[void 0].concat(r)))}return e.now=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.getCurrentRealTime()+e.getCurrentTime():t.now.apply(this,arguments)},e}();n.UTC=t.UTC,n.parse=t.parse;var r={setTimeout:e.setTimeout,setInterval:e.setInterval,clearTimeout:e.clearTimeout,clearInterval:e.clearInterval},o=function(){function n(){this._schedulerQueue=[],this._currentTime=0,this._currentRealTime=t.now()}return n.prototype.getCurrentTime=function(){return this._currentTime},n.prototype.getCurrentRealTime=function(){return this._currentRealTime},n.prototype.setCurrentRealTime=function(e){this._currentRealTime=e},n.prototype.scheduleFunction=function(e,t,r,o,i,a){void 0===r&&(r=[]),void 0===o&&(o=!1),void 0===i&&(i=!1),void 0===a&&(a=-1);for(var s=a<0?n.nextId++:a,c={endTime:this._currentTime+t,id:s,func:e,args:r,delay:t,isPeriodic:o,isRequestAnimationFrame:i},u=0;u0&&!(r0;){if(++i>t)throw new Error("flush failed after reaching the limit of "+t+" tasks. Does your code use a polling timeout?");if(0===this._schedulerQueue.filter(function(e){return!e.isPeriodic&&!e.isRequestAnimationFrame}).length)break;var a=this._schedulerQueue.shift();if(o=this._currentTime,this._currentTime=a.endTime,n&&n(this._currentTime-o),!a.func.apply(e,a.args))break}return this._currentTime-r},n}();o.nextId=1;var i=function(){function i(t,n,r){void 0===n&&(n=!1),this.trackPendingRequestAnimationFrame=n,this.macroTaskOptions=r,this._scheduler=new o,this._microtasks=[],this._lastError=null,this._uncaughtPromiseErrors=Promise[Zone.__symbol__("uncaughtPromiseErrors")],this.pendingPeriodicTimers=[],this.pendingTimers=[],this.patchDateLocked=!1,this.properties={FakeAsyncTestZoneSpec:this},this.name="fakeAsyncTestZone for "+t,this.macroTaskOptions||(this.macroTaskOptions=e[Zone.__symbol__("FakeAsyncTestMacroTask")])}return i.assertInZone=function(){if(null==Zone.current.get("FakeAsyncTestZoneSpec"))throw new Error("The code should be running in the fakeAsync zone to call this function")},i.prototype._fnAndFlush=function(t,n){var r=this;return function(){for(var o=[],i=0;i-1&&e.splice(n,1)},i.prototype._dequeueTimer=function(e){var t=this;return function(){i._removeTimer(t.pendingTimers,e)}},i.prototype._requeuePeriodicTimer=function(e,t,n,r){var o=this;return function(){-1!==o.pendingPeriodicTimers.indexOf(r)&&o._scheduler.scheduleFunction(e,t,n,!0,!1,r)}},i.prototype._dequeuePeriodicTimer=function(e){var t=this;return function(){i._removeTimer(t.pendingPeriodicTimers,e)}},i.prototype._setTimeout=function(e,t,n,r){void 0===r&&(r=!0);var i=this._dequeueTimer(o.nextId),a=this._fnAndFlush(e,{onSuccess:i,onError:i}),s=this._scheduler.scheduleFunction(a,t,n,!1,!r);return r&&this.pendingTimers.push(s),s},i.prototype._clearTimeout=function(e){i._removeTimer(this.pendingTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},i.prototype._setInterval=function(e,t,n){var r=o.nextId,i={onSuccess:null,onError:this._dequeuePeriodicTimer(r)},a=this._fnAndFlush(e,i);return i.onSuccess=this._requeuePeriodicTimer(a,t,n,r),this._scheduler.scheduleFunction(a,t,n,!0),this.pendingPeriodicTimers.push(r),r},i.prototype._clearInterval=function(e){i._removeTimer(this.pendingPeriodicTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},i.prototype._resetLastErrorAndThrow=function(){var e=this._lastError||this._uncaughtPromiseErrors[0];throw this._uncaughtPromiseErrors.length=0,this._lastError=null,e},i.prototype.getCurrentTime=function(){return this._scheduler.getCurrentTime()},i.prototype.getCurrentRealTime=function(){return this._scheduler.getCurrentRealTime()},i.prototype.setCurrentRealTime=function(e){this._scheduler.setCurrentRealTime(e)},i.patchDate=function(){e[Zone.__symbol__("disableDatePatching")]||e.Date!==n&&(e.Date=n,n.prototype=t.prototype,i.checkTimerPatch())},i.resetDate=function(){e.Date===n&&(e.Date=t)},i.checkTimerPatch=function(){e.setTimeout!==r.setTimeout&&(e.setTimeout=r.setTimeout,e.clearTimeout=r.clearTimeout),e.setInterval!==r.setInterval&&(e.setInterval=r.setInterval,e.clearInterval=r.clearInterval)},i.prototype.lockDatePatch=function(){this.patchDateLocked=!0,i.patchDate()},i.prototype.unlockDatePatch=function(){this.patchDateLocked=!1,i.resetDate()},i.prototype.tick=function(e,t){void 0===e&&(e=0),i.assertInZone(),this.flushMicrotasks(),this._scheduler.tick(e,t),null!==this._lastError&&this._resetLastErrorAndThrow()},i.prototype.flushMicrotasks=function(){for(i.assertInZone();this._microtasks.length>0;){var e=this._microtasks.shift();e.func.apply(e.target,e.args)}(null!==this._lastError||this._uncaughtPromiseErrors.length)&&this._resetLastErrorAndThrow()},i.prototype.flush=function(e,t,n){i.assertInZone(),this.flushMicrotasks();var r=this._scheduler.flush(e,t,n);return null!==this._lastError&&this._resetLastErrorAndThrow(),r},i.prototype.onScheduleTask=function(e,t,n,r){switch(r.type){case"microTask":var o=r.data&&r.data.args,i=void 0;if(o){var a=r.data.cbIdx;"number"==typeof o.length&&o.length>a+1&&(i=Array.prototype.slice.call(o,a+1))}this._microtasks.push({func:r.invoke,args:i,target:r.data&&r.data.target});break;case"macroTask":switch(r.source){case"setTimeout":r.data.handleId=this._setTimeout(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"setImmediate":r.data.handleId=this._setTimeout(r.invoke,0,Array.prototype.slice.call(r.data.args,1));break;case"setInterval":r.data.handleId=this._setInterval(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"XMLHttpRequest.send":throw new Error("Cannot make XHRs from within a fake async test. Request URL: "+r.data.url);case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":r.data.handleId=this._setTimeout(r.invoke,16,r.data.args,this.trackPendingRequestAnimationFrame);break;default:var s=this.findMacroTaskOption(r);if(s){var c=r.data&&r.data.args,u=c&&c.length>1?c[1]:0,l=s.callbackArgs?s.callbackArgs:c;s.isPeriodic?(r.data.handleId=this._setInterval(r.invoke,u,l),r.data.isPeriodic=!0):r.data.handleId=this._setTimeout(r.invoke,u,l);break}throw new Error("Unknown macroTask scheduled in fake async test: "+r.source)}break;case"eventTask":r=e.scheduleTask(n,r)}return r},i.prototype.onCancelTask=function(e,t,n,r){switch(r.source){case"setTimeout":case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":return this._clearTimeout(r.data.handleId);case"setInterval":return this._clearInterval(r.data.handleId);default:var o=this.findMacroTaskOption(r);if(o){var i=r.data.handleId;return o.isPeriodic?this._clearInterval(i):this._clearTimeout(i)}return e.cancelTask(n,r)}},i.prototype.onInvoke=function(e,t,n,r,o,a,s){try{return i.patchDate(),e.invoke(n,r,o,a,s)}finally{this.patchDateLocked||i.resetDate()}},i.prototype.findMacroTaskOption=function(e){if(!this.macroTaskOptions)return null;for(var t=0;t0)throw new Error(i.pendingPeriodicTimers.length+" periodic timer(s) still in the queue.");if(i.pendingTimers.length>0)throw new Error(i.pendingTimers.length+" timer(s) still in the queue.");return l}finally{a()}}}}}), +/** + * @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.__load_patch("promisefortest",function(e,t,n){var r=n.symbol("state"),o=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function e(){var n=Promise[t.__symbol__("ZonePromiseThen")];n||(n=Promise[t.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var e=n.apply(this,arguments);if(null===this[r]){var i=t.current.get("AsyncTestZoneSpec");i&&(i.unresolvedChainedPromiseCount++,e[o]=!0)}return e})},Promise[n.symbol("unPatchPromiseForTest")]=function e(){var n=Promise[t.__symbol__("ZonePromiseThen")];n&&(Promise.prototype.then=n,Promise[t.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone-testing.js b/dist/zone-testing.js old mode 100644 new mode 100755 index 59a2b0c4d..9fc04e283 --- a/dist/zone-testing.js +++ b/dist/zone-testing.js @@ -5,1644 +5,1596 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var __assign = (undefined && undefined.__assign) || function () { - __assign = Object.assign || function(t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) - t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; -var NEWLINE = '\n'; -var IGNORE_FRAMES = {}; -var creationTrace = '__creationTrace__'; -var ERROR_TAG = 'STACKTRACE TRACKING'; -var SEP_TAG = '__SEP_TAG__'; -var sepTemplate = SEP_TAG + '@[native]'; -var LongStackTrace = /** @class */ (function () { - function LongStackTrace() { - this.error = getStacktrace(); - this.timestamp = new Date(); +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + /** + * @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 + */ + /** + * @fileoverview + * @suppress {globalThis} + */ + var NEWLINE = '\n'; + var IGNORE_FRAMES = {}; + var creationTrace = '__creationTrace__'; + var ERROR_TAG = 'STACKTRACE TRACKING'; + var SEP_TAG = '__SEP_TAG__'; + var sepTemplate = SEP_TAG + '@[native]'; + var LongStackTrace = /** @class */ (function () { + function LongStackTrace() { + this.error = getStacktrace(); + this.timestamp = new Date(); + } + return LongStackTrace; + }()); + function getStacktraceWithUncaughtError() { + return new Error(ERROR_TAG); } - return LongStackTrace; -}()); -function getStacktraceWithUncaughtError() { - return new Error(ERROR_TAG); -} -function getStacktraceWithCaughtError() { - try { - throw getStacktraceWithUncaughtError(); + function getStacktraceWithCaughtError() { + try { + throw getStacktraceWithUncaughtError(); + } + catch (err) { + return err; + } } - catch (err) { - return err; + // Some implementations of exception handling don't create a stack trace if the exception + // isn't thrown, however it's faster not to actually throw the exception. + var error = getStacktraceWithUncaughtError(); + var caughtError = getStacktraceWithCaughtError(); + var getStacktrace = error.stack ? + getStacktraceWithUncaughtError : + (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); + function getFrames(error) { + return error.stack ? error.stack.split(NEWLINE) : []; } -} -// Some implementations of exception handling don't create a stack trace if the exception -// isn't thrown, however it's faster not to actually throw the exception. -var error = getStacktraceWithUncaughtError(); -var caughtError = getStacktraceWithCaughtError(); -var getStacktrace = error.stack ? - getStacktraceWithUncaughtError : - (caughtError.stack ? getStacktraceWithCaughtError : getStacktraceWithUncaughtError); -function getFrames(error) { - return error.stack ? error.stack.split(NEWLINE) : []; -} -function addErrorStack(lines, error) { - var trace = getFrames(error); - for (var i = 0; i < trace.length; i++) { - var frame = trace[i]; - // Filter out the Frames which are part of stack capturing. - if (!IGNORE_FRAMES.hasOwnProperty(frame)) { - lines.push(trace[i]); + function addErrorStack(lines, error) { + var trace = getFrames(error); + for (var i = 0; i < trace.length; i++) { + var frame = trace[i]; + // Filter out the Frames which are part of stack capturing. + if (!IGNORE_FRAMES.hasOwnProperty(frame)) { + lines.push(trace[i]); + } } } -} -function renderLongStackTrace(frames, stack) { - var longTrace = [stack ? stack.trim() : '']; - if (frames) { - var timestamp = new Date().getTime(); - for (var i = 0; i < frames.length; i++) { - var traceFrames = frames[i]; - var lastTime = traceFrames.timestamp; - var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; - separator = separator.replace(/[^\w\d]/g, '_'); - longTrace.push(sepTemplate.replace(SEP_TAG, separator)); - addErrorStack(longTrace, traceFrames.error); - timestamp = lastTime.getTime(); + function renderLongStackTrace(frames, stack) { + var longTrace = [stack ? stack.trim() : '']; + if (frames) { + var timestamp = new Date().getTime(); + for (var i = 0; i < frames.length; i++) { + var traceFrames = frames[i]; + var lastTime = traceFrames.timestamp; + var separator = "____________________Elapsed " + (timestamp - lastTime.getTime()) + " ms; At: " + lastTime; + separator = separator.replace(/[^\w\d]/g, '_'); + longTrace.push(sepTemplate.replace(SEP_TAG, separator)); + addErrorStack(longTrace, traceFrames.error); + timestamp = lastTime.getTime(); + } } + return longTrace.join(NEWLINE); } - return longTrace.join(NEWLINE); -} -Zone['longStackTraceZoneSpec'] = { - name: 'long-stack-trace', - longStackTraceLimit: 10, - // add a getLongStackTrace method in spec to - // handle handled reject promise error. - getLongStackTrace: function (error) { - if (!error) { - return undefined; - } - var trace = error[Zone.__symbol__('currentTaskTrace')]; - if (!trace) { - return error.stack; - } - return renderLongStackTrace(trace, error.stack); - }, - onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var currentTask = Zone.currentTask; - var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; - trace = [new LongStackTrace()].concat(trace); - if (trace.length > this.longStackTraceLimit) { - trace.length = this.longStackTraceLimit; + Zone['longStackTraceZoneSpec'] = { + name: 'long-stack-trace', + longStackTraceLimit: 10, + // add a getLongStackTrace method in spec to + // handle handled reject promise error. + getLongStackTrace: function (error) { + if (!error) { + return undefined; } - if (!task.data) - task.data = {}; - if (task.type === 'eventTask') { - // Fix issue https://github.com/angular/zone.js/issues/1195, - // For event task of browser, by default, all task will share a - // singleton instance of data object, we should create a new one here - // The cast to `any` is required to workaround a closure bug which wrongly applies - // URL sanitization rules to .data access. - task.data = __assign({}, task.data); + var trace = error[Zone.__symbol__('currentTaskTrace')]; + if (!trace) { + return error.stack; } - task.data[creationTrace] = trace; - } - return parentZoneDelegate.scheduleTask(targetZone, task); - }, - onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { - if (Error.stackTraceLimit > 0) { - // if Error.stackTraceLimit is 0, means stack trace - // is disabled, so we don't need to generate long stack trace - // this will improve performance in some test(some test will - // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 - var parentTask = Zone.currentTask || error.task; - if (error instanceof Error && parentTask) { - var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); - try { - error.stack = error.longStack = longStack; + return renderLongStackTrace(trace, error.stack); + }, + onScheduleTask: function (parentZoneDelegate, currentZone, targetZone, task) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var currentTask = Zone.currentTask; + var trace = currentTask && currentTask.data && currentTask.data[creationTrace] || []; + trace = [new LongStackTrace()].concat(trace); + if (trace.length > this.longStackTraceLimit) { + trace.length = this.longStackTraceLimit; } - catch (err) { + if (!task.data) + task.data = {}; + if (task.type === 'eventTask') { + // Fix issue https://github.com/angular/zone.js/issues/1195, + // For event task of browser, by default, all task will share a + // singleton instance of data object, we should create a new one here + // The cast to `any` is required to workaround a closure bug which wrongly applies + // URL sanitization rules to .data access. + task.data = Object.assign({}, task.data); } + task.data[creationTrace] = trace; } - } - return parentZoneDelegate.handleError(targetZone, error); - } -}; -function captureStackTraces(stackTraces, count) { - if (count > 0) { - stackTraces.push(getFrames((new LongStackTrace()).error)); - captureStackTraces(stackTraces, count - 1); - } -} -function computeIgnoreFrames() { - if (Error.stackTraceLimit <= 0) { - return; - } - var frames = []; - captureStackTraces(frames, 2); - var frames1 = frames[0]; - var frames2 = frames[1]; - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - if (frame1.indexOf(ERROR_TAG) == -1) { - var match = frame1.match(/^\s*at\s+/); - if (match) { - sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; - break; + return parentZoneDelegate.scheduleTask(targetZone, task); + }, + onHandleError: function (parentZoneDelegate, currentZone, targetZone, error) { + if (Error.stackTraceLimit > 0) { + // if Error.stackTraceLimit is 0, means stack trace + // is disabled, so we don't need to generate long stack trace + // this will improve performance in some test(some test will + // set stackTraceLimit to 0, https://github.com/angular/zone.js/issues/698 + var parentTask = Zone.currentTask || error.task; + if (error instanceof Error && parentTask) { + var longStack = renderLongStackTrace(parentTask.data && parentTask.data[creationTrace], error.stack); + try { + error.stack = error.longStack = longStack; + } + catch (err) { + } + } } + return parentZoneDelegate.handleError(targetZone, error); } - } - for (var i = 0; i < frames1.length; i++) { - var frame1 = frames1[i]; - var frame2 = frames2[i]; - if (frame1 === frame2) { - IGNORE_FRAMES[frame1] = true; - } - else { - break; - } - } -} -computeIgnoreFrames(); - -/** - * @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 = /** @class */ (function () { - function ProxyZoneSpec(defaultSpecDelegate) { - if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } - this.defaultSpecDelegate = defaultSpecDelegate; - this.name = 'ProxyZone'; - this._delegateSpec = null; - this.properties = { 'ProxyZoneSpec': this }; - this.propertyKeys = null; - this.lastTaskState = null; - this.isNeedToTriggerHasTask = false; - this.tasks = []; - this.setDelegate(defaultSpecDelegate); - } - ProxyZoneSpec.get = function () { - return Zone.current.get('ProxyZoneSpec'); - }; - ProxyZoneSpec.isLoaded = function () { - return ProxyZoneSpec.get() instanceof ProxyZoneSpec; - }; - ProxyZoneSpec.assertPresent = function () { - if (!ProxyZoneSpec.isLoaded()) { - throw new Error("Expected to be running in 'ProxyZone', but it was not found."); - } - return ProxyZoneSpec.get(); - }; - ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { - var _this = this; - var isNewDelegate = this._delegateSpec !== delegateSpec; - this._delegateSpec = delegateSpec; - this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); - this.propertyKeys = null; - if (delegateSpec && delegateSpec.properties) { - this.propertyKeys = Object.keys(delegateSpec.properties); - this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); - } - // if set a new delegateSpec, shoulde check whether need to - // trigger hasTask or not - if (isNewDelegate && this.lastTaskState && - (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { - this.isNeedToTriggerHasTask = true; - } - }; - ProxyZoneSpec.prototype.getDelegate = function () { - return this._delegateSpec; }; - ProxyZoneSpec.prototype.resetDelegate = function () { - var delegateSpec = this.getDelegate(); - this.setDelegate(this.defaultSpecDelegate); - }; - ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { - if (this.isNeedToTriggerHasTask && this.lastTaskState) { - // last delegateSpec has microTask or macroTask - // should call onHasTask in current delegateSpec - this.isNeedToTriggerHasTask = false; - this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); + function captureStackTraces(stackTraces, count) { + if (count > 0) { + stackTraces.push(getFrames((new LongStackTrace()).error)); + captureStackTraces(stackTraces, count - 1); } - }; - ProxyZoneSpec.prototype.removeFromTasks = function (task) { - if (!this.tasks) { + } + function computeIgnoreFrames() { + if (Error.stackTraceLimit <= 0) { return; } - for (var i = 0; i < this.tasks.length; i++) { - if (this.tasks[i] === task) { - this.tasks.splice(i, 1); - return; + var frames = []; + captureStackTraces(frames, 2); + var frames1 = frames[0]; + var frames2 = frames[1]; + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + if (frame1.indexOf(ERROR_TAG) == -1) { + var match = frame1.match(/^\s*at\s+/); + if (match) { + sepTemplate = match[0] + SEP_TAG + ' (http://localhost)'; + break; + } } } - }; - ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { - if (this.tasks.length === 0) { - return ''; - } - var taskInfo = this.tasks.map(function (task) { - var dataInfo = task.data && - Object.keys(task.data) - .map(function (key) { - return key + ':' + task.data[key]; - }) - .join(','); - return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; - }); - var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; - // clear tasks - this.tasks = []; - return pendingTasksInfo; - }; - ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { - if (this._delegateSpec && this._delegateSpec.onFork) { - return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); - } - else { - return parentZoneDelegate.fork(targetZone, zoneSpec); - } - }; - ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { - if (this._delegateSpec && this._delegateSpec.onIntercept) { - return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); - } - else { - return parentZoneDelegate.intercept(targetZone, delegate, source); - } - }; - ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvoke) { - return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); - } - else { - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - }; - ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - if (this._delegateSpec && this._delegateSpec.onHandleError) { - return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); - } - else { - return parentZoneDelegate.handleError(targetZone, error); - } - }; - ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.tasks.push(task); - } - if (this._delegateSpec && this._delegateSpec.onScheduleTask) { - return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.scheduleTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onInvokeTask) { - return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); - } - else { - return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); - } - }; - ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { - if (task.type !== 'eventTask') { - this.removeFromTasks(task); - } - this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); - if (this._delegateSpec && this._delegateSpec.onCancelTask) { - return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); - } - else { - return parentZoneDelegate.cancelTask(targetZone, task); - } - }; - ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { - this.lastTaskState = hasTaskState; - if (this._delegateSpec && this._delegateSpec.onHasTask) { - this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); - } - else { - delegate.hasTask(target, hasTaskState); - } - }; - return ProxyZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['ProxyZoneSpec'] = ProxyZoneSpec; - -/** - * @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 = /** @class */ (function () { - function SyncTestZoneSpec(namePrefix) { - this.runZone = Zone.current; - this.name = 'syncTestZone for ' + namePrefix; - } - SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - case 'macroTask': - throw new Error("Cannot call " + task.source + " from within a sync test."); - case 'eventTask': - task = delegate.scheduleTask(target, task); + for (var i = 0; i < frames1.length; i++) { + var frame1 = frames1[i]; + var frame2 = frames2[i]; + if (frame1 === frame2) { + IGNORE_FRAMES[frame1] = true; + } + else { break; - } - return task; - }; - return SyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -(function () { - 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 __()); - }; - var _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; - // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs - // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) - if (!Zone) - throw new Error('Missing: zone.js'); - if (typeof jasmine == 'undefined') - throw new Error('Missing: jasmine.js'); - if (jasmine['__zone_patch__']) - throw new Error("'jasmine' has already been patched with 'Zone'."); - jasmine['__zone_patch__'] = true; - var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (!SyncTestZoneSpec) - throw new Error('Missing: SyncTestZoneSpec'); - if (!ProxyZoneSpec) - throw new Error('Missing: ProxyZoneSpec'); - var ambientZone = Zone.current; - // Create a synchronous-only zone in which to run `describe` blocks in order to raise an - // error if any asynchronous operations are attempted inside of a `describe` but outside of - // a `beforeEach` or `it`. - var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); - var symbol = Zone.__symbol__; - // whether patch jasmine clock when in fakeAsync - var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; - // the original variable name fakeAsyncPatchLock is not accurate, so the name will be - // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also - // automatically disable the auto jump into fakeAsync feature - var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && - ((_global[symbol('fakeAsyncPatchLock')] === true) || - (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); - var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; - if (!ignoreUnhandledRejection) { - var globalErrors_1 = jasmine.GlobalErrors; - if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { - jasmine[symbol('GlobalErrors')] = globalErrors_1; - jasmine.GlobalErrors = function () { - var instance = new globalErrors_1(); - var originalInstall = instance.install; - if (originalInstall && !instance[symbol('install')]) { - instance[symbol('install')] = originalInstall; - instance.install = function () { - var originalHandlers = process.listeners('unhandledRejection'); - var r = originalInstall.apply(this, arguments); - process.removeAllListeners('unhandledRejection'); - if (originalHandlers) { - originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); - } - return r; - }; - } - return instance; - }; + } } } - // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. - var jasmineEnv = jasmine.getEnv(); - ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[methodName] = function (description, specDefinitions) { - return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); + computeIgnoreFrames(); + /** + * @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 = /** @class */ (function () { + function ProxyZoneSpec(defaultSpecDelegate) { + if (defaultSpecDelegate === void 0) { defaultSpecDelegate = null; } + this.defaultSpecDelegate = defaultSpecDelegate; + this.name = 'ProxyZone'; + this._delegateSpec = null; + this.properties = { 'ProxyZoneSpec': this }; + this.propertyKeys = null; + this.lastTaskState = null; + this.isNeedToTriggerHasTask = false; + this.tasks = []; + this.setDelegate(defaultSpecDelegate); + } + ProxyZoneSpec.get = function () { + return Zone.current.get('ProxyZoneSpec'); }; - }); - ['it', 'xit', 'fit'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (description, specDefinitions, timeout) { - arguments[1] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); + ProxyZoneSpec.isLoaded = function () { + return ProxyZoneSpec.get() instanceof ProxyZoneSpec; }; - }); - ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { - var originalJasmineFn = jasmineEnv[methodName]; - jasmineEnv[symbol(methodName)] = originalJasmineFn; - jasmineEnv[methodName] = function (specDefinitions, timeout) { - arguments[0] = wrapTestInZone(specDefinitions); - return originalJasmineFn.apply(this, arguments); + ProxyZoneSpec.assertPresent = function () { + if (!ProxyZoneSpec.isLoaded()) { + throw new Error("Expected to be running in 'ProxyZone', but it was not found."); + } + return ProxyZoneSpec.get(); }; - }); - if (!disablePatchingJasmineClock) { - // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so - // they can work properly in FakeAsyncTest - var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); - jasmine['clock'] = function () { - var clock = originalClockFn_1.apply(this, arguments); - if (!clock[symbol('patched')]) { - clock[symbol('patched')] = symbol('patched'); - var originalTick_1 = (clock[symbol('tick')] = clock.tick); - clock.tick = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); - } - return originalTick_1.apply(this, arguments); - }; - var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); - clock.mockDate = function () { - var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncZoneSpec) { - var dateTime = arguments.length > 0 ? arguments[0] : new Date(); - return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : - arguments); - } - return originalMockDate_1.apply(this, arguments); - }; - // for auto go into fakeAsync feature, we need the flag to enable it - if (enableAutoFakeAsyncWhenClockPatched) { - ['install', 'uninstall'].forEach(function (methodName) { - var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); - clock[methodName] = function () { - var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; - if (FakeAsyncTestZoneSpec) { - jasmine[symbol('clockInstalled')] = 'install' === methodName; - return; - } - return originalClockFn.apply(this, arguments); - }; - }); - } + ProxyZoneSpec.prototype.setDelegate = function (delegateSpec) { + var _this = this; + var isNewDelegate = this._delegateSpec !== delegateSpec; + this._delegateSpec = delegateSpec; + this.propertyKeys && this.propertyKeys.forEach(function (key) { return delete _this.properties[key]; }); + this.propertyKeys = null; + if (delegateSpec && delegateSpec.properties) { + this.propertyKeys = Object.keys(delegateSpec.properties); + this.propertyKeys.forEach(function (k) { return _this.properties[k] = delegateSpec.properties[k]; }); + } + // if set a new delegateSpec, shoulde check whether need to + // trigger hasTask or not + if (isNewDelegate && this.lastTaskState && + (this.lastTaskState.macroTask || this.lastTaskState.microTask)) { + this.isNeedToTriggerHasTask = true; } - return clock; }; - } - /** - * Gets a function wrapping the body of a Jasmine `describe` block to execute in a - * synchronous-only zone. - */ - function wrapDescribeInZone(describeBody) { - return function () { - return syncZone.run(describeBody, this, arguments); + ProxyZoneSpec.prototype.getDelegate = function () { + return this._delegateSpec; }; - } - function runInTestZone(testBody, applyThis, queueRunner, done) { - var isClockInstalled = !!jasmine[symbol('clockInstalled')]; - var testProxyZoneSpec = queueRunner.testProxyZoneSpec; - var testProxyZone = queueRunner.testProxyZone; - if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { - // auto run a fakeAsync - var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; - if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { - testBody = fakeAsyncModule.fakeAsync(testBody); - } - } - if (done) { - return testProxyZone.run(testBody, applyThis, [done]); - } - else { - return testProxyZone.run(testBody, applyThis); - } - } - /** - * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to - * execute in a ProxyZone zone. - * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` - */ - function wrapTestInZone(testBody) { - // The `done` callback is only passed through if the function expects at least one argument. - // Note we have to make a function with correct number of arguments, otherwise jasmine will - // think that all functions are sync or async. - return (testBody && (testBody.length ? function (done) { - return runInTestZone(testBody, this, this.queueRunner, done); - } : function () { - return runInTestZone(testBody, this, this.queueRunner); - })); - } - var QueueRunner = jasmine.QueueRunner; - jasmine.QueueRunner = (function (_super) { - __extends(ZoneQueueRunner, _super); - function ZoneQueueRunner(attrs) { - var _this = this; - attrs.onComplete = (function (fn) { return function () { - // All functions are done, clear the test zone. - _this.testProxyZone = null; - _this.testProxyZoneSpec = null; - ambientZone.scheduleMicroTask('jasmine.onComplete', fn); - }; })(attrs.onComplete); - var nativeSetTimeout = _global['__zone_symbol__setTimeout']; - var nativeClearTimeout = _global['__zone_symbol__clearTimeout']; - if (nativeSetTimeout) { - // should run setTimeout inside jasmine outside of zone - attrs.timeout = { - setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, - clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout - }; + ProxyZoneSpec.prototype.resetDelegate = function () { + var delegateSpec = this.getDelegate(); + this.setDelegate(this.defaultSpecDelegate); + }; + ProxyZoneSpec.prototype.tryTriggerHasTask = function (parentZoneDelegate, currentZone, targetZone) { + if (this.isNeedToTriggerHasTask && this.lastTaskState) { + // last delegateSpec has microTask or macroTask + // should call onHasTask in current delegateSpec + this.isNeedToTriggerHasTask = false; + this.onHasTask(parentZoneDelegate, currentZone, targetZone, this.lastTaskState); } - // create a userContext to hold the queueRunner itself - // so we can access the testProxy in it/xit/beforeEach ... - if (jasmine.UserContext) { - if (!attrs.userContext) { - attrs.userContext = new jasmine.UserContext(); - } - attrs.userContext.queueRunner = this; + }; + ProxyZoneSpec.prototype.removeFromTasks = function (task) { + if (!this.tasks) { + return; } - else { - if (!attrs.userContext) { - attrs.userContext = {}; + for (var i = 0; i < this.tasks.length; i++) { + if (this.tasks[i] === task) { + this.tasks.splice(i, 1); + return; } - attrs.userContext.queueRunner = this; } - // patch attrs.onException - var onException = attrs.onException; - attrs.onException = function (error) { - if (error && - error.message === - 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { - // jasmine timeout, we can make the error message more - // reasonable to tell what tasks are pending - var proxyZoneSpec = this && this.testProxyZoneSpec; - if (proxyZoneSpec) { - var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); - try { - // try catch here in case error.message is not writable - error.message += pendingTasksInfo; - } - catch (err) { - } - } - } - if (onException) { - onException.call(this, error); - } - }; - _super.call(this, attrs); - } - ZoneQueueRunner.prototype.execute = function () { - var _this = this; - var zone = Zone.current; - var isChildOfAmbientZone = false; - while (zone) { - if (zone === ambientZone) { - isChildOfAmbientZone = true; - break; - } - zone = zone.parent; + }; + ProxyZoneSpec.prototype.getAndClearPendingTasksInfo = function () { + if (this.tasks.length === 0) { + return ''; } - if (!isChildOfAmbientZone) - throw new Error('Unexpected Zone: ' + Zone.current.name); - // This is the zone which will be used for running individual tests. - // It will be a proxy zone, so that the tests function can retroactively install - // different zones. - // Example: - // - In beforeEach() do childZone = Zone.current.fork(...); - // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the - // zone outside of fakeAsync it will be able to escape the fakeAsync rules. - // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add - // fakeAsync behavior to the childZone. - this.testProxyZoneSpec = new ProxyZoneSpec(); - this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); - if (!Zone.currentTask) { - // if we are not running in a task then if someone would register a - // element.addEventListener and then calling element.click() the - // addEventListener callback would think that it is the top most task and would - // drain the microtask queue on element.click() which would be incorrect. - // For this reason we always force a task when running jasmine tests. - Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); + var taskInfo = this.tasks.map(function (task) { + var dataInfo = task.data && + Object.keys(task.data) + .map(function (key) { + return key + ':' + task.data[key]; + }) + .join(','); + return "type: " + task.type + ", source: " + task.source + ", args: {" + dataInfo + "}"; + }); + var pendingTasksInfo = '--Pendng async tasks are: [' + taskInfo + ']'; + // clear tasks + this.tasks = []; + return pendingTasksInfo; + }; + ProxyZoneSpec.prototype.onFork = function (parentZoneDelegate, currentZone, targetZone, zoneSpec) { + if (this._delegateSpec && this._delegateSpec.onFork) { + return this._delegateSpec.onFork(parentZoneDelegate, currentZone, targetZone, zoneSpec); } else { - _super.prototype.execute.call(this); + return parentZoneDelegate.fork(targetZone, zoneSpec); } }; - return ZoneQueueRunner; - })(QueueRunner); -})(); - -/** - * @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 _global = typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; -var AsyncTestZoneSpec = /** @class */ (function () { - function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { - this.finishCallback = finishCallback; - this.failCallback = failCallback; - this._pendingMicroTasks = false; - this._pendingMacroTasks = false; - this._alreadyErrored = false; - this._isSync = false; - this.runZone = Zone.current; - this.unresolvedChainedPromiseCount = 0; - this.supportWaitUnresolvedChainedPromise = false; - this.name = 'asyncTestZone for ' + namePrefix; - this.properties = { 'AsyncTestZoneSpec': this }; - this.supportWaitUnresolvedChainedPromise = - _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; - } - AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { - return this.unresolvedChainedPromiseCount > 0; - }; - AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { - var _this = this; - if (!(this._pendingMicroTasks || this._pendingMacroTasks || - (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { - // We do this because we would like to catch unhandled rejected promises. - this.runZone.run(function () { - setTimeout(function () { - if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { - _this.finishCallback(); - } - }, 0); - }); - } - }; - AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; - if (patchPromiseForTest) { - patchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { - if (!this.supportWaitUnresolvedChainedPromise) { - return; - } - var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; - if (unPatchPromiseForTest) { - unPatchPromiseForTest(); - } - }; - AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - if (task.type === 'microTask' && task.data && task.data instanceof Promise) { - // check whether the promise is a chained promise - if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { - // chained promise is being scheduled - this.unresolvedChainedPromiseCount--; + ProxyZoneSpec.prototype.onIntercept = function (parentZoneDelegate, currentZone, targetZone, delegate, source) { + if (this._delegateSpec && this._delegateSpec.onIntercept) { + return this._delegateSpec.onIntercept(parentZoneDelegate, currentZone, targetZone, delegate, source); } - } - return delegate.scheduleTask(target, task); - }; - AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.invokeTask(target, task, applyThis, applyArgs); - }; - AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - if (task.type !== 'eventTask') { - this._isSync = false; - } - return delegate.cancelTask(target, task); - }; - // 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. - // updated by(JiaLiPassion), only call finish callback when no task - // was scheduled/invoked/canceled. - AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { - try { - this._isSync = true; - return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); - } - finally { - var afterTaskCounts = parentZoneDelegate._taskCounts; - if (this._isSync) { - this._finishCallbackIfDone(); + else { + return parentZoneDelegate.intercept(targetZone, delegate, source); } - } - }; - AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - // Let the parent try to handle the error. - var result = parentZoneDelegate.handleError(targetZone, error); - if (result) { - this.failCallback(error); - this._alreadyErrored = true; - } - return false; - }; - AsyncTestZoneSpec.prototype.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(); - } - }; - AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); - return AsyncTestZoneSpec; -}()); -// Export the class so that new instances can be created with proper -// constructor params. -Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; - -/** - * @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.__load_patch('asynctest', function (global, Zone, api) { - /** - * Wraps a test function in an asynchronous test zone. The test will automatically - * complete when all asynchronous calls within this zone are done. - */ - Zone[api.symbol('asyncTest')] = function asyncTest(fn) { - // If we're running using the Jasmine test framework, adapt to call the 'done' - // function when asynchronous activity is finished. - if (global.jasmine) { - // Not using an arrow function to preserve context passed from call site - return function (done) { - if (!done) { - // if we run beforeEach in @angular/core/testing/testing_internal then we get no done - // fake it here and assume sync. - done = function () { }; - done.fail = function (e) { - throw e; - }; - } - runInTestZone(fn, this, done, function (err) { - if (typeof err === 'string') { - return done.fail(new Error(err)); - } - else { - done.fail(err); - } - }); - }; - } - // Otherwise, return a promise which will resolve when asynchronous activity - // is finished. This will be correctly consumed by the Mocha framework with - // it('...', async(myFn)); or can be used in a custom framework. - // Not using an arrow function to preserve context passed from call site - return function () { - var _this = this; - return new Promise(function (finishCallback, failCallback) { - runInTestZone(fn, _this, finishCallback, failCallback); - }); }; - }; - function runInTestZone(fn, context, finishCallback, failCallback) { - var currentZone = Zone.current; - var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; - if (AsyncTestZoneSpec === undefined) { - throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/async-test.js'); - } - var ProxyZoneSpec = Zone['ProxyZoneSpec']; - if (ProxyZoneSpec === undefined) { - throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + - 'Please make sure that your environment includes zone.js/dist/proxy.js'); - } - var proxyZoneSpec = ProxyZoneSpec.get(); - ProxyZoneSpec.assertPresent(); - // We need to create the AsyncTestZoneSpec outside the ProxyZone. - // If we do it in ProxyZone then we will get to infinite recursion. - var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); - var previousDelegate = proxyZoneSpec.getDelegate(); - proxyZone.parent.run(function () { - var testZoneSpec = new AsyncTestZoneSpec(function () { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's - // sill this one. Otherwise, assume - // it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - finishCallback(); - }); - }, function (error) { - // Need to restore the original zone. - if (proxyZoneSpec.getDelegate() == testZoneSpec) { - // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. - proxyZoneSpec.setDelegate(previousDelegate); - } - testZoneSpec.unPatchPromiseForTest(); - currentZone.run(function () { - failCallback(error); - }); - }, 'test'); - proxyZoneSpec.setDelegate(testZoneSpec); - testZoneSpec.patchPromiseForTest(); - }); - return Zone.current.runGuarded(fn, context); - } -}); - -/** - * @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 __read = (undefined && undefined.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (undefined && undefined.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -(function (global) { - var OriginalDate = global.Date; - var FakeDate = /** @class */ (function () { - function FakeDate() { - if (arguments.length === 0) { - var d = new OriginalDate(); - d.setTime(FakeDate.now()); - return d; + ProxyZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvoke) { + return this._delegateSpec.onInvoke(parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source); } else { - var args = Array.prototype.slice.call(arguments); - return new (OriginalDate.bind.apply(OriginalDate, __spread([void 0], args)))(); + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } - } - FakeDate.now = function () { - var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (fakeAsyncTestZoneSpec) { - return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); - } - return OriginalDate.now.apply(this, arguments); - }; - return FakeDate; - }()); - FakeDate.UTC = OriginalDate.UTC; - FakeDate.parse = OriginalDate.parse; - // keep a reference for zone patched timer function - var timers = { - setTimeout: global.setTimeout, - setInterval: global.setInterval, - clearTimeout: global.clearTimeout, - clearInterval: global.clearInterval - }; - var Scheduler = /** @class */ (function () { - function Scheduler() { - // Scheduler queue with the tuple of end time and callback function - sorted by end time. - this._schedulerQueue = []; - // Current simulated time in millis. - this._currentTime = 0; - // Current real time in millis. - this._currentRealTime = OriginalDate.now(); - } - Scheduler.prototype.getCurrentTime = function () { - return this._currentTime; - }; - Scheduler.prototype.getCurrentRealTime = function () { - return this._currentRealTime; - }; - Scheduler.prototype.setCurrentRealTime = function (realTime) { - this._currentRealTime = realTime; }; - Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { - if (args === void 0) { args = []; } - if (isPeriodic === void 0) { isPeriodic = false; } - if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } - if (id === void 0) { id = -1; } - var currentId = id < 0 ? Scheduler.nextId++ : id; - var endTime = this._currentTime + delay; - // Insert so that scheduler queue remains sorted by end time. - var newEntry = { - endTime: endTime, - id: currentId, - func: cb, - args: args, - delay: delay, - isPeriodic: isPeriodic, - isRequestAnimationFrame: isRequestAnimationFrame - }; - var i = 0; - for (; i < this._schedulerQueue.length; i++) { - var currentEntry = this._schedulerQueue[i]; - if (newEntry.endTime < currentEntry.endTime) { - break; - } + ProxyZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + if (this._delegateSpec && this._delegateSpec.onHandleError) { + return this._delegateSpec.onHandleError(parentZoneDelegate, currentZone, targetZone, error); } - this._schedulerQueue.splice(i, 0, newEntry); - return currentId; - }; - Scheduler.prototype.removeScheduledFunctionWithId = function (id) { - for (var i = 0; i < this._schedulerQueue.length; i++) { - if (this._schedulerQueue[i].id == id) { - this._schedulerQueue.splice(i, 1); - break; - } + else { + return parentZoneDelegate.handleError(targetZone, error); } }; - Scheduler.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - var finalTime = this._currentTime + millis; - var lastCurrentTime = 0; - if (this._schedulerQueue.length === 0 && doTick) { - doTick(millis); - return; + ProxyZoneSpec.prototype.onScheduleTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.tasks.push(task); } - while (this._schedulerQueue.length > 0) { - var current = this._schedulerQueue[0]; - if (finalTime < current.endTime) { - // Done processing the queue since it's sorted by endTime. - break; - } - else { - // Time to run scheduled function. Remove it from the head of queue. - var current_1 = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current_1.endTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); - } - var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } - } + if (this._delegateSpec && this._delegateSpec.onScheduleTask) { + return this._delegateSpec.onScheduleTask(parentZoneDelegate, currentZone, targetZone, task); } - lastCurrentTime = this._currentTime; - this._currentTime = finalTime; - if (doTick) { - doTick(this._currentTime - lastCurrentTime); + else { + return parentZoneDelegate.scheduleTask(targetZone, task); } }; - Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { - if (limit === void 0) { limit = 20; } - if (flushPeriodic === void 0) { flushPeriodic = false; } - if (flushPeriodic) { - return this.flushPeriodic(doTick); + ProxyZoneSpec.prototype.onInvokeTask = function (parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); + } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onInvokeTask) { + return this._delegateSpec.onInvokeTask(parentZoneDelegate, currentZone, targetZone, task, applyThis, applyArgs); } else { - return this.flushNonPeriodic(limit, doTick); + return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); } }; - Scheduler.prototype.flushPeriodic = function (doTick) { - if (this._schedulerQueue.length === 0) { - return 0; + ProxyZoneSpec.prototype.onCancelTask = function (parentZoneDelegate, currentZone, targetZone, task) { + if (task.type !== 'eventTask') { + this.removeFromTasks(task); } - // Find the last task currently queued in the scheduler queue and tick - // till that time. - var startTime = this._currentTime; - var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; - this.tick(lastTask.endTime - startTime, doTick); - return this._currentTime - startTime; - }; - Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { - var startTime = this._currentTime; - var lastCurrentTime = 0; - var count = 0; - while (this._schedulerQueue.length > 0) { - count++; - if (count > limit) { - throw new Error('flush failed after reaching the limit of ' + limit + - ' tasks. Does your code use a polling timeout?'); - } - // flush only non-periodic timers. - // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. - if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) - .length === 0) { - break; - } - var current = this._schedulerQueue.shift(); - lastCurrentTime = this._currentTime; - this._currentTime = current.endTime; - if (doTick) { - // Update any secondary schedulers like Jasmine mock Date. - doTick(this._currentTime - lastCurrentTime); - } - var retval = current.func.apply(global, current.args); - if (!retval) { - // Uncaught exception in the current scheduled function. Stop processing the queue. - break; - } + this.tryTriggerHasTask(parentZoneDelegate, currentZone, targetZone); + if (this._delegateSpec && this._delegateSpec.onCancelTask) { + return this._delegateSpec.onCancelTask(parentZoneDelegate, currentZone, targetZone, task); + } + else { + return parentZoneDelegate.cancelTask(targetZone, task); } - return this._currentTime - startTime; }; - // Next scheduler id. - Scheduler.nextId = 1; - return Scheduler; - }()); - var FakeAsyncTestZoneSpec = /** @class */ (function () { - function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { - if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } - this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; - this.macroTaskOptions = macroTaskOptions; - this._scheduler = new Scheduler(); - this._microtasks = []; - this._lastError = null; - this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; - this.pendingPeriodicTimers = []; - this.pendingTimers = []; - this.patchDateLocked = false; - this.properties = { 'FakeAsyncTestZoneSpec': this }; - this.name = 'fakeAsyncTestZone for ' + namePrefix; - // in case user can't access the construction of FakeAsyncTestSpec - // user can also define macroTaskOptions by define a global variable. - if (!this.macroTaskOptions) { - this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + ProxyZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + this.lastTaskState = hasTaskState; + if (this._delegateSpec && this._delegateSpec.onHasTask) { + this._delegateSpec.onHasTask(delegate, current, target, hasTaskState); } - } - FakeAsyncTestZoneSpec.assertInZone = function () { - if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); + else { + delegate.hasTask(target, hasTaskState); } }; - FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { - var _this = this; - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - fn.apply(global, args); - if (_this._lastError === null) { // Success - if (completers.onSuccess != null) { - completers.onSuccess.apply(global); - } - // Flush microtasks only on success. - _this.flushMicrotasks(); - } - else { // Failure - if (completers.onError != null) { - completers.onError.apply(global); - } - } - // Return true if there were no errors, false otherwise. - return _this._lastError === null; - }; + return ProxyZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['ProxyZoneSpec'] = ProxyZoneSpec; + /** + * @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 = /** @class */ (function () { + function SyncTestZoneSpec(namePrefix) { + this.runZone = Zone.current; + this.name = 'syncTestZone for ' + namePrefix; + } + SyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + case 'macroTask': + throw new Error("Cannot call " + task.source + " from within a sync test."); + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; }; - FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { - var index = timers.indexOf(id); - if (index > -1) { - timers.splice(index, 1); + return SyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['SyncTestZoneSpec'] = SyncTestZoneSpec; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + (function (_global) { + 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 __()); }; - FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { - var _this = this; - return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + // Patch jasmine's describe/it/beforeEach/afterEach functions so test code always runs + // in a testZone (ProxyZone). (See: angular/zone.js#91 & angular/angular#10503) + if (!Zone) + throw new Error('Missing: zone.js'); + if (typeof jasmine == 'undefined') + throw new Error('Missing: jasmine.js'); + if (jasmine['__zone_patch__']) + throw new Error("'jasmine' has already been patched with 'Zone'."); + jasmine['__zone_patch__'] = true; + var SyncTestZoneSpec = Zone['SyncTestZoneSpec']; + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (!SyncTestZoneSpec) + throw new Error('Missing: SyncTestZoneSpec'); + if (!ProxyZoneSpec) + throw new Error('Missing: ProxyZoneSpec'); + var ambientZone = Zone.current; + // Create a synchronous-only zone in which to run `describe` blocks in order to raise an + // error if any asynchronous operations are attempted inside of a `describe` but outside of + // a `beforeEach` or `it`. + var syncZone = ambientZone.fork(new SyncTestZoneSpec('jasmine.describe')); + var symbol = Zone.__symbol__; + // whether patch jasmine clock when in fakeAsync + var disablePatchingJasmineClock = _global[symbol('fakeAsyncDisablePatchingClock')] === true; + // the original variable name fakeAsyncPatchLock is not accurate, so the name will be + // fakeAsyncAutoFakeAsyncWhenClockPatched and if this enablePatchingJasmineClock is false, we also + // automatically disable the auto jump into fakeAsync feature + var enableAutoFakeAsyncWhenClockPatched = !disablePatchingJasmineClock && + ((_global[symbol('fakeAsyncPatchLock')] === true) || + (_global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true)); + var ignoreUnhandledRejection = _global[symbol('ignoreUnhandledRejection')] === true; + if (!ignoreUnhandledRejection) { + var globalErrors_1 = jasmine.GlobalErrors; + if (globalErrors_1 && !jasmine[symbol('GlobalErrors')]) { + jasmine[symbol('GlobalErrors')] = globalErrors_1; + jasmine.GlobalErrors = function () { + var instance = new globalErrors_1(); + var originalInstall = instance.install; + if (originalInstall && !instance[symbol('install')]) { + instance[symbol('install')] = originalInstall; + instance.install = function () { + var originalHandlers = process.listeners('unhandledRejection'); + var r = originalInstall.apply(this, arguments); + process.removeAllListeners('unhandledRejection'); + if (originalHandlers) { + originalHandlers.forEach(function (h) { return process.on('unhandledRejection', h); }); + } + return r; + }; + } + return instance; + }; + } + } + // Monkey patch all of the jasmine DSL so that each function runs in appropriate zone. + var jasmineEnv = jasmine.getEnv(); + ['describe', 'xdescribe', 'fdescribe'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[methodName] = function (description, specDefinitions) { + return originalJasmineFn.call(this, description, wrapDescribeInZone(specDefinitions)); }; - }; - FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { - var _this = this; - return function () { - // Requeue the timer callback if it's not been canceled. - if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { - _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + }); + ['it', 'xit', 'fit'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (description, specDefinitions, timeout) { + arguments[1] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + ['beforeEach', 'afterEach', 'beforeAll', 'afterAll'].forEach(function (methodName) { + var originalJasmineFn = jasmineEnv[methodName]; + jasmineEnv[symbol(methodName)] = originalJasmineFn; + jasmineEnv[methodName] = function (specDefinitions, timeout) { + arguments[0] = wrapTestInZone(specDefinitions); + return originalJasmineFn.apply(this, arguments); + }; + }); + if (!disablePatchingJasmineClock) { + // need to patch jasmine.clock().mockDate and jasmine.clock().tick() so + // they can work properly in FakeAsyncTest + var originalClockFn_1 = (jasmine[symbol('clock')] = jasmine['clock']); + jasmine['clock'] = function () { + var clock = originalClockFn_1.apply(this, arguments); + if (!clock[symbol('patched')]) { + clock[symbol('patched')] = symbol('patched'); + var originalTick_1 = (clock[symbol('tick')] = clock.tick); + clock.tick = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + return fakeAsyncZoneSpec.tick.apply(fakeAsyncZoneSpec, arguments); + } + return originalTick_1.apply(this, arguments); + }; + var originalMockDate_1 = (clock[symbol('mockDate')] = clock.mockDate); + clock.mockDate = function () { + var fakeAsyncZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncZoneSpec) { + var dateTime = arguments.length > 0 ? arguments[0] : new Date(); + return fakeAsyncZoneSpec.setCurrentRealTime.apply(fakeAsyncZoneSpec, dateTime && typeof dateTime.getTime === 'function' ? [dateTime.getTime()] : + arguments); + } + return originalMockDate_1.apply(this, arguments); + }; + // for auto go into fakeAsync feature, we need the flag to enable it + if (enableAutoFakeAsyncWhenClockPatched) { + ['install', 'uninstall'].forEach(function (methodName) { + var originalClockFn = (clock[symbol(methodName)] = clock[methodName]); + clock[methodName] = function () { + var FakeAsyncTestZoneSpec = Zone['FakeAsyncTestZoneSpec']; + if (FakeAsyncTestZoneSpec) { + jasmine[symbol('clockInstalled')] = 'install' === methodName; + return; + } + return originalClockFn.apply(this, arguments); + }; + }); + } } + return clock; }; - }; - FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { - var _this = this; + } + /** + * Gets a function wrapping the body of a Jasmine `describe` block to execute in a + * synchronous-only zone. + */ + function wrapDescribeInZone(describeBody) { return function () { - FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + return syncZone.run(describeBody, this, arguments); }; - }; - FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { - if (isTimer === void 0) { isTimer = true; } - var removeTimerFn = this._dequeueTimer(Scheduler.nextId); - // Queue the callback and dequeue the timer on success and error. - var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); - var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); - if (isTimer) { - this.pendingTimers.push(id); - } - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { - var id = Scheduler.nextId; - var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; - var cb = this._fnAndFlush(fn, completers); - // Use the callback created above to requeue on success. - completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); - // Queue the callback and dequeue the periodic timer only on error. - this._scheduler.scheduleFunction(cb, interval, args, true); - this.pendingPeriodicTimers.push(id); - return id; - }; - FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { - FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); - this._scheduler.removeScheduledFunctionWithId(id); - }; - FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { - var error = this._lastError || this._uncaughtPromiseErrors[0]; - this._uncaughtPromiseErrors.length = 0; - this._lastError = null; - throw error; - }; - FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { - return this._scheduler.getCurrentTime(); - }; - FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { - return this._scheduler.getCurrentRealTime(); - }; - FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { - this._scheduler.setCurrentRealTime(realTime); - }; - FakeAsyncTestZoneSpec.patchDate = function () { - if (!!global[Zone.__symbol__('disableDatePatching')]) { - // we don't want to patch global Date - // because in some case, global Date - // is already being patched, we need to provide - // an option to let user still use their - // own version of Date. - return; - } - if (global['Date'] === FakeDate) { - // already patched - return; - } - global['Date'] = FakeDate; - FakeDate.prototype = OriginalDate.prototype; - // try check and reset timers - // because jasmine.clock().install() may - // have replaced the global timer - FakeAsyncTestZoneSpec.checkTimerPatch(); - }; - FakeAsyncTestZoneSpec.resetDate = function () { - if (global['Date'] === FakeDate) { - global['Date'] = OriginalDate; - } - }; - FakeAsyncTestZoneSpec.checkTimerPatch = function () { - if (global.setTimeout !== timers.setTimeout) { - global.setTimeout = timers.setTimeout; - global.clearTimeout = timers.clearTimeout; + } + function runInTestZone(testBody, applyThis, queueRunner, done) { + var isClockInstalled = !!jasmine[symbol('clockInstalled')]; + var testProxyZoneSpec = queueRunner.testProxyZoneSpec; + var testProxyZone = queueRunner.testProxyZone; + if (isClockInstalled && enableAutoFakeAsyncWhenClockPatched) { + // auto run a fakeAsync + var fakeAsyncModule = Zone[Zone.__symbol__('fakeAsyncTest')]; + if (fakeAsyncModule && typeof fakeAsyncModule.fakeAsync === 'function') { + testBody = fakeAsyncModule.fakeAsync(testBody); + } } - if (global.setInterval !== timers.setInterval) { - global.setInterval = timers.setInterval; - global.clearInterval = timers.clearInterval; + if (done) { + return testProxyZone.run(testBody, applyThis, [done]); } - }; - FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { - this.patchDateLocked = true; - FakeAsyncTestZoneSpec.patchDate(); - }; - FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { - this.patchDateLocked = false; - FakeAsyncTestZoneSpec.resetDate(); - }; - FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { - if (millis === void 0) { millis = 0; } - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - this._scheduler.tick(millis, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); + else { + return testProxyZone.run(testBody, applyThis); } - }; - FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { - var _this = this; - FakeAsyncTestZoneSpec.assertInZone(); - var flushErrors = function () { - if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { - // If there is an error stop processing the microtask queue and rethrow the error. - _this._resetLastErrorAndThrow(); + } + /** + * Gets a function wrapping the body of a Jasmine `it/beforeEach/afterEach` block to + * execute in a ProxyZone zone. + * This will run in `testProxyZone`. The `testProxyZone` will be reset by the `ZoneQueueRunner` + */ + function wrapTestInZone(testBody) { + // The `done` callback is only passed through if the function expects at least one argument. + // Note we have to make a function with correct number of arguments, otherwise jasmine will + // think that all functions are sync or async. + return (testBody && (testBody.length ? function (done) { + return runInTestZone(testBody, this, this.queueRunner, done); + } : function () { + return runInTestZone(testBody, this, this.queueRunner); + })); + } + var QueueRunner = jasmine.QueueRunner; + jasmine.QueueRunner = (function (_super) { + __extends(ZoneQueueRunner, _super); + function ZoneQueueRunner(attrs) { + var _this = this; + attrs.onComplete = (function (fn) { return function () { + // All functions are done, clear the test zone. + _this.testProxyZone = null; + _this.testProxyZoneSpec = null; + ambientZone.scheduleMicroTask('jasmine.onComplete', fn); + }; })(attrs.onComplete); + var nativeSetTimeout = _global[Zone.__symbol__('setTimeout')]; + var nativeClearTimeout = _global[Zone.__symbol__('clearTimeout')]; + if (nativeSetTimeout) { + // should run setTimeout inside jasmine outside of zone + attrs.timeout = { + setTimeout: nativeSetTimeout ? nativeSetTimeout : _global.setTimeout, + clearTimeout: nativeClearTimeout ? nativeClearTimeout : _global.clearTimeout + }; } - }; - while (this._microtasks.length > 0) { - var microtask = this._microtasks.shift(); - microtask.func.apply(microtask.target, microtask.args); - } - flushErrors(); - }; - FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { - FakeAsyncTestZoneSpec.assertInZone(); - this.flushMicrotasks(); - var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); - if (this._lastError !== null) { - this._resetLastErrorAndThrow(); - } - return elapsed; - }; - FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { - switch (task.type) { - case 'microTask': - var args = task.data && task.data.args; - // should pass additional arguments to callback if have any - // currently we know process.nextTick will have such additional - // arguments - var additionalArgs = void 0; - if (args) { - var callbackIndex = task.data.cbIdx; - if (typeof args.length === 'number' && args.length > callbackIndex + 1) { - additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); - } + // create a userContext to hold the queueRunner itself + // so we can access the testProxy in it/xit/beforeEach ... + if (jasmine.UserContext) { + if (!attrs.userContext) { + attrs.userContext = new jasmine.UserContext(); } - this._microtasks.push({ - func: task.invoke, - args: additionalArgs, - target: task.data && task.data.target - }); - break; - case 'macroTask': - switch (task.source) { - case 'setTimeout': - task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'setImmediate': - task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); - break; - case 'setInterval': - task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); - break; - case 'XMLHttpRequest.send': - throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + - task.data['url']); - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. - // (60 frames per second) - task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); - break; - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var args_1 = task.data && task.data['args']; - var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; - var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; - if (!!macroTaskOption.isPeriodic) { - // periodic macroTask, use setInterval to simulate - task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); - task.data.isPeriodic = true; - } - else { - // not periodic, use setTimeout to simulate - task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); - } - break; + attrs.userContext.queueRunner = this; + } + else { + if (!attrs.userContext) { + attrs.userContext = {}; + } + attrs.userContext.queueRunner = this; + } + // patch attrs.onException + var onException = attrs.onException; + attrs.onException = function (error) { + if (error && + error.message === + 'Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.') { + // jasmine timeout, we can make the error message more + // reasonable to tell what tasks are pending + var proxyZoneSpec = this && this.testProxyZoneSpec; + if (proxyZoneSpec) { + var pendingTasksInfo = proxyZoneSpec.getAndClearPendingTasksInfo(); + try { + // try catch here in case error.message is not writable + error.message += pendingTasksInfo; } - throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + catch (err) { + } + } } - break; - case 'eventTask': - task = delegate.scheduleTask(target, task); - break; - } - return task; - }; - FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { - switch (task.source) { - case 'setTimeout': - case 'requestAnimationFrame': - case 'webkitRequestAnimationFrame': - case 'mozRequestAnimationFrame': - return this._clearTimeout(task.data['handleId']); - case 'setInterval': - return this._clearInterval(task.data['handleId']); - default: - // user can define which macroTask they want to support by passing - // macroTaskOptions - var macroTaskOption = this.findMacroTaskOption(task); - if (macroTaskOption) { - var handleId = task.data['handleId']; - return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : - this._clearTimeout(handleId); + if (onException) { + onException.call(this, error); } - return delegate.cancelTask(target, task); - } - }; - FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { - try { - FakeAsyncTestZoneSpec.patchDate(); - return delegate.invoke(target, callback, applyThis, applyArgs, source); + }; + _super.call(this, attrs); } - finally { - if (!this.patchDateLocked) { - FakeAsyncTestZoneSpec.resetDate(); + ZoneQueueRunner.prototype.execute = function () { + var _this = this; + var zone = Zone.current; + var isChildOfAmbientZone = false; + while (zone) { + if (zone === ambientZone) { + isChildOfAmbientZone = true; + break; + } + zone = zone.parent; } - } - }; - FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { - if (!this.macroTaskOptions) { - return null; - } - for (var i = 0; i < this.macroTaskOptions.length; i++) { - var macroTaskOption = this.macroTaskOptions[i]; - if (macroTaskOption.source === task.source) { - return macroTaskOption; + if (!isChildOfAmbientZone) + throw new Error('Unexpected Zone: ' + Zone.current.name); + // This is the zone which will be used for running individual tests. + // It will be a proxy zone, so that the tests function can retroactively install + // different zones. + // Example: + // - In beforeEach() do childZone = Zone.current.fork(...); + // - In it() try to do fakeAsync(). The issue is that because the beforeEach forked the + // zone outside of fakeAsync it will be able to escape the fakeAsync rules. + // - Because ProxyZone is parent fo `childZone` fakeAsync can retroactively add + // fakeAsync behavior to the childZone. + this.testProxyZoneSpec = new ProxyZoneSpec(); + this.testProxyZone = ambientZone.fork(this.testProxyZoneSpec); + if (!Zone.currentTask) { + // if we are not running in a task then if someone would register a + // element.addEventListener and then calling element.click() the + // addEventListener callback would think that it is the top most task and would + // drain the microtask queue on element.click() which would be incorrect. + // For this reason we always force a task when running jasmine tests. + Zone.current.scheduleMicroTask('jasmine.execute().forceTask', function () { return QueueRunner.prototype.execute.call(_this); }); } - } - return null; - }; - FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { - this._lastError = error; - return false; // Don't propagate error to parent zone. - }; - return FakeAsyncTestZoneSpec; - }()); - // Export the class so that new instances can be created with proper - // constructor params. - Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); - -/** - * @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.__load_patch('fakeasync', function (global, Zone, api) { - var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; - var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; - var _fakeAsyncTestZoneSpec = null; + else { + _super.prototype.execute.call(this); + } + }; + return ZoneQueueRunner; + })(QueueRunner); + })(commonjsGlobal); /** - * Clears out the shared fake async zone for a test. - * To be called in a global `beforeEach`. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 resetFakeAsyncZone() { - if (_fakeAsyncTestZoneSpec) { - _fakeAsyncTestZoneSpec.unlockDatePatch(); - } - _fakeAsyncTestZoneSpec = null; - // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. - ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); - } - /** - * Wraps a function to be executed in the fakeAsync zone: - * - microtasks are manually executed by calling `flushMicrotasks()`, - * - timers are synchronous, `tick()` simulates the asynchronous passage of time. - * - * If there are any pending timers at the end of the function, an exception will be thrown. - * - * Can be used to wrap inject() calls. - * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @param fn - * @returns The function wrapped to be executed in the fakeAsync zone - * - * @experimental - */ - function fakeAsync(fn) { - // Not using an arrow function to preserve context passed from call site - return function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var proxyZoneSpec = ProxyZoneSpec.assertPresent(); - if (Zone.current.get('FakeAsyncTestZoneSpec')) { - throw new Error('fakeAsync() calls can not be nested'); + (function (_global) { + var AsyncTestZoneSpec = /** @class */ (function () { + function AsyncTestZoneSpec(finishCallback, failCallback, namePrefix) { + this.finishCallback = finishCallback; + this.failCallback = failCallback; + this._pendingMicroTasks = false; + this._pendingMacroTasks = false; + this._alreadyErrored = false; + this._isSync = false; + this.runZone = Zone.current; + this.unresolvedChainedPromiseCount = 0; + this.supportWaitUnresolvedChainedPromise = false; + this.name = 'asyncTestZone for ' + namePrefix; + this.properties = { 'AsyncTestZoneSpec': this }; + this.supportWaitUnresolvedChainedPromise = + _global[Zone.__symbol__('supportWaitUnResolvedChainedPromise')] === true; } - try { - // in case jasmine.clock init a fakeAsyncTestZoneSpec - if (!_fakeAsyncTestZoneSpec) { - if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { - throw new Error('fakeAsync() calls can not be nested'); + AsyncTestZoneSpec.prototype.isUnresolvedChainedPromisePending = function () { + return this.unresolvedChainedPromiseCount > 0; + }; + AsyncTestZoneSpec.prototype._finishCallbackIfDone = function () { + var _this = this; + if (!(this._pendingMicroTasks || this._pendingMacroTasks || + (this.supportWaitUnresolvedChainedPromise && this.isUnresolvedChainedPromisePending()))) { + // We do this because we would like to catch unhandled rejected promises. + this.runZone.run(function () { + setTimeout(function () { + if (!_this._alreadyErrored && !(_this._pendingMicroTasks || _this._pendingMacroTasks)) { + _this.finishCallback(); + } + }, 0); + }); + } + }; + AsyncTestZoneSpec.prototype.patchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var patchPromiseForTest = Promise[Zone.__symbol__('patchPromiseForTest')]; + if (patchPromiseForTest) { + patchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.unPatchPromiseForTest = function () { + if (!this.supportWaitUnresolvedChainedPromise) { + return; + } + var unPatchPromiseForTest = Promise[Zone.__symbol__('unPatchPromiseForTest')]; + if (unPatchPromiseForTest) { + unPatchPromiseForTest(); + } + }; + AsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + if (task.type === 'microTask' && task.data && task.data instanceof Promise) { + // check whether the promise is a chained promise + if (task.data[AsyncTestZoneSpec.symbolParentUnresolved] === true) { + // chained promise is being scheduled + this.unresolvedChainedPromiseCount--; } - _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); } - var res = void 0; - var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); - proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); - _fakeAsyncTestZoneSpec.lockDatePatch(); + return delegate.scheduleTask(target, task); + }; + AsyncTestZoneSpec.prototype.onInvokeTask = function (delegate, current, target, task, applyThis, applyArgs) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.invokeTask(target, task, applyThis, applyArgs); + }; + AsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + if (task.type !== 'eventTask') { + this._isSync = false; + } + return delegate.cancelTask(target, task); + }; + // 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. + // updated by(JiaLiPassion), only call finish callback when no task + // was scheduled/invoked/canceled. + AsyncTestZoneSpec.prototype.onInvoke = function (parentZoneDelegate, currentZone, targetZone, delegate, applyThis, applyArgs, source) { try { - res = fn.apply(this, args); - flushMicrotasks(); + this._isSync = true; + return parentZoneDelegate.invoke(targetZone, delegate, applyThis, applyArgs, source); } finally { - proxyZoneSpec.setDelegate(lastProxyZoneSpec); + var afterTaskCounts = parentZoneDelegate._taskCounts; + if (this._isSync) { + this._finishCallbackIfDone(); + } } - if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + - "periodic timer(s) still in the queue."); + }; + AsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + // Let the parent try to handle the error. + var result = parentZoneDelegate.handleError(targetZone, error); + if (result) { + this.failCallback(error); + this._alreadyErrored = true; } - if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { - throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + return false; + }; + AsyncTestZoneSpec.prototype.onHasTask = function (delegate, current, target, hasTaskState) { + delegate.hasTask(target, hasTaskState); + if (hasTaskState.change == 'microTask') { + this._pendingMicroTasks = hasTaskState.microTask; + this._finishCallbackIfDone(); } - return res; - } - finally { - resetFakeAsyncZone(); + else if (hasTaskState.change == 'macroTask') { + this._pendingMacroTasks = hasTaskState.macroTask; + this._finishCallbackIfDone(); + } + }; + return AsyncTestZoneSpec; + }()); + AsyncTestZoneSpec.symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['AsyncTestZoneSpec'] = AsyncTestZoneSpec; + })(commonjsGlobal); + /** + * @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.__load_patch('asynctest', function (global, Zone, api) { + /** + * Wraps a test function in an asynchronous test zone. The test will automatically + * complete when all asynchronous calls within this zone are done. + */ + Zone[api.symbol('asyncTest')] = function asyncTest(fn) { + // If we're running using the Jasmine test framework, adapt to call the 'done' + // function when asynchronous activity is finished. + if (global.jasmine) { + // Not using an arrow function to preserve context passed from call site + return function (done) { + if (!done) { + // if we run beforeEach in @angular/core/testing/testing_internal then we get no done + // fake it here and assume sync. + done = function () { }; + done.fail = function (e) { + throw e; + }; + } + runInTestZone(fn, this, done, function (err) { + if (typeof err === 'string') { + return done.fail(new Error(err)); + } + else { + done.fail(err); + } + }); + }; } + // Otherwise, return a promise which will resolve when asynchronous activity + // is finished. This will be correctly consumed by the Mocha framework with + // it('...', async(myFn)); or can be used in a custom framework. + // Not using an arrow function to preserve context passed from call site + return function () { + var _this = this; + return new Promise(function (finishCallback, failCallback) { + runInTestZone(fn, _this, finishCallback, failCallback); + }); + }; }; - } - function _getFakeAsyncZoneSpec() { - if (_fakeAsyncTestZoneSpec == null) { - _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); - if (_fakeAsyncTestZoneSpec == null) { - throw new Error('The code should be running in the fakeAsync zone to call this function'); + function runInTestZone(fn, context, finishCallback, failCallback) { + var currentZone = Zone.current; + var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; + if (AsyncTestZoneSpec === undefined) { + throw new Error('AsyncTestZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/async-test.js'); + } + var ProxyZoneSpec = Zone['ProxyZoneSpec']; + if (ProxyZoneSpec === undefined) { + throw new Error('ProxyZoneSpec is needed for the async() test helper but could not be found. ' + + 'Please make sure that your environment includes zone.js/dist/proxy.js'); } + var proxyZoneSpec = ProxyZoneSpec.get(); + ProxyZoneSpec.assertPresent(); + // We need to create the AsyncTestZoneSpec outside the ProxyZone. + // If we do it in ProxyZone then we will get to infinite recursion. + var proxyZone = Zone.current.getZoneWith('ProxyZoneSpec'); + var previousDelegate = proxyZoneSpec.getDelegate(); + proxyZone.parent.run(function () { + var testZoneSpec = new AsyncTestZoneSpec(function () { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's + // sill this one. Otherwise, assume + // it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + finishCallback(); + }); + }, function (error) { + // Need to restore the original zone. + if (proxyZoneSpec.getDelegate() == testZoneSpec) { + // Only reset the zone spec if it's sill this one. Otherwise, assume it's OK. + proxyZoneSpec.setDelegate(previousDelegate); + } + testZoneSpec.unPatchPromiseForTest(); + currentZone.run(function () { + failCallback(error); + }); + }, 'test'); + proxyZoneSpec.setDelegate(testZoneSpec); + testZoneSpec.patchPromiseForTest(); + }); + return Zone.current.runGuarded(fn, context); } - return _fakeAsyncTestZoneSpec; - } + }); /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. - * - * The microtasks queue is drained at the very start of this function and after any timer callback - * has been executed. + * @license + * Copyright Google Inc. All Rights Reserved. * - * ## Example - * - * {@example core/testing/ts/fake_async.ts region='basic'} - * - * @experimental + * 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 tick(millis) { - if (millis === void 0) { millis = 0; } - _getFakeAsyncZoneSpec().tick(millis); - } + (function (global) { + var OriginalDate = global.Date; + var FakeDate = /** @class */ (function () { + function FakeDate() { + if (arguments.length === 0) { + var d = new OriginalDate(); + d.setTime(FakeDate.now()); + return d; + } + else { + var args = Array.prototype.slice.call(arguments); + return new (OriginalDate.bind.apply(OriginalDate, [void 0].concat(args)))(); + } + } + FakeDate.now = function () { + var fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (fakeAsyncTestZoneSpec) { + return fakeAsyncTestZoneSpec.getCurrentRealTime() + fakeAsyncTestZoneSpec.getCurrentTime(); + } + return OriginalDate.now.apply(this, arguments); + }; + return FakeDate; + }()); + FakeDate.UTC = OriginalDate.UTC; + FakeDate.parse = OriginalDate.parse; + // keep a reference for zone patched timer function + var timers = { + setTimeout: global.setTimeout, + setInterval: global.setInterval, + clearTimeout: global.clearTimeout, + clearInterval: global.clearInterval + }; + var Scheduler = /** @class */ (function () { + function Scheduler() { + // Scheduler queue with the tuple of end time and callback function - sorted by end time. + this._schedulerQueue = []; + // Current simulated time in millis. + this._currentTime = 0; + // Current real time in millis. + this._currentRealTime = OriginalDate.now(); + } + Scheduler.prototype.getCurrentTime = function () { + return this._currentTime; + }; + Scheduler.prototype.getCurrentRealTime = function () { + return this._currentRealTime; + }; + Scheduler.prototype.setCurrentRealTime = function (realTime) { + this._currentRealTime = realTime; + }; + Scheduler.prototype.scheduleFunction = function (cb, delay, args, isPeriodic, isRequestAnimationFrame, id) { + if (args === void 0) { args = []; } + if (isPeriodic === void 0) { isPeriodic = false; } + if (isRequestAnimationFrame === void 0) { isRequestAnimationFrame = false; } + if (id === void 0) { id = -1; } + var currentId = id < 0 ? Scheduler.nextId++ : id; + var endTime = this._currentTime + delay; + // Insert so that scheduler queue remains sorted by end time. + var newEntry = { + endTime: endTime, + id: currentId, + func: cb, + args: args, + delay: delay, + isPeriodic: isPeriodic, + isRequestAnimationFrame: isRequestAnimationFrame + }; + var i = 0; + for (; i < this._schedulerQueue.length; i++) { + var currentEntry = this._schedulerQueue[i]; + if (newEntry.endTime < currentEntry.endTime) { + break; + } + } + this._schedulerQueue.splice(i, 0, newEntry); + return currentId; + }; + Scheduler.prototype.removeScheduledFunctionWithId = function (id) { + for (var i = 0; i < this._schedulerQueue.length; i++) { + if (this._schedulerQueue[i].id == id) { + this._schedulerQueue.splice(i, 1); + break; + } + } + }; + Scheduler.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + var finalTime = this._currentTime + millis; + var lastCurrentTime = 0; + if (this._schedulerQueue.length === 0 && doTick) { + doTick(millis); + return; + } + while (this._schedulerQueue.length > 0) { + var current = this._schedulerQueue[0]; + if (finalTime < current.endTime) { + // Done processing the queue since it's sorted by endTime. + break; + } + else { + // Time to run scheduled function. Remove it from the head of queue. + var current_1 = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current_1.endTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + var retval = current_1.func.apply(global, current_1.isRequestAnimationFrame ? [this._currentTime] : current_1.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + } + lastCurrentTime = this._currentTime; + this._currentTime = finalTime; + if (doTick) { + doTick(this._currentTime - lastCurrentTime); + } + }; + Scheduler.prototype.flush = function (limit, flushPeriodic, doTick) { + if (limit === void 0) { limit = 20; } + if (flushPeriodic === void 0) { flushPeriodic = false; } + if (flushPeriodic) { + return this.flushPeriodic(doTick); + } + else { + return this.flushNonPeriodic(limit, doTick); + } + }; + Scheduler.prototype.flushPeriodic = function (doTick) { + if (this._schedulerQueue.length === 0) { + return 0; + } + // Find the last task currently queued in the scheduler queue and tick + // till that time. + var startTime = this._currentTime; + var lastTask = this._schedulerQueue[this._schedulerQueue.length - 1]; + this.tick(lastTask.endTime - startTime, doTick); + return this._currentTime - startTime; + }; + Scheduler.prototype.flushNonPeriodic = function (limit, doTick) { + var startTime = this._currentTime; + var lastCurrentTime = 0; + var count = 0; + while (this._schedulerQueue.length > 0) { + count++; + if (count > limit) { + throw new Error('flush failed after reaching the limit of ' + limit + + ' tasks. Does your code use a polling timeout?'); + } + // flush only non-periodic timers. + // If the only remaining tasks are periodic(or requestAnimationFrame), finish flushing. + if (this._schedulerQueue.filter(function (task) { return !task.isPeriodic && !task.isRequestAnimationFrame; }) + .length === 0) { + break; + } + var current = this._schedulerQueue.shift(); + lastCurrentTime = this._currentTime; + this._currentTime = current.endTime; + if (doTick) { + // Update any secondary schedulers like Jasmine mock Date. + doTick(this._currentTime - lastCurrentTime); + } + var retval = current.func.apply(global, current.args); + if (!retval) { + // Uncaught exception in the current scheduled function. Stop processing the queue. + break; + } + } + return this._currentTime - startTime; + }; + return Scheduler; + }()); + // Next scheduler id. + Scheduler.nextId = 1; + var FakeAsyncTestZoneSpec = /** @class */ (function () { + function FakeAsyncTestZoneSpec(namePrefix, trackPendingRequestAnimationFrame, macroTaskOptions) { + if (trackPendingRequestAnimationFrame === void 0) { trackPendingRequestAnimationFrame = false; } + this.trackPendingRequestAnimationFrame = trackPendingRequestAnimationFrame; + this.macroTaskOptions = macroTaskOptions; + this._scheduler = new Scheduler(); + this._microtasks = []; + this._lastError = null; + this._uncaughtPromiseErrors = Promise[Zone.__symbol__('uncaughtPromiseErrors')]; + this.pendingPeriodicTimers = []; + this.pendingTimers = []; + this.patchDateLocked = false; + this.properties = { 'FakeAsyncTestZoneSpec': this }; + this.name = 'fakeAsyncTestZone for ' + namePrefix; + // in case user can't access the construction of FakeAsyncTestSpec + // user can also define macroTaskOptions by define a global variable. + if (!this.macroTaskOptions) { + this.macroTaskOptions = global[Zone.__symbol__('FakeAsyncTestMacroTask')]; + } + } + FakeAsyncTestZoneSpec.assertInZone = function () { + if (Zone.current.get('FakeAsyncTestZoneSpec') == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + }; + FakeAsyncTestZoneSpec.prototype._fnAndFlush = function (fn, completers) { + var _this = this; + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + fn.apply(global, args); + if (_this._lastError === null) { // Success + if (completers.onSuccess != null) { + completers.onSuccess.apply(global); + } + // Flush microtasks only on success. + _this.flushMicrotasks(); + } + else { // Failure + if (completers.onError != null) { + completers.onError.apply(global); + } + } + // Return true if there were no errors, false otherwise. + return _this._lastError === null; + }; + }; + FakeAsyncTestZoneSpec._removeTimer = function (timers, id) { + var index = timers.indexOf(id); + if (index > -1) { + timers.splice(index, 1); + } + }; + FakeAsyncTestZoneSpec.prototype._dequeueTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._requeuePeriodicTimer = function (fn, interval, args, id) { + var _this = this; + return function () { + // Requeue the timer callback if it's not been canceled. + if (_this.pendingPeriodicTimers.indexOf(id) !== -1) { + _this._scheduler.scheduleFunction(fn, interval, args, true, false, id); + } + }; + }; + FakeAsyncTestZoneSpec.prototype._dequeuePeriodicTimer = function (id) { + var _this = this; + return function () { + FakeAsyncTestZoneSpec._removeTimer(_this.pendingPeriodicTimers, id); + }; + }; + FakeAsyncTestZoneSpec.prototype._setTimeout = function (fn, delay, args, isTimer) { + if (isTimer === void 0) { isTimer = true; } + var removeTimerFn = this._dequeueTimer(Scheduler.nextId); + // Queue the callback and dequeue the timer on success and error. + var cb = this._fnAndFlush(fn, { onSuccess: removeTimerFn, onError: removeTimerFn }); + var id = this._scheduler.scheduleFunction(cb, delay, args, false, !isTimer); + if (isTimer) { + this.pendingTimers.push(id); + } + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearTimeout = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._setInterval = function (fn, interval, args) { + var id = Scheduler.nextId; + var completers = { onSuccess: null, onError: this._dequeuePeriodicTimer(id) }; + var cb = this._fnAndFlush(fn, completers); + // Use the callback created above to requeue on success. + completers.onSuccess = this._requeuePeriodicTimer(cb, interval, args, id); + // Queue the callback and dequeue the periodic timer only on error. + this._scheduler.scheduleFunction(cb, interval, args, true); + this.pendingPeriodicTimers.push(id); + return id; + }; + FakeAsyncTestZoneSpec.prototype._clearInterval = function (id) { + FakeAsyncTestZoneSpec._removeTimer(this.pendingPeriodicTimers, id); + this._scheduler.removeScheduledFunctionWithId(id); + }; + FakeAsyncTestZoneSpec.prototype._resetLastErrorAndThrow = function () { + var error = this._lastError || this._uncaughtPromiseErrors[0]; + this._uncaughtPromiseErrors.length = 0; + this._lastError = null; + throw error; + }; + FakeAsyncTestZoneSpec.prototype.getCurrentTime = function () { + return this._scheduler.getCurrentTime(); + }; + FakeAsyncTestZoneSpec.prototype.getCurrentRealTime = function () { + return this._scheduler.getCurrentRealTime(); + }; + FakeAsyncTestZoneSpec.prototype.setCurrentRealTime = function (realTime) { + this._scheduler.setCurrentRealTime(realTime); + }; + FakeAsyncTestZoneSpec.patchDate = function () { + if (!!global[Zone.__symbol__('disableDatePatching')]) { + // we don't want to patch global Date + // because in some case, global Date + // is already being patched, we need to provide + // an option to let user still use their + // own version of Date. + return; + } + if (global['Date'] === FakeDate) { + // already patched + return; + } + global['Date'] = FakeDate; + FakeDate.prototype = OriginalDate.prototype; + // try check and reset timers + // because jasmine.clock().install() may + // have replaced the global timer + FakeAsyncTestZoneSpec.checkTimerPatch(); + }; + FakeAsyncTestZoneSpec.resetDate = function () { + if (global['Date'] === FakeDate) { + global['Date'] = OriginalDate; + } + }; + FakeAsyncTestZoneSpec.checkTimerPatch = function () { + if (global.setTimeout !== timers.setTimeout) { + global.setTimeout = timers.setTimeout; + global.clearTimeout = timers.clearTimeout; + } + if (global.setInterval !== timers.setInterval) { + global.setInterval = timers.setInterval; + global.clearInterval = timers.clearInterval; + } + }; + FakeAsyncTestZoneSpec.prototype.lockDatePatch = function () { + this.patchDateLocked = true; + FakeAsyncTestZoneSpec.patchDate(); + }; + FakeAsyncTestZoneSpec.prototype.unlockDatePatch = function () { + this.patchDateLocked = false; + FakeAsyncTestZoneSpec.resetDate(); + }; + FakeAsyncTestZoneSpec.prototype.tick = function (millis, doTick) { + if (millis === void 0) { millis = 0; } + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + this._scheduler.tick(millis, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + }; + FakeAsyncTestZoneSpec.prototype.flushMicrotasks = function () { + var _this = this; + FakeAsyncTestZoneSpec.assertInZone(); + var flushErrors = function () { + if (_this._lastError !== null || _this._uncaughtPromiseErrors.length) { + // If there is an error stop processing the microtask queue and rethrow the error. + _this._resetLastErrorAndThrow(); + } + }; + while (this._microtasks.length > 0) { + var microtask = this._microtasks.shift(); + microtask.func.apply(microtask.target, microtask.args); + } + flushErrors(); + }; + FakeAsyncTestZoneSpec.prototype.flush = function (limit, flushPeriodic, doTick) { + FakeAsyncTestZoneSpec.assertInZone(); + this.flushMicrotasks(); + var elapsed = this._scheduler.flush(limit, flushPeriodic, doTick); + if (this._lastError !== null) { + this._resetLastErrorAndThrow(); + } + return elapsed; + }; + FakeAsyncTestZoneSpec.prototype.onScheduleTask = function (delegate, current, target, task) { + switch (task.type) { + case 'microTask': + var args = task.data && task.data.args; + // should pass additional arguments to callback if have any + // currently we know process.nextTick will have such additional + // arguments + var additionalArgs = void 0; + if (args) { + var callbackIndex = task.data.cbIdx; + if (typeof args.length === 'number' && args.length > callbackIndex + 1) { + additionalArgs = Array.prototype.slice.call(args, callbackIndex + 1); + } + } + this._microtasks.push({ + func: task.invoke, + args: additionalArgs, + target: task.data && task.data.target + }); + break; + case 'macroTask': + switch (task.source) { + case 'setTimeout': + task.data['handleId'] = this._setTimeout(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'setImmediate': + task.data['handleId'] = this._setTimeout(task.invoke, 0, Array.prototype.slice.call(task.data['args'], 1)); + break; + case 'setInterval': + task.data['handleId'] = this._setInterval(task.invoke, task.data['delay'], Array.prototype.slice.call(task.data['args'], 2)); + break; + case 'XMLHttpRequest.send': + throw new Error('Cannot make XHRs from within a fake async test. Request URL: ' + + task.data['url']); + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + // Simulate a requestAnimationFrame by using a setTimeout with 16 ms. + // (60 frames per second) + task.data['handleId'] = this._setTimeout(task.invoke, 16, task.data['args'], this.trackPendingRequestAnimationFrame); + break; + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var args_1 = task.data && task.data['args']; + var delay = args_1 && args_1.length > 1 ? args_1[1] : 0; + var callbackArgs = macroTaskOption.callbackArgs ? macroTaskOption.callbackArgs : args_1; + if (!!macroTaskOption.isPeriodic) { + // periodic macroTask, use setInterval to simulate + task.data['handleId'] = this._setInterval(task.invoke, delay, callbackArgs); + task.data.isPeriodic = true; + } + else { + // not periodic, use setTimeout to simulate + task.data['handleId'] = this._setTimeout(task.invoke, delay, callbackArgs); + } + break; + } + throw new Error('Unknown macroTask scheduled in fake async test: ' + task.source); + } + break; + case 'eventTask': + task = delegate.scheduleTask(target, task); + break; + } + return task; + }; + FakeAsyncTestZoneSpec.prototype.onCancelTask = function (delegate, current, target, task) { + switch (task.source) { + case 'setTimeout': + case 'requestAnimationFrame': + case 'webkitRequestAnimationFrame': + case 'mozRequestAnimationFrame': + return this._clearTimeout(task.data['handleId']); + case 'setInterval': + return this._clearInterval(task.data['handleId']); + default: + // user can define which macroTask they want to support by passing + // macroTaskOptions + var macroTaskOption = this.findMacroTaskOption(task); + if (macroTaskOption) { + var handleId = task.data['handleId']; + return macroTaskOption.isPeriodic ? this._clearInterval(handleId) : + this._clearTimeout(handleId); + } + return delegate.cancelTask(target, task); + } + }; + FakeAsyncTestZoneSpec.prototype.onInvoke = function (delegate, current, target, callback, applyThis, applyArgs, source) { + try { + FakeAsyncTestZoneSpec.patchDate(); + return delegate.invoke(target, callback, applyThis, applyArgs, source); + } + finally { + if (!this.patchDateLocked) { + FakeAsyncTestZoneSpec.resetDate(); + } + } + }; + FakeAsyncTestZoneSpec.prototype.findMacroTaskOption = function (task) { + if (!this.macroTaskOptions) { + return null; + } + for (var i = 0; i < this.macroTaskOptions.length; i++) { + var macroTaskOption = this.macroTaskOptions[i]; + if (macroTaskOption.source === task.source) { + return macroTaskOption; + } + } + return null; + }; + FakeAsyncTestZoneSpec.prototype.onHandleError = function (parentZoneDelegate, currentZone, targetZone, error) { + this._lastError = error; + return false; // Don't propagate error to parent zone. + }; + return FakeAsyncTestZoneSpec; + }()); + // Export the class so that new instances can be created with proper + // constructor params. + Zone['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; + })(commonjsGlobal); /** - * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by - * draining the macrotask queue until it is empty. The returned value is the milliseconds - * of time that would have been elapsed. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @param maxTurns - * @returns The simulated time elapsed, in millis. - * - * @experimental + * 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 flush(maxTurns) { - return _getFakeAsyncZoneSpec().flush(maxTurns); - } + Zone.__load_patch('fakeasync', function (global, Zone, api) { + var FakeAsyncTestZoneSpec = Zone && Zone['FakeAsyncTestZoneSpec']; + var ProxyZoneSpec = Zone && Zone['ProxyZoneSpec']; + var _fakeAsyncTestZoneSpec = null; + /** + * Clears out the shared fake async zone for a test. + * To be called in a global `beforeEach`. + * + * @experimental + */ + function resetFakeAsyncZone() { + if (_fakeAsyncTestZoneSpec) { + _fakeAsyncTestZoneSpec.unlockDatePatch(); + } + _fakeAsyncTestZoneSpec = null; + // in node.js testing we may not have ProxyZoneSpec in which case there is nothing to reset. + ProxyZoneSpec && ProxyZoneSpec.assertPresent().resetDelegate(); + } + /** + * Wraps a function to be executed in the fakeAsync zone: + * - microtasks are manually executed by calling `flushMicrotasks()`, + * - timers are synchronous, `tick()` simulates the asynchronous passage of time. + * + * If there are any pending timers at the end of the function, an exception will be thrown. + * + * Can be used to wrap inject() calls. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @param fn + * @returns The function wrapped to be executed in the fakeAsync zone + * + * @experimental + */ + function fakeAsync(fn) { + // Not using an arrow function to preserve context passed from call site + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var proxyZoneSpec = ProxyZoneSpec.assertPresent(); + if (Zone.current.get('FakeAsyncTestZoneSpec')) { + throw new Error('fakeAsync() calls can not be nested'); + } + try { + // in case jasmine.clock init a fakeAsyncTestZoneSpec + if (!_fakeAsyncTestZoneSpec) { + if (proxyZoneSpec.getDelegate() instanceof FakeAsyncTestZoneSpec) { + throw new Error('fakeAsync() calls can not be nested'); + } + _fakeAsyncTestZoneSpec = new FakeAsyncTestZoneSpec(); + } + var res = void 0; + var lastProxyZoneSpec = proxyZoneSpec.getDelegate(); + proxyZoneSpec.setDelegate(_fakeAsyncTestZoneSpec); + _fakeAsyncTestZoneSpec.lockDatePatch(); + try { + res = fn.apply(this, args); + flushMicrotasks(); + } + finally { + proxyZoneSpec.setDelegate(lastProxyZoneSpec); + } + if (_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingPeriodicTimers.length + " " + + "periodic timer(s) still in the queue."); + } + if (_fakeAsyncTestZoneSpec.pendingTimers.length > 0) { + throw new Error(_fakeAsyncTestZoneSpec.pendingTimers.length + " timer(s) still in the queue."); + } + return res; + } + finally { + resetFakeAsyncZone(); + } + }; + } + function _getFakeAsyncZoneSpec() { + if (_fakeAsyncTestZoneSpec == null) { + _fakeAsyncTestZoneSpec = Zone.current.get('FakeAsyncTestZoneSpec'); + if (_fakeAsyncTestZoneSpec == null) { + throw new Error('The code should be running in the fakeAsync zone to call this function'); + } + } + return _fakeAsyncTestZoneSpec; + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone. + * + * The microtasks queue is drained at the very start of this function and after any timer callback + * has been executed. + * + * ## Example + * + * {@example core/testing/ts/fake_async.ts region='basic'} + * + * @experimental + */ + function tick(millis) { + if (millis === void 0) { millis = 0; } + _getFakeAsyncZoneSpec().tick(millis); + } + /** + * Simulates the asynchronous passage of time for the timers in the fakeAsync zone by + * draining the macrotask queue until it is empty. The returned value is the milliseconds + * of time that would have been elapsed. + * + * @param maxTurns + * @returns The simulated time elapsed, in millis. + * + * @experimental + */ + function flush(maxTurns) { + return _getFakeAsyncZoneSpec().flush(maxTurns); + } + /** + * Discard all remaining periodic tasks. + * + * @experimental + */ + function discardPeriodicTasks() { + var zoneSpec = _getFakeAsyncZoneSpec(); + var pendingTimers = zoneSpec.pendingPeriodicTimers; + zoneSpec.pendingPeriodicTimers.length = 0; + } + /** + * Flush any pending microtasks. + * + * @experimental + */ + function flushMicrotasks() { + _getFakeAsyncZoneSpec().flushMicrotasks(); + } + Zone[api.symbol('fakeAsyncTest')] = + { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; + }); /** - * Discard all remaining periodic tasks. + * @license + * Copyright Google Inc. All Rights Reserved. * - * @experimental + * 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 discardPeriodicTasks() { - var zoneSpec = _getFakeAsyncZoneSpec(); - var pendingTimers = zoneSpec.pendingPeriodicTimers; - zoneSpec.pendingPeriodicTimers.length = 0; - } /** - * Flush any pending microtasks. + * Promise for async/fakeAsync zoneSpec test + * can support async operation which not supported by zone.js + * such as + * it ('test jsonp in AsyncZone', async() => { + * new Promise(res => { + * jsonp(url, (data) => { + * // success callback + * res(data); + * }); + * }).then((jsonpResult) => { + * // get jsonp result. * - * @experimental + * // user will expect AsyncZoneSpec wait for + * // then, but because jsonp is not zone aware + * // AsyncZone will finish before then is called. + * }); + * }); */ - function flushMicrotasks() { - _getFakeAsyncZoneSpec().flushMicrotasks(); - } - Zone[api.symbol('fakeAsyncTest')] = - { resetFakeAsyncZone: resetFakeAsyncZone, flushMicrotasks: flushMicrotasks, discardPeriodicTasks: discardPeriodicTasks, tick: tick, flush: flush, fakeAsync: fakeAsync }; -}); - -/** - * @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 - */ -/** - * Promise for async/fakeAsync zoneSpec test - * can support async operation which not supported by zone.js - * such as - * it ('test jsonp in AsyncZone', async() => { - * new Promise(res => { - * jsonp(url, (data) => { - * // success callback - * res(data); - * }); - * }).then((jsonpResult) => { - * // get jsonp result. - * - * // user will expect AsyncZoneSpec wait for - * // then, but because jsonp is not zone aware - * // AsyncZone will finish before then is called. - * }); - * }); - */ -Zone.__load_patch('promisefortest', function (global, Zone, api) { - var symbolState = api.symbol('state'); - var UNRESOLVED = null; - var symbolParentUnresolved = api.symbol('parentUnresolved'); - // patch Promise.prototype.then to keep an internal - // number for tracking unresolved chained promise - // we will decrease this number when the parent promise - // being resolved/rejected and chained promise was - // scheduled as a microTask. - // so we can know such kind of chained promise still - // not resolved in AsyncTestZone - Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - return; - } - oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; - Promise.prototype.then = function () { - var chained = oriThen.apply(this, arguments); - if (this[symbolState] === UNRESOLVED) { - // parent promise is unresolved. - var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); - if (asyncTestZoneSpec) { - asyncTestZoneSpec.unresolvedChainedPromiseCount++; - chained[symbolParentUnresolved] = true; + Zone.__load_patch('promisefortest', function (global, Zone, api) { + var symbolState = api.symbol('state'); + var UNRESOLVED = null; + var symbolParentUnresolved = api.symbol('parentUnresolved'); + // patch Promise.prototype.then to keep an internal + // number for tracking unresolved chained promise + // we will decrease this number when the parent promise + // being resolved/rejected and chained promise was + // scheduled as a microTask. + // so we can know such kind of chained promise still + // not resolved in AsyncTestZone + Promise[api.symbol('patchPromiseForTest')] = function patchPromiseForTest() { + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + return; + } + oriThen = Promise[Zone.__symbol__('ZonePromiseThen')] = Promise.prototype.then; + Promise.prototype.then = function () { + var chained = oriThen.apply(this, arguments); + if (this[symbolState] === UNRESOLVED) { + // parent promise is unresolved. + var asyncTestZoneSpec = Zone.current.get('AsyncTestZoneSpec'); + if (asyncTestZoneSpec) { + asyncTestZoneSpec.unresolvedChainedPromiseCount++; + chained[symbolParentUnresolved] = true; + } } + return chained; + }; + }; + Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { + // restore origin then + var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; + if (oriThen) { + Promise.prototype.then = oriThen; + Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; } - return chained; }; - }; - Promise[api.symbol('unPatchPromiseForTest')] = function unpatchPromiseForTest() { - // restore origin then - var oriThen = Promise[Zone.__symbol__('ZonePromiseThen')]; - if (oriThen) { - Promise.prototype.then = oriThen; - Promise[Zone.__symbol__('ZonePromiseThen')] = undefined; - } - }; -}); - -/** - * @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 - */ -// load test related files into bundle in correct order - -}))); + }); + /** + * @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 + */ +})); +//# sourceMappingURL=zone-testing-rollup.umd.js.map diff --git a/dist/zone-testing.min.js b/dist/zone-testing.min.js new file mode 100755 index 000000000..b6d625ccc --- /dev/null +++ b/dist/zone-testing.min.js @@ -0,0 +1,71 @@ +/** +* @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(e){"function"==typeof define&&define.amd?define(e):e()}(function(){"use strict"; +/** + * @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 e="\n",t={},n="STACKTRACE TRACKING",r="__SEP_TAG__",s=r+"@[native]",o=function o(){this.error=l(),this.timestamp=new Date};function i(){return new Error(n)}function a(){try{throw i()}catch(e){return e}}var c=i(),u=a(),l=c.stack?i:u.stack?a:i;function h(t){return t.stack?t.stack.split(e):[]}function p(e,n){for(var r=h(n),s=0;s0){var s=Zone.currentTask,i=s&&s.data&&s.data.__creationTrace__||[];(i=[new o].concat(i)).length>this.longStackTraceLimit&&(i.length=this.longStackTraceLimit),r.data||(r.data={}),"eventTask"===r.type&&(r.data=Object.assign({},r.data)),r.data.__creationTrace__=i}return e.scheduleTask(n,r)},onHandleError:function(e,t,n,r){if(Error.stackTraceLimit>0){var s=Zone.currentTask||r.task;if(r instanceof Error&&s){var o=d(s.data&&s.data.__creationTrace__,r.stack);try{r.stack=r.longStack=o}catch(e){}}}return e.handleError(n,r)}},function f(){if(!(Error.stackTraceLimit<=0)){var e=[];!function e(t,n){n>0&&(t.push(h((new o).error)),e(t,n-1))}(e,2);for(var i=e[0],a=e[1],c=0;c0?arguments[0]:new Date;return e.setCurrentRealTime.apply(e,t&&"function"==typeof t.getTime?[t.getTime()]:arguments)}return n.apply(this,arguments)},a&&["install","uninstall"].forEach(function(t){var n=e[o(t)]=e[t];e[t]=function(){if(!Zone.FakeAsyncTestZoneSpec)return n.apply(this,arguments);jasmine[o("clockInstalled")]="install"===t}})}return e}}function h(e,t,n,r){var s=!!jasmine[o("clockInstalled")],i=n.testProxyZone;if(s&&a){var c=Zone[Zone.__symbol__("fakeAsyncTest")];c&&"function"==typeof c.fakeAsync&&(e=c.fakeAsync(e))}return r?i.run(e,t,[r]):i.run(e,t)}function p(e){return e&&(e.length?function(t){return h(e,this,this.queueRunner,t)}:function(){return h(e,this,this.queueRunner)})}var d=jasmine.QueueRunner;jasmine.QueueRunner=function(t){function s(n){var s,o=this;n.onComplete=(s=n.onComplete,function(){o.testProxyZone=null,o.testProxyZoneSpec=null,r.scheduleMicroTask("jasmine.onComplete",s)});var i=e[Zone.__symbol__("setTimeout")],a=e[Zone.__symbol__("clearTimeout")];i&&(n.timeout={setTimeout:i||e.setTimeout,clearTimeout:a||e.clearTimeout}),jasmine.UserContext?(n.userContext||(n.userContext=new jasmine.UserContext),n.userContext.queueRunner=this):(n.userContext||(n.userContext={}),n.userContext.queueRunner=this);var c=n.onException;n.onException=function(e){if(e&&"Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."===e.message){var t=this&&this.testProxyZoneSpec;if(t){var n=t.getAndClearPendingTasksInfo();try{e.message+=n}catch(e){}}}c&&c.call(this,e)},t.call(this,n)}return function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);function r(){this.constructor=e}e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(s,t),s.prototype.execute=function(){for(var e=this,s=Zone.current,o=!1;s;){if(s===r){o=!0;break}s=s.parent}if(!o)throw new Error("Unexpected Zone: "+Zone.current.name);this.testProxyZoneSpec=new n,this.testProxyZone=r.fork(this.testProxyZoneSpec),Zone.currentTask?t.prototype.execute.call(this):Zone.current.scheduleMicroTask("jasmine.execute().forceTask",function(){return d.prototype.execute.call(e)})},s}(d)}(y), +/** + * @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 + */ +_=y,(k=function(){function e(e,t,n){this.finishCallback=e,this.failCallback=t,this._pendingMicroTasks=!1,this._pendingMacroTasks=!1,this._alreadyErrored=!1,this._isSync=!1,this.runZone=Zone.current,this.unresolvedChainedPromiseCount=0,this.supportWaitUnresolvedChainedPromise=!1,this.name="asyncTestZone for "+n,this.properties={AsyncTestZoneSpec:this},this.supportWaitUnresolvedChainedPromise=!0===_[Zone.__symbol__("supportWaitUnResolvedChainedPromise")]}return e.prototype.isUnresolvedChainedPromisePending=function(){return this.unresolvedChainedPromiseCount>0},e.prototype._finishCallbackIfDone=function(){var e=this;this._pendingMicroTasks||this._pendingMacroTasks||this.supportWaitUnresolvedChainedPromise&&this.isUnresolvedChainedPromisePending()||this.runZone.run(function(){setTimeout(function(){e._alreadyErrored||e._pendingMicroTasks||e._pendingMacroTasks||e.finishCallback()},0)})},e.prototype.patchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("patchPromiseForTest")];e&&e()}},e.prototype.unPatchPromiseForTest=function(){if(this.supportWaitUnresolvedChainedPromise){var e=Promise[Zone.__symbol__("unPatchPromiseForTest")];e&&e()}},e.prototype.onScheduleTask=function(t,n,r,s){return"eventTask"!==s.type&&(this._isSync=!1),"microTask"===s.type&&s.data&&s.data instanceof Promise&&!0===s.data[e.symbolParentUnresolved]&&this.unresolvedChainedPromiseCount--,t.scheduleTask(r,s)},e.prototype.onInvokeTask=function(e,t,n,r,s,o){return"eventTask"!==r.type&&(this._isSync=!1),e.invokeTask(n,r,s,o)},e.prototype.onCancelTask=function(e,t,n,r){return"eventTask"!==r.type&&(this._isSync=!1),e.cancelTask(n,r)},e.prototype.onInvoke=function(e,t,n,r,s,o,i){try{return this._isSync=!0,e.invoke(n,r,s,o,i)}finally{this._isSync&&this._finishCallbackIfDone()}},e.prototype.onHandleError=function(e,t,n,r){return e.handleError(n,r)&&(this.failCallback(r),this._alreadyErrored=!0),!1},e.prototype.onHasTask=function(e,t,n,r){e.hasTask(n,r),"microTask"==r.change?(this._pendingMicroTasks=r.microTask,this._finishCallbackIfDone()):"macroTask"==r.change&&(this._pendingMacroTasks=r.macroTask,this._finishCallbackIfDone())},e}()).symbolParentUnresolved=Zone.__symbol__("parentUnresolved"),Zone.AsyncTestZoneSpec=k, +/** + * @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.__load_patch("asynctest",function(e,t,n){function r(e,n,r,s){var o=t.current,i=t.AsyncTestZoneSpec;if(void 0===i)throw new Error("AsyncTestZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/async-test.js");var a=t.ProxyZoneSpec;if(void 0===a)throw new Error("ProxyZoneSpec is needed for the async() test helper but could not be found. Please make sure that your environment includes zone.js/dist/proxy.js");var c=a.get();a.assertPresent();var u=t.current.getZoneWith("ProxyZoneSpec"),l=c.getDelegate();return u.parent.run(function(){var e=new i(function(){c.getDelegate()==e&&c.setDelegate(l),e.unPatchPromiseForTest(),o.run(function(){r()})},function(t){c.getDelegate()==e&&c.setDelegate(l),e.unPatchPromiseForTest(),o.run(function(){s(t)})},"test");c.setDelegate(e),e.patchPromiseForTest()}),t.current.runGuarded(e,n)}t[n.symbol("asyncTest")]=function t(n){return e.jasmine?function(e){e||((e=function(){}).fail=function(e){throw e}),r(n,this,e,function(t){if("string"==typeof t)return e.fail(new Error(t));e.fail(t)})}:function(){var e=this;return new Promise(function(t,s){r(n,e,t,s)})}}}), +/** + * @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(e){var t=e.Date,n=function(){function e(){if(0===arguments.length){var n=new t;return n.setTime(e.now()),n}var r=Array.prototype.slice.call(arguments);return new(t.bind.apply(t,[void 0].concat(r)))}return e.now=function(){var e=Zone.current.get("FakeAsyncTestZoneSpec");return e?e.getCurrentRealTime()+e.getCurrentTime():t.now.apply(this,arguments)},e}();n.UTC=t.UTC,n.parse=t.parse;var r={setTimeout:e.setTimeout,setInterval:e.setInterval,clearTimeout:e.clearTimeout,clearInterval:e.clearInterval},s=function(){function n(){this._schedulerQueue=[],this._currentTime=0,this._currentRealTime=t.now()}return n.prototype.getCurrentTime=function(){return this._currentTime},n.prototype.getCurrentRealTime=function(){return this._currentRealTime},n.prototype.setCurrentRealTime=function(e){this._currentRealTime=e},n.prototype.scheduleFunction=function(e,t,r,s,o,i){void 0===r&&(r=[]),void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===i&&(i=-1);for(var a=i<0?n.nextId++:i,c={endTime:this._currentTime+t,id:a,func:e,args:r,delay:t,isPeriodic:s,isRequestAnimationFrame:o},u=0;u0&&!(r0;){if(++o>t)throw new Error("flush failed after reaching the limit of "+t+" tasks. Does your code use a polling timeout?");if(0===this._schedulerQueue.filter(function(e){return!e.isPeriodic&&!e.isRequestAnimationFrame}).length)break;var i=this._schedulerQueue.shift();if(s=this._currentTime,this._currentTime=i.endTime,n&&n(this._currentTime-s),!i.func.apply(e,i.args))break}return this._currentTime-r},n}();s.nextId=1;var o=function(){function o(t,n,r){void 0===n&&(n=!1),this.trackPendingRequestAnimationFrame=n,this.macroTaskOptions=r,this._scheduler=new s,this._microtasks=[],this._lastError=null,this._uncaughtPromiseErrors=Promise[Zone.__symbol__("uncaughtPromiseErrors")],this.pendingPeriodicTimers=[],this.pendingTimers=[],this.patchDateLocked=!1,this.properties={FakeAsyncTestZoneSpec:this},this.name="fakeAsyncTestZone for "+t,this.macroTaskOptions||(this.macroTaskOptions=e[Zone.__symbol__("FakeAsyncTestMacroTask")])}return o.assertInZone=function(){if(null==Zone.current.get("FakeAsyncTestZoneSpec"))throw new Error("The code should be running in the fakeAsync zone to call this function")},o.prototype._fnAndFlush=function(t,n){var r=this;return function(){for(var s=[],o=0;o-1&&e.splice(n,1)},o.prototype._dequeueTimer=function(e){var t=this;return function(){o._removeTimer(t.pendingTimers,e)}},o.prototype._requeuePeriodicTimer=function(e,t,n,r){var s=this;return function(){-1!==s.pendingPeriodicTimers.indexOf(r)&&s._scheduler.scheduleFunction(e,t,n,!0,!1,r)}},o.prototype._dequeuePeriodicTimer=function(e){var t=this;return function(){o._removeTimer(t.pendingPeriodicTimers,e)}},o.prototype._setTimeout=function(e,t,n,r){void 0===r&&(r=!0);var o=this._dequeueTimer(s.nextId),i=this._fnAndFlush(e,{onSuccess:o,onError:o}),a=this._scheduler.scheduleFunction(i,t,n,!1,!r);return r&&this.pendingTimers.push(a),a},o.prototype._clearTimeout=function(e){o._removeTimer(this.pendingTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},o.prototype._setInterval=function(e,t,n){var r=s.nextId,o={onSuccess:null,onError:this._dequeuePeriodicTimer(r)},i=this._fnAndFlush(e,o);return o.onSuccess=this._requeuePeriodicTimer(i,t,n,r),this._scheduler.scheduleFunction(i,t,n,!0),this.pendingPeriodicTimers.push(r),r},o.prototype._clearInterval=function(e){o._removeTimer(this.pendingPeriodicTimers,e),this._scheduler.removeScheduledFunctionWithId(e)},o.prototype._resetLastErrorAndThrow=function(){var e=this._lastError||this._uncaughtPromiseErrors[0];throw this._uncaughtPromiseErrors.length=0,this._lastError=null,e},o.prototype.getCurrentTime=function(){return this._scheduler.getCurrentTime()},o.prototype.getCurrentRealTime=function(){return this._scheduler.getCurrentRealTime()},o.prototype.setCurrentRealTime=function(e){this._scheduler.setCurrentRealTime(e)},o.patchDate=function(){e[Zone.__symbol__("disableDatePatching")]||e.Date!==n&&(e.Date=n,n.prototype=t.prototype,o.checkTimerPatch())},o.resetDate=function(){e.Date===n&&(e.Date=t)},o.checkTimerPatch=function(){e.setTimeout!==r.setTimeout&&(e.setTimeout=r.setTimeout,e.clearTimeout=r.clearTimeout),e.setInterval!==r.setInterval&&(e.setInterval=r.setInterval,e.clearInterval=r.clearInterval)},o.prototype.lockDatePatch=function(){this.patchDateLocked=!0,o.patchDate()},o.prototype.unlockDatePatch=function(){this.patchDateLocked=!1,o.resetDate()},o.prototype.tick=function(e,t){void 0===e&&(e=0),o.assertInZone(),this.flushMicrotasks(),this._scheduler.tick(e,t),null!==this._lastError&&this._resetLastErrorAndThrow()},o.prototype.flushMicrotasks=function(){for(o.assertInZone();this._microtasks.length>0;){var e=this._microtasks.shift();e.func.apply(e.target,e.args)}(null!==this._lastError||this._uncaughtPromiseErrors.length)&&this._resetLastErrorAndThrow()},o.prototype.flush=function(e,t,n){o.assertInZone(),this.flushMicrotasks();var r=this._scheduler.flush(e,t,n);return null!==this._lastError&&this._resetLastErrorAndThrow(),r},o.prototype.onScheduleTask=function(e,t,n,r){switch(r.type){case"microTask":var s=r.data&&r.data.args,o=void 0;if(s){var i=r.data.cbIdx;"number"==typeof s.length&&s.length>i+1&&(o=Array.prototype.slice.call(s,i+1))}this._microtasks.push({func:r.invoke,args:o,target:r.data&&r.data.target});break;case"macroTask":switch(r.source){case"setTimeout":r.data.handleId=this._setTimeout(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"setImmediate":r.data.handleId=this._setTimeout(r.invoke,0,Array.prototype.slice.call(r.data.args,1));break;case"setInterval":r.data.handleId=this._setInterval(r.invoke,r.data.delay,Array.prototype.slice.call(r.data.args,2));break;case"XMLHttpRequest.send":throw new Error("Cannot make XHRs from within a fake async test. Request URL: "+r.data.url);case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":r.data.handleId=this._setTimeout(r.invoke,16,r.data.args,this.trackPendingRequestAnimationFrame);break;default:var a=this.findMacroTaskOption(r);if(a){var c=r.data&&r.data.args,u=c&&c.length>1?c[1]:0,l=a.callbackArgs?a.callbackArgs:c;a.isPeriodic?(r.data.handleId=this._setInterval(r.invoke,u,l),r.data.isPeriodic=!0):r.data.handleId=this._setTimeout(r.invoke,u,l);break}throw new Error("Unknown macroTask scheduled in fake async test: "+r.source)}break;case"eventTask":r=e.scheduleTask(n,r)}return r},o.prototype.onCancelTask=function(e,t,n,r){switch(r.source){case"setTimeout":case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":return this._clearTimeout(r.data.handleId);case"setInterval":return this._clearInterval(r.data.handleId);default:var s=this.findMacroTaskOption(r);if(s){var o=r.data.handleId;return s.isPeriodic?this._clearInterval(o):this._clearTimeout(o)}return e.cancelTask(n,r)}},o.prototype.onInvoke=function(e,t,n,r,s,i,a){try{return o.patchDate(),e.invoke(n,r,s,i,a)}finally{this.patchDateLocked||o.resetDate()}},o.prototype.findMacroTaskOption=function(e){if(!this.macroTaskOptions)return null;for(var t=0;t0)throw new Error(o.pendingPeriodicTimers.length+" periodic timer(s) still in the queue.");if(o.pendingTimers.length>0)throw new Error(o.pendingTimers.length+" timer(s) still in the queue.");return l}finally{i()}}}}}), +/** + * @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.__load_patch("promisefortest",function(e,t,n){var r=n.symbol("state"),s=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function e(){var n=Promise[t.__symbol__("ZonePromiseThen")];n||(n=Promise[t.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){var e=n.apply(this,arguments);if(null===this[r]){var o=t.current.get("AsyncTestZoneSpec");o&&(o.unresolvedChainedPromiseCount++,e[s]=!0)}return e})},Promise[n.symbol("unPatchPromiseForTest")]=function e(){var n=Promise[t.__symbol__("ZonePromiseThen")];n&&(Promise.prototype.then=n,Promise[t.__symbol__("ZonePromiseThen")]=void 0)}})}); \ No newline at end of file diff --git a/dist/zone.js b/dist/zone.js old mode 100644 new mode 100755 index 75d3e835e..44c9ce012 --- a/dist/zone.js +++ b/dist/zone.js @@ -5,1926 +5,2006 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory() : - typeof define === 'function' && define.amd ? define(factory) : - (factory()); -}(this, (function () { 'use strict'; - -/** - * @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) { - var performance = global['performance']; - function mark(name) { - performance && performance['mark'] && performance['mark'](name); - } - function performanceMeasure(name, label) { - performance && performance['measure'] && performance['measure'](name, label); - } - mark('Zone'); - var checkDuplicate = global[('__zone_symbol__forceDuplicateZoneCheck')] === true; - if (global['Zone']) { - // if global['Zone'] already exists (maybe zone.js was already loaded or - // some other lib also registered a global object named Zone), we may need - // to throw an error, but sometimes user may not want this error. - // For example, - // we have two web pages, page1 includes zone.js, page2 doesn't. - // and the 1st time user load page1 and page2, everything work fine, - // but when user load page2 again, error occurs because global['Zone'] already exists. - // so we add a flag to let user choose whether to throw this error or not. - // By default, if existing Zone is from zone.js, we will not throw the error. - if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { - throw new Error('Zone already loaded.'); - } - else { - return global['Zone']; +(function (factory) { + typeof define === 'function' && define.amd ? define(factory) : + factory(); +}(function () { + 'use strict'; + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + /** + * @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) { + var performance = global['performance']; + function mark(name) { + performance && performance['mark'] && performance['mark'](name); + } + function performanceMeasure(name, label) { + performance && performance['measure'] && performance['measure'](name, label); + } + mark('Zone'); + // Initialize before it's accessed below. + // __Zone_symbol_prefix global can be used to override the default zone + // symbol prefix with a custom one if needed. + var symbolPrefix = global['__Zone_symbol_prefix'] || '__zone_symbol__'; + function __symbol__(name) { + return symbolPrefix + name; + } + var checkDuplicate = global[__symbol__('forceDuplicateZoneCheck')] === true; + if (global['Zone']) { + // if global['Zone'] already exists (maybe zone.js was already loaded or + // some other lib also registered a global object named Zone), we may need + // to throw an error, but sometimes user may not want this error. + // For example, + // we have two web pages, page1 includes zone.js, page2 doesn't. + // and the 1st time user load page1 and page2, everything work fine, + // but when user load page2 again, error occurs because global['Zone'] already exists. + // so we add a flag to let user choose whether to throw this error or not. + // By default, if existing Zone is from zone.js, we will not throw the error. + if (checkDuplicate || typeof global['Zone'].__symbol__ !== 'function') { + throw new Error('Zone already loaded.'); + } + else { + return global['Zone']; + } } - } - var Zone = /** @class */ (function () { - function Zone(parent, zoneSpec) { - this._parent = parent; - this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; - this._properties = zoneSpec && zoneSpec.properties || {}; - this._zoneDelegate = - new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); - } - Zone.assertZonePatched = function () { - if (global['Promise'] !== patches['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.)'); + var Zone = /** @class */ (function () { + function Zone(parent, zoneSpec) { + this._parent = parent; + this._name = zoneSpec ? zoneSpec.name || 'unnamed' : ''; + this._properties = zoneSpec && zoneSpec.properties || {}; + this._zoneDelegate = + new ZoneDelegate(this, this._parent && this._parent._zoneDelegate, zoneSpec); } - }; - Object.defineProperty(Zone, "root", { - get: function () { - var zone = Zone.current; - while (zone.parent) { - zone = zone.parent; + Zone.assertZonePatched = function () { + if (global['Promise'] !== patches['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.)'); } - return zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "current", { - get: function () { - return _currentZoneFrame.zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone, "currentTask", { - get: function () { - return _currentTask; - }, - enumerable: true, - configurable: true - }); - Zone.__load_patch = function (name, fn) { - if (patches.hasOwnProperty(name)) { - if (checkDuplicate) { - throw Error('Already loaded patch: ' + name); + }; + Object.defineProperty(Zone, "root", { + get: function () { + var zone = Zone.current; + while (zone.parent) { + zone = zone.parent; + } + return zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "current", { + get: function () { + return _currentZoneFrame.zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone, "currentTask", { + get: function () { + return _currentTask; + }, + enumerable: true, + configurable: true + }); + Zone.__load_patch = function (name, fn) { + if (patches.hasOwnProperty(name)) { + if (checkDuplicate) { + throw Error('Already loaded patch: ' + name); + } } - } - else if (!global['__Zone_disable_' + name]) { - var perfName = 'Zone:' + name; - mark(perfName); - patches[name] = fn(global, Zone, _api); - performanceMeasure(perfName, perfName); - } - }; - Object.defineProperty(Zone.prototype, "parent", { - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Zone.prototype, "name", { - get: function () { - return this._name; - }, - enumerable: true, - configurable: true - }); - Zone.prototype.get = function (key) { - var zone = this.getZoneWith(key); - if (zone) - return zone._properties[key]; - }; - Zone.prototype.getZoneWith = function (key) { - var current = this; - while (current) { - if (current._properties.hasOwnProperty(key)) { - return current; + else if (!global['__Zone_disable_' + name]) { + var perfName = 'Zone:' + name; + mark(perfName); + patches[name] = fn(global, Zone, _api); + performanceMeasure(perfName, perfName); } - current = current._parent; - } - return null; - }; - Zone.prototype.fork = function (zoneSpec) { - if (!zoneSpec) - throw new Error('ZoneSpec required!'); - return this._zoneDelegate.fork(this, zoneSpec); - }; - Zone.prototype.wrap = function (callback, source) { - if (typeof callback !== 'function') { - throw new Error('Expecting function got: ' + callback); - } - var _callback = this._zoneDelegate.intercept(this, callback, source); - var zone = this; - return function () { - return zone.runGuarded(_callback, this, arguments, source); }; - }; - Zone.prototype.run = function (callback, applyThis, applyArgs, source) { - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { - if (applyThis === void 0) { applyThis = null; } - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { + Object.defineProperty(Zone.prototype, "parent", { + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Zone.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Zone.prototype.get = function (key) { + var zone = this.getZoneWith(key); + if (zone) + return zone._properties[key]; + }; + Zone.prototype.getZoneWith = function (key) { + var current = this; + while (current) { + if (current._properties.hasOwnProperty(key)) { + return current; + } + current = current._parent; + } + return null; + }; + Zone.prototype.fork = function (zoneSpec) { + if (!zoneSpec) + throw new Error('ZoneSpec required!'); + return this._zoneDelegate.fork(this, zoneSpec); + }; + Zone.prototype.wrap = function (callback, source) { + if (typeof callback !== 'function') { + throw new Error('Expecting function got: ' + callback); + } + var _callback = this._zoneDelegate.intercept(this, callback, source); + var zone = this; + return function () { + return zone.runGuarded(_callback, this, arguments, source); + }; + }; + Zone.prototype.run = function (callback, applyThis, applyArgs, source) { + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; try { return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + finally { + _currentZoneFrame = _currentZoneFrame.parent; + } + }; + Zone.prototype.runGuarded = function (callback, applyThis, applyArgs, source) { + if (applyThis === void 0) { applyThis = null; } + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + try { + return this._zoneDelegate.invoke(this, callback, applyThis, applyArgs, source); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - _currentZoneFrame = _currentZoneFrame.parent; - } - }; - Zone.prototype.runTask = function (task, applyThis, applyArgs) { - if (task.zone != this) { - throw new Error('A task can only be run in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - } - // https://github.com/angular/zone.js/issues/778, sometimes eventTask - // will run in notScheduled(canceled) state, we should not try to - // run such kind of task but just return - if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { - return; - } - var reEntryGuard = task.state != running; - reEntryGuard && task._transitionTo(running, scheduled); - task.runCount++; - var previousTask = _currentTask; - _currentTask = task; - _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; - try { - if (task.type == macroTask && task.data && !task.data.isPeriodic) { - task.cancelFn = undefined; + finally { + _currentZoneFrame = _currentZoneFrame.parent; } - try { - return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + }; + Zone.prototype.runTask = function (task, applyThis, applyArgs) { + if (task.zone != this) { + throw new Error('A task can only be run in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + } + // https://github.com/angular/zone.js/issues/778, sometimes eventTask + // will run in notScheduled(canceled) state, we should not try to + // run such kind of task but just return + if (task.state === notScheduled && (task.type === eventTask || task.type === macroTask)) { + return; } - catch (error) { - if (this._zoneDelegate.handleError(this, error)) { - throw error; + var reEntryGuard = task.state != running; + reEntryGuard && task._transitionTo(running, scheduled); + task.runCount++; + var previousTask = _currentTask; + _currentTask = task; + _currentZoneFrame = { parent: _currentZoneFrame, zone: this }; + try { + if (task.type == macroTask && task.data && !task.data.isPeriodic) { + task.cancelFn = undefined; + } + try { + return this._zoneDelegate.invokeTask(this, task, applyThis, applyArgs); + } + catch (error) { + if (this._zoneDelegate.handleError(this, error)) { + throw error; + } } } - } - finally { - // if the task's state is notScheduled or unknown, then it has already been cancelled - // we should not reset the state to scheduled - if (task.state !== notScheduled && task.state !== unknown) { - if (task.type == eventTask || (task.data && task.data.isPeriodic)) { - reEntryGuard && task._transitionTo(scheduled, running); + finally { + // if the task's state is notScheduled or unknown, then it has already been cancelled + // we should not reset the state to scheduled + if (task.state !== notScheduled && task.state !== unknown) { + if (task.type == eventTask || (task.data && task.data.isPeriodic)) { + reEntryGuard && task._transitionTo(scheduled, running); + } + else { + task.runCount = 0; + this._updateTaskCount(task, -1); + reEntryGuard && + task._transitionTo(notScheduled, running, notScheduled); + } } - else { - task.runCount = 0; - this._updateTaskCount(task, -1); - reEntryGuard && - task._transitionTo(notScheduled, running, notScheduled); + _currentZoneFrame = _currentZoneFrame.parent; + _currentTask = previousTask; + } + }; + Zone.prototype.scheduleTask = function (task) { + if (task.zone && task.zone !== this) { + // check if the task was rescheduled, the newZone + // should not be the children of the original zone + var newZone = this; + while (newZone) { + if (newZone === task.zone) { + throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); + } + newZone = newZone.parent; } } - _currentZoneFrame = _currentZoneFrame.parent; - _currentTask = previousTask; - } - }; - Zone.prototype.scheduleTask = function (task) { - if (task.zone && task.zone !== this) { - // check if the task was rescheduled, the newZone - // should not be the children of the original zone - var newZone = this; - while (newZone) { - if (newZone === task.zone) { - throw Error("can not reschedule task to " + this.name + " which is descendants of the original zone " + task.zone.name); - } - newZone = newZone.parent; - } - } - task._transitionTo(scheduling, notScheduled); - var zoneDelegates = []; - task._zoneDelegates = zoneDelegates; - task._zone = this; - try { - task = this._zoneDelegate.scheduleTask(this, task); - } - catch (err) { - // should set task's state to unknown when scheduleTask throw error - // because the err may from reschedule, so the fromState maybe notScheduled - task._transitionTo(unknown, scheduling, notScheduled); - // TODO: @JiaLiPassion, should we check the result from handleError? - this._zoneDelegate.handleError(this, err); - throw err; - } - if (task._zoneDelegates === zoneDelegates) { - // we have to check because internally the delegate can reschedule the task. - this._updateTaskCount(task, 1); - } - if (task.state == scheduling) { - task._transitionTo(scheduled, scheduling); - } - return task; - }; - Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { - return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); - }; - Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { - return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); - }; - Zone.prototype.cancelTask = function (task) { - if (task.zone != this) - throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + - (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); - task._transitionTo(canceling, scheduled, running); - try { - this._zoneDelegate.cancelTask(this, task); - } - catch (err) { - // if error occurs when cancelTask, transit the state to unknown - task._transitionTo(unknown, canceling); - this._zoneDelegate.handleError(this, err); - throw err; - } - this._updateTaskCount(task, -1); - task._transitionTo(notScheduled, canceling); - task.runCount = 0; - return task; - }; - Zone.prototype._updateTaskCount = function (task, count) { - var zoneDelegates = task._zoneDelegates; - if (count == -1) { - task._zoneDelegates = null; - } - for (var i = 0; i < zoneDelegates.length; i++) { - zoneDelegates[i]._updateTaskCount(task.type, count); - } - }; + task._transitionTo(scheduling, notScheduled); + var zoneDelegates = []; + task._zoneDelegates = zoneDelegates; + task._zone = this; + try { + task = this._zoneDelegate.scheduleTask(this, task); + } + catch (err) { + // should set task's state to unknown when scheduleTask throw error + // because the err may from reschedule, so the fromState maybe notScheduled + task._transitionTo(unknown, scheduling, notScheduled); + // TODO: @JiaLiPassion, should we check the result from handleError? + this._zoneDelegate.handleError(this, err); + throw err; + } + if (task._zoneDelegates === zoneDelegates) { + // we have to check because internally the delegate can reschedule the task. + this._updateTaskCount(task, 1); + } + if (task.state == scheduling) { + task._transitionTo(scheduled, scheduling); + } + return task; + }; + Zone.prototype.scheduleMicroTask = function (source, callback, data, customSchedule) { + return this.scheduleTask(new ZoneTask(microTask, source, callback, data, customSchedule, undefined)); + }; + Zone.prototype.scheduleMacroTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(macroTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.scheduleEventTask = function (source, callback, data, customSchedule, customCancel) { + return this.scheduleTask(new ZoneTask(eventTask, source, callback, data, customSchedule, customCancel)); + }; + Zone.prototype.cancelTask = function (task) { + if (task.zone != this) + throw new Error('A task can only be cancelled in the zone of creation! (Creation: ' + + (task.zone || NO_ZONE).name + '; Execution: ' + this.name + ')'); + task._transitionTo(canceling, scheduled, running); + try { + this._zoneDelegate.cancelTask(this, task); + } + catch (err) { + // if error occurs when cancelTask, transit the state to unknown + task._transitionTo(unknown, canceling); + this._zoneDelegate.handleError(this, err); + throw err; + } + this._updateTaskCount(task, -1); + task._transitionTo(notScheduled, canceling); + task.runCount = 0; + return task; + }; + Zone.prototype._updateTaskCount = function (task, count) { + var zoneDelegates = task._zoneDelegates; + if (count == -1) { + task._zoneDelegates = null; + } + for (var i = 0; i < zoneDelegates.length; i++) { + zoneDelegates[i]._updateTaskCount(task.type, count); + } + }; + return Zone; + }()); Zone.__symbol__ = __symbol__; - return Zone; - }()); - var DELEGATE_ZS = { - name: '', - onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, - onScheduleTask: function (delegate, _, target, task) { - return delegate.scheduleTask(target, task); - }, - onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { - return delegate.invokeTask(target, task, applyThis, applyArgs); - }, - onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } - }; - var ZoneDelegate = /** @class */ (function () { - function ZoneDelegate(zone, parentDelegate, zoneSpec) { - this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; - this.zone = zone; - this._parentDelegate = parentDelegate; - this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); - this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); - this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); - this._interceptZS = - zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); - this._interceptDlgt = - zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); - this._interceptCurrZone = - zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); - this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); - this._invokeDlgt = - zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); - this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); - this._handleErrorZS = - zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); - this._handleErrorDlgt = - zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); - this._handleErrorCurrZone = - zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); - this._scheduleTaskZS = - zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); - this._scheduleTaskDlgt = zoneSpec && - (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); - this._scheduleTaskCurrZone = - zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); - this._invokeTaskZS = - zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); - this._invokeTaskDlgt = - zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); - this._invokeTaskCurrZone = - zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); - this._cancelTaskZS = - zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); - this._cancelTaskDlgt = - zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); - this._cancelTaskCurrZone = - zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); - this._hasTaskZS = null; - this._hasTaskDlgt = null; - this._hasTaskDlgtOwner = null; - this._hasTaskCurrZone = null; - var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; - var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; - if (zoneSpecHasTask || parentHasTask) { - // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such - // a case all task related interceptors must go through this ZD. We can't short circuit it. - this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; - this._hasTaskDlgt = parentDelegate; - this._hasTaskDlgtOwner = this; - this._hasTaskCurrZone = zone; - if (!zoneSpec.onScheduleTask) { - this._scheduleTaskZS = DELEGATE_ZS; - this._scheduleTaskDlgt = parentDelegate; - this._scheduleTaskCurrZone = this.zone; - } - if (!zoneSpec.onInvokeTask) { - this._invokeTaskZS = DELEGATE_ZS; - this._invokeTaskDlgt = parentDelegate; - this._invokeTaskCurrZone = this.zone; - } - if (!zoneSpec.onCancelTask) { - this._cancelTaskZS = DELEGATE_ZS; - this._cancelTaskDlgt = parentDelegate; - this._cancelTaskCurrZone = this.zone; - } - } - } - ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { - return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : - new Zone(targetZone, zoneSpec); - }; - ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { - return this._interceptZS ? - this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : - callback; + var DELEGATE_ZS = { + name: '', + onHasTask: function (delegate, _, target, hasTaskState) { return delegate.hasTask(target, hasTaskState); }, + onScheduleTask: function (delegate, _, target, task) { return delegate.scheduleTask(target, task); }, + onInvokeTask: function (delegate, _, target, task, applyThis, applyArgs) { return delegate.invokeTask(target, task, applyThis, applyArgs); }, + onCancelTask: function (delegate, _, target, task) { return delegate.cancelTask(target, task); } }; - ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { - return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : - callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.handleError = function (targetZone, error) { - return this._handleErrorZS ? - this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : - true; - }; - ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { - var returnTask = task; - if (this._scheduleTaskZS) { - if (this._hasTaskZS) { - returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + var ZoneDelegate = /** @class */ (function () { + function ZoneDelegate(zone, parentDelegate, zoneSpec) { + this._taskCounts = { 'microTask': 0, 'macroTask': 0, 'eventTask': 0 }; + this.zone = zone; + this._parentDelegate = parentDelegate; + this._forkZS = zoneSpec && (zoneSpec && zoneSpec.onFork ? zoneSpec : parentDelegate._forkZS); + this._forkDlgt = zoneSpec && (zoneSpec.onFork ? parentDelegate : parentDelegate._forkDlgt); + this._forkCurrZone = zoneSpec && (zoneSpec.onFork ? this.zone : parentDelegate.zone); + this._interceptZS = + zoneSpec && (zoneSpec.onIntercept ? zoneSpec : parentDelegate._interceptZS); + this._interceptDlgt = + zoneSpec && (zoneSpec.onIntercept ? parentDelegate : parentDelegate._interceptDlgt); + this._interceptCurrZone = + zoneSpec && (zoneSpec.onIntercept ? this.zone : parentDelegate.zone); + this._invokeZS = zoneSpec && (zoneSpec.onInvoke ? zoneSpec : parentDelegate._invokeZS); + this._invokeDlgt = + zoneSpec && (zoneSpec.onInvoke ? parentDelegate : parentDelegate._invokeDlgt); + this._invokeCurrZone = zoneSpec && (zoneSpec.onInvoke ? this.zone : parentDelegate.zone); + this._handleErrorZS = + zoneSpec && (zoneSpec.onHandleError ? zoneSpec : parentDelegate._handleErrorZS); + this._handleErrorDlgt = + zoneSpec && (zoneSpec.onHandleError ? parentDelegate : parentDelegate._handleErrorDlgt); + this._handleErrorCurrZone = + zoneSpec && (zoneSpec.onHandleError ? this.zone : parentDelegate.zone); + this._scheduleTaskZS = + zoneSpec && (zoneSpec.onScheduleTask ? zoneSpec : parentDelegate._scheduleTaskZS); + this._scheduleTaskDlgt = zoneSpec && + (zoneSpec.onScheduleTask ? parentDelegate : parentDelegate._scheduleTaskDlgt); + this._scheduleTaskCurrZone = + zoneSpec && (zoneSpec.onScheduleTask ? this.zone : parentDelegate.zone); + this._invokeTaskZS = + zoneSpec && (zoneSpec.onInvokeTask ? zoneSpec : parentDelegate._invokeTaskZS); + this._invokeTaskDlgt = + zoneSpec && (zoneSpec.onInvokeTask ? parentDelegate : parentDelegate._invokeTaskDlgt); + this._invokeTaskCurrZone = + zoneSpec && (zoneSpec.onInvokeTask ? this.zone : parentDelegate.zone); + this._cancelTaskZS = + zoneSpec && (zoneSpec.onCancelTask ? zoneSpec : parentDelegate._cancelTaskZS); + this._cancelTaskDlgt = + zoneSpec && (zoneSpec.onCancelTask ? parentDelegate : parentDelegate._cancelTaskDlgt); + this._cancelTaskCurrZone = + zoneSpec && (zoneSpec.onCancelTask ? this.zone : parentDelegate.zone); + this._hasTaskZS = null; + this._hasTaskDlgt = null; + this._hasTaskDlgtOwner = null; + this._hasTaskCurrZone = null; + var zoneSpecHasTask = zoneSpec && zoneSpec.onHasTask; + var parentHasTask = parentDelegate && parentDelegate._hasTaskZS; + if (zoneSpecHasTask || parentHasTask) { + // If we need to report hasTask, than this ZS needs to do ref counting on tasks. In such + // a case all task related interceptors must go through this ZD. We can't short circuit it. + this._hasTaskZS = zoneSpecHasTask ? zoneSpec : DELEGATE_ZS; + this._hasTaskDlgt = parentDelegate; + this._hasTaskDlgtOwner = this; + this._hasTaskCurrZone = zone; + if (!zoneSpec.onScheduleTask) { + this._scheduleTaskZS = DELEGATE_ZS; + this._scheduleTaskDlgt = parentDelegate; + this._scheduleTaskCurrZone = this.zone; + } + if (!zoneSpec.onInvokeTask) { + this._invokeTaskZS = DELEGATE_ZS; + this._invokeTaskDlgt = parentDelegate; + this._invokeTaskCurrZone = this.zone; + } + if (!zoneSpec.onCancelTask) { + this._cancelTaskZS = DELEGATE_ZS; + this._cancelTaskDlgt = parentDelegate; + this._cancelTaskCurrZone = this.zone; + } } - returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); - if (!returnTask) - returnTask = task; } - else { - if (task.scheduleFn) { - task.scheduleFn(task); + ZoneDelegate.prototype.fork = function (targetZone, zoneSpec) { + return this._forkZS ? this._forkZS.onFork(this._forkDlgt, this.zone, targetZone, zoneSpec) : + new Zone(targetZone, zoneSpec); + }; + ZoneDelegate.prototype.intercept = function (targetZone, callback, source) { + return this._interceptZS ? + this._interceptZS.onIntercept(this._interceptDlgt, this._interceptCurrZone, targetZone, callback, source) : + callback; + }; + ZoneDelegate.prototype.invoke = function (targetZone, callback, applyThis, applyArgs, source) { + return this._invokeZS ? this._invokeZS.onInvoke(this._invokeDlgt, this._invokeCurrZone, targetZone, callback, applyThis, applyArgs, source) : + callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.handleError = function (targetZone, error) { + return this._handleErrorZS ? + this._handleErrorZS.onHandleError(this._handleErrorDlgt, this._handleErrorCurrZone, targetZone, error) : + true; + }; + ZoneDelegate.prototype.scheduleTask = function (targetZone, task) { + var returnTask = task; + if (this._scheduleTaskZS) { + if (this._hasTaskZS) { + returnTask._zoneDelegates.push(this._hasTaskDlgtOwner); + } + returnTask = this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt, this._scheduleTaskCurrZone, targetZone, task); + if (!returnTask) + returnTask = task; + } + else { + if (task.scheduleFn) { + task.scheduleFn(task); + } + else if (task.type == microTask) { + scheduleMicroTask(task); + } + else { + throw new Error('Task is missing scheduleFn.'); + } } - else if (task.type == microTask) { - scheduleMicroTask(task); + return returnTask; + }; + ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { + return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : + task.callback.apply(applyThis, applyArgs); + }; + ZoneDelegate.prototype.cancelTask = function (targetZone, task) { + var value; + if (this._cancelTaskZS) { + value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); } else { - throw new Error('Task is missing scheduleFn.'); + if (!task.cancelFn) { + throw Error('Task is not cancelable'); + } + value = task.cancelFn(task); } - } - return returnTask; - }; - ZoneDelegate.prototype.invokeTask = function (targetZone, task, applyThis, applyArgs) { - return this._invokeTaskZS ? this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt, this._invokeTaskCurrZone, targetZone, task, applyThis, applyArgs) : - task.callback.apply(applyThis, applyArgs); - }; - ZoneDelegate.prototype.cancelTask = function (targetZone, task) { - var value; - if (this._cancelTaskZS) { - value = this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt, this._cancelTaskCurrZone, targetZone, task); - } - else { - if (!task.cancelFn) { - throw Error('Task is not cancelable'); + return value; + }; + ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { + // hasTask should not throw error so other ZoneDelegate + // can still trigger hasTask callback + try { + this._hasTaskZS && + this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); + } + catch (err) { + this.handleError(targetZone, err); + } + }; + ZoneDelegate.prototype._updateTaskCount = function (type, count) { + var counts = this._taskCounts; + var prev = counts[type]; + var next = counts[type] = prev + count; + if (next < 0) { + throw new Error('More tasks executed then were scheduled.'); + } + if (prev == 0 || next == 0) { + var isEmpty = { + microTask: counts['microTask'] > 0, + macroTask: counts['macroTask'] > 0, + eventTask: counts['eventTask'] > 0, + change: type + }; + this.hasTask(this.zone, isEmpty); + } + }; + return ZoneDelegate; + }()); + var ZoneTask = /** @class */ (function () { + function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { + this._zone = null; + this.runCount = 0; + this._zoneDelegates = null; + this._state = 'notScheduled'; + this.type = type; + this.source = source; + this.data = options; + this.scheduleFn = scheduleFn; + this.cancelFn = cancelFn; + this.callback = callback; + var self = this; + // TODO: @JiaLiPassion options should have interface + if (type === eventTask && options && options.useG) { + this.invoke = ZoneTask.invokeTask; + } + else { + this.invoke = function () { + return ZoneTask.invokeTask.call(global, self, this, arguments); + }; } - value = task.cancelFn(task); - } - return value; - }; - ZoneDelegate.prototype.hasTask = function (targetZone, isEmpty) { - // hasTask should not throw error so other ZoneDelegate - // can still trigger hasTask callback - try { - this._hasTaskZS && - this._hasTaskZS.onHasTask(this._hasTaskDlgt, this._hasTaskCurrZone, targetZone, isEmpty); - } - catch (err) { - this.handleError(targetZone, err); - } - }; - ZoneDelegate.prototype._updateTaskCount = function (type, count) { - var counts = this._taskCounts; - var prev = counts[type]; - var next = counts[type] = prev + count; - if (next < 0) { - throw new Error('More tasks executed then were scheduled.'); - } - if (prev == 0 || next == 0) { - var isEmpty = { - microTask: counts['microTask'] > 0, - macroTask: counts['macroTask'] > 0, - eventTask: counts['eventTask'] > 0, - change: type - }; - this.hasTask(this.zone, isEmpty); - } - }; - return ZoneDelegate; - }()); - var ZoneTask = /** @class */ (function () { - function ZoneTask(type, source, callback, options, scheduleFn, cancelFn) { - this._zone = null; - this.runCount = 0; - this._zoneDelegates = null; - this._state = 'notScheduled'; - this.type = type; - this.source = source; - this.data = options; - this.scheduleFn = scheduleFn; - this.cancelFn = cancelFn; - this.callback = callback; - var self = this; - // TODO: @JiaLiPassion options should have interface - if (type === eventTask && options && options.useG) { - this.invoke = ZoneTask.invokeTask; } - else { - this.invoke = function () { - return ZoneTask.invokeTask.call(global, self, this, arguments); + ZoneTask.invokeTask = function (task, target, args) { + if (!task) { + task = this; + } + _numberOfNestedTaskFrames++; + try { + task.runCount++; + return task.zone.runTask(task, target, args); + } + finally { + if (_numberOfNestedTaskFrames == 1) { + drainMicroTaskQueue(); + } + _numberOfNestedTaskFrames--; + } + }; + Object.defineProperty(ZoneTask.prototype, "zone", { + get: function () { + return this._zone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ZoneTask.prototype, "state", { + get: function () { + return this._state; + }, + enumerable: true, + configurable: true + }); + ZoneTask.prototype.cancelScheduleRequest = function () { + this._transitionTo(notScheduled, scheduling); + }; + ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { + if (this._state === fromState1 || this._state === fromState2) { + this._state = toState; + if (toState == notScheduled) { + this._zoneDelegates = null; + } + } + else { + throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); + } + }; + ZoneTask.prototype.toString = function () { + if (this.data && typeof this.data.handleId !== 'undefined') { + return this.data.handleId.toString(); + } + else { + return Object.prototype.toString.call(this); + } + }; + // add toJSON method to prevent cyclic error when + // call JSON.stringify(zoneTask) + ZoneTask.prototype.toJSON = function () { + return { + type: this.type, + state: this.state, + source: this.source, + zone: this.zone.name, + runCount: this.runCount }; + }; + return ZoneTask; + }()); + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// MICROTASK QUEUE + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var symbolSetTimeout = __symbol__('setTimeout'); + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var _microTaskQueue = []; + var _isDrainingMicrotaskQueue = false; + var nativeMicroTaskQueuePromise; + function scheduleMicroTask(task) { + // if we are not running in any task, and there has not been anything scheduled + // we must bootstrap the initial task creation by manually scheduling the drain + if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { + // We are not running in Task, so we need to kickstart the microtask queue. + if (!nativeMicroTaskQueuePromise) { + if (global[symbolPromise]) { + nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); + } + } + if (nativeMicroTaskQueuePromise) { + var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; + if (!nativeThen) { + // native Promise is not patchable, we need to use `then` directly + // issue 1078 + nativeThen = nativeMicroTaskQueuePromise['then']; + } + nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); + } + else { + global[symbolSetTimeout](drainMicroTaskQueue, 0); + } } + task && _microTaskQueue.push(task); } - ZoneTask.invokeTask = function (task, target, args) { - if (!task) { - task = this; - } - _numberOfNestedTaskFrames++; - try { - task.runCount++; - return task.zone.runTask(task, target, args); - } - finally { - if (_numberOfNestedTaskFrames == 1) { - drainMicroTaskQueue(); + function drainMicroTaskQueue() { + if (!_isDrainingMicrotaskQueue) { + _isDrainingMicrotaskQueue = true; + while (_microTaskQueue.length) { + var queue = _microTaskQueue; + _microTaskQueue = []; + for (var i = 0; i < queue.length; i++) { + var task = queue[i]; + try { + task.zone.runTask(task, null, null); + } + catch (error) { + _api.onUnhandledError(error); + } + } + } + _api.microtaskDrainDone(); + _isDrainingMicrotaskQueue = false; + } + } + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + /// BOOTSTRAP + ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// + var NO_ZONE = { name: 'NO ZONE' }; + var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; + var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; + var patches = {}; + var _api = { + symbol: __symbol__, + currentZoneFrame: function () { return _currentZoneFrame; }, + onUnhandledError: noop, + microtaskDrainDone: noop, + scheduleMicroTask: scheduleMicroTask, + showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, + patchEventTarget: function () { return []; }, + patchOnProperties: noop, + patchMethod: function () { return noop; }, + bindArguments: function () { return []; }, + patchThen: function () { return noop; }, + patchMacroTask: function () { return noop; }, + setNativePromise: function (NativePromise) { + // sometimes NativePromise.resolve static function + // is not ready yet, (such as core-js/es6.promise) + // so we need to check here. + if (NativePromise && typeof NativePromise.resolve === 'function') { + nativeMicroTaskQueuePromise = NativePromise.resolve(0); } - _numberOfNestedTaskFrames--; - } - }; - Object.defineProperty(ZoneTask.prototype, "zone", { - get: function () { - return this._zone; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ZoneTask.prototype, "state", { - get: function () { - return this._state; }, - enumerable: true, - configurable: true - }); - ZoneTask.prototype.cancelScheduleRequest = function () { - this._transitionTo(notScheduled, scheduling); + patchEventPrototype: function () { return noop; }, + isIEOrEdge: function () { return false; }, + getGlobalObjects: function () { return undefined; }, + ObjectDefineProperty: function () { return noop; }, + ObjectGetOwnPropertyDescriptor: function () { return undefined; }, + ObjectCreate: function () { return undefined; }, + ArraySlice: function () { return []; }, + patchClass: function () { return noop; }, + wrapWithCurrentZone: function () { return noop; }, + filterProperties: function () { return []; }, + attachOriginToPatched: function () { return noop; }, + _redefineProperty: function () { return noop; }, + patchCallbacks: function () { return noop; } }; - ZoneTask.prototype._transitionTo = function (toState, fromState1, fromState2) { - if (this._state === fromState1 || this._state === fromState2) { - this._state = toState; - if (toState == notScheduled) { - this._zoneDelegates = null; + var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; + var _currentTask = null; + var _numberOfNestedTaskFrames = 0; + function noop() { } + performanceMeasure('Zone', 'Zone'); + return global['Zone'] = Zone; + })(commonjsGlobal); + /** + * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + var ObjectDefineProperty = Object.defineProperty; + function readableObjectToString(obj) { + if (obj && obj.toString === Object.prototype.toString) { + var className = obj.constructor && obj.constructor.name; + return (className ? className : '') + ': ' + JSON.stringify(obj); + } + return obj ? obj.toString() : Object.prototype.toString.call(obj); + } + var __symbol__ = api.symbol; + var _uncaughtPromiseErrors = []; + var symbolPromise = __symbol__('Promise'); + var symbolThen = __symbol__('then'); + var creationTrace = '__creationTrace__'; + api.onUnhandledError = function (e) { + if (api.showUncaughtError()) { + var rejection = e && e.rejection; + if (rejection) { + console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + } + else { + console.error(e); } - } - else { - throw new Error(this.type + " '" + this.source + "': can not transition to '" + toState + "', expecting state '" + fromState1 + "'" + (fromState2 ? ' or \'' + fromState2 + '\'' : '') + ", was '" + this._state + "'."); - } - }; - ZoneTask.prototype.toString = function () { - if (this.data && typeof this.data.handleId !== 'undefined') { - return this.data.handleId.toString(); - } - else { - return Object.prototype.toString.call(this); } }; - // add toJSON method to prevent cyclic error when - // call JSON.stringify(zoneTask) - ZoneTask.prototype.toJSON = function () { - return { - type: this.type, - state: this.state, - source: this.source, - zone: this.zone.name, - runCount: this.runCount - }; - }; - return ZoneTask; - }()); - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// MICROTASK QUEUE - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var symbolSetTimeout = __symbol__('setTimeout'); - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var _microTaskQueue = []; - var _isDrainingMicrotaskQueue = false; - var nativeMicroTaskQueuePromise; - function scheduleMicroTask(task) { - // if we are not running in any task, and there has not been anything scheduled - // we must bootstrap the initial task creation by manually scheduling the drain - if (_numberOfNestedTaskFrames === 0 && _microTaskQueue.length === 0) { - // We are not running in Task, so we need to kickstart the microtask queue. - if (!nativeMicroTaskQueuePromise) { - if (global[symbolPromise]) { - nativeMicroTaskQueuePromise = global[symbolPromise].resolve(0); - } - } - if (nativeMicroTaskQueuePromise) { - var nativeThen = nativeMicroTaskQueuePromise[symbolThen]; - if (!nativeThen) { - // native Promise is not patchable, we need to use `then` directly - // issue 1078 - nativeThen = nativeMicroTaskQueuePromise['then']; - } - nativeThen.call(nativeMicroTaskQueuePromise, drainMicroTaskQueue); - } - else { - global[symbolSetTimeout](drainMicroTaskQueue, 0); - } - } - task && _microTaskQueue.push(task); - } - function drainMicroTaskQueue() { - if (!_isDrainingMicrotaskQueue) { - _isDrainingMicrotaskQueue = true; - while (_microTaskQueue.length) { - var queue = _microTaskQueue; - _microTaskQueue = []; - for (var i = 0; i < queue.length; i++) { - var task = queue[i]; + api.microtaskDrainDone = function () { + while (_uncaughtPromiseErrors.length) { + var _loop_1 = function () { + var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); try { - task.zone.runTask(task, null, null); + uncaughtPromiseError.zone.runGuarded(function () { + throw uncaughtPromiseError; + }); } catch (error) { - _api.onUnhandledError(error); + handleUnhandledRejection(error); } + }; + while (_uncaughtPromiseErrors.length) { + _loop_1(); } } - _api.microtaskDrainDone(); - _isDrainingMicrotaskQueue = false; - } - } - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - /// BOOTSTRAP - ////////////////////////////////////////////////////// - ////////////////////////////////////////////////////// - var NO_ZONE = { name: 'NO ZONE' }; - var notScheduled = 'notScheduled', scheduling = 'scheduling', scheduled = 'scheduled', running = 'running', canceling = 'canceling', unknown = 'unknown'; - var microTask = 'microTask', macroTask = 'macroTask', eventTask = 'eventTask'; - var patches = {}; - var _api = { - symbol: __symbol__, - currentZoneFrame: function () { return _currentZoneFrame; }, - onUnhandledError: noop, - microtaskDrainDone: noop, - scheduleMicroTask: scheduleMicroTask, - showUncaughtError: function () { return !Zone[__symbol__('ignoreConsoleErrorUncaughtError')]; }, - patchEventTarget: function () { return []; }, - patchOnProperties: noop, - patchMethod: function () { return noop; }, - bindArguments: function () { return []; }, - patchThen: function () { return noop; }, - patchMacroTask: function () { return noop; }, - setNativePromise: function (NativePromise) { - // sometimes NativePromise.resolve static function - // is not ready yet, (such as core-js/es6.promise) - // so we need to check here. - if (NativePromise && typeof NativePromise.resolve === 'function') { - nativeMicroTaskQueuePromise = NativePromise.resolve(0); - } - }, - patchEventPrototype: function () { return noop; }, - isIEOrEdge: function () { return false; }, - getGlobalObjects: function () { return undefined; }, - ObjectDefineProperty: function () { return noop; }, - ObjectGetOwnPropertyDescriptor: function () { return undefined; }, - ObjectCreate: function () { return undefined; }, - ArraySlice: function () { return []; }, - patchClass: function () { return noop; }, - wrapWithCurrentZone: function () { return noop; }, - filterProperties: function () { return []; }, - attachOriginToPatched: function () { return noop; }, - _redefineProperty: function () { return noop; }, - patchCallbacks: function () { return noop; } - }; - var _currentZoneFrame = { parent: null, zone: new Zone(null, null) }; - var _currentTask = null; - var _numberOfNestedTaskFrames = 0; - function noop() { } - function __symbol__(name) { - return '__zone_symbol__' + name; - } - performanceMeasure('Zone', 'Zone'); - return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -var __values = (undefined && undefined.__values) || function (o) { - var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; - if (m) return m.call(o); - return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; -}; -/** - * @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.__load_patch('ZoneAwarePromise', function (global, Zone, api) { - var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - var ObjectDefineProperty = Object.defineProperty; - function readableObjectToString(obj) { - if (obj && obj.toString === Object.prototype.toString) { - var className = obj.constructor && obj.constructor.name; - return (className ? className : '') + ': ' + JSON.stringify(obj); - } - return obj ? obj.toString() : Object.prototype.toString.call(obj); - } - var __symbol__ = api.symbol; - var _uncaughtPromiseErrors = []; - var symbolPromise = __symbol__('Promise'); - var symbolThen = __symbol__('then'); - var creationTrace = '__creationTrace__'; - api.onUnhandledError = function (e) { - if (api.showUncaughtError()) { - var rejection = e && e.rejection; - if (rejection) { - console.error('Unhandled Promise rejection:', rejection instanceof Error ? rejection.message : rejection, '; Zone:', e.zone.name, '; Task:', e.task && e.task.source, '; Value:', rejection, rejection instanceof Error ? rejection.stack : undefined); + }; + var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); + function handleUnhandledRejection(e) { + api.onUnhandledError(e); + try { + var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; + if (handler && typeof handler === 'function') { + handler.call(this, e); + } } - else { - console.error(e); + catch (err) { } } - }; - api.microtaskDrainDone = function () { - while (_uncaughtPromiseErrors.length) { - var _loop_1 = function () { - var uncaughtPromiseError = _uncaughtPromiseErrors.shift(); + function isThenable(value) { + return value && value.then; + } + function forwardResolution(value) { + return value; + } + function forwardRejection(rejection) { + return ZoneAwarePromise.reject(rejection); + } + var symbolState = __symbol__('state'); + var symbolValue = __symbol__('value'); + var symbolFinally = __symbol__('finally'); + var symbolParentPromiseValue = __symbol__('parentPromiseValue'); + var symbolParentPromiseState = __symbol__('parentPromiseState'); + var source = 'Promise.then'; + var UNRESOLVED = null; + var RESOLVED = true; + var REJECTED = false; + var REJECTED_NO_CATCH = 0; + function makeResolver(promise, state) { + return function (v) { try { - uncaughtPromiseError.zone.runGuarded(function () { - throw uncaughtPromiseError; - }); + resolvePromise(promise, state, v); } - catch (error) { - handleUnhandledRejection(error); + catch (err) { + resolvePromise(promise, false, err); } + // Do not return value or you will break the Promise spec. }; - while (_uncaughtPromiseErrors.length) { - _loop_1(); - } - } - }; - var UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL = __symbol__('unhandledPromiseRejectionHandler'); - function handleUnhandledRejection(e) { - api.onUnhandledError(e); - try { - var handler = Zone[UNHANDLED_PROMISE_REJECTION_HANDLER_SYMBOL]; - if (handler && typeof handler === 'function') { - handler.call(this, e); - } - } - catch (err) { } - } - function isThenable(value) { - return value && value.then; - } - function forwardResolution(value) { - return value; - } - function forwardRejection(rejection) { - return ZoneAwarePromise.reject(rejection); - } - var symbolState = __symbol__('state'); - var symbolValue = __symbol__('value'); - var symbolFinally = __symbol__('finally'); - var symbolParentPromiseValue = __symbol__('parentPromiseValue'); - var symbolParentPromiseState = __symbol__('parentPromiseState'); - var source = 'Promise.then'; - var UNRESOLVED = null; - var RESOLVED = true; - var REJECTED = false; - var REJECTED_NO_CATCH = 0; - function makeResolver(promise, state) { - return function (v) { - try { - resolvePromise(promise, state, v); - } - catch (err) { - resolvePromise(promise, false, err); - } - // Do not return value or you will break the Promise spec. - }; - } - var once = function () { - var wasCalled = false; - return function wrapper(wrappedFunction) { - return function () { - if (wasCalled) { - return; - } - wasCalled = true; - wrappedFunction.apply(null, arguments); + var once = function () { + var wasCalled = false; + return function wrapper(wrappedFunction) { + return function () { + if (wasCalled) { + return; + } + wasCalled = true; + wrappedFunction.apply(null, arguments); + }; }; }; - }; - var TYPE_ERROR = 'Promise resolved with itself'; - var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); - // Promise Resolution - function resolvePromise(promise, state, value) { - var onceWrapper = once(); - if (promise === value) { - throw new TypeError(TYPE_ERROR); - } - if (promise[symbolState] === UNRESOLVED) { - // should only get value.then once based on promise spec. - var then = null; - try { - if (typeof value === 'object' || typeof value === 'function') { - then = value && value.then; - } - } - catch (err) { - onceWrapper(function () { - resolvePromise(promise, false, err); - })(); - return promise; - } - // if (value instanceof ZoneAwarePromise) { - if (state !== REJECTED && value instanceof ZoneAwarePromise && - value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && - value[symbolState] !== UNRESOLVED) { - clearRejectedNoCatch(value); - resolvePromise(promise, value[symbolState], value[symbolValue]); - } - else if (state !== REJECTED && typeof then === 'function') { + var TYPE_ERROR = 'Promise resolved with itself'; + var CURRENT_TASK_TRACE_SYMBOL = __symbol__('currentTaskTrace'); + // Promise Resolution + function resolvePromise(promise, state, value) { + var onceWrapper = once(); + if (promise === value) { + throw new TypeError(TYPE_ERROR); + } + if (promise[symbolState] === UNRESOLVED) { + // should only get value.then once based on promise spec. + var then = null; try { - then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); + if (typeof value === 'object' || typeof value === 'function') { + then = value && value.then; + } } catch (err) { onceWrapper(function () { resolvePromise(promise, false, err); })(); + return promise; } - } - else { - promise[symbolState] = state; - var queue = promise[symbolValue]; - promise[symbolValue] = value; - if (promise[symbolFinally] === symbolFinally) { - // the promise is generated by Promise.prototype.finally - if (state === RESOLVED) { - // the state is resolved, should ignore the value - // and use parent promise value - promise[symbolState] = promise[symbolParentPromiseState]; - promise[symbolValue] = promise[symbolParentPromiseValue]; - } - } - // record task information in value when error occurs, so we can - // do some additional work such as render longStackTrace - if (state === REJECTED && value instanceof Error) { - // check if longStackTraceZone is here - var trace = Zone.currentTask && Zone.currentTask.data && - Zone.currentTask.data[creationTrace]; - if (trace) { - // only keep the long stack trace into error when in longStackTraceZone - ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); - } - } - for (var i = 0; i < queue.length;) { - scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); - } - if (queue.length == 0 && state == REJECTED) { - promise[symbolState] = REJECTED_NO_CATCH; + // if (value instanceof ZoneAwarePromise) { + if (state !== REJECTED && value instanceof ZoneAwarePromise && + value.hasOwnProperty(symbolState) && value.hasOwnProperty(symbolValue) && + value[symbolState] !== UNRESOLVED) { + clearRejectedNoCatch(value); + resolvePromise(promise, value[symbolState], value[symbolValue]); + } + else if (state !== REJECTED && typeof then === 'function') { try { - // try to print more readable error log - throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + - (value && value.stack ? '\n' + value.stack : '')); + then.call(value, onceWrapper(makeResolver(promise, state)), onceWrapper(makeResolver(promise, false))); } catch (err) { - var error_1 = err; - error_1.rejection = value; - error_1.promise = promise; - error_1.zone = Zone.current; - error_1.task = Zone.currentTask; - _uncaughtPromiseErrors.push(error_1); - api.scheduleMicroTask(); // to make sure that it is running + onceWrapper(function () { + resolvePromise(promise, false, err); + })(); + } + } + else { + promise[symbolState] = state; + var queue = promise[symbolValue]; + promise[symbolValue] = value; + if (promise[symbolFinally] === symbolFinally) { + // the promise is generated by Promise.prototype.finally + if (state === RESOLVED) { + // the state is resolved, should ignore the value + // and use parent promise value + promise[symbolState] = promise[symbolParentPromiseState]; + promise[symbolValue] = promise[symbolParentPromiseValue]; + } + } + // record task information in value when error occurs, so we can + // do some additional work such as render longStackTrace + if (state === REJECTED && value instanceof Error) { + // check if longStackTraceZone is here + var trace = Zone.currentTask && Zone.currentTask.data && + Zone.currentTask.data[creationTrace]; + if (trace) { + // only keep the long stack trace into error when in longStackTraceZone + ObjectDefineProperty(value, CURRENT_TASK_TRACE_SYMBOL, { configurable: true, enumerable: false, writable: true, value: trace }); + } + } + for (var i = 0; i < queue.length;) { + scheduleResolveOrReject(promise, queue[i++], queue[i++], queue[i++], queue[i++]); + } + if (queue.length == 0 && state == REJECTED) { + promise[symbolState] = REJECTED_NO_CATCH; + try { + // try to print more readable error log + throw new Error('Uncaught (in promise): ' + readableObjectToString(value) + + (value && value.stack ? '\n' + value.stack : '')); + } + catch (err) { + var error = err; + error.rejection = value; + error.promise = promise; + error.zone = Zone.current; + error.task = Zone.currentTask; + _uncaughtPromiseErrors.push(error); + api.scheduleMicroTask(); // to make sure that it is running + } } } } + // Resolving an already resolved promise is a noop. + return promise; } - // Resolving an already resolved promise is a noop. - return promise; - } - var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); - function clearRejectedNoCatch(promise) { - if (promise[symbolState] === REJECTED_NO_CATCH) { - // if the promise is rejected no catch status - // and queue.length > 0, means there is a error handler - // here to handle the rejected promise, we should trigger - // windows.rejectionhandled eventHandler or nodejs rejectionHandled - // eventHandler - try { - var handler = Zone[REJECTION_HANDLED_HANDLER]; - if (handler && typeof handler === 'function') { - handler.call(this, { rejection: promise[symbolValue], promise: promise }); + var REJECTION_HANDLED_HANDLER = __symbol__('rejectionHandledHandler'); + function clearRejectedNoCatch(promise) { + if (promise[symbolState] === REJECTED_NO_CATCH) { + // if the promise is rejected no catch status + // and queue.length > 0, means there is a error handler + // here to handle the rejected promise, we should trigger + // windows.rejectionhandled eventHandler or nodejs rejectionHandled + // eventHandler + try { + var handler = Zone[REJECTION_HANDLED_HANDLER]; + if (handler && typeof handler === 'function') { + handler.call(this, { rejection: promise[symbolValue], promise: promise }); + } } - } - catch (err) { - } - promise[symbolState] = REJECTED; - for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { - if (promise === _uncaughtPromiseErrors[i].promise) { - _uncaughtPromiseErrors.splice(i, 1); + catch (err) { + } + promise[symbolState] = REJECTED; + for (var i = 0; i < _uncaughtPromiseErrors.length; i++) { + if (promise === _uncaughtPromiseErrors[i].promise) { + _uncaughtPromiseErrors.splice(i, 1); + } } } } - } - function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { - clearRejectedNoCatch(promise); - var promiseState = promise[symbolState]; - var delegate = promiseState ? - (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : - (typeof onRejected === 'function') ? onRejected : forwardRejection; - zone.scheduleMicroTask(source, function () { - try { - var parentPromiseValue = promise[symbolValue]; - var isFinallyPromise = chainPromise && symbolFinally === chainPromise[symbolFinally]; - if (isFinallyPromise) { - // if the promise is generated from finally call, keep parent promise's state and value - chainPromise[symbolParentPromiseValue] = parentPromiseValue; - chainPromise[symbolParentPromiseState] = promiseState; - } - // should not pass value to finally callback - var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? - [] : - [parentPromiseValue]); - resolvePromise(chainPromise, true, value); - } - catch (error) { - // if error occurs, should always return this error - resolvePromise(chainPromise, false, error); - } - }, chainPromise); - } - var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; - var ZoneAwarePromise = /** @class */ (function () { - function ZoneAwarePromise(executor) { - var promise = this; - if (!(promise instanceof ZoneAwarePromise)) { - throw new Error('Must be an instanceof Promise.'); - } - promise[symbolState] = UNRESOLVED; - promise[symbolValue] = []; // queue; - try { - executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); - } - catch (error) { - resolvePromise(promise, false, error); - } + function scheduleResolveOrReject(promise, zone, chainPromise, onFulfilled, onRejected) { + clearRejectedNoCatch(promise); + var promiseState = promise[symbolState]; + var delegate = promiseState ? + (typeof onFulfilled === 'function') ? onFulfilled : forwardResolution : + (typeof onRejected === 'function') ? onRejected : forwardRejection; + zone.scheduleMicroTask(source, function () { + try { + var parentPromiseValue = promise[symbolValue]; + var isFinallyPromise = !!chainPromise && symbolFinally === chainPromise[symbolFinally]; + if (isFinallyPromise) { + // if the promise is generated from finally call, keep parent promise's state and value + chainPromise[symbolParentPromiseValue] = parentPromiseValue; + chainPromise[symbolParentPromiseState] = promiseState; + } + // should not pass value to finally callback + var value = zone.run(delegate, undefined, isFinallyPromise && delegate !== forwardRejection && delegate !== forwardResolution ? + [] : + [parentPromiseValue]); + resolvePromise(chainPromise, true, value); + } + catch (error) { + // if error occurs, should always return this error + resolvePromise(chainPromise, false, error); + } + }, chainPromise); } - ZoneAwarePromise.toString = function () { - return ZONE_AWARE_PROMISE_TO_STRING; - }; - ZoneAwarePromise.resolve = function (value) { - return resolvePromise(new this(null), RESOLVED, value); - }; - ZoneAwarePromise.reject = function (error) { - return resolvePromise(new this(null), REJECTED, error); - }; - ZoneAwarePromise.race = function (values) { - var e_1, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; - }); - function onResolve(value) { - resolve(value); - } - function onReject(error) { - reject(error); + var ZONE_AWARE_PROMISE_TO_STRING = 'function ZoneAwarePromise() { [native code] }'; + var ZoneAwarePromise = /** @class */ (function () { + function ZoneAwarePromise(executor) { + var promise = this; + if (!(promise instanceof ZoneAwarePromise)) { + throw new Error('Must be an instanceof Promise.'); + } + promise[symbolState] = UNRESOLVED; + promise[symbolValue] = []; // queue; + try { + executor && executor(makeResolver(promise, RESOLVED), makeResolver(promise, REJECTED)); + } + catch (error) { + resolvePromise(promise, false, error); + } } - try { - for (var values_1 = __values(values), values_1_1 = values_1.next(); !values_1_1.done; values_1_1 = values_1.next()) { - var value = values_1_1.value; + ZoneAwarePromise.toString = function () { + return ZONE_AWARE_PROMISE_TO_STRING; + }; + ZoneAwarePromise.resolve = function (value) { + return resolvePromise(new this(null), RESOLVED, value); + }; + ZoneAwarePromise.reject = function (error) { + return resolvePromise(new this(null), REJECTED, error); + }; + ZoneAwarePromise.race = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + function onResolve(value) { + resolve(value); + } + function onReject(error) { + reject(error); + } + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; if (!isThenable(value)) { value = this.resolve(value); } value.then(onResolve, onReject); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (values_1_1 && !values_1_1.done && (_a = values_1.return)) _a.call(values_1); + return promise; + }; + ZoneAwarePromise.all = function (values) { + var resolve; + var reject; + var promise = new this(function (res, rej) { + resolve = res; + reject = rej; + }); + // Start at 2 to prevent prematurely resolving if .then is called immediately. + var unresolvedCount = 2; + var valueIndex = 0; + var resolvedValues = []; + var _loop_2 = function (value) { + if (!isThenable(value)) { + value = this_1.resolve(value); + } + var curValueIndex = valueIndex; + value.then(function (value) { + resolvedValues[curValueIndex] = value; + unresolvedCount--; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + }, reject); + unresolvedCount++; + valueIndex++; + }; + var this_1 = this; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var value = values_2[_i]; + _loop_2(value); } - finally { if (e_1) throw e_1.error; } - } - return promise; - }; - ZoneAwarePromise.all = function (values) { - var e_2, _a; - var resolve; - var reject; - var promise = new this(function (res, rej) { - resolve = res; - reject = rej; + // Make the unresolvedCount zero-based again. + unresolvedCount -= 2; + if (unresolvedCount === 0) { + resolve(resolvedValues); + } + return promise; + }; + Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { + get: function () { + return 'Promise'; + }, + enumerable: true, + configurable: true }); - // Start at 2 to prevent prematurely resolving if .then is called immediately. - var unresolvedCount = 2; - var valueIndex = 0; - var resolvedValues = []; - var _loop_2 = function (value) { - if (!isThenable(value)) { - value = this_1.resolve(value); - } - var curValueIndex = valueIndex; - value.then(function (value) { - resolvedValues[curValueIndex] = value; - unresolvedCount--; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - }, reject); - unresolvedCount++; - valueIndex++; + ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { + var chainPromise = new this.constructor(null); + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); + } + else { + scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); + } + return chainPromise; }; - var this_1 = this; - try { - for (var values_2 = __values(values), values_2_1 = values_2.next(); !values_2_1.done; values_2_1 = values_2.next()) { - var value = values_2_1.value; - _loop_2(value); + ZoneAwarePromise.prototype.catch = function (onRejected) { + return this.then(null, onRejected); + }; + ZoneAwarePromise.prototype.finally = function (onFinally) { + var chainPromise = new this.constructor(null); + chainPromise[symbolFinally] = symbolFinally; + var zone = Zone.current; + if (this[symbolState] == UNRESOLVED) { + this[symbolValue].push(zone, chainPromise, onFinally, onFinally); } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (values_2_1 && !values_2_1.done && (_a = values_2.return)) _a.call(values_2); + else { + scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); } - finally { if (e_2) throw e_2.error; } - } - // Make the unresolvedCount zero-based again. - unresolvedCount -= 2; - if (unresolvedCount === 0) { - resolve(resolvedValues); - } - return promise; - }; - Object.defineProperty(ZoneAwarePromise.prototype, Symbol.toStringTag, { - get: function () { - return 'Promise'; - }, - enumerable: true, - configurable: true - }); - ZoneAwarePromise.prototype.then = function (onFulfilled, onRejected) { - var chainPromise = new this.constructor(null); - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFulfilled, onRejected); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFulfilled, onRejected); - } - return chainPromise; - }; - ZoneAwarePromise.prototype.catch = function (onRejected) { - return this.then(null, onRejected); - }; - ZoneAwarePromise.prototype.finally = function (onFinally) { - var chainPromise = new this.constructor(null); - chainPromise[symbolFinally] = symbolFinally; - var zone = Zone.current; - if (this[symbolState] == UNRESOLVED) { - this[symbolValue].push(zone, chainPromise, onFinally, onFinally); - } - else { - scheduleResolveOrReject(this, zone, chainPromise, onFinally, onFinally); - } - return chainPromise; - }; - return ZoneAwarePromise; - }()); - // Protect against aggressive optimizers dropping seemingly unused properties. - // E.g. Closure Compiler in advanced mode. - ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; - ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; - ZoneAwarePromise['race'] = ZoneAwarePromise.race; - ZoneAwarePromise['all'] = ZoneAwarePromise.all; - var NativePromise = global[symbolPromise] = global['Promise']; - var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); - var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); - if (!desc || desc.configurable) { - desc && delete desc.writable; - desc && delete desc.value; - if (!desc) { - desc = { configurable: true, enumerable: true }; - } - desc.get = function () { - // if we already set ZoneAwarePromise, use patched one - // otherwise return native one. - return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; - }; - desc.set = function (NewNativePromise) { - if (NewNativePromise === ZoneAwarePromise) { - // if the NewNativePromise is ZoneAwarePromise - // save to global - global[ZONE_AWARE_PROMISE] = NewNativePromise; - } - else { - // if the NewNativePromise is not ZoneAwarePromise - // for example: after load zone.js, some library just - // set es6-promise to global, if we set it to global - // directly, assertZonePatched will fail and angular - // will not loaded, so we just set the NewNativePromise - // to global[symbolPromise], so the result is just like - // we load ES6 Promise before zone.js - global[symbolPromise] = NewNativePromise; - if (!NewNativePromise.prototype[symbolThen]) { - patchThen(NewNativePromise); - } - api.setNativePromise(NewNativePromise); + return chainPromise; + }; + return ZoneAwarePromise; + }()); + // Protect against aggressive optimizers dropping seemingly unused properties. + // E.g. Closure Compiler in advanced mode. + ZoneAwarePromise['resolve'] = ZoneAwarePromise.resolve; + ZoneAwarePromise['reject'] = ZoneAwarePromise.reject; + ZoneAwarePromise['race'] = ZoneAwarePromise.race; + ZoneAwarePromise['all'] = ZoneAwarePromise.all; + var NativePromise = global[symbolPromise] = global['Promise']; + var ZONE_AWARE_PROMISE = Zone.__symbol__('ZoneAwarePromise'); + var desc = ObjectGetOwnPropertyDescriptor(global, 'Promise'); + if (!desc || desc.configurable) { + desc && delete desc.writable; + desc && delete desc.value; + if (!desc) { + desc = { configurable: true, enumerable: true }; + } + desc.get = function () { + // if we already set ZoneAwarePromise, use patched one + // otherwise return native one. + return global[ZONE_AWARE_PROMISE] ? global[ZONE_AWARE_PROMISE] : global[symbolPromise]; + }; + desc.set = function (NewNativePromise) { + if (NewNativePromise === ZoneAwarePromise) { + // if the NewNativePromise is ZoneAwarePromise + // save to global + global[ZONE_AWARE_PROMISE] = NewNativePromise; + } + else { + // if the NewNativePromise is not ZoneAwarePromise + // for example: after load zone.js, some library just + // set es6-promise to global, if we set it to global + // directly, assertZonePatched will fail and angular + // will not loaded, so we just set the NewNativePromise + // to global[symbolPromise], so the result is just like + // we load ES6 Promise before zone.js + global[symbolPromise] = NewNativePromise; + if (!NewNativePromise.prototype[symbolThen]) { + patchThen(NewNativePromise); + } + api.setNativePromise(NewNativePromise); + } + }; + ObjectDefineProperty(global, 'Promise', desc); + } + global['Promise'] = ZoneAwarePromise; + var symbolThenPatched = __symbol__('thenPatched'); + function patchThen(Ctor) { + var proto = Ctor.prototype; + var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); + if (prop && (prop.writable === false || !prop.configurable)) { + // check Ctor.prototype.then propertyDescriptor is writable or not + // in meteor env, writable is false, we should ignore such case + return; } - }; - ObjectDefineProperty(global, 'Promise', desc); - } - global['Promise'] = ZoneAwarePromise; - var symbolThenPatched = __symbol__('thenPatched'); - function patchThen(Ctor) { - var proto = Ctor.prototype; - var prop = ObjectGetOwnPropertyDescriptor(proto, 'then'); - if (prop && (prop.writable === false || !prop.configurable)) { - // check Ctor.prototype.then propertyDescriptor is writable or not - // in meteor env, writable is false, we should ignore such case - return; + var originalThen = proto.then; + // Keep a reference to the original method. + proto[symbolThen] = originalThen; + Ctor.prototype.then = function (onResolve, onReject) { + var _this = this; + var wrapped = new ZoneAwarePromise(function (resolve, reject) { + originalThen.call(_this, resolve, reject); + }); + return wrapped.then(onResolve, onReject); + }; + Ctor[symbolThenPatched] = true; } - var originalThen = proto.then; - // Keep a reference to the original method. - proto[symbolThen] = originalThen; - Ctor.prototype.then = function (onResolve, onReject) { - var _this = this; - var wrapped = new ZoneAwarePromise(function (resolve, reject) { - originalThen.call(_this, resolve, reject); - }); - return wrapped.then(onResolve, onReject); - }; - Ctor[symbolThenPatched] = true; - } - api.patchThen = patchThen; - function zoneify(fn) { - return function () { - var resultPromise = fn.apply(this, arguments); - if (resultPromise instanceof ZoneAwarePromise) { + api.patchThen = patchThen; + function zoneify(fn) { + return function () { + var resultPromise = fn.apply(this, arguments); + if (resultPromise instanceof ZoneAwarePromise) { + return resultPromise; + } + var ctor = resultPromise.constructor; + if (!ctor[symbolThenPatched]) { + patchThen(ctor); + } return resultPromise; + }; + } + if (NativePromise) { + patchThen(NativePromise); + var fetch_1 = global['fetch']; + if (typeof fetch_1 == 'function') { + global[api.symbol('fetch')] = fetch_1; + global['fetch'] = zoneify(fetch_1); } - var ctor = resultPromise.constructor; - if (!ctor[symbolThenPatched]) { - patchThen(ctor); + } + // This is not part of public API, but it is useful for tests, so we expose it. + Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; + return ZoneAwarePromise; + }); + /** + * @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 'Zone' variable + * @fileoverview + * @suppress {undefinedVars,globalThis,missingRequire} + */ + // issue #989, to reduce bundle size, use short name + /** Object.getOwnPropertyDescriptor */ + var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + /** Object.defineProperty */ + var ObjectDefineProperty = Object.defineProperty; + /** Object.getPrototypeOf */ + var ObjectGetPrototypeOf = Object.getPrototypeOf; + /** Object.create */ + var ObjectCreate = Object.create; + /** Array.prototype.slice */ + var ArraySlice = Array.prototype.slice; + /** addEventListener string const */ + var ADD_EVENT_LISTENER_STR = 'addEventListener'; + /** removeEventListener string const */ + var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; + /** zoneSymbol addEventListener */ + var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); + /** zoneSymbol removeEventListener */ + var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); + /** true string const */ + var TRUE_STR = 'true'; + /** false string const */ + var FALSE_STR = 'false'; + /** Zone symbol prefix string const. */ + var ZONE_SYMBOL_PREFIX = Zone.__symbol__(''); + function wrapWithCurrentZone(callback, source) { + return Zone.current.wrap(callback, source); + } + function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { + return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); + } + var zoneSymbol = Zone.__symbol__; + var isWindowExists = typeof window !== 'undefined'; + var internalWindow = isWindowExists ? window : undefined; + var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; + var REMOVE_ATTRIBUTE = 'removeAttribute'; + var NULL_ON_PROP_VALUE = [null]; + function bindArguments(args, source) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = wrapWithCurrentZone(args[i], source + '_' + i); + } + } + return args; + } + function patchPrototype(prototype, fnNames) { + var source = prototype.constructor['name']; + var _loop_3 = function (i) { + var name_1 = fnNames[i]; + var delegate = prototype[name_1]; + if (delegate) { + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); + if (!isPropertyWritable(prototypeDesc)) { + return "continue"; + } + prototype[name_1] = (function (delegate) { + var patched = function () { + return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); + }; + attachOriginToPatched(patched, delegate); + return patched; + })(delegate); } - return resultPromise; }; - } - if (NativePromise) { - patchThen(NativePromise); - var fetch_1 = global['fetch']; - if (typeof fetch_1 == 'function') { - global[api.symbol('fetch')] = fetch_1; - global['fetch'] = zoneify(fetch_1); - } - } - // This is not part of public API, but it is useful for tests, so we expose it. - Promise[Zone.__symbol__('uncaughtPromiseErrors')] = _uncaughtPromiseErrors; - return ZoneAwarePromise; -}); - -/** - * @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 'Zone' variable - * @fileoverview - * @suppress {undefinedVars,globalThis,missingRequire} - */ -// issue #989, to reduce bundle size, use short name -/** Object.getOwnPropertyDescriptor */ -var ObjectGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -/** Object.defineProperty */ -var ObjectDefineProperty = Object.defineProperty; -/** Object.getPrototypeOf */ -var ObjectGetPrototypeOf = Object.getPrototypeOf; -/** Object.create */ -var ObjectCreate = Object.create; -/** Array.prototype.slice */ -var ArraySlice = Array.prototype.slice; -/** addEventListener string const */ -var ADD_EVENT_LISTENER_STR = 'addEventListener'; -/** removeEventListener string const */ -var REMOVE_EVENT_LISTENER_STR = 'removeEventListener'; -/** zoneSymbol addEventListener */ -var ZONE_SYMBOL_ADD_EVENT_LISTENER = Zone.__symbol__(ADD_EVENT_LISTENER_STR); -/** zoneSymbol removeEventListener */ -var ZONE_SYMBOL_REMOVE_EVENT_LISTENER = Zone.__symbol__(REMOVE_EVENT_LISTENER_STR); -/** true string const */ -var TRUE_STR = 'true'; -/** false string const */ -var FALSE_STR = 'false'; -/** __zone_symbol__ string const */ -var ZONE_SYMBOL_PREFIX = '__zone_symbol__'; -function wrapWithCurrentZone(callback, source) { - return Zone.current.wrap(callback, source); -} -function scheduleMacroTaskWithCurrentZone(source, callback, data, customSchedule, customCancel) { - return Zone.current.scheduleMacroTask(source, callback, data, customSchedule, customCancel); -} -var zoneSymbol = Zone.__symbol__; -var isWindowExists = typeof window !== 'undefined'; -var internalWindow = isWindowExists ? window : undefined; -var _global = isWindowExists && internalWindow || typeof self === 'object' && self || global; -var REMOVE_ATTRIBUTE = 'removeAttribute'; -var NULL_ON_PROP_VALUE = [null]; -function bindArguments(args, source) { - for (var i = args.length - 1; i >= 0; i--) { - if (typeof args[i] === 'function') { - args[i] = wrapWithCurrentZone(args[i], source + '_' + i); - } - } - return args; -} -function patchPrototype(prototype, fnNames) { - var source = prototype.constructor['name']; - var _loop_1 = function (i) { - var name_1 = fnNames[i]; - var delegate = prototype[name_1]; - if (delegate) { - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, name_1); - if (!isPropertyWritable(prototypeDesc)) { - return "continue"; - } - prototype[name_1] = (function (delegate) { - var patched = function () { - return delegate.apply(this, bindArguments(arguments, source + '.' + name_1)); - }; - attachOriginToPatched(patched, delegate); - return patched; - })(delegate); - } - }; - for (var i = 0; i < fnNames.length; i++) { - _loop_1(i); - } -} -function isPropertyWritable(propertyDesc) { - if (!propertyDesc) { - return true; - } - if (propertyDesc.writable === false) { - return false; - } - return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); -} -var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]'); -var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); -// we are in electron of nw, so we are both browser and nodejs -// Make sure to access `process` through `_global` so that WebPack does not accidentally browserify -// this code. -var isMix = typeof _global.process !== 'undefined' && - {}.toString.call(_global.process) === '[object process]' && !isWebWorker && - !!(isWindowExists && internalWindow['HTMLElement']); -var zoneSymbolEventNames = {}; -var wrapFn = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; - } - var eventNameSymbol = zoneSymbolEventNames[event.type]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); - } - var target = this || event.target || _global; - var listener = target[eventNameSymbol]; - var result; - if (isBrowser && target === internalWindow && event.type === 'error') { - // window.onerror have different signiture - // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror - // and onerror callback will prevent default when callback return true - var errorEvent = event; - result = listener && - listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); - if (result === true) { - event.preventDefault(); + for (var i = 0; i < fnNames.length; i++) { + _loop_3(i); } } - else { - result = listener && listener.apply(this, arguments); - if (result != undefined && !result) { - event.preventDefault(); - } - } - return result; -}; -function patchProperty(obj, prop, prototype) { - var desc = ObjectGetOwnPropertyDescriptor(obj, prop); - if (!desc && prototype) { - // when patch window object, use prototype to check prop exist or not - var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); - if (prototypeDesc) { - desc = { enumerable: true, configurable: true }; + function isPropertyWritable(propertyDesc) { + if (!propertyDesc) { + return true; } - } - // if the descriptor not exists or is not configurable - // just return - if (!desc || !desc.configurable) { - return; - } - var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); - if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { - return; - } - // A property descriptor cannot have getter/setter and be writable - // deleting the writable and value properties avoids this error: - // - // TypeError: property descriptors must not specify a value or be writable when a - // getter or setter has been specified - delete desc.writable; - delete desc.value; - var originalDescGet = desc.get; - var originalDescSet = desc.set; - // substr(2) cuz 'onclick' -> 'click', etc - var eventName = prop.substr(2); - var eventNameSymbol = zoneSymbolEventNames[eventName]; - if (!eventNameSymbol) { - eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); - } - desc.set = function (newValue) { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; + if (propertyDesc.writable === false) { + return false; } - if (!target) { + return !(typeof propertyDesc.get === 'function' && typeof propertyDesc.set === 'undefined'); + } + var isWebWorker = (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope); + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isNode = (!('nw' in _global) && typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]'); + var isBrowser = !isNode && !isWebWorker && !!(isWindowExists && internalWindow['HTMLElement']); + // we are in electron of nw, so we are both browser and nodejs + // Make sure to access `process` through `_global` so that WebPack does not accidentally browserify + // this code. + var isMix = typeof _global.process !== 'undefined' && + {}.toString.call(_global.process) === '[object process]' && !isWebWorker && + !!(isWindowExists && internalWindow['HTMLElement']); + var zoneSymbolEventNames = {}; + var wrapFn = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - var previousValue = target[eventNameSymbol]; - if (previousValue) { - target.removeEventListener(eventName, wrapFn); - } - // issue #978, when onload handler was added before loading zone.js - // we should remove it with originalDescSet - if (originalDescSet) { - originalDescSet.apply(target, NULL_ON_PROP_VALUE); + var eventNameSymbol = zoneSymbolEventNames[event.type]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[event.type] = zoneSymbol('ON_PROPERTY' + event.type); } - if (typeof newValue === 'function') { - target[eventNameSymbol] = newValue; - target.addEventListener(eventName, wrapFn, false); + var target = this || event.target || _global; + var listener = target[eventNameSymbol]; + var result; + if (isBrowser && target === internalWindow && event.type === 'error') { + // window.onerror have different signiture + // https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.onerror + // and onerror callback will prevent default when callback return true + var errorEvent = event; + result = listener && + listener.call(this, errorEvent.message, errorEvent.filename, errorEvent.lineno, errorEvent.colno, errorEvent.error); + if (result === true) { + event.preventDefault(); + } } else { - target[eventNameSymbol] = null; + result = listener && listener.apply(this, arguments); + if (result != undefined && !result) { + event.preventDefault(); + } } + return result; }; - // The getter would return undefined for unassigned properties but the default value of an - // unassigned property is null - desc.get = function () { - // in some of windows's onproperty callback, this is undefined - // so we need to check it - var target = this; - if (!target && obj === _global) { - target = _global; + function patchProperty(obj, prop, prototype) { + var desc = ObjectGetOwnPropertyDescriptor(obj, prop); + if (!desc && prototype) { + // when patch window object, use prototype to check prop exist or not + var prototypeDesc = ObjectGetOwnPropertyDescriptor(prototype, prop); + if (prototypeDesc) { + desc = { enumerable: true, configurable: true }; + } + } + // if the descriptor not exists or is not configurable + // just return + if (!desc || !desc.configurable) { + return; } - if (!target) { - return null; + var onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched'); + if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) { + return; } - var listener = target[eventNameSymbol]; - if (listener) { - return listener; - } - else if (originalDescGet) { - // result will be null when use inline event attribute, - // such as - // because the onclick function is internal raw uncompiled handler - // the onclick will be evaluated when first time event was triggered or - // the property is accessed, https://github.com/angular/zone.js/issues/525 - // so we should use original native get to retrieve the handler - var value = originalDescGet && originalDescGet.call(this); - if (value) { - desc.set.call(this, value); - if (typeof target[REMOVE_ATTRIBUTE] === 'function') { - target.removeAttribute(prop); - } - return value; + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + var originalDescGet = desc.get; + var originalDescSet = desc.set; + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var eventNameSymbol = zoneSymbolEventNames[eventName]; + if (!eventNameSymbol) { + eventNameSymbol = zoneSymbolEventNames[eventName] = zoneSymbol('ON_PROPERTY' + eventName); + } + desc.set = function (newValue) { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return; } - } - return null; - }; - ObjectDefineProperty(obj, prop, desc); - obj[onPropPatchedSymbol] = true; -} -function patchOnProperties(obj, properties, prototype) { - if (properties) { - for (var i = 0; i < properties.length; i++) { - patchProperty(obj, 'on' + properties[i], prototype); - } - } - else { - var onProperties = []; - for (var prop in obj) { - if (prop.substr(0, 2) == 'on') { - onProperties.push(prop); + var previousValue = target[eventNameSymbol]; + if (previousValue) { + target.removeEventListener(eventName, wrapFn); } - } - for (var j = 0; j < onProperties.length; j++) { - patchProperty(obj, onProperties[j], prototype); - } - } -} -var originalInstanceKey = zoneSymbol('originalInstance'); -// wrap some native API on `window` -function patchClass(className) { - var OriginalClass = _global[className]; - if (!OriginalClass) - return; - // keep original class in global - _global[zoneSymbol(className)] = OriginalClass; - _global[className] = function () { - var a = bindArguments(arguments, className); - switch (a.length) { - case 0: - this[originalInstanceKey] = new OriginalClass(); - break; - case 1: - this[originalInstanceKey] = new OriginalClass(a[0]); - break; - case 2: - this[originalInstanceKey] = new OriginalClass(a[0], a[1]); - break; - case 3: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); - break; - case 4: - this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); - break; - default: - throw new Error('Arg list too long.'); - } - }; - // attach original delegate to patched function - attachOriginToPatched(_global[className], OriginalClass); - var instance = new OriginalClass(function () { }); - var prop; - for (prop in instance) { - // https://bugs.webkit.org/show_bug.cgi?id=44721 - if (className === 'XMLHttpRequest' && prop === 'responseBlob') - continue; - (function (prop) { - if (typeof instance[prop] === 'function') { - _global[className].prototype[prop] = function () { - return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); - }; + // issue #978, when onload handler was added before loading zone.js + // we should remove it with originalDescSet + if (originalDescSet) { + originalDescSet.apply(target, NULL_ON_PROP_VALUE); + } + if (typeof newValue === 'function') { + target[eventNameSymbol] = newValue; + target.addEventListener(eventName, wrapFn, false); } else { - ObjectDefineProperty(_global[className].prototype, prop, { - set: function (fn) { - if (typeof fn === 'function') { - this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); - // keep callback in wrapped function so we can - // use it in Function.prototype.toString to return - // the native one. - attachOriginToPatched(this[originalInstanceKey][prop], fn); - } - else { - this[originalInstanceKey][prop] = fn; - } - }, - get: function () { - return this[originalInstanceKey][prop]; - } - }); + target[eventNameSymbol] = null; } - }(prop)); - } - for (prop in OriginalClass) { - if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { - _global[className][prop] = OriginalClass[prop]; - } - } -} -function copySymbolProperties(src, dest) { - if (typeof Object.getOwnPropertySymbols !== 'function') { - return; - } - var symbols = Object.getOwnPropertySymbols(src); - symbols.forEach(function (symbol) { - var desc = Object.getOwnPropertyDescriptor(src, symbol); - Object.defineProperty(dest, symbol, { - get: function () { - return src[symbol]; - }, - set: function (value) { - if (desc && (!desc.writable || typeof desc.set !== 'function')) { - // if src[symbol] is not writable or not have a setter, just return - return; + }; + // The getter would return undefined for unassigned properties but the default value of an + // unassigned property is null + desc.get = function () { + // in some of windows's onproperty callback, this is undefined + // so we need to check it + var target = this; + if (!target && obj === _global) { + target = _global; + } + if (!target) { + return null; + } + var listener = target[eventNameSymbol]; + if (listener) { + return listener; + } + else if (originalDescGet) { + // result will be null when use inline event attribute, + // such as + // because the onclick function is internal raw uncompiled handler + // the onclick will be evaluated when first time event was triggered or + // the property is accessed, https://github.com/angular/zone.js/issues/525 + // so we should use original native get to retrieve the handler + var value = originalDescGet && originalDescGet.call(this); + if (value) { + desc.set.call(this, value); + if (typeof target[REMOVE_ATTRIBUTE] === 'function') { + target.removeAttribute(prop); + } + return value; } - src[symbol] = value; - }, - enumerable: desc ? desc.enumerable : true, - configurable: desc ? desc.configurable : true - }); - }); -} -var shouldCopySymbolProperties = false; - -function patchMethod(target, name, patchFn) { - var proto = target; - while (proto && !proto.hasOwnProperty(name)) { - proto = ObjectGetPrototypeOf(proto); - } - if (!proto && target[name]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = target; - } - var delegateName = zoneSymbol(name); - var delegate = null; - if (proto && !(delegate = proto[delegateName])) { - delegate = proto[delegateName] = proto[name]; - // check whether proto[name] is writable - // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob - var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); - if (isPropertyWritable(desc)) { - var patchDelegate_1 = patchFn(delegate, delegateName, name); - proto[name] = function () { - return patchDelegate_1(this, arguments); - }; - attachOriginToPatched(proto[name], delegate); - if (shouldCopySymbolProperties) { - copySymbolProperties(delegate, proto[name]); } - } - } - return delegate; -} -// TODO: @JiaLiPassion, support cancel task later if necessary -function patchMacroTask(obj, funcName, metaCreator) { - var setNative = null; - function scheduleTask(task) { - var data = task.data; - data.args[data.cbIdx] = function () { - task.invoke.apply(this, arguments); + return null; }; - setNative.apply(data.target, data.args); - return task; + ObjectDefineProperty(obj, prop, desc); + obj[onPropPatchedSymbol] = true; } - setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { - var meta = metaCreator(self, args); - if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { - return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); + function patchOnProperties(obj, properties, prototype) { + if (properties) { + for (var i = 0; i < properties.length; i++) { + patchProperty(obj, 'on' + properties[i], prototype); + } } else { - // cause an error by calling it directly. - return delegate.apply(self, args); - } - }; }); -} - -function attachOriginToPatched(patched, original) { - patched[zoneSymbol('OriginalDelegate')] = original; -} -var isDetectedIEOrEdge = false; -var ieOrEdge = false; -function isIE() { - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { - return true; - } - } - catch (error) { - } - return false; -} -function isIEOrEdge() { - if (isDetectedIEOrEdge) { - return ieOrEdge; - } - isDetectedIEOrEdge = true; - try { - var ua = internalWindow.navigator.userAgent; - if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { - ieOrEdge = true; - } - } - catch (error) { - } - return ieOrEdge; -} - -/** - * @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 - */ -// override Function.prototype.toString to make zone.js patched function -// look like native function -Zone.__load_patch('toString', function (global) { - // patch Func.prototype.toString to let them look like native - var originalFunctionToString = Function.prototype.toString; - var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); - var PROMISE_SYMBOL = zoneSymbol('Promise'); - var ERROR_SYMBOL = zoneSymbol('Error'); - var newFunctionToString = function toString() { - if (typeof this === 'function') { - var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; - if (originalDelegate) { - if (typeof originalDelegate === 'function') { - return originalFunctionToString.call(originalDelegate); - } - else { - return Object.prototype.toString.call(originalDelegate); - } - } - if (this === Promise) { - var nativePromise = global[PROMISE_SYMBOL]; - if (nativePromise) { - return originalFunctionToString.call(nativePromise); + var onProperties = []; + for (var prop in obj) { + if (prop.substr(0, 2) == 'on') { + onProperties.push(prop); } } - if (this === Error) { - var nativeError = global[ERROR_SYMBOL]; - if (nativeError) { - return originalFunctionToString.call(nativeError); - } + for (var j = 0; j < onProperties.length; j++) { + patchProperty(obj, onProperties[j], prototype); } } - return originalFunctionToString.call(this); - }; - newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; - Function.prototype.toString = newFunctionToString; - // patch Object.prototype.toString to let them look like native - var originalObjectToString = Object.prototype.toString; - var PROMISE_OBJECT_TO_STRING = '[object Promise]'; - Object.prototype.toString = function () { - if (this instanceof Promise) { - return PROMISE_OBJECT_TO_STRING; - } - return originalObjectToString.call(this); - }; -}); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var passiveSupported = false; -if (typeof window !== 'undefined') { - try { - var options = Object.defineProperty({}, 'passive', { - get: function () { - passiveSupported = true; - } - }); - window.addEventListener('test', options, options); - window.removeEventListener('test', options, options); - } - catch (err) { - passiveSupported = false; } -} -// an identifier to tell ZoneTask do not create a new invoke closure -var OPTIMIZED_ZONE_EVENT_TASK_DATA = { - useG: true -}; -var zoneSymbolEventNames$1 = {}; -var globalSources = {}; -var EVENT_NAME_SYMBOL_REGX = /^__zone_symbol__(\w+)(true|false)$/; -var IMMEDIATE_PROPAGATION_SYMBOL = ('__zone_symbol__propagationStopped'); -function patchEventTarget(_global, apis, patchOptions) { - var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; - var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; - var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; - var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; - var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); - var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; - var PREPEND_EVENT_LISTENER = 'prependListener'; - var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; - var invokeTask = function (task, target, event) { - // for better performance, check isRemoved which is set - // by removeEventListener - if (task.isRemoved) { + var originalInstanceKey = zoneSymbol('originalInstance'); + // wrap some native API on `window` + function patchClass(className) { + var OriginalClass = _global[className]; + if (!OriginalClass) return; + // keep original class in global + _global[zoneSymbol(className)] = OriginalClass; + _global[className] = function () { + var a = bindArguments(arguments, className); + switch (a.length) { + case 0: + this[originalInstanceKey] = new OriginalClass(); + break; + case 1: + this[originalInstanceKey] = new OriginalClass(a[0]); + break; + case 2: + this[originalInstanceKey] = new OriginalClass(a[0], a[1]); + break; + case 3: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2]); + break; + case 4: + this[originalInstanceKey] = new OriginalClass(a[0], a[1], a[2], a[3]); + break; + default: + throw new Error('Arg list too long.'); + } + }; + // attach original delegate to patched function + attachOriginToPatched(_global[className], OriginalClass); + var instance = new OriginalClass(function () { }); + var prop; + for (prop in instance) { + // https://bugs.webkit.org/show_bug.cgi?id=44721 + if (className === 'XMLHttpRequest' && prop === 'responseBlob') + continue; + (function (prop) { + if (typeof instance[prop] === 'function') { + _global[className].prototype[prop] = function () { + return this[originalInstanceKey][prop].apply(this[originalInstanceKey], arguments); + }; + } + else { + ObjectDefineProperty(_global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this[originalInstanceKey][prop] = wrapWithCurrentZone(fn, className + '.' + prop); + // keep callback in wrapped function so we can + // use it in Function.prototype.toString to return + // the native one. + attachOriginToPatched(this[originalInstanceKey][prop], fn); + } + else { + this[originalInstanceKey][prop] = fn; + } + }, + get: function () { + return this[originalInstanceKey][prop]; + } + }); + } + }(prop)); } - var delegate = task.callback; - if (typeof delegate === 'object' && delegate.handleEvent) { - // create the bind version of handleEvent when invoke - task.callback = function (event) { return delegate.handleEvent(event); }; - task.originalDelegate = delegate; - } - // invoke static task.invoke - task.invoke(task, target, [event]); - var options = task.options; - if (options && typeof options === 'object' && options.once) { - // if options.once is true, after invoke once remove listener here - // only browser need to do this, nodejs eventEmitter will cal removeListener - // inside EventEmitter.once - var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; - target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + for (prop in OriginalClass) { + if (prop !== 'prototype' && OriginalClass.hasOwnProperty(prop)) { + _global[className][prop] = OriginalClass[prop]; + } } - }; - // global shared zoneAwareCallback to handle all event callback with capture = false - var globalZoneAwareCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { + } + function copySymbolProperties(src, dest) { + if (typeof Object.getOwnPropertySymbols !== 'function') { return; } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); - } - else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; + var symbols = Object.getOwnPropertySymbols(src); + symbols.forEach(function (symbol) { + var desc = Object.getOwnPropertyDescriptor(src, symbol); + Object.defineProperty(dest, symbol, { + get: function () { + return src[symbol]; + }, + set: function (value) { + if (desc && (!desc.writable || typeof desc.set !== 'function')) { + // if src[symbol] is not writable or not have a setter, just return + return; } - invokeTask(copyTasks[i], target, event); + src[symbol] = value; + }, + enumerable: desc ? desc.enumerable : true, + configurable: desc ? desc.configurable : true + }); + }); + } + var shouldCopySymbolProperties = false; + function patchMethod(target, name, patchFn) { + var proto = target; + while (proto && !proto.hasOwnProperty(name)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && target[name]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = target; + } + var delegateName = zoneSymbol(name); + var delegate = null; + if (proto && !(delegate = proto[delegateName])) { + delegate = proto[delegateName] = proto[name]; + // check whether proto[name] is writable + // some property is readonly in safari, such as HtmlCanvasElement.prototype.toBlob + var desc = proto && ObjectGetOwnPropertyDescriptor(proto, name); + if (isPropertyWritable(desc)) { + var patchDelegate_1 = patchFn(delegate, delegateName, name); + proto[name] = function () { + return patchDelegate_1(this, arguments); + }; + attachOriginToPatched(proto[name], delegate); + if (shouldCopySymbolProperties) { + copySymbolProperties(delegate, proto[name]); } } } - }; - // global shared zoneAwareCallback to handle all event callback with capture = true - var globalZoneAwareCaptureCallback = function (event) { - // https://github.com/angular/zone.js/issues/911, in IE, sometimes - // event will be undefined, so we need to use window.event - event = event || _global.event; - if (!event) { - return; + return delegate; + } + // TODO: @JiaLiPassion, support cancel task later if necessary + function patchMacroTask(obj, funcName, metaCreator) { + var setNative = null; + function scheduleTask(task) { + var data = task.data; + data.args[data.cbIdx] = function () { + task.invoke.apply(this, arguments); + }; + setNative.apply(data.target, data.args); + return task; } - // event.target is needed for Samsung TV and SourceBuffer - // || global is needed https://github.com/angular/zone.js/issues/190 - var target = this || event.target || _global; - var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; - if (tasks) { - // invoke all tasks which attached to current target with given event.type and capture = false - // for performance concern, if task.length === 1, just invoke - if (tasks.length === 1) { - invokeTask(tasks[0], target, event); + setNative = patchMethod(obj, funcName, function (delegate) { return function (self, args) { + var meta = metaCreator(self, args); + if (meta.cbIdx >= 0 && typeof args[meta.cbIdx] === 'function') { + return scheduleMacroTaskWithCurrentZone(meta.name, args[meta.cbIdx], meta, scheduleTask); } else { - // https://github.com/angular/zone.js/issues/836 - // copy the tasks array before invoke, to avoid - // the callback will remove itself or other listener - var copyTasks = tasks.slice(); - for (var i = 0; i < copyTasks.length; i++) { - if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { - break; - } - invokeTask(copyTasks[i], target, event); - } + // cause an error by calling it directly. + return delegate.apply(self, args); + } + }; }); + } + function attachOriginToPatched(patched, original) { + patched[zoneSymbol('OriginalDelegate')] = original; + } + var isDetectedIEOrEdge = false; + var ieOrEdge = false; + function isIE() { + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1) { + return true; } } - }; - function patchEventTargetMethods(obj, patchOptions) { - if (!obj) { - return false; - } - var useGlobalCallback = true; - if (patchOptions && patchOptions.useG !== undefined) { - useGlobalCallback = patchOptions.useG; - } - var validateHandler = patchOptions && patchOptions.vh; - var checkDuplicate = true; - if (patchOptions && patchOptions.chkDup !== undefined) { - checkDuplicate = patchOptions.chkDup; + catch (error) { } - var returnTarget = false; - if (patchOptions && patchOptions.rt !== undefined) { - returnTarget = patchOptions.rt; + return false; + } + function isIEOrEdge() { + if (isDetectedIEOrEdge) { + return ieOrEdge; } - var proto = obj; - while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { - proto = ObjectGetPrototypeOf(proto); + isDetectedIEOrEdge = true; + try { + var ua = internalWindow.navigator.userAgent; + if (ua.indexOf('MSIE ') !== -1 || ua.indexOf('Trident/') !== -1 || ua.indexOf('Edge/') !== -1) { + ieOrEdge = true; + } } - if (!proto && obj[ADD_EVENT_LISTENER]) { - // somehow we did not find it, but we can see it. This happens on IE for Window properties. - proto = obj; + catch (error) { } - if (!proto) { - return false; + return ieOrEdge; + } + /** + * @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 + */ + // override Function.prototype.toString to make zone.js patched function + // look like native function + Zone.__load_patch('toString', function (global) { + // patch Func.prototype.toString to let them look like native + var originalFunctionToString = Function.prototype.toString; + var ORIGINAL_DELEGATE_SYMBOL = zoneSymbol('OriginalDelegate'); + var PROMISE_SYMBOL = zoneSymbol('Promise'); + var ERROR_SYMBOL = zoneSymbol('Error'); + var newFunctionToString = function toString() { + if (typeof this === 'function') { + var originalDelegate = this[ORIGINAL_DELEGATE_SYMBOL]; + if (originalDelegate) { + if (typeof originalDelegate === 'function') { + return originalFunctionToString.call(originalDelegate); + } + else { + return Object.prototype.toString.call(originalDelegate); + } + } + if (this === Promise) { + var nativePromise = global[PROMISE_SYMBOL]; + if (nativePromise) { + return originalFunctionToString.call(nativePromise); + } + } + if (this === Error) { + var nativeError = global[ERROR_SYMBOL]; + if (nativeError) { + return originalFunctionToString.call(nativeError); + } + } + } + return originalFunctionToString.call(this); + }; + newFunctionToString[ORIGINAL_DELEGATE_SYMBOL] = originalFunctionToString; + Function.prototype.toString = newFunctionToString; + // patch Object.prototype.toString to let them look like native + var originalObjectToString = Object.prototype.toString; + var PROMISE_OBJECT_TO_STRING = '[object Promise]'; + Object.prototype.toString = function () { + if (this instanceof Promise) { + return PROMISE_OBJECT_TO_STRING; + } + return originalObjectToString.call(this); + }; + }); + /** + * @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 passiveSupported = false; + if (typeof window !== 'undefined') { + try { + var options = Object.defineProperty({}, 'passive', { + get: function () { + passiveSupported = true; + } + }); + window.addEventListener('test', options, options); + window.removeEventListener('test', options, options); } - if (proto[zoneSymbolAddEventListener]) { - return false; + catch (err) { + passiveSupported = false; } - var eventNameToString = patchOptions && patchOptions.eventNameToString; - // a shared global taskData to pass data for scheduleEventTask - // so we do not need to create a new object just for pass some data - var taskData = {}; - var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; - var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = - proto[REMOVE_EVENT_LISTENER]; - var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = - proto[LISTENERS_EVENT_LISTENER]; - var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; - var nativePrependEventListener; - if (patchOptions && patchOptions.prepend) { - nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = - proto[patchOptions.prepend]; - } - function checkIsPassive(task) { - if (!passiveSupported && typeof taskData.options !== 'boolean' && - typeof taskData.options !== 'undefined' && taskData.options !== null) { - // options is a non-null non-undefined object - // passive is not supported - // don't pass options as object - // just pass capture as a boolean - task.options = !!taskData.options.capture; - taskData.options = task.options; - } - } - var customScheduleGlobal = function (task) { - // if there is already a task for the eventName + capture, - // just return, because we use the shared globalZoneAwareCallback here. - if (taskData.isExisting) { + } + // an identifier to tell ZoneTask do not create a new invoke closure + var OPTIMIZED_ZONE_EVENT_TASK_DATA = { + useG: true + }; + var zoneSymbolEventNames$1 = {}; + var globalSources = {}; + var EVENT_NAME_SYMBOL_REGX = new RegExp('^' + ZONE_SYMBOL_PREFIX + '(\\w+)(true|false)$'); + var IMMEDIATE_PROPAGATION_SYMBOL = zoneSymbol('propagationStopped'); + function patchEventTarget(_global, apis, patchOptions) { + var ADD_EVENT_LISTENER = (patchOptions && patchOptions.add) || ADD_EVENT_LISTENER_STR; + var REMOVE_EVENT_LISTENER = (patchOptions && patchOptions.rm) || REMOVE_EVENT_LISTENER_STR; + var LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.listeners) || 'eventListeners'; + var REMOVE_ALL_LISTENERS_EVENT_LISTENER = (patchOptions && patchOptions.rmAll) || 'removeAllListeners'; + var zoneSymbolAddEventListener = zoneSymbol(ADD_EVENT_LISTENER); + var ADD_EVENT_LISTENER_SOURCE = '.' + ADD_EVENT_LISTENER + ':'; + var PREPEND_EVENT_LISTENER = 'prependListener'; + var PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':'; + var invokeTask = function (task, target, event) { + // for better performance, check isRemoved which is set + // by removeEventListener + if (task.isRemoved) { return; } - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + var delegate = task.callback; + if (typeof delegate === 'object' && delegate.handleEvent) { + // create the bind version of handleEvent when invoke + task.callback = function (event) { return delegate.handleEvent(event); }; + task.originalDelegate = delegate; + } + // invoke static task.invoke + task.invoke(task, target, [event]); + var options = task.options; + if (options && typeof options === 'object' && options.once) { + // if options.once is true, after invoke once remove listener here + // only browser need to do this, nodejs eventEmitter will cal removeListener + // inside EventEmitter.once + var delegate_1 = task.originalDelegate ? task.originalDelegate : task.callback; + target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate_1, options); + } }; - var customCancelGlobal = function (task) { - // if task is not marked as isRemoved, this call is directly - // from Zone.prototype.cancelTask, we should remove the task - // from tasksList of target first - if (!task.isRemoved) { - var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; - var symbolEventName = void 0; - if (symbolEventNames) { - symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + // global shared zoneAwareCallback to handle all event callback with capture = false + var globalZoneAwareCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { + return; + } + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][FALSE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); } - var existingTasks = symbolEventName && task.target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (existingTask === task) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - task.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - task.allRemoved = true; - task.target[symbolEventName] = null; - } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { break; } + invokeTask(copyTasks[i], target, event); } } } - // if all tasks for the eventName + capture have gone, - // we will really remove the global event callback, - // if not, return - if (!task.allRemoved) { + }; + // global shared zoneAwareCallback to handle all event callback with capture = true + var globalZoneAwareCaptureCallback = function (event) { + // https://github.com/angular/zone.js/issues/911, in IE, sometimes + // event will be undefined, so we need to use window.event + event = event || _global.event; + if (!event) { return; } - return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); - }; - var customScheduleNonGlobal = function (task) { - checkIsPassive(task); - return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customSchedulePrepend = function (task) { - return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); - }; - var customCancelNonGlobal = function (task) { - return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); - }; - var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; - var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; - var compareTaskCallbackVsDelegate = function (task, delegate) { - var typeOfDelegate = typeof delegate; - return (typeOfDelegate === 'function' && task.callback === delegate) || - (typeOfDelegate === 'object' && task.originalDelegate === delegate); + // event.target is needed for Samsung TV and SourceBuffer + // || global is needed https://github.com/angular/zone.js/issues/190 + var target = this || event.target || _global; + var tasks = target[zoneSymbolEventNames$1[event.type][TRUE_STR]]; + if (tasks) { + // invoke all tasks which attached to current target with given event.type and capture = false + // for performance concern, if task.length === 1, just invoke + if (tasks.length === 1) { + invokeTask(tasks[0], target, event); + } + else { + // https://github.com/angular/zone.js/issues/836 + // copy the tasks array before invoke, to avoid + // the callback will remove itself or other listener + var copyTasks = tasks.slice(); + for (var i = 0; i < copyTasks.length; i++) { + if (event && event[IMMEDIATE_PROPAGATION_SYMBOL] === true) { + break; + } + invokeTask(copyTasks[i], target, event); + } + } + } }; - var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; - var blackListedEvents = Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')]; - var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { - if (returnTarget === void 0) { returnTarget = false; } - if (prepend === void 0) { prepend = false; } - return function () { - var target = this || _global; - var eventName = arguments[0]; - var delegate = arguments[1]; - if (!delegate) { - return nativeListener.apply(this, arguments); - } - if (isNode && eventName === 'uncaughtException') { - // don't patch uncaughtException of nodejs to prevent endless loop - return nativeListener.apply(this, arguments); - } - // don't create the bind delegate function for handleEvent - // case here to improve addEventListener performance - // we will create the bind delegate when invoke - var isHandleEvent = false; - if (typeof delegate !== 'function') { - if (!delegate.handleEvent) { - return nativeListener.apply(this, arguments); + function patchEventTargetMethods(obj, patchOptions) { + if (!obj) { + return false; + } + var useGlobalCallback = true; + if (patchOptions && patchOptions.useG !== undefined) { + useGlobalCallback = patchOptions.useG; + } + var validateHandler = patchOptions && patchOptions.vh; + var checkDuplicate = true; + if (patchOptions && patchOptions.chkDup !== undefined) { + checkDuplicate = patchOptions.chkDup; + } + var returnTarget = false; + if (patchOptions && patchOptions.rt !== undefined) { + returnTarget = patchOptions.rt; + } + var proto = obj; + while (proto && !proto.hasOwnProperty(ADD_EVENT_LISTENER)) { + proto = ObjectGetPrototypeOf(proto); + } + if (!proto && obj[ADD_EVENT_LISTENER]) { + // somehow we did not find it, but we can see it. This happens on IE for Window properties. + proto = obj; + } + if (!proto) { + return false; + } + if (proto[zoneSymbolAddEventListener]) { + return false; + } + var eventNameToString = patchOptions && patchOptions.eventNameToString; + // a shared global taskData to pass data for scheduleEventTask + // so we do not need to create a new object just for pass some data + var taskData = {}; + var nativeAddEventListener = proto[zoneSymbolAddEventListener] = proto[ADD_EVENT_LISTENER]; + var nativeRemoveEventListener = proto[zoneSymbol(REMOVE_EVENT_LISTENER)] = + proto[REMOVE_EVENT_LISTENER]; + var nativeListeners = proto[zoneSymbol(LISTENERS_EVENT_LISTENER)] = + proto[LISTENERS_EVENT_LISTENER]; + var nativeRemoveAllListeners = proto[zoneSymbol(REMOVE_ALL_LISTENERS_EVENT_LISTENER)] = + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER]; + var nativePrependEventListener; + if (patchOptions && patchOptions.prepend) { + nativePrependEventListener = proto[zoneSymbol(patchOptions.prepend)] = + proto[patchOptions.prepend]; + } + function checkIsPassive(task) { + if (!passiveSupported && typeof taskData.options !== 'boolean' && + typeof taskData.options !== 'undefined' && taskData.options !== null) { + // options is a non-null non-undefined object + // passive is not supported + // don't pass options as object + // just pass capture as a boolean + task.options = !!taskData.options.capture; + taskData.options = task.options; + } + } + var customScheduleGlobal = function (task) { + // if there is already a task for the eventName + capture, + // just return, because we use the shared globalZoneAwareCallback here. + if (taskData.isExisting) { + return; + } + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, taskData.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, taskData.options); + }; + var customCancelGlobal = function (task) { + // if task is not marked as isRemoved, this call is directly + // from Zone.prototype.cancelTask, we should remove the task + // from tasksList of target first + if (!task.isRemoved) { + var symbolEventNames = zoneSymbolEventNames$1[task.eventName]; + var symbolEventName = void 0; + if (symbolEventNames) { + symbolEventName = symbolEventNames[task.capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = symbolEventName && task.target[symbolEventName]; + if (existingTasks) { + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (existingTask === task) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + task.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + task.allRemoved = true; + task.target[symbolEventName] = null; + } + break; + } + } } - isHandleEvent = true; } - if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + // if all tasks for the eventName + capture have gone, + // we will really remove the global event callback, + // if not, return + if (!task.allRemoved) { return; } - var options = arguments[2]; - if (blackListedEvents) { - // check black list - for (var i = 0; i < blackListedEvents.length; i++) { - if (eventName === blackListedEvents[i]) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.capture ? globalZoneAwareCaptureCallback : globalZoneAwareCallback, task.options); + }; + var customScheduleNonGlobal = function (task) { + checkIsPassive(task); + return nativeAddEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customSchedulePrepend = function (task) { + return nativePrependEventListener.call(taskData.target, taskData.eventName, task.invoke, taskData.options); + }; + var customCancelNonGlobal = function (task) { + return nativeRemoveEventListener.call(task.target, task.eventName, task.invoke, task.options); + }; + var customSchedule = useGlobalCallback ? customScheduleGlobal : customScheduleNonGlobal; + var customCancel = useGlobalCallback ? customCancelGlobal : customCancelNonGlobal; + var compareTaskCallbackVsDelegate = function (task, delegate) { + var typeOfDelegate = typeof delegate; + return (typeOfDelegate === 'function' && task.callback === delegate) || + (typeOfDelegate === 'object' && task.originalDelegate === delegate); + }; + var compare = (patchOptions && patchOptions.diff) ? patchOptions.diff : compareTaskCallbackVsDelegate; + var blackListedEvents = Zone[zoneSymbol('BLACK_LISTED_EVENTS')]; + var makeAddListener = function (nativeListener, addSource, customScheduleFn, customCancelFn, returnTarget, prepend) { + if (returnTarget === void 0) { returnTarget = false; } + if (prepend === void 0) { prepend = false; } + return function () { + var target = this || _global; + var eventName = arguments[0]; + var delegate = arguments[1]; + if (!delegate) { + return nativeListener.apply(this, arguments); + } + if (isNode && eventName === 'uncaughtException') { + // don't patch uncaughtException of nodejs to prevent endless loop + return nativeListener.apply(this, arguments); + } + // don't create the bind delegate function for handleEvent + // case here to improve addEventListener performance + // we will create the bind delegate when invoke + var isHandleEvent = false; + if (typeof delegate !== 'function') { + if (!delegate.handleEvent) { return nativeListener.apply(this, arguments); } + isHandleEvent = true; } - } + if (validateHandler && !validateHandler(nativeListener, delegate, target, arguments)) { + return; + } + var options = arguments[2]; + if (blackListedEvents) { + // check black list + for (var i = 0; i < blackListedEvents.length; i++) { + if (eventName === blackListedEvents[i]) { + return nativeListener.apply(this, arguments); + } + } + } + var capture; + var once = false; + if (options === undefined) { + capture = false; + } + else if (options === true) { + capture = true; + } + else if (options === false) { + capture = false; + } + else { + capture = options ? !!options.capture : false; + once = options ? !!options.once : false; + } + var zone = Zone.current; + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + var symbolEventName; + if (!symbolEventNames) { + // the code is duplicate, but I just want to get some better performance + var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; + var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames$1[eventName] = {}; + zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; + symbolEventName = capture ? symbolCapture : symbol; + } + else { + symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; + } + var existingTasks = target[symbolEventName]; + var isExisting = false; + if (existingTasks) { + // already have task registered + isExisting = true; + if (checkDuplicate) { + for (var i = 0; i < existingTasks.length; i++) { + if (compare(existingTasks[i], delegate)) { + // same callback, same capture, same event name, just return + return; + } + } + } + } + else { + existingTasks = target[symbolEventName] = []; + } + var source; + var constructorName = target.constructor['name']; + var targetSource = globalSources[constructorName]; + if (targetSource) { + source = targetSource[eventName]; + } + if (!source) { + source = constructorName + addSource + + (eventNameToString ? eventNameToString(eventName) : eventName); + } + // do not create a new object as task.data to pass those things + // just use the global shared one + taskData.options = options; + if (once) { + // if addEventListener with once options, we don't pass it to + // native addEventListener, instead we keep the once setting + // and handle ourselves. + taskData.options.once = false; + } + taskData.target = target; + taskData.capture = capture; + taskData.eventName = eventName; + taskData.isExisting = isExisting; + var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; + // keep taskData into data to allow onScheduleEventTask to access the task information + if (data) { + data.taskData = taskData; + } + var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); + // should clear taskData.target to avoid memory leak + // issue, https://github.com/angular/angular/issues/20442 + taskData.target = null; + // need to clear up taskData because it is a global object + if (data) { + data.taskData = null; + } + // have to save those information to task in case + // application may call task.zone.cancelTask() directly + if (once) { + options.once = true; + } + if (!(!passiveSupported && typeof task.options === 'boolean')) { + // if not support passive, and we pass an option object + // to addEventListener, we should save the options to task + task.options = options; + } + task.target = target; + task.capture = capture; + task.eventName = eventName; + if (isHandleEvent) { + // save original delegate for compare to check duplicate + task.originalDelegate = delegate; + } + if (!prepend) { + existingTasks.push(task); + } + else { + existingTasks.unshift(task); + } + if (returnTarget) { + return target; + } + }; + }; + proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); + if (nativePrependEventListener) { + proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); + } + proto[REMOVE_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var options = arguments[2]; var capture; - var once = false; if (options === undefined) { capture = false; } @@ -1936,1540 +2016,1387 @@ function patchEventTarget(_global, apis, patchOptions) { } else { capture = options ? !!options.capture : false; - once = options ? !!options.once : false; } - var zone = Zone.current; + var delegate = arguments[1]; + if (!delegate) { + return nativeRemoveEventListener.apply(this, arguments); + } + if (validateHandler && + !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { + return; + } var symbolEventNames = zoneSymbolEventNames$1[eventName]; var symbolEventName; - if (!symbolEventNames) { - // the code is duplicate, but I just want to get some better performance - var falseEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + FALSE_STR; - var trueEventName = (eventNameToString ? eventNameToString(eventName) : eventName) + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames$1[eventName] = {}; - zoneSymbolEventNames$1[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames$1[eventName][TRUE_STR] = symbolCapture; - symbolEventName = capture ? symbolCapture : symbol; - } - else { + if (symbolEventNames) { symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; } - var existingTasks = target[symbolEventName]; - var isExisting = false; + var existingTasks = symbolEventName && target[symbolEventName]; if (existingTasks) { - // already have task registered - isExisting = true; - if (checkDuplicate) { - for (var i = 0; i < existingTasks.length; i++) { - if (compare(existingTasks[i], delegate)) { - // same callback, same capture, same event name, just return - return; + for (var i = 0; i < existingTasks.length; i++) { + var existingTask = existingTasks[i]; + if (compare(existingTask, delegate)) { + existingTasks.splice(i, 1); + // set isRemoved to data for faster invokeTask check + existingTask.isRemoved = true; + if (existingTasks.length === 0) { + // all tasks for the eventName + capture have gone, + // remove globalZoneAwareCallback and remove the task cache from target + existingTask.allRemoved = true; + target[symbolEventName] = null; } + existingTask.zone.cancelTask(existingTask); + if (returnTarget) { + return target; + } + return; } } } - else { - existingTasks = target[symbolEventName] = []; - } - var source; - var constructorName = target.constructor['name']; - var targetSource = globalSources[constructorName]; - if (targetSource) { - source = targetSource[eventName]; - } - if (!source) { - source = constructorName + addSource + - (eventNameToString ? eventNameToString(eventName) : eventName); - } - // do not create a new object as task.data to pass those things - // just use the global shared one - taskData.options = options; - if (once) { - // if addEventListener with once options, we don't pass it to - // native addEventListener, instead we keep the once setting - // and handle ourselves. - taskData.options.once = false; - } - taskData.target = target; - taskData.capture = capture; - taskData.eventName = eventName; - taskData.isExisting = isExisting; - var data = useGlobalCallback ? OPTIMIZED_ZONE_EVENT_TASK_DATA : undefined; - // keep taskData into data to allow onScheduleEventTask to access the task information - if (data) { - data.taskData = taskData; - } - var task = zone.scheduleEventTask(source, delegate, data, customScheduleFn, customCancelFn); - // should clear taskData.target to avoid memory leak - // issue, https://github.com/angular/angular/issues/20442 - taskData.target = null; - // need to clear up taskData because it is a global object - if (data) { - data.taskData = null; - } - // have to save those information to task in case - // application may call task.zone.cancelTask() directly - if (once) { - options.once = true; - } - if (!(!passiveSupported && typeof task.options === 'boolean')) { - // if not support passive, and we pass an option object - // to addEventListener, we should save the options to task - task.options = options; - } - task.target = target; - task.capture = capture; - task.eventName = eventName; - if (isHandleEvent) { - // save original delegate for compare to check duplicate - task.originalDelegate = delegate; - } - if (!prepend) { - existingTasks.push(task); - } - else { - existingTasks.unshift(task); - } - if (returnTarget) { - return target; + // issue 930, didn't find the event name or callback + // from zone kept existingTasks, the callback maybe + // added outside of zone, we need to call native removeEventListener + // to try to remove it. + return nativeRemoveEventListener.apply(this, arguments); + }; + proto[LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + var listeners = []; + var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); + for (var i = 0; i < tasks.length; i++) { + var task = tasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + listeners.push(delegate); } + return listeners; }; - }; - proto[ADD_EVENT_LISTENER] = makeAddListener(nativeAddEventListener, ADD_EVENT_LISTENER_SOURCE, customSchedule, customCancel, returnTarget); - if (nativePrependEventListener) { - proto[PREPEND_EVENT_LISTENER] = makeAddListener(nativePrependEventListener, PREPEND_EVENT_LISTENER_SOURCE, customSchedulePrepend, customCancel, returnTarget, true); - } - proto[REMOVE_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var options = arguments[2]; - var capture; - if (options === undefined) { - capture = false; - } - else if (options === true) { - capture = true; - } - else if (options === false) { - capture = false; - } - else { - capture = options ? !!options.capture : false; - } - var delegate = arguments[1]; - if (!delegate) { - return nativeRemoveEventListener.apply(this, arguments); - } - if (validateHandler && - !validateHandler(nativeRemoveEventListener, delegate, target, arguments)) { - return; - } - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - var symbolEventName; - if (symbolEventNames) { - symbolEventName = symbolEventNames[capture ? TRUE_STR : FALSE_STR]; - } - var existingTasks = symbolEventName && target[symbolEventName]; - if (existingTasks) { - for (var i = 0; i < existingTasks.length; i++) { - var existingTask = existingTasks[i]; - if (compare(existingTask, delegate)) { - existingTasks.splice(i, 1); - // set isRemoved to data for faster invokeTask check - existingTask.isRemoved = true; - if (existingTasks.length === 0) { - // all tasks for the eventName + capture have gone, - // remove globalZoneAwareCallback and remove the task cache from target - existingTask.allRemoved = true; - target[symbolEventName] = null; - } - existingTask.zone.cancelTask(existingTask); - if (returnTarget) { - return target; + proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { + var target = this || _global; + var eventName = arguments[0]; + if (!eventName) { + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + var prop = keys[i]; + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + // in nodejs EventEmitter, removeListener event is + // used for monitoring the removeListener call, + // so just keep removeListener eventListener until + // all other eventListeners are removed + if (evtName && evtName !== 'removeListener') { + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); } - return; } + // remove removeListener listener finally + this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); } - } - // issue 930, didn't find the event name or callback - // from zone kept existingTasks, the callback maybe - // added outside of zone, we need to call native removeEventListener - // to try to remove it. - return nativeRemoveEventListener.apply(this, arguments); - }; - proto[LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - var listeners = []; - var tasks = findEventTasks(target, eventNameToString ? eventNameToString(eventName) : eventName); - for (var i = 0; i < tasks.length; i++) { - var task = tasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - listeners.push(delegate); - } - return listeners; - }; - proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER] = function () { - var target = this || _global; - var eventName = arguments[0]; - if (!eventName) { - var keys = Object.keys(target); - for (var i = 0; i < keys.length; i++) { - var prop = keys[i]; - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - // in nodejs EventEmitter, removeListener event is - // used for monitoring the removeListener call, - // so just keep removeListener eventListener until - // all other eventListeners are removed - if (evtName && evtName !== 'removeListener') { - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, evtName); - } - } - // remove removeListener listener finally - this[REMOVE_ALL_LISTENERS_EVENT_LISTENER].call(this, 'removeListener'); - } - else { - var symbolEventNames = zoneSymbolEventNames$1[eventName]; - if (symbolEventNames) { - var symbolEventName = symbolEventNames[FALSE_STR]; - var symbolCaptureEventName = symbolEventNames[TRUE_STR]; - var tasks = target[symbolEventName]; - var captureTasks = target[symbolCaptureEventName]; - if (tasks) { - var removeTasks = tasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + else { + var symbolEventNames = zoneSymbolEventNames$1[eventName]; + if (symbolEventNames) { + var symbolEventName = symbolEventNames[FALSE_STR]; + var symbolCaptureEventName = symbolEventNames[TRUE_STR]; + var tasks = target[symbolEventName]; + var captureTasks = target[symbolCaptureEventName]; + if (tasks) { + var removeTasks = tasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } - } - if (captureTasks) { - var removeTasks = captureTasks.slice(); - for (var i = 0; i < removeTasks.length; i++) { - var task = removeTasks[i]; - var delegate = task.originalDelegate ? task.originalDelegate : task.callback; - this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + if (captureTasks) { + var removeTasks = captureTasks.slice(); + for (var i = 0; i < removeTasks.length; i++) { + var task = removeTasks[i]; + var delegate = task.originalDelegate ? task.originalDelegate : task.callback; + this[REMOVE_EVENT_LISTENER].call(this, eventName, delegate, task.options); + } } } } + if (returnTarget) { + return this; + } + }; + // for native toString patch + attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); + attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); + if (nativeRemoveAllListeners) { + attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); } - if (returnTarget) { - return this; + if (nativeListeners) { + attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); } - }; - // for native toString patch - attachOriginToPatched(proto[ADD_EVENT_LISTENER], nativeAddEventListener); - attachOriginToPatched(proto[REMOVE_EVENT_LISTENER], nativeRemoveEventListener); - if (nativeRemoveAllListeners) { - attachOriginToPatched(proto[REMOVE_ALL_LISTENERS_EVENT_LISTENER], nativeRemoveAllListeners); - } - if (nativeListeners) { - attachOriginToPatched(proto[LISTENERS_EVENT_LISTENER], nativeListeners); + return true; } - return true; - } - var results = []; - for (var i = 0; i < apis.length; i++) { - results[i] = patchEventTargetMethods(apis[i], patchOptions); - } - return results; -} -function findEventTasks(target, eventName) { - var foundTasks = []; - for (var prop in target) { - var match = EVENT_NAME_SYMBOL_REGX.exec(prop); - var evtName = match && match[1]; - if (evtName && (!eventName || evtName === eventName)) { - var tasks = target[prop]; - if (tasks) { - for (var i = 0; i < tasks.length; i++) { - foundTasks.push(tasks[i]); + var results = []; + for (var i = 0; i < apis.length; i++) { + results[i] = patchEventTargetMethods(apis[i], patchOptions); + } + return results; + } + function findEventTasks(target, eventName) { + var foundTasks = []; + for (var prop in target) { + var match = EVENT_NAME_SYMBOL_REGX.exec(prop); + var evtName = match && match[1]; + if (evtName && (!eventName || evtName === eventName)) { + var tasks = target[prop]; + if (tasks) { + for (var i = 0; i < tasks.length; i++) { + foundTasks.push(tasks[i]); + } } } } + return foundTasks; } - return foundTasks; -} -function patchEventPrototype(global, api) { - var Event = global['Event']; - if (Event && Event.prototype) { - api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) { return function (self, args) { - self[IMMEDIATE_PROPAGATION_SYMBOL] = true; - // we need to call the native stopImmediatePropagation - // in case in some hybrid application, some part of - // application will be controlled by zone, some are not - delegate && delegate.apply(self, 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 - */ -function patchCallbacks(api, target, targetName, method, callbacks) { - var symbol = Zone.__symbol__(method); - if (target[symbol]) { - return; + function patchEventPrototype(global, api) { + var Event = global['Event']; + if (Event && Event.prototype) { + api.patchMethod(Event.prototype, 'stopImmediatePropagation', function (delegate) { return function (self, args) { + self[IMMEDIATE_PROPAGATION_SYMBOL] = true; + // we need to call the native stopImmediatePropagation + // in case in some hybrid application, some part of + // application will be controlled by zone, some are not + delegate && delegate.apply(self, args); + }; }); + } } - var nativeDelegate = target[symbol] = target[method]; - target[method] = function (name, opts, options) { - if (opts && opts.prototype) { - callbacks.forEach(function (callback) { - var source = targetName + "." + method + "::" + callback; - var prototype = opts.prototype; - if (prototype.hasOwnProperty(callback)) { - var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); - if (descriptor && descriptor.value) { - descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); - api._redefineProperty(opts.prototype, callback, descriptor); + /** + * @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 patchCallbacks(api, target, targetName, method, callbacks) { + var symbol = Zone.__symbol__(method); + if (target[symbol]) { + return; + } + var nativeDelegate = target[symbol] = target[method]; + target[method] = function (name, opts, options) { + if (opts && opts.prototype) { + callbacks.forEach(function (callback) { + var source = targetName + "." + method + "::" + callback; + var prototype = opts.prototype; + if (prototype.hasOwnProperty(callback)) { + var descriptor = api.ObjectGetOwnPropertyDescriptor(prototype, callback); + if (descriptor && descriptor.value) { + descriptor.value = api.wrapWithCurrentZone(descriptor.value, source); + api._redefineProperty(opts.prototype, callback, descriptor); + } + else if (prototype[callback]) { + prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); + } } else if (prototype[callback]) { prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); } - } - else if (prototype[callback]) { - prototype[callback] = api.wrapWithCurrentZone(prototype[callback], source); - } - }); - } - return nativeDelegate.call(target, name, opts, options); - }; - api.attachOriginToPatched(target[method], nativeDelegate); -} - -/** - * @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 - */ -/* - * This is necessary for Chrome and Chrome mobile, to enable - * things like redefining `createdCallback` on an element. - */ -var zoneSymbol$1 = Zone.__symbol__; -var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; -var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = - Object.getOwnPropertyDescriptor; -var _create = Object.create; -var unconfigurablesKey = zoneSymbol$1('unconfigurables'); -function propertyPatch() { - Object.defineProperty = function (obj, prop, desc) { - if (isUnconfigurable(obj, prop)) { - throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); - } - var originalConfigurableFlag = desc.configurable; - if (prop !== 'prototype') { - desc = rewriteDescriptor(obj, prop, desc); - } - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); - }; - Object.defineProperties = function (obj, props) { - Object.keys(props).forEach(function (prop) { - Object.defineProperty(obj, prop, props[prop]); - }); - return obj; - }; - Object.create = function (obj, proto) { - if (typeof proto === 'object' && !Object.isFrozen(proto)) { - Object.keys(proto).forEach(function (prop) { - proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); - }); - } - return _create(obj, proto); - }; - Object.getOwnPropertyDescriptor = function (obj, prop) { - var desc = _getOwnPropertyDescriptor(obj, prop); - if (desc && isUnconfigurable(obj, prop)) { - desc.configurable = false; - } - return desc; - }; -} -function _redefineProperty(obj, prop, desc) { - var originalConfigurableFlag = desc.configurable; - desc = rewriteDescriptor(obj, prop, desc); - return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); -} -function isUnconfigurable(obj, prop) { - return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; -} -function rewriteDescriptor(obj, prop, desc) { - // issue-927, if the desc is frozen, don't try to change the desc - if (!Object.isFrozen(desc)) { - desc.configurable = true; - } - if (!desc.configurable) { - // issue-927, if the obj is frozen, don't try to set the desc to obj - if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { - _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); - } - if (obj[unconfigurablesKey]) { - obj[unconfigurablesKey][prop] = true; - } - } - return desc; -} -function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { - try { - return _defineProperty(obj, prop, desc); - } - catch (error) { - if (desc.configurable) { - // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's - // retry with the original flag value - if (typeof originalConfigurableFlag == 'undefined') { - delete desc.configurable; - } - else { - desc.configurable = originalConfigurableFlag; + }); } - try { - return _defineProperty(obj, prop, desc); + return nativeDelegate.call(target, name, opts, options); + }; + api.attachOriginToPatched(target[method], nativeDelegate); + } + /** + * @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 + */ + /* + * This is necessary for Chrome and Chrome mobile, to enable + * things like redefining `createdCallback` on an element. + */ + var zoneSymbol$1 = Zone.__symbol__; + var _defineProperty = Object[zoneSymbol$1('defineProperty')] = Object.defineProperty; + var _getOwnPropertyDescriptor = Object[zoneSymbol$1('getOwnPropertyDescriptor')] = + Object.getOwnPropertyDescriptor; + var _create = Object.create; + var unconfigurablesKey = zoneSymbol$1('unconfigurables'); + function propertyPatch() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + var originalConfigurableFlag = desc.configurable; + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); + }; + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + Object.create = function (obj, proto) { + if (typeof proto === 'object' && !Object.isFrozen(proto)) { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); } - catch (error) { - var descJson = null; - try { - descJson = JSON.stringify(desc); - } - catch (error) { - descJson = desc.toString(); - } - console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); + return _create(obj, proto); + }; + Object.getOwnPropertyDescriptor = function (obj, prop) { + var desc = _getOwnPropertyDescriptor(obj, prop); + if (desc && isUnconfigurable(obj, prop)) { + desc.configurable = false; } - } - else { - throw error; - } - } -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -var globalEventHandlersEventNames = [ - 'abort', - 'animationcancel', - 'animationend', - 'animationiteration', - 'auxclick', - 'beforeinput', - 'blur', - 'cancel', - 'canplay', - 'canplaythrough', - 'change', - 'compositionstart', - 'compositionupdate', - 'compositionend', - 'cuechange', - 'click', - 'close', - 'contextmenu', - 'curechange', - 'dblclick', - 'drag', - 'dragend', - 'dragenter', - 'dragexit', - 'dragleave', - 'dragover', - 'drop', - 'durationchange', - 'emptied', - 'ended', - 'error', - 'focus', - 'focusin', - 'focusout', - 'gotpointercapture', - 'input', - 'invalid', - 'keydown', - 'keypress', - 'keyup', - 'load', - 'loadstart', - 'loadeddata', - 'loadedmetadata', - 'lostpointercapture', - 'mousedown', - 'mouseenter', - 'mouseleave', - 'mousemove', - 'mouseout', - 'mouseover', - 'mouseup', - 'mousewheel', - 'orientationchange', - 'pause', - 'play', - 'playing', - 'pointercancel', - 'pointerdown', - 'pointerenter', - 'pointerleave', - 'pointerlockchange', - 'mozpointerlockchange', - 'webkitpointerlockerchange', - 'pointerlockerror', - 'mozpointerlockerror', - 'webkitpointerlockerror', - 'pointermove', - 'pointout', - 'pointerover', - 'pointerup', - 'progress', - 'ratechange', - 'reset', - 'resize', - 'scroll', - 'seeked', - 'seeking', - 'select', - 'selectionchange', - 'selectstart', - 'show', - 'sort', - 'stalled', - 'submit', - 'suspend', - 'timeupdate', - 'volumechange', - 'touchcancel', - 'touchmove', - 'touchstart', - 'touchend', - 'transitioncancel', - 'transitionend', - 'waiting', - 'wheel' -]; -var documentEventNames = [ - 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', - 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', - 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', - 'visibilitychange', 'resume' -]; -var windowEventNames = [ - 'absolutedeviceorientation', - 'afterinput', - 'afterprint', - 'appinstalled', - 'beforeinstallprompt', - 'beforeprint', - 'beforeunload', - 'devicelight', - 'devicemotion', - 'deviceorientation', - 'deviceorientationabsolute', - 'deviceproximity', - 'hashchange', - 'languagechange', - 'message', - 'mozbeforepaint', - 'offline', - 'online', - 'paint', - 'pageshow', - 'pagehide', - 'popstate', - 'rejectionhandled', - 'storage', - 'unhandledrejection', - 'unload', - 'userproximity', - 'vrdisplyconnected', - 'vrdisplaydisconnected', - 'vrdisplaypresentchange' -]; -var htmlElementEventNames = [ - 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', - 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', - 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' -]; -var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; -var ieElementEventNames = [ - 'activate', - 'afterupdate', - 'ariarequest', - 'beforeactivate', - 'beforedeactivate', - 'beforeeditfocus', - 'beforeupdate', - 'cellchange', - 'controlselect', - 'dataavailable', - 'datasetchanged', - 'datasetcomplete', - 'errorupdate', - 'filterchange', - 'layoutcomplete', - 'losecapture', - 'move', - 'moveend', - 'movestart', - 'propertychange', - 'resizeend', - 'resizestart', - 'rowenter', - 'rowexit', - 'rowsdelete', - 'rowsinserted', - 'command', - 'compassneedscalibration', - 'deactivate', - 'help', - 'mscontentzoom', - 'msmanipulationstatechanged', - 'msgesturechange', - 'msgesturedoubletap', - 'msgestureend', - 'msgesturehold', - 'msgesturestart', - 'msgesturetap', - 'msgotpointercapture', - 'msinertiastart', - 'mslostpointercapture', - 'mspointercancel', - 'mspointerdown', - 'mspointerenter', - 'mspointerhover', - 'mspointerleave', - 'mspointermove', - 'mspointerout', - 'mspointerover', - 'mspointerup', - 'pointerout', - 'mssitemodejumplistitemremoved', - 'msthumbnailclick', - 'stop', - 'storagecommit' -]; -var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; -var formEventNames = ['autocomplete', 'autocompleteerror']; -var detailEventNames = ['toggle']; -var frameEventNames = ['load']; -var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; -var marqueeEventNames = ['bounce', 'finish', 'start']; -var XMLHttpRequestEventNames = [ - 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', - 'readystatechange' -]; -var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; -var websocketEventNames = ['close', 'error', 'open', 'message']; -var workerEventNames = ['error', 'message']; -var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); -function filterProperties(target, onProperties, ignoreProperties) { - if (!ignoreProperties || ignoreProperties.length === 0) { - return onProperties; - } - var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); - if (!tip || tip.length === 0) { - return onProperties; - } - var targetIgnoreProperties = tip[0].ignoreProperties; - return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); -} -function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { - // check whether target is available, sometimes target will be undefined - // because different browser or some 3rd party plugin. - if (!target) { - return; + return desc; + }; } - var filteredProperties = filterProperties(target, onProperties, ignoreProperties); - patchOnProperties(target, filteredProperties, prototype); -} -function propertyDescriptorPatch(api, _global) { - if (isNode && !isMix) { - return; + function _redefineProperty(obj, prop, desc) { + var originalConfigurableFlag = desc.configurable; + desc = rewriteDescriptor(obj, prop, desc); + return _tryDefineProperty(obj, prop, desc, originalConfigurableFlag); } - if (Zone[api.symbol('patchEvents')]) { - // events are already been patched by legacy patch. - return; + function isUnconfigurable(obj, prop) { + return obj && obj[unconfigurablesKey] && obj[unconfigurablesKey][prop]; } - var supportsWebSocket = typeof WebSocket !== 'undefined'; - var ignoreProperties = _global['__Zone_ignore_on_properties']; - // for browsers that we can patch the descriptor: Chrome & Firefox - if (isBrowser) { - var internalWindow = window; - var ignoreErrorProperties = isIE ? [{ target: internalWindow, ignoreProperties: ['error'] }] : []; - // in IE/Edge, onProp not exist in window object, but in WindowPrototype - // so we need to pass WindowPrototype to check onProp exist or not - patchFilteredProperties(internalWindow, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow)); - patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); - if (typeof internalWindow['SVGElement'] !== 'undefined') { - patchFilteredProperties(internalWindow['SVGElement'].prototype, eventNames, ignoreProperties); - } - patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); - patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); - patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); - patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); - patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); - var HTMLMarqueeElement_1 = internalWindow['HTMLMarqueeElement']; - if (HTMLMarqueeElement_1) { - patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); - } - var Worker_1 = internalWindow['Worker']; - if (Worker_1) { - patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + function rewriteDescriptor(obj, prop, desc) { + // issue-927, if the desc is frozen, don't try to change the desc + if (!Object.isFrozen(desc)) { + desc.configurable = true; } - } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (XMLHttpRequest) { - // XMLHttpRequest is not available in ServiceWorker, so we need to check here - patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget) { - patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); - } - if (typeof IDBIndex !== 'undefined') { - patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); - patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); - } - if (supportsWebSocket) { - patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); - } -} - -/** - * @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.__load_patch('util', function (global, Zone, api) { - api.patchOnProperties = patchOnProperties; - api.patchMethod = patchMethod; - api.bindArguments = bindArguments; - api.patchMacroTask = patchMacroTask; - // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to - // define which events will not be patched by `Zone.js`. - // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep - // the name consistent with angular repo. - // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for - // backwards compatibility. - var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); - var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); - if (global[SYMBOL_UNPATCHED_EVENTS]) { - global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; - } - if (global[SYMBOL_BLACK_LISTED_EVENTS]) { - Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = - global[SYMBOL_BLACK_LISTED_EVENTS]; - } - api.patchEventPrototype = patchEventPrototype; - api.patchEventTarget = patchEventTarget; - api.isIEOrEdge = isIEOrEdge; - api.ObjectDefineProperty = ObjectDefineProperty; - api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; - api.ObjectCreate = ObjectCreate; - api.ArraySlice = ArraySlice; - api.patchClass = patchClass; - api.wrapWithCurrentZone = wrapWithCurrentZone; - api.filterProperties = filterProperties; - api.attachOriginToPatched = attachOriginToPatched; - api._redefineProperty = _redefineProperty; - api.patchCallbacks = patchCallbacks; - api.getGlobalObjects = function () { return ({ - globalSources: globalSources, - zoneSymbolEventNames: zoneSymbolEventNames$1, - eventNames: eventNames, - isBrowser: isBrowser, - isMix: isMix, - isNode: isNode, - TRUE_STR: TRUE_STR, - FALSE_STR: FALSE_STR, - ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, - ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, - REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR - }); }; -}); - -/** - * @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 - */ - -/** - * @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 eventTargetLegacyPatch(_global, api) { - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - 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,WebSocket' - .split(','); - var EVENT_TARGET = 'EventTarget'; - var apis = []; - var isWtf = _global['wtf']; - var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); - if (isWtf) { - // Workaround for: https://github.com/google/tracing-framework/issues/555 - apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); - } - else if (_global[EVENT_TARGET]) { - apis.push(EVENT_TARGET); - } - else { - // Note: EventTarget is not available in all browsers, - // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget - apis = NO_EVENT_TARGET; - } - var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; - var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; - var ieOrEdge = api.isIEOrEdge(); - var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; - var FUNCTION_WRAPPER = '[object FunctionWrapper]'; - var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - // predefine all task.source string - for (var i = 0; i < WTF_ISSUE_555.length; i++) { - var target = WTF_ISSUE_555_ARRAY[i]; - var targets = globalSources[target] = {}; - for (var j = 0; j < eventNames.length; j++) { - var eventName = eventNames[j]; - targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + if (!desc.configurable) { + // issue-927, if the obj is frozen, don't try to set the desc to obj + if (!obj[unconfigurablesKey] && !Object.isFrozen(obj)) { + _defineProperty(obj, unconfigurablesKey, { writable: true, value: {} }); + } + if (obj[unconfigurablesKey]) { + obj[unconfigurablesKey][prop] = true; + } } + return desc; } - var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { - if (!isDisableIECheck && ieOrEdge) { - if (isEnableCrossContextCheck) { + function _tryDefineProperty(obj, prop, desc, originalConfigurableFlag) { + try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + if (desc.configurable) { + // In case of errors, when the configurable flag was likely set by rewriteDescriptor(), let's + // retry with the original flag value + if (typeof originalConfigurableFlag == 'undefined') { + delete desc.configurable; + } + else { + desc.configurable = originalConfigurableFlag; + } try { + return _defineProperty(obj, prop, desc); + } + catch (error) { + var descJson = null; + try { + descJson = JSON.stringify(desc); + } + catch (error) { + descJson = desc.toString(); + } + console.log("Attempting to configure '" + prop + "' with descriptor '" + descJson + "' on object '" + obj + "' and got error, giving up: " + error); + } + } + else { + throw error; + } + } + } + /** + * @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 globalEventHandlersEventNames = [ + 'abort', + 'animationcancel', + 'animationend', + 'animationiteration', + 'auxclick', + 'beforeinput', + 'blur', + 'cancel', + 'canplay', + 'canplaythrough', + 'change', + 'compositionstart', + 'compositionupdate', + 'compositionend', + 'cuechange', + 'click', + 'close', + 'contextmenu', + 'curechange', + 'dblclick', + 'drag', + 'dragend', + 'dragenter', + 'dragexit', + 'dragleave', + 'dragover', + 'drop', + 'durationchange', + 'emptied', + 'ended', + 'error', + 'focus', + 'focusin', + 'focusout', + 'gotpointercapture', + 'input', + 'invalid', + 'keydown', + 'keypress', + 'keyup', + 'load', + 'loadstart', + 'loadeddata', + 'loadedmetadata', + 'lostpointercapture', + 'mousedown', + 'mouseenter', + 'mouseleave', + 'mousemove', + 'mouseout', + 'mouseover', + 'mouseup', + 'mousewheel', + 'orientationchange', + 'pause', + 'play', + 'playing', + 'pointercancel', + 'pointerdown', + 'pointerenter', + 'pointerleave', + 'pointerlockchange', + 'mozpointerlockchange', + 'webkitpointerlockerchange', + 'pointerlockerror', + 'mozpointerlockerror', + 'webkitpointerlockerror', + 'pointermove', + 'pointout', + 'pointerover', + 'pointerup', + 'progress', + 'ratechange', + 'reset', + 'resize', + 'scroll', + 'seeked', + 'seeking', + 'select', + 'selectionchange', + 'selectstart', + 'show', + 'sort', + 'stalled', + 'submit', + 'suspend', + 'timeupdate', + 'volumechange', + 'touchcancel', + 'touchmove', + 'touchstart', + 'touchend', + 'transitioncancel', + 'transitionend', + 'waiting', + 'wheel' + ]; + var documentEventNames = [ + 'afterscriptexecute', 'beforescriptexecute', 'DOMContentLoaded', 'freeze', 'fullscreenchange', + 'mozfullscreenchange', 'webkitfullscreenchange', 'msfullscreenchange', 'fullscreenerror', + 'mozfullscreenerror', 'webkitfullscreenerror', 'msfullscreenerror', 'readystatechange', + 'visibilitychange', 'resume' + ]; + var windowEventNames = [ + 'absolutedeviceorientation', + 'afterinput', + 'afterprint', + 'appinstalled', + 'beforeinstallprompt', + 'beforeprint', + 'beforeunload', + 'devicelight', + 'devicemotion', + 'deviceorientation', + 'deviceorientationabsolute', + 'deviceproximity', + 'hashchange', + 'languagechange', + 'message', + 'mozbeforepaint', + 'offline', + 'online', + 'paint', + 'pageshow', + 'pagehide', + 'popstate', + 'rejectionhandled', + 'storage', + 'unhandledrejection', + 'unload', + 'userproximity', + 'vrdisplyconnected', + 'vrdisplaydisconnected', + 'vrdisplaypresentchange' + ]; + var htmlElementEventNames = [ + 'beforecopy', 'beforecut', 'beforepaste', 'copy', 'cut', 'paste', 'dragstart', 'loadend', + 'animationstart', 'search', 'transitionrun', 'transitionstart', 'webkitanimationend', + 'webkitanimationiteration', 'webkitanimationstart', 'webkittransitionend' + ]; + var mediaElementEventNames = ['encrypted', 'waitingforkey', 'msneedkey', 'mozinterruptbegin', 'mozinterruptend']; + var ieElementEventNames = [ + 'activate', + 'afterupdate', + 'ariarequest', + 'beforeactivate', + 'beforedeactivate', + 'beforeeditfocus', + 'beforeupdate', + 'cellchange', + 'controlselect', + 'dataavailable', + 'datasetchanged', + 'datasetcomplete', + 'errorupdate', + 'filterchange', + 'layoutcomplete', + 'losecapture', + 'move', + 'moveend', + 'movestart', + 'propertychange', + 'resizeend', + 'resizestart', + 'rowenter', + 'rowexit', + 'rowsdelete', + 'rowsinserted', + 'command', + 'compassneedscalibration', + 'deactivate', + 'help', + 'mscontentzoom', + 'msmanipulationstatechanged', + 'msgesturechange', + 'msgesturedoubletap', + 'msgestureend', + 'msgesturehold', + 'msgesturestart', + 'msgesturetap', + 'msgotpointercapture', + 'msinertiastart', + 'mslostpointercapture', + 'mspointercancel', + 'mspointerdown', + 'mspointerenter', + 'mspointerhover', + 'mspointerleave', + 'mspointermove', + 'mspointerout', + 'mspointerover', + 'mspointerup', + 'pointerout', + 'mssitemodejumplistitemremoved', + 'msthumbnailclick', + 'stop', + 'storagecommit' + ]; + var webglEventNames = ['webglcontextrestored', 'webglcontextlost', 'webglcontextcreationerror']; + var formEventNames = ['autocomplete', 'autocompleteerror']; + var detailEventNames = ['toggle']; + var frameEventNames = ['load']; + var frameSetEventNames = ['blur', 'error', 'focus', 'load', 'resize', 'scroll', 'messageerror']; + var marqueeEventNames = ['bounce', 'finish', 'start']; + var XMLHttpRequestEventNames = [ + 'loadstart', 'progress', 'abort', 'error', 'load', 'progress', 'timeout', 'loadend', + 'readystatechange' + ]; + var IDBIndexEventNames = ['upgradeneeded', 'complete', 'abort', 'success', 'error', 'blocked', 'versionchange', 'close']; + var websocketEventNames = ['close', 'error', 'open', 'message']; + var workerEventNames = ['error', 'message']; + var eventNames = globalEventHandlersEventNames.concat(webglEventNames, formEventNames, detailEventNames, documentEventNames, windowEventNames, htmlElementEventNames, ieElementEventNames); + function filterProperties(target, onProperties, ignoreProperties) { + if (!ignoreProperties || ignoreProperties.length === 0) { + return onProperties; + } + var tip = ignoreProperties.filter(function (ip) { return ip.target === target; }); + if (!tip || tip.length === 0) { + return onProperties; + } + var targetIgnoreProperties = tip[0].ignoreProperties; + return onProperties.filter(function (op) { return targetIgnoreProperties.indexOf(op) === -1; }); + } + function patchFilteredProperties(target, onProperties, ignoreProperties, prototype) { + // check whether target is available, sometimes target will be undefined + // because different browser or some 3rd party plugin. + if (!target) { + return; + } + var filteredProperties = filterProperties(target, onProperties, ignoreProperties); + patchOnProperties(target, filteredProperties, prototype); + } + function propertyDescriptorPatch(api, _global) { + if (isNode && !isMix) { + return; + } + if (Zone[api.symbol('patchEvents')]) { + // events are already been patched by legacy patch. + return; + } + var supportsWebSocket = typeof WebSocket !== 'undefined'; + var ignoreProperties = _global['__Zone_ignore_on_properties']; + // for browsers that we can patch the descriptor: Chrome & Firefox + if (isBrowser) { + var internalWindow_1 = window; + var ignoreErrorProperties = isIE ? [{ target: internalWindow_1, ignoreProperties: ['error'] }] : []; + // in IE/Edge, onProp not exist in window object, but in WindowPrototype + // so we need to pass WindowPrototype to check onProp exist or not + patchFilteredProperties(internalWindow_1, eventNames.concat(['messageerror']), ignoreProperties ? ignoreProperties.concat(ignoreErrorProperties) : ignoreProperties, ObjectGetPrototypeOf(internalWindow_1)); + patchFilteredProperties(Document.prototype, eventNames, ignoreProperties); + if (typeof internalWindow_1['SVGElement'] !== 'undefined') { + patchFilteredProperties(internalWindow_1['SVGElement'].prototype, eventNames, ignoreProperties); + } + patchFilteredProperties(Element.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLElement.prototype, eventNames, ignoreProperties); + patchFilteredProperties(HTMLMediaElement.prototype, mediaElementEventNames, ignoreProperties); + patchFilteredProperties(HTMLFrameSetElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLBodyElement.prototype, windowEventNames.concat(frameSetEventNames), ignoreProperties); + patchFilteredProperties(HTMLFrameElement.prototype, frameEventNames, ignoreProperties); + patchFilteredProperties(HTMLIFrameElement.prototype, frameEventNames, ignoreProperties); + var HTMLMarqueeElement_1 = internalWindow_1['HTMLMarqueeElement']; + if (HTMLMarqueeElement_1) { + patchFilteredProperties(HTMLMarqueeElement_1.prototype, marqueeEventNames, ignoreProperties); + } + var Worker_1 = internalWindow_1['Worker']; + if (Worker_1) { + patchFilteredProperties(Worker_1.prototype, workerEventNames, ignoreProperties); + } + } + var XMLHttpRequest = _global['XMLHttpRequest']; + if (XMLHttpRequest) { + // XMLHttpRequest is not available in ServiceWorker, so we need to check here + patchFilteredProperties(XMLHttpRequest.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + var XMLHttpRequestEventTarget = _global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget) { + patchFilteredProperties(XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype, XMLHttpRequestEventNames, ignoreProperties); + } + if (typeof IDBIndex !== 'undefined') { + patchFilteredProperties(IDBIndex.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBOpenDBRequest.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBDatabase.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBTransaction.prototype, IDBIndexEventNames, ignoreProperties); + patchFilteredProperties(IDBCursor.prototype, IDBIndexEventNames, ignoreProperties); + } + if (supportsWebSocket) { + patchFilteredProperties(WebSocket.prototype, websocketEventNames, ignoreProperties); + } + } + /** + * @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.__load_patch('util', function (global, Zone, api) { + api.patchOnProperties = patchOnProperties; + api.patchMethod = patchMethod; + api.bindArguments = bindArguments; + api.patchMacroTask = patchMacroTask; + // In earlier version of zone.js (<0.9.0), we use env name `__zone_symbol__BLACK_LISTED_EVENTS` to + // define which events will not be patched by `Zone.js`. + // In newer version (>=0.9.0), we change the env name to `__zone_symbol__UNPATCHED_EVENTS` to keep + // the name consistent with angular repo. + // The `__zone_symbol__BLACK_LISTED_EVENTS` is deprecated, but it is still be supported for + // backwards compatibility. + var SYMBOL_BLACK_LISTED_EVENTS = Zone.__symbol__('BLACK_LISTED_EVENTS'); + var SYMBOL_UNPATCHED_EVENTS = Zone.__symbol__('UNPATCHED_EVENTS'); + if (global[SYMBOL_UNPATCHED_EVENTS]) { + global[SYMBOL_BLACK_LISTED_EVENTS] = global[SYMBOL_UNPATCHED_EVENTS]; + } + if (global[SYMBOL_BLACK_LISTED_EVENTS]) { + Zone[SYMBOL_BLACK_LISTED_EVENTS] = Zone[SYMBOL_UNPATCHED_EVENTS] = + global[SYMBOL_BLACK_LISTED_EVENTS]; + } + api.patchEventPrototype = patchEventPrototype; + api.patchEventTarget = patchEventTarget; + api.isIEOrEdge = isIEOrEdge; + api.ObjectDefineProperty = ObjectDefineProperty; + api.ObjectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; + api.ObjectCreate = ObjectCreate; + api.ArraySlice = ArraySlice; + api.patchClass = patchClass; + api.wrapWithCurrentZone = wrapWithCurrentZone; + api.filterProperties = filterProperties; + api.attachOriginToPatched = attachOriginToPatched; + api._redefineProperty = _redefineProperty; + api.patchCallbacks = patchCallbacks; + api.getGlobalObjects = function () { return ({ + globalSources: globalSources, + zoneSymbolEventNames: zoneSymbolEventNames$1, + eventNames: eventNames, + isBrowser: isBrowser, + isMix: isMix, + isNode: isNode, + TRUE_STR: TRUE_STR, + FALSE_STR: FALSE_STR, + ZONE_SYMBOL_PREFIX: ZONE_SYMBOL_PREFIX, + ADD_EVENT_LISTENER_STR: ADD_EVENT_LISTENER_STR, + REMOVE_EVENT_LISTENER_STR: REMOVE_EVENT_LISTENER_STR + }); }; + }); + /** + * @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 + */ + /** + * @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 eventTargetLegacyPatch(_global, api) { + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, globalSources = _a.globalSources, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + 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,WebSocket' + .split(','); + var EVENT_TARGET = 'EventTarget'; + var apis = []; + var isWtf = _global['wtf']; + var WTF_ISSUE_555_ARRAY = WTF_ISSUE_555.split(','); + if (isWtf) { + // Workaround for: https://github.com/google/tracing-framework/issues/555 + apis = WTF_ISSUE_555_ARRAY.map(function (v) { return 'HTML' + v + 'Element'; }).concat(NO_EVENT_TARGET); + } + else if (_global[EVENT_TARGET]) { + apis.push(EVENT_TARGET); + } + else { + // Note: EventTarget is not available in all browsers, + // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget + apis = NO_EVENT_TARGET; + } + var isDisableIECheck = _global['__Zone_disable_IE_check'] || false; + var isEnableCrossContextCheck = _global['__Zone_enable_cross_context_check'] || false; + var ieOrEdge = api.isIEOrEdge(); + var ADD_EVENT_LISTENER_SOURCE = '.addEventListener:'; + var FUNCTION_WRAPPER = '[object FunctionWrapper]'; + var BROWSER_TOOLS = 'function __BROWSERTOOLS_CONSOLE_SAFEFUNC() { [native code] }'; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + // predefine all task.source string + for (var i = 0; i < WTF_ISSUE_555.length; i++) { + var target = WTF_ISSUE_555_ARRAY[i]; + var targets = globalSources[target] = {}; + for (var j = 0; j < eventNames.length; j++) { + var eventName = eventNames[j]; + targets[eventName] = target + ADD_EVENT_LISTENER_SOURCE + eventName; + } + } + var checkIEAndCrossContext = function (nativeDelegate, delegate, target, args) { + if (!isDisableIECheck && ieOrEdge) { + if (isEnableCrossContextCheck) { + try { + var testString = delegate.toString(); + if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { + nativeDelegate.apply(target, args); + return false; + } + } + catch (error) { + nativeDelegate.apply(target, args); + return false; + } + } + else { var testString = delegate.toString(); if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { nativeDelegate.apply(target, args); return false; } } + } + else if (isEnableCrossContextCheck) { + try { + delegate.toString(); + } catch (error) { nativeDelegate.apply(target, args); return false; } } + return true; + }; + var apiTypes = []; + for (var i = 0; i < apis.length; i++) { + var type = _global[apis[i]]; + apiTypes.push(type && type.prototype); + } + // vh is validateHandler to check event handler + // is valid or not(for security check) + api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); + Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; + return true; + } + /** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + // we have to patch the instance since the proto is non-configurable + function apply(api, _global) { + var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; + var WS = _global.WebSocket; + // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener + // On older Chrome, no need since EventTarget was already patched + if (!_global.EventTarget) { + api.patchEventTarget(_global, [WS.prototype]); + } + _global.WebSocket = function (x, y) { + var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); + var proxySocket; + var proxySocketProto; + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = api.ObjectCreate(socket); + // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' + // but proxySocket not, so we will keep socket as prototype and pass it to + // patchOnProperties method + proxySocketProto = socket; + [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { + proxySocket[propName] = function () { + var args = api.ArraySlice.call(arguments); + if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { + var eventName = args.length > 0 ? args[0] : undefined; + if (eventName) { + var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); + socket[propertySymbol] = proxySocket[propertySymbol]; + } + } + return socket[propName].apply(socket, args); + }; + }); + } else { - var testString = delegate.toString(); - if ((testString === FUNCTION_WRAPPER || testString == BROWSER_TOOLS)) { - nativeDelegate.apply(target, args); - return false; - } + // we can patch the real socket + proxySocket = socket; } + api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); + return proxySocket; + }; + var globalWebSocket = _global['WebSocket']; + for (var prop in WS) { + globalWebSocket[prop] = WS[prop]; + } + } + /** + * @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 propertyDescriptorLegacyPatch(api, _global) { + var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; + if (isNode && !isMix) { + return; } - else if (isEnableCrossContextCheck) { - try { - delegate.toString(); - } - catch (error) { - nativeDelegate.apply(target, args); + if (!canPatchViaPropertyDescriptor(api, _global)) { + var supportsWebSocket = typeof WebSocket !== 'undefined'; + // Safari, Android browsers (Jelly Bean) + patchViaCapturingAllTheEvents(api); + api.patchClass('XMLHttpRequest'); + if (supportsWebSocket) { + apply(api, _global); + } + Zone[api.symbol('patchEvents')] = true; + } + } + function canPatchViaPropertyDescriptor(api, _global) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((isBrowser || isMix) && + !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && + typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) return false; + // try to use onclick to detect whether we can patch via propertyDescriptor + // because XMLHttpRequest is not available in service worker + if (desc) { + api.ObjectDefineProperty(Element.prototype, 'onclick', { + enumerable: true, + configurable: true, + get: function () { + return true; + } + }); + var div = document.createElement('div'); + var result = !!div.onclick; + api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + return result; } } - return true; - }; - var apiTypes = []; - for (var i = 0; i < apis.length; i++) { - var type = _global[apis[i]]; - apiTypes.push(type && type.prototype); - } - // vh is validateHandler to check event handler - // is valid or not(for security check) - api.patchEventTarget(_global, apiTypes, { vh: checkIEAndCrossContext }); - Zone[api.symbol('patchEventTarget')] = !!_global[EVENT_TARGET]; - return true; -} - -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -// we have to patch the instance since the proto is non-configurable -function apply(api, _global) { - var _a = api.getGlobalObjects(), ADD_EVENT_LISTENER_STR = _a.ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR = _a.REMOVE_EVENT_LISTENER_STR; - var WS = _global.WebSocket; - // On Safari window.EventTarget doesn't exist so need to patch WS add/removeEventListener - // On older Chrome, no need since EventTarget was already patched - if (!_global.EventTarget) { - api.patchEventTarget(_global, [WS.prototype]); - } - _global.WebSocket = function (x, y) { - var socket = arguments.length > 1 ? new WS(x, y) : new WS(x); - var proxySocket; - var proxySocketProto; - // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance - var onmessageDesc = api.ObjectGetOwnPropertyDescriptor(socket, 'onmessage'); - if (onmessageDesc && onmessageDesc.configurable === false) { - proxySocket = api.ObjectCreate(socket); - // socket have own property descriptor 'onopen', 'onmessage', 'onclose', 'onerror' - // but proxySocket not, so we will keep socket as prototype and pass it to - // patchOnProperties method - proxySocketProto = socket; - [ADD_EVENT_LISTENER_STR, REMOVE_EVENT_LISTENER_STR, 'send', 'close'].forEach(function (propName) { - proxySocket[propName] = function () { - var args = api.ArraySlice.call(arguments); - if (propName === ADD_EVENT_LISTENER_STR || propName === REMOVE_EVENT_LISTENER_STR) { - var eventName = args.length > 0 ? args[0] : undefined; - if (eventName) { - var propertySymbol = Zone.__symbol__('ON_PROPERTY' + eventName); - socket[propertySymbol] = proxySocket[propertySymbol]; - } - } - return socket[propName].apply(socket, args); - }; + var XMLHttpRequest = _global['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return false; + } + var ON_READY_STATE_CHANGE = 'onreadystatechange'; + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); + // add enumerable and configurable here because in opera + // by default XMLHttpRequest.prototype.onreadystatechange is undefined + // without adding enumerable and configurable will cause onreadystatechange + // non-configurable + // and if XMLHttpRequest.prototype.onreadystatechange is undefined, + // we should set a real desc instead a fake one + if (xhrDesc) { + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { + enumerable: true, + configurable: true, + get: function () { + return true; + } }); + var req = new XMLHttpRequest(); + var result = !!req.onreadystatechange; + // restore original desc + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); + return result; } else { - // we can patch the real socket - proxySocket = socket; - } - api.patchOnProperties(proxySocket, ['close', 'error', 'message', 'open'], proxySocketProto); - return proxySocket; - }; - var globalWebSocket = _global['WebSocket']; - for (var prop in WS) { - globalWebSocket[prop] = WS[prop]; - } -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {globalThis} - */ -function propertyDescriptorLegacyPatch(api, _global) { - var _a = api.getGlobalObjects(), isNode = _a.isNode, isMix = _a.isMix; - if (isNode && !isMix) { - return; - } - if (!canPatchViaPropertyDescriptor(api, _global)) { - var supportsWebSocket = typeof WebSocket !== 'undefined'; - // Safari, Android browsers (Jelly Bean) - patchViaCapturingAllTheEvents(api); - api.patchClass('XMLHttpRequest'); - if (supportsWebSocket) { - apply(api, _global); - } - Zone[api.symbol('patchEvents')] = true; - } -} -function canPatchViaPropertyDescriptor(api, _global) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((isBrowser || isMix) && - !api.ObjectGetOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && - typeof Element !== 'undefined') { - // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 - // IDL interface attributes are not configurable - var desc = api.ObjectGetOwnPropertyDescriptor(Element.prototype, 'onclick'); - if (desc && !desc.configurable) - return false; - // try to use onclick to detect whether we can patch via propertyDescriptor - // because XMLHttpRequest is not available in service worker - if (desc) { - api.ObjectDefineProperty(Element.prototype, 'onclick', { + var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); + api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { enumerable: true, configurable: true, get: function () { - return true; + return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; + }, + set: function (value) { + this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; } }); - var div = document.createElement('div'); - var result = !!div.onclick; - api.ObjectDefineProperty(Element.prototype, 'onclick', desc); + var req = new XMLHttpRequest(); + var detectFunc = function () { }; + req.onreadystatechange = detectFunc; + var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = null; return result; } } - var XMLHttpRequest = _global['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker - return false; - } - var ON_READY_STATE_CHANGE = 'onreadystatechange'; - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - var xhrDesc = api.ObjectGetOwnPropertyDescriptor(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE); - // add enumerable and configurable here because in opera - // by default XMLHttpRequest.prototype.onreadystatechange is undefined - // without adding enumerable and configurable will cause onreadystatechange - // non-configurable - // and if XMLHttpRequest.prototype.onreadystatechange is undefined, - // we should set a real desc instead a fake one - if (xhrDesc) { - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return true; - } - }); - var req = new XMLHttpRequest(); - var result = !!req.onreadystatechange; - // restore original desc - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, xhrDesc || {}); - return result; - } - else { - var SYMBOL_FAKE_ONREADYSTATECHANGE_1 = api.symbol('fake'); - api.ObjectDefineProperty(XMLHttpRequestPrototype, ON_READY_STATE_CHANGE, { - enumerable: true, - configurable: true, - get: function () { - return this[SYMBOL_FAKE_ONREADYSTATECHANGE_1]; - }, - set: function (value) { - this[SYMBOL_FAKE_ONREADYSTATECHANGE_1] = value; - } - }); - var req = new XMLHttpRequest(); - var detectFunc = function () { }; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; - req.onreadystatechange = null; - return result; - } -} -// Whenever any eventListener fires, we check the eventListener target and all parents -// for `onwhatever` properties and replace them with zone-bound functions -// - Chrome (for now) -function patchViaCapturingAllTheEvents(api) { - var eventNames = api.getGlobalObjects().eventNames; - var unboundKey = api.symbol('unbound'); - var _loop_1 = function (i) { - var property = eventNames[i]; - var onproperty = 'on' + property; - self.addEventListener(property, function (event) { - var elt = event.target, bound, source; - if (elt) { - source = elt.constructor['name'] + '.' + onproperty; - } - else { - source = 'unknown.' + onproperty; - } - while (elt) { - if (elt[onproperty] && !elt[onproperty][unboundKey]) { - bound = api.wrapWithCurrentZone(elt[onproperty], source); - bound[unboundKey] = elt[onproperty]; - elt[onproperty] = bound; + // Whenever any eventListener fires, we check the eventListener target and all parents + // for `onwhatever` properties and replace them with zone-bound functions + // - Chrome (for now) + function patchViaCapturingAllTheEvents(api) { + var eventNames = api.getGlobalObjects().eventNames; + var unboundKey = api.symbol('unbound'); + var _loop_4 = function (i) { + var property = eventNames[i]; + var onproperty = 'on' + property; + self.addEventListener(property, function (event) { + var elt = event.target, bound, source; + if (elt) { + source = elt.constructor['name'] + '.' + onproperty; } - elt = elt.parentElement; - } - }, true); - }; - for (var i = 0; i < eventNames.length; i++) { - _loop_1(i); - } -} - -/** - * @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, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { - return; - } - var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -(function (_global) { - _global['__zone_symbol__legacyPatch'] = function () { - var Zone = _global['Zone']; - Zone.__load_patch('registerElement', function (global, Zone, api) { - registerElementPatch(global, api); - }); - Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { - eventTargetLegacyPatch(global, api); - propertyDescriptorLegacyPatch(api, global); - }); - }; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -var taskSymbol = zoneSymbol('zoneTask'); -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; - function timer() { - try { - task.invoke.apply(this, arguments); - } - finally { - // issue-934, task will be cancelled - // even it is a periodic task such as - // setInterval - if (!(task.data && task.data.isPeriodic)) { - if (typeof data.handleId === 'number') { - // in non-nodejs env, we remove timerId - // from local cache - delete tasksByHandleId[data.handleId]; + else { + source = 'unknown.' + onproperty; + } + while (elt) { + if (elt[onproperty] && !elt[onproperty][unboundKey]) { + bound = api.wrapWithCurrentZone(elt[onproperty], source); + bound[unboundKey] = elt[onproperty]; + elt[onproperty] = bound; } - else if (data.handleId) { - // Node returns complex objects as handleIds - // we remove task reference from timer object - data.handleId[taskSymbol] = null; + elt = elt.parentElement; + } + }, true); + }; + for (var i = 0; i < eventNames.length; i++) { + _loop_4(i); + } + } + /** + * @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, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !('registerElement' in _global.document)) { + return; + } + var callbacks = ['createdCallback', 'attachedCallback', 'detachedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, document, 'Document', 'registerElement', callbacks); + } + /** + * @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) { + _global[Zone.__symbol__('legacyPatch')] = function () { + var Zone = _global['Zone']; + Zone.__load_patch('registerElement', function (global, Zone, api) { + registerElementPatch(global, api); + }); + Zone.__load_patch('EventTargetLegacy', function (global, Zone, api) { + eventTargetLegacyPatch(global, api); + propertyDescriptorLegacyPatch(api, global); + }); + }; + })(typeof window !== 'undefined' ? + window : + typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}); + /** + * @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 taskSymbol = zoneSymbol('zoneTask'); + 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; + function timer() { + try { + task.invoke.apply(this, arguments); + } + finally { + // issue-934, task will be cancelled + // even it is a periodic task such as + // setInterval + if (!(task.data && task.data.isPeriodic)) { + if (typeof data.handleId === 'number') { + // in non-nodejs env, we remove timerId + // from local cache + delete tasksByHandleId[data.handleId]; + } + else if (data.handleId) { + // Node returns complex objects as handleIds + // we remove task reference from timer object + data.handleId[taskSymbol] = null; + } } } } + data.args[0] = timer; + data.handleId = setNative.apply(window, data.args); + return task; } - data.args[0] = timer; - 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 options = { - isPeriodic: nameSuffix === 'Interval', - delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : - undefined, - args: args - }; - var task = scheduleMacroTaskWithCurrentZone(setName, args[0], options, scheduleTask, clearTask); - if (!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 options = { + isPeriodic: nameSuffix === 'Interval', + delay: (nameSuffix === 'Timeout' || nameSuffix === 'Interval') ? args[1] || 0 : + undefined, + args: args + }; + var task = scheduleMacroTaskWithCurrentZone(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 (typeof handle === 'number') { + // for non nodejs env, we save handleId: task + // mapping in local cache for clearTimeout + tasksByHandleId[handle] = task; + } + else if (handle) { + // for nodejs env, we save task + // reference in timerId Object for clearTimeout + handle[taskSymbol] = task; + } + // check whether handle is null, because some polyfill or browser + // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame + if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && + typeof handle.unref === 'function') { + task.ref = handle.ref.bind(handle); + task.unref = handle.unref.bind(handle); + } + if (typeof handle === 'number' || handle) { + return handle; + } return task; } - // Node.js must additionally support the ref and unref functions. - var handle = task.data.handleId; - if (typeof handle === 'number') { - // for non nodejs env, we save handleId: task - // mapping in local cache for clearTimeout - tasksByHandleId[handle] = task; - } - else if (handle) { - // for nodejs env, we save task - // reference in timerId Object for clearTimeout - handle[taskSymbol] = task; - } - // check whether handle is null, because some polyfill or browser - // may return undefined from setTimeout/setInterval/setImmediate/requestAnimationFrame - if (handle && handle.ref && handle.unref && typeof handle.ref === 'function' && - typeof handle.unref === 'function') { - task.ref = handle.ref.bind(handle); - task.unref = handle.unref.bind(handle); - } - if (typeof handle === 'number' || handle) { - return 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 id = args[0]; - var task; - if (typeof id === 'number') { - // non nodejs env. - task = tasksByHandleId[id]; - } - else { - // nodejs env. - task = id && id[taskSymbol]; - // other environments. - if (!task) { - task = id; + else { + // cause an error by calling it directly. + return delegate.apply(window, args); + } + }; }); + clearNative = + patchMethod(window, cancelName, function (delegate) { return function (self, args) { + var id = args[0]; + var task; + if (typeof id === 'number') { + // non nodejs env. + task = tasksByHandleId[id]; } - } - if (task && typeof task.type === 'string') { - if (task.state !== 'notScheduled' && - (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { - if (typeof id === 'number') { - delete tasksByHandleId[id]; + else { + // nodejs env. + task = id && id[taskSymbol]; + // other environments. + if (!task) { + task = id; } - else if (id) { - id[taskSymbol] = null; + } + if (task && typeof task.type === 'string') { + if (task.state !== 'notScheduled' && + (task.cancelFn && task.data.isPeriodic || task.runCount === 0)) { + if (typeof id === 'number') { + delete tasksByHandleId[id]; + } + else if (id) { + id[taskSymbol] = null; + } + // Do not cancel already canceled functions + task.zone.cancelTask(task); } - // 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 - */ -function patchCustomElements(_global, api) { - var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; - if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { - return; - } - var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; - api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); -} - -/** - * @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 eventTargetPatch(_global, api) { - if (Zone[api.symbol('patchEventTarget')]) { - // EventTarget is already patched. - return; - } - var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; - // predefine all __zone_symbol__ + eventName + true/false string - for (var i = 0; i < eventNames.length; i++) { - var eventName = eventNames[i]; - var falseEventName = eventName + FALSE_STR; - var trueEventName = eventName + TRUE_STR; - var symbol = ZONE_SYMBOL_PREFIX + falseEventName; - var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; - zoneSymbolEventNames[eventName] = {}; - zoneSymbolEventNames[eventName][FALSE_STR] = symbol; - zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; - } - var EVENT_TARGET = _global['EventTarget']; - if (!EVENT_TARGET || !EVENT_TARGET.prototype) { - return; - } - api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); - return true; -} -function patchEvent$1(global, api) { - api.patchEventPrototype(global, api); -} - -/** - * @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 - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ -Zone.__load_patch('legacy', function (global) { - var legacyPatch = global[Zone.__symbol__('legacyPatch')]; - if (legacyPatch) { - legacyPatch(); - } -}); -Zone.__load_patch('timers', function (global) { - var set = 'set'; - var clear = 'clear'; - patchTimer(global, set, clear, 'Timeout'); - patchTimer(global, set, clear, 'Interval'); - patchTimer(global, set, clear, 'Immediate'); -}); -Zone.__load_patch('requestAnimationFrame', function (global) { - patchTimer(global, 'request', 'cancel', 'AnimationFrame'); - patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); - patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); -}); -Zone.__load_patch('blocking', function (global, Zone) { - var blockingMethods = ['alert', 'prompt', 'confirm']; - for (var i = 0; i < blockingMethods.length; i++) { - var name_1 = blockingMethods[i]; - patchMethod(global, name_1, function (delegate, symbol, name) { - return function (s, args) { - return Zone.current.run(delegate, global, args, name); - }; - }); - } -}); -Zone.__load_patch('EventTarget', function (global, Zone, api) { - patchEvent$1(global, api); - eventTargetPatch(global, api); - // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener - var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { - api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); - } - patchClass('MutationObserver'); - patchClass('WebKitMutationObserver'); - patchClass('IntersectionObserver'); - patchClass('FileReader'); -}); -Zone.__load_patch('on_property', function (global, Zone, api) { - propertyDescriptorPatch(api, global); - propertyPatch(); -}); -Zone.__load_patch('customElements', function (global, Zone, api) { - patchCustomElements(global, api); -}); -Zone.__load_patch('XHR', function (global, Zone) { - // Treat XMLHttpRequest as a macrotask. - patchXHR(global); - var XHR_TASK = zoneSymbol('xhrTask'); - var XHR_SYNC = zoneSymbol('xhrSync'); - var XHR_LISTENER = zoneSymbol('xhrListener'); - var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); - var XHR_URL = zoneSymbol('xhrURL'); - var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); - function patchXHR(window) { - var XMLHttpRequest = window['XMLHttpRequest']; - if (!XMLHttpRequest) { - // XMLHttpRequest is not available in service worker + 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 + */ + function patchCustomElements(_global, api) { + var _a = api.getGlobalObjects(), isBrowser = _a.isBrowser, isMix = _a.isMix; + if ((!isBrowser && !isMix) || !_global['customElements'] || !('customElements' in _global)) { return; } - var XMLHttpRequestPrototype = XMLHttpRequest.prototype; - function findPendingTask(target) { - return target[XHR_TASK]; + var callbacks = ['connectedCallback', 'disconnectedCallback', 'adoptedCallback', 'attributeChangedCallback']; + api.patchCallbacks(api, _global.customElements, 'customElements', 'define', callbacks); + } + /** + * @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 eventTargetPatch(_global, api) { + if (Zone[api.symbol('patchEventTarget')]) { + // EventTarget is already patched. + return; } - var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - if (!oriAddListener) { - var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; - if (XMLHttpRequestEventTarget_1) { - var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; - oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; - } + var _a = api.getGlobalObjects(), eventNames = _a.eventNames, zoneSymbolEventNames = _a.zoneSymbolEventNames, TRUE_STR = _a.TRUE_STR, FALSE_STR = _a.FALSE_STR, ZONE_SYMBOL_PREFIX = _a.ZONE_SYMBOL_PREFIX; + // predefine all __zone_symbol__ + eventName + true/false string + for (var i = 0; i < eventNames.length; i++) { + var eventName = eventNames[i]; + var falseEventName = eventName + FALSE_STR; + var trueEventName = eventName + TRUE_STR; + var symbol = ZONE_SYMBOL_PREFIX + falseEventName; + var symbolCapture = ZONE_SYMBOL_PREFIX + trueEventName; + zoneSymbolEventNames[eventName] = {}; + zoneSymbolEventNames[eventName][FALSE_STR] = symbol; + zoneSymbolEventNames[eventName][TRUE_STR] = symbolCapture; + } + var EVENT_TARGET = _global['EventTarget']; + if (!EVENT_TARGET || !EVENT_TARGET.prototype) { + return; } - var READY_STATE_CHANGE = 'readystatechange'; - var SCHEDULED = 'scheduled'; - function scheduleTask(task) { - var data = task.data; - var target = data.target; - target[XHR_SCHEDULED] = false; - target[XHR_ERROR_BEFORE_SCHEDULED] = false; - // remove existing event listener - var listener = target[XHR_LISTENER]; - if (!oriAddListener) { - oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; - oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + api.patchEventTarget(_global, [EVENT_TARGET && EVENT_TARGET.prototype]); + return true; + } + function patchEvent(global, api) { + api.patchEventPrototype(global, api); + } + /** + * @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.__load_patch('legacy', function (global) { + var legacyPatch = global[Zone.__symbol__('legacyPatch')]; + if (legacyPatch) { + legacyPatch(); + } + }); + Zone.__load_patch('timers', function (global) { + var set = 'set'; + var clear = 'clear'; + patchTimer(global, set, clear, 'Timeout'); + patchTimer(global, set, clear, 'Interval'); + patchTimer(global, set, clear, 'Immediate'); + }); + Zone.__load_patch('requestAnimationFrame', function (global) { + patchTimer(global, 'request', 'cancel', 'AnimationFrame'); + patchTimer(global, 'mozRequest', 'mozCancel', 'AnimationFrame'); + patchTimer(global, 'webkitRequest', 'webkitCancel', 'AnimationFrame'); + }); + Zone.__load_patch('blocking', function (global, Zone) { + var blockingMethods = ['alert', 'prompt', 'confirm']; + for (var i = 0; i < blockingMethods.length; i++) { + var name_2 = blockingMethods[i]; + patchMethod(global, name_2, function (delegate, symbol, name) { + return function (s, args) { + return Zone.current.run(delegate, global, args, name); + }; + }); + } + }); + Zone.__load_patch('EventTarget', function (global, Zone, api) { + patchEvent(global, api); + eventTargetPatch(global, api); + // patch XMLHttpRequestEventTarget's addEventListener/removeEventListener + var XMLHttpRequestEventTarget = global['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget && XMLHttpRequestEventTarget.prototype) { + api.patchEventTarget(global, [XMLHttpRequestEventTarget.prototype]); + } + patchClass('MutationObserver'); + patchClass('WebKitMutationObserver'); + patchClass('IntersectionObserver'); + patchClass('FileReader'); + }); + Zone.__load_patch('on_property', function (global, Zone, api) { + propertyDescriptorPatch(api, global); + propertyPatch(); + }); + Zone.__load_patch('customElements', function (global, Zone, api) { + patchCustomElements(global, api); + }); + Zone.__load_patch('XHR', function (global, Zone) { + // Treat XMLHttpRequest as a macrotask. + patchXHR(global); + var XHR_TASK = zoneSymbol('xhrTask'); + var XHR_SYNC = zoneSymbol('xhrSync'); + var XHR_LISTENER = zoneSymbol('xhrListener'); + var XHR_SCHEDULED = zoneSymbol('xhrScheduled'); + var XHR_URL = zoneSymbol('xhrURL'); + var XHR_ERROR_BEFORE_SCHEDULED = zoneSymbol('xhrErrorBeforeScheduled'); + function patchXHR(window) { + var XMLHttpRequest = window['XMLHttpRequest']; + if (!XMLHttpRequest) { + // XMLHttpRequest is not available in service worker + return; } - if (listener) { - oriRemoveListener.call(target, READY_STATE_CHANGE, listener); - } - var newListener = target[XHR_LISTENER] = function () { - if (target.readyState === target.DONE) { - // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with - // readyState=4 multiple times, so we need to check task state here - if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { - // check whether the xhr has registered onload listener - // if that is the case, the task should invoke after all - // onload listeners finish. - var loadTasks = target['__zone_symbol__loadfalse']; - if (loadTasks && loadTasks.length > 0) { - var oriInvoke_1 = task.invoke; - task.invoke = function () { - // need to load the tasks again, because in other - // load listener, they may remove themselves - var loadTasks = target['__zone_symbol__loadfalse']; - for (var i = 0; i < loadTasks.length; i++) { - if (loadTasks[i] === task) { - loadTasks.splice(i, 1); + var XMLHttpRequestPrototype = XMLHttpRequest.prototype; + function findPendingTask(target) { + return target[XHR_TASK]; + } + var oriAddListener = XMLHttpRequestPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + var oriRemoveListener = XMLHttpRequestPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + if (!oriAddListener) { + var XMLHttpRequestEventTarget_1 = window['XMLHttpRequestEventTarget']; + if (XMLHttpRequestEventTarget_1) { + var XMLHttpRequestEventTargetPrototype = XMLHttpRequestEventTarget_1.prototype; + oriAddListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = XMLHttpRequestEventTargetPrototype[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + } + var READY_STATE_CHANGE = 'readystatechange'; + var SCHEDULED = 'scheduled'; + function scheduleTask(task) { + var data = task.data; + var target = data.target; + target[XHR_SCHEDULED] = false; + target[XHR_ERROR_BEFORE_SCHEDULED] = false; + // remove existing event listener + var listener = target[XHR_LISTENER]; + if (!oriAddListener) { + oriAddListener = target[ZONE_SYMBOL_ADD_EVENT_LISTENER]; + oriRemoveListener = target[ZONE_SYMBOL_REMOVE_EVENT_LISTENER]; + } + if (listener) { + oriRemoveListener.call(target, READY_STATE_CHANGE, listener); + } + var newListener = target[XHR_LISTENER] = function () { + if (target.readyState === target.DONE) { + // sometimes on some browsers XMLHttpRequest will fire onreadystatechange with + // readyState=4 multiple times, so we need to check task state here + if (!data.aborted && target[XHR_SCHEDULED] && task.state === SCHEDULED) { + // check whether the xhr has registered onload listener + // if that is the case, the task should invoke after all + // onload listeners finish. + var loadTasks = target[Zone.__symbol__('loadfalse')]; + if (loadTasks && loadTasks.length > 0) { + var oriInvoke_1 = task.invoke; + task.invoke = function () { + // need to load the tasks again, because in other + // load listener, they may remove themselves + var loadTasks = target[Zone.__symbol__('loadfalse')]; + for (var i = 0; i < loadTasks.length; i++) { + if (loadTasks[i] === task) { + loadTasks.splice(i, 1); + } } - } - if (!data.aborted && task.state === SCHEDULED) { - oriInvoke_1.call(task); - } - }; - loadTasks.push(task); + if (!data.aborted && task.state === SCHEDULED) { + oriInvoke_1.call(task); + } + }; + loadTasks.push(task); + } + else { + task.invoke(); + } } - else { - task.invoke(); + else if (!data.aborted && target[XHR_SCHEDULED] === false) { + // error occurs when xhr.send() + target[XHR_ERROR_BEFORE_SCHEDULED] = true; } } - else if (!data.aborted && target[XHR_SCHEDULED] === false) { - // error occurs when xhr.send() - target[XHR_ERROR_BEFORE_SCHEDULED] = true; - } + }; + oriAddListener.call(target, READY_STATE_CHANGE, newListener); + var storedTask = target[XHR_TASK]; + if (!storedTask) { + target[XHR_TASK] = task; } - }; - oriAddListener.call(target, READY_STATE_CHANGE, newListener); - var storedTask = target[XHR_TASK]; - if (!storedTask) { - target[XHR_TASK] = task; - } - sendNative.apply(target, data.args); - target[XHR_SCHEDULED] = true; - return task; - } - function placeholderCallback() { } - function clearTask(task) { - var data = task.data; - // Note - ideally, we would call data.target.removeEventListener here, but it's too late - // to prevent it from firing. So instead, we store info for the event listener. - data.aborted = true; - return abortNative.apply(data.target, data.args); - } - var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { - self[XHR_SYNC] = args[2] == false; - self[XHR_URL] = args[1]; - return openNative.apply(self, args); - }; }); - var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; - var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); - var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); - var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { - if (Zone.current[fetchTaskScheduling] === true) { - // a fetch is scheduling, so we are using xhr to polyfill fetch - // and because we already schedule macroTask for fetch, we should - // not schedule a macroTask for xhr again - return sendNative.apply(self, args); - } - if (self[XHR_SYNC]) { - // if the XHR is sync there is no task to schedule, just execute the code. - return sendNative.apply(self, args); + sendNative.apply(target, data.args); + target[XHR_SCHEDULED] = true; + return task; } - else { - var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; - var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); - if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && - task.state === SCHEDULED) { - // xhr request throw error when send - // we should invoke task instead of leaving a scheduled - // pending macroTask - task.invoke(); + function placeholderCallback() { } + function clearTask(task) { + var data = task.data; + // Note - ideally, we would call data.target.removeEventListener here, but it's too late + // to prevent it from firing. So instead, we store info for the event listener. + data.aborted = true; + return abortNative.apply(data.target, data.args); + } + var openNative = patchMethod(XMLHttpRequestPrototype, 'open', function () { return function (self, args) { + self[XHR_SYNC] = args[2] == false; + self[XHR_URL] = args[1]; + return openNative.apply(self, args); + }; }); + var XMLHTTPREQUEST_SOURCE = 'XMLHttpRequest.send'; + var fetchTaskAborting = zoneSymbol('fetchTaskAborting'); + var fetchTaskScheduling = zoneSymbol('fetchTaskScheduling'); + var sendNative = patchMethod(XMLHttpRequestPrototype, 'send', function () { return function (self, args) { + if (Zone.current[fetchTaskScheduling] === true) { + // a fetch is scheduling, so we are using xhr to polyfill fetch + // and because we already schedule macroTask for fetch, we should + // not schedule a macroTask for xhr again + return sendNative.apply(self, args); + } + if (self[XHR_SYNC]) { + // if the XHR is sync there is no task to schedule, just execute the code. + return sendNative.apply(self, args); } - } - }; }); - var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { - var task = findPendingTask(self); - if (task && typeof task.type == 'string') { - // If the XHR has already completed, do nothing. - // If the XHR has already been aborted, do nothing. - // Fix #569, call abort multiple times before done will cause - // macroTask task count be negative number - if (task.cancelFn == null || (task.data && task.data.aborted)) { - return; + else { + var options = { target: self, url: self[XHR_URL], isPeriodic: false, args: args, aborted: false }; + var task = scheduleMacroTaskWithCurrentZone(XMLHTTPREQUEST_SOURCE, placeholderCallback, options, scheduleTask, clearTask); + if (self && self[XHR_ERROR_BEFORE_SCHEDULED] === true && !options.aborted && + task.state === SCHEDULED) { + // xhr request throw error when send + // we should invoke task instead of leaving a scheduled + // pending macroTask + task.invoke(); + } } - task.zone.cancelTask(task); - } - else if (Zone.current[fetchTaskAborting] === true) { - // the abort is called from fetch polyfill, we need to call native abort of XHR. - return abortNative.apply(self, args); - } - // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no - // task - // to cancel. Do nothing. - }; }); - } -}); -Zone.__load_patch('geolocation', function (global) { - /// GEO_LOCATION - if (global['navigator'] && global['navigator'].geolocation) { - patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); - } -}); -Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { - // handle unhandled promise rejection - function findPromiseRejectionHandler(evtName) { - return function (e) { - var eventTasks = findEventTasks(global, evtName); - eventTasks.forEach(function (eventTask) { - // windows has added unhandledrejection event listener - // trigger the event listener - var PromiseRejectionEvent = global['PromiseRejectionEvent']; - if (PromiseRejectionEvent) { - var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); - eventTask.invoke(evt); + }; }); + var abortNative = patchMethod(XMLHttpRequestPrototype, 'abort', function () { return function (self, args) { + var task = findPendingTask(self); + if (task && typeof task.type == 'string') { + // If the XHR has already completed, do nothing. + // If the XHR has already been aborted, do nothing. + // Fix #569, call abort multiple times before done will cause + // macroTask task count be negative number + if (task.cancelFn == null || (task.data && task.data.aborted)) { + return; + } + task.zone.cancelTask(task); } - }); - }; - } - if (global['PromiseRejectionEvent']) { - Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = - findPromiseRejectionHandler('unhandledrejection'); - Zone[zoneSymbol('rejectionHandledHandler')] = - findPromiseRejectionHandler('rejectionhandled'); - } -}); - -/** - * @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 - */ - -}))); + else if (Zone.current[fetchTaskAborting] === true) { + // the abort is called from fetch polyfill, we need to call native abort of XHR. + return abortNative.apply(self, args); + } + // Otherwise, we are trying to abort an XHR which has not yet been sent, so there is no + // task + // to cancel. Do nothing. + }; }); + } + }); + Zone.__load_patch('geolocation', function (global) { + /// GEO_LOCATION + if (global['navigator'] && global['navigator'].geolocation) { + patchPrototype(global['navigator'].geolocation, ['getCurrentPosition', 'watchPosition']); + } + }); + Zone.__load_patch('PromiseRejectionEvent', function (global, Zone) { + // handle unhandled promise rejection + function findPromiseRejectionHandler(evtName) { + return function (e) { + var eventTasks = findEventTasks(global, evtName); + eventTasks.forEach(function (eventTask) { + // windows has added unhandledrejection event listener + // trigger the event listener + var PromiseRejectionEvent = global['PromiseRejectionEvent']; + if (PromiseRejectionEvent) { + var evt = new PromiseRejectionEvent(evtName, { promise: e.promise, reason: e.rejection }); + eventTask.invoke(evt); + } + }); + }; + } + if (global['PromiseRejectionEvent']) { + Zone[zoneSymbol('unhandledPromiseRejectionHandler')] = + findPromiseRejectionHandler('unhandledrejection'); + Zone[zoneSymbol('rejectionHandledHandler')] = + findPromiseRejectionHandler('rejectionhandled'); + } + }); + /** + * @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 + */ +})); +//# sourceMappingURL=zone-rollup.umd.js.map diff --git a/dist/zone.js.d.ts b/dist/zone.js.d.ts old mode 100644 new mode 100755 index 8a033d536..f051f1cd4 --- a/dist/zone.js.d.ts +++ b/dist/zone.js.d.ts @@ -5,6 +5,7 @@ * 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 'global' variable * @fileoverview @@ -284,6 +285,8 @@ interface ZoneType { * Return the root zone. */ root: Zone; + /** Was @ internal but this prevents compiling tests as separate unit */ + __symbol__(name: string): string; } interface UncaughtPromiseError extends Error { zone: Zone; diff --git a/dist/zone.min.js b/dist/zone.min.js old mode 100644 new mode 100755 index 5709b6db5..23bf054d1 --- a/dist/zone.min.js +++ b/dist/zone.min.js @@ -1 +1,150 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";!function(e){var t=e.performance;function n(e){t&&t.mark&&t.mark(e)}function r(e,n){t&&t.measure&&t.measure(e,n)}n("Zone");var o=!0===e.__zone_symbol__forceDuplicateZoneCheck;if(e.Zone){if(o||"function"!=typeof e.Zone.__symbol__)throw new Error("Zone already loaded.");return e.Zone}var a,i=function(){function t(e,t){this._parent=e,this._name=t?t.name||"unnamed":"",this._properties=t&&t.properties||{},this._zoneDelegate=new s(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==P.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return Z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return j},enumerable:!0,configurable:!0}),t.__load_patch=function(a,i){if(P.hasOwnProperty(a)){if(o)throw Error("Already loaded patch: "+a)}else if(!e["__Zone_disable_"+a]){var c="Zone:"+a;n(c),P[a]=i(e,t,D),r(c,c)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){Z={parent:Z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{Z=Z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),Z={parent:Z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{Z=Z.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");if(e.state!==_||e.type!==S&&e.type!==O){var r=e.state!=k;r&&e._transitionTo(k,b),e.runCount++;var o=j;j=e,Z={parent:Z,zone:this};try{e.type==O&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==_&&e.state!==E&&(e.type==S||e.data&&e.data.isPeriodic?r&&e._transitionTo(b,k):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(_,k,_))),Z=Z.parent,j=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(m,_);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(E,m,_),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==m&&e._transitionTo(b,m),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new l(w,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new l(O,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new l(S,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||y).name+"; Execution: "+this.name+")");e._transitionTo(T,b,k);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(E,T),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(_,T),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e};this.hasTask(this.zone,a)}},e}(),l=function(){function t(n,r,o,a,i,c){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=c,this.callback=o;var s=this;n===S&&a&&a.useG?this.invoke=t.invokeTask:this.invoke=function(){return t.invokeTask.call(e,s,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),z++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==z&&g(),z--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(_,m)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==_&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),u=I("setTimeout"),f=I("Promise"),p=I("then"),h=[],d=!1;function v(t){if(0===z&&0===h.length)if(a||e[f]&&(a=e[f].resolve(0)),a){var n=a[p];n||(n=a.then),n.call(a,g)}else e[u](g,0);t&&h.push(t)}function g(){if(!d){for(d=!0;h.length;){var e=h;h=[];for(var t=0;t=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}};Zone.__load_patch("ZoneAwarePromise",function(t,n,r){var o=Object.getOwnPropertyDescriptor,a=Object.defineProperty;var i=r.symbol,c=[],s=i("Promise"),l=i("then"),u="__creationTrace__";r.onUnhandledError=function(e){if(r.showUncaughtError()){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)}},r.microtaskDrainDone=function(){for(;c.length;)for(var e=function(){var e=c.shift();try{e.zone.runGuarded(function(){throw e})}catch(e){p(e)}};c.length;)e()};var f=i("unhandledPromiseRejectionHandler");function p(e){r.onUnhandledError(e);try{var t=n[f];t&&"function"==typeof t&&t.call(this,e)}catch(e){}}function h(e){return e&&e.then}function d(e){return e}function v(e){return R.reject(e)}var g=i("state"),y=i("value"),_=i("finally"),m=i("parentPromiseValue"),b=i("parentPromiseState"),k="Promise.then",T=null,E=!0,w=!1,O=0;function S(e,t){return function(n){try{j(e,t,n)}catch(t){j(e,!1,t)}}}var P=function(){var e=!1;return function(t){return function(){e||(e=!0,t.apply(null,arguments))}}},D="Promise resolved with itself",Z=i("currentTaskTrace");function j(e,t,o){var i=P();if(e===o)throw new TypeError(D);if(e[g]===T){var s=null;try{"object"!=typeof o&&"function"!=typeof o||(s=o&&o.then)}catch(t){return i(function(){j(e,!1,t)})(),e}if(t!==w&&o instanceof R&&o.hasOwnProperty(g)&&o.hasOwnProperty(y)&&o[g]!==T)C(o),j(e,o[g],o[y]);else if(t!==w&&"function"==typeof s)try{s.call(o,i(S(e,t)),i(S(e,!1)))}catch(t){i(function(){j(e,!1,t)})()}else{e[g]=t;var l=e[y];if(e[y]=o,e[_]===_&&t===E&&(e[g]=e[b],e[y]=e[m]),t===w&&o instanceof Error){var f=n.currentTask&&n.currentTask.data&&n.currentTask.data[u];f&&a(o,Z,{configurable:!0,enumerable:!1,writable:!0,value:f})}for(var p=0;p=0;n--)"function"==typeof e[n]&&(e[n]=h(e[n],t+"_"+n));return e}function T(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var E="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,w=!("nw"in _)&&void 0!==_.process&&"[object process]"==={}.toString.call(_.process),O=!w&&!E&&!(!g||!y.HTMLElement),S=void 0!==_.process&&"[object process]"==={}.toString.call(_.process)&&!E&&!(!g||!y.HTMLElement),P={},D=function(e){if(e=e||_.event){var t=P[e.type];t||(t=P[e.type]=v("ON_PROPERTY"+e.type));var n,r=this||e.target||_,o=r[t];if(O&&r===y&&"error"===e.type){var a=e;!0===(n=o&&o.call(this,a.message,a.filename,a.lineno,a.colno,a.error))&&e.preventDefault()}else null==(n=o&&o.apply(this,arguments))||n||e.preventDefault();return n}};function Z(e,r,o){var a=t(e,r);!a&&o&&(t(o,r)&&(a={enumerable:!0,configurable:!0}));if(a&&a.configurable){var i=v("on"+r+"patched");if(!e.hasOwnProperty(i)||!e[i]){delete a.writable,delete a.value;var c=a.get,s=a.set,l=r.substr(2),u=P[l];u||(u=P[l]=v("ON_PROPERTY"+l)),a.set=function(t){var n=this;(n||e!==_||(n=_),n)&&(n[u]&&n.removeEventListener(l,D),s&&s.apply(n,b),"function"==typeof t?(n[u]=t,n.addEventListener(l,D,!1)):n[u]=null)},a.get=function(){var t=this;if(t||e!==_||(t=_),!t)return null;var n=t[u];if(n)return n;if(c){var o=c&&c.call(this);if(o)return a.set.call(this,o),"function"==typeof t[m]&&t.removeAttribute(r),o}return null},n(e,r,a),e[i]=!0}}}function j(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?d(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function M(e,t){e[v("OriginalDelegate")]=t}var x=!1,N=!1;function F(){try{var e=y.navigator.userAgent;if(-1!==e.indexOf("MSIE ")||-1!==e.indexOf("Trident/"))return!0}catch(e){}return!1}function H(){if(x)return N;x=!0;try{var e=y.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(N=!0)}catch(e){}return N}Zone.__load_patch("toString",function(e){var t=Function.prototype.toString,n=v("OriginalDelegate"),r=v("Promise"),o=v("Error"),a=function(){if("function"==typeof this){var a=this[n];if(a)return"function"==typeof a?t.call(a):Object.prototype.toString.call(a);if(this===Promise){var i=e[r];if(i)return t.call(i)}if(this===Error){var c=e[o];if(c)return t.call(c)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}});var A=!1;if("undefined"!=typeof window)try{var B=Object.defineProperty({},"passive",{get:function(){A=!0}});window.addEventListener("test",B,B),window.removeEventListener("test",B,B)}catch(e){A=!1}var G={useG:!0},W={},q={},U=/^__zone_symbol__(\w+)(true|false)$/,X="__zone_symbol__propagationStopped";function V(e,t,n){var o=n&&n.add||i,a=n&&n.rm||c,s=n&&n.listeners||"eventListeners",l=n&&n.rmAll||"removeAllListeners",h=v(o),d="."+o+":",g="prependListener",y="."+g+":",_=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;if(o&&"object"==typeof o&&o.once){var i=e.originalDelegate?e.originalDelegate:e.callback;t[a].call(t,n.type,i,o)}}},m=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[W[t.type][f]];if(r)if(1===r.length)_(r[0],n,t);else for(var o=r.slice(),a=0;a1?new a(t,n):new a(t),l=e.ObjectGetOwnPropertyDescriptor(s,"onmessage");return l&&!1===l.configurable?(i=e.ObjectCreate(s),c=s,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var c=Zone.__symbol__("ON_PROPERTY"+a);s[c]=i[c]}}return s[t].apply(s,n)}})):i=s,e.patchOnProperties(i,["close","error","message","open"],c),i};var i=t.WebSocket;for(var c in a)i[c]=a[c]}(e,t),Zone[e.symbol("patchEvents")]=!0}}Zone.__load_patch("util",function(e,r,s){s.patchOnProperties=j,s.patchMethod=R,s.bindArguments=k,s.patchMacroTask=L;var l=r.__symbol__("BLACK_LISTED_EVENTS"),d=r.__symbol__("UNPATCHED_EVENTS");e[d]&&(e[l]=e[d]),e[l]&&(r[l]=r[d]=e[l]),s.patchEventPrototype=K,s.patchEventTarget=V,s.isIEOrEdge=H,s.ObjectDefineProperty=n,s.ObjectGetOwnPropertyDescriptor=t,s.ObjectCreate=o,s.ArraySlice=a,s.patchClass=C,s.wrapWithCurrentZone=h,s.filterProperties=ye,s.attachOriginToPatched=M,s._redefineProperty=re,s.patchCallbacks=J,s.getGlobalObjects=function(){return{globalSources:q,zoneSymbolEventNames:W,eventNames:ge,isBrowser:O,isMix:S,isNode:w,TRUE_STR:u,FALSE_STR:f,ZONE_SYMBOL_PREFIX:p,ADD_EVENT_LISTENER_STR:i,REMOVE_EVENT_LISTENER_STR:c}}}),function(e){e.__zone_symbol__legacyPatch=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function(e,t){var n=t.getGlobalObjects(),r=n.isBrowser,o=n.isMix;(r||o)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])}(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){be(e,n),ke(n,e)})}}("undefined"!=typeof window&&window||"undefined"!=typeof self&&self||global);var Te=v("zoneTask");function Ee(e,t,n,r){var o=null,a=null;n+=r;var i={};function c(t){var n=t.data;return n.args[0]=function(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[Te]=null))}},n.handleId=o.apply(e,n.args),t}function s(e){return a(e.data.handleId)}o=R(e,t+=r,function(n){return function(o,a){if("function"==typeof a[0]){var l={isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?a[1]||0:void 0,args:a},u=d(t,a[0],l,c,s);if(!u)return u;var f=u.data.handleId;return"number"==typeof f?i[f]=u:f&&(f[Te]=u),f&&f.ref&&f.unref&&"function"==typeof f.ref&&"function"==typeof f.unref&&(u.ref=f.ref.bind(f),u.unref=f.unref.bind(f)),"number"==typeof f||f?f:u}return n.apply(e,a)}}),a=R(e,n,function(t){return function(n,r){var o,a=r[0];"number"==typeof a?o=i[a]:(o=a&&a[Te])||(o=a),o&&"string"==typeof o.type?"notScheduled"!==o.state&&(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&("number"==typeof a?delete i[a]:a&&(a[Te]=null),o.zone.cancelTask(o)):t.apply(e,r)}})}function we(e,t){if(!Zone[t.symbol("patchEventTarget")]){for(var n=t.getGlobalObjects(),r=n.eventNames,o=n.zoneSymbolEventNames,a=n.TRUE_STR,i=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,s=0;s0){var o=e.invoke;e.invoke=function(){for(var n=r.__zone_symbol__loadfalse,a=0;a",this._properties=t&&t.properties||{},this._zoneDelegate=new l(this,this._parent&&this._parent._zoneDelegate,t)}return t.assertZonePatched=function(){if(e.Promise!==Z.ZoneAwarePromise)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(t,"root",{get:function(){for(var e=t.current;e.parent;)e=e.parent;return e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"current",{get:function(){return z.zone},enumerable:!0,configurable:!0}),Object.defineProperty(t,"currentTask",{get:function(){return C},enumerable:!0,configurable:!0}),t.__load_patch=function(o,a){if(Z.hasOwnProperty(o)){if(i)throw Error("Already loaded patch: "+o)}else if(!e["__Zone_disable_"+o]){var c="Zone:"+o;n(c),Z[o]=a(e,t,j),r(c,c)}},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.get=function(e){var t=this.getZoneWith(e);if(t)return t._properties[e]},t.prototype.getZoneWith=function(e){for(var t=this;t;){if(t._properties.hasOwnProperty(e))return t;t=t._parent}return null},t.prototype.fork=function(e){if(!e)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,e)},t.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)}},t.prototype.run=function(e,t,n,r){z={parent:z,zone:this};try{return this._zoneDelegate.invoke(this,e,t,n,r)}finally{z=z.parent}},t.prototype.runGuarded=function(e,t,n,r){void 0===t&&(t=null),z={parent:z,zone:this};try{try{return this._zoneDelegate.invoke(this,e,t,n,r)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{z=z.parent}},t.prototype.runTask=function(e,t,n){if(e.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(e.zone||_).name+"; Execution: "+this.name+")");if(e.state!==b||e.type!==D&&e.type!==P){var r=e.state!=E;r&&e._transitionTo(E,T),e.runCount++;var o=C;C=e,z={parent:z,zone:this};try{e.type==P&&e.data&&!e.data.isPeriodic&&(e.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,e,t,n)}catch(e){if(this._zoneDelegate.handleError(this,e))throw e}}finally{e.state!==b&&e.state!==O&&(e.type==D||e.data&&e.data.isPeriodic?r&&e._transitionTo(T,E):(e.runCount=0,this._updateTaskCount(e,-1),r&&e._transitionTo(b,E,b))),z=z.parent,C=o}}},t.prototype.scheduleTask=function(e){if(e.zone&&e.zone!==this)for(var t=this;t;){if(t===e.zone)throw Error("can not reschedule task to "+this.name+" which is descendants of the original zone "+e.zone.name);t=t.parent}e._transitionTo(k,b);var n=[];e._zoneDelegates=n,e._zone=this;try{e=this._zoneDelegate.scheduleTask(this,e)}catch(t){throw e._transitionTo(O,k,b),this._zoneDelegate.handleError(this,t),t}return e._zoneDelegates===n&&this._updateTaskCount(e,1),e.state==k&&e._transitionTo(T,k),e},t.prototype.scheduleMicroTask=function(e,t,n,r){return this.scheduleTask(new f(S,e,t,n,r,void 0))},t.prototype.scheduleMacroTask=function(e,t,n,r,o){return this.scheduleTask(new f(P,e,t,n,r,o))},t.prototype.scheduleEventTask=function(e,t,n,r,o){return this.scheduleTask(new f(D,e,t,n,r,o))},t.prototype.cancelTask=function(e){if(e.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(e.zone||_).name+"; Execution: "+this.name+")");e._transitionTo(w,T,E);try{this._zoneDelegate.cancelTask(this,e)}catch(t){throw e._transitionTo(O,w),this._zoneDelegate.handleError(this,t),t}return this._updateTaskCount(e,-1),e._transitionTo(b,w),e.runCount=0,e},t.prototype._updateTaskCount=function(e,t){var n=e._zoneDelegates;-1==t&&(e._zoneDelegates=null);for(var r=0;r0,macroTask:n.macroTask>0,eventTask:n.eventTask>0,change:e})},e}(),f=function(){function t(n,r,o,a,i,c){this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=n,this.source=r,this.data=a,this.scheduleFn=i,this.cancelFn=c,this.callback=o;var s=this;this.invoke=n===D&&a&&a.useG?t.invokeTask:function(){return t.invokeTask.call(e,s,this,arguments)}}return t.invokeTask=function(e,t,n){e||(e=this),I++;try{return e.runCount++,e.zone.runTask(e,t,n)}finally{1==I&&m(),I--}},Object.defineProperty(t.prototype,"zone",{get:function(){return this._zone},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.cancelScheduleRequest=function(){this._transitionTo(b,k)},t.prototype._transitionTo=function(e,t,n){if(this._state!==t&&this._state!==n)throw new Error(this.type+" '"+this.source+"': can not transition to '"+e+"', expecting state '"+t+"'"+(n?" or '"+n+"'":"")+", was '"+this._state+"'.");this._state=e,e==b&&(this._zoneDelegates=null)},t.prototype.toString=function(){return this.data&&void 0!==this.data.handleId?this.data.handleId.toString():Object.prototype.toString.call(this)},t.prototype.toJSON=function(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}},t}(),p=a("setTimeout"),h=a("Promise"),d=a("then"),v=[],g=!1;function y(t){if(0===I&&0===v.length)if(s||e[h]&&(s=e[h].resolve(0)),s){var n=s[d];n||(n=s.then),n.call(s,m)}else e[p](m,0);t&&v.push(t)}function m(){if(!g){for(g=!0;v.length;){var e=v;v=[];for(var t=0;t=0;n--)"function"==typeof e[n]&&(e[n]=p(e[n],t+"_"+n));return e}function k(e){return!e||!1!==e.writable&&!("function"==typeof e.get&&void 0===e.set)}var T="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,E=!("nw"in y)&&void 0!==y.process&&"[object process]"==={}.toString.call(y.process),w=!E&&!T&&!(!v||!g.HTMLElement),O=void 0!==y.process&&"[object process]"==={}.toString.call(y.process)&&!T&&!(!v||!g.HTMLElement),S={},P=function(e){if(e=e||y.event){var t=S[e.type];t||(t=S[e.type]=d("ON_PROPERTY"+e.type));var n,r=this||e.target||y,o=r[t];return w&&r===g&&"error"===e.type?!0===(n=o&&o.call(this,e.message,e.filename,e.lineno,e.colno,e.error))&&e.preventDefault():null==(n=o&&o.apply(this,arguments))||n||e.preventDefault(),n}};function D(n,r,o){var a=e(n,r);if(!a&&o&&e(o,r)&&(a={enumerable:!0,configurable:!0}),a&&a.configurable){var i=d("on"+r+"patched");if(!n.hasOwnProperty(i)||!n[i]){delete a.writable,delete a.value;var c=a.get,s=a.set,u=r.substr(2),l=S[u];l||(l=S[u]=d("ON_PROPERTY"+u)),a.set=function(e){var t=this;t||n!==y||(t=y),t&&(t[l]&&t.removeEventListener(u,P),s&&s.apply(t,_),"function"==typeof e?(t[l]=e,t.addEventListener(u,P,!1)):t[l]=null)},a.get=function(){var e=this;if(e||n!==y||(e=y),!e)return null;var t=e[l];if(t)return t;if(c){var o=c&&c.call(this);if(o)return a.set.call(this,o),"function"==typeof e[m]&&e.removeAttribute(r),o}return null},t(n,r,a),n[i]=!0}}}function Z(e,t,n){if(t)for(var r=0;r=0&&"function"==typeof r[a.cbIdx]?h(a.name,r[a.cbIdx],a,o):e.apply(t,r)}})}function L(e,t){e[d("OriginalDelegate")]=t}var M=!1,x=!1;function N(){if(M)return x;M=!0;try{var e=g.navigator.userAgent;-1===e.indexOf("MSIE ")&&-1===e.indexOf("Trident/")&&-1===e.indexOf("Edge/")||(x=!0)}catch(e){}return x} +/** + * @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.__load_patch("toString",function(e){var t=Function.prototype.toString,n=d("OriginalDelegate"),r=d("Promise"),o=d("Error"),a=function a(){if("function"==typeof this){var i=this[n];if(i)return"function"==typeof i?t.call(i):Object.prototype.toString.call(i);if(this===Promise){var c=e[r];if(c)return t.call(c)}if(this===Error){var s=e[o];if(s)return t.call(s)}}return t.call(this)};a[n]=t,Function.prototype.toString=a;var i=Object.prototype.toString;Object.prototype.toString=function(){return this instanceof Promise?"[object Promise]":i.call(this)}}); +/** + * @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 F=!1;if("undefined"!=typeof window)try{var H=Object.defineProperty({},"passive",{get:function(){F=!0}});window.addEventListener("test",H,H),window.removeEventListener("test",H,H)}catch(e){F=!1}var A={useG:!0},B={},G={},W=new RegExp("^"+f+"(\\w+)(true|false)$"),q=d("propagationStopped");function U(e,t,r){var o=r&&r.add||a,c=r&&r.rm||i,s=r&&r.listeners||"eventListeners",p=r&&r.rmAll||"removeAllListeners",h=d(o),v="."+o+":",g="prependListener",y="."+g+":",m=function(e,t,n){if(!e.isRemoved){var r=e.callback;"object"==typeof r&&r.handleEvent&&(e.callback=function(e){return r.handleEvent(e)},e.originalDelegate=r),e.invoke(e,t,[n]);var o=e.options;o&&"object"==typeof o&&o.once&&t[c].call(t,n.type,e.originalDelegate?e.originalDelegate:e.callback,o)}},_=function(t){if(t=t||e.event){var n=this||t.target||e,r=n[B[t.type][l]];if(r)if(1===r.length)m(r[0],n,t);else for(var o=r.slice(),a=0;a1?new a(t,n):new a(t),u=e.ObjectGetOwnPropertyDescriptor(s,"onmessage");return u&&!1===u.configurable?(i=e.ObjectCreate(s),c=s,[r,o,"send","close"].forEach(function(t){i[t]=function(){var n=e.ArraySlice.call(arguments);if(t===r||t===o){var a=n.length>0?n[0]:void 0;if(a){var c=Zone.__symbol__("ON_PROPERTY"+a);s[c]=i[c]}}return s[t].apply(s,n)}})):i=s,e.patchOnProperties(i,["close","error","message","open"],c),i};var i=t.WebSocket;for(var c in a)i[c]=a[c]}(e,t),Zone[e.symbol("patchEvents")]=!0}}Zone.__load_patch("util",function(n,c,s){s.patchOnProperties=Z,s.patchMethod=I,s.bindArguments=b,s.patchMacroTask=R;var h=c.__symbol__("BLACK_LISTED_EVENTS"),d=c.__symbol__("UNPATCHED_EVENTS");n[d]&&(n[h]=n[d]),n[h]&&(c[h]=c[d]=n[h]),s.patchEventPrototype=V,s.patchEventTarget=U,s.isIEOrEdge=N,s.ObjectDefineProperty=t,s.ObjectGetOwnPropertyDescriptor=e,s.ObjectCreate=r,s.ArraySlice=o,s.patchClass=z,s.wrapWithCurrentZone=p,s.filterProperties=ve,s.attachOriginToPatched=L,s._redefineProperty=te,s.patchCallbacks=Y,s.getGlobalObjects=function(){return{globalSources:G,zoneSymbolEventNames:B,eventNames:de,isBrowser:w,isMix:O,isNode:E,TRUE_STR:u,FALSE_STR:l,ZONE_SYMBOL_PREFIX:f,ADD_EVENT_LISTENER_STR:a,REMOVE_EVENT_LISTENER_STR:i}}}), +/** + * @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(e){e[Zone.__symbol__("legacyPatch")]=function(){var t=e.Zone;t.__load_patch("registerElement",function(e,t,n){!function r(e,t){var n=t.getGlobalObjects();(n.isBrowser||n.isMix)&&"registerElement"in e.document&&t.patchCallbacks(t,document,"Document","registerElement",["createdCallback","attachedCallback","detachedCallback","attributeChangedCallback"])} +/** + * @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 + */(e,n)}),t.__load_patch("EventTargetLegacy",function(e,t,n){me(e,n),_e(n,e)})}}("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}); +/** + * @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 be=d("zoneTask");function ke(e,t,n,r){var o=null,a=null;n+=r;var i={};function c(t){var n=t.data;return n.args[0]=function r(){try{t.invoke.apply(this,arguments)}finally{t.data&&t.data.isPeriodic||("number"==typeof n.handleId?delete i[n.handleId]:n.handleId&&(n.handleId[be]=null))}},n.handleId=o.apply(e,n.args),t}function s(e){return a(e.data.handleId)}o=I(e,t+=r,function(n){return function(o,a){if("function"==typeof a[0]){var u=h(t,a[0],{isPeriodic:"Interval"===r,delay:"Timeout"===r||"Interval"===r?a[1]||0:void 0,args:a},c,s);if(!u)return u;var l=u.data.handleId;return"number"==typeof l?i[l]=u:l&&(l[be]=u),l&&l.ref&&l.unref&&"function"==typeof l.ref&&"function"==typeof l.unref&&(u.ref=l.ref.bind(l),u.unref=l.unref.bind(l)),"number"==typeof l||l?l:u}return n.apply(e,a)}}),a=I(e,n,function(t){return function(n,r){var o,a=r[0];"number"==typeof a?o=i[a]:(o=a&&a[be])||(o=a),o&&"string"==typeof o.type?"notScheduled"!==o.state&&(o.cancelFn&&o.data.isPeriodic||0===o.runCount)&&("number"==typeof a?delete i[a]:a&&(a[be]=null),o.zone.cancelTask(o)):t.apply(e,r)}})} +/** + * @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 + */ +/** + * @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 Te(e,t){if(!Zone[t.symbol("patchEventTarget")]){for(var n=t.getGlobalObjects(),r=n.eventNames,o=n.zoneSymbolEventNames,a=n.TRUE_STR,i=n.FALSE_STR,c=n.ZONE_SYMBOL_PREFIX,s=0;s0){var a=e.invoke;e.invoke=function(){for(var r=o[t.__symbol__("loadfalse")],i=0;i { +((_global: any) => { const __extends = function(d: any, b: any) { for (const p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; @@ -16,8 +16,6 @@ } d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new (__ as any)()); }; - const _global: any = - typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; // 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'); @@ -305,4 +303,4 @@ }; return ZoneQueueRunner; })(QueueRunner); -})(); +})(global); diff --git a/lib/mocha/mocha.ts b/lib/mocha/mocha.ts index 12d872558..42714fe18 100644 --- a/lib/mocha/mocha.ts +++ b/lib/mocha/mocha.ts @@ -175,4 +175,4 @@ return originalRun.call(this, fn); }; })(Mocha.Runner.prototype.runTest, Mocha.Runner.prototype.run); -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +})(global); diff --git a/lib/zone-spec/async-test.ts b/lib/zone-spec/async-test.ts index 86ed4b190..f51840dfd 100644 --- a/lib/zone-spec/async-test.ts +++ b/lib/zone-spec/async-test.ts @@ -5,8 +5,7 @@ * 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 _global: any = - typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global; +(function(_global: any) { class AsyncTestZoneSpec implements ZoneSpec { static symbolParentUnresolved = Zone.__symbol__('parentUnresolved'); @@ -147,3 +146,4 @@ class AsyncTestZoneSpec implements ZoneSpec { // Export the class so that new instances can be created with proper // constructor params. (Zone as any)['AsyncTestZoneSpec'] = AsyncTestZoneSpec; +})(global); diff --git a/lib/zone-spec/fake-async-test.ts b/lib/zone-spec/fake-async-test.ts index c2d288cbc..cc01c06c5 100644 --- a/lib/zone-spec/fake-async-test.ts +++ b/lib/zone-spec/fake-async-test.ts @@ -570,4 +570,4 @@ class FakeAsyncTestZoneSpec implements ZoneSpec { // Export the class so that new instances can be created with proper // constructor params. (Zone as any)['FakeAsyncTestZoneSpec'] = FakeAsyncTestZoneSpec; -})(typeof window === 'object' && window || typeof self === 'object' && self || global); +})(global); diff --git a/lib/zone-spec/wtf.ts b/lib/zone-spec/wtf.ts index 2053cdb75..3eafc5011 100644 --- a/lib/zone-spec/wtf.ts +++ b/lib/zone-spec/wtf.ts @@ -156,4 +156,4 @@ function zonePathName(zone: Zone) { } (Zone as any)['wtfZoneSpec'] = !wtfEnabled ? null : new WtfZoneSpec(); -})(typeof window === 'object' && window || typeof self === 'object' && self || global); +})(global); diff --git a/lib/zone.ts b/lib/zone.ts index d6ae82cec..831e49fb0 100644 --- a/lib/zone.ts +++ b/lib/zone.ts @@ -312,7 +312,7 @@ interface ZoneType { /** @internal */ __load_patch(name: string, fn: _PatchFn): void; - /** @internal */ + /** Was @ internal but this prevents compiling tests as separate unit */ __symbol__(name: string): string; } @@ -1417,4 +1417,4 @@ const Zone: ZoneType = (function(global: any) { performanceMeasure('Zone', 'Zone'); return global['Zone'] = Zone; -})(typeof window !== 'undefined' && window || typeof self !== 'undefined' && self || global); +})(global); diff --git a/package.json b/package.json index b25db4fc0..b56c9159b 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,13 @@ "test": "test" }, "scripts": { + "build:bazel": "bazel build //:npm_package", + "build:bazel:test": "bazel run //:test_npm_package", + "build:gulp": "gulp build", + "// 1": "Run both builds and make a directory to extract the current npm package", + "prebuild:compare": "yarn build:gulp && yarn build:bazel && rm -rf build/current-pkg && mkdir -p build/current-pkg", + "// 2": "This command assumes you have installed the meld tool to have graphical diff", + "build:compare": "npm pack | xargs tar -xvz -C build/current-pkg -f && meld build/current-pkg/package build/bin/npm_package", "changelog": "gulp changelog", "ci": "npm run lint && npm run format && npm run promisetest && npm run test:single && npm run test-node", "closure:test": "scripts/closure/closure_compiler.sh", @@ -26,7 +33,7 @@ "karma-jasmine:autoclose": "npm run karma-jasmine:single && npm run ws-client", "karma-jasmine-phantomjs:autoclose": "npm run karma-jasmine:phantomjs && npm run ws-client", "lint": "gulp lint", - "prepublish": "tsc && gulp build", + "prepublishOnly": "tsc && gulp build", "promisetest": "gulp promisetest", "promisefinallytest": "mocha promise.finally.spec.js", "webdriver-start": "webdriver-manager update && webdriver-manager start", @@ -48,7 +55,10 @@ "test-node": "gulp test/node", "test-bluebird": "gulp test/bluebird", "test-mocha": "npm run tsc && concurrently \"npm run tsc:w\" \"npm run ws-server\" \"karma start karma-build-mocha.conf.js\"", - "serve": "python -m SimpleHTTPServer 8000" + "serve": "python -m SimpleHTTPServer 8000", + "bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" ! -path \"./build/*\" | xargs buildifier -v --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable", + "bazel:lint": "yarn bazel:format --lint=warn", + "bazel:lint-fix": "yarn bazel:format --lint=fix" }, "repository": { "type": "git", @@ -61,8 +71,15 @@ }, "dependencies": {}, "devDependencies": { + "@bazel/bazel": "^0.22.0", + "@bazel/buildifier": "^0.22.0", + "@bazel/ibazel": "^0.9.1", + "@bazel/jasmine": "^0.29.0", + "@bazel/karma": "^0.28.0", + "@bazel/typescript": "^0.28.0", "@types/jasmine": "2.2.33", "@types/node": "^9.x", + "@types/shelljs": "^0.8.5", "@types/systemjs": "^0.19.30", "assert": "^1.4.1", "bluebird": "^3.5.1", @@ -90,17 +107,16 @@ "karma-firefox-launcher": "^0.1.4", "karma-jasmine": "^1.1.1", "karma-mocha": "^1.2.0", - "karma-phantomjs-launcher": "^1.0.4", "karma-safari-launcher": "^0.1.1", "karma-sauce-launcher": "^0.2.10", "karma-sourcemap-loader": "^0.3.6", "mocha": "^3.1.2", "nodejs-websocket": "^1.2.0", - "phantomjs": "^2.1.7", "promises-aplus-tests": "^2.1.2", "pump": "^1.0.1", "rxjs": "^6.2.1", "selenium-webdriver": "^3.4.0", + "shelljs": "^0.8.3", "systemjs": "^0.19.37", "terser": "^3.16.1", "ts-loader": "^0.6.0", diff --git a/sauce.conf.js b/sauce.conf.js index b44ac54d8..28bc132b8 100644 --- a/sauce.conf.js +++ b/sauce.conf.js @@ -35,7 +35,8 @@ module.exports = function(config, ignoredLaunchers) { platform: 'OS X 10.10', version: '8.4' },*/ - 'SL_IOS9': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'}, + // 'SL_IOS9': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: + // '9.3'}, 'SL_IOS10': {base: 'SauceLabs', browserName: 'iphone', platform: 'OS X 10.10', version: '10.3'}, 'SL_IE9': { base: 'SauceLabs', @@ -87,16 +88,17 @@ module.exports = function(config, ignoredLaunchers) { platform: 'Linux', version: '4.3' },*/ - 'SL_ANDROID4.4': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '4.4'}, + // 'SL_ANDROID4.4': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: + // '4.4'}, 'SL_ANDROID5.1': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '5.1'}, 'SL_ANDROID6.0': {base: 'SauceLabs', browserName: 'android', platform: 'Linux', version: '6.0'}, - 'SL_ANDROID7.1': { + 'SL_ANDROID8.0': { base: 'SauceLabs', browserName: 'Chrome', - appiumVersion: '1.6.4', + appiumVersion: '1.12.1', platformName: 'Android', deviceName: 'Android GoogleAPI Emulator', - platformVersion: '7.1' + platformVersion: '8.0' } }; diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 96fe7151a..cce9bd81a 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -401,6 +401,7 @@ describe('Zone', function() { // Edge 14, error will be undefined. expect(error).toBe(testError); } + (window as any).onerror = null; setTimeout(done); return true; }; diff --git a/test/browser/registerElement.spec.ts b/test/browser/registerElement.spec.ts index bf61e71d6..2956306a5 100644 --- a/test/browser/registerElement.spec.ts +++ b/test/browser/registerElement.spec.ts @@ -27,15 +27,13 @@ describe( let customElements; customElements = testZone.run(function() { - callbackNames.map(function(callbackName) { + callbackNames.forEach(function(callbackName) { const fullCallbackName = callbackName + 'Callback'; const proto = Object.create(HTMLElement.prototype); (proto as any)[fullCallbackName] = function(arg: any) { callbacks[callbackName](arg); }; - return (document).registerElement('x-' + callbackName.toLowerCase(), { - prototype: proto - }); + (document).registerElement('x-' + callbackName.toLowerCase(), {prototype: proto}); }); }); diff --git a/test/common/Error.spec.ts b/test/common/Error.spec.ts index e59d2d8e9..849181b18 100644 --- a/test/common/Error.spec.ts +++ b/test/common/Error.spec.ts @@ -82,6 +82,7 @@ describe('ZoneAwareError', () => { // and there is no point in running them. const _global: any = typeof window !== 'undefined' ? window : global; let config: any; + const __karma__ = _global.__karma__; if (typeof __karma__ !== 'undefined') { config = __karma__ && (__karma__ as any).config; } else if (typeof process !== 'undefined') { diff --git a/test/npm_package/npm_package.spec.ts b/test/npm_package/npm_package.spec.ts new file mode 100644 index 000000000..ee016bb4e --- /dev/null +++ b/test/npm_package/npm_package.spec.ts @@ -0,0 +1,169 @@ +/** + * @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 * as path from 'path'; +import * as shx from 'shelljs'; + +/** + * Utility functions that allows me to create fs paths + * p`${foo}/some/${{bar}}/path` rather than path.join(foo, 'some', + */ +function p(templateStringArray: TemplateStringsArray) { + const segments = []; + for (const entry of templateStringArray) { + segments.push(...entry.split('/').filter(s => s !== '')); + } + return path.join(...segments); +} + +describe('Zone.js npm_package', () => { + beforeEach(() => { + shx.cd('./npm_package'); + }); + afterEach(() => { + shx.cd('../'); + }); + describe('misc root files', () => { + describe('README.md', () => { + it('should have a README.md file with basic info', () => { + expect(shx.cat('README.md')).toContain(`Zone`); + }); + }); + }); + + describe('primary entry-point', () => { + const packageJson = 'package.json'; + + it('should have a package.json file', () => { + expect(shx.grep('"name":', packageJson)).toContain(`zone.js`); + }); + + it('should contain correct version number with the PLACEHOLDER string replaced', () => { + expect(shx.grep('"version":', packageJson)).toMatch(/\d+\.\d+\.\d+(?!-PLACEHOLDER)/); + }); + + it('should contain module resolution mappings', () => { + expect(shx.grep('"main":', packageJson)).toContain(`dist/zone-node.js`); + }); + }); + + describe('check dist folder', () => { + beforeEach(() => { + shx.cd('./dist'); + }); + afterEach(() => { + shx.cd('../'); + }); + describe('typescript support', () => { + it('should have an zone.js.d.ts file', () => { + expect(shx.cat('zone.js.d.ts')).toContain('declare const'); + }); + }); + + describe('closure', () => { + it('should contain externs', () => { + expect(shx.cat('zone_externs.js')).toContain('Externs for zone.js'); + }); + }); + + describe('es5', () => { + it('zone.js(es5) should not contain es6 spread code', () => { + expect(shx.cat('zone.js')).not.toContain('let value of values'); + }); + }); + + describe('es2015', () => { + it('zone-evergreen.js(es2015) should contain es6 code', () => { + expect(shx.cat('zone-evergreen.js')).toContain('let value of values'); + }); + }); + + describe('dist file list', () => { + it('should contain all files', () => { + const list = shx.ls('./').stdout.split('\n').sort().slice(1); + const expected = [ + 'async-test.js', + 'async-test.min.js', + 'fake-async-test.js', + 'fake-async-test.min.js', + 'jasmine-patch.js', + 'jasmine-patch.min.js', + 'long-stack-trace-zone.js', + 'long-stack-trace-zone.min.js', + 'mocha-patch.js', + 'mocha-patch.min.js', + 'proxy.js', + 'proxy.min.js', + 'sync-test.js', + 'sync-test.min.js', + 'task-tracking.js', + 'task-tracking.min.js', + 'webapis-media-query.js', + 'webapis-media-query.min.js', + 'webapis-notification.js', + 'webapis-notification.min.js', + 'webapis-rtc-peer-connection.js', + 'webapis-rtc-peer-connection.min.js', + 'webapis-shadydom.js', + 'webapis-shadydom.min.js', + 'wtf.js', + 'wtf.min.js', + 'zone_externs.js', + 'zone-bluebird.js', + 'zone-bluebird.min.js', + 'zone-error.js', + 'zone-error.min.js', + 'zone-evergreen.js', + 'zone-evergreen.min.js', + 'zone-evergreen-testing-bundle.js', + 'zone-evergreen-testing-bundle.min.js', + 'zone-legacy.js', + 'zone-legacy.min.js', + 'zone-mix.js', + 'zone-mix.min.js', + 'zone-node.js', + 'zone-node.min.js', + 'zone-patch-canvas.js', + 'zone-patch-canvas.min.js', + 'zone-patch-cordova.js', + 'zone-patch-cordova.min.js', + 'zone-patch-electron.js', + 'zone-patch-electron.min.js', + 'zone-patch-fetch.js', + 'zone-patch-fetch.min.js', + 'zone-patch-jsonp.js', + 'zone-patch-jsonp.min.js', + 'zone-patch-promise-test.js', + 'zone-patch-promise-test.min.js', + 'zone-patch-resize-observer.js', + 'zone-patch-resize-observer.min.js', + 'zone-patch-rxjs-fake-async.js', + 'zone-patch-rxjs-fake-async.min.js', + 'zone-patch-rxjs.js', + 'zone-patch-rxjs.min.js', + 'zone-patch-socket-io.js', + 'zone-patch-socket-io.min.js', + 'zone-patch-user-media.js', + 'zone-patch-user-media.min.js', + 'zone-testing-bundle.js', + 'zone-testing-bundle.min.js', + 'zone-testing-node-bundle.js', + 'zone-testing-node-bundle.min.js', + 'zone-testing.js', + 'zone-testing.min.js', + 'zone.js', + 'zone.js.d.ts', + 'zone.min.js', + ].sort(); + expect(list.length).toBe(expected.length); + for (let i = 0; i < list.length; i++) { + expect(list[i]).toEqual(expected[i]); + } + }); + }); + }); +}); diff --git a/test/webdriver/test.sauce.es2015.js b/test/webdriver/test.sauce.es2015.js index 845d6e715..9d86d08f6 100644 --- a/test/webdriver/test.sauce.es2015.js +++ b/test/webdriver/test.sauce.es2015.js @@ -14,7 +14,7 @@ const desiredCapabilities = { platformName: 'Android', platformVersion: '6.0', deviceOrientation: 'portrait', - appiumVersion: '1.7.2' + appiumVersion: '1.12.1' }, android71: { deviceName: 'Android GoogleAPI Emulator', @@ -22,7 +22,7 @@ const desiredCapabilities = { platformName: 'Android', platformVersion: '7.1', deviceOrientation: 'portrait', - appiumVersion: '1.7.2' + appiumVersion: '1.12.1' } }; diff --git a/test/webdriver/test.sauce.js b/test/webdriver/test.sauce.js index 0a8adacdf..07dd17f7f 100644 --- a/test/webdriver/test.sauce.js +++ b/test/webdriver/test.sauce.js @@ -18,7 +18,6 @@ const desiredCapabilities = { safari10: {browserName: 'safari', platform: 'OS X 10.11', version: '10.0'}, safari11: {browserName: 'safari', platform: 'macOS 10.13', version: '11.1'}, /*ios84: {browserName: 'iphone', platform: 'OS X 10.10', version: '8.4'},*/ - ios93: {browserName: 'iphone', platform: 'OS X 10.10', version: '9.3'}, ios10: {browserName: 'iphone', platform: 'OS X 10.10', version: '10.3'}, ios11: {browserName: 'iphone', platform: 'OS X 10.12', version: '11.2'}, /* @@ -34,7 +33,7 @@ const desiredCapabilities = { version: '10' },*/ ie11: {browserName: 'internet explorer', platform: 'Windows 10', version: '11'}, - andriod44: {browserName: 'android', platform: 'Linux', version: '4.4'}, + // andriod44: {browserName: 'android', platform: 'Linux', version: '4.4'}, android51: {browserName: 'android', platform: 'Linux', version: '5.1'}, }; diff --git a/tsconfig-esm-node.json b/tsconfig-esm-node.json index e7bec45d8..1199bc46f 100644 --- a/tsconfig-esm-node.json +++ b/tsconfig-esm-node.json @@ -24,6 +24,7 @@ ] }, "exclude": [ + "bazel-out", "node_modules", "build", "build-esm", diff --git a/tsconfig-esm.json b/tsconfig-esm.json index f11b57662..34ddc4227 100644 --- a/tsconfig-esm.json +++ b/tsconfig-esm.json @@ -25,6 +25,7 @@ }, "exclude": [ "node_modules", + "bazel-out", "build", "build-esm", "build-esm-2015", diff --git a/tsconfig-node.json b/tsconfig-node.json index a71de5837..bb0405eab 100644 --- a/tsconfig-node.json +++ b/tsconfig-node.json @@ -23,6 +23,7 @@ }, "exclude": [ "node_modules", + "bazel-out", "build", "build-esm", "build-esm-2015", diff --git a/tsconfig.json b/tsconfig.json index 6bdb42538..7a3828c43 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "lib": [ "es5", "dom", + "es2015.iterable", "es2015.promise", "es2015.symbol", "es2015.symbol.wellknown" @@ -22,6 +23,7 @@ }, "exclude": [ "node_modules", + "bazel-out", "build", "build-esm", "build-esm-2015", diff --git a/yarn.lock b/yarn.lock index d5bff0187..2c3c37f41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,16 +2,194 @@ # yarn lockfile v1 +"@bazel/bazel-darwin_x64@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel-darwin_x64/-/bazel-darwin_x64-0.22.0.tgz#a2bea5922dba9a32554a218ba4849a200115b248" + integrity sha512-LFxkyQgPATeB64z/1IvOWZhK+lc3JVHejbmdo96qB4lsoD8zselvOlgHvVXxlAjRxVZ9mlmXDvDRDyaXyyRdwA== + +"@bazel/bazel-linux_x64@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel-linux_x64/-/bazel-linux_x64-0.22.0.tgz#12e5884f2a7b7f3b62afbef9f8da4de0976f3bc8" + integrity sha512-xDs8cb2bbGZ9uvzYZOzCVrMBywzRhLj0J/t+py+FYZj+VO5B3wVg9eUf6nWWR0oJ2mzvToI9h31t2tNdqwy2kQ== + +"@bazel/bazel-win32_x64@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@bazel/bazel-win32_x64/-/bazel-win32_x64-0.22.0.tgz#a8a65986639583a8cc7b018e001aedfdafe41b50" + integrity sha512-FbJaXVDoCLnpIFLnPHFkQdfriYPXfnfQNuf9EXMliERdRuoeBVbwEZfwcuArxZWNFus7bD8QiTj0XzKVWO+Wbw== + +"@bazel/bazel@^0.22.0": + version "0.22.1" + resolved "https://registry.yarnpkg.com/@bazel/bazel/-/bazel-0.22.1.tgz#0df1f7a91ab8d97591509349791b9a0ac972caf5" + integrity sha512-2do3k+63uXClAVY3lblqXw044j4V3WeuD/MF+XrnTxfMyD5Dpp6FssoAoR0fMmbIRWtEZwB9trgfcg9CdHLI+g== + optionalDependencies: + "@bazel/bazel-darwin_x64" "0.22.0" + "@bazel/bazel-linux_x64" "0.22.0" + "@bazel/bazel-win32_x64" "0.22.0" + +"@bazel/buildifier-darwin_x64@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@bazel/buildifier-darwin_x64/-/buildifier-darwin_x64-0.22.0.tgz#00dde7ce03be8c550b3908dd91cf1fc0baef7ff7" + integrity sha512-tpJ6w3mmh8wBm/k5AidAZvjWm3Hge3ipSjGtxTfq/xgUCacAtGt219nwyAMs0CwLPuABLbcINQmmKtG5VpxK9A== + +"@bazel/buildifier-linux_x64@0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@bazel/buildifier-linux_x64/-/buildifier-linux_x64-0.22.0.tgz#146c44bafbb1e4711725414582a49835d04b8618" + integrity sha512-qaE7QF2YHKOXFBk2QcwOBfA3Ipm08vP9ZK9Vxtubbq9O0MM5tWvfKI48VkfX6pg8QNXDJ+sBndznxQSSWstsWQ== + +"@bazel/buildifier@^0.22.0": + version "0.22.0" + resolved "https://registry.yarnpkg.com/@bazel/buildifier/-/buildifier-0.22.0.tgz#d1abc2ce4317ba71351276c6b1b9e1533abf8e3d" + integrity sha512-S+mrUwanR8HMcp92iEDk4D1oOLsVhCM42Hx0rqL1eVmXPwLYL+F/sIjeGTw/6BgxMEHVSl2M3CcTFAS0b60BTQ== + optionalDependencies: + "@bazel/buildifier-darwin_x64" "0.22.0" + "@bazel/buildifier-linux_x64" "0.22.0" + +"@bazel/ibazel@^0.9.1": + version "0.9.1" + resolved "https://registry.yarnpkg.com/@bazel/ibazel/-/ibazel-0.9.1.tgz#d3248d60b7ef44ced1c2bdecda87ab2b6141a56e" + integrity sha512-twdytcFr+zj7CQcJCDegrAAI2soRyL34yaxD+3g59W8u188iOsZ392gscFJufysoEQKvAon1UiI3DqCrS+qYDw== + +"@bazel/jasmine@^0.29.0": + version "0.29.0" + resolved "https://registry.yarnpkg.com/@bazel/jasmine/-/jasmine-0.29.0.tgz#347d9c512daf8576dcdaa9bb168733fa444c2263" + integrity sha512-QH/mLAH4e7gcJrfOT0BmJ4wk+5Ly3RU+RPLaCyacnCjmJCICukZJa/rrjbVtwd8u7ZM+Hf6tRaLLydSeKXGBug== + dependencies: + jasmine "~3.3.1" + jasmine-core "~3.3.0" + v8-coverage "1.0.9" + +"@bazel/karma@^0.28.0": + version "0.28.0" + resolved "https://registry.yarnpkg.com/@bazel/karma/-/karma-0.28.0.tgz#b66db9bfd22b558fb3860c8d668f08362ddfe916" + integrity sha512-ig8b90q9s5R/Uwbx76u4t2htWCfkGf6krKYXsaK9qrfHV/5kELsYcNEkQggyYzJmYOqfjJrMAsndO9W+goFhDw== + dependencies: + jasmine-core "2.8.0" + karma "^4.0.0" + karma-chrome-launcher "2.2.0" + karma-firefox-launcher "1.1.0" + karma-jasmine "2.0.1" + karma-requirejs "1.1.0" + karma-sauce-launcher "2.0.2" + karma-sourcemap-loader "0.3.7" + requirejs "2.3.5" + semver "5.6.0" + tmp "0.0.33" + +"@bazel/typescript@^0.28.0": + version "0.28.0" + resolved "https://registry.yarnpkg.com/@bazel/typescript/-/typescript-0.28.0.tgz#fdc9ca63c097c8de6aa8c3e81b3dd870b5605791" + integrity sha512-sGi8+pRuPDe7bmK1cUmHfN/3uxHHpJTX9S3edq75pr6MytORIQZBxjSu9aRCgposIe1dPFTGt4B7TOZT8Ln+zw== + dependencies: + protobufjs "6.8.8" + semver "5.6.0" + source-map-support "0.5.9" + tsutils "2.27.2" + +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= + +"@types/events@*": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7" + integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g== + +"@types/glob@*": + version "7.1.1" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575" + integrity sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w== + dependencies: + "@types/events" "*" + "@types/minimatch" "*" + "@types/node" "*" + "@types/jasmine@2.2.33": version "2.2.33" resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.2.33.tgz#4715cfd2ca7fbd632fc7f1784f13e637bed028c5" integrity sha1-RxXP0sp/vWMvx/F4TxPmN77QKMU= +"@types/long@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.0.tgz#719551d2352d301ac8b81db732acb6bdc28dbdef" + integrity sha512-1w52Nyx4Gq47uuu0EVcsHBxZFJgurQ+rTKS3qMHxR1GY2T8c2AJYd6vZoZ9q1rupaDjU0yT+Jc2XTyXkjeMA+Q== + +"@types/minimatch@*": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" + integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== + +"@types/node@*": + version "12.0.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.2.tgz#3452a24edf9fea138b48fad4a0a028a683da1e40" + integrity sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA== + +"@types/node@^10.1.0": + version "10.14.6" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.6.tgz#9cbfcb62c50947217f4d88d4d274cc40c22625a9" + integrity sha512-Fvm24+u85lGmV4hT5G++aht2C5I4Z4dYlWZIh62FAfFO/TfzXtPpoLI6I7AuBWkIFqZCnhFOoTT7RjjaIL5Fjg== + "@types/node@^9.x": version "9.6.22" resolved "https://registry.yarnpkg.com/@types/node/-/node-9.6.22.tgz#05b55093faaadedea7a4b3f76e9a61346a6dd209" integrity sha512-RIg9EkxzVMkNH0M4sLRngK23f5QiigJC0iODQmu4nopzstt8AjegYund3r82iMrd2BNCjcZVnklaItvKHaGfBA== +"@types/shelljs@^0.8.5": + version "0.8.5" + resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.5.tgz#1e507b2f6d1f893269bd3e851ec24419ef9beeea" + integrity sha512-bZgjwIWu9gHCjirKJoOlLzGi5N0QgZ5t7EXEuoqyWCHTuSddURXo3FOBYDyRPNOWzZ6NbkLvZnVkn483Y/tvcQ== + dependencies: + "@types/glob" "*" + "@types/node" "*" + "@types/systemjs@^0.19.30": version "0.19.33" resolved "https://registry.yarnpkg.com/@types/systemjs/-/systemjs-0.19.33.tgz#47c47e7639867b6694beb3f60c4f53ad55eb1b13" @@ -38,6 +216,14 @@ accepts@1.3.3: mime-types "~2.1.11" negotiator "0.6.1" +accepts@~1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.5.tgz#eb777df6011723a3b14e8a72c0805c8e86746bd2" + integrity sha1-63d99gEXI6OxTopywIBcjoZ0a9I= + dependencies: + mime-types "~2.1.18" + negotiator "0.6.1" + add-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/add-stream/-/add-stream-1.0.0.tgz#6a7990437ca736d5e1288db92bd3266d5f5cb2aa" @@ -53,6 +239,13 @@ after@0.8.2: resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" integrity sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8= +agent-base@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" + integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg== + dependencies: + es6-promisify "^5.0.0" + ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" @@ -156,6 +349,14 @@ anymatch@^1.3.0: micromatch "^2.1.5" normalize-path "^2.0.0" +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" + aproba@^1.0.3: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -293,6 +494,11 @@ arraybuffer.slice@0.0.6: resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.6.tgz#f33b2159f0532a3f3107a272c0ccfbd1ad2979ca" integrity sha1-8zshWfBTKj8xB6JywMz70a0peco= +arraybuffer.slice@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz#3bbc4275dd584cc1b10809b89d4e8b63a69e7675" + integrity sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog== + arrify@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -340,6 +546,16 @@ async-each@^1.0.0: resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" integrity sha1-GdOGodntxufByF04iu28xW0zYC0= +async-each@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.2.tgz#8b8a7ca2a658f927e9f307d6d1a42f4199f0f735" + integrity sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg== + +async-limiter@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" + integrity sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg== + async@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/async/-/async-0.9.0.tgz#ac3613b1da9bed1b47510bb4651b8931e47146c7" @@ -350,13 +566,20 @@ async@^1.4.0, async@^1.4.2, async@^1.5.2: resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= -async@^2.0.0, async@^2.0.1: +async@^2.0.0: version "2.6.0" resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" integrity sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw== dependencies: lodash "^4.14.0" +async@^2.1.2, async@^2.6.1: + version "2.6.2" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" + integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== + dependencies: + lodash "^4.17.11" + async@~0.2.6: version "0.2.10" resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" @@ -510,18 +733,16 @@ bl@^1.0.0: dependencies: readable-stream "^2.0.5" -bl@~1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/bl/-/bl-1.0.3.tgz#fc5421a28fd4226036c3b3891a66a25bc64d226e" - integrity sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4= - dependencies: - readable-stream "~2.0.5" - blob@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.4.tgz#bcf13052ca54463f30f9fc7e95b9a47630a94921" integrity sha1-vPEwUspURj8w+fx+lbmkdjCpSSE= +blob@0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/blob/-/blob-0.0.5.tgz#d680eeef25f8cd91ad533f5b01eed48e64caf683" + integrity sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig== + block-stream@*: version "0.0.9" resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" @@ -539,6 +760,11 @@ bluebird@^2.9.27, bluebird@^2.9.30: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1" integrity sha1-U0uQM8AiyVecVro7Plpcqvu2UOE= +bluebird@^3.3.0: + version "3.5.4" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.4.tgz#d6cc661595de30d5b3af5fcedd3c0b3ef6ec5714" + integrity sha512-FG+nFEZChJrbQ9tIccIfZJBz3J7mLrAhxakAbnrJWn8d7aKOC+LWifa0G+p4ZqKp4y13T7juYvdhq9NzKdsrjw== + bluebird@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9" @@ -560,6 +786,22 @@ body-parser@^1.12.4: raw-body "2.3.2" type-is "~1.6.15" +body-parser@^1.16.1: + version "1.18.3" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.3.tgz#5b292198ffdd553b3a0f20ded0592b956955c8b4" + integrity sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ= + dependencies: + bytes "3.0.0" + content-type "~1.0.4" + debug "2.6.9" + depd "~1.1.2" + http-errors "~1.6.3" + iconv-lite "0.4.23" + on-finished "~2.3.0" + qs "6.5.2" + raw-body "2.3.3" + type-is "~1.6.16" + boom@2.x.x: version "2.10.1" resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" @@ -636,6 +878,22 @@ braces@^2.3.1: split-string "^3.0.2" to-regex "^3.0.1" +braces@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" @@ -716,7 +974,7 @@ camelcase@^2.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" integrity sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8= -camelcase@^4.0.0: +camelcase@^4.0.0, camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= @@ -726,11 +984,6 @@ capture-stack-trace@^1.0.0: resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" integrity sha1-Sm+gc5nCa7pH8LJJa00PtAjFVQ0= -caseless@~0.11.0: - version "0.11.0" - resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" - integrity sha1-cVuW6phBWTzDMGeSP17GDr2k99c= - caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" @@ -801,6 +1054,30 @@ chokidar@^1.4.1: optionalDependencies: fsevents "^1.0.0" +chokidar@^2.0.3: + version "2.1.5" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.5.tgz#0ae8434d962281a5f56c72869e79cb6d9d86ad4d" + integrity sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.2.1" + upath "^1.1.1" + optionalDependencies: + fsevents "^1.2.7" + +chownr@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" + integrity sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g== + clang-format@^1.0.32: version "1.2.2" resolved "https://registry.yarnpkg.com/clang-format/-/clang-format-1.2.2.tgz#a7277a03fce9aa4e387ddaa83b60d99dab115737" @@ -867,6 +1144,15 @@ cliui@^2.1.0: right-align "^0.1.1" wordwrap "0.0.2" +cliui@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49" + integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ== + dependencies: + string-width "^2.1.1" + strip-ansi "^4.0.0" + wrap-ansi "^2.0.0" + clone-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" @@ -982,7 +1268,7 @@ commander@2.9.0: dependencies: graceful-readlink ">= 1.0.0" -commander@^2.8.1, commander@^2.9.0: +commander@^2.8.1: version "2.14.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" integrity sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw== @@ -992,6 +1278,11 @@ commander@~2.17.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== +commander@~2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422" + integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ== + compare-func@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.2.tgz#99dd0ba457e1f9bc722b12c08ec33eeab31fa648" @@ -1045,16 +1336,7 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= -concat-stream@1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.0.tgz#53f7d43c51c5e43f81c8fdd03321c631be68d611" - integrity sha1-U/fUPFHF5D+ByP3QMyHGMb5o1hE= - dependencies: - inherits "~2.0.1" - readable-stream "~2.0.0" - typedarray "~0.0.5" - -concat-stream@1.6.0, concat-stream@^1.5.0: +concat-stream@^1.5.0: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" integrity sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc= @@ -1088,7 +1370,7 @@ configstore@^3.0.0: write-file-atomic "^2.0.0" xdg-basedir "^3.0.0" -connect@^3.3.5: +connect@^3.3.5, connect@^3.6.0: version "3.6.6" resolved "https://registry.yarnpkg.com/connect/-/connect-3.6.6.tgz#09eff6c55af7236e137135a72574858b6786f524" integrity sha1-Ce/2xVr3I24TcTWnJXSFi2eG9SQ= @@ -1271,6 +1553,11 @@ core-js@^2.1.0, core-js@^2.4.0: resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.3.tgz#8acc38345824f16d8365b7c9b4259168e8ed603e" integrity sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4= +core-js@^2.2.0: + version "2.6.5" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.5.tgz#44bc8d249e7fb2ff5d00e0341a7ffb94fbf67895" + integrity sha512-klh/kDpwX8hryYL14M9w/xei6vrv6sE8gTHDG7/T/+SEovB/G4ejwcfE/CBzO6Edsu+OETZMZ3wcX/EjUkrl5A== + core-js@^2.5.7: version "2.5.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" @@ -1321,6 +1608,14 @@ cross-spawn@^0.2.9: dependencies: lru-cache "^2.5.0" +cross-spawn@^4: + version "4.0.2" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41" + integrity sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE= + dependencies: + lru-cache "^4.0.1" + which "^1.2.9" + cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -1409,6 +1704,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +date-format@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/date-format/-/date-format-2.0.0.tgz#7cf7b172f1ec564f0003b39ea302c5498fb98c8f" + integrity sha512-M6UqVvZVgFYqZL1SfHsRGIQSz3ZL+qgbsV5Lp1Vj61LZVYuEwcMXYay7DRDtYs2HQQBK5hQtQ0fD9aEJ89V0LA== + dateformat@^1.0.11, dateformat@^1.0.12: version "1.0.12" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" @@ -1427,11 +1727,6 @@ deap@^1.0.0: resolved "https://registry.yarnpkg.com/deap/-/deap-1.0.0.tgz#b148bf82430a27699b7483a03eb6b67585bfc888" integrity sha1-sUi/gkMKJ2mbdIOgPra2dYW/yIg= -debug@0.7.4: - version "0.7.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-0.7.4.tgz#06e1ea8082c2cb14e39806e22e2f6f757f92af39" - integrity sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk= - debug@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" @@ -1460,7 +1755,28 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -decamelize@^1.0.0, decamelize@^1.1.2: +debug@^3.1.0: + version "3.2.6" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" + integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== + dependencies: + ms "^2.1.1" + +debug@^4.1.0, debug@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + +debug@~3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + +decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= @@ -1470,6 +1786,11 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + deep-extend@~0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" @@ -1542,7 +1863,7 @@ depd@1.1.1: resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359" integrity sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k= -depd@~1.1.1: +depd@~1.1.1, depd@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= @@ -1712,6 +2033,23 @@ engine.io-client@~1.8.4: xmlhttprequest-ssl "1.5.3" yeast "0.1.2" +engine.io-client@~3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/engine.io-client/-/engine.io-client-3.2.1.tgz#6f54c0475de487158a1a7c77d10178708b6add36" + integrity sha512-y5AbkytWeM4jQr7m/koQLc5AxpRKC1hEVUb/s1FUAWEJq5AzJJ4NLvzuKPuxtDi5Mq755WuDvZ6Iv2rXj4PTzw== + dependencies: + component-emitter "1.2.1" + component-inherit "0.0.3" + debug "~3.1.0" + engine.io-parser "~2.1.1" + has-cors "1.1.0" + indexof "0.0.1" + parseqs "0.0.5" + parseuri "0.0.5" + ws "~3.3.1" + xmlhttprequest-ssl "~1.5.4" + yeast "0.1.2" + engine.io-parser@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-1.3.2.tgz#937b079f0007d0893ec56d46cb220b8cb435220a" @@ -1724,6 +2062,17 @@ engine.io-parser@1.3.2: has-binary "0.1.7" wtf-8 "1.0.0" +engine.io-parser@~2.1.0, engine.io-parser@~2.1.1: + version "2.1.3" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-2.1.3.tgz#757ab970fbf2dfb32c7b74b033216d5739ef79a6" + integrity sha512-6HXPre2O4Houl7c4g7Ic/XzPnHBvaEmN90vtRO9uLmwtRqQmTOw0QMevL1TOfL2Cpu1VzsaTmMotQgMdkzGkVA== + dependencies: + after "0.8.2" + arraybuffer.slice "~0.0.7" + base64-arraybuffer "0.1.5" + blob "0.0.5" + has-binary2 "~1.0.2" + engine.io@~1.8.4: version "1.8.5" resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-1.8.5.tgz#4ebe5e75c6dc123dee4afdce6e5fdced21eb93f6" @@ -1736,6 +2085,18 @@ engine.io@~1.8.4: engine.io-parser "1.3.2" ws "~1.1.5" +engine.io@~3.2.0: + version "3.2.1" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-3.2.1.tgz#b60281c35484a70ee0351ea0ebff83ec8c9522a2" + integrity sha512-+VlKzHzMhaU+GsCIg4AoXF1UdDFjHHwMmMKqMJNDNLlUlejz58FCy4LBqB2YVJskHGYl06BatYWKP2TVdVXE5w== + dependencies: + accepts "~1.3.4" + base64id "1.0.0" + cookie "0.3.1" + debug "~3.1.0" + engine.io-parser "~2.1.0" + ws "~3.3.1" + enhanced-resolve@^0.9.0: version "0.9.1" resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz#4d6e689b3725f86090927ccc86cd9f1635b89e2e" @@ -1757,6 +2118,13 @@ error-ex@^1.2.0: dependencies: is-arrayish "^0.2.1" +error-ex@^1.3.1: + version "1.3.2" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" + integrity sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g== + dependencies: + is-arrayish "^0.2.1" + es5-ext@^0.10.12, es5-ext@^0.10.14, es5-ext@^0.10.30, es5-ext@^0.10.35, es5-ext@^0.10.9, es5-ext@~0.10.14, es5-ext@~0.10.2: version "0.10.39" resolved "https://registry.yarnpkg.com/es5-ext/-/es5-ext-0.10.39.tgz#fca21b67559277ca4ac1a1ed7048b107b6f76d87" @@ -1789,6 +2157,13 @@ es6-promise@~3.0.2: resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.0.2.tgz#010d5858423a5f118979665f46486a95c6ee2bb6" integrity sha1-AQ1YWEI6XxGJeWZfRkhqlcbuK7Y= +es6-promisify@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" + integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= + dependencies: + es6-promise "^4.0.3" + es6-symbol@^3.1.1, es6-symbol@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/es6-symbol/-/es6-symbol-3.1.1.tgz#bf00ef4fdab6ba1b46ecb7b629b4c7ed5715cc77" @@ -1972,26 +2347,6 @@ extglob@^2.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" -extract-zip@^1.6.5: - version "1.6.6" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.6.tgz#1290ede8d20d0872b429fd3f351ca128ec5ef85c" - integrity sha1-EpDt6NINCHK0Kf0/NRyhKOxe+Fw= - dependencies: - concat-stream "1.6.0" - debug "2.6.9" - mkdirp "0.5.0" - yauzl "2.4.1" - -extract-zip@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.5.0.tgz#92ccf6d81ef70a9fa4c1747114ccef6d8688a6c4" - integrity sha1-ksz22B73Cp+kwXRxFMzvbYaIpsQ= - dependencies: - concat-stream "1.5.0" - debug "0.7.4" - mkdirp "0.5.0" - yauzl "2.4.1" - extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" @@ -2021,13 +2376,6 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" integrity sha1-1RQsDK7msRifh9OnYREGT4bIu/I= -fd-slicer@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/fd-slicer/-/fd-slicer-1.0.1.tgz#8b5bcbd9ec327c5041bf9ab023fd6750f1177e65" - integrity sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU= - dependencies: - pend "~1.2.0" - figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" @@ -2087,6 +2435,20 @@ find-up@^1.0.0: path-exists "^2.0.0" pinkie-promise "^2.0.0" +find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= + dependencies: + locate-path "^2.0.0" + +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + findup-sync@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-2.0.0.tgz#9326b1488c22d1a6088650a86901b2d9a90a2cbc" @@ -2125,6 +2487,11 @@ flagged-respawn@^1.0.0: resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.0.tgz#4e79ae9b2eb38bf86b3bb56bf3e0a56aa5fcabd7" integrity sha1-Tnmumy6zi/hrO7Vr8+ClaqX8q9c= +flatted@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.0.tgz#55122b6536ea496b4b44893ee2608141d10d9916" + integrity sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg== + for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -2144,6 +2511,14 @@ for-own@^1.0.0: dependencies: for-in "^1.0.1" +foreground-child@^1.5.6: + version "1.5.6" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-1.5.6.tgz#4fd71ad2dfde96789b980a5c0a295937cb2f5ce9" + integrity sha1-T9ca0t/elnibmApcCilZN8svXOk= + dependencies: + cross-spawn "^4" + signal-exit "^3.0.0" + forever-agent@~0.6.0, forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -2158,15 +2533,6 @@ form-data@~0.2.0: combined-stream "~0.0.4" mime-types "~2.0.3" -form-data@~1.0.0-rc3: - version "1.0.1" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.1.tgz#ae315db9a4907fa065502304a66d7733475ee37c" - integrity sha1-rjFduaSQf6BlUCMEpm13M0de43w= - dependencies: - async "^2.0.1" - combined-stream "^1.0.5" - mime-types "^2.1.11" - form-data@~2.1.1: version "2.1.4" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" @@ -2211,25 +2577,21 @@ fs-access@^1.0.0: dependencies: null-check "^1.0.0" -fs-extra@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" - integrity sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA= +fs-extra@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9" + integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw== dependencies: graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" + jsonfile "^4.0.0" + universalify "^0.1.0" -fs-extra@~0.26.4: - version "0.26.7" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.26.7.tgz#9ae1fdd94897798edab76d0918cf42d0c3184fa9" - integrity sha1-muH92UiXeY7at20JGM9C0MMYT6k= +fs-minipass@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" + integrity sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ== dependencies: - graceful-fs "^4.1.2" - jsonfile "^2.1.0" - klaw "^1.0.0" - path-is-absolute "^1.0.0" - rimraf "^2.2.8" + minipass "^2.2.1" fs.realpath@^1.0.0: version "1.0.0" @@ -2244,6 +2606,14 @@ fsevents@^1.0.0: nan "^2.3.0" node-pre-gyp "^0.6.39" +fsevents@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.7.tgz#4851b664a3783e52003b3c66eb0eee1074933aa4" + integrity sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw== + dependencies: + nan "^2.9.2" + node-pre-gyp "^0.10.0" + fstream-ignore@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" @@ -2303,6 +2673,11 @@ generate-object-property@^1.1.0: dependencies: is-property "^1.0.0" +get-caller-file@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" + integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== + get-pkg-repo@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/get-pkg-repo/-/get-pkg-repo-1.4.0.tgz#c73b489c06d80cc5536c2c853f9e05232056972d" @@ -2385,6 +2760,14 @@ glob-parent@^2.0.0: dependencies: is-glob "^2.0.0" +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" + integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + glob-stream@^3.1.5: version "3.1.18" resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" @@ -2472,6 +2855,18 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@~7.1.1: once "^1.3.0" path-is-absolute "^1.0.0" +glob@^7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + glob@~3.1.21: version "3.1.21" resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" @@ -2599,7 +2994,7 @@ graceful-fs@^3.0.0: dependencies: natives "^1.1.0" -graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= @@ -2784,6 +3179,17 @@ handlebars@^4.0.2: optionalDependencies: uglify-js "^2.6" +handlebars@^4.0.3: + version "4.1.2" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67" + integrity sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw== + dependencies: + neo-async "^2.6.0" + optimist "^0.6.1" + source-map "^0.6.1" + optionalDependencies: + uglify-js "^3.1.4" + har-schema@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" @@ -2804,16 +3210,6 @@ har-validator@^1.4.0: commander "^2.8.1" is-my-json-valid "^2.12.0" -har-validator@~2.0.2: - version "2.0.6" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" - integrity sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0= - dependencies: - chalk "^1.1.1" - commander "^2.9.0" - is-my-json-valid "^2.12.4" - pinkie-promise "^2.0.0" - har-validator@~4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" @@ -2844,6 +3240,13 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" +has-binary2@~1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-binary2/-/has-binary2-1.0.3.tgz#7776ac627f3ea77250cfc332dab7ddf5e4f5d11d" + integrity sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw== + dependencies: + isarray "2.0.1" + has-binary@0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/has-binary/-/has-binary-0.1.7.tgz#68e61eb16210c9545a0a5cce06a873912fe1e68c" @@ -2935,15 +3338,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -hasha@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1" - integrity sha1-eNfL/B5tZjA/55g3NlmEUXsvbuE= - dependencies: - is-stream "^1.0.1" - pinkie-promise "^2.0.0" - -hawk@3.1.3, hawk@~3.1.0, hawk@~3.1.3: +hawk@3.1.3, hawk@~3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" integrity sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ= @@ -3010,6 +3405,16 @@ http-errors@1.6.2, http-errors@~1.6.2: setprototypeof "1.0.3" statuses ">= 1.3.1 < 2" +http-errors@1.6.3, http-errors@~1.6.3: + version "1.6.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" + integrity sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0= + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + http-proxy@^1.13.0: version "1.16.2" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.16.2.tgz#06dff292952bf64dbe8471fa9df73066d4f37742" @@ -3045,11 +3450,40 @@ http-signature@~1.2.0: jsprim "^1.2.2" sshpk "^1.7.0" +https-proxy-agent@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" + integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ== + dependencies: + agent-base "^4.1.0" + debug "^3.1.0" + iconv-lite@0.4.19, iconv-lite@^0.4.17: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" integrity sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ== +iconv-lite@0.4.23: + version "0.4.23" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.23.tgz#297871f63be507adcfbfca715d0cd0eed84e9a63" + integrity sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.4.4: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +ignore-walk@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" + integrity sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ== + dependencies: + minimatch "^3.0.4" + immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" @@ -3135,6 +3569,11 @@ interpret@^1.0.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" integrity sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ= +invert-kv@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" + integrity sha1-EEqOSqym09jNFXqO+L+rLXo//bY= + is-absolute@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" @@ -3258,7 +3697,7 @@ is-extglob@^1.0.0: resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" integrity sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA= -is-extglob@^2.1.0: +is-extglob@^2.1.0, is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= @@ -3325,6 +3764,13 @@ is-glob@^3.1.0: dependencies: is-extglob "^2.1.0" +is-glob@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + is-index-x@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-index-x/-/is-index-x-1.1.0.tgz#43dac97b3a04f30191530833f45ac35001682ee2" @@ -3349,7 +3795,7 @@ is-my-ip-valid@^1.0.0: resolved "https://registry.yarnpkg.com/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz#7b351b8e8edd4d3995d4d066680e664d94696824" integrity sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ== -is-my-json-valid@^2.12.0, is-my-json-valid@^2.12.4: +is-my-json-valid@^2.12.0: version "2.17.2" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz#6b2103a288e94ef3de5cf15d29dd85fc4b78d65c" integrity sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg== @@ -3485,7 +3931,7 @@ is-retry-allowed@^1.0.0: resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-1.1.0.tgz#11a060568b67339444033d0125a61a20d564fb34" integrity sha1-EaBgVotnM5REAz0BJaYaINVk+zQ= -is-stream@^1.0.0, is-stream@^1.0.1, is-stream@^1.1.0: +is-stream@^1.0.0, is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= @@ -3544,6 +3990,11 @@ isarray@1.0.0, isarray@~1.0.0: resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= +isarray@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.1.tgz#a37d94ed9cda2d59865c9f76fe596ee1f338741e" + integrity sha1-o32U7ZzaLVmGXJ92/llu4fM4dB4= + isbinaryfile@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-3.0.2.tgz#4a3e974ec0cba9004d3fc6cde7209ea69368a621" @@ -3571,6 +4022,28 @@ isstream@~0.1.1, isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= +istanbul-lib-coverage@^1.2.0, istanbul-lib-coverage@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.1.tgz#ccf7edcd0a0bb9b8f729feeb0930470f9af664f0" + integrity sha512-PzITeunAgyGbtY1ibVIUiV679EFChHjoMNRibEIobvmrCRaIgwLxNucOSimtNWUhEib/oO7QY2imD75JVgCJWQ== + +istanbul-lib-report@^1.1.3: + version "1.1.5" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.5.tgz#f2a657fc6282f96170aaf281eb30a458f7f4170c" + integrity sha512-UsYfRMoi6QO/doUshYNqcKJqVmFe9w51GZz8BS3WB0lYxAllQYklka2wP9+dGZeHYaWIdcXUx8JGdbqaoXRXzw== + dependencies: + istanbul-lib-coverage "^1.2.1" + mkdirp "^0.5.1" + path-parse "^1.0.5" + supports-color "^3.1.2" + +istanbul-reports@^1.3.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.5.1.tgz#97e4dbf3b515e8c484caea15d6524eebd3ff4e1a" + integrity sha512-+cfoZ0UXzWjhAdzosCPP3AN8vvef8XDkWtTfgaN+7L3YTpNYITnCaEkceo5SEYy644VkHka/P1FvkWvrG/rrJw== + dependencies: + handlebars "^4.0.3" + jade@0.26.3: version "0.26.3" resolved "https://registry.yarnpkg.com/jade/-/jade-0.26.3.tgz#8f10d7977d8d79f2f6ff862a81b0513ccb25686c" @@ -3579,17 +4052,27 @@ jade@0.26.3: commander "0.6.1" mkdirp "0.3.0" +jasmine-core@2.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.8.0.tgz#bcc979ae1f9fd05701e45e52e65d3a5d63f1a24e" + integrity sha1-vMl5rh+f0FcB5F5S5l06XWPxok4= + jasmine-core@^2.9.1: version "2.99.1" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15" integrity sha1-5kAN8ea1bhMLYcS80JPap/boyhU= +jasmine-core@^3.3: + version "3.4.0" + resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.4.0.tgz#2a74618e966026530c3518f03e9f845d26473ce3" + integrity sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg== + jasmine-core@~3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-3.3.0.tgz#dea1cdc634bc93c7e0d4ad27185df30fa971b10e" integrity sha512-3/xSmG/d35hf80BEN66Y6g9Ca5l/Isdeg/j6zvbTYlTzeKinzmaTM4p9am5kYqOmE05D7s1t8FGjzdSnbUbceA== -jasmine@^3.3.1: +jasmine@^3.3.1, jasmine@~3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-3.3.1.tgz#d61bb1dd8888859bd11ea83074a78ee13d949905" integrity sha512-/vU3/H7U56XsxIXHwgEuWpCgQ0bRi2iiZeUpx7Nqo8n1TpoDHfZhkPIc7CO8I4pnMzYsi3XaSZEiy8cnTfujng== @@ -3607,6 +4090,11 @@ jsbn@~0.1.0: resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= +json-parse-better-errors@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + json-schema-traverse@^0.3.0: version "0.3.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -3639,10 +4127,10 @@ json5@^0.5.0: resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= -jsonfile@^2.1.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" - integrity sha1-NzaitCi4e72gzIO1P6PWM6NcKug= +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= optionalDependencies: graceful-fs "^4.1.6" @@ -3682,23 +4170,43 @@ jszip@^3.1.3: pako "~1.0.2" readable-stream "~2.0.6" -karma-chrome-launcher@^0.2.1: - version "0.2.3" - resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-0.2.3.tgz#4c6d700d163a9d34c618efd87918be49e7a4a8c9" +karma-chrome-launcher@2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz#cf1b9d07136cc18fe239327d24654c3dbc368acf" + integrity sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w== + dependencies: + fs-access "^1.0.0" + which "^1.2.1" + +karma-chrome-launcher@^0.2.1: + version "0.2.3" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-0.2.3.tgz#4c6d700d163a9d34c618efd87918be49e7a4a8c9" integrity sha1-TG1wDRY6nTTGGO/YeRi+SeekqMk= dependencies: fs-access "^1.0.0" which "^1.2.1" +karma-firefox-launcher@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz#2c47030452f04531eb7d13d4fc7669630bb93339" + integrity sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA== + karma-firefox-launcher@^0.1.4: version "0.1.7" resolved "https://registry.yarnpkg.com/karma-firefox-launcher/-/karma-firefox-launcher-0.1.7.tgz#c05dd86533691e62f31952595098e8bd357d39f3" integrity sha1-wF3YZTNpHmLzGVJZUJjovTV9OfM= +karma-jasmine@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-2.0.1.tgz#26e3e31f2faf272dd80ebb0e1898914cc3a19763" + integrity sha512-iuC0hmr9b+SNn1DaUD2QEYtUxkS1J+bSJSn7ejdEexs7P8EYvA1CWkEdrDQ+8jVH3AgWlCNwjYsT1chjcNW9lA== + dependencies: + jasmine-core "^3.3" + karma-jasmine@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.1.tgz#6fe840e75a11600c9d91e84b33c458e1c46a3529" - integrity sha1-b+hA51oRYAydkehLM8RY4cRqNSk= + version "1.1.2" + resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.2.tgz#394f2b25ffb4a644b9ada6f22d443e2fd08886c3" + integrity sha1-OU8rJf+0pkS5rabyLUQ+L9CIhsM= karma-mocha@^1.2.0: version "1.3.0" @@ -3707,19 +4215,25 @@ karma-mocha@^1.2.0: dependencies: minimist "1.2.0" -karma-phantomjs-launcher@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/karma-phantomjs-launcher/-/karma-phantomjs-launcher-1.0.4.tgz#d23ca34801bda9863ad318e3bb4bd4062b13acd2" - integrity sha1-0jyjSAG9qYY60xjju0vUBisTrNI= - dependencies: - lodash "^4.0.1" - phantomjs-prebuilt "^2.1.7" +karma-requirejs@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/karma-requirejs/-/karma-requirejs-1.1.0.tgz#fddae2cb87d7ebc16fb0222893564d7fee578798" + integrity sha1-/driy4fX68FvsCIok1ZNf+5Xh5g= karma-safari-launcher@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/karma-safari-launcher/-/karma-safari-launcher-0.1.1.tgz#a6380accab60a583fdd624f41b9a3f10fdf41008" integrity sha1-pjgKzKtgpYP91iT0G5o/EP30EAg= +karma-sauce-launcher@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/karma-sauce-launcher/-/karma-sauce-launcher-2.0.2.tgz#dbf98e70d86bf287b03a537cf637eb7aefa975c3" + integrity sha512-jLUFaJhHMcKpxFWUesyWYihzM5FvQiJsDwGcCtKeOy2lsWhkVw0V0Byqb1d+wU6myU1mribBtsIcub23HS4kWA== + dependencies: + sauce-connect-launcher "^1.2.4" + saucelabs "^1.5.0" + selenium-webdriver "^4.0.0-alpha.1" + karma-sauce-launcher@^0.2.10: version "0.2.14" resolved "https://registry.yarnpkg.com/karma-sauce-launcher/-/karma-sauce-launcher-0.2.14.tgz#e42e412517c5f40534c8bba7d14bb4f10727b6a7" @@ -3730,7 +4244,7 @@ karma-sauce-launcher@^0.2.10: saucelabs "~0.1.0" wd "~0.3.4" -karma-sourcemap-loader@^0.3.6: +karma-sourcemap-loader@0.3.7, karma-sourcemap-loader@^0.3.6: version "0.3.7" resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.7.tgz#91322c77f8f13d46fed062b042e1009d4c4505d8" integrity sha1-kTIsd/jxPUb+0GKwQuEAnUxFBdg= @@ -3766,10 +4280,38 @@ karma@^0.13.14: source-map "^0.5.3" useragent "^2.1.6" -kew@^0.7.0, kew@~0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/kew/-/kew-0.7.0.tgz#79d93d2d33363d6fdd2970b335d9141ad591d79b" - integrity sha1-edk9LTM2PW/dKXCzNdkUGtWR15s= +karma@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/karma/-/karma-4.0.1.tgz#2581d6caa0d4cd28b65131561b47bad6d5478773" + integrity sha512-ind+4s03BqIXas7ZmraV3/kc5+mnqwCd+VDX1FndS6jxbt03kQKX2vXrWxNLuCjVYmhMwOZosAEKMM0a2q7w7A== + dependencies: + bluebird "^3.3.0" + body-parser "^1.16.1" + braces "^2.3.2" + chokidar "^2.0.3" + colors "^1.1.0" + connect "^3.6.0" + core-js "^2.2.0" + di "^0.0.1" + dom-serialize "^2.2.0" + flatted "^2.0.0" + glob "^7.1.1" + graceful-fs "^4.1.2" + http-proxy "^1.13.0" + isbinaryfile "^3.0.0" + lodash "^4.17.11" + log4js "^4.0.0" + mime "^2.3.1" + minimatch "^3.0.2" + optimist "^0.6.1" + qjobs "^1.1.4" + range-parser "^1.2.0" + rimraf "^2.6.0" + safe-buffer "^5.0.1" + socket.io "2.1.1" + source-map "^0.6.1" + tmp "0.0.33" + useragent "2.3.0" kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0: version "3.2.2" @@ -3795,13 +4337,6 @@ kind-of@^6.0.0, kind-of@^6.0.2: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== -klaw@^1.0.0: - version "1.3.1" - resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" - integrity sha1-QIhDO0azsbolnXh4XY6W9zugJDk= - optionalDependencies: - graceful-fs "^4.1.9" - latest-version@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-3.1.0.tgz#a205383fea322b33b5ae3b18abee0dc2f356ee15" @@ -3835,6 +4370,13 @@ lazystream@~0.1.0: dependencies: readable-stream "~1.0.2" +lcid@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835" + integrity sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU= + dependencies: + invert-kv "^1.0.0" + lie@~3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" @@ -3867,6 +4409,16 @@ load-json-file@^1.0.0: pinkie-promise "^2.0.0" strip-bom "^2.0.0" +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + loader-utils@^0.2.6: version "0.2.17" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.17.tgz#f86e6374d43205a6e6c60e9196f17c0299bfb348" @@ -3877,6 +4429,22 @@ loader-utils@^0.2.6: json5 "^0.5.0" object-assign "^4.0.1" +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + lodash._baseassign@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" @@ -4028,11 +4596,16 @@ lodash@^3.2.0, lodash@^3.8.0: resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" integrity sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y= -lodash@^4.0.0, lodash@^4.0.1, lodash@^4.14.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.8.0, lodash@~4.17.4: +lodash@^4.0.0, lodash@^4.14.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.8.0, lodash@~4.17.4: version "4.17.5" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" integrity sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw== +lodash@^4.16.6, lodash@^4.17.10, lodash@^4.17.11: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== + lodash@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" @@ -4056,11 +4629,27 @@ log4js@^0.6.31: readable-stream "~1.0.2" semver "~4.3.3" +log4js@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-4.1.0.tgz#57983c6a443546a8c8607e9cb045d2a117c27644" + integrity sha512-eDa+zZPeVEeK6QGJAePyXM6pg4P3n3TO5rX9iZMVY48JshsTyLJZLIL5HipI1kQ2qLsSyOpUqNND/C5H4WhhiA== + dependencies: + date-format "^2.0.0" + debug "^4.1.1" + flatted "^2.0.0" + rfdc "^1.1.2" + streamroller "^1.0.4" + lolex@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.3.2.tgz#7c3da62ffcb30f0f5a80a2566ca24e45d8a01f31" integrity sha1-fD2mL/yzDw9agKJWbKJORdigHzE= +long@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" + integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -4160,6 +4749,13 @@ media-typer@0.3.0: resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" + integrity sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y= + dependencies: + mimic-fn "^1.0.0" + memoizee@^0.4.3: version "0.4.11" resolved "https://registry.yarnpkg.com/memoizee/-/memoizee-0.4.11.tgz#bde9817663c9e40fdb2a4ea1c367296087ae8c8f" @@ -4240,6 +4836,25 @@ micromatch@^3.0.4: snapdragon "^0.8.1" to-regex "^3.0.1" +micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + mime-db@~1.12.0: version "1.12.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.12.0.tgz#3d0c63180f458eb10d325aaa37d7c58ae312e9d7" @@ -4250,7 +4865,7 @@ mime-db@~1.33.0: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" integrity sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ== -mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.7: +mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.7: version "2.1.18" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" integrity sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ== @@ -4269,6 +4884,11 @@ mime@^1.3.4: resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== +mime@^2.3.1: + version "2.4.2" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.2.tgz#ce5229a5e99ffc313abac806b482c10e7ba6ac78" + integrity sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg== + mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" @@ -4319,6 +4939,21 @@ minimist@~0.0.1: resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8= +minipass@^2.2.1, minipass@^2.3.4: + version "2.3.5" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" + integrity sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA== + dependencies: + safe-buffer "^5.1.2" + yallist "^3.0.0" + +minizlib@^1.1.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614" + integrity sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA== + dependencies: + minipass "^2.2.1" + mixin-deep@^1.2.0: version "1.3.1" resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" @@ -4332,13 +4967,6 @@ mkdirp@0.3.0: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e" integrity sha1-G79asbqCevI1dRQ0kEJkVfSB/h4= -mkdirp@0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.0.tgz#1d73076a6df986cd9344e15e71fcc05a4c9abf12" - integrity sha1-HXMHam35hs2TROFecfzAWkyavxI= - dependencies: - minimist "0.0.8" - mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -4405,6 +5033,11 @@ ms@2.0.0: resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= +ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== + multipipe@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-0.1.2.tgz#2a8f2ddf70eed564dff2d57f1e1a137d9f05078b" @@ -4427,6 +5060,11 @@ nan@^2.3.0: resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a" integrity sha1-7XFfP+neArV6XmJS2QqWZ14fCFo= +nan@^2.9.2: + version "2.13.2" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7" + integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw== + nanomatch@^1.2.9: version "1.2.9" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.9.tgz#879f7150cb2dab7a471259066c104eee6e0fa7c2" @@ -4450,11 +5088,25 @@ natives@^1.1.0: resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA== +needle@^2.2.1: + version "2.3.0" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.3.0.tgz#ce3fea21197267bacb310705a7bbe24f2a3a3492" + integrity sha512-QBZu7aAFR0522EyaXZM0FZ9GLpq6lvQ3uq8gteiDUp7wKdy0lSd2hPlgFwVuW1CBkfEs9PfDQsQzZghLs/psdg== + dependencies: + debug "^4.1.0" + iconv-lite "^0.4.4" + sax "^1.2.4" + negotiator@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" integrity sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk= +neo-async@^2.6.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" + integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== + next-tick@1: version "1.0.0" resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" @@ -4465,6 +5117,22 @@ node-int64@~0.3.0: resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.3.3.tgz#2d6e6b2ece5de8588b43d88d1bc41b26cd1fa84d" integrity sha1-LW5rLs5d6FiLQ9iNG8QbJs0fqE0= +node-pre-gyp@^0.10.0: + version "0.10.3" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc" + integrity sha512-d1xFs+C/IPS8Id0qPTZ4bUT8wWryfR/OzzAFxweG+uLN85oPzyo2Iw6bVlLQ/JOdgNonXLCoRyqDzDWq4iw72A== + dependencies: + detect-libc "^1.0.2" + mkdirp "^0.5.1" + needle "^2.2.1" + nopt "^4.0.1" + npm-packlist "^1.1.6" + npmlog "^4.0.2" + rc "^1.2.7" + rimraf "^2.6.1" + semver "^5.3.0" + tar "^4" + node-pre-gyp@^0.6.39: version "0.6.39" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz#c00e96860b23c0e1420ac7befc5044e1d78d8649" @@ -4482,7 +5150,7 @@ node-pre-gyp@^0.6.39: tar "^2.2.1" tar-pack "^3.4.0" -node-uuid@~1.4.0, node-uuid@~1.4.7: +node-uuid@~1.4.0: version "1.4.8" resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.8.tgz#b040eb0923968afabf8d32fb1f17f1167fdab907" integrity sha1-sEDrCSOWivq/jTL7HxfxFn/auQc= @@ -4515,13 +5183,18 @@ normalize-package-data@^2.3.0, normalize-package-data@^2.3.2, normalize-package- semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-path@^2.0.0, normalize-path@^2.0.1: +normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= dependencies: remove-trailing-separator "^1.0.1" +normalize-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + normalize-space-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/normalize-space-x/-/normalize-space-x-3.0.0.tgz#17907d6c7c724a4f9567471cbb319553bc0f8882" @@ -4531,11 +5204,24 @@ normalize-space-x@^3.0.0: trim-x "^3.0.0" white-space-x "^3.0.0" +npm-bundled@^1.0.1: + version "1.0.6" + resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd" + integrity sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g== + npm-install-package@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/npm-install-package/-/npm-install-package-2.1.0.tgz#d7efe3cfcd7ab00614b896ea53119dc9ab259125" integrity sha1-1+/jz816sAYUuJbqUxGdyaslkSU= +npm-packlist@^1.1.6: + version "1.4.1" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.1.tgz#19064cdf988da80ea3cee45533879d90192bbfbc" + integrity sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw== + dependencies: + ignore-walk "^3.0.1" + npm-bundled "^1.0.1" + npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -4568,7 +5254,7 @@ oauth-sign@~0.6.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.6.0.tgz#7dbeae44f6ca454e1f168451d630746735813ce3" integrity sha1-fb6uRPbKRU4fFoRR1jB0ZzWBPOM= -oauth-sign@~0.8.0, oauth-sign@~0.8.1, oauth-sign@~0.8.2: +oauth-sign@~0.8.1, oauth-sign@~0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" integrity sha1-Rqarfwrq2N6unsBWV4C31O/rnUM= @@ -4718,11 +5404,20 @@ ordered-read-streams@^0.1.0: resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" integrity sha1-/VZamvjrRHO6abbtijQ1LLVS8SY= -os-homedir@^1.0.0: +os-homedir@^1.0.0, os-homedir@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= +os-locale@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" + integrity sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA== + dependencies: + execa "^0.7.0" + lcid "^1.0.0" + mem "^1.1.0" + os-tmpdir@^1.0.0, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -4741,6 +5436,44 @@ p-finally@^1.0.0: resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + +p-limit@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.0.tgz#417c9941e6027a9abcba5092dd2904e255b5fbc2" + integrity sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ== + dependencies: + p-try "^2.0.0" + +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= + dependencies: + p-limit "^1.1.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + package-json@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/package-json/-/package-json-4.0.1.tgz#8869a0401253661c4c4ca3da6c2121ed555f5eed" @@ -4797,6 +5530,14 @@ parse-json@^2.2.0: dependencies: error-ex "^1.2.0" +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + parse-passwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" @@ -4833,6 +5574,11 @@ pascalcase@^0.1.1: resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= + path-exists@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" @@ -4840,6 +5586,11 @@ path-exists@^2.0.0: dependencies: pinkie-promise "^2.0.0" +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -4881,6 +5632,13 @@ path-type@^1.0.0: pify "^2.0.0" pinkie-promise "^2.0.0" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== + dependencies: + pify "^3.0.0" + pause-stream@0.0.11: version "0.0.11" resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" @@ -4888,11 +5646,6 @@ pause-stream@0.0.11: dependencies: through "~2.3" -pend@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50" - integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA= - performance-now@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" @@ -4903,35 +5656,6 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -phantomjs-prebuilt@^2.1.7: - version "2.1.16" - resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef" - integrity sha1-79ISpKOWbTZHaE6ouniFSb4q7+8= - dependencies: - es6-promise "^4.0.3" - extract-zip "^1.6.5" - fs-extra "^1.0.0" - hasha "^2.2.0" - kew "^0.7.0" - progress "^1.1.8" - request "^2.81.0" - request-progress "^2.0.1" - which "^1.2.10" - -phantomjs@^2.1.7: - version "2.1.7" - resolved "https://registry.yarnpkg.com/phantomjs/-/phantomjs-2.1.7.tgz#c6910f67935c37285b6114329fc2f27d5f3e3134" - integrity sha1-xpEPZ5NcNyhbYRQyn8LyfV8+MTQ= - dependencies: - extract-zip "~1.5.0" - fs-extra "~0.26.4" - hasha "^2.2.0" - kew "~0.7.0" - progress "~1.1.8" - request "~2.67.0" - request-progress "~2.0.1" - which "~1.2.2" - pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" @@ -4999,11 +5723,6 @@ process-nextick-args@~2.0.0: resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" integrity sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw== -progress@^1.1.8, progress@~1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" - integrity sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74= - promises-aplus-tests@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/promises-aplus-tests/-/promises-aplus-tests-2.1.2.tgz#76b7c5638968720861969cfbcd8795afd274885c" @@ -5021,6 +5740,25 @@ property-is-enumerable-x@^1.1.0: to-object-x "^1.4.1" to-property-key-x "^2.0.1" +protobufjs@6.8.8: + version "6.8.8" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.8.8.tgz#c8b4f1282fd7a90e6f5b109ed11c84af82908e7c" + integrity sha512-AAmHtD5pXgZfi7GMpllpO3q1Xw1OYldr+dMUlAnffGTAhqkg72WdmSY71uKBF/JuyiKs8psYbtKrhi0ASCD8qw== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^4.0.0" + "@types/node" "^10.1.0" + long "^4.0.0" + pseudomap@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" @@ -5059,21 +5797,26 @@ q@~1.4.1: resolved "https://registry.yarnpkg.com/q/-/q-1.4.1.tgz#55705bcd93c5f3673530c2c2cbc0c2b3addc286e" integrity sha1-VXBbzZPF82c1MMLCy8DCs63cKG4= +qjobs@^1.1.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" + integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== + qs@6.5.1, qs@~6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" integrity sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A== +qs@6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" + integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== + qs@~2.4.0: version "2.4.2" resolved "https://registry.yarnpkg.com/qs/-/qs-2.4.2.tgz#f7ce788e5777df0b5010da7f7c4e73ba32470f5a" integrity sha1-9854jld33wtQENp/fE5zujJHD1o= -qs@~5.2.0: - version "5.2.1" - resolved "https://registry.yarnpkg.com/qs/-/qs-5.2.1.tgz#801fee030e0b9450d6385adc48a4cc55b44aedfc" - integrity sha1-gB/uAw4LlFDWOFrcSKTMVbRK7fw= - qs@~6.4.0: version "6.4.0" resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" @@ -5092,6 +5835,11 @@ randomatic@^1.1.3: is-number "^3.0.0" kind-of "^4.0.0" +range-parser@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" + integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= + raw-body@2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" @@ -5102,6 +5850,16 @@ raw-body@2.3.2: iconv-lite "0.4.19" unpipe "1.0.0" +raw-body@2.3.3: + version "2.3.3" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.3.tgz#1b324ece6b5706e153855bc1148c65bb7f6ea0c3" + integrity sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw== + dependencies: + bytes "3.0.0" + http-errors "1.6.3" + iconv-lite "0.4.23" + unpipe "1.0.0" + rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: version "1.2.5" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.5.tgz#275cd687f6e3b36cc756baa26dfee80a790301fd" @@ -5112,6 +5870,16 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.1.7: minimist "^1.2.0" strip-json-comments "~2.0.1" +rc@^1.2.7: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -5120,6 +5888,14 @@ read-pkg-up@^1.0.1: find-up "^1.0.0" read-pkg "^1.0.0" +read-pkg-up@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-4.0.0.tgz#1b221c6088ba7799601c808f91161c66e58f8978" + integrity sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA== + dependencies: + find-up "^3.0.0" + read-pkg "^3.0.0" + read-pkg@^1.0.0, read-pkg@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" @@ -5129,6 +5905,15 @@ read-pkg@^1.0.0, read-pkg@^1.1.0: normalize-package-data "^2.3.2" path-type "^1.0.0" +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + "readable-stream@2 || 3": version "3.1.1" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.1.1.tgz#ed6bbc6c5ba58b090039ff18ce670515795aeb06" @@ -5171,7 +5956,7 @@ readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@~2.0.0, readable-stream@~2.0.5, readable-stream@~2.0.6: +readable-stream@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" integrity sha1-j5A0HmilPMySh4jaz80Rs265t44= @@ -5193,6 +5978,15 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" +readdirp@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" + integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ== + dependencies: + graceful-fs "^4.1.11" + micromatch "^3.1.10" + readable-stream "^2.0.2" + rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" @@ -5220,7 +6014,7 @@ regex-cache@^0.4.2: dependencies: is-equal-shallow "^0.1.3" -regex-not@^1.0.0: +regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== @@ -5288,13 +6082,6 @@ replace-ext@^1.0.0: resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb" integrity sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs= -request-progress@^2.0.1, request-progress@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08" - integrity sha1-XTa7V5YcZzqlt4jbyBQf3yO0Tgg= - dependencies: - throttleit "^1.0.0" - request@2.81.0: version "2.81.0" resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" @@ -5323,7 +6110,7 @@ request@2.81.0: tunnel-agent "^0.6.0" uuid "^3.0.0" -request@^2.78.0, request@^2.81.0, request@~2.83.0: +request@^2.78.0, request@~2.83.0: version "2.83.0" resolved "https://registry.yarnpkg.com/request/-/request-2.83.0.tgz#ca0b65da02ed62935887808e6f510381034e3356" integrity sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw== @@ -5375,32 +6162,6 @@ request@~2.55.0: tough-cookie ">=0.12.0" tunnel-agent "~0.4.0" -request@~2.67.0: - version "2.67.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.67.0.tgz#8af74780e2bf11ea0ae9aa965c11f11afd272742" - integrity sha1-ivdHgOK/EeoK6aqWXBHxGv0nJ0I= - dependencies: - aws-sign2 "~0.6.0" - bl "~1.0.0" - caseless "~0.11.0" - combined-stream "~1.0.5" - extend "~3.0.0" - forever-agent "~0.6.1" - form-data "~1.0.0-rc3" - har-validator "~2.0.2" - hawk "~3.1.0" - http-signature "~1.1.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - node-uuid "~1.4.7" - oauth-sign "~0.8.0" - qs "~5.2.0" - stringstream "~0.0.4" - tough-cookie "~2.2.0" - tunnel-agent "~0.4.1" - require-coercible-to-string-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/require-coercible-to-string-x/-/require-coercible-to-string-x-1.0.0.tgz#367b3e9ca67e00324c411b0b498453a74cd5569e" @@ -5409,6 +6170,21 @@ require-coercible-to-string-x@^1.0.0: require-object-coercible-x "^1.4.1" to-string-x "^1.4.2" +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" + integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + require-object-coercible-x@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/require-object-coercible-x/-/require-object-coercible-x-1.4.1.tgz#75b9fb5bda2d15cf705a5714f108e8b40ca3eb2e" @@ -5416,6 +6192,11 @@ require-object-coercible-x@^1.4.1: dependencies: is-nil-x "^1.4.1" +requirejs@2.3.5: + version "2.3.5" + resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.5.tgz#617b9acbbcb336540ef4914d790323a8d4b861b0" + integrity sha512-svnO+aNcR/an9Dpi44C7KSAy5fFGLtmPbaaCeQaklUz8BQhS64tWWIIlvEA5jrWICzlO/X9KSzSeXFnZdBu8nw== + requires-port@1.x.x: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -5454,6 +6235,11 @@ ret@~0.1.10: resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== +rfdc@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.1.2.tgz#e6e72d74f5dc39de8f538f65e00c36c18018e349" + integrity sha512-92ktAgvZhBzYTIK0Mja9uen5q5J3NRVMoDkJL2VMwq6SXjVCgqvQeVP2XAaUY6HT+XpQYeLSjb3UoitBryKmdA== + rgb2hex@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/rgb2hex/-/rgb2hex-0.1.0.tgz#ccd55f860ae0c5c4ea37504b958e442d8d12325b" @@ -5478,6 +6264,13 @@ rimraf@2.2.6: resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.6.tgz#c59597569b14d956ad29cacc42bdddf5f0ea4f4c" integrity sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w= +rimraf@^2.6.0, rimraf@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + rimraf@~2.2.6: version "2.2.8" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" @@ -5529,6 +6322,11 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" integrity sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg== +safe-buffer@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + safe-regex@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" @@ -5536,6 +6334,11 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" +"safer-buffer@>= 2.1.2 < 3": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + samsam@1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.2.tgz#bec11fdc83a9fda063401210e40176c3024d1567" @@ -5546,6 +6349,17 @@ samsam@~1.1: resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.1.3.tgz#9f5087419b4d091f232571e7fa52e90b0f552621" integrity sha1-n1CHQZtNCR8jJXHn+lLpCw9VJiE= +sauce-connect-launcher@^1.2.4: + version "1.2.5" + resolved "https://registry.yarnpkg.com/sauce-connect-launcher/-/sauce-connect-launcher-1.2.5.tgz#ac12e38be4168825a9492862a6bdab5e835a5e30" + integrity sha512-q9GoMBgsBApfYC/GWfNZMgoYOls6YZ77bJ7kXiHDtltVnV+QFiz0/Ac7LSRd6n69RfP/ful8spIFWv0oFs3eOQ== + dependencies: + adm-zip "~0.4.3" + async "^2.1.2" + https-proxy-agent "^2.2.1" + lodash "^4.16.6" + rimraf "^2.5.4" + sauce-connect-launcher@~0.11.1: version "0.11.1" resolved "https://registry.yarnpkg.com/sauce-connect-launcher/-/sauce-connect-launcher-0.11.1.tgz#65f51d8891249fdabaaf17599734de1902476129" @@ -5556,12 +6370,19 @@ sauce-connect-launcher@~0.11.1: lodash "3.5.0" rimraf "2.2.6" +saucelabs@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-1.5.0.tgz#9405a73c360d449b232839919a86c396d379fd9d" + integrity sha512-jlX3FGdWvYf4Q3LFfFWS1QvPg3IGCGWxIc8QBFdPTbpTJnt/v17FHXYVAn7C8sHf1yUXo2c7yIM0isDryfYtHQ== + dependencies: + https-proxy-agent "^2.2.1" + saucelabs@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/saucelabs/-/saucelabs-0.1.1.tgz#5e0ea1cf3d735d6ea15fde94b5bda6bc15d2c06d" integrity sha1-Xg6hzz1zXW6hX96Utb2mvBXSwG0= -sax@>=0.6.0: +sax@>=0.6.0, sax@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== @@ -5576,6 +6397,16 @@ selenium-webdriver@^3.4.0: tmp "0.0.30" xml2js "^0.4.17" +selenium-webdriver@^4.0.0-alpha.1: + version "4.0.0-alpha.1" + resolved "https://registry.yarnpkg.com/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz#cc93415e21d2dc1dfd85dfc5f6b55f3ac53933b1" + integrity sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q== + dependencies: + jszip "^3.1.3" + rimraf "^2.5.4" + tmp "0.0.30" + xml2js "^0.4.17" + semver-diff@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" @@ -5588,6 +6419,11 @@ semver-diff@^2.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA== +semver@5.6.0: + version "5.6.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" + integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg== + semver@^4.1.0, semver@~4.3.3: version "4.3.6" resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" @@ -5598,7 +6434,7 @@ sequencify@~0.0.7: resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" integrity sha1-kM/xnQLgcCf9dn9erT57ldHnOAw= -set-blocking@~2.0.0: +set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= @@ -5640,6 +6476,11 @@ setprototypeof@1.0.3: resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" integrity sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ= +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -5652,6 +6493,15 @@ shebang-regex@^1.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= +shelljs@^0.8.3: + version "0.8.3" + resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097" + integrity sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A== + dependencies: + glob "^7.0.0" + interpret "^1.0.0" + rechoir "^0.6.2" + sigmund@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" @@ -5724,6 +6574,11 @@ socket.io-adapter@0.5.0: debug "2.3.3" socket.io-parser "2.3.1" +socket.io-adapter@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-1.1.1.tgz#2a805e8a14d6372124dd9159ad4502f8cb07f06b" + integrity sha1-KoBeihTWNyEk3ZFZrUUC+MsH8Gs= + socket.io-client@1.7.4: version "1.7.4" resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-1.7.4.tgz#ec9f820356ed99ef6d357f0756d648717bdd4281" @@ -5741,6 +6596,26 @@ socket.io-client@1.7.4: socket.io-parser "2.3.1" to-array "0.1.4" +socket.io-client@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/socket.io-client/-/socket.io-client-2.1.1.tgz#dcb38103436ab4578ddb026638ae2f21b623671f" + integrity sha512-jxnFyhAuFxYfjqIgduQlhzqTcOEQSn+OHKVfAxWaNWa7ecP7xSNk2Dx/3UEsDcY7NcFafxvNvKPmmO7HTwTxGQ== + dependencies: + backo2 "1.0.2" + base64-arraybuffer "0.1.5" + component-bind "1.0.0" + component-emitter "1.2.1" + debug "~3.1.0" + engine.io-client "~3.2.0" + has-binary2 "~1.0.2" + has-cors "1.1.0" + indexof "0.0.1" + object-component "0.0.3" + parseqs "0.0.5" + parseuri "0.0.5" + socket.io-parser "~3.2.0" + to-array "0.1.4" + socket.io-parser@2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-2.3.1.tgz#dd532025103ce429697326befd64005fcfe5b4a0" @@ -5751,6 +6626,27 @@ socket.io-parser@2.3.1: isarray "0.0.1" json3 "3.3.2" +socket.io-parser@~3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-3.2.0.tgz#e7c6228b6aa1f814e6148aea325b51aa9499e077" + integrity sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA== + dependencies: + component-emitter "1.2.1" + debug "~3.1.0" + isarray "2.0.1" + +socket.io@2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-2.1.1.tgz#a069c5feabee3e6b214a75b40ce0652e1cfb9980" + integrity sha512-rORqq9c+7W0DAK3cleWNSyfv/qKXV99hV4tZe+gGLfBECw3XEhBy7x85F3wypA9688LKjtwO9pX9L33/xQI8yA== + dependencies: + debug "~3.1.0" + engine.io "~3.2.0" + has-binary2 "~1.0.2" + socket.io-adapter "~1.1.0" + socket.io-client "2.1.1" + socket.io-parser "~3.2.0" + socket.io@^1.4.5: version "1.7.4" resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-1.7.4.tgz#2f7ecedc3391bf2d5c73e291fe233e6e34d4dd00" @@ -5785,6 +6681,14 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" +source-map-support@0.5.9: + version "0.5.9" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" + integrity sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map-support@~0.5.9: version "0.5.10" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.10.tgz#2214080bc9d51832511ee2bab96e3c2f9353120c" @@ -5822,7 +6726,7 @@ source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.1: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.0, source-map@~0.6.1: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -5832,6 +6736,18 @@ sparkles@^1.0.0: resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" integrity sha1-Gsu/tZJDbRC76PeFt8xvgoFQEsM= +spawn-wrap@^1.4.2: + version "1.4.2" + resolved "https://registry.yarnpkg.com/spawn-wrap/-/spawn-wrap-1.4.2.tgz#cff58e73a8224617b6561abdc32586ea0c82248c" + integrity sha512-vMwR3OmmDhnxCVxM8M+xO/FtIp6Ju/mNaDfCMMW7FDcLRTPFWUswec4LXJHTJE2hwTI9O0YBfygu4DalFl7Ylg== + dependencies: + foreground-child "^1.5.6" + mkdirp "^0.5.0" + os-homedir "^1.0.1" + rimraf "^2.6.2" + signal-exit "^3.0.2" + which "^1.3.0" + spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" @@ -5905,6 +6821,11 @@ static-extend@^0.1.1: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" integrity sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew== +"statuses@>= 1.4.0 < 2": + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= + statuses@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.3.1.tgz#faf51b9eb74aaef3b3acf4ad5f61abf24cb7b93e" @@ -5940,6 +6861,17 @@ stream-shift@^1.0.0: resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" integrity sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI= +streamroller@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-1.0.4.tgz#d485c7624796d5e2eb34190c79afcbf006afb5e6" + integrity sha512-Wc2Gm5ygjSX8ZpW9J7Y9FwiSzTlKSvcl0FTTMd3rn7RoxDXpBW+xD9TY5sWL2n0UR61COB0LG1BQvN6nTUQbLQ== + dependencies: + async "^2.6.1" + date-format "^2.0.0" + debug "^3.1.0" + fs-extra "^7.0.0" + lodash "^4.17.10" + string-width@^1.0.1, string-width@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" @@ -6017,6 +6949,11 @@ strip-bom@^2.0.0: dependencies: is-utf8 "^0.2.0" +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" @@ -6056,6 +6993,13 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= +supports-color@^3.1.2: + version "3.2.3" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + integrity sha1-ZawFBLOVQXHYpklGsq48u4pfVPY= + dependencies: + has-flag "^1.0.0" + supports-color@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.2.0.tgz#b0d5333b1184dd3666cbe5aa0b45c5ac7ac17a4a" @@ -6125,6 +7069,19 @@ tar@^2.2.1: fstream "^1.0.2" inherits "2" +tar@^4: + version "4.4.8" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d" + integrity sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ== + dependencies: + chownr "^1.1.1" + fs-minipass "^1.2.5" + minipass "^2.3.4" + minizlib "^1.1.1" + mkdirp "^0.5.0" + safe-buffer "^5.1.2" + yallist "^3.0.2" + temp@^0.8.1: version "0.8.3" resolved "https://registry.yarnpkg.com/temp/-/temp-0.8.3.tgz#e0c6bc4d26b903124410e4fed81103014dfc1f59" @@ -6149,16 +7106,21 @@ terser@^3.14.1, terser@^3.16.1: source-map "~0.6.1" source-map-support "~0.5.9" +test-exclude@^5.2.2: + version "5.2.3" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0" + integrity sha512-M+oxtseCFO3EDtAaGH7iiej3CBkzXqFMbzqYAACdzKui4eZA+pq3tZEwChvOdNfa7xxy8BfbmgJSIr43cC/+2g== + dependencies: + glob "^7.1.3" + minimatch "^3.0.4" + read-pkg-up "^4.0.0" + require-main-filename "^2.0.0" + text-extensions@^1.0.0: version "1.7.0" resolved "https://registry.yarnpkg.com/text-extensions/-/text-extensions-1.7.0.tgz#faaaba2625ed746d568a23e4d0aacd9bf08a8b39" integrity sha512-AKXZeDq230UaSzaO5s3qQUZOaC7iKbzq0jOFL614R7d9R593HLqAOL0cYoqLdkNrjBSOdmoQI06yigq1TSBXAg== -throttleit@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c" - integrity sha1-nnhYNtr0Z0MUWlmEtiaNgoUorGw= - through2-filter@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec" @@ -6228,7 +7190,7 @@ tmp@0.0.30: dependencies: os-tmpdir "~1.0.1" -tmp@0.0.x, tmp@^0.0.33: +tmp@0.0.33, tmp@0.0.x, tmp@^0.0.33: version "0.0.33" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" integrity sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw== @@ -6326,6 +7288,16 @@ to-regex@^3.0.1: extend-shallow "^2.0.1" regex-not "^1.0.0" +to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + to-string-symbols-supported-x@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/to-string-symbols-supported-x/-/to-string-symbols-supported-x-1.0.0.tgz#d435eb72312fe885b18047a96d59c75641476872" @@ -6357,11 +7329,6 @@ tough-cookie@>=0.12.0, tough-cookie@~2.3.0, tough-cookie@~2.3.3: dependencies: punycode "^1.4.1" -tough-cookie@~2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.2.2.tgz#c83a1830f4e5ef0b93ef2a3488e724f8de016ac7" - integrity sha1-yDoYMPTl7wuT7yo0iOck+N4Basc= - trim-left-x@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/trim-left-x/-/trim-left-x-3.0.0.tgz#356cf055896726b9754425e841398842e90b4cdf" @@ -6410,7 +7377,7 @@ ts-loader@^0.6.0: object-assign "^2.0.0" semver "^5.0.1" -tslib@^1.9.0: +tslib@^1.8.1, tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== @@ -6437,6 +7404,13 @@ tslint@^4.1.1: tsutils "^1.1.0" update-notifier "^2.0.0" +tsutils@2.27.2: + version "2.27.2" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.2.tgz#60ba88a23d6f785ec4b89c6e8179cac9b431f1c7" + integrity sha512-qf6rmT84TFMuxAKez2pIfR8UCai49iQsfB7YWVjV1bKpy/d0PWT5rEOSM6La9PiHZ0k1RRZQiwVdVJfQ3BPHgg== + dependencies: + tslib "^1.8.1" + tsutils@^1.1.0: version "1.9.1" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0" @@ -6449,7 +7423,7 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -tunnel-agent@~0.4.0, tunnel-agent@~0.4.1: +tunnel-agent@~0.4.0: version "0.4.3" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" integrity sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us= @@ -6459,7 +7433,7 @@ tweetnacl@^0.14.3, tweetnacl@~0.14.0: resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= -type-is@~1.6.15: +type-is@~1.6.15, type-is@~1.6.16: version "1.6.16" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194" integrity sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q== @@ -6467,7 +7441,7 @@ type-is@~1.6.15: media-typer "0.3.0" mime-types "~2.1.18" -typedarray@^0.0.6, typedarray@~0.0.5: +typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= @@ -6497,6 +7471,14 @@ uglify-js@^2.6: optionalDependencies: uglify-to-browserify "~1.0.0" +uglify-js@^3.1.4: + version "3.5.12" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.5.12.tgz#6b759cabc08c3e91fe82323d6387019f0c5864cd" + integrity sha512-KeQesOpPiZNgVwJj8Ge3P4JYbQHUdZzpx6Fahy6eKAYRSV4zhVmLXoC+JtOeYxcHCHTve8RG1ZGdTvpeOUM26Q== + dependencies: + commander "~2.20.0" + source-map "~0.6.1" + uglify-save-license@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/uglify-save-license/-/uglify-save-license-0.4.1.tgz#95726c17cc6fd171c3617e3bf4d8d82aa8c4cce1" @@ -6517,6 +7499,11 @@ ultron@1.0.x: resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.0.2.tgz#ace116ab557cd197386a4e88f4685378c8b2e4fa" integrity sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po= +ultron@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" + integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== + unc-path-regex@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" @@ -6562,6 +7549,11 @@ unique-string@^1.0.0: dependencies: crypto-random-string "^1.0.0" +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -6580,6 +7572,11 @@ unzip-response@^2.0.1: resolved "https://registry.yarnpkg.com/unzip-response/-/unzip-response-2.0.1.tgz#d2f0f737d16b0615e72a6935ed04214572d56f97" integrity sha1-0vD3N9FrBhXnKmk17QQhRXLVb5c= +upath@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/upath/-/upath-1.1.2.tgz#3db658600edaeeccbe6db5e684d67ee8c2acd068" + integrity sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q== + update-notifier@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-2.3.0.tgz#4e8827a6bb915140ab093559d7014e3ebb837451" @@ -6629,7 +7626,7 @@ user-home@^1.1.1: resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" integrity sha1-K1viOjK2Onyd640PKNSFcko98ZA= -useragent@^2.1.6: +useragent@2.3.0, useragent@^2.1.6: version "2.3.0" resolved "https://registry.yarnpkg.com/useragent/-/useragent-2.3.0.tgz#217f943ad540cb2128658ab23fc960f6a88c9972" integrity sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw== @@ -6659,6 +7656,35 @@ uuid@^3.0.0, uuid@^3.1.0: resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" integrity sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA== +uuid@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== + +v8-coverage@1.0.9: + version "1.0.9" + resolved "https://registry.yarnpkg.com/v8-coverage/-/v8-coverage-1.0.9.tgz#780889680c0fea0f587adf22e2b5f443b9434745" + integrity sha512-JolsCH1JDI2QULrxkAGZaovJPvg/Q0p20Uj0F5N8fPtYDtz38gNBRPQ/WVXlLLd3d8WHvKN96AfE4XFk4u0g2g== + dependencies: + debug "^3.1.0" + foreground-child "^1.5.6" + istanbul-lib-coverage "^1.2.0" + istanbul-lib-report "^1.1.3" + istanbul-reports "^1.3.0" + mkdirp "^0.5.1" + rimraf "^2.6.2" + signal-exit "^3.0.2" + spawn-wrap "^1.4.2" + test-exclude "^5.2.2" + uuid "^3.3.2" + v8-to-istanbul "1.2.0" + yargs "^11.0.0" + +v8-to-istanbul@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-1.2.0.tgz#f6a22ffb08b2202aaba8c2be497d1d41fe8fb4b6" + integrity sha512-rVSmjdEfJmOHN8GYCbg+XUhbzXZr7DzdaXIslB9DdcopGZEMsW5x5qIdxr/8DcW7msULHNnvs/xUY1TszvhKRw== + v8flags@^2.0.2: version "2.1.1" resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" @@ -6854,17 +7880,22 @@ when@^3.7.5: resolved "https://registry.yarnpkg.com/when/-/when-3.7.8.tgz#c7130b6a7ea04693e842cdc9e7a1f2aa39a39f82" integrity sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I= -which@^1.0.5, which@^1.2.1, which@^1.2.10, which@^1.2.14, which@^1.2.9: +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +which@^1.0.5, which@^1.2.1, which@^1.2.14, which@^1.2.9: version "1.3.0" resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" integrity sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg== dependencies: isexe "^2.0.0" -which@~1.2.2: - version "1.2.14" - resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5" - integrity sha1-mofEN48D6CfOyvGs31bHNsAcFOU= +which@^1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== dependencies: isexe "^2.0.0" @@ -6902,6 +7933,14 @@ wordwrap@~0.0.2: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= +wrap-ansi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" + integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU= + dependencies: + string-width "^1.0.1" + strip-ansi "^3.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" @@ -6924,6 +7963,15 @@ ws@~1.1.5: options ">=0.0.5" ultron "1.0.x" +ws@~3.3.1: + version "3.3.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" + integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== + dependencies: + async-limiter "~1.0.0" + safe-buffer "~5.1.0" + ultron "~1.1.0" + wtf-8@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a" @@ -6952,16 +8000,56 @@ xmlhttprequest-ssl@1.5.3: resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.3.tgz#185a888c04eca46c3e4070d99f7b49de3528992d" integrity sha1-GFqIjATspGw+QHDZn3tJ3jUomS0= +xmlhttprequest-ssl@~1.5.4: + version "1.5.5" + resolved "https://registry.yarnpkg.com/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz#c2876b06168aadc40e57d97e81191ac8f4398b3e" + integrity sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4= + "xtend@>=4.0.0 <4.1.0-0", xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" integrity sha1-pcbVMr5lbiPbgg77lDofBJmNY68= +y18n@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" + integrity sha1-bRX7qITAhnnA136I53WegR4H+kE= + yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= +yallist@^3.0.0, yallist@^3.0.2: + version "3.0.3" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.3.tgz#b4b049e314be545e3ce802236d6cd22cd91c3de9" + integrity sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A== + +yargs-parser@^9.0.2: + version "9.0.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-9.0.2.tgz#9ccf6a43460fe4ed40a9bb68f48d43b8a68cc077" + integrity sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc= + dependencies: + camelcase "^4.1.0" + +yargs@^11.0.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-11.1.0.tgz#90b869934ed6e871115ea2ff58b03f4724ed2d77" + integrity sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A== + dependencies: + cliui "^4.0.0" + decamelize "^1.1.1" + find-up "^2.1.0" + get-caller-file "^1.0.1" + os-locale "^2.0.0" + require-directory "^2.1.1" + require-main-filename "^1.0.1" + set-blocking "^2.0.0" + string-width "^2.0.0" + which-module "^2.0.0" + y18n "^3.2.1" + yargs-parser "^9.0.2" + yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" @@ -6972,13 +8060,6 @@ yargs@~3.10.0: decamelize "^1.0.0" window-size "0.1.0" -yauzl@2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.4.1.tgz#9528f442dab1b2284e58b4379bb194e22e0c4005" - integrity sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU= - dependencies: - fd-slicer "~1.0.1" - yeast@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419" From b11bd466c20dc338b6d4d5bc3e59868ff263778d Mon Sep 17 00:00:00 2001 From: JiaLiPassion Date: Mon, 22 Jul 2019 23:26:01 +0900 Subject: [PATCH 106/106] doc: archive zone.js repo (#1250) --- README.md | 92 +------------------------------------------------------ 1 file changed, 1 insertion(+), 91 deletions(-) diff --git a/README.md b/README.md index 36772cd2f..fd047346f 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,3 @@ # Zone.js -[![Build Status](https://travis-ci.org/angular/zone.js.png)](https://travis-ci.org/angular/zone.js) -[![CDNJS](https://img.shields.io/cdnjs/v/zone.js.svg)](https://cdnjs.com/libraries/zone.js) - -Implements _Zones_ for JavaScript, inspired by [Dart](https://www.dartlang.org/articles/zones/). - -> If you're using zone.js via unpkg (i.e. using `https://unpkg.com/zone.js`) -> and you're using any of the following libraries, make sure you import them first - -> * 'newrelic' as it patches global.Promise before zone.js does -> * 'async-listener' as it patches global.setTimeout, global.setInterval before zone.js does -> * 'continuation-local-storage' as it uses async-listener - -# NEW Zone.js POST-v0.6.0 - -See the new API [here](./dist/zone.js.d.ts). - -Read up on [Zone Primer](https://docs.google.com/document/d/1F5Ug0jcrm031vhSMJEOgp1l-Is-Vf0UCNDY-LsQtAIY). - -## What's a Zone? - -A Zone is an execution context that persists across async tasks. -You can think of it as [thread-local storage](http://en.wikipedia.org/wiki/Thread-local_storage) for JavaScript VMs. - -See this video from ng-conf 2014 for a detailed explanation: - -[![screenshot of the zone.js presentation and ng-conf 2014](/presentation.png)](//www.youtube.com/watch?v=3IqtmUscE_U&t=150) - -## See also -* [async-listener](https://github.com/othiym23/async-listener) - a similar library for node -* [Async stack traces in Chrome](http://www.html5rocks.com/en/tutorials/developertools/async-call-stack/) -* [strongloop/zone](https://github.com/strongloop/zone) (Deprecated) -* [vizone](https://github.com/gilbox/vizone) - control flow visualizer that uses zone.js - -## Standard API support - -zone.js patched most standard web APIs (such as DOM events, `XMLHttpRequest`, ...) and nodejs APIs -(`EventEmitter`, `fs`, ...), for more details, please see [STANDARD-APIS.md](STANDARD-APIS.md). - -## Nonstandard API support - -We are adding support to some nonstandard APIs, such as MediaQuery and -Notification. Please see [NON-STANDARD-APIS.md](NON-STANDARD-APIS.md) for more details. - -## Examples - -You can find some samples to describe how to use zone.js in [SAMPLE.md](SAMPLE.md). - -## Modules - -zone.js patches the async APIs described above, but those patches will have some overhead. -Starting from zone.js v0.8.9, you can choose which web API module you want to patch. -For more details, please -see [MODULE.md](MODULE.md). - -## Bundles -There are several bundles under `dist` folder. - -|Bundle|Summary| -|---|---| -|zone.js|the default bundle, contains the most used APIs such as `setTimeout/Promise/EventTarget...`, also this bundle supports all evergreen and legacy (IE/Legacy Firefox/Legacy Safari) Browsers| -|zone-evergreen.js|the bundle for evergreen browsers, doesn't include the `patch` for `legacy` browsers such as `IE` or old versions of `Firefox/Safari`| -|zone-legacy.js|the patch bundle for legacy browsers, only includes the `patch` for `legacy` browsers such as `IE` or old versions of `Firefox/Safari`. This bundle must be loaded after `zone-evergreen.js`, **`zone.js`=`zone-evergreen.js` + `zone-legacy.js`**| -|zone-testing.js|the bundle for zone testing support, including `jasmine/mocha` support and `async/fakeAsync/sync` test utilities| -|zone-externs.js|the API definitions for `closure compiler`| - -And here are the additional optional patches not included in the main zone.js bundles - -|Patch|Summary| -|---|---| -|webapis-media-query.js|patch for `MediaQuery APIs`| -|webapis-notification.js|patch for `Notification APIs`| -|webapis-rtc-peer-connection.js|patch for `RTCPeerConnection APIs`| -|webapis-shadydom.js|patch for `Shady DOM APIs`| -|zone-bluebird.js|patch for `Bluebird APIs`| -|zone-error.js|patch for `Error Global Object`, supports remove `Zone StackTrace`| -|zone-patch-canvas.js|patch for `Canvas API`| -|zone-patch-cordova.js|patch for `Cordova API`| -|zone-patch-electron.js|patch for `Electron API`| -|zone-patch-fetch.js|patch for `Fetch API`| -|zone-patch-jsonp.js|utility for `jsonp API`| -|zone-patch-resize-observer.js|patch for `ResizeObserver API`| -|zone-patch-rxjs.js|patch for `rxjs API`| -|zone-patch-rxjs-fake-async.js|patch for `rxjs fakeasync test`| -|zone-patch-socket-io.js|patch for `socket-io`| -|zone-patch-user-media.js|patch for `UserMedia API`| - -## Promise A+ test passed -[![Promises/A+ 1.1 compliant](https://promisesaplus.com/assets/logo-small.png)](https://promisesaplus.com/) - -## License -MIT +## The `zone.js repo` has been moved to `angular mono repo` [here](https://github.com/angular/angular/tree/master/packages/zone.js), This repo has been archived. Please create issue in angular repo. Thanks! \ No newline at end of file