mirror of https://github.com/ghostfolio/ghostfolio
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
34 KiB
8 lines
34 KiB
'use strict';
|
|
/**
|
|
* @license Angular
|
|
* (c) 2010-2025 Google LLC. https://angular.dev/
|
|
* License: MIT
|
|
*/
|
|
var he=Object.defineProperty,fe=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var Te=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable;var U=(i,e,t)=>e in i?he(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,O=(i,e)=>{for(var t in e||(e={}))Te.call(e,t)&&U(i,t,e[t]);if($)for(var t of $(e))_e.call(e,t)&&U(i,t,e[t]);return i},G=(i,e)=>fe(i,de(e));var T=(i,e,t)=>(U(i,typeof e!="symbol"?e+"":e,t),t);var q=(i,e,t)=>new Promise((n,r)=>{var h=l=>{try{d(t.next(l))}catch(w){r(w)}},u=l=>{try{d(t.throw(l))}catch(w){r(w)}},d=l=>l.done?n(l.value):Promise.resolve(l.value).then(h,u);d((t=t.apply(i,e)).next())});function K(i){i.__load_patch("jasmine",(e,t,n)=>{var Z;let r=function(s,o){for(let c in o)o.hasOwnProperty(c)&&(s[c]=o[c]);function a(){this.constructor=s}s.prototype=o===null?Object.create(o):(a.prototype=o.prototype,new a)};if(!t)throw new Error("Missing: zone.js");if(typeof jest!="undefined"||typeof jasmine=="undefined"||jasmine.__zone_patch__)return;jasmine.__zone_patch__=!0;let h=t.SyncTestZoneSpec,u=t.ProxyZoneSpec;if(!h)throw new Error("Missing: SyncTestZoneSpec");if(!u)throw new Error("Missing: ProxyZoneSpec");let d=t.current,l=t.__symbol__,w=e[l("fakeAsyncDisablePatchingClock")]===!0,m=!w&&(e[l("fakeAsyncPatchLock")]===!0||e[l("fakeAsyncAutoFakeAsyncWhenClockPatched")]===!0),P=jasmine.getEnv();if(["describe","xdescribe","fdescribe"].forEach(s=>{let o=P[s];P[s]=function(a,c){return o.call(this,a,b(a,c))}}),["it","xit","fit"].forEach(s=>{let o=P[s];P[l(s)]=o,P[s]=function(a,c,k){return arguments[1]=p(c),o.apply(this,arguments)}}),["beforeEach","afterEach","beforeAll","afterAll"].forEach(s=>{let o=P[s];P[l(s)]=o,P[s]=function(a,c){return arguments[0]=p(a),o.apply(this,arguments)}}),!w){let s=jasmine[l("clock")]=jasmine.clock;jasmine.clock=function(){let o=s.apply(this,arguments);if(!o[l("patched")]){o[l("patched")]=l("patched");let a=o[l("tick")]=o.tick;o.tick=function(){let k=t.current.get("FakeAsyncTestZoneSpec");return k?k.tick.apply(k,arguments):a.apply(this,arguments)};let c=o[l("mockDate")]=o.mockDate;o.mockDate=function(){let k=t.current.get("FakeAsyncTestZoneSpec");if(k){let S=arguments.length>0?arguments[0]:new Date;return k.setFakeBaseSystemTime.apply(k,S&&typeof S.getTime=="function"?[S.getTime()]:arguments)}return c.apply(this,arguments)},m&&["install","uninstall"].forEach(k=>{let S=o[l(k)]=o[k];o[k]=function(){if(t.FakeAsyncTestZoneSpec){jasmine[l("clockInstalled")]=k==="install";return}return S.apply(this,arguments)}})}return o}}if(!jasmine[t.__symbol__("createSpyObj")]){let s=jasmine.createSpyObj;jasmine[t.__symbol__("createSpyObj")]=s,jasmine.createSpyObj=function(){let o=Array.prototype.slice.call(arguments),a=o.length>=3?o[2]:null,c;if(a){let k=Object.defineProperty;Object.defineProperty=function(S,v,C){return k.call(this,S,v,G(O({},C),{configurable:!0,enumerable:!0}))};try{c=s.apply(this,o)}finally{Object.defineProperty=k}}else c=s.apply(this,o);return c}}function b(s,o){return function(){return d.fork(new h(`jasmine.describe#${s}`)).run(o,this,arguments)}}function E(s,o,a,c){let k=!!jasmine[l("clockInstalled")],S=a.testProxyZoneSpec,v=a.testProxyZone,C;if(k&&m){let R=t[t.__symbol__("fakeAsyncTest")];R&&typeof R.fakeAsync=="function"&&(s=R.fakeAsync(s))}return c?v.run(s,o,[c]):v.run(s,o)}function p(s){return s&&(s.length?function(o){return E(s,this,this.queueRunner,o)}:function(){return E(s,this,this.queueRunner)})}let f=jasmine,_=(Z=f==null?void 0:f.private)!=null&&Z.QueueRunner?f==null?void 0:f.private:f,y=_.QueueRunner;_.QueueRunner=function(s){r(o,s);function o(a){a.onComplete&&(a.onComplete=(v=>()=>{this.testProxyZone=null,this.testProxyZoneSpec=null,d.scheduleMicroTask("jasmine.onComplete",v)})(a.onComplete));let c=e[t.__symbol__("setTimeout")],k=e[t.__symbol__("clearTimeout")];c&&(a.timeout={setTimeout:c||e.setTimeout,clearTimeout:k||e.clearTimeout}),_.UserContext?(a.userContext||(a.userContext=new _.UserContext),a.userContext.queueRunner=this):(a.userContext||(a.userContext={}),a.userContext.queueRunner=this);let S=a.onException;a.onException=function(v){if(v&&v.message==="Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL."){let C=this&&this.testProxyZoneSpec;if(C){let R=C.getAndClearPendingTasksInfo();try{v.message+=R}catch(ve){}}}S&&S.call(this,v)},s.call(this,a)}return o.prototype.execute=function(){let a=t.current,c=!1;for(;a;){if(a===d){c=!0;break}a=a.parent}if(!c)throw new Error("Unexpected Zone: "+t.current.name);this.testProxyZoneSpec=new u,this.testProxyZone=d.fork(this.testProxyZoneSpec),t.currentTask?s.prototype.execute.call(this):t.current.scheduleMicroTask("jasmine.execute().forceTask",()=>y.prototype.execute.call(this))},o}(y)})}function V(i){i.__load_patch("jest",(e,t,n)=>{if(typeof jest=="undefined"||jest.__zone_patch__)return;t[n.symbol("ignoreConsoleErrorUncaughtError")]=!0,jest.__zone_patch__=!0;let r=t.ProxyZoneSpec,h=t.SyncTestZoneSpec;if(!r)throw new Error("Missing ProxyZoneSpec");let u=t.current,d=u.fork(new h("jest.describe")),l=new r,w=u.fork(l);function m(p){return function(...f){let _=p.apply(this,f);return function(...y){return y[1]=b(y[1]),_.apply(this,y)}}}function P(p){return function(...f){return function(..._){return _[1]=E(_[1]),p.apply(this,f).apply(this,_)}}}function b(p){return function(...f){return d.run(p,this,f)}}function E(p,f=!1){if(typeof p!="function")return p;let _=function(){if(t[n.symbol("useFakeTimersCalled")]===!0&&p&&!p.isFakeAsync){let y=t[t.__symbol__("fakeAsyncTest")];y&&typeof y.fakeAsync=="function"&&(p=y.fakeAsync(p))}return l.isTestFunc=f,w.run(p,null,arguments)};return Object.defineProperty(_,"length",{configurable:!0,writable:!0,enumerable:!1}),_.length=p.length,_}["describe","xdescribe","fdescribe"].forEach(p=>{let f=e[p];e[t.__symbol__(p)]||(e[t.__symbol__(p)]=f,e[p]=function(..._){return _[1]=b(_[1]),f.apply(this,_)},e[p].each=m(f.each))}),e.describe.only=e.fdescribe,e.describe.skip=e.xdescribe,["it","xit","fit","test","xtest"].forEach(p=>{let f=e[p];e[t.__symbol__(p)]||(e[t.__symbol__(p)]=f,e[p]=function(..._){return _[1]=E(_[1],!0),f.apply(this,_)},e[p].each=P(f.each),e[p].todo=f.todo,e[p].failing=f.failing)}),e.it.only=e.fit,e.it.skip=e.xit,e.test.only=e.fit,e.test.skip=e.xit,["beforeEach","afterEach","beforeAll","afterAll"].forEach(p=>{let f=e[p];e[t.__symbol__(p)]||(e[t.__symbol__(p)]=f,e[p]=function(..._){return _[0]=E(_[0]),f.apply(this,_)})}),t.patchJestObject=function(f,_=!1){function y(){return!!t.current.get("FakeAsyncTestZoneSpec")}function Z(){let s=t.current.get("ProxyZoneSpec");return s&&s.isTestFunc}f[n.symbol("fakeTimers")]||(f[n.symbol("fakeTimers")]=!0,n.patchMethod(f,"_checkFakeTimers",s=>function(o,a){return y()?!0:s.apply(o,a)}),n.patchMethod(f,"useFakeTimers",s=>function(o,a){return t[n.symbol("useFakeTimersCalled")]=!0,_||Z()?s.apply(o,a):o}),n.patchMethod(f,"useRealTimers",s=>function(o,a){return t[n.symbol("useFakeTimersCalled")]=!1,_||Z()?s.apply(o,a):o}),n.patchMethod(f,"setSystemTime",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c&&y())c.setFakeBaseSystemTime(a[0]);else return s.apply(o,a)}),n.patchMethod(f,"getRealSystemTime",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");return c&&y()?c.getRealSystemTime():s.apply(o,a)}),n.patchMethod(f,"runAllTicks",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c)c.flushMicrotasks();else return s.apply(o,a)}),n.patchMethod(f,"runAllTimers",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c)c.flush(100,!0);else return s.apply(o,a)}),n.patchMethod(f,"advanceTimersByTime",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c)c.tick(a[0]);else return s.apply(o,a)}),n.patchMethod(f,"runOnlyPendingTimers",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c)c.flushOnlyPendingTimers();else return s.apply(o,a)}),n.patchMethod(f,"advanceTimersToNextTimer",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c)c.tickToNext(a[0]);else return s.apply(o,a)}),n.patchMethod(f,"clearAllTimers",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");if(c)c.removeAllTimers();else return s.apply(o,a)}),n.patchMethod(f,"getTimerCount",s=>function(o,a){let c=t.current.get("FakeAsyncTestZoneSpec");return c?c.getTimerCount():s.apply(o,a)}))}})}function X(i){i.__load_patch("mocha",(e,t)=>{let n=e.Mocha;if(typeof n=="undefined")return;if(typeof t=="undefined")throw new Error("Missing Zone.js");let r=t.ProxyZoneSpec,h=t.SyncTestZoneSpec;if(!r)throw new Error("Missing ProxyZoneSpec");if(n.__zone_patch__)throw new Error('"Mocha" has already been patched with "Zone".');n.__zone_patch__=!0;let u=t.current,d=u.fork(new h("Mocha.describe")),l=null,w=u.fork(new r),m={after:e.after,afterEach:e.afterEach,before:e.before,beforeEach:e.beforeEach,describe:e.describe,it:e.it};function P(f,_,y){for(let Z=0;Z<f.length;Z++){let s=f[Z];typeof s=="function"&&(f[Z]=s.length===0?_(s):y(s),f[Z].toString=function(){return s.toString()})}return f}function b(f){return P(f,function(y){return function(){return d.run(y,this,arguments)}})}function E(f){return P(f,function(Z){return function(){return l.run(Z,this)}},function(Z){return function(s){return l.run(Z,this,[s])}})}function p(f){return P(f,function(Z){return function(){return w.run(Z,this)}},function(Z){return function(s){return w.run(Z,this,[s])}})}e.describe=e.suite=function(){return m.describe.apply(this,b(arguments))},e.xdescribe=e.suite.skip=e.describe.skip=function(){return m.describe.skip.apply(this,b(arguments))},e.describe.only=e.suite.only=function(){return m.describe.only.apply(this,b(arguments))},e.it=e.specify=e.test=function(){return m.it.apply(this,E(arguments))},e.xit=e.xspecify=e.it.skip=function(){return m.it.skip.apply(this,E(arguments))},e.it.only=e.test.only=function(){return m.it.only.apply(this,E(arguments))},e.after=e.suiteTeardown=function(){return m.after.apply(this,p(arguments))},e.afterEach=e.teardown=function(){return m.afterEach.apply(this,E(arguments))},e.before=e.suiteSetup=function(){return m.before.apply(this,p(arguments))},e.beforeEach=e.setup=function(){return m.beforeEach.apply(this,E(arguments))},((f,_)=>{n.Runner.prototype.runTest=function(y){t.current.scheduleMicroTask("mocha.forceTask",()=>{f.call(this,y)})},n.Runner.prototype.run=function(y){return this.on("test",Z=>{l=u.fork(new r)}),this.on("fail",(Z,s)=>{let o=l&&l.get("ProxyZoneSpec");if(o&&s)try{s.message+=o.getAndClearPendingTasksInfo()}catch(a){}}),_.call(this,y)}})(n.Runner.prototype.runTest,n.Runner.prototype.run)})}var pe=globalThis;function H(i){return(pe.__Zone_symbol_prefix||"__zone_symbol__")+i}var ke=globalThis,L=class i{constructor(e,t,n){T(this,"finishCallback");T(this,"failCallback");T(this,"_pendingMicroTasks",!1);T(this,"_pendingMacroTasks",!1);T(this,"_alreadyErrored",!1);T(this,"_isSync",!1);T(this,"_existingFinishTimer",null);T(this,"entryFunction",null);T(this,"runZone",Zone.current);T(this,"unresolvedChainedPromiseCount",0);T(this,"supportWaitUnresolvedChainedPromise",!1);T(this,"name");T(this,"properties");this.finishCallback=e,this.failCallback=t,this.name="asyncTestZone for "+n,this.properties={AsyncTestZoneSpec:this},this.supportWaitUnresolvedChainedPromise=ke[H("supportWaitUnResolvedChainedPromise")]===!0}static get symbolParentUnresolved(){return H("parentUnresolved")}isUnresolvedChainedPromisePending(){return this.unresolvedChainedPromiseCount>0}_finishCallbackIfDone(){this._existingFinishTimer!==null&&(clearTimeout(this._existingFinishTimer),this._existingFinishTimer=null),this._pendingMicroTasks||this._pendingMacroTasks||this.supportWaitUnresolvedChainedPromise&&this.isUnresolvedChainedPromisePending()||this.runZone.run(()=>{this._existingFinishTimer=setTimeout(()=>{!this._alreadyErrored&&!(this._pendingMicroTasks||this._pendingMacroTasks)&&this.finishCallback()},0)})}patchPromiseForTest(){if(!this.supportWaitUnresolvedChainedPromise)return;let e=Promise[Zone.__symbol__("patchPromiseForTest")];e&&e()}unPatchPromiseForTest(){if(!this.supportWaitUnresolvedChainedPromise)return;let e=Promise[Zone.__symbol__("unPatchPromiseForTest")];e&&e()}onScheduleTask(e,t,n,r){return r.type!=="eventTask"&&(this._isSync=!1),r.type==="microTask"&&r.data&&r.data instanceof Promise&&r.data[i.symbolParentUnresolved]===!0&&this.unresolvedChainedPromiseCount--,e.scheduleTask(n,r)}onInvokeTask(e,t,n,r,h,u){return r.type!=="eventTask"&&(this._isSync=!1),e.invokeTask(n,r,h,u)}onCancelTask(e,t,n,r){return r.type!=="eventTask"&&(this._isSync=!1),e.cancelTask(n,r)}onInvoke(e,t,n,r,h,u,d){this.entryFunction||(this.entryFunction=r);try{return this._isSync=!0,e.invoke(n,r,h,u,d)}finally{this._isSync&&this.entryFunction===r&&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),t===n&&(r.change=="microTask"?(this._pendingMicroTasks=r.microTask,this._finishCallbackIfDone()):r.change=="macroTask"&&(this._pendingMacroTasks=r.macroTask,this._finishCallbackIfDone()))}};function Y(i){i.AsyncTestZoneSpec=L,i.__load_patch("asynctest",(e,t,n)=>{t[n.symbol("asyncTest")]=function(u){return e.jasmine?function(d){d||(d=function(){},d.fail=function(l){throw l}),r(u,this,void 0,d,l=>{if(typeof l=="string")return d.fail(new Error(l));d.fail(l)})}:function(...d){return new Promise((l,w)=>{r(u,this,d,l,w)})}};function r(h,u,d,l,w){let m=t.current,P=t.AsyncTestZoneSpec;if(P===void 0)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/plugins/async-test");let b=t.ProxyZoneSpec;if(!b)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/plugins/proxy");let E=b.get();b.assertPresent();let p=t.current.getZoneWith("ProxyZoneSpec"),f=E.getDelegate();return p.parent.run(()=>{let _=new P(()=>{E.getDelegate()==_&&E.setDelegate(f),_.unPatchPromiseForTest(),m.run(()=>{l()})},y=>{E.getDelegate()==_&&E.setDelegate(f),_.unPatchPromiseForTest(),m.run(()=>{w(y)})},"test");E.setDelegate(_),_.patchPromiseForTest()}),t.current.runGuarded(h,u,d)}})}function B(){throw typeof jest!="undefined"&&jest.__zone_patch__?new Error("Only globals are patched with zone-testing. If you import `it`, `describe`, etc. directly, you cannot use `fakeAsync` or `waitForAsync`."):new Error("ProxyZoneSpec is needed for the fakeAsync and waitForAsync test helpers but could not be found. Make sure that your environment includes zone-testing.js")}var N=class i{constructor(e=null){T(this,"defaultSpecDelegate");T(this,"name","ProxyZone");T(this,"_delegateSpec",null);T(this,"properties",{ProxyZoneSpec:this});T(this,"propertyKeys",null);T(this,"lastTaskState",null);T(this,"isNeedToTriggerHasTask",!1);T(this,"tasks",[]);this.defaultSpecDelegate=e,this.setDelegate(e)}static get(){return Zone.current.get("ProxyZoneSpec")}static isLoaded(){return i.get()instanceof i}static assertPresent(){let e=i.get();if(e===void 0)throw new Error("Expected to be running in 'ProxyZone', but it was not found.");return e}setDelegate(e){let t=this._delegateSpec!==e;this._delegateSpec=e,this.propertyKeys&&this.propertyKeys.forEach(n=>delete this.properties[n]),this.propertyKeys=null,e&&e.properties&&(this.propertyKeys=Object.keys(e.properties),this.propertyKeys.forEach(n=>this.properties[n]=e.properties[n])),t&&this.lastTaskState&&(this.lastTaskState.macroTask||this.lastTaskState.microTask)&&(this.isNeedToTriggerHasTask=!0)}getDelegate(){return this._delegateSpec}resetDelegate(){let e=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<this.tasks.length;t++)if(this.tasks[t]===e){this.tasks.splice(t,1);return}}}getAndClearPendingTasksInfo(){if(this.tasks.length===0)return"";let t="--Pending async tasks are: ["+this.tasks.map(n=>{let r=n.data&&Object.keys(n.data).map(h=>h+":"+n.data[h]).join(",");return`type: ${n.type}, source: ${n.source}, args: {${r}}`})+"]";return this.tasks=[],t}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,h){return this._delegateSpec&&this._delegateSpec.onIntercept?this._delegateSpec.onIntercept(e,t,n,r,h):e.intercept(n,r,h)}onInvoke(e,t,n,r,h,u,d){return this.tryTriggerHasTask(e,t,n),this._delegateSpec&&this._delegateSpec.onInvoke?this._delegateSpec.onInvoke(e,t,n,r,h,u,d):e.invoke(n,r,h,u,d)}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 r.type!=="eventTask"&&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,h,u){return r.type!=="eventTask"&&this.removeFromTasks(r),this.tryTriggerHasTask(e,t,n),this._delegateSpec&&this._delegateSpec.onInvokeTask?this._delegateSpec.onInvokeTask(e,t,n,r,h,u):e.invokeTask(n,r,h,u)}onCancelTask(e,t,n,r){return r.type!=="eventTask"&&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)}};function ee(i){i.ProxyZoneSpec=N}var g=typeof window=="object"&&window||typeof self=="object"&&self||globalThis.global,te=g.setImmediate,re=g.setTimeout,x=g.Date;function D(){if(arguments.length===0){let i=new x;return i.setTime(D.now()),i}else{let i=Array.prototype.slice.call(arguments);return new x(...i)}}D.now=function(){let i=Zone.current.get("FakeAsyncTestZoneSpec");return i?i.getFakeSystemTime():x.now.apply(this,arguments)};D.UTC=x.UTC;D.parse=x.parse;var A,me=function(){},I=class I{constructor(){T(this,"_schedulerQueue",[]);T(this,"_currentTickTime",0);T(this,"_currentFakeBaseSystemTime",x.now());T(this,"_currentTickRequeuePeriodicEntries",[])}static getNextId(){let e=A.nativeSetTimeout.call(g,me,0);return A.nativeClearTimeout.call(g,e),typeof e=="number"?e:I.nextNodeJSId++}getCurrentTickTime(){return this._currentTickTime}getFakeSystemTime(){return this._currentFakeBaseSystemTime+this._currentTickTime}setFakeBaseSystemTime(e){this._currentFakeBaseSystemTime=e}getRealSystemTime(){return x.now()}scheduleFunction(e,t,n){n=O({args:[],isPeriodic:!1,isRequestAnimationFrame:!1,id:-1,isRequeuePeriodic:!1},n);let r=n.id<0?I.nextId:n.id;I.nextId=I.getNextId();let u={endTime:this._currentTickTime+t,id:r,func:e,args:n.args,delay:t,isPeriodic:n.isPeriodic,isRequestAnimationFrame:n.isRequestAnimationFrame};n.isRequeuePeriodic&&this._currentTickRequeuePeriodicEntries.push(u);let d=0;for(;d<this._schedulerQueue.length;d++){let l=this._schedulerQueue[d];if(u.endTime<l.endTime)break}return this._schedulerQueue.splice(d,0,u),r}removeScheduledFunctionWithId(e){for(let t=0;t<this._schedulerQueue.length;t++)if(this._schedulerQueue[t].id==e){this._schedulerQueue.splice(t,1);break}}removeAll(){this._schedulerQueue=[]}getTimerCount(){return this._schedulerQueue.length}tickToNext(e=1,t,n){if(this._schedulerQueue.length<e)return;let r=this._currentTickTime,h=this._schedulerQueue[e-1];this.tick(h.endTime-r,t,n)}tick(e=0,t,n){let r=this._currentTickTime+e,h=0;n=Object.assign({processNewMacroTasksSynchronously:!0},n);let u=n.processNewMacroTasksSynchronously?this._schedulerQueue:this._schedulerQueue.slice();if(u.length===0&&t){t(e);return}for(;u.length>0;){this._currentTickRequeuePeriodicEntries=[];let d=u[0];if(r<d.endTime)break;{let l=u.shift();if(!n.processNewMacroTasksSynchronously){let m=this._schedulerQueue.indexOf(l);m>=0&&this._schedulerQueue.splice(m,1)}if(h=this._currentTickTime,this._currentTickTime=l.endTime,t&&t(this._currentTickTime-h),!l.func.apply(g,l.isRequestAnimationFrame?[this._currentTickTime]:l.args))break;n.processNewMacroTasksSynchronously||this._currentTickRequeuePeriodicEntries.forEach(m=>{let P=0;for(;P<u.length;P++){let b=u[P];if(m.endTime<b.endTime)break}u.splice(P,0,m)})}}h=this._currentTickTime,this._currentTickTime=r,t&&t(this._currentTickTime-h)}executeNextTask(e){let t=this._schedulerQueue.shift();t!==void 0&&(e==null||e(t.endTime-this._currentTickTime),this._currentTickTime=t.endTime,t.func.apply(g,t.isRequestAnimationFrame?[this._currentTickTime]:t.args))}flushOnlyPendingTimers(e){if(this._schedulerQueue.length===0)return 0;let t=this._currentTickTime,n=this._schedulerQueue[this._schedulerQueue.length-1];return this.tick(n.endTime-t,e,{processNewMacroTasksSynchronously:!1}),this._currentTickTime-t}flush(e=20,t=!1,n){return t?this.flushPeriodic(n):this.flushNonPeriodic(e,n)}flushPeriodic(e){if(this._schedulerQueue.length===0)return 0;let t=this._currentTickTime,n=this._schedulerQueue[this._schedulerQueue.length-1];return this.tick(n.endTime-t,e),this._currentTickTime-t}flushNonPeriodic(e,t){let n=this._currentTickTime,r=0,h=0;for(;this._schedulerQueue.length>0;){if(h++,h>e)throw new Error("flush failed after reaching the limit of "+e+" tasks. Does your code use a polling timeout?");if(this._schedulerQueue.filter(l=>!l.isPeriodic&&!l.isRequestAnimationFrame).length===0)break;let u=this._schedulerQueue.shift();if(r=this._currentTickTime,this._currentTickTime=u.endTime,t&&t(this._currentTickTime-r),!u.func.apply(g,u.args))break}return this._currentTickTime-n}};T(I,"nextNodeJSId",1),T(I,"nextId",-1);var M=I,J=class i{constructor(e,t=!1,n){T(this,"trackPendingRequestAnimationFrame");T(this,"macroTaskOptions");T(this,"_scheduler",new M);T(this,"_microtasks",[]);T(this,"_lastError",null);T(this,"_uncaughtPromiseErrors",Promise[Zone.__symbol__("uncaughtPromiseErrors")]);T(this,"pendingPeriodicTimers",[]);T(this,"pendingTimers",[]);T(this,"patchDateLocked",!1);T(this,"tickMode",{counter:0,mode:"manual"});T(this,"name");T(this,"properties",{FakeAsyncTestZoneSpec:this});this.trackPendingRequestAnimationFrame=t,this.macroTaskOptions=n,this.name="fakeAsyncTestZone for "+e,this.macroTaskOptions||(this.macroTaskOptions=g[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(e,t){return(...n)=>(e.apply(g,n),this._lastError===null?(t.onSuccess!=null&&t.onSuccess.apply(g),this.flushMicrotasks()):t.onError!=null&&t.onError.apply(g),this._lastError===null)}static _removeTimer(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}_dequeueTimer(e){return()=>{i._removeTimer(this.pendingTimers,e)}}_requeuePeriodicTimer(e,t,n,r){return()=>{this.pendingPeriodicTimers.indexOf(r)!==-1&&this._scheduler.scheduleFunction(e,t,{args:n,isPeriodic:!0,id:r,isRequeuePeriodic:!0})}}_dequeuePeriodicTimer(e){return()=>{i._removeTimer(this.pendingPeriodicTimers,e)}}_setTimeout(e,t,n,r=!0){let h=this._dequeueTimer(M.nextId),u=this._fnAndFlush(e,{onSuccess:h,onError:h}),d=this._scheduler.scheduleFunction(u,t,{args:n,isRequestAnimationFrame:!r});return r&&this.pendingTimers.push(d),d}_clearTimeout(e){i._removeTimer(this.pendingTimers,e),this._scheduler.removeScheduledFunctionWithId(e)}_setInterval(e,t,n){let r=M.nextId,h={onSuccess:null,onError:this._dequeuePeriodicTimer(r)},u=this._fnAndFlush(e,h);return h.onSuccess=this._requeuePeriodicTimer(u,t,n,r),this._scheduler.scheduleFunction(u,t,{args:n,isPeriodic:!0}),this.pendingPeriodicTimers.push(r),r}_clearInterval(e){i._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}getCurrentTickTime(){return this._scheduler.getCurrentTickTime()}getFakeSystemTime(){return this._scheduler.getFakeSystemTime()}setFakeBaseSystemTime(e){this._scheduler.setFakeBaseSystemTime(e)}getRealSystemTime(){return this._scheduler.getRealSystemTime()}static patchDate(){g[Zone.__symbol__("disableDatePatching")]||g.Date!==D&&(g.Date=D,D.prototype=x.prototype,i.checkTimerPatch())}static resetDate(){g.Date===D&&(g.Date=x)}static checkTimerPatch(){if(!A)throw new Error("Expected timers to have been patched.");g.setTimeout!==A.setTimeout&&(g.setTimeout=A.setTimeout,g.clearTimeout=A.clearTimeout),g.setInterval!==A.setInterval&&(g.setInterval=A.setInterval,g.clearInterval=A.clearInterval)}lockDatePatch(){this.patchDateLocked=!0,i.patchDate()}unlockDatePatch(){this.patchDateLocked=!1,i.resetDate()}setTickMode(e,t){e!==this.tickMode.mode&&(this.tickMode.counter++,this.tickMode.mode=e,e==="automatic"&&this.advanceUntilModeChanges(t))}advanceUntilModeChanges(e){i.assertInZone();let t=Zone.current,{counter:n}=this.tickMode;Zone.root.run(()=>q(this,null,function*(){if(yield W(()=>q(this,null,function*(){yield void 0,t.run(()=>{this.flushMicrotasks()})})),this.tickMode.counter===n)for(;;){if(yield W(()=>this.newMacrotask(t)),this.tickMode.counter!==n)return;yield W(()=>t.run(()=>{this._scheduler.executeNextTask(e)}))}}))}newMacrotask(e){return q(this,null,function*(){if(te)yield new Promise(t=>{te(t)});else{let t=new MessageChannel;yield new Promise(n=>{t.port1.onmessage=n,t.port2.postMessage(void 0)}),t.port1.close(),t.port2.close(),yield new Promise(n=>{re(n)})}e.run(()=>{this.flushMicrotasks()})})}tickToNext(e=1,t,n={processNewMacroTasksSynchronously:!0}){e<=0||(i.assertInZone(),this.flushMicrotasks(),this._scheduler.tickToNext(e,t,n),this._lastError!==null&&this._resetLastErrorAndThrow())}tick(e=0,t,n={processNewMacroTasksSynchronously:!0}){i.assertInZone(),this.flushMicrotasks(),this._scheduler.tick(e,t,n),this._lastError!==null&&this._resetLastErrorAndThrow()}flushMicrotasks(){i.assertInZone();let e=()=>{(this._lastError!==null||this._uncaughtPromiseErrors.length)&&this._resetLastErrorAndThrow()};for(;this._microtasks.length>0;){let t=this._microtasks.shift();t.func.apply(t.target,t.args)}e()}flush(e,t,n){i.assertInZone(),this.flushMicrotasks();let r=this._scheduler.flush(e,t,n);return this._lastError!==null&&this._resetLastErrorAndThrow(),r}flushOnlyPendingTimers(e){i.assertInZone(),this.flushMicrotasks();let t=this._scheduler.flushOnlyPendingTimers(e);return this._lastError!==null&&this._resetLastErrorAndThrow(),t}removeAllTimers(){i.assertInZone(),this._scheduler.removeAll(),this.pendingPeriodicTimers=[],this.pendingTimers=[]}getTimerCount(){return this._scheduler.getTimerCount()+this._microtasks.length}onScheduleTask(e,t,n,r){switch(r.type){case"microTask":let h=r.data&&r.data.args,u;if(h){let d=r.data.cbIdx;typeof h.length=="number"&&h.length>d+1&&(u=Array.prototype.slice.call(h,d+1))}this._microtasks.push({func:r.invoke,args:u,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":if(this.tickMode.mode==="manual")throw new Error("Cannot make XHRs from within a fake async test. Request URL: "+r.data.url);r=e.scheduleTask(n,r);break;case"requestAnimationFrame":case"webkitRequestAnimationFrame":case"mozRequestAnimationFrame":r.data.handleId=this._setTimeout(r.invoke,16,r.data.args,this.trackPendingRequestAnimationFrame);break;default:let d=this.findMacroTaskOption(r);if(d){let l=r.data&&r.data.args,w=l&&l.length>1?l[1]:0,m=d.callbackArgs?d.callbackArgs:l;d.isPeriodic?(r.data.handleId=this._setInterval(r.invoke,w,m),r.data.isPeriodic=!0):r.data.handleId=this._setTimeout(r.invoke,w,m);break}throw new Error("Unknown macroTask scheduled in fake async test: "+r.source)}break;case"eventTask":r=e.scheduleTask(n,r);break}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:let h=this.findMacroTaskOption(r);if(h){let u=r.data.handleId;return h.isPeriodic?this._clearInterval(u):this._clearTimeout(u)}return e.cancelTask(n,r)}}onInvoke(e,t,n,r,h,u,d){try{return i.patchDate(),e.invoke(n,r,h,u,d)}finally{this.patchDateLocked||i.resetDate()}}findMacroTaskOption(e){if(!this.macroTaskOptions)return null;for(let t=0;t<this.macroTaskOptions.length;t++){let n=this.macroTaskOptions[t];if(n.source===e.source)return n}return null}onHandleError(e,t,n,r){return this._lastError=r,!1}},F=null;function Q(){return Zone&&Zone.ProxyZoneSpec}var j=null,ne=null;function se(){var i,e;F&&F.unlockDatePatch(),F=null,(e=(i=Q())==null?void 0:i.get())==null||e.resetDelegate(),j==null||j.resetDelegate()}function ye(i,e={}){let{flush:t=!0}=e,n=function(...r){let h=Q();h||B();let u=h.assertPresent();if(Zone.current.get("FakeAsyncTestZoneSpec"))throw new Error("fakeAsync() calls can not be nested");try{if(!F){let w=Zone&&Zone.FakeAsyncTestZoneSpec;if(u.getDelegate()instanceof w)throw new Error("fakeAsync() calls can not be nested");F=new w}let d,l=u.getDelegate();u.setDelegate(F),F.lockDatePatch();try{d=i.apply(this,r),t?F.flush(20,!0):ie()}finally{u.setDelegate(l)}if(!t){if(F.pendingPeriodicTimers.length>0)throw new Error(`${F.pendingPeriodicTimers.length} periodic timer(s) still in the queue.`);if(F.pendingTimers.length>0)throw new Error(`${F.pendingTimers.length} timer(s) still in the queue.`)}return d}finally{se()}};return n.isFakeAsync=!0,n}function z(){if(F==null&&(F=Zone.current.get("FakeAsyncTestZoneSpec"),F==null))throw new Error("The code should be running in the fakeAsync zone to call this function");return F}function ge(i=0,e=!1){z().tick(i,null,e)}function we(i){return z().flush(i)}function Se(){let i=z(),e=i.pendingPeriodicTimers;i.pendingPeriodicTimers.length=0}function Pe(i){return function(...t){let n=Q();if(n===void 0)throw new Error("ProxyZoneSpec is needed for the withProxyZone() test helper but could not be found. Make sure that your environment includes zone-testing.js");return(n.get()!==void 0?Zone.current:Ze()).run(i,this,t)}}function Ze(){let i=Q();if(i===void 0)throw new Error("ProxyZoneSpec is needed for withProxyZone but could not be found. Make sure that your environment includes zone-testing.js");return j===null&&(j=new i),ne=Zone.root.fork(j),ne}function ie(){z().flushMicrotasks()}function oe(i){i.FakeAsyncTestZoneSpec=J,i.__load_patch("fakeasync",(e,t,n)=>{t[n.symbol("fakeAsyncTest")]={resetFakeAsyncZone:se,flushMicrotasks:ie,discardPeriodicTasks:Se,tick:ge,flush:we,fakeAsync:ye,withProxyZone:Pe}},!0),A={setTimeout:g.setTimeout,setInterval:g.setInterval,clearTimeout:g.clearTimeout,clearInterval:g.clearInterval,nativeSetTimeout:g[i.__symbol__("setTimeout")],nativeClearTimeout:g[i.__symbol__("clearTimeout")]},M.nextId=M.getNextId()}function W(i){return q(this,null,function*(){try{return yield i()}catch(e){Ee(e)}})}function Ee(i){Zone.root.run(()=>{re(()=>{throw i})})}function ce(i){let e=`
|
|
`,t={},n="__creationTrace__",r="STACKTRACE TRACKING",h="__SEP_TAG__",u=h+"@[native]";class d{constructor(){T(this,"error",b());T(this,"timestamp",new Date)}}function l(){return new Error(r)}function w(){try{throw l()}catch(s){return s}}let m=l(),P=w(),b=m.stack?l:P.stack?w:l;function E(s){return s.stack?s.stack.split(e):[]}function p(s,o){let a=E(o);for(let c=0;c<a.length;c++){let k=a[c];t.hasOwnProperty(k)||s.push(a[c])}}function f(s,o){let a=[o?o.trim():""];if(s){let c=new Date().getTime();for(let k=0;k<s.length;k++){let S=s[k],v=S.timestamp,C=`____________________Elapsed ${c-v.getTime()} ms; At: ${v}`;C=C.replace(/[^\w\d]/g,"_"),a.push(u.replace(h,C)),p(a,S.error),c=v.getTime()}}return a.join(e)}function _(){return Error.stackTraceLimit>0}i.longStackTraceZoneSpec={name:"long-stack-trace",longStackTraceLimit:10,getLongStackTrace:function(s){if(!s)return;let o=s[i.__symbol__("currentTaskTrace")];return o?f(o,s.stack):s.stack},onScheduleTask:function(s,o,a,c){if(_()){let k=i.currentTask,S=k&&k.data&&k.data[n]||[];S=[new d].concat(S),S.length>this.longStackTraceLimit&&(S.length=this.longStackTraceLimit),c.data||(c.data={}),c.type==="eventTask"&&(c.data=O({},c.data)),c.data[n]=S}return s.scheduleTask(a,c)},onHandleError:function(s,o,a,c){if(_()){let k=i.currentTask||c.task;if(c instanceof Error&&k){let S=f(k.data&&k.data[n],c.stack);try{c.stack=c.longStack=S}catch(v){}}}return s.handleError(a,c)}};function y(s,o){o>0&&(s.push(E(new d().error)),y(s,o-1))}function Z(){if(!_())return;let s=[];y(s,2);let o=s[0],a=s[1];for(let c=0;c<o.length;c++){let k=o[c];if(k.indexOf(r)==-1){let S=k.match(/^\s*at\s+/);if(S){u=S[0]+h+" (http://localhost)";break}}}for(let c=0;c<o.length;c++){let k=o[c],S=a[c];if(k===S)t[k]=!0;else break}}Z()}function ae(i){class e{constructor(n){T(this,"runZone",i.current);T(this,"name");this.name="syncTestZone for "+n}onScheduleTask(n,r,h,u){switch(u.type){case"microTask":case"macroTask":throw new Error(`Cannot call ${u.source} from within a sync test (${this.name}).`);case"eventTask":u=n.scheduleTask(h,u);break}return u}}i.SyncTestZoneSpec=e}function ue(i){i.__load_patch("promisefortest",(e,t,n)=>{let r=n.symbol("state"),h=null,u=n.symbol("parentUnresolved");Promise[n.symbol("patchPromiseForTest")]=function(){let l=Promise[t.__symbol__("ZonePromiseThen")];l||(l=Promise[t.__symbol__("ZonePromiseThen")]=Promise.prototype.then,Promise.prototype.then=function(){let w=l.apply(this,arguments);if(this[r]===h){let m=t.current.get("AsyncTestZoneSpec");m&&(m.unresolvedChainedPromiseCount++,w[u]=!0)}return w})},Promise[n.symbol("unPatchPromiseForTest")]=function(){let l=Promise[t.__symbol__("ZonePromiseThen")];l&&(Promise.prototype.then=l,Promise[t.__symbol__("ZonePromiseThen")]=void 0)}})}function le(i){ce(i),ee(i),ae(i),K(i),V(i),X(i),Y(i),oe(i),ue(i)}le(Zone);
|
|
|