@drincs/pixi-vn 1.2.13 → 1.2.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/index.cjs +140 -140
- package/dist/canvas/index.mjs +140 -140
- package/dist/canvas/tickers/index.cjs +144 -144
- package/dist/canvas/tickers/index.mjs +144 -144
- package/dist/character/index.cjs +51 -51
- package/dist/character/index.mjs +51 -51
- package/dist/classes/index.cjs +1 -1
- package/dist/classes/index.d.cts +2 -2
- package/dist/classes/index.d.ts +2 -2
- package/dist/classes/index.mjs +1 -1
- package/dist/history/index.cjs +2 -2
- package/dist/history/index.mjs +2 -2
- package/dist/index.cjs +158 -158
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +158 -158
- package/dist/narration/index.cjs +52 -52
- package/dist/narration/index.mjs +52 -52
- package/dist/sound/index.cjs +50 -50
- package/dist/sound/index.mjs +50 -50
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.mjs +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
package/dist/classes/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var z=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,U=new Set,D=typeof process=="object"&&process?process:{},I=(l,t,e,i)=>{typeof D.emitWarning=="function"?D.emitWarning(l,t,e,i):console.error(`[${e}] ${t}: ${l}`);},C=globalThis.AbortController,M=globalThis.AbortSignal;if(typeof C>"u"){M=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},C=class{constructor(){t();}signal=new M;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let l=D.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{l&&(l=false,I("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var j=l=>!U.has(l),y=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),G=l=>y(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?E:null:null,E=class extends Array{constructor(t){super(t),this.fill(0);}},L=class l{heap;length;static#a=false;static create(t){let e=G(t);if(!e)return [];l.#a=true;let i=new l(t,e);return l.#a=false,i}constructor(t,e){if(!l.#a)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},R=class l{#a;#c;#p;#O;#w;#W;#x;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#m;#s;#i;#t;#l;#u;#o;#h;#S;#r;#b;#_;#d;#y;#E;#f;#D;static unsafeExposeInternals(t){return {starts:t.#_,ttls:t.#d,sizes:t.#b,keyMap:t.#s,keyList:t.#i,valList:t.#t,next:t.#l,prev:t.#u,get head(){return t.#o},get tail(){return t.#h},free:t.#S,isBackgroundFetch:e=>t.#e(e),backgroundFetch:(e,i,s,n)=>t.#U(e,i,s,n),moveToTail:e=>t.#R(e),indexes:e=>t.#A(e),rindexes:e=>t.#F(e),isStale:e=>t.#g(e)}}get max(){return this.#a}get maxSize(){return this.#c}get calculatedSize(){return this.#m}get size(){return this.#n}get fetchMethod(){return this.#W}get memoMethod(){return this.#x}get dispose(){return this.#p}get onInsert(){return this.#O}get disposeAfter(){return this.#w}constructor(t){let{max:e=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:h,updateAgeOnHas:o,allowStale:r,dispose:g,onInsert:S,disposeAfter:f,noDisposeOnSet:c,noUpdateTTL:u,maxSize:A=0,maxEntrySize:d=0,sizeCalculation:b,fetchMethod:a,memoMethod:w,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:O,ignoreFetchAbort:F}=t;if(e!==0&&!y(e))throw new TypeError("max option must be a nonnegative integer");let v=e?G(e):Array;if(!v)throw new Error("invalid max value: "+e);if(this.#a=e,this.#c=A,this.maxEntrySize=d||this.#c,this.sizeCalculation=b,this.sizeCalculation){if(!this.#c&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#x=w,a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#W=a,this.#E=!!a,this.#s=new Map,this.#i=new Array(e).fill(void 0),this.#t=new Array(e).fill(void 0),this.#l=new v(e),this.#u=new v(e),this.#o=0,this.#h=0,this.#S=L.create(e),this.#n=0,this.#m=0,typeof g=="function"&&(this.#p=g),typeof S=="function"&&(this.#O=S),typeof f=="function"?(this.#w=f,this.#r=[]):(this.#w=void 0,this.#r=void 0),this.#y=!!this.#p,this.#D=!!this.#O,this.#f=!!this.#w,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!m,this.allowStaleOnFetchAbort=!!O,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(this.#c!==0&&!y(this.#c))throw new TypeError("maxSize must be a positive integer if specified");if(!y(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H();}if(this.allowStale=!!r,this.noDeleteOnStaleGet=!!p,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!o,this.ttlResolution=y(s)||s===0?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!y(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I();}if(this.#a===0&&this.ttl===0&&this.#c===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#a&&!this.#c){let T="LRU_CACHE_UNBOUNDED";j(T)&&(U.add(T),I("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",T,l));}}getRemainingTTL(t){return this.#s.has(t)?1/0:0}#I(){let t=new E(this.#a),e=new E(this.#a);this.#d=t,this.#_=e,this.#G=(n,h,o=z.now())=>{if(e[n]=h!==0?o:0,t[n]=h,h!==0&&this.ttlAutopurge){let r=setTimeout(()=>{this.#g(n)&&this.#T(this.#i[n],"expire");},h+1);r.unref&&r.unref();}},this.#v=n=>{e[n]=t[n]!==0?z.now():0;},this.#z=(n,h)=>{if(t[h]){let o=t[h],r=e[h];if(!o||!r)return;n.ttl=o,n.start=r,n.now=i||s();let g=n.now-r;n.remainingTTL=o-g;}};let i=0,s=()=>{let n=z.now();if(this.ttlResolution>0){i=n;let h=setTimeout(()=>i=0,this.ttlResolution);h.unref&&h.unref();}return n};this.getRemainingTTL=n=>{let h=this.#s.get(n);if(h===void 0)return 0;let o=t[h],r=e[h];if(!o||!r)return 1/0;let g=(i||s())-r;return o-g},this.#g=n=>{let h=e[n],o=t[n];return !!o&&!!h&&(i||s())-h>o};}#v=()=>{};#z=()=>{};#G=()=>{};#g=()=>false;#H(){let t=new E(this.#a);this.#m=0,this.#b=t,this.#C=e=>{this.#m-=t[e],t[e]=0;},this.#j=(e,i,s,n)=>{if(this.#e(i))return 0;if(!y(s))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(s=n(i,e),!y(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#L=(e,i,s)=>{if(t[e]=i,this.#c){let n=this.#c-t[e];for(;this.#m>n;)this.#M(true);}this.#m+=t[e],s&&(s.entrySize=i,s.totalCalculatedSize=this.#m);};}#C=t=>{};#L=(t,e,i)=>{};#j=(t,e,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:t=this.allowStale}={}){if(this.#n)for(let e=this.#h;!(!this.#N(e)||((t||!this.#g(e))&&(yield e),e===this.#o));)e=this.#u[e];}*#F({allowStale:t=this.allowStale}={}){if(this.#n)for(let e=this.#o;!(!this.#N(e)||((t||!this.#g(e))&&(yield e),e===this.#h));)e=this.#l[e];}#N(t){return t!==void 0&&this.#s.get(this.#i[t])===t}*entries(){for(let t of this.#A())this.#t[t]!==void 0&&this.#i[t]!==void 0&&!this.#e(this.#t[t])&&(yield [this.#i[t],this.#t[t]]);}*rentries(){for(let t of this.#F())this.#t[t]!==void 0&&this.#i[t]!==void 0&&!this.#e(this.#t[t])&&(yield [this.#i[t],this.#t[t]]);}*keys(){for(let t of this.#A()){let e=this.#i[t];e!==void 0&&!this.#e(this.#t[t])&&(yield e);}}*rkeys(){for(let t of this.#F()){let e=this.#i[t];e!==void 0&&!this.#e(this.#t[t])&&(yield e);}}*values(){for(let t of this.#A())this.#t[t]!==void 0&&!this.#e(this.#t[t])&&(yield this.#t[t]);}*rvalues(){for(let t of this.#F())this.#t[t]!==void 0&&!this.#e(this.#t[t])&&(yield this.#t[t]);}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;if(n!==void 0&&t(n,this.#i[i],this))return this.get(this.#i[i],e)}}forEach(t,e=this){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&t.call(e,n,this.#i[i],this);}}rforEach(t,e=this){for(let i of this.#F()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&t.call(e,n,this.#i[i],this);}}purgeStale(){let t=false;for(let e of this.#F({allowStale:true}))this.#g(e)&&(this.#T(this.#i[e],"expire"),t=true);return t}info(t){let e=this.#s.get(t);if(e===void 0)return;let i=this.#t[e],s=this.#e(i)?i.__staleWhileFetching:i;if(s===void 0)return;let n={value:s};if(this.#d&&this.#_){let h=this.#d[e],o=this.#_[e];if(h&&o){let r=h-(z.now()-o);n.ttl=r,n.start=Date.now();}}return this.#b&&(n.size=this.#b[e]),n}dump(){let t=[];for(let e of this.#A({allowStale:true})){let i=this.#i[e],s=this.#t[e],n=this.#e(s)?s.__staleWhileFetching:s;if(n===void 0||i===void 0)continue;let h={value:n};if(this.#d&&this.#_){h.ttl=this.#d[e];let o=z.now()-this.#_[e];h.start=Math.floor(Date.now()-o);}this.#b&&(h.size=this.#b[e]),t.unshift([i,h]);}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let s=Date.now()-i.start;i.start=z.now()-s;}this.set(e,i.value,i);}}set(t,e,i={}){if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:n,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:r}=i,{noUpdateTTL:g=this.noUpdateTTL}=i,S=this.#j(t,e,i.size||0,o);if(this.maxEntrySize&&S>this.maxEntrySize)return r&&(r.set="miss",r.maxEntrySizeExceeded=true),this.#T(t,"set"),this;let f=this.#n===0?void 0:this.#s.get(t);if(f===void 0)f=this.#n===0?this.#h:this.#S.length!==0?this.#S.pop():this.#n===this.#a?this.#M(false):this.#n,this.#i[f]=t,this.#t[f]=e,this.#s.set(t,f),this.#l[this.#h]=f,this.#u[f]=this.#h,this.#h=f,this.#n++,this.#L(f,S,r),r&&(r.set="add"),g=false,this.#D&&this.#O?.(e,t,"add");else {this.#R(f);let c=this.#t[f];if(e!==c){if(this.#E&&this.#e(c)){c.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:u}=c;u!==void 0&&!h&&(this.#y&&this.#p?.(u,t,"set"),this.#f&&this.#r?.push([u,t,"set"]));}else h||(this.#y&&this.#p?.(c,t,"set"),this.#f&&this.#r?.push([c,t,"set"]));if(this.#C(f),this.#L(f,S,r),this.#t[f]=e,r){r.set="replace";let u=c&&this.#e(c)?c.__staleWhileFetching:c;u!==void 0&&(r.oldValue=u);}}else r&&(r.set="update");this.#D&&this.onInsert?.(e,t,e===c?"update":"replace");}if(s!==0&&!this.#d&&this.#I(),this.#d&&(g||this.#G(f,s,n),r&&this.#z(r,f)),!h&&this.#f&&this.#r){let c=this.#r,u;for(;u=c?.shift();)this.#w?.(...u);}return this}pop(){try{for(;this.#n;){let t=this.#t[this.#o];if(this.#M(!0),this.#e(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#f&&this.#r){let t=this.#r,e;for(;e=t?.shift();)this.#w?.(...e);}}}#M(t){let e=this.#o,i=this.#i[e],s=this.#t[e];return this.#E&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#y||this.#f)&&(this.#y&&this.#p?.(s,i,"evict"),this.#f&&this.#r?.push([s,i,"evict"])),this.#C(e),t&&(this.#i[e]=void 0,this.#t[e]=void 0,this.#S.push(e)),this.#n===1?(this.#o=this.#h=0,this.#S.length=0):this.#o=this.#l[e],this.#s.delete(i),this.#n--,e}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=e,n=this.#s.get(t);if(n!==void 0){let h=this.#t[n];if(this.#e(h)&&h.__staleWhileFetching===void 0)return false;if(this.#g(n))s&&(s.has="stale",this.#z(s,n));else return i&&this.#v(n),s&&(s.has="hit",this.#z(s,n)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:i=this.allowStale}=e,s=this.#s.get(t);if(s===void 0||!i&&this.#g(s))return;let n=this.#t[s];return this.#e(n)?n.__staleWhileFetching:n}#U(t,e,i,s){let n=e===void 0?void 0:this.#t[e];if(this.#e(n))return n;let h=new C,{signal:o}=i;o?.addEventListener("abort",()=>h.abort(o.reason),{signal:h.signal});let r={signal:h.signal,options:i,context:s},g=(d,b=false)=>{let{aborted:a}=h.signal,w=i.ignoreFetchAbort&&d!==void 0;if(i.status&&(a&&!b?(i.status.fetchAborted=true,i.status.fetchError=h.signal.reason,w&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),a&&!w&&!b)return f(h.signal.reason);let _=u;return this.#t[e]===u&&(d===void 0?_.__staleWhileFetching?this.#t[e]=_.__staleWhileFetching:this.#T(t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,d,r.options))),d},S=d=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=d),f(d)),f=d=>{let{aborted:b}=h.signal,a=b&&i.allowStaleOnFetchAbort,w=a||i.allowStaleOnFetchRejection,_=w||i.noDeleteOnFetchRejection,p=u;if(this.#t[e]===u&&(!_||p.__staleWhileFetching===void 0?this.#T(t,"fetch"):a||(this.#t[e]=p.__staleWhileFetching)),w)return i.status&&p.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),p.__staleWhileFetching;if(p.__returned===p)throw d},c=(d,b)=>{let a=this.#W?.(t,n,r);a&&a instanceof Promise&&a.then(w=>d(w===void 0?void 0:w),b),h.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(d(void 0),i.allowStaleOnFetchAbort&&(d=w=>g(w,true)));});};i.status&&(i.status.fetchDispatched=true);let u=new Promise(c).then(g,S),A=Object.assign(u,{__abortController:h,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,A,{...r.options,status:void 0}),e=this.#s.get(t)):this.#t[e]=A,A}#e(t){if(!this.#E)return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof C}async fetch(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:r=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:S=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:A=this.allowStaleOnFetchAbort,context:d,forceRefresh:b=false,status:a,signal:w}=e;if(!this.#E)return a&&(a.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:a});let _={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:h,noDisposeOnSet:o,size:r,sizeCalculation:g,noUpdateTTL:S,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:A,ignoreFetchAbort:u,status:a,signal:w},p=this.#s.get(t);if(p===void 0){a&&(a.fetch="miss");let m=this.#U(t,p,_,d);return m.__returned=m}else {let m=this.#t[p];if(this.#e(m)){let x=i&&m.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",x&&(a.returnedStale=true)),x?m.__staleWhileFetching:m.__returned=m}let O=this.#g(p);if(!b&&!O)return a&&(a.fetch="hit"),this.#R(p),s&&this.#v(p),a&&this.#z(a,p),m;let F=this.#U(t,p,_,d),T=F.__staleWhileFetching!==void 0&&i;return a&&(a.fetch=O?"stale":"refresh",T&&O&&(a.returnedStale=true)),T?F.__staleWhileFetching:F.__returned=F}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=this.#x;if(!i)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:n,...h}=e,o=this.get(t,h);if(!n&&o!==void 0)return o;let r=i(t,o,{options:h,context:s});return this.set(t,r,h),r}get(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:h}=e,o=this.#s.get(t);if(o!==void 0){let r=this.#t[o],g=this.#e(r);return h&&this.#z(h,o),this.#g(o)?(h&&(h.get="stale"),g?(h&&i&&r.__staleWhileFetching!==void 0&&(h.returnedStale=true),i?r.__staleWhileFetching:void 0):(n||this.#T(t,"expire"),h&&i&&(h.returnedStale=true),i?r:void 0)):(h&&(h.get="hit"),g?r.__staleWhileFetching:(this.#R(o),s&&this.#v(o),r))}else h&&(h.get="miss");}#V(t,e){this.#u[e]=t,this.#l[t]=e;}#R(t){t!==this.#h&&(t===this.#o?this.#o=this.#l[t]:this.#V(this.#u[t],this.#l[t]),this.#V(this.#h,t),this.#h=t);}delete(t){return this.#T(t,"delete")}#T(t,e){let i=false;if(this.#n!==0){let s=this.#s.get(t);if(s!==void 0)if(i=true,this.#n===1)this.#P(e);else {this.#C(s);let n=this.#t[s];if(this.#e(n)?n.__abortController.abort(new Error("deleted")):(this.#y||this.#f)&&(this.#y&&this.#p?.(n,t,e),this.#f&&this.#r?.push([n,t,e])),this.#s.delete(t),this.#i[s]=void 0,this.#t[s]=void 0,s===this.#h)this.#h=this.#u[s];else if(s===this.#o)this.#o=this.#l[s];else {let h=this.#u[s];this.#l[h]=this.#l[s];let o=this.#l[s];this.#u[o]=this.#u[s];}this.#n--,this.#S.push(s);}}if(this.#f&&this.#r?.length){let s=this.#r,n;for(;n=s?.shift();)this.#w?.(...n);}return i}clear(){return this.#P("delete")}#P(t){for(let e of this.#F({allowStale:true})){let i=this.#t[e];if(this.#e(i))i.__abortController.abort(new Error("deleted"));else {let s=this.#i[e];this.#y&&this.#p?.(i,s,t),this.#f&&this.#r?.push([i,s,t]);}}if(this.#s.clear(),this.#t.fill(void 0),this.#i.fill(void 0),this.#d&&this.#_&&(this.#d.fill(0),this.#_.fill(0)),this.#b&&this.#b.fill(0),this.#o=0,this.#h=0,this.#S.length=0,this.#m=0,this.#n=0,this.#f&&this.#r){let e=this.#r,i;for(;i=e?.shift();)this.#w?.(...i);}}};var W=class{cache;map=new Map;constructor(t){this.cache=new R({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}get entries(){return this.map.entries}keys(){return this.map.keys()}get values(){return this.map.values}};exports.CachedMap=W;
|
|
1
|
+
'use strict';var Ht=Object.defineProperty;var Mt=f=>{throw TypeError(f)};var Kt=(f,e,i)=>e in f?Ht(f,e,{enumerable:true,configurable:true,writable:true,value:i}):f[e]=i;var w=(f,e,i)=>Kt(f,typeof e!="symbol"?e+"":e,i),Ot=(f,e,i)=>e.has(f)||Mt("Cannot "+i);var t=(f,e,i)=>(Ot(f,e,"read from private field"),i?i.call(f):e.get(f)),p=(f,e,i)=>e.has(f)?Mt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,i),l=(f,e,i,s)=>(Ot(f,e,"write to private field"),e.set(f,i),i),a=(f,e,i)=>(Ot(f,e,"access private method"),i);var _t=(f,e,i,s)=>({set _(r){l(f,e,r);},get _(){return t(f,e,s)}});var at=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,jt=new Set,vt=typeof process=="object"&&process?process:{},Nt=(f,e,i,s)=>{typeof vt.emitWarning=="function"?vt.emitWarning(f,e,i,s):console.error(`[${i}] ${e}: ${f}`);},Ft=globalThis.AbortController,Ut=globalThis.AbortSignal;if(typeof Ft>"u"){Ut=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},Ft=class{constructor(){w(this,"signal",new Ut);e();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=vt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,Nt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var Bt=f=>!jt.has(f),J=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Vt=f=>J(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?lt:null:null,lt=class extends Array{constructor(e){super(e),this.fill(0);}},ft,it=class it{constructor(e,i){w(this,"heap");w(this,"length");if(!t(it,ft))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=Vt(e);if(!i)return [];l(it,ft,true);let s=new it(e,i);return l(it,ft,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};ft=new WeakMap,p(it,ft,false);var Ct=it,It,Gt,j,D,N,st,V,ct,ut,T,P,A,S,d,C,L,v,z,H,E,K,B,M,k,et,R,dt,o,Rt,nt,Y,mt,U,Pt,ht,gt,St,Q,Z,Wt,yt,At,m,xt,wt,tt,Dt,Lt=class Lt{constructor(e){p(this,o);p(this,j);p(this,D);p(this,N);p(this,st);p(this,V);p(this,ct);p(this,ut);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");p(this,T);p(this,P);p(this,A);p(this,S);p(this,d);p(this,C);p(this,L);p(this,v);p(this,z);p(this,H);p(this,E);p(this,K);p(this,B);p(this,M);p(this,k);p(this,et);p(this,R);p(this,dt);p(this,nt,()=>{});p(this,Y,()=>{});p(this,mt,()=>{});p(this,U,()=>false);p(this,ht,e=>{});p(this,gt,(e,i,s)=>{});p(this,St,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,It,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:h,updateAgeOnHas:u,allowStale:c,dispose:F,onInsert:$,disposeAfter:b,noDisposeOnSet:X,noUpdateTTL:I,maxSize:q=0,maxEntrySize:y=0,sizeCalculation:_,fetchMethod:g,memoMethod:W,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:pt,ignoreFetchAbort:rt}=e;if(i!==0&&!J(i))throw new TypeError("max option must be a nonnegative integer");let bt=i?Vt(i):Array;if(!bt)throw new Error("invalid max value: "+i);if(l(this,j,i),l(this,D,q),this.maxEntrySize=y||t(this,D),this.sizeCalculation=_,this.sizeCalculation){if(!t(this,D)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(W!==void 0&&typeof W!="function")throw new TypeError("memoMethod must be a function if defined");if(l(this,ut,W),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(l(this,ct,g),l(this,et,!!g),l(this,A,new Map),l(this,S,new Array(i).fill(void 0)),l(this,d,new Array(i).fill(void 0)),l(this,C,new bt(i)),l(this,L,new bt(i)),l(this,v,0),l(this,z,0),l(this,H,Ct.create(i)),l(this,T,0),l(this,P,0),typeof F=="function"&&l(this,N,F),typeof $=="function"&&l(this,st,$),typeof b=="function"?(l(this,V,b),l(this,E,[])):(l(this,V,void 0),l(this,E,void 0)),l(this,k,!!t(this,N)),l(this,dt,!!t(this,st)),l(this,R,!!t(this,V)),this.noDisposeOnSet=!!X,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!G,this.allowStaleOnFetchAbort=!!pt,this.ignoreFetchAbort=!!rt,this.maxEntrySize!==0){if(t(this,D)!==0&&!J(t(this,D)))throw new TypeError("maxSize must be a positive integer if specified");if(!J(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");a(this,o,Pt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!u,this.ttlResolution=J(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!J(this.ttl))throw new TypeError("ttl must be a positive integer if specified");a(this,o,Rt).call(this);}if(t(this,j)===0&&this.ttl===0&&t(this,D)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,j)&&!t(this,D)){let ot="LRU_CACHE_UNBOUNDED";Bt(ot)&&(jt.add(ot),Nt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ot,Lt));}}static unsafeExposeInternals(e){return {starts:t(e,B),ttls:t(e,M),sizes:t(e,K),keyMap:t(e,A),keyList:t(e,S),valList:t(e,d),next:t(e,C),prev:t(e,L),get head(){return t(e,v)},get tail(){return t(e,z)},free:t(e,H),isBackgroundFetch:i=>{var s;return a(s=e,o,m).call(s,i)},backgroundFetch:(i,s,r,n)=>{var h;return a(h=e,o,At).call(h,i,s,r,n)},moveToTail:i=>{var s;return a(s=e,o,wt).call(s,i)},indexes:i=>{var s;return a(s=e,o,Q).call(s,i)},rindexes:i=>{var s;return a(s=e,o,Z).call(s,i)},isStale:i=>{var s;return t(s=e,U).call(s,i)}}}get max(){return t(this,j)}get maxSize(){return t(this,D)}get calculatedSize(){return t(this,P)}get size(){return t(this,T)}get fetchMethod(){return t(this,ct)}get memoMethod(){return t(this,ut)}get dispose(){return t(this,N)}get onInsert(){return t(this,st)}get disposeAfter(){return t(this,V)}getRemainingTTL(e){return t(this,A).has(e)?1/0:0}*entries(){for(let e of a(this,o,Q).call(this))t(this,d)[e]!==void 0&&t(this,S)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield [t(this,S)[e],t(this,d)[e]]);}*rentries(){for(let e of a(this,o,Z).call(this))t(this,d)[e]!==void 0&&t(this,S)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield [t(this,S)[e],t(this,d)[e]]);}*keys(){for(let e of a(this,o,Q).call(this)){let i=t(this,S)[e];i!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield i);}}*rkeys(){for(let e of a(this,o,Z).call(this)){let i=t(this,S)[e];i!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield i);}}*values(){for(let e of a(this,o,Q).call(this))t(this,d)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}*rvalues(){for(let e of a(this,o,Z).call(this))t(this,d)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}[(Gt=Symbol.iterator,It=Symbol.toStringTag,Gt)](){return this.entries()}find(e,i={}){for(let s of a(this,o,Q).call(this)){let r=t(this,d)[s],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,S)[s],this))return this.get(t(this,S)[s],i)}}forEach(e,i=this){for(let s of a(this,o,Q).call(this)){let r=t(this,d)[s],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,S)[s],this);}}rforEach(e,i=this){for(let s of a(this,o,Z).call(this)){let r=t(this,d)[s],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,S)[s],this);}}purgeStale(){let e=false;for(let i of a(this,o,Z).call(this,{allowStale:true}))t(this,U).call(this,i)&&(a(this,o,tt).call(this,t(this,S)[i],"expire"),e=true);return e}info(e){let i=t(this,A).get(e);if(i===void 0)return;let s=t(this,d)[i],r=a(this,o,m).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,M)&&t(this,B)){let h=t(this,M)[i],u=t(this,B)[i];if(h&&u){let c=h-(at.now()-u);n.ttl=c,n.start=Date.now();}}return t(this,K)&&(n.size=t(this,K)[i]),n}dump(){let e=[];for(let i of a(this,o,Q).call(this,{allowStale:true})){let s=t(this,S)[i],r=t(this,d)[i],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let h={value:n};if(t(this,M)&&t(this,B)){h.ttl=t(this,M)[i];let u=at.now()-t(this,B)[i];h.start=Math.floor(Date.now()-u);}t(this,K)&&(h.size=t(this,K)[i]),e.unshift([s,h]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=at.now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var X,I,q,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:u=this.sizeCalculation,status:c}=s,{noUpdateTTL:F=this.noUpdateTTL}=s,$=t(this,St).call(this,e,i,s.size||0,u);if(this.maxEntrySize&&$>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),a(this,o,tt).call(this,e,"set"),this;let b=t(this,T)===0?void 0:t(this,A).get(e);if(b===void 0)b=t(this,T)===0?t(this,z):t(this,H).length!==0?t(this,H).pop():t(this,T)===t(this,j)?a(this,o,yt).call(this,false):t(this,T),t(this,S)[b]=e,t(this,d)[b]=i,t(this,A).set(e,b),t(this,C)[t(this,z)]=b,t(this,L)[b]=t(this,z),l(this,z,b),_t(this,T)._++,t(this,gt).call(this,b,$,c),c&&(c.set="add"),F=false,t(this,dt)&&((X=t(this,st))==null||X.call(this,i,e,"add"));else {a(this,o,wt).call(this,b);let _=t(this,d)[b];if(i!==_){if(t(this,et)&&a(this,o,m).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=_;g!==void 0&&!h&&(t(this,k)&&((I=t(this,N))==null||I.call(this,g,e,"set")),t(this,R)&&t(this,E)?.push([g,e,"set"]));}else h||(t(this,k)&&((q=t(this,N))==null||q.call(this,_,e,"set")),t(this,R)&&t(this,E)?.push([_,e,"set"]));if(t(this,ht).call(this,b),t(this,gt).call(this,b,$,c),t(this,d)[b]=i,c){c.set="replace";let g=_&&a(this,o,m).call(this,_)?_.__staleWhileFetching:_;g!==void 0&&(c.oldValue=g);}}else c&&(c.set="update");t(this,dt)&&this.onInsert?.(i,e,i===_?"update":"replace");}if(r!==0&&!t(this,M)&&a(this,o,Rt).call(this),t(this,M)&&(F||t(this,mt).call(this,b,r,n),c&&t(this,Y).call(this,c,b)),!h&&t(this,R)&&t(this,E)){let _=t(this,E),g;for(;g=_?.shift();)(y=t(this,V))==null||y.call(this,...g);}return this}pop(){var e;try{for(;t(this,T);){let i=t(this,d)[t(this,v)];if(a(this,o,yt).call(this,!0),a(this,o,m).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,R)&&t(this,E)){let i=t(this,E),s;for(;s=i?.shift();)(e=t(this,V))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,A).get(e);if(n!==void 0){let h=t(this,d)[n];if(a(this,o,m).call(this,h)&&h.__staleWhileFetching===void 0)return false;if(t(this,U).call(this,n))r&&(r.has="stale",t(this,Y).call(this,r,n));else return s&&t(this,nt).call(this,n),r&&(r.has="hit",t(this,Y).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,A).get(e);if(r===void 0||!s&&t(this,U).call(this,r))return;let n=t(this,d)[r];return a(this,o,m).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:u=this.noDisposeOnSet,size:c=0,sizeCalculation:F=this.sizeCalculation,noUpdateTTL:$=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:X=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:y,forceRefresh:_=false,status:g,signal:W}=i;if(!t(this,et))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let x={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:h,noDisposeOnSet:u,size:c,sizeCalculation:F,noUpdateTTL:$,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:X,allowStaleOnFetchAbort:q,ignoreFetchAbort:I,status:g,signal:W},O=t(this,A).get(e);if(O===void 0){g&&(g.fetch="miss");let G=a(this,o,At).call(this,e,O,x,y);return G.__returned=G}else {let G=t(this,d)[O];if(a(this,o,m).call(this,G)){let Et=s&&G.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Et&&(g.returnedStale=true)),Et?G.__staleWhileFetching:G.__returned=G}let pt=t(this,U).call(this,O);if(!_&&!pt)return g&&(g.fetch="hit"),a(this,o,wt).call(this,O),r&&t(this,nt).call(this,O),g&&t(this,Y).call(this,g,O),G;let rt=a(this,o,At).call(this,e,O,x,y),ot=rt.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=pt?"stale":"refresh",ot&&pt&&(g.returnedStale=true)),ot?rt.__staleWhileFetching:rt.__returned=rt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,ut);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...h}=i,u=this.get(e,h);if(!n&&u!==void 0)return u;let c=s(e,u,{options:h,context:r});return this.set(e,c,h),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:h}=i,u=t(this,A).get(e);if(u!==void 0){let c=t(this,d)[u],F=a(this,o,m).call(this,c);return h&&t(this,Y).call(this,h,u),t(this,U).call(this,u)?(h&&(h.get="stale"),F?(h&&s&&c.__staleWhileFetching!==void 0&&(h.returnedStale=true),s?c.__staleWhileFetching:void 0):(n||a(this,o,tt).call(this,e,"expire"),h&&s&&(h.returnedStale=true),s?c:void 0)):(h&&(h.get="hit"),F?c.__staleWhileFetching:(a(this,o,wt).call(this,u),r&&t(this,nt).call(this,u),c))}else h&&(h.get="miss");}delete(e){return a(this,o,tt).call(this,e,"delete")}clear(){return a(this,o,Dt).call(this,"delete")}};j=new WeakMap,D=new WeakMap,N=new WeakMap,st=new WeakMap,V=new WeakMap,ct=new WeakMap,ut=new WeakMap,T=new WeakMap,P=new WeakMap,A=new WeakMap,S=new WeakMap,d=new WeakMap,C=new WeakMap,L=new WeakMap,v=new WeakMap,z=new WeakMap,H=new WeakMap,E=new WeakMap,K=new WeakMap,B=new WeakMap,M=new WeakMap,k=new WeakMap,et=new WeakMap,R=new WeakMap,dt=new WeakMap,o=new WeakSet,Rt=function(){let e=new lt(t(this,j)),i=new lt(t(this,j));l(this,M,e),l(this,B,i),l(this,mt,(n,h,u=at.now())=>{if(i[n]=h!==0?u:0,e[n]=h,h!==0&&this.ttlAutopurge){let c=setTimeout(()=>{t(this,U).call(this,n)&&a(this,o,tt).call(this,t(this,S)[n],"expire");},h+1);c.unref&&c.unref();}}),l(this,nt,n=>{i[n]=e[n]!==0?at.now():0;}),l(this,Y,(n,h)=>{if(e[h]){let u=e[h],c=i[h];if(!u||!c)return;n.ttl=u,n.start=c,n.now=s||r();let F=n.now-c;n.remainingTTL=u-F;}});let s=0,r=()=>{let n=at.now();if(this.ttlResolution>0){s=n;let h=setTimeout(()=>s=0,this.ttlResolution);h.unref&&h.unref();}return n};this.getRemainingTTL=n=>{let h=t(this,A).get(n);if(h===void 0)return 0;let u=e[h],c=i[h];if(!u||!c)return 1/0;let F=(s||r())-c;return u-F},l(this,U,n=>{let h=i[n],u=e[n];return !!u&&!!h&&(s||r())-h>u});},nt=new WeakMap,Y=new WeakMap,mt=new WeakMap,U=new WeakMap,Pt=function(){let e=new lt(t(this,j));l(this,P,0),l(this,K,e),l(this,ht,i=>{l(this,P,t(this,P)-e[i]),e[i]=0;}),l(this,St,(i,s,r,n)=>{if(a(this,o,m).call(this,s))return 0;if(!J(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!J(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),l(this,gt,(i,s,r)=>{if(e[i]=s,t(this,D)){let n=t(this,D)-e[i];for(;t(this,P)>n;)a(this,o,yt).call(this,true);}l(this,P,t(this,P)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,P));});},ht=new WeakMap,gt=new WeakMap,St=new WeakMap,Q=function*({allowStale:e=this.allowStale}={}){if(t(this,T))for(let i=t(this,z);!(!a(this,o,Wt).call(this,i)||((e||!t(this,U).call(this,i))&&(yield i),i===t(this,v)));)i=t(this,L)[i];},Z=function*({allowStale:e=this.allowStale}={}){if(t(this,T))for(let i=t(this,v);!(!a(this,o,Wt).call(this,i)||((e||!t(this,U).call(this,i))&&(yield i),i===t(this,z)));)i=t(this,C)[i];},Wt=function(e){return e!==void 0&&t(this,A).get(t(this,S)[e])===e},yt=function(e){var n;let i=t(this,v),s=t(this,S)[i],r=t(this,d)[i];return t(this,et)&&a(this,o,m).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,k)||t(this,R))&&(t(this,k)&&((n=t(this,N))==null||n.call(this,r,s,"evict")),t(this,R)&&t(this,E)?.push([r,s,"evict"])),t(this,ht).call(this,i),e&&(t(this,S)[i]=void 0,t(this,d)[i]=void 0,t(this,H).push(i)),t(this,T)===1?(l(this,v,l(this,z,0)),t(this,H).length=0):l(this,v,t(this,C)[i]),t(this,A).delete(s),_t(this,T)._--,i},At=function(e,i,s,r){let n=i===void 0?void 0:t(this,d)[i];if(a(this,o,m).call(this,n))return n;let h=new Ft,{signal:u}=s;u?.addEventListener("abort",()=>h.abort(u.reason),{signal:h.signal});let c={signal:h.signal,options:s,context:r},F=(y,_=false)=>{let{aborted:g}=h.signal,W=s.ignoreFetchAbort&&y!==void 0;if(s.status&&(g&&!_?(s.status.fetchAborted=true,s.status.fetchError=h.signal.reason,W&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!W&&!_)return b(h.signal.reason);let x=I;return t(this,d)[i]===I&&(y===void 0?x.__staleWhileFetching?t(this,d)[i]=x.__staleWhileFetching:a(this,o,tt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},$=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),b(y)),b=y=>{let{aborted:_}=h.signal,g=_&&s.allowStaleOnFetchAbort,W=g||s.allowStaleOnFetchRejection,x=W||s.noDeleteOnFetchRejection,O=I;if(t(this,d)[i]===I&&(!x||O.__staleWhileFetching===void 0?a(this,o,tt).call(this,e,"fetch"):g||(t(this,d)[i]=O.__staleWhileFetching)),W)return s.status&&O.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw y},X=(y,_)=>{var W;let g=(W=t(this,ct))==null?void 0:W.call(this,e,n,c);g&&g instanceof Promise&&g.then(x=>y(x===void 0?void 0:x),_),h.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=x=>F(x,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(X).then(F,$),q=Object.assign(I,{__abortController:h,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,q,{...c.options,status:void 0}),i=t(this,A).get(e)):t(this,d)[i]=q,q},m=function(e){if(!t(this,et))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},xt=function(e,i){t(this,L)[i]=e,t(this,C)[e]=i;},wt=function(e){e!==t(this,z)&&(e===t(this,v)?l(this,v,t(this,C)[e]):a(this,o,xt).call(this,t(this,L)[e],t(this,C)[e]),a(this,o,xt).call(this,t(this,z),e),l(this,z,e));},tt=function(e,i){var r,n;let s=false;if(t(this,T)!==0){let h=t(this,A).get(e);if(h!==void 0)if(s=true,t(this,T)===1)a(this,o,Dt).call(this,i);else {t(this,ht).call(this,h);let u=t(this,d)[h];if(a(this,o,m).call(this,u)?u.__abortController.abort(new Error("deleted")):(t(this,k)||t(this,R))&&(t(this,k)&&((r=t(this,N))==null||r.call(this,u,e,i)),t(this,R)&&t(this,E)?.push([u,e,i])),t(this,A).delete(e),t(this,S)[h]=void 0,t(this,d)[h]=void 0,h===t(this,z))l(this,z,t(this,L)[h]);else if(h===t(this,v))l(this,v,t(this,C)[h]);else {let c=t(this,L)[h];t(this,C)[c]=t(this,C)[h];let F=t(this,C)[h];t(this,L)[F]=t(this,L)[h];}_t(this,T)._--,t(this,H).push(h);}}if(t(this,R)&&t(this,E)?.length){let h=t(this,E),u;for(;u=h?.shift();)(n=t(this,V))==null||n.call(this,...u);}return s},Dt=function(e){var i,s;for(let r of a(this,o,Z).call(this,{allowStale:true})){let n=t(this,d)[r];if(a(this,o,m).call(this,n))n.__abortController.abort(new Error("deleted"));else {let h=t(this,S)[r];t(this,k)&&((i=t(this,N))==null||i.call(this,n,h,e)),t(this,R)&&t(this,E)?.push([n,h,e]);}}if(t(this,A).clear(),t(this,d).fill(void 0),t(this,S).fill(void 0),t(this,M)&&t(this,B)&&(t(this,M).fill(0),t(this,B).fill(0)),t(this,K)&&t(this,K).fill(0),l(this,v,0),l(this,z,0),t(this,H).length=0,l(this,P,0),l(this,T,0),t(this,R)&&t(this,E)){let r=t(this,E),n;for(;n=r?.shift();)(s=t(this,V))==null||s.call(this,...n);}};var Tt=Lt;var zt=class{constructor(e){w(this,"cache");w(this,"map",new Map);this.cache=new Tt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};exports.CachedMap=zt;
|
package/dist/classes/index.d.cts
CHANGED
|
@@ -15,9 +15,9 @@ declare class CachedMap<K extends {}, V extends {}> implements Map<K, V> {
|
|
|
15
15
|
has(key: K): boolean;
|
|
16
16
|
set(key: K, value: V): this;
|
|
17
17
|
get size(): number;
|
|
18
|
-
|
|
18
|
+
entries(): MapIterator<[K, V]>;
|
|
19
19
|
keys(): MapIterator<K>;
|
|
20
|
-
|
|
20
|
+
values(): MapIterator<V>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export { CachedMap };
|
package/dist/classes/index.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ declare class CachedMap<K extends {}, V extends {}> implements Map<K, V> {
|
|
|
15
15
|
has(key: K): boolean;
|
|
16
16
|
set(key: K, value: V): this;
|
|
17
17
|
get size(): number;
|
|
18
|
-
|
|
18
|
+
entries(): MapIterator<[K, V]>;
|
|
19
19
|
keys(): MapIterator<K>;
|
|
20
|
-
|
|
20
|
+
values(): MapIterator<V>;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export { CachedMap };
|
package/dist/classes/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var z=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,U=new Set,D=typeof process=="object"&&process?process:{},I=(l,t,e,i)=>{typeof D.emitWarning=="function"?D.emitWarning(l,t,e,i):console.error(`[${e}] ${t}: ${l}`);},C=globalThis.AbortController,M=globalThis.AbortSignal;if(typeof C>"u"){M=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},C=class{constructor(){t();}signal=new M;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let l=D.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{l&&(l=false,I("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var j=l=>!U.has(l),y=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),G=l=>y(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?E:null:null,E=class extends Array{constructor(t){super(t),this.fill(0);}},L=class l{heap;length;static#a=false;static create(t){let e=G(t);if(!e)return [];l.#a=true;let i=new l(t,e);return l.#a=false,i}constructor(t,e){if(!l.#a)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},R=class l{#a;#c;#p;#O;#w;#W;#x;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#m;#s;#i;#t;#l;#u;#o;#h;#S;#r;#b;#_;#d;#y;#E;#f;#D;static unsafeExposeInternals(t){return {starts:t.#_,ttls:t.#d,sizes:t.#b,keyMap:t.#s,keyList:t.#i,valList:t.#t,next:t.#l,prev:t.#u,get head(){return t.#o},get tail(){return t.#h},free:t.#S,isBackgroundFetch:e=>t.#e(e),backgroundFetch:(e,i,s,n)=>t.#U(e,i,s,n),moveToTail:e=>t.#R(e),indexes:e=>t.#A(e),rindexes:e=>t.#F(e),isStale:e=>t.#g(e)}}get max(){return this.#a}get maxSize(){return this.#c}get calculatedSize(){return this.#m}get size(){return this.#n}get fetchMethod(){return this.#W}get memoMethod(){return this.#x}get dispose(){return this.#p}get onInsert(){return this.#O}get disposeAfter(){return this.#w}constructor(t){let{max:e=0,ttl:i,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:h,updateAgeOnHas:o,allowStale:r,dispose:g,onInsert:S,disposeAfter:f,noDisposeOnSet:c,noUpdateTTL:u,maxSize:A=0,maxEntrySize:d=0,sizeCalculation:b,fetchMethod:a,memoMethod:w,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:p,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:O,ignoreFetchAbort:F}=t;if(e!==0&&!y(e))throw new TypeError("max option must be a nonnegative integer");let v=e?G(e):Array;if(!v)throw new Error("invalid max value: "+e);if(this.#a=e,this.#c=A,this.maxEntrySize=d||this.#c,this.sizeCalculation=b,this.sizeCalculation){if(!this.#c&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#x=w,a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#W=a,this.#E=!!a,this.#s=new Map,this.#i=new Array(e).fill(void 0),this.#t=new Array(e).fill(void 0),this.#l=new v(e),this.#u=new v(e),this.#o=0,this.#h=0,this.#S=L.create(e),this.#n=0,this.#m=0,typeof g=="function"&&(this.#p=g),typeof S=="function"&&(this.#O=S),typeof f=="function"?(this.#w=f,this.#r=[]):(this.#w=void 0,this.#r=void 0),this.#y=!!this.#p,this.#D=!!this.#O,this.#f=!!this.#w,this.noDisposeOnSet=!!c,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!m,this.allowStaleOnFetchAbort=!!O,this.ignoreFetchAbort=!!F,this.maxEntrySize!==0){if(this.#c!==0&&!y(this.#c))throw new TypeError("maxSize must be a positive integer if specified");if(!y(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#H();}if(this.allowStale=!!r,this.noDeleteOnStaleGet=!!p,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!o,this.ttlResolution=y(s)||s===0?s:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!y(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I();}if(this.#a===0&&this.ttl===0&&this.#c===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#a&&!this.#c){let T="LRU_CACHE_UNBOUNDED";j(T)&&(U.add(T),I("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",T,l));}}getRemainingTTL(t){return this.#s.has(t)?1/0:0}#I(){let t=new E(this.#a),e=new E(this.#a);this.#d=t,this.#_=e,this.#G=(n,h,o=z.now())=>{if(e[n]=h!==0?o:0,t[n]=h,h!==0&&this.ttlAutopurge){let r=setTimeout(()=>{this.#g(n)&&this.#T(this.#i[n],"expire");},h+1);r.unref&&r.unref();}},this.#v=n=>{e[n]=t[n]!==0?z.now():0;},this.#z=(n,h)=>{if(t[h]){let o=t[h],r=e[h];if(!o||!r)return;n.ttl=o,n.start=r,n.now=i||s();let g=n.now-r;n.remainingTTL=o-g;}};let i=0,s=()=>{let n=z.now();if(this.ttlResolution>0){i=n;let h=setTimeout(()=>i=0,this.ttlResolution);h.unref&&h.unref();}return n};this.getRemainingTTL=n=>{let h=this.#s.get(n);if(h===void 0)return 0;let o=t[h],r=e[h];if(!o||!r)return 1/0;let g=(i||s())-r;return o-g},this.#g=n=>{let h=e[n],o=t[n];return !!o&&!!h&&(i||s())-h>o};}#v=()=>{};#z=()=>{};#G=()=>{};#g=()=>false;#H(){let t=new E(this.#a);this.#m=0,this.#b=t,this.#C=e=>{this.#m-=t[e],t[e]=0;},this.#j=(e,i,s,n)=>{if(this.#e(i))return 0;if(!y(s))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(s=n(i,e),!y(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#L=(e,i,s)=>{if(t[e]=i,this.#c){let n=this.#c-t[e];for(;this.#m>n;)this.#M(true);}this.#m+=t[e],s&&(s.entrySize=i,s.totalCalculatedSize=this.#m);};}#C=t=>{};#L=(t,e,i)=>{};#j=(t,e,i,s)=>{if(i||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#A({allowStale:t=this.allowStale}={}){if(this.#n)for(let e=this.#h;!(!this.#N(e)||((t||!this.#g(e))&&(yield e),e===this.#o));)e=this.#u[e];}*#F({allowStale:t=this.allowStale}={}){if(this.#n)for(let e=this.#o;!(!this.#N(e)||((t||!this.#g(e))&&(yield e),e===this.#h));)e=this.#l[e];}#N(t){return t!==void 0&&this.#s.get(this.#i[t])===t}*entries(){for(let t of this.#A())this.#t[t]!==void 0&&this.#i[t]!==void 0&&!this.#e(this.#t[t])&&(yield [this.#i[t],this.#t[t]]);}*rentries(){for(let t of this.#F())this.#t[t]!==void 0&&this.#i[t]!==void 0&&!this.#e(this.#t[t])&&(yield [this.#i[t],this.#t[t]]);}*keys(){for(let t of this.#A()){let e=this.#i[t];e!==void 0&&!this.#e(this.#t[t])&&(yield e);}}*rkeys(){for(let t of this.#F()){let e=this.#i[t];e!==void 0&&!this.#e(this.#t[t])&&(yield e);}}*values(){for(let t of this.#A())this.#t[t]!==void 0&&!this.#e(this.#t[t])&&(yield this.#t[t]);}*rvalues(){for(let t of this.#F())this.#t[t]!==void 0&&!this.#e(this.#t[t])&&(yield this.#t[t]);}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,e={}){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;if(n!==void 0&&t(n,this.#i[i],this))return this.get(this.#i[i],e)}}forEach(t,e=this){for(let i of this.#A()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&t.call(e,n,this.#i[i],this);}}rforEach(t,e=this){for(let i of this.#F()){let s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&t.call(e,n,this.#i[i],this);}}purgeStale(){let t=false;for(let e of this.#F({allowStale:true}))this.#g(e)&&(this.#T(this.#i[e],"expire"),t=true);return t}info(t){let e=this.#s.get(t);if(e===void 0)return;let i=this.#t[e],s=this.#e(i)?i.__staleWhileFetching:i;if(s===void 0)return;let n={value:s};if(this.#d&&this.#_){let h=this.#d[e],o=this.#_[e];if(h&&o){let r=h-(z.now()-o);n.ttl=r,n.start=Date.now();}}return this.#b&&(n.size=this.#b[e]),n}dump(){let t=[];for(let e of this.#A({allowStale:true})){let i=this.#i[e],s=this.#t[e],n=this.#e(s)?s.__staleWhileFetching:s;if(n===void 0||i===void 0)continue;let h={value:n};if(this.#d&&this.#_){h.ttl=this.#d[e];let o=z.now()-this.#_[e];h.start=Math.floor(Date.now()-o);}this.#b&&(h.size=this.#b[e]),t.unshift([i,h]);}return t}load(t){this.clear();for(let[e,i]of t){if(i.start){let s=Date.now()-i.start;i.start=z.now()-s;}this.set(e,i.value,i);}}set(t,e,i={}){if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:n,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:r}=i,{noUpdateTTL:g=this.noUpdateTTL}=i,S=this.#j(t,e,i.size||0,o);if(this.maxEntrySize&&S>this.maxEntrySize)return r&&(r.set="miss",r.maxEntrySizeExceeded=true),this.#T(t,"set"),this;let f=this.#n===0?void 0:this.#s.get(t);if(f===void 0)f=this.#n===0?this.#h:this.#S.length!==0?this.#S.pop():this.#n===this.#a?this.#M(false):this.#n,this.#i[f]=t,this.#t[f]=e,this.#s.set(t,f),this.#l[this.#h]=f,this.#u[f]=this.#h,this.#h=f,this.#n++,this.#L(f,S,r),r&&(r.set="add"),g=false,this.#D&&this.#O?.(e,t,"add");else {this.#R(f);let c=this.#t[f];if(e!==c){if(this.#E&&this.#e(c)){c.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:u}=c;u!==void 0&&!h&&(this.#y&&this.#p?.(u,t,"set"),this.#f&&this.#r?.push([u,t,"set"]));}else h||(this.#y&&this.#p?.(c,t,"set"),this.#f&&this.#r?.push([c,t,"set"]));if(this.#C(f),this.#L(f,S,r),this.#t[f]=e,r){r.set="replace";let u=c&&this.#e(c)?c.__staleWhileFetching:c;u!==void 0&&(r.oldValue=u);}}else r&&(r.set="update");this.#D&&this.onInsert?.(e,t,e===c?"update":"replace");}if(s!==0&&!this.#d&&this.#I(),this.#d&&(g||this.#G(f,s,n),r&&this.#z(r,f)),!h&&this.#f&&this.#r){let c=this.#r,u;for(;u=c?.shift();)this.#w?.(...u);}return this}pop(){try{for(;this.#n;){let t=this.#t[this.#o];if(this.#M(!0),this.#e(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#f&&this.#r){let t=this.#r,e;for(;e=t?.shift();)this.#w?.(...e);}}}#M(t){let e=this.#o,i=this.#i[e],s=this.#t[e];return this.#E&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#y||this.#f)&&(this.#y&&this.#p?.(s,i,"evict"),this.#f&&this.#r?.push([s,i,"evict"])),this.#C(e),t&&(this.#i[e]=void 0,this.#t[e]=void 0,this.#S.push(e)),this.#n===1?(this.#o=this.#h=0,this.#S.length=0):this.#o=this.#l[e],this.#s.delete(i),this.#n--,e}has(t,e={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:s}=e,n=this.#s.get(t);if(n!==void 0){let h=this.#t[n];if(this.#e(h)&&h.__staleWhileFetching===void 0)return false;if(this.#g(n))s&&(s.has="stale",this.#z(s,n));else return i&&this.#v(n),s&&(s.has="hit",this.#z(s,n)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:i=this.allowStale}=e,s=this.#s.get(t);if(s===void 0||!i&&this.#g(s))return;let n=this.#t[s];return this.#e(n)?n.__staleWhileFetching:n}#U(t,e,i,s){let n=e===void 0?void 0:this.#t[e];if(this.#e(n))return n;let h=new C,{signal:o}=i;o?.addEventListener("abort",()=>h.abort(o.reason),{signal:h.signal});let r={signal:h.signal,options:i,context:s},g=(d,b=false)=>{let{aborted:a}=h.signal,w=i.ignoreFetchAbort&&d!==void 0;if(i.status&&(a&&!b?(i.status.fetchAborted=true,i.status.fetchError=h.signal.reason,w&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),a&&!w&&!b)return f(h.signal.reason);let _=u;return this.#t[e]===u&&(d===void 0?_.__staleWhileFetching?this.#t[e]=_.__staleWhileFetching:this.#T(t,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(t,d,r.options))),d},S=d=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=d),f(d)),f=d=>{let{aborted:b}=h.signal,a=b&&i.allowStaleOnFetchAbort,w=a||i.allowStaleOnFetchRejection,_=w||i.noDeleteOnFetchRejection,p=u;if(this.#t[e]===u&&(!_||p.__staleWhileFetching===void 0?this.#T(t,"fetch"):a||(this.#t[e]=p.__staleWhileFetching)),w)return i.status&&p.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),p.__staleWhileFetching;if(p.__returned===p)throw d},c=(d,b)=>{let a=this.#W?.(t,n,r);a&&a instanceof Promise&&a.then(w=>d(w===void 0?void 0:w),b),h.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(d(void 0),i.allowStaleOnFetchAbort&&(d=w=>g(w,true)));});};i.status&&(i.status.fetchDispatched=true);let u=new Promise(c).then(g,S),A=Object.assign(u,{__abortController:h,__staleWhileFetching:n,__returned:void 0});return e===void 0?(this.set(t,A,{...r.options,status:void 0}),e=this.#s.get(t)):this.#t[e]=A,A}#e(t){if(!this.#E)return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof C}async fetch(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:r=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:S=this.noUpdateTTL,noDeleteOnFetchRejection:f=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:A=this.allowStaleOnFetchAbort,context:d,forceRefresh:b=false,status:a,signal:w}=e;if(!this.#E)return a&&(a.fetch="get"),this.get(t,{allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:a});let _={allowStale:i,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:h,noDisposeOnSet:o,size:r,sizeCalculation:g,noUpdateTTL:S,noDeleteOnFetchRejection:f,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:A,ignoreFetchAbort:u,status:a,signal:w},p=this.#s.get(t);if(p===void 0){a&&(a.fetch="miss");let m=this.#U(t,p,_,d);return m.__returned=m}else {let m=this.#t[p];if(this.#e(m)){let x=i&&m.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",x&&(a.returnedStale=true)),x?m.__staleWhileFetching:m.__returned=m}let O=this.#g(p);if(!b&&!O)return a&&(a.fetch="hit"),this.#R(p),s&&this.#v(p),a&&this.#z(a,p),m;let F=this.#U(t,p,_,d),T=F.__staleWhileFetching!==void 0&&i;return a&&(a.fetch=O?"stale":"refresh",T&&O&&(a.returnedStale=true)),T?F.__staleWhileFetching:F.__returned=F}}async forceFetch(t,e={}){let i=await this.fetch(t,e);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(t,e={}){let i=this.#x;if(!i)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:n,...h}=e,o=this.get(t,h);if(!n&&o!==void 0)return o;let r=i(t,o,{options:h,context:s});return this.set(t,r,h),r}get(t,e={}){let{allowStale:i=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:h}=e,o=this.#s.get(t);if(o!==void 0){let r=this.#t[o],g=this.#e(r);return h&&this.#z(h,o),this.#g(o)?(h&&(h.get="stale"),g?(h&&i&&r.__staleWhileFetching!==void 0&&(h.returnedStale=true),i?r.__staleWhileFetching:void 0):(n||this.#T(t,"expire"),h&&i&&(h.returnedStale=true),i?r:void 0)):(h&&(h.get="hit"),g?r.__staleWhileFetching:(this.#R(o),s&&this.#v(o),r))}else h&&(h.get="miss");}#V(t,e){this.#u[e]=t,this.#l[t]=e;}#R(t){t!==this.#h&&(t===this.#o?this.#o=this.#l[t]:this.#V(this.#u[t],this.#l[t]),this.#V(this.#h,t),this.#h=t);}delete(t){return this.#T(t,"delete")}#T(t,e){let i=false;if(this.#n!==0){let s=this.#s.get(t);if(s!==void 0)if(i=true,this.#n===1)this.#P(e);else {this.#C(s);let n=this.#t[s];if(this.#e(n)?n.__abortController.abort(new Error("deleted")):(this.#y||this.#f)&&(this.#y&&this.#p?.(n,t,e),this.#f&&this.#r?.push([n,t,e])),this.#s.delete(t),this.#i[s]=void 0,this.#t[s]=void 0,s===this.#h)this.#h=this.#u[s];else if(s===this.#o)this.#o=this.#l[s];else {let h=this.#u[s];this.#l[h]=this.#l[s];let o=this.#l[s];this.#u[o]=this.#u[s];}this.#n--,this.#S.push(s);}}if(this.#f&&this.#r?.length){let s=this.#r,n;for(;n=s?.shift();)this.#w?.(...n);}return i}clear(){return this.#P("delete")}#P(t){for(let e of this.#F({allowStale:true})){let i=this.#t[e];if(this.#e(i))i.__abortController.abort(new Error("deleted"));else {let s=this.#i[e];this.#y&&this.#p?.(i,s,t),this.#f&&this.#r?.push([i,s,t]);}}if(this.#s.clear(),this.#t.fill(void 0),this.#i.fill(void 0),this.#d&&this.#_&&(this.#d.fill(0),this.#_.fill(0)),this.#b&&this.#b.fill(0),this.#o=0,this.#h=0,this.#S.length=0,this.#m=0,this.#n=0,this.#f&&this.#r){let e=this.#r,i;for(;i=e?.shift();)this.#w?.(...i);}}};var W=class{cache;map=new Map;constructor(t){this.cache=new R({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}get entries(){return this.map.entries}keys(){return this.map.keys()}get values(){return this.map.values}};export{W as CachedMap};
|
|
1
|
+
var Ht=Object.defineProperty;var Mt=f=>{throw TypeError(f)};var Kt=(f,e,i)=>e in f?Ht(f,e,{enumerable:true,configurable:true,writable:true,value:i}):f[e]=i;var w=(f,e,i)=>Kt(f,typeof e!="symbol"?e+"":e,i),Ot=(f,e,i)=>e.has(f)||Mt("Cannot "+i);var t=(f,e,i)=>(Ot(f,e,"read from private field"),i?i.call(f):e.get(f)),p=(f,e,i)=>e.has(f)?Mt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,i),l=(f,e,i,s)=>(Ot(f,e,"write to private field"),e.set(f,i),i),a=(f,e,i)=>(Ot(f,e,"access private method"),i);var _t=(f,e,i,s)=>({set _(r){l(f,e,r);},get _(){return t(f,e,s)}});var at=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,jt=new Set,vt=typeof process=="object"&&process?process:{},Nt=(f,e,i,s)=>{typeof vt.emitWarning=="function"?vt.emitWarning(f,e,i,s):console.error(`[${i}] ${e}: ${f}`);},Ft=globalThis.AbortController,Ut=globalThis.AbortSignal;if(typeof Ft>"u"){Ut=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},Ft=class{constructor(){w(this,"signal",new Ut);e();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=vt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,Nt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var Bt=f=>!jt.has(f),J=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Vt=f=>J(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?lt:null:null,lt=class extends Array{constructor(e){super(e),this.fill(0);}},ft,it=class it{constructor(e,i){w(this,"heap");w(this,"length");if(!t(it,ft))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=Vt(e);if(!i)return [];l(it,ft,true);let s=new it(e,i);return l(it,ft,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};ft=new WeakMap,p(it,ft,false);var Ct=it,It,Gt,j,D,N,st,V,ct,ut,T,P,A,S,d,C,L,v,z,H,E,K,B,M,k,et,R,dt,o,Rt,nt,Y,mt,U,Pt,ht,gt,St,Q,Z,Wt,yt,At,m,xt,wt,tt,Dt,Lt=class Lt{constructor(e){p(this,o);p(this,j);p(this,D);p(this,N);p(this,st);p(this,V);p(this,ct);p(this,ut);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");p(this,T);p(this,P);p(this,A);p(this,S);p(this,d);p(this,C);p(this,L);p(this,v);p(this,z);p(this,H);p(this,E);p(this,K);p(this,B);p(this,M);p(this,k);p(this,et);p(this,R);p(this,dt);p(this,nt,()=>{});p(this,Y,()=>{});p(this,mt,()=>{});p(this,U,()=>false);p(this,ht,e=>{});p(this,gt,(e,i,s)=>{});p(this,St,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,It,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:h,updateAgeOnHas:u,allowStale:c,dispose:F,onInsert:$,disposeAfter:b,noDisposeOnSet:X,noUpdateTTL:I,maxSize:q=0,maxEntrySize:y=0,sizeCalculation:_,fetchMethod:g,memoMethod:W,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:O,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:pt,ignoreFetchAbort:rt}=e;if(i!==0&&!J(i))throw new TypeError("max option must be a nonnegative integer");let bt=i?Vt(i):Array;if(!bt)throw new Error("invalid max value: "+i);if(l(this,j,i),l(this,D,q),this.maxEntrySize=y||t(this,D),this.sizeCalculation=_,this.sizeCalculation){if(!t(this,D)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(W!==void 0&&typeof W!="function")throw new TypeError("memoMethod must be a function if defined");if(l(this,ut,W),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(l(this,ct,g),l(this,et,!!g),l(this,A,new Map),l(this,S,new Array(i).fill(void 0)),l(this,d,new Array(i).fill(void 0)),l(this,C,new bt(i)),l(this,L,new bt(i)),l(this,v,0),l(this,z,0),l(this,H,Ct.create(i)),l(this,T,0),l(this,P,0),typeof F=="function"&&l(this,N,F),typeof $=="function"&&l(this,st,$),typeof b=="function"?(l(this,V,b),l(this,E,[])):(l(this,V,void 0),l(this,E,void 0)),l(this,k,!!t(this,N)),l(this,dt,!!t(this,st)),l(this,R,!!t(this,V)),this.noDisposeOnSet=!!X,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!G,this.allowStaleOnFetchAbort=!!pt,this.ignoreFetchAbort=!!rt,this.maxEntrySize!==0){if(t(this,D)!==0&&!J(t(this,D)))throw new TypeError("maxSize must be a positive integer if specified");if(!J(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");a(this,o,Pt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!O,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!u,this.ttlResolution=J(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!J(this.ttl))throw new TypeError("ttl must be a positive integer if specified");a(this,o,Rt).call(this);}if(t(this,j)===0&&this.ttl===0&&t(this,D)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,j)&&!t(this,D)){let ot="LRU_CACHE_UNBOUNDED";Bt(ot)&&(jt.add(ot),Nt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ot,Lt));}}static unsafeExposeInternals(e){return {starts:t(e,B),ttls:t(e,M),sizes:t(e,K),keyMap:t(e,A),keyList:t(e,S),valList:t(e,d),next:t(e,C),prev:t(e,L),get head(){return t(e,v)},get tail(){return t(e,z)},free:t(e,H),isBackgroundFetch:i=>{var s;return a(s=e,o,m).call(s,i)},backgroundFetch:(i,s,r,n)=>{var h;return a(h=e,o,At).call(h,i,s,r,n)},moveToTail:i=>{var s;return a(s=e,o,wt).call(s,i)},indexes:i=>{var s;return a(s=e,o,Q).call(s,i)},rindexes:i=>{var s;return a(s=e,o,Z).call(s,i)},isStale:i=>{var s;return t(s=e,U).call(s,i)}}}get max(){return t(this,j)}get maxSize(){return t(this,D)}get calculatedSize(){return t(this,P)}get size(){return t(this,T)}get fetchMethod(){return t(this,ct)}get memoMethod(){return t(this,ut)}get dispose(){return t(this,N)}get onInsert(){return t(this,st)}get disposeAfter(){return t(this,V)}getRemainingTTL(e){return t(this,A).has(e)?1/0:0}*entries(){for(let e of a(this,o,Q).call(this))t(this,d)[e]!==void 0&&t(this,S)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield [t(this,S)[e],t(this,d)[e]]);}*rentries(){for(let e of a(this,o,Z).call(this))t(this,d)[e]!==void 0&&t(this,S)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield [t(this,S)[e],t(this,d)[e]]);}*keys(){for(let e of a(this,o,Q).call(this)){let i=t(this,S)[e];i!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield i);}}*rkeys(){for(let e of a(this,o,Z).call(this)){let i=t(this,S)[e];i!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield i);}}*values(){for(let e of a(this,o,Q).call(this))t(this,d)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}*rvalues(){for(let e of a(this,o,Z).call(this))t(this,d)[e]!==void 0&&!a(this,o,m).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}[(Gt=Symbol.iterator,It=Symbol.toStringTag,Gt)](){return this.entries()}find(e,i={}){for(let s of a(this,o,Q).call(this)){let r=t(this,d)[s],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,S)[s],this))return this.get(t(this,S)[s],i)}}forEach(e,i=this){for(let s of a(this,o,Q).call(this)){let r=t(this,d)[s],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,S)[s],this);}}rforEach(e,i=this){for(let s of a(this,o,Z).call(this)){let r=t(this,d)[s],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,S)[s],this);}}purgeStale(){let e=false;for(let i of a(this,o,Z).call(this,{allowStale:true}))t(this,U).call(this,i)&&(a(this,o,tt).call(this,t(this,S)[i],"expire"),e=true);return e}info(e){let i=t(this,A).get(e);if(i===void 0)return;let s=t(this,d)[i],r=a(this,o,m).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,M)&&t(this,B)){let h=t(this,M)[i],u=t(this,B)[i];if(h&&u){let c=h-(at.now()-u);n.ttl=c,n.start=Date.now();}}return t(this,K)&&(n.size=t(this,K)[i]),n}dump(){let e=[];for(let i of a(this,o,Q).call(this,{allowStale:true})){let s=t(this,S)[i],r=t(this,d)[i],n=a(this,o,m).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let h={value:n};if(t(this,M)&&t(this,B)){h.ttl=t(this,M)[i];let u=at.now()-t(this,B)[i];h.start=Math.floor(Date.now()-u);}t(this,K)&&(h.size=t(this,K)[i]),e.unshift([s,h]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=at.now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var X,I,q,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:u=this.sizeCalculation,status:c}=s,{noUpdateTTL:F=this.noUpdateTTL}=s,$=t(this,St).call(this,e,i,s.size||0,u);if(this.maxEntrySize&&$>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),a(this,o,tt).call(this,e,"set"),this;let b=t(this,T)===0?void 0:t(this,A).get(e);if(b===void 0)b=t(this,T)===0?t(this,z):t(this,H).length!==0?t(this,H).pop():t(this,T)===t(this,j)?a(this,o,yt).call(this,false):t(this,T),t(this,S)[b]=e,t(this,d)[b]=i,t(this,A).set(e,b),t(this,C)[t(this,z)]=b,t(this,L)[b]=t(this,z),l(this,z,b),_t(this,T)._++,t(this,gt).call(this,b,$,c),c&&(c.set="add"),F=false,t(this,dt)&&((X=t(this,st))==null||X.call(this,i,e,"add"));else {a(this,o,wt).call(this,b);let _=t(this,d)[b];if(i!==_){if(t(this,et)&&a(this,o,m).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=_;g!==void 0&&!h&&(t(this,k)&&((I=t(this,N))==null||I.call(this,g,e,"set")),t(this,R)&&t(this,E)?.push([g,e,"set"]));}else h||(t(this,k)&&((q=t(this,N))==null||q.call(this,_,e,"set")),t(this,R)&&t(this,E)?.push([_,e,"set"]));if(t(this,ht).call(this,b),t(this,gt).call(this,b,$,c),t(this,d)[b]=i,c){c.set="replace";let g=_&&a(this,o,m).call(this,_)?_.__staleWhileFetching:_;g!==void 0&&(c.oldValue=g);}}else c&&(c.set="update");t(this,dt)&&this.onInsert?.(i,e,i===_?"update":"replace");}if(r!==0&&!t(this,M)&&a(this,o,Rt).call(this),t(this,M)&&(F||t(this,mt).call(this,b,r,n),c&&t(this,Y).call(this,c,b)),!h&&t(this,R)&&t(this,E)){let _=t(this,E),g;for(;g=_?.shift();)(y=t(this,V))==null||y.call(this,...g);}return this}pop(){var e;try{for(;t(this,T);){let i=t(this,d)[t(this,v)];if(a(this,o,yt).call(this,!0),a(this,o,m).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,R)&&t(this,E)){let i=t(this,E),s;for(;s=i?.shift();)(e=t(this,V))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,A).get(e);if(n!==void 0){let h=t(this,d)[n];if(a(this,o,m).call(this,h)&&h.__staleWhileFetching===void 0)return false;if(t(this,U).call(this,n))r&&(r.has="stale",t(this,Y).call(this,r,n));else return s&&t(this,nt).call(this,n),r&&(r.has="hit",t(this,Y).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,A).get(e);if(r===void 0||!s&&t(this,U).call(this,r))return;let n=t(this,d)[r];return a(this,o,m).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:u=this.noDisposeOnSet,size:c=0,sizeCalculation:F=this.sizeCalculation,noUpdateTTL:$=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:X=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:y,forceRefresh:_=false,status:g,signal:W}=i;if(!t(this,et))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let x={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:h,noDisposeOnSet:u,size:c,sizeCalculation:F,noUpdateTTL:$,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:X,allowStaleOnFetchAbort:q,ignoreFetchAbort:I,status:g,signal:W},O=t(this,A).get(e);if(O===void 0){g&&(g.fetch="miss");let G=a(this,o,At).call(this,e,O,x,y);return G.__returned=G}else {let G=t(this,d)[O];if(a(this,o,m).call(this,G)){let Et=s&&G.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Et&&(g.returnedStale=true)),Et?G.__staleWhileFetching:G.__returned=G}let pt=t(this,U).call(this,O);if(!_&&!pt)return g&&(g.fetch="hit"),a(this,o,wt).call(this,O),r&&t(this,nt).call(this,O),g&&t(this,Y).call(this,g,O),G;let rt=a(this,o,At).call(this,e,O,x,y),ot=rt.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=pt?"stale":"refresh",ot&&pt&&(g.returnedStale=true)),ot?rt.__staleWhileFetching:rt.__returned=rt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,ut);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...h}=i,u=this.get(e,h);if(!n&&u!==void 0)return u;let c=s(e,u,{options:h,context:r});return this.set(e,c,h),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:h}=i,u=t(this,A).get(e);if(u!==void 0){let c=t(this,d)[u],F=a(this,o,m).call(this,c);return h&&t(this,Y).call(this,h,u),t(this,U).call(this,u)?(h&&(h.get="stale"),F?(h&&s&&c.__staleWhileFetching!==void 0&&(h.returnedStale=true),s?c.__staleWhileFetching:void 0):(n||a(this,o,tt).call(this,e,"expire"),h&&s&&(h.returnedStale=true),s?c:void 0)):(h&&(h.get="hit"),F?c.__staleWhileFetching:(a(this,o,wt).call(this,u),r&&t(this,nt).call(this,u),c))}else h&&(h.get="miss");}delete(e){return a(this,o,tt).call(this,e,"delete")}clear(){return a(this,o,Dt).call(this,"delete")}};j=new WeakMap,D=new WeakMap,N=new WeakMap,st=new WeakMap,V=new WeakMap,ct=new WeakMap,ut=new WeakMap,T=new WeakMap,P=new WeakMap,A=new WeakMap,S=new WeakMap,d=new WeakMap,C=new WeakMap,L=new WeakMap,v=new WeakMap,z=new WeakMap,H=new WeakMap,E=new WeakMap,K=new WeakMap,B=new WeakMap,M=new WeakMap,k=new WeakMap,et=new WeakMap,R=new WeakMap,dt=new WeakMap,o=new WeakSet,Rt=function(){let e=new lt(t(this,j)),i=new lt(t(this,j));l(this,M,e),l(this,B,i),l(this,mt,(n,h,u=at.now())=>{if(i[n]=h!==0?u:0,e[n]=h,h!==0&&this.ttlAutopurge){let c=setTimeout(()=>{t(this,U).call(this,n)&&a(this,o,tt).call(this,t(this,S)[n],"expire");},h+1);c.unref&&c.unref();}}),l(this,nt,n=>{i[n]=e[n]!==0?at.now():0;}),l(this,Y,(n,h)=>{if(e[h]){let u=e[h],c=i[h];if(!u||!c)return;n.ttl=u,n.start=c,n.now=s||r();let F=n.now-c;n.remainingTTL=u-F;}});let s=0,r=()=>{let n=at.now();if(this.ttlResolution>0){s=n;let h=setTimeout(()=>s=0,this.ttlResolution);h.unref&&h.unref();}return n};this.getRemainingTTL=n=>{let h=t(this,A).get(n);if(h===void 0)return 0;let u=e[h],c=i[h];if(!u||!c)return 1/0;let F=(s||r())-c;return u-F},l(this,U,n=>{let h=i[n],u=e[n];return !!u&&!!h&&(s||r())-h>u});},nt=new WeakMap,Y=new WeakMap,mt=new WeakMap,U=new WeakMap,Pt=function(){let e=new lt(t(this,j));l(this,P,0),l(this,K,e),l(this,ht,i=>{l(this,P,t(this,P)-e[i]),e[i]=0;}),l(this,St,(i,s,r,n)=>{if(a(this,o,m).call(this,s))return 0;if(!J(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!J(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),l(this,gt,(i,s,r)=>{if(e[i]=s,t(this,D)){let n=t(this,D)-e[i];for(;t(this,P)>n;)a(this,o,yt).call(this,true);}l(this,P,t(this,P)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,P));});},ht=new WeakMap,gt=new WeakMap,St=new WeakMap,Q=function*({allowStale:e=this.allowStale}={}){if(t(this,T))for(let i=t(this,z);!(!a(this,o,Wt).call(this,i)||((e||!t(this,U).call(this,i))&&(yield i),i===t(this,v)));)i=t(this,L)[i];},Z=function*({allowStale:e=this.allowStale}={}){if(t(this,T))for(let i=t(this,v);!(!a(this,o,Wt).call(this,i)||((e||!t(this,U).call(this,i))&&(yield i),i===t(this,z)));)i=t(this,C)[i];},Wt=function(e){return e!==void 0&&t(this,A).get(t(this,S)[e])===e},yt=function(e){var n;let i=t(this,v),s=t(this,S)[i],r=t(this,d)[i];return t(this,et)&&a(this,o,m).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,k)||t(this,R))&&(t(this,k)&&((n=t(this,N))==null||n.call(this,r,s,"evict")),t(this,R)&&t(this,E)?.push([r,s,"evict"])),t(this,ht).call(this,i),e&&(t(this,S)[i]=void 0,t(this,d)[i]=void 0,t(this,H).push(i)),t(this,T)===1?(l(this,v,l(this,z,0)),t(this,H).length=0):l(this,v,t(this,C)[i]),t(this,A).delete(s),_t(this,T)._--,i},At=function(e,i,s,r){let n=i===void 0?void 0:t(this,d)[i];if(a(this,o,m).call(this,n))return n;let h=new Ft,{signal:u}=s;u?.addEventListener("abort",()=>h.abort(u.reason),{signal:h.signal});let c={signal:h.signal,options:s,context:r},F=(y,_=false)=>{let{aborted:g}=h.signal,W=s.ignoreFetchAbort&&y!==void 0;if(s.status&&(g&&!_?(s.status.fetchAborted=true,s.status.fetchError=h.signal.reason,W&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!W&&!_)return b(h.signal.reason);let x=I;return t(this,d)[i]===I&&(y===void 0?x.__staleWhileFetching?t(this,d)[i]=x.__staleWhileFetching:a(this,o,tt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},$=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),b(y)),b=y=>{let{aborted:_}=h.signal,g=_&&s.allowStaleOnFetchAbort,W=g||s.allowStaleOnFetchRejection,x=W||s.noDeleteOnFetchRejection,O=I;if(t(this,d)[i]===I&&(!x||O.__staleWhileFetching===void 0?a(this,o,tt).call(this,e,"fetch"):g||(t(this,d)[i]=O.__staleWhileFetching)),W)return s.status&&O.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw y},X=(y,_)=>{var W;let g=(W=t(this,ct))==null?void 0:W.call(this,e,n,c);g&&g instanceof Promise&&g.then(x=>y(x===void 0?void 0:x),_),h.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=x=>F(x,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(X).then(F,$),q=Object.assign(I,{__abortController:h,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,q,{...c.options,status:void 0}),i=t(this,A).get(e)):t(this,d)[i]=q,q},m=function(e){if(!t(this,et))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},xt=function(e,i){t(this,L)[i]=e,t(this,C)[e]=i;},wt=function(e){e!==t(this,z)&&(e===t(this,v)?l(this,v,t(this,C)[e]):a(this,o,xt).call(this,t(this,L)[e],t(this,C)[e]),a(this,o,xt).call(this,t(this,z),e),l(this,z,e));},tt=function(e,i){var r,n;let s=false;if(t(this,T)!==0){let h=t(this,A).get(e);if(h!==void 0)if(s=true,t(this,T)===1)a(this,o,Dt).call(this,i);else {t(this,ht).call(this,h);let u=t(this,d)[h];if(a(this,o,m).call(this,u)?u.__abortController.abort(new Error("deleted")):(t(this,k)||t(this,R))&&(t(this,k)&&((r=t(this,N))==null||r.call(this,u,e,i)),t(this,R)&&t(this,E)?.push([u,e,i])),t(this,A).delete(e),t(this,S)[h]=void 0,t(this,d)[h]=void 0,h===t(this,z))l(this,z,t(this,L)[h]);else if(h===t(this,v))l(this,v,t(this,C)[h]);else {let c=t(this,L)[h];t(this,C)[c]=t(this,C)[h];let F=t(this,C)[h];t(this,L)[F]=t(this,L)[h];}_t(this,T)._--,t(this,H).push(h);}}if(t(this,R)&&t(this,E)?.length){let h=t(this,E),u;for(;u=h?.shift();)(n=t(this,V))==null||n.call(this,...u);}return s},Dt=function(e){var i,s;for(let r of a(this,o,Z).call(this,{allowStale:true})){let n=t(this,d)[r];if(a(this,o,m).call(this,n))n.__abortController.abort(new Error("deleted"));else {let h=t(this,S)[r];t(this,k)&&((i=t(this,N))==null||i.call(this,n,h,e)),t(this,R)&&t(this,E)?.push([n,h,e]);}}if(t(this,A).clear(),t(this,d).fill(void 0),t(this,S).fill(void 0),t(this,M)&&t(this,B)&&(t(this,M).fill(0),t(this,B).fill(0)),t(this,K)&&t(this,K).fill(0),l(this,v,0),l(this,z,0),t(this,H).length=0,l(this,P,0),l(this,T,0),t(this,R)&&t(this,E)){let r=t(this,E),n;for(;n=r?.shift();)(s=t(this,V))==null||s.call(this,...n);}};var Tt=Lt;var zt=class{constructor(e){w(this,"cache");w(this,"map",new Map);this.cache=new Tt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};export{zt as CachedMap};
|
package/dist/history/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var ce=Object.create;var re=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var be=(l,e)=>()=>(e||l((e={exports:{}}).exports,e),e.exports);var Se=(l,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of me(e))!ge.call(l,r)&&r!==t&&re(l,r,{get:()=>e[r],enumerable:!(i=pe(e,r))||i.enumerable});return l};var ve=(l,e,t)=>(t=l!=null?ce(ye(l)):{},Se(re(t,"default",{value:l,enumerable:true}),l));var se=be((X,ne)=>{(function(l,e){var t=e(l);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return t});else if(typeof X=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))ne.exports=t;else {var i=l.DeepDiff;t.noConflict=function(){return l.DeepDiff===t&&(l.DeepDiff=i),t},l.DeepDiff=t;}})(X,function(l){var e=["N","E","A","D"];function t(o,a){o.super_=a,o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}});}function i(o,a){Object.defineProperty(this,"kind",{value:o,enumerable:true}),a&&a.length&&Object.defineProperty(this,"path",{value:a,enumerable:true});}function r(o,a,s){r.super_.call(this,"E",o),Object.defineProperty(this,"lhs",{value:a,enumerable:true}),Object.defineProperty(this,"rhs",{value:s,enumerable:true});}t(r,i);function n(o,a){n.super_.call(this,"N",o),Object.defineProperty(this,"rhs",{value:a,enumerable:true});}t(n,i);function h(o,a){h.super_.call(this,"D",o),Object.defineProperty(this,"lhs",{value:a,enumerable:true});}t(h,i);function c(o,a,s){c.super_.call(this,"A",o),Object.defineProperty(this,"index",{value:a,enumerable:true}),Object.defineProperty(this,"item",{value:s,enumerable:true});}t(c,i);function d(o,a,s){var f=o.slice((a)+1||o.length);return o.length=a<0?o.length+a:a,o.push.apply(o,f),o}function g(o){var a=typeof o;return a!=="object"?a:o===Math?"math":o===null?"null":Array.isArray(o)?"array":Object.prototype.toString.call(o)==="[object Date]"?"date":typeof o.toString=="function"&&/^\/.*\//.test(o.toString())?"regexp":"object"}function _(o){var a=0;if(o.length===0)return a;for(var s=0;s<o.length;s++){var f=o.charCodeAt(s);a=(a<<5)-a+f,a=a&a;}return a}function m(o){var a=0,s=g(o);if(s==="array"){o.forEach(function(k){a+=m(k);});var f="[type: array, hash: "+a+"]";return a+_(f)}if(s==="object"){for(var u in o)if(o.hasOwnProperty(u)){var w="[ type: object, key: "+u+", value hash: "+m(o[u])+"]";a+=_(w);}return a}var b="[ type: "+s+" ; value: "+o+"]";return a+_(b)}function y(o,a,s,f,u,w,b,k){s=s||[],u=u||[],b=b||[];var O=u.slice(0);if(typeof w<"u"&&w!==null){if(f){if(typeof f=="function"&&f(O,w))return;if(typeof f=="object"){if(f.prefilter&&f.prefilter(O,w))return;if(f.normalize){var $=f.normalize(O,w,o,a);$&&(o=$[0],a=$[1]);}}}O.push(w);}g(o)==="regexp"&&g(a)==="regexp"&&(o=o.toString(),a=a.toString());var Y=typeof o,de=typeof a,D,P,z,j,ee=Y!=="undefined"||b&&b.length>0&&b[b.length-1].lhs&&Object.getOwnPropertyDescriptor(b[b.length-1].lhs,w),te=de!=="undefined"||b&&b.length>0&&b[b.length-1].rhs&&Object.getOwnPropertyDescriptor(b[b.length-1].rhs,w);if(!ee&&te)s.push(new n(O,a));else if(!te&&ee)s.push(new h(O,o));else if(g(o)!==g(a))s.push(new r(O,o,a));else if(g(o)==="date"&&o-a!==0)s.push(new r(O,o,a));else if(Y==="object"&&o!==null&&a!==null){for(D=b.length-1;D>-1;--D)if(b[D].lhs===o){j=true;break}if(j)o!==a&&s.push(new r(O,o,a));else {if(b.push({lhs:o,rhs:a}),Array.isArray(o)){for(k&&(o.sort(function(J,q){return m(J)-m(q)}),a.sort(function(J,q){return m(J)-m(q)})),D=a.length-1,P=o.length-1;D>P;)s.push(new c(O,D,new n(void 0,a[D--])));for(;P>D;)s.push(new c(O,P,new h(void 0,o[P--])));for(;D>=0;--D)y(o[D],a[D],s,f,O,D,b,k);}else {var ie=Object.keys(o),U=Object.keys(a);for(D=0;D<ie.length;++D)z=ie[D],j=U.indexOf(z),j>=0?(y(o[z],a[z],s,f,O,z,b,k),U[j]=null):y(o[z],void 0,s,f,O,z,b,k);for(D=0;D<U.length;++D)z=U[D],z&&y(void 0,a[z],s,f,O,z,b,k);}b.length=b.length-1;}}else o!==a&&(Y==="number"&&isNaN(o)&&isNaN(a)||s.push(new r(O,o,a)));}function G(o,a,s,f,u){var w=[];if(y(o,a,w,f,null,null,null,u),s)for(var b=0;b<w.length;++b)s(w[b]);return w}function N(o,a,s,f,u,w,b){return y(o,a,s,f,u,w,b,true)}function E(o,a,s,f){var u=f?function(b){b&&f.push(b);}:void 0,w=G(o,a,u,s);return f||(w.length?w:void 0)}function T(o,a,s,f){var u=f?function(b){b&&f.push(b);}:void 0,w=G(o,a,u,s,true);return f||(w.length?w:void 0)}function v(o,a,s){if(s.path&&s.path.length){var f=o[a],u,w=s.path.length-1;for(u=0;u<w;u++)f=f[s.path[u]];switch(s.kind){case "A":v(f[s.path[u]],s.index,s.item);break;case "D":delete f[s.path[u]];break;case "E":case "N":f[s.path[u]]=s.rhs;break}}else switch(s.kind){case "A":v(o[a],s.index,s.item);break;case "D":o=d(o,a);break;case "E":case "N":o[a]=s.rhs;break}return o}function H(o,a,s){if(typeof s>"u"&&a&&~e.indexOf(a.kind)&&(s=a),o&&s&&s.kind){for(var f=o,u=-1,w=s.path?s.path.length-1:0;++u<w;)typeof f[s.path[u]]>"u"&&(f[s.path[u]]=typeof s.path[u+1]<"u"&&typeof s.path[u+1]=="number"?[]:{}),f=f[s.path[u]];switch(s.kind){case "A":s.path&&typeof f[s.path[u]]>"u"&&(f[s.path[u]]=[]),v(s.path?f[s.path[u]]:f,s.index,s.item);break;case "D":delete f[s.path[u]];break;case "E":case "N":f[s.path[u]]=s.rhs;break}}}function C(o,a,s){if(s.path&&s.path.length){var f=o[a],u,w=s.path.length-1;for(u=0;u<w;u++)f=f[s.path[u]];switch(s.kind){case "A":C(f[s.path[u]],s.index,s.item);break;case "D":f[s.path[u]]=s.lhs;break;case "E":f[s.path[u]]=s.lhs;break;case "N":delete f[s.path[u]];break}}else switch(s.kind){case "A":C(o[a],s.index,s.item);break;case "D":o[a]=s.lhs;break;case "E":o[a]=s.lhs;break;case "N":o=d(o,a);break}return o}function A(o,a,s){if(o&&a&&s&&s.kind){var f=o,u,w;for(w=s.path.length-1,u=0;u<w;u++)typeof f[s.path[u]]>"u"&&(f[s.path[u]]={}),f=f[s.path[u]];switch(s.kind){case "A":C(f[s.path[u]],s.index,s.item);break;case "D":f[s.path[u]]=s.lhs;break;case "E":f[s.path[u]]=s.lhs;break;case "N":delete f[s.path[u]];break}}}function x(o,a,s){if(o&&a){var f=function(u){(!s||s(o,a,u))&&H(o,a,u);};G(o,a,f);}}return Object.defineProperties(E,{diff:{value:E,enumerable:true},orderIndependentDiff:{value:T,enumerable:true},observableDiff:{value:G,enumerable:true},orderIndependentObservableDiff:{value:N,enumerable:true},orderIndepHash:{value:m,enumerable:true},applyDiff:{value:x,enumerable:true},applyChange:{value:H,enumerable:true},revertChange:{value:A,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),E.DeepDiff=E,l&&(l.DeepDiff=E),E});});var ue=ve(se());var S;(r=>(r.log=(n,...h)=>console.log(`[Pixi\u2019VN] ${n}`,...h),r.warn=(n,...h)=>console.warn(`[Pixi\u2019VN] ${n}`,...h),r.error=(n,...h)=>console.error(`[Pixi\u2019VN] ${n}`,...h),r.info=(n,...h)=>console.info(`[Pixi\u2019VN] ${n}`,...h)))(S||={});var M=class l{static init(e){l._getStepCounter=e.getStepCounter,l._setStepCounter=e.setStepCounter,l._getCurrentGameStepState=e.getCurrentGameStepState,l._restoreGameStepState=e.restoreGameStepState,l._getOpenedLabels=e.getOpenedLabels,e.onGoNextEnd&&(l._onGoNextEnd=e.onGoNextEnd),l._getVariable=e.getVariable,l._setVariable=e.setVariable,l._removeVariable=e.removeVariable,l._getFlag=e.getFlag,l._setFlag=e.setFlag,e.onLabelClosing&&(l._onLabelClosing=e.onLabelClosing),l._addHistoryItem=e.addHistoryItem,l._getCurrentStepsRunningNumber=e.getCurrentStepsRunningNumber,l._getCharacter=e.getCharacter;}static _getStepCounter=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return l._getStepCounter()}static set stepCounter(e){l._setStepCounter(e);}static _getCurrentGameStepState=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return l._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return l._restoreGameStepState}static _getOpenedLabels=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return l._getOpenedLabels()}static _onGoNextEnd=async()=>{};static get onGoNextEnd(){return l._onGoNextEnd}static _getVariable=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return l._getVariable}static _setVariable=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return l._setVariable}static _removeVariable=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return l._removeVariable}static _getFlag=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return l._getFlag}static _setFlag=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return l._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return l._onLabelClosing}static _addHistoryItem=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return l._addHistoryItem}static _getCurrentStepsRunningNumber=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentStepsRunningNumber(){return l._getCurrentStepsRunningNumber()}static _getCharacter=()=>{throw S.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")};static get getCharacter(){return l._getCharacter}static onEnd;static onError};function I(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw S.error("Error creating exportable element",l,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function oe(l,e){let t=I(l);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(i=>{"type"in i?we(t,i):_e(t,i);}),t}function we(l,e){let t=l;e.path&&e.path.length>0?e.path.forEach((i,r)=>{if(e.path&&r===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":t[i]=e.oldValue;break;case "CREATE":Array.isArray(t)&&typeof i=="number"?t.splice(i,1):delete t[i];break}else t=t[i];}):S.warn("No path found, skipping diff",e);}function _e(l,e){let t=l;e.path&&e.path.length>0?e.path.forEach((i,r)=>{if(e.path&&r===e.path.length-1){if(e.kind==="E"||e.kind==="D")t[i]=e.lhs;else if(e.kind==="N")Number.isInteger(i)?Array.isArray(t)&&t.splice(i,1):typeof i=="string"&&delete t[i];else if(e.kind==="A"){let n=e.index;e.item.kind==="N"?t[i].splice(n,1):e.item.kind==="E"||e.item.kind==="D"?t[i][n]=e.item.lhs:e.item.kind==="A"?S.warn("Nested array found, skipping diff",e):S.warn("No array found, skipping diff",e);}}else t=t[i];}):S.warn("No path found, skipping diff",e);}var R=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,le=new Set,Q=typeof process=="object"&&process?process:{},he=(l,e,t,i)=>{typeof Q.emitWarning=="function"?Q.emitWarning(l,e,t,i):console.error(`[${t}] ${e}: ${l}`);},K=globalThis.AbortController,ae=globalThis.AbortSignal;if(typeof K>"u"){ae=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,r){this._onabort.push(r);}},K=class{constructor(){e();}signal=new ae;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i);}}};let l=Q.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,he("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var Ee=l=>!le.has(l),F=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),fe=l=>F(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?V:null:null,V=class extends Array{constructor(e){super(e),this.fill(0);}},Z=class l{heap;length;static#l=false;static create(e){let t=fe(e);if(!t)return [];l.#l=true;let i=new l(e,t);return l.#l=false,i}constructor(e,t){if(!l.#l)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},B=class l{#l;#u;#m;#A;#y;#T;#z;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#g;#r;#i;#e;#h;#d;#a;#s;#b;#o;#S;#v;#c;#w;#H;#f;#M;static unsafeExposeInternals(e){return {starts:e.#v,ttls:e.#c,sizes:e.#S,keyMap:e.#r,keyList:e.#i,valList:e.#e,next:e.#h,prev:e.#d,get head(){return e.#a},get tail(){return e.#s},free:e.#b,isBackgroundFetch:t=>e.#t(t),backgroundFetch:(t,i,r,n)=>e.#F(t,i,r,n),moveToTail:t=>e.#C(t),indexes:t=>e.#_(t),rindexes:t=>e.#E(t),isStale:t=>e.#p(t)}}get max(){return this.#l}get maxSize(){return this.#u}get calculatedSize(){return this.#g}get size(){return this.#n}get fetchMethod(){return this.#T}get memoMethod(){return this.#z}get dispose(){return this.#m}get onInsert(){return this.#A}get disposeAfter(){return this.#y}constructor(e){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:h,updateAgeOnHas:c,allowStale:d,dispose:g,onInsert:_,disposeAfter:m,noDisposeOnSet:y,noUpdateTTL:G,maxSize:N=0,maxEntrySize:E=0,sizeCalculation:T,fetchMethod:v,memoMethod:H,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:o,ignoreFetchAbort:a}=e;if(t!==0&&!F(t))throw new TypeError("max option must be a nonnegative integer");let s=t?fe(t):Array;if(!s)throw new Error("invalid max value: "+t);if(this.#l=t,this.#u=N,this.maxEntrySize=E||this.#u,this.sizeCalculation=T,this.sizeCalculation){if(!this.#u&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(H!==void 0&&typeof H!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#z=H,v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#T=v,this.#H=!!v,this.#r=new Map,this.#i=new Array(t).fill(void 0),this.#e=new Array(t).fill(void 0),this.#h=new s(t),this.#d=new s(t),this.#a=0,this.#s=0,this.#b=Z.create(t),this.#n=0,this.#g=0,typeof g=="function"&&(this.#m=g),typeof _=="function"&&(this.#A=_),typeof m=="function"?(this.#y=m,this.#o=[]):(this.#y=void 0,this.#o=void 0),this.#w=!!this.#m,this.#M=!!this.#A,this.#f=!!this.#y,this.noDisposeOnSet=!!y,this.noUpdateTTL=!!G,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!o,this.ignoreFetchAbort=!!a,this.maxEntrySize!==0){if(this.#u!==0&&!F(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!F(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#W();}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!c,this.ttlResolution=F(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=i||0,this.ttl){if(!F(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#L();}if(this.#l===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#l&&!this.#u){let f="LRU_CACHE_UNBOUNDED";Ee(f)&&(le.add(f),he("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",f,l));}}getRemainingTTL(e){return this.#r.has(e)?1/0:0}#L(){let e=new V(this.#l),t=new V(this.#l);this.#c=e,this.#v=t,this.#k=(n,h,c=R.now())=>{if(t[n]=h!==0?c:0,e[n]=h,h!==0&&this.ttlAutopurge){let d=setTimeout(()=>{this.#p(n)&&this.#G(this.#i[n],"expire");},h+1);d.unref&&d.unref();}},this.#O=n=>{t[n]=e[n]!==0?R.now():0;},this.#D=(n,h)=>{if(e[h]){let c=e[h],d=t[h];if(!c||!d)return;n.ttl=c,n.start=d,n.now=i||r();let g=n.now-d;n.remainingTTL=c-g;}};let i=0,r=()=>{let n=R.now();if(this.ttlResolution>0){i=n;let h=setTimeout(()=>i=0,this.ttlResolution);h.unref&&h.unref();}return n};this.getRemainingTTL=n=>{let h=this.#r.get(n);if(h===void 0)return 0;let c=e[h],d=t[h];if(!c||!d)return 1/0;let g=(i||r())-d;return c-g},this.#p=n=>{let h=t[n],c=e[n];return !!c&&!!h&&(i||r())-h>c};}#O=()=>{};#D=()=>{};#k=()=>{};#p=()=>false;#W(){let e=new V(this.#l);this.#g=0,this.#S=e,this.#x=t=>{this.#g-=e[t],e[t]=0;},this.#R=(t,i,r,n)=>{if(this.#t(i))return 0;if(!F(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(i,t),!F(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#I=(t,i,r)=>{if(e[t]=i,this.#u){let n=this.#u-e[t];for(;this.#g>n;)this.#N(true);}this.#g+=e[t],r&&(r.entrySize=i,r.totalCalculatedSize=this.#g);};}#x=e=>{};#I=(e,t,i)=>{};#R=(e,t,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#_({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#s;!(!this.#V(t)||((e||!this.#p(t))&&(yield t),t===this.#a));)t=this.#d[t];}*#E({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#a;!(!this.#V(t)||((e||!this.#p(t))&&(yield t),t===this.#s));)t=this.#h[t];}#V(e){return e!==void 0&&this.#r.get(this.#i[e])===e}*entries(){for(let e of this.#_())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield [this.#i[e],this.#e[e]]);}*rentries(){for(let e of this.#E())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield [this.#i[e],this.#e[e]]);}*keys(){for(let e of this.#_()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t);}}*rkeys(){for(let e of this.#E()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t);}}*values(){for(let e of this.#_())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e]);}*rvalues(){for(let e of this.#E())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e]);}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let i of this.#_()){let r=this.#e[i],n=this.#t(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.#i[i],this))return this.get(this.#i[i],t)}}forEach(e,t=this){for(let i of this.#_()){let r=this.#e[i],n=this.#t(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.#i[i],this);}}rforEach(e,t=this){for(let i of this.#E()){let r=this.#e[i],n=this.#t(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(t,n,this.#i[i],this);}}purgeStale(){let e=false;for(let t of this.#E({allowStale:true}))this.#p(t)&&(this.#G(this.#i[t],"expire"),e=true);return e}info(e){let t=this.#r.get(e);if(t===void 0)return;let i=this.#e[t],r=this.#t(i)?i.__staleWhileFetching:i;if(r===void 0)return;let n={value:r};if(this.#c&&this.#v){let h=this.#c[t],c=this.#v[t];if(h&&c){let d=h-(R.now()-c);n.ttl=d,n.start=Date.now();}}return this.#S&&(n.size=this.#S[t]),n}dump(){let e=[];for(let t of this.#_({allowStale:true})){let i=this.#i[t],r=this.#e[t],n=this.#t(r)?r.__staleWhileFetching:r;if(n===void 0||i===void 0)continue;let h={value:n};if(this.#c&&this.#v){h.ttl=this.#c[t];let c=R.now()-this.#v[t];h.start=Math.floor(Date.now()-c);}this.#S&&(h.size=this.#S[t]),e.unshift([i,h]);}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=R.now()-r;}this.set(t,i.value,i);}}set(e,t,i={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:d}=i,{noUpdateTTL:g=this.noUpdateTTL}=i,_=this.#R(e,t,i.size||0,c);if(this.maxEntrySize&&_>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),this.#G(e,"set"),this;let m=this.#n===0?void 0:this.#r.get(e);if(m===void 0)m=this.#n===0?this.#s:this.#b.length!==0?this.#b.pop():this.#n===this.#l?this.#N(false):this.#n,this.#i[m]=e,this.#e[m]=t,this.#r.set(e,m),this.#h[this.#s]=m,this.#d[m]=this.#s,this.#s=m,this.#n++,this.#I(m,_,d),d&&(d.set="add"),g=false,this.#M&&this.#A?.(t,e,"add");else {this.#C(m);let y=this.#e[m];if(t!==y){if(this.#H&&this.#t(y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:G}=y;G!==void 0&&!h&&(this.#w&&this.#m?.(G,e,"set"),this.#f&&this.#o?.push([G,e,"set"]));}else h||(this.#w&&this.#m?.(y,e,"set"),this.#f&&this.#o?.push([y,e,"set"]));if(this.#x(m),this.#I(m,_,d),this.#e[m]=t,d){d.set="replace";let G=y&&this.#t(y)?y.__staleWhileFetching:y;G!==void 0&&(d.oldValue=G);}}else d&&(d.set="update");this.#M&&this.onInsert?.(t,e,t===y?"update":"replace");}if(r!==0&&!this.#c&&this.#L(),this.#c&&(g||this.#k(m,r,n),d&&this.#D(d,m)),!h&&this.#f&&this.#o){let y=this.#o,G;for(;G=y?.shift();)this.#y?.(...G);}return this}pop(){try{for(;this.#n;){let e=this.#e[this.#a];if(this.#N(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#f&&this.#o){let e=this.#o,t;for(;t=e?.shift();)this.#y?.(...t);}}}#N(e){let t=this.#a,i=this.#i[t],r=this.#e[t];return this.#H&&this.#t(r)?r.__abortController.abort(new Error("evicted")):(this.#w||this.#f)&&(this.#w&&this.#m?.(r,i,"evict"),this.#f&&this.#o?.push([r,i,"evict"])),this.#x(t),e&&(this.#i[t]=void 0,this.#e[t]=void 0,this.#b.push(t)),this.#n===1?(this.#a=this.#s=0,this.#b.length=0):this.#a=this.#h[t],this.#r.delete(i),this.#n--,t}has(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=t,n=this.#r.get(e);if(n!==void 0){let h=this.#e[n];if(this.#t(h)&&h.__staleWhileFetching===void 0)return false;if(this.#p(n))r&&(r.has="stale",this.#D(r,n));else return i&&this.#O(n),r&&(r.has="hit",this.#D(r,n)),true}else r&&(r.has="miss");return false}peek(e,t={}){let{allowStale:i=this.allowStale}=t,r=this.#r.get(e);if(r===void 0||!i&&this.#p(r))return;let n=this.#e[r];return this.#t(n)?n.__staleWhileFetching:n}#F(e,t,i,r){let n=t===void 0?void 0:this.#e[t];if(this.#t(n))return n;let h=new K,{signal:c}=i;c?.addEventListener("abort",()=>h.abort(c.reason),{signal:h.signal});let d={signal:h.signal,options:i,context:r},g=(E,T=false)=>{let{aborted:v}=h.signal,H=i.ignoreFetchAbort&&E!==void 0;if(i.status&&(v&&!T?(i.status.fetchAborted=true,i.status.fetchError=h.signal.reason,H&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),v&&!H&&!T)return m(h.signal.reason);let C=G;return this.#e[t]===G&&(E===void 0?C.__staleWhileFetching?this.#e[t]=C.__staleWhileFetching:this.#G(e,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(e,E,d.options))),E},_=E=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=E),m(E)),m=E=>{let{aborted:T}=h.signal,v=T&&i.allowStaleOnFetchAbort,H=v||i.allowStaleOnFetchRejection,C=H||i.noDeleteOnFetchRejection,A=G;if(this.#e[t]===G&&(!C||A.__staleWhileFetching===void 0?this.#G(e,"fetch"):v||(this.#e[t]=A.__staleWhileFetching)),H)return i.status&&A.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw E},y=(E,T)=>{let v=this.#T?.(e,n,d);v&&v instanceof Promise&&v.then(H=>E(H===void 0?void 0:H),T),h.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(E(void 0),i.allowStaleOnFetchAbort&&(E=H=>g(H,true)));});};i.status&&(i.status.fetchDispatched=true);let G=new Promise(y).then(g,_),N=Object.assign(G,{__abortController:h,__staleWhileFetching:n,__returned:void 0});return t===void 0?(this.set(e,N,{...d.options,status:void 0}),t=this.#r.get(e)):this.#e[t]=N,N}#t(e){if(!this.#H)return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof K}async fetch(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:d=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:_=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:N=this.allowStaleOnFetchAbort,context:E,forceRefresh:T=false,status:v,signal:H}=t;if(!this.#H)return v&&(v.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:v});let C={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:h,noDisposeOnSet:c,size:d,sizeCalculation:g,noUpdateTTL:_,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:N,ignoreFetchAbort:G,status:v,signal:H},A=this.#r.get(e);if(A===void 0){v&&(v.fetch="miss");let x=this.#F(e,A,C,E);return x.__returned=x}else {let x=this.#e[A];if(this.#t(x)){let u=i&&x.__staleWhileFetching!==void 0;return v&&(v.fetch="inflight",u&&(v.returnedStale=true)),u?x.__staleWhileFetching:x.__returned=x}let o=this.#p(A);if(!T&&!o)return v&&(v.fetch="hit"),this.#C(A),r&&this.#O(A),v&&this.#D(v,A),x;let a=this.#F(e,A,C,E),f=a.__staleWhileFetching!==void 0&&i;return v&&(v.fetch=o?"stale":"refresh",f&&o&&(v.returnedStale=true)),f?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let i=await this.fetch(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let i=this.#z;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...h}=t,c=this.get(e,h);if(!n&&c!==void 0)return c;let d=i(e,c,{options:h,context:r});return this.set(e,d,h),d}get(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:h}=t,c=this.#r.get(e);if(c!==void 0){let d=this.#e[c],g=this.#t(d);return h&&this.#D(h,c),this.#p(c)?(h&&(h.get="stale"),g?(h&&i&&d.__staleWhileFetching!==void 0&&(h.returnedStale=true),i?d.__staleWhileFetching:void 0):(n||this.#G(e,"expire"),h&&i&&(h.returnedStale=true),i?d:void 0)):(h&&(h.get="hit"),g?d.__staleWhileFetching:(this.#C(c),r&&this.#O(c),d))}else h&&(h.get="miss");}#P(e,t){this.#d[t]=e,this.#h[e]=t;}#C(e){e!==this.#s&&(e===this.#a?this.#a=this.#h[e]:this.#P(this.#d[e],this.#h[e]),this.#P(this.#s,e),this.#s=e);}delete(e){return this.#G(e,"delete")}#G(e,t){let i=false;if(this.#n!==0){let r=this.#r.get(e);if(r!==void 0)if(i=true,this.#n===1)this.#j(t);else {this.#x(r);let n=this.#e[r];if(this.#t(n)?n.__abortController.abort(new Error("deleted")):(this.#w||this.#f)&&(this.#w&&this.#m?.(n,e,t),this.#f&&this.#o?.push([n,e,t])),this.#r.delete(e),this.#i[r]=void 0,this.#e[r]=void 0,r===this.#s)this.#s=this.#d[r];else if(r===this.#a)this.#a=this.#h[r];else {let h=this.#d[r];this.#h[h]=this.#h[r];let c=this.#h[r];this.#d[c]=this.#d[r];}this.#n--,this.#b.push(r);}}if(this.#f&&this.#o?.length){let r=this.#o,n;for(;n=r?.shift();)this.#y?.(...n);}return i}clear(){return this.#j("delete")}#j(e){for(let t of this.#E({allowStale:true})){let i=this.#e[t];if(this.#t(i))i.__abortController.abort(new Error("deleted"));else {let r=this.#i[t];this.#w&&this.#m?.(i,r,e),this.#f&&this.#o?.push([i,r,e]);}}if(this.#r.clear(),this.#e.fill(void 0),this.#i.fill(void 0),this.#c&&this.#v&&(this.#c.fill(0),this.#v.fill(0)),this.#S&&this.#S.fill(0),this.#a=0,this.#s=0,this.#b.length=0,this.#g=0,this.#n=0,this.#f&&this.#o){let t=this.#o,i;for(;i=t?.shift();)this.#y?.(...i);}}};var L=class{cache;map=new Map;constructor(e){this.cache=new B({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}get entries(){return this.map.entries}keys(){return this.map.keys()}get values(){return this.map.values}};var p=class l{static _diffHistory=new L({cacheSize:5});static _stepsInfoHistory=new L({cacheSize:5});static _narrationHistory=new L({cacheSize:50});static stepLimitSaved=20;static goBackRunning=false;static _originalStepData=void 0;static get originalStepData(){return l._originalStepData?I(l._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){l._originalStepData=I(e);}};var W=class{get stepsInfoMap(){return p._stepsInfoHistory}get diffMap(){return p._diffHistory}get narrationMap(){return p._narrationHistory}get size(){return p._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return p._stepsInfoHistory.keys()}get(e){let t=p._narrationHistory.get(e);if(!(t&&Object.keys(t).length===1&&t.stepIndex!==void 0))return t}delete(e){p._stepsInfoHistory.delete(e),p._diffHistory.delete(e),p._narrationHistory.delete(e);}internalRestoreOldGameState(e,t){if(e<=0||this.size==0)return t;let i=this.lastKey;if(typeof i!="number")return S.error("You can't go back, there is no step to go back"),t;let r=p._diffHistory.get(i);if(r)try{let n=oe(t,r);return M.stepCounter=i,this.delete(i),this.internalRestoreOldGameState(e-1,n)}catch(n){return S.error("Error applying diff",n),t}else return S.error("You can't go back, there is no step to go back"),t}async goBack(e,t=1){if(t<=0){S.warn("The parameter steps must be greater than 0");return}if(p._diffHistory.size<1){S.warn("You can't go back, there is no step to go back");return}if(p.goBackRunning){S.warn("Go back is already running");return}p.goBackRunning=true;try{let i=I(this.internalRestoreOldGameState(t,p.originalStepData));if(i){await M.restoreGameStepState(i,e);let r=M.stepCounter-1,n=p._narrationHistory.get(r);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let h=p._stepsInfoHistory.get(r);if(h){let c=this.itemMapper({step:h});p._narrationHistory.set(h.index,c);}}}else S.error("Error going back");p.goBackRunning=!1;}catch(i){S.error("Error going back",i),p.goBackRunning=false;}}add(e,t={}){let i=p.originalStepData,{ignoreSameStep:r}=t,n=M.currentGameStepState;if(!r&&this.isSameStep(i,n))return;let h=this.lastKey;(async()=>{try{let d,g;if(typeof h=="number"&&(d=p._stepsInfoHistory.get(h),g=p._narrationHistory.get(h)),p._stepsInfoHistory.set(e.index,e),e.index!==0){let y=(0,ue.diff)(i,n);y?p._diffHistory.set(e.index,y):S.warn("It was not possible to create the difference between the two steps");}let _={},m=this.itemMapper({step:e},_);if(p._narrationHistory.set(e.index,m),d&&g&&typeof h=="number"){let y=this.itemMapper({..._,step:d},{});p._narrationHistory.set(h,y);}}catch(d){S.error("Error adding history step",d);}})(),p.originalStepData=n;}itemMapper(e,t){let{step:i,choiceIndexMade:r,inputValue:n,removeDialogue:h}=e,c=i.dialogue||i.dialoge;t&&i.isGlued&&(t.removeDialogue=true),h&&(c=void 0);let d=i.choices;if(t&&i.currentLabel&&i.choiceIndexMade!==void 0&&(t.choiceIndexMade=i.choiceIndexMade),i.inputValue&&t&&(t.inputValue=i.inputValue),c||d||n){let g=d?.map((_,m)=>{let y=false;return _.oneTime&&i.alreadyMadeChoices&&i.alreadyMadeChoices.includes(m)&&(y=true),{text:_.text,type:_.type,isResponse:false,hidden:y}});if(g){if(g.every(_=>_.hidden)){let _=g.find(m=>m.hidden===false);_&&(_.hidden=false);}r!==void 0&&(g[r].isResponse=true);}return {dialogue:c?{...c,character:c.character?M.getCharacter(c.character)||c.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:g,stepIndex:i.index,inputValue:n}}return {stepIndex:i.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((i,r)=>i-r).forEach(i=>{let r=this.get(i);r&&e.push(r);}),e}get currentLabelHistory(){let e=[],t=Array.from(this.keys()).sort((d,g)=>g-d);if(t.length===0)return e;let i=t[0];if(typeof i!="number")return e;let r=p._stepsInfoHistory.get(i);if(!r)return e;let n=r.openedLabels;if(!n||!Array.isArray(n)||n.length===0)return e;let h=n[0].currentStepIndex,c=n[0].label;return t.every((d,g)=>{let _=this.get(d);if(_){if(g===0)return e.push(_),true;let m=p._stepsInfoHistory.get(d);if(!m)return true;let y=m.openedLabels;if(!y||!Array.isArray(y)||y.length===0||y[0].label!==c||y[0].currentStepIndex>=h)return false;h=y[0].currentStepIndex,e.push(_);}return true}),e.reverse()}removeNarrativeHistory(e){if(e){let t=Array.from(this.keys()).sort((i,r)=>i-r);t=t.slice(0,e),t.forEach(i=>{p._narrationHistory.delete(i),p._stepsInfoHistory.delete(i),p._diffHistory.delete(i);});}else p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:p._diffHistory.has(e)}blockGoBack(){M.currentStepsRunningNumber===0&&p._diffHistory.clear();}isSameStep(e,t){if(e.openedLabels.length===t.openedLabels.length)try{let i=JSON.stringify(e.openedLabels),r=JSON.stringify(t.openedLabels);if(i===r&&e.path===t.path&&e.labelIndex===t.labelIndex)return !0}catch(i){return S.error("Error comparing opened labels",i),true}return false}clear(){p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear(),p._originalStepData=void 0;}get stepLimitSaved(){return p.stepLimitSaved}set stepLimitSaved(e){p.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((i,r)=>i-r);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let t=[];return e.forEach(i=>{let r=p._stepsInfoHistory.get(i);if(r){let n=p._diffHistory.get(i);t.push({...r,diff:n});}}),{stepsHistory:I(t),originalStepData:I(p._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((i,r)=>i-r),t={};e.forEach(i=>{let r=p._stepsInfoHistory.get(i);if(r){let n={...t};t={};let h=this.itemMapper({step:r,choiceIndexMade:n.choiceIndexMade,inputValue:n.inputValue,removeDialogue:n.removeDialogue},t);h&&p._narrationHistory.set(i,h);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(i=>{i.diff&&p._diffHistory.set(i.index,i.diff);let r={...i,diff:void 0};p._stepsInfoHistory.set(i.index,r);}),this.restoreNarrativeHistory()):S.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?p._originalStepData=e.originalStepData:S.warn("Could not import originalStepData data, so will be ignored");}catch(t){S.error("Error importing data",t);}}};var Ze=new W;
|
|
2
|
-
exports.HistoryManagerStatic=
|
|
1
|
+
'use strict';var St=Object.create;var Ue=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var ot=f=>{throw TypeError(f)};var Dt=(f,e,t)=>e in f?Ue(f,e,{enumerable:true,configurable:true,writable:true,value:t}):f[e]=t;var At=(f,e)=>()=>(e||f((e={exports:{}}).exports,e),e.exports);var Ht=(f,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wt(e))!_t.call(f,n)&&n!==t&&Ue(f,n,{get:()=>e[n],enumerable:!(r=vt(e,n))||r.enumerable});return f};var Ot=(f,e,t)=>(t=f!=null?St(Et(f)):{},Ht(Ue(t,"default",{value:f,enumerable:true}),f));var S=(f,e,t)=>Dt(f,typeof e!="symbol"?e+"":e,t),Ye=(f,e,t)=>e.has(f)||ot("Cannot "+t);var i=(f,e,t)=>(Ye(f,e,"read from private field"),t?t.call(f):e.get(f)),O=(f,e,t)=>e.has(f)?ot("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,t),b=(f,e,t,r)=>(Ye(f,e,"write to private field"),e.set(f,t),t),c=(f,e,t)=>(Ye(f,e,"access private method"),t);var Re=(f,e,t,r)=>({set _(n){b(f,e,n);},get _(){return i(f,e,r)}});var lt=At((Je,at)=>{(function(f,e){var t=e(f);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return t});else if(typeof Je=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))at.exports=t;else {var r=f.DeepDiff;t.noConflict=function(){return f.DeepDiff===t&&(f.DeepDiff=r),t},f.DeepDiff=t;}})(Je,function(f){var e=["N","E","A","D"];function t(l,h){l.super_=h,l.prototype=Object.create(h.prototype,{constructor:{value:l,enumerable:false,writable:true,configurable:true}});}function r(l,h){Object.defineProperty(this,"kind",{value:l,enumerable:true}),h&&h.length&&Object.defineProperty(this,"path",{value:h,enumerable:true});}function n(l,h,o){n.super_.call(this,"E",l),Object.defineProperty(this,"lhs",{value:h,enumerable:true}),Object.defineProperty(this,"rhs",{value:o,enumerable:true});}t(n,r);function s(l,h){s.super_.call(this,"N",l),Object.defineProperty(this,"rhs",{value:h,enumerable:true});}t(s,r);function a(l,h){a.super_.call(this,"D",l),Object.defineProperty(this,"lhs",{value:h,enumerable:true});}t(a,r);function m(l,h,o){m.super_.call(this,"A",l),Object.defineProperty(this,"index",{value:h,enumerable:true}),Object.defineProperty(this,"item",{value:o,enumerable:true});}t(m,r);function p(l,h,o){var d=l.slice((h)+1||l.length);return l.length=h<0?l.length+h:h,l.push.apply(l,d),l}function D(l){var h=typeof l;return h!=="object"?h:l===Math?"math":l===null?"null":Array.isArray(l)?"array":Object.prototype.toString.call(l)==="[object Date]"?"date":typeof l.toString=="function"&&/^\/.*\//.test(l.toString())?"regexp":"object"}function C(l){var h=0;if(l.length===0)return h;for(var o=0;o<l.length;o++){var d=l.charCodeAt(o);h=(h<<5)-h+d,h=h&h;}return h}function _(l){var h=0,o=D(l);if(o==="array"){l.forEach(function(Se){h+=_(Se);});var d="[type: array, hash: "+h+"]";return h+C(d)}if(o==="object"){for(var y in l)if(l.hasOwnProperty(y)){var x="[ type: object, key: "+y+", value hash: "+_(l[y])+"]";h+=C(x);}return h}var H="[ type: "+o+" ; value: "+l+"]";return h+C(H)}function G(l,h,o,d,y,x,H,Se){o=o||[],y=y||[],H=H||[];var K=y.slice(0);if(typeof x<"u"&&x!==null){if(d){if(typeof d=="function"&&d(K,x))return;if(typeof d=="object"){if(d.prefilter&&d.prefilter(K,x))return;if(d.normalize){var We=d.normalize(K,x,l,h);We&&(l=We[0],h=We[1]);}}}K.push(x);}D(l)==="regexp"&&D(h)==="regexp"&&(l=l.toString(),h=h.toString());var Ke=typeof l,bt=typeof h,N,Te,ee,ze,rt=Ke!=="undefined"||H&&H.length>0&&H[H.length-1].lhs&&Object.getOwnPropertyDescriptor(H[H.length-1].lhs,x),nt=bt!=="undefined"||H&&H.length>0&&H[H.length-1].rhs&&Object.getOwnPropertyDescriptor(H[H.length-1].rhs,x);if(!rt&&nt)o.push(new s(K,h));else if(!nt&&rt)o.push(new a(K,l));else if(D(l)!==D(h))o.push(new n(K,l,h));else if(D(l)==="date"&&l-h!==0)o.push(new n(K,l,h));else if(Ke==="object"&&l!==null&&h!==null){for(N=H.length-1;N>-1;--N)if(H[N].lhs===l){ze=true;break}if(ze)l!==h&&o.push(new n(K,l,h));else {if(H.push({lhs:l,rhs:h}),Array.isArray(l)){for(Se&&(l.sort(function(Be,$e){return _(Be)-_($e)}),h.sort(function(Be,$e){return _(Be)-_($e)})),N=h.length-1,Te=l.length-1;N>Te;)o.push(new m(K,N,new s(void 0,h[N--])));for(;Te>N;)o.push(new m(K,Te,new a(void 0,l[Te--])));for(;N>=0;--N)G(l[N],h[N],o,d,K,N,H,Se);}else {var st=Object.keys(l),Le=Object.keys(h);for(N=0;N<st.length;++N)ee=st[N],ze=Le.indexOf(ee),ze>=0?(G(l[ee],h[ee],o,d,K,ee,H,Se),Le[ze]=null):G(l[ee],void 0,o,d,K,ee,H,Se);for(N=0;N<Le.length;++N)ee=Le[N],ee&&G(void 0,h[ee],o,d,K,ee,H,Se);}H.length=H.length-1;}}else l!==h&&(Ke==="number"&&isNaN(l)&&isNaN(h)||o.push(new n(K,l,h)));}function j(l,h,o,d,y){var x=[];if(G(l,h,x,d,null,null,null,y),o)for(var H=0;H<x.length;++H)o(x[H]);return x}function Z(l,h,o,d,y,x,H){return G(l,h,o,d,y,x,H,true)}function T(l,h,o,d){var y=d?function(H){H&&d.push(H);}:void 0,x=j(l,h,y,o);return d||(x.length?x:void 0)}function z(l,h,o,d){var y=d?function(H){H&&d.push(H);}:void 0,x=j(l,h,y,o,true);return d||(x.length?x:void 0)}function w(l,h,o){if(o.path&&o.path.length){var d=l[h],y,x=o.path.length-1;for(y=0;y<x;y++)d=d[o.path[y]];switch(o.kind){case "A":w(d[o.path[y]],o.index,o.item);break;case "D":delete d[o.path[y]];break;case "E":case "N":d[o.path[y]]=o.rhs;break}}else switch(o.kind){case "A":w(l[h],o.index,o.item);break;case "D":l=p(l,h);break;case "E":case "N":l[h]=o.rhs;break}return l}function W(l,h,o){if(typeof o>"u"&&h&&~e.indexOf(h.kind)&&(o=h),l&&o&&o.kind){for(var d=l,y=-1,x=o.path?o.path.length-1:0;++y<x;)typeof d[o.path[y]]>"u"&&(d[o.path[y]]=typeof o.path[y+1]<"u"&&typeof o.path[y+1]=="number"?[]:{}),d=d[o.path[y]];switch(o.kind){case "A":o.path&&typeof d[o.path[y]]>"u"&&(d[o.path[y]]=[]),w(o.path?d[o.path[y]]:d,o.index,o.item);break;case "D":delete d[o.path[y]];break;case "E":case "N":d[o.path[y]]=o.rhs;break}}}function k(l,h,o){if(o.path&&o.path.length){var d=l[h],y,x=o.path.length-1;for(y=0;y<x;y++)d=d[o.path[y]];switch(o.kind){case "A":k(d[o.path[y]],o.index,o.item);break;case "D":d[o.path[y]]=o.lhs;break;case "E":d[o.path[y]]=o.lhs;break;case "N":delete d[o.path[y]];break}}else switch(o.kind){case "A":k(l[h],o.index,o.item);break;case "D":l[h]=o.lhs;break;case "E":l[h]=o.lhs;break;case "N":l=p(l,h);break}return l}function L(l,h,o){if(l&&h&&o&&o.kind){var d=l,y,x;for(x=o.path.length-1,y=0;y<x;y++)typeof d[o.path[y]]>"u"&&(d[o.path[y]]={}),d=d[o.path[y]];switch(o.kind){case "A":k(d[o.path[y]],o.index,o.item);break;case "D":d[o.path[y]]=o.lhs;break;case "E":d[o.path[y]]=o.lhs;break;case "N":delete d[o.path[y]];break}}}function Y(l,h,o){if(l&&h){var d=function(y){(!o||o(l,h,y))&&W(l,h,y);};j(l,h,d);}}return Object.defineProperties(T,{diff:{value:T,enumerable:true},orderIndependentDiff:{value:z,enumerable:true},observableDiff:{value:j,enumerable:true},orderIndependentObservableDiff:{value:Z,enumerable:true},orderIndepHash:{value:_,enumerable:true},applyDiff:{value:Y,enumerable:true},applyChange:{value:W,enumerable:true},revertChange:{value:L,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),T.DeepDiff=T,f&&(f.DeepDiff=T),T});});var gt=Ot(lt());var A;(n=>(n.log=(s,...a)=>console.log(`[Pixi\u2019VN] ${s}`,...a),n.warn=(s,...a)=>console.warn(`[Pixi\u2019VN] ${s}`,...a),n.error=(s,...a)=>console.error(`[Pixi\u2019VN] ${s}`,...a),n.info=(s,...a)=>console.info(`[Pixi\u2019VN] ${s}`,...a)))(A||(A={}));var v=class v{static init(e){v._getStepCounter=e.getStepCounter,v._setStepCounter=e.setStepCounter,v._getCurrentGameStepState=e.getCurrentGameStepState,v._restoreGameStepState=e.restoreGameStepState,v._getOpenedLabels=e.getOpenedLabels,e.onGoNextEnd&&(v._onGoNextEnd=e.onGoNextEnd),v._getVariable=e.getVariable,v._setVariable=e.setVariable,v._removeVariable=e.removeVariable,v._getFlag=e.getFlag,v._setFlag=e.setFlag,e.onLabelClosing&&(v._onLabelClosing=e.onLabelClosing),v._addHistoryItem=e.addHistoryItem,v._getCurrentStepsRunningNumber=e.getCurrentStepsRunningNumber,v._getCharacter=e.getCharacter;}static get stepCounter(){return v._getStepCounter()}static set stepCounter(e){v._setStepCounter(e);}static get currentGameStepState(){return v._getCurrentGameStepState()}static get restoreGameStepState(){return v._restoreGameStepState}static get openedLabels(){return v._getOpenedLabels()}static get onGoNextEnd(){return v._onGoNextEnd}static get getVariable(){return v._getVariable}static get setVariable(){return v._setVariable}static get removeVariable(){return v._removeVariable}static get getFlag(){return v._getFlag}static get setFlag(){return v._setFlag}static get onLabelClosing(){return v._onLabelClosing}static get addHistoryItem(){return v._addHistoryItem}static get currentStepsRunningNumber(){return v._getCurrentStepsRunningNumber()}static get getCharacter(){return v._getCharacter}};S(v,"_getStepCounter",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_setStepCounter",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getCurrentGameStepState",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_restoreGameStepState",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getOpenedLabels",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_onGoNextEnd",async()=>{}),S(v,"_getVariable",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_setVariable",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_removeVariable",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getFlag",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_setFlag",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_onLabelClosing",()=>{}),S(v,"_addHistoryItem",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getCurrentStepsRunningNumber",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),S(v,"_getCharacter",()=>{throw A.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")}),S(v,"onEnd"),S(v,"onError");var fe=v;function ue(f){try{if(typeof f>"u")return f;let e=JSON.stringify(f);return JSON.parse(e)}catch(e){throw A.error("Error creating exportable element",f,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function ht(f,e){let t=ue(f);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(r=>{"type"in r?xt(t,r):Ct(t,r);}),t}function xt(f,e){let t=f;e.path&&e.path.length>0?e.path.forEach((r,n)=>{if(e.path&&n===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":t[r]=e.oldValue;break;case "CREATE":Array.isArray(t)&&typeof r=="number"?t.splice(r,1):delete t[r];break}else t=t[r];}):A.warn("No path found, skipping diff",e);}function Ct(f,e){let t=f;e.path&&e.path.length>0?e.path.forEach((r,n)=>{if(e.path&&n===e.path.length-1){if(e.kind==="E"||e.kind==="D")t[r]=e.lhs;else if(e.kind==="N")Number.isInteger(r)?Array.isArray(t)&&t.splice(r,1):typeof r=="string"&&delete t[r];else if(e.kind==="A"){let s=e.index;e.item.kind==="N"?t[r].splice(s,1):e.item.kind==="E"||e.item.kind==="D"?t[r][s]=e.item.lhs:e.item.kind==="A"?A.warn("Nested array found, skipping diff",e):A.warn("No array found, skipping diff",e);}}else t=t[r];}):A.warn("No path found, skipping diff",e);}var De=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ct=new Set,qe=typeof process=="object"&&process?process:{},pt=(f,e,t,r)=>{typeof qe.emitWarning=="function"?qe.emitWarning(f,e,t,r):console.error(`[${t}] ${e}: ${f}`);},Pe=globalThis.AbortController,ft=globalThis.AbortSignal;if(typeof Pe>"u"){ft=class{constructor(){S(this,"onabort");S(this,"_onabort",[]);S(this,"reason");S(this,"aborted",false);}addEventListener(r,n){this._onabort.push(n);}},Pe=class{constructor(){S(this,"signal",new ft);e();}abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=true;for(let n of this.signal._onabort)n(r);this.signal.onabort?.(r);}}};let f=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,pt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var Gt=f=>!ct.has(f),ce=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),mt=f=>ce(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ae:null:null,Ae=class extends Array{constructor(e){super(e),this.fill(0);}},He,ve=class ve{constructor(e,t){S(this,"heap");S(this,"length");if(!i(ve,He))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=mt(e);if(!t)return [];b(ve,He,true);let r=new ve(e,t);return b(ve,He,false),r}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};He=new WeakMap,O(ve,He,false);var Xe=ve,ut,dt,te,J,ie,we,re,Oe,xe,R,ne,F,M,E,$,q,B,V,se,P,oe,ae,X,le,ge,U,Ce,u,Qe,Ee,de,Me,Q,yt,_e,Ge,Ne,pe,me,Ze,ke,Ve,I,et,Ie,ye,tt,it=class it{constructor(e){O(this,u);O(this,te);O(this,J);O(this,ie);O(this,we);O(this,re);O(this,Oe);O(this,xe);S(this,"ttl");S(this,"ttlResolution");S(this,"ttlAutopurge");S(this,"updateAgeOnGet");S(this,"updateAgeOnHas");S(this,"allowStale");S(this,"noDisposeOnSet");S(this,"noUpdateTTL");S(this,"maxEntrySize");S(this,"sizeCalculation");S(this,"noDeleteOnFetchRejection");S(this,"noDeleteOnStaleGet");S(this,"allowStaleOnFetchAbort");S(this,"allowStaleOnFetchRejection");S(this,"ignoreFetchAbort");O(this,R);O(this,ne);O(this,F);O(this,M);O(this,E);O(this,$);O(this,q);O(this,B);O(this,V);O(this,se);O(this,P);O(this,oe);O(this,ae);O(this,X);O(this,le);O(this,ge);O(this,U);O(this,Ce);O(this,Ee,()=>{});O(this,de,()=>{});O(this,Me,()=>{});O(this,Q,()=>false);O(this,_e,e=>{});O(this,Ge,(e,t,r)=>{});O(this,Ne,(e,t,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});S(this,ut,"LRUCache");let{max:t=0,ttl:r,ttlResolution:n=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:m,allowStale:p,dispose:D,onInsert:C,disposeAfter:_,noDisposeOnSet:G,noUpdateTTL:j,maxSize:Z=0,maxEntrySize:T=0,sizeCalculation:z,fetchMethod:w,memoMethod:W,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:Y,allowStaleOnFetchAbort:l,ignoreFetchAbort:h}=e;if(t!==0&&!ce(t))throw new TypeError("max option must be a nonnegative integer");let o=t?mt(t):Array;if(!o)throw new Error("invalid max value: "+t);if(b(this,te,t),b(this,J,Z),this.maxEntrySize=T||i(this,J),this.sizeCalculation=z,this.sizeCalculation){if(!i(this,J)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(W!==void 0&&typeof W!="function")throw new TypeError("memoMethod must be a function if defined");if(b(this,xe,W),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(b(this,Oe,w),b(this,ge,!!w),b(this,F,new Map),b(this,M,new Array(t).fill(void 0)),b(this,E,new Array(t).fill(void 0)),b(this,$,new o(t)),b(this,q,new o(t)),b(this,B,0),b(this,V,0),b(this,se,Xe.create(t)),b(this,R,0),b(this,ne,0),typeof D=="function"&&b(this,ie,D),typeof C=="function"&&b(this,we,C),typeof _=="function"?(b(this,re,_),b(this,P,[])):(b(this,re,void 0),b(this,P,void 0)),b(this,le,!!i(this,ie)),b(this,Ce,!!i(this,we)),b(this,U,!!i(this,re)),this.noDisposeOnSet=!!G,this.noUpdateTTL=!!j,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!Y,this.allowStaleOnFetchAbort=!!l,this.ignoreFetchAbort=!!h,this.maxEntrySize!==0){if(i(this,J)!==0&&!ce(i(this,J)))throw new TypeError("maxSize must be a positive integer if specified");if(!ce(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,u,yt).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!m,this.ttlResolution=ce(n)||n===0?n:1,this.ttlAutopurge=!!s,this.ttl=r||0,this.ttl){if(!ce(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,u,Qe).call(this);}if(i(this,te)===0&&this.ttl===0&&i(this,J)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,te)&&!i(this,J)){let d="LRU_CACHE_UNBOUNDED";Gt(d)&&(ct.add(d),pt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",d,it));}}static unsafeExposeInternals(e){return {starts:i(e,ae),ttls:i(e,X),sizes:i(e,oe),keyMap:i(e,F),keyList:i(e,M),valList:i(e,E),next:i(e,$),prev:i(e,q),get head(){return i(e,B)},get tail(){return i(e,V)},free:i(e,se),isBackgroundFetch:t=>{var r;return c(r=e,u,I).call(r,t)},backgroundFetch:(t,r,n,s)=>{var a;return c(a=e,u,Ve).call(a,t,r,n,s)},moveToTail:t=>{var r;return c(r=e,u,Ie).call(r,t)},indexes:t=>{var r;return c(r=e,u,pe).call(r,t)},rindexes:t=>{var r;return c(r=e,u,me).call(r,t)},isStale:t=>{var r;return i(r=e,Q).call(r,t)}}}get max(){return i(this,te)}get maxSize(){return i(this,J)}get calculatedSize(){return i(this,ne)}get size(){return i(this,R)}get fetchMethod(){return i(this,Oe)}get memoMethod(){return i(this,xe)}get dispose(){return i(this,ie)}get onInsert(){return i(this,we)}get disposeAfter(){return i(this,re)}getRemainingTTL(e){return i(this,F).has(e)?1/0:0}*entries(){for(let e of c(this,u,pe).call(this))i(this,E)[e]!==void 0&&i(this,M)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield [i(this,M)[e],i(this,E)[e]]);}*rentries(){for(let e of c(this,u,me).call(this))i(this,E)[e]!==void 0&&i(this,M)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield [i(this,M)[e],i(this,E)[e]]);}*keys(){for(let e of c(this,u,pe).call(this)){let t=i(this,M)[e];t!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield t);}}*rkeys(){for(let e of c(this,u,me).call(this)){let t=i(this,M)[e];t!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield t);}}*values(){for(let e of c(this,u,pe).call(this))i(this,E)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield i(this,E)[e]);}*rvalues(){for(let e of c(this,u,me).call(this))i(this,E)[e]!==void 0&&!c(this,u,I).call(this,i(this,E)[e])&&(yield i(this,E)[e]);}[(dt=Symbol.iterator,ut=Symbol.toStringTag,dt)](){return this.entries()}find(e,t={}){for(let r of c(this,u,pe).call(this)){let n=i(this,E)[r],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;if(s!==void 0&&e(s,i(this,M)[r],this))return this.get(i(this,M)[r],t)}}forEach(e,t=this){for(let r of c(this,u,pe).call(this)){let n=i(this,E)[r],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,i(this,M)[r],this);}}rforEach(e,t=this){for(let r of c(this,u,me).call(this)){let n=i(this,E)[r],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,i(this,M)[r],this);}}purgeStale(){let e=false;for(let t of c(this,u,me).call(this,{allowStale:true}))i(this,Q).call(this,t)&&(c(this,u,ye).call(this,i(this,M)[t],"expire"),e=true);return e}info(e){let t=i(this,F).get(e);if(t===void 0)return;let r=i(this,E)[t],n=c(this,u,I).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let s={value:n};if(i(this,X)&&i(this,ae)){let a=i(this,X)[t],m=i(this,ae)[t];if(a&&m){let p=a-(De.now()-m);s.ttl=p,s.start=Date.now();}}return i(this,oe)&&(s.size=i(this,oe)[t]),s}dump(){let e=[];for(let t of c(this,u,pe).call(this,{allowStale:true})){let r=i(this,M)[t],n=i(this,E)[t],s=c(this,u,I).call(this,n)?n.__staleWhileFetching:n;if(s===void 0||r===void 0)continue;let a={value:s};if(i(this,X)&&i(this,ae)){a.ttl=i(this,X)[t];let m=De.now()-i(this,ae)[t];a.start=Math.floor(Date.now()-m);}i(this,oe)&&(a.size=i(this,oe)[t]),e.unshift([r,a]);}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let n=Date.now()-r.start;r.start=De.now()-n;}this.set(t,r.value,r);}}set(e,t,r={}){var G,j,Z,T;if(t===void 0)return this.delete(e),this;let{ttl:n=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:m=this.sizeCalculation,status:p}=r,{noUpdateTTL:D=this.noUpdateTTL}=r,C=i(this,Ne).call(this,e,t,r.size||0,m);if(this.maxEntrySize&&C>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),c(this,u,ye).call(this,e,"set"),this;let _=i(this,R)===0?void 0:i(this,F).get(e);if(_===void 0)_=i(this,R)===0?i(this,V):i(this,se).length!==0?i(this,se).pop():i(this,R)===i(this,te)?c(this,u,ke).call(this,false):i(this,R),i(this,M)[_]=e,i(this,E)[_]=t,i(this,F).set(e,_),i(this,$)[i(this,V)]=_,i(this,q)[_]=i(this,V),b(this,V,_),Re(this,R)._++,i(this,Ge).call(this,_,C,p),p&&(p.set="add"),D=false,i(this,Ce)&&((G=i(this,we))==null||G.call(this,t,e,"add"));else {c(this,u,Ie).call(this,_);let z=i(this,E)[_];if(t!==z){if(i(this,ge)&&c(this,u,I).call(this,z)){z.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=z;w!==void 0&&!a&&(i(this,le)&&((j=i(this,ie))==null||j.call(this,w,e,"set")),i(this,U)&&i(this,P)?.push([w,e,"set"]));}else a||(i(this,le)&&((Z=i(this,ie))==null||Z.call(this,z,e,"set")),i(this,U)&&i(this,P)?.push([z,e,"set"]));if(i(this,_e).call(this,_),i(this,Ge).call(this,_,C,p),i(this,E)[_]=t,p){p.set="replace";let w=z&&c(this,u,I).call(this,z)?z.__staleWhileFetching:z;w!==void 0&&(p.oldValue=w);}}else p&&(p.set="update");i(this,Ce)&&this.onInsert?.(t,e,t===z?"update":"replace");}if(n!==0&&!i(this,X)&&c(this,u,Qe).call(this),i(this,X)&&(D||i(this,Me).call(this,_,n,s),p&&i(this,de).call(this,p,_)),!a&&i(this,U)&&i(this,P)){let z=i(this,P),w;for(;w=z?.shift();)(T=i(this,re))==null||T.call(this,...w);}return this}pop(){var e;try{for(;i(this,R);){let t=i(this,E)[i(this,B)];if(c(this,u,ke).call(this,!0),c(this,u,I).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(i(this,U)&&i(this,P)){let t=i(this,P),r;for(;r=t?.shift();)(e=i(this,re))==null||e.call(this,...r);}}}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=t,s=i(this,F).get(e);if(s!==void 0){let a=i(this,E)[s];if(c(this,u,I).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Q).call(this,s))n&&(n.has="stale",i(this,de).call(this,n,s));else return r&&i(this,Ee).call(this,s),n&&(n.has="hit",i(this,de).call(this,n,s)),true}else n&&(n.has="miss");return false}peek(e,t={}){let{allowStale:r=this.allowStale}=t,n=i(this,F).get(e);if(n===void 0||!r&&i(this,Q).call(this,n))return;let s=i(this,E)[n];return c(this,u,I).call(this,s)?s.__staleWhileFetching:s}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:m=this.noDisposeOnSet,size:p=0,sizeCalculation:D=this.sizeCalculation,noUpdateTTL:C=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:G=this.allowStaleOnFetchRejection,ignoreFetchAbort:j=this.ignoreFetchAbort,allowStaleOnFetchAbort:Z=this.allowStaleOnFetchAbort,context:T,forceRefresh:z=false,status:w,signal:W}=t;if(!i(this,ge))return w&&(w.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:s,status:w});let k={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:m,size:p,sizeCalculation:D,noUpdateTTL:C,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:G,allowStaleOnFetchAbort:Z,ignoreFetchAbort:j,status:w,signal:W},L=i(this,F).get(e);if(L===void 0){w&&(w.fetch="miss");let Y=c(this,u,Ve).call(this,e,L,k,T);return Y.__returned=Y}else {let Y=i(this,E)[L];if(c(this,u,I).call(this,Y)){let y=r&&Y.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",y&&(w.returnedStale=true)),y?Y.__staleWhileFetching:Y.__returned=Y}let l=i(this,Q).call(this,L);if(!z&&!l)return w&&(w.fetch="hit"),c(this,u,Ie).call(this,L),n&&i(this,Ee).call(this,L),w&&i(this,de).call(this,w,L),Y;let h=c(this,u,Ve).call(this,e,L,k,T),d=h.__staleWhileFetching!==void 0&&r;return w&&(w.fetch=l?"stale":"refresh",d&&l&&(w.returnedStale=true)),d?h.__staleWhileFetching:h.__returned=h}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=i(this,xe);if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:s,...a}=t,m=this.get(e,a);if(!s&&m!==void 0)return m;let p=r(e,m,{options:a,context:n});return this.set(e,p,a),p}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,m=i(this,F).get(e);if(m!==void 0){let p=i(this,E)[m],D=c(this,u,I).call(this,p);return a&&i(this,de).call(this,a,m),i(this,Q).call(this,m)?(a&&(a.get="stale"),D?(a&&r&&p.__staleWhileFetching!==void 0&&(a.returnedStale=true),r?p.__staleWhileFetching:void 0):(s||c(this,u,ye).call(this,e,"expire"),a&&r&&(a.returnedStale=true),r?p:void 0)):(a&&(a.get="hit"),D?p.__staleWhileFetching:(c(this,u,Ie).call(this,m),n&&i(this,Ee).call(this,m),p))}else a&&(a.get="miss");}delete(e){return c(this,u,ye).call(this,e,"delete")}clear(){return c(this,u,tt).call(this,"delete")}};te=new WeakMap,J=new WeakMap,ie=new WeakMap,we=new WeakMap,re=new WeakMap,Oe=new WeakMap,xe=new WeakMap,R=new WeakMap,ne=new WeakMap,F=new WeakMap,M=new WeakMap,E=new WeakMap,$=new WeakMap,q=new WeakMap,B=new WeakMap,V=new WeakMap,se=new WeakMap,P=new WeakMap,oe=new WeakMap,ae=new WeakMap,X=new WeakMap,le=new WeakMap,ge=new WeakMap,U=new WeakMap,Ce=new WeakMap,u=new WeakSet,Qe=function(){let e=new Ae(i(this,te)),t=new Ae(i(this,te));b(this,X,e),b(this,ae,t),b(this,Me,(s,a,m=De.now())=>{if(t[s]=a!==0?m:0,e[s]=a,a!==0&&this.ttlAutopurge){let p=setTimeout(()=>{i(this,Q).call(this,s)&&c(this,u,ye).call(this,i(this,M)[s],"expire");},a+1);p.unref&&p.unref();}}),b(this,Ee,s=>{t[s]=e[s]!==0?De.now():0;}),b(this,de,(s,a)=>{if(e[a]){let m=e[a],p=t[a];if(!m||!p)return;s.ttl=m,s.start=p,s.now=r||n();let D=s.now-p;s.remainingTTL=m-D;}});let r=0,n=()=>{let s=De.now();if(this.ttlResolution>0){r=s;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref();}return s};this.getRemainingTTL=s=>{let a=i(this,F).get(s);if(a===void 0)return 0;let m=e[a],p=t[a];if(!m||!p)return 1/0;let D=(r||n())-p;return m-D},b(this,Q,s=>{let a=t[s],m=e[s];return !!m&&!!a&&(r||n())-a>m});},Ee=new WeakMap,de=new WeakMap,Me=new WeakMap,Q=new WeakMap,yt=function(){let e=new Ae(i(this,te));b(this,ne,0),b(this,oe,e),b(this,_e,t=>{b(this,ne,i(this,ne)-e[t]),e[t]=0;}),b(this,Ne,(t,r,n,s)=>{if(c(this,u,I).call(this,r))return 0;if(!ce(n))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(n=s(r,t),!ce(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),b(this,Ge,(t,r,n)=>{if(e[t]=r,i(this,J)){let s=i(this,J)-e[t];for(;i(this,ne)>s;)c(this,u,ke).call(this,true);}b(this,ne,i(this,ne)+e[t]),n&&(n.entrySize=r,n.totalCalculatedSize=i(this,ne));});},_e=new WeakMap,Ge=new WeakMap,Ne=new WeakMap,pe=function*({allowStale:e=this.allowStale}={}){if(i(this,R))for(let t=i(this,V);!(!c(this,u,Ze).call(this,t)||((e||!i(this,Q).call(this,t))&&(yield t),t===i(this,B)));)t=i(this,q)[t];},me=function*({allowStale:e=this.allowStale}={}){if(i(this,R))for(let t=i(this,B);!(!c(this,u,Ze).call(this,t)||((e||!i(this,Q).call(this,t))&&(yield t),t===i(this,V)));)t=i(this,$)[t];},Ze=function(e){return e!==void 0&&i(this,F).get(i(this,M)[e])===e},ke=function(e){var s;let t=i(this,B),r=i(this,M)[t],n=i(this,E)[t];return i(this,ge)&&c(this,u,I).call(this,n)?n.__abortController.abort(new Error("evicted")):(i(this,le)||i(this,U))&&(i(this,le)&&((s=i(this,ie))==null||s.call(this,n,r,"evict")),i(this,U)&&i(this,P)?.push([n,r,"evict"])),i(this,_e).call(this,t),e&&(i(this,M)[t]=void 0,i(this,E)[t]=void 0,i(this,se).push(t)),i(this,R)===1?(b(this,B,b(this,V,0)),i(this,se).length=0):b(this,B,i(this,$)[t]),i(this,F).delete(r),Re(this,R)._--,t},Ve=function(e,t,r,n){let s=t===void 0?void 0:i(this,E)[t];if(c(this,u,I).call(this,s))return s;let a=new Pe,{signal:m}=r;m?.addEventListener("abort",()=>a.abort(m.reason),{signal:a.signal});let p={signal:a.signal,options:r,context:n},D=(T,z=false)=>{let{aborted:w}=a.signal,W=r.ignoreFetchAbort&&T!==void 0;if(r.status&&(w&&!z?(r.status.fetchAborted=true,r.status.fetchError=a.signal.reason,W&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),w&&!W&&!z)return _(a.signal.reason);let k=j;return i(this,E)[t]===j&&(T===void 0?k.__staleWhileFetching?i(this,E)[t]=k.__staleWhileFetching:c(this,u,ye).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(e,T,p.options))),T},C=T=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=T),_(T)),_=T=>{let{aborted:z}=a.signal,w=z&&r.allowStaleOnFetchAbort,W=w||r.allowStaleOnFetchRejection,k=W||r.noDeleteOnFetchRejection,L=j;if(i(this,E)[t]===j&&(!k||L.__staleWhileFetching===void 0?c(this,u,ye).call(this,e,"fetch"):w||(i(this,E)[t]=L.__staleWhileFetching)),W)return r.status&&L.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),L.__staleWhileFetching;if(L.__returned===L)throw T},G=(T,z)=>{var W;let w=(W=i(this,Oe))==null?void 0:W.call(this,e,s,p);w&&w instanceof Promise&&w.then(k=>T(k===void 0?void 0:k),z),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(T(void 0),r.allowStaleOnFetchAbort&&(T=k=>D(k,true)));});};r.status&&(r.status.fetchDispatched=true);let j=new Promise(G).then(D,C),Z=Object.assign(j,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,Z,{...p.options,status:void 0}),t=i(this,F).get(e)):i(this,E)[t]=Z,Z},I=function(e){if(!i(this,ge))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Pe},et=function(e,t){i(this,q)[t]=e,i(this,$)[e]=t;},Ie=function(e){e!==i(this,V)&&(e===i(this,B)?b(this,B,i(this,$)[e]):c(this,u,et).call(this,i(this,q)[e],i(this,$)[e]),c(this,u,et).call(this,i(this,V),e),b(this,V,e));},ye=function(e,t){var n,s;let r=false;if(i(this,R)!==0){let a=i(this,F).get(e);if(a!==void 0)if(r=true,i(this,R)===1)c(this,u,tt).call(this,t);else {i(this,_e).call(this,a);let m=i(this,E)[a];if(c(this,u,I).call(this,m)?m.__abortController.abort(new Error("deleted")):(i(this,le)||i(this,U))&&(i(this,le)&&((n=i(this,ie))==null||n.call(this,m,e,t)),i(this,U)&&i(this,P)?.push([m,e,t])),i(this,F).delete(e),i(this,M)[a]=void 0,i(this,E)[a]=void 0,a===i(this,V))b(this,V,i(this,q)[a]);else if(a===i(this,B))b(this,B,i(this,$)[a]);else {let p=i(this,q)[a];i(this,$)[p]=i(this,$)[a];let D=i(this,$)[a];i(this,q)[D]=i(this,q)[a];}Re(this,R)._--,i(this,se).push(a);}}if(i(this,U)&&i(this,P)?.length){let a=i(this,P),m;for(;m=a?.shift();)(s=i(this,re))==null||s.call(this,...m);}return r},tt=function(e){var t,r;for(let n of c(this,u,me).call(this,{allowStale:true})){let s=i(this,E)[n];if(c(this,u,I).call(this,s))s.__abortController.abort(new Error("deleted"));else {let a=i(this,M)[n];i(this,le)&&((t=i(this,ie))==null||t.call(this,s,a,e)),i(this,U)&&i(this,P)?.push([s,a,e]);}}if(i(this,F).clear(),i(this,E).fill(void 0),i(this,M).fill(void 0),i(this,X)&&i(this,ae)&&(i(this,X).fill(0),i(this,ae).fill(0)),i(this,oe)&&i(this,oe).fill(0),b(this,B,0),b(this,V,0),i(this,se).length=0,b(this,ne,0),b(this,R,0),i(this,U)&&i(this,P)){let n=i(this,P),s;for(;s=n?.shift();)(r=i(this,re))==null||r.call(this,...s);}};var je=it;var be=class{constructor(e){S(this,"cache");S(this,"map",new Map);this.cache=new je({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var he=class he{static get originalStepData(){return he._originalStepData?ue(he._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){he._originalStepData=ue(e);}};S(he,"_diffHistory",new be({cacheSize:5})),S(he,"_stepsInfoHistory",new be({cacheSize:5})),S(he,"_narrationHistory",new be({cacheSize:50})),S(he,"stepLimitSaved",20),S(he,"goBackRunning",false),S(he,"_originalStepData");var g=he;var Fe=class{get stepsInfoMap(){return g._stepsInfoHistory}get diffMap(){return g._diffHistory}get narrationMap(){return g._narrationHistory}get size(){return g._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return g._stepsInfoHistory.keys()}get(e){let t=g._narrationHistory.get(e);if(!(t&&Object.keys(t).length===1&&t.stepIndex!==void 0))return t}delete(e){g._stepsInfoHistory.delete(e),g._diffHistory.delete(e),g._narrationHistory.delete(e);}internalRestoreOldGameState(e,t){if(e<=0||this.size==0)return t;let r=this.lastKey;if(typeof r!="number")return A.error("You can't go back, there is no step to go back"),t;let n=g._diffHistory.get(r);if(n)try{let s=ht(t,n);return fe.stepCounter=r,this.delete(r),this.internalRestoreOldGameState(e-1,s)}catch(s){return A.error("Error applying diff",s),t}else return A.error("You can't go back, there is no step to go back"),t}async goBack(e,t=1){if(t<=0){A.warn("The parameter steps must be greater than 0");return}if(g._diffHistory.size<1){A.warn("You can't go back, there is no step to go back");return}if(g.goBackRunning){A.warn("Go back is already running");return}g.goBackRunning=true;try{let r=ue(this.internalRestoreOldGameState(t,g.originalStepData));if(r){await fe.restoreGameStepState(r,e);let n=fe.stepCounter-1,s=g._narrationHistory.get(n);if(s&&Object.keys(s).length===1&&s.stepIndex!==void 0){let a=g._stepsInfoHistory.get(n);if(a){let m=this.itemMapper({step:a});g._narrationHistory.set(a.index,m);}}}else A.error("Error going back");g.goBackRunning=!1;}catch(r){A.error("Error going back",r),g.goBackRunning=false;}}add(e,t={}){let r=g.originalStepData,{ignoreSameStep:n}=t,s=fe.currentGameStepState;if(!n&&this.isSameStep(r,s))return;let a=this.lastKey;(async()=>{try{let p,D;if(typeof a=="number"&&(p=g._stepsInfoHistory.get(a),D=g._narrationHistory.get(a)),g._stepsInfoHistory.set(e.index,e),e.index!==0){let G=(0,gt.diff)(r,s);G?g._diffHistory.set(e.index,G):A.warn("It was not possible to create the difference between the two steps");}let C={},_=this.itemMapper({step:e},C);if(g._narrationHistory.set(e.index,_),p&&D&&typeof a=="number"){let G=this.itemMapper({...C,step:p},{});g._narrationHistory.set(a,G);}}catch(p){A.error("Error adding history step",p);}})(),g.originalStepData=s;}itemMapper(e,t){let{step:r,choiceIndexMade:n,inputValue:s,removeDialogue:a}=e,m=r.dialogue||r.dialoge;t&&r.isGlued&&(t.removeDialogue=true),a&&(m=void 0);let p=r.choices;if(t&&r.currentLabel&&r.choiceIndexMade!==void 0&&(t.choiceIndexMade=r.choiceIndexMade),r.inputValue&&t&&(t.inputValue=r.inputValue),m||p||s){let D=p?.map((C,_)=>{let G=false;return C.oneTime&&r.alreadyMadeChoices&&r.alreadyMadeChoices.includes(_)&&(G=true),{text:C.text,type:C.type,isResponse:false,hidden:G}});if(D){if(D.every(C=>C.hidden)){let C=D.find(_=>_.hidden===false);C&&(C.hidden=false);}n!==void 0&&(D[n].isResponse=true);}return {dialogue:m?{...m,character:m.character?fe.getCharacter(m.character)||m.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:D,stepIndex:r.index,inputValue:s}}return {stepIndex:r.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((r,n)=>r-n).forEach(r=>{let n=this.get(r);n&&e.push(n);}),e}get currentLabelHistory(){let e=[],t=Array.from(this.keys()).sort((p,D)=>D-p);if(t.length===0)return e;let r=t[0];if(typeof r!="number")return e;let n=g._stepsInfoHistory.get(r);if(!n)return e;let s=n.openedLabels;if(!s||!Array.isArray(s)||s.length===0)return e;let a=s[0].currentStepIndex,m=s[0].label;return t.every((p,D)=>{let C=this.get(p);if(C){if(D===0)return e.push(C),true;let _=g._stepsInfoHistory.get(p);if(!_)return true;let G=_.openedLabels;if(!G||!Array.isArray(G)||G.length===0||G[0].label!==m||G[0].currentStepIndex>=a)return false;a=G[0].currentStepIndex,e.push(C);}return true}),e.reverse()}removeNarrativeHistory(e){if(e){let t=Array.from(this.keys()).sort((r,n)=>r-n);t=t.slice(0,e),t.forEach(r=>{g._narrationHistory.delete(r),g._stepsInfoHistory.delete(r),g._diffHistory.delete(r);});}else g._stepsInfoHistory.clear(),g._diffHistory.clear(),g._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:g._diffHistory.has(e)}blockGoBack(){fe.currentStepsRunningNumber===0&&g._diffHistory.clear();}isSameStep(e,t){if(e.openedLabels.length===t.openedLabels.length)try{let r=JSON.stringify(e.openedLabels),n=JSON.stringify(t.openedLabels);if(r===n&&e.path===t.path&&e.labelIndex===t.labelIndex)return !0}catch(r){return A.error("Error comparing opened labels",r),true}return false}clear(){g._stepsInfoHistory.clear(),g._diffHistory.clear(),g._narrationHistory.clear(),g._originalStepData=void 0;}get stepLimitSaved(){return g.stepLimitSaved}set stepLimitSaved(e){g.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((r,n)=>r-n);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let t=[];return e.forEach(r=>{let n=g._stepsInfoHistory.get(r);if(n){let s=g._diffHistory.get(r);t.push({...n,diff:s});}}),{stepsHistory:ue(t),originalStepData:ue(g._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((r,n)=>r-n),t={};e.forEach(r=>{let n=g._stepsInfoHistory.get(r);if(n){let s={...t};t={};let a=this.itemMapper({step:n,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},t);a&&g._narrationHistory.set(r,a);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(r=>{r.diff&&g._diffHistory.set(r.index,r.diff);let n={...r,diff:void 0};g._stepsInfoHistory.set(r.index,n);}),this.restoreNarrativeHistory()):A.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?g._originalStepData=e.originalStepData:A.warn("Could not import originalStepData data, so will be ignored");}catch(t){A.error("Error importing data",t);}}};var fi=new Fe;
|
|
2
|
+
exports.HistoryManagerStatic=g;exports.stepHistory=fi;
|