@drincs/pixi-vn 1.9.4 → 1.9.6
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/README.md +186 -170
- package/dist/{ContainerMemory-DNqSVzLY.d.cts → ContainerMemory-De04YSUc.d.cts} +2 -1
- package/dist/{ContainerMemory-DNqSVzLY.d.ts → ContainerMemory-De04YSUc.d.ts} +2 -1
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +1008 -918
- package/dist/canvas.d.ts +1008 -918
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.d.cts +3 -2
- package/dist/characters.d.ts +3 -2
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-S7HZUIEI.mjs → chunk-A5FN4SNI.mjs} +1 -1
- package/dist/chunk-B46NFIFC.mjs +1 -0
- package/dist/chunk-FPMP2OWB.mjs +1 -0
- package/dist/{chunk-6OABTG5R.mjs → chunk-OJKUK6GL.mjs} +1 -1
- package/dist/{chunk-5MVDNAT4.mjs → chunk-WYGKBGMH.mjs} +1 -1
- package/dist/chunk-XLRCR56W.mjs +1 -0
- package/dist/core.d.cts +12 -5
- package/dist/core.d.ts +12 -5
- package/dist/filters.cjs +1 -1
- package/dist/filters.d.cts +18 -3
- package/dist/filters.d.ts +18 -3
- package/dist/filters.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +10 -5
- package/dist/history.d.ts +10 -5
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +8 -2
- package/dist/motion.d.ts +8 -2
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.d.cts +7 -2
- package/dist/narration.d.ts +7 -2
- package/dist/narration.mjs +1 -1
- package/dist/pixi/browser.js +182 -148
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +3 -2
- package/dist/sound.d.ts +3 -2
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +7 -2
- package/dist/storage.d.ts +7 -2
- package/dist/storage.mjs +1 -1
- package/dist/tickers.cjs +1 -1
- package/dist/tickers.d.cts +72 -1
- package/dist/tickers.d.ts +72 -1
- package/dist/tickers.mjs +1 -1
- package/dist/vite-listener.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +2 -1
- package/dist/worker.d.ts +2 -1
- package/package.json +11 -10
- package/dist/chunk-AW5XWF24.mjs +0 -1
- package/dist/chunk-K7JIC2F2.mjs +0 -1
package/dist/history.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core'),worker=require('@drincs/pixi-vn/worker');var Xt=Object.defineProperty;var kt=f=>{throw TypeError(f)};var Jt=(f,t,i)=>t in f?Xt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var R=(f,t,i)=>Jt(f,typeof t!="symbol"?t+"":t,i),Dt=(f,t,i)=>t.has(f)||kt("Cannot "+i);var e=(f,t,i)=>(Dt(f,t,"read from private field"),i?i.call(f):t.get(f)),S=(f,t,i)=>t.has(f)?kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),p=(f,t,i,s)=>(Dt(f,t,"write to private field"),t.set(f,i),i),u=(f,t,i)=>(Dt(f,t,"access private method"),i);var Tt=(f,t,i,s)=>({set _(r){p(f,t,r);},get _(){return e(f,t,s)}});var zt="narration";var Vt={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Qt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Yt=new Set,Mt=typeof process=="object"&&process?process:{},Wt=(f,t,i,s)=>{typeof Mt.emitWarning=="function"?Mt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},Rt=globalThis.AbortController,Ut=globalThis.AbortSignal;if(typeof Rt>"u"){Ut=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Rt=class{constructor(){t();}signal=new Ut;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 f=Mt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=false,Wt("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 Zt=f=>!Yt.has(f);var st=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),jt=f=>st(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ht:null:null,Ht=class extends Array{constructor(f){super(f),this.fill(0);}},et,gt,te=(et=class{heap;length;static create(t){let i=jt(t);if(!i)return [];p(et,gt,true);let s=new et(t,i);return p(et,gt,false),s}constructor(t,i){if(!e(et,gt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},gt=new WeakMap,S(et,gt,false),et),Kt,Pt,W,z,j,lt,B,yt,mt,q,H,$,T,v,g,L,V,D,x,X,I,J,Q,U,K,Z,at,G,St,h,Nt,ut,it,wt,P,qt,ct,_t,At,rt,nt,Lt,xt,It,E,Gt,vt,ot,Ft,bt,Bt=(bt=class{constructor(t){S(this,h);S(this,W);S(this,z);S(this,j);S(this,lt);S(this,B);S(this,yt);S(this,mt);S(this,q);R(this,"ttl");R(this,"ttlResolution");R(this,"ttlAutopurge");R(this,"updateAgeOnGet");R(this,"updateAgeOnHas");R(this,"allowStale");R(this,"noDisposeOnSet");R(this,"noUpdateTTL");R(this,"maxEntrySize");R(this,"sizeCalculation");R(this,"noDeleteOnFetchRejection");R(this,"noDeleteOnStaleGet");R(this,"allowStaleOnFetchAbort");R(this,"allowStaleOnFetchRejection");R(this,"ignoreFetchAbort");S(this,H);S(this,$);S(this,T);S(this,v);S(this,g);S(this,L);S(this,V);S(this,D);S(this,x);S(this,X);S(this,I);S(this,J);S(this,Q);S(this,U);S(this,K);S(this,Z);S(this,at);S(this,G);S(this,St);S(this,ut,()=>{});S(this,it,()=>{});S(this,wt,()=>{});S(this,P,()=>false);S(this,ct,t=>{});S(this,_t,(t,i,s)=>{});S(this,At,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});R(this,Kt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:l,dispose:d,onInsert:_,disposeAfter:m,noDisposeOnSet:O,noUpdateTTL:Y,maxSize:tt=0,maxEntrySize:w=0,sizeCalculation:b,fetchMethod:y,memoMethod:M,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:Et,ignoreFetchAbort:ft,perf:pt}=t;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,q,pt??Qt),i!==0&&!st(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?jt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(p(this,W,i),p(this,z,tt),this.maxEntrySize=w||e(this,z),this.sizeCalculation=b,this.sizeCalculation){if(!e(this,z)&&!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(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,mt,M),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,yt,y),p(this,at,!!y),p(this,T,new Map),p(this,v,new Array(i).fill(void 0)),p(this,g,new Array(i).fill(void 0)),p(this,L,new dt(i)),p(this,V,new dt(i)),p(this,D,0),p(this,x,0),p(this,X,te.create(i)),p(this,H,0),p(this,$,0),typeof d=="function"&&p(this,j,d),typeof _=="function"&&p(this,lt,_),typeof m=="function"?(p(this,B,m),p(this,I,[])):(p(this,B,void 0),p(this,I,void 0)),p(this,Z,!!e(this,j)),p(this,St,!!e(this,lt)),p(this,G,!!e(this,B)),this.noDisposeOnSet=!!O,this.noUpdateTTL=!!Y,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!Et,this.ignoreFetchAbort=!!ft,this.maxEntrySize!==0){if(e(this,z)!==0&&!st(e(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");u(this,h,qt).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");u(this,h,Nt).call(this);}if(e(this,W)===0&&this.ttl===0&&e(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,W)&&!e(this,z)){let Ct="LRU_CACHE_UNBOUNDED";Zt(Ct)&&(Yt.add(Ct),Wt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ct,bt));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,U),autopurgeTimers:e(t,K),sizes:e(t,J),keyMap:e(t,T),keyList:e(t,v),valList:e(t,g),next:e(t,L),prev:e(t,V),get head(){return e(t,D)},get tail(){return e(t,x)},free:e(t,X),isBackgroundFetch:i=>{var s;return u(s=t,h,E).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return u(n=t,h,It).call(n,i,s,r,o)},moveToTail:i=>{var s;return u(s=t,h,vt).call(s,i)},indexes:i=>{var s;return u(s=t,h,rt).call(s,i)},rindexes:i=>{var s;return u(s=t,h,nt).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,W)}get maxSize(){return e(this,z)}get calculatedSize(){return e(this,$)}get size(){return e(this,H)}get fetchMethod(){return e(this,yt)}get memoMethod(){return e(this,mt)}get dispose(){return e(this,j)}get onInsert(){return e(this,lt)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,T).has(t)?1/0:0}*entries(){for(let t of u(this,h,rt).call(this))e(this,g)[t]!==void 0&&e(this,v)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield [e(this,v)[t],e(this,g)[t]]);}*rentries(){for(let t of u(this,h,nt).call(this))e(this,g)[t]!==void 0&&e(this,v)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield [e(this,v)[t],e(this,g)[t]]);}*keys(){for(let t of u(this,h,rt).call(this)){let i=e(this,v)[t];i!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield i);}}*rkeys(){for(let t of u(this,h,nt).call(this)){let i=e(this,v)[t];i!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield i);}}*values(){for(let t of u(this,h,rt).call(this))e(this,g)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}*rvalues(){for(let t of u(this,h,nt).call(this))e(this,g)[t]!==void 0&&!u(this,h,E).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}[(Pt=Symbol.iterator,Kt=Symbol.toStringTag,Pt)](){return this.entries()}find(t,i={}){for(let s of u(this,h,rt).call(this)){let r=e(this,g)[s],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,v)[s],this))return this.get(e(this,v)[s],i)}}forEach(t,i=this){for(let s of u(this,h,rt).call(this)){let r=e(this,g)[s],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,v)[s],this);}}rforEach(t,i=this){for(let s of u(this,h,nt).call(this)){let r=e(this,g)[s],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,v)[s],this);}}purgeStale(){let t=false;for(let i of u(this,h,nt).call(this,{allowStale:true}))e(this,P).call(this,i)&&(u(this,h,ot).call(this,e(this,v)[i],"expire"),t=true);return t}info(t){let i=e(this,T).get(t);if(i===void 0)return;let s=e(this,g)[i],r=u(this,h,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,U)&&e(this,Q)){let n=e(this,U)[i],a=e(this,Q)[i];if(n&&a){let l=n-(e(this,q).now()-a);o.ttl=l,o.start=Date.now();}}return e(this,J)&&(o.size=e(this,J)[i]),o}dump(){let t=[];for(let i of u(this,h,rt).call(this,{allowStale:true})){let s=e(this,v)[i],r=e(this,g)[i],o=u(this,h,E).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,U)&&e(this,Q)){n.ttl=e(this,U)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,J)&&(n.size=e(this,J)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var O,Y,tt,w;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:l}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,_=e(this,At).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&_>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),u(this,h,ot).call(this,t,"set"),this;let m=e(this,H)===0?void 0:e(this,T).get(t);if(m===void 0)m=e(this,H)===0?e(this,x):e(this,X).length!==0?e(this,X).pop():e(this,H)===e(this,W)?u(this,h,xt).call(this,false):e(this,H),e(this,v)[m]=t,e(this,g)[m]=i,e(this,T).set(t,m),e(this,L)[e(this,x)]=m,e(this,V)[m]=e(this,x),p(this,x,m),Tt(this,H)._++,e(this,_t).call(this,m,_,l),l&&(l.set="add"),d=false,e(this,St)&&((O=e(this,lt))==null||O.call(this,i,t,"add"));else {u(this,h,vt).call(this,m);let b=e(this,g)[m];if(i!==b){if(e(this,at)&&u(this,h,E).call(this,b)){b.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=b;y!==void 0&&!n&&(e(this,Z)&&((Y=e(this,j))==null||Y.call(this,y,t,"set")),e(this,G)&&e(this,I)?.push([y,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,j))==null||tt.call(this,b,t,"set")),e(this,G)&&e(this,I)?.push([b,t,"set"]));if(e(this,ct).call(this,m),e(this,_t).call(this,m,_,l),e(this,g)[m]=i,l){l.set="replace";let y=b&&u(this,h,E).call(this,b)?b.__staleWhileFetching:b;y!==void 0&&(l.oldValue=y);}}else l&&(l.set="update");e(this,St)&&this.onInsert?.(i,t,i===b?"update":"replace");}if(r!==0&&!e(this,U)&&u(this,h,Nt).call(this),e(this,U)&&(d||e(this,wt).call(this,m,r,o),l&&e(this,it).call(this,l,m)),!n&&e(this,G)&&e(this,I)){let b=e(this,I),y;for(;y=b?.shift();)(w=e(this,B))==null||w.call(this,...y);}return this}pop(){var t;try{for(;e(this,H);){let i=e(this,g)[e(this,D)];if(u(this,h,xt).call(this,!0),u(this,h,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,G)&&e(this,I)){let i=e(this,I),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,T).get(t);if(o!==void 0){let n=e(this,g)[o];if(u(this,h,E).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,it).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,T).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,g)[r];return u(this,h,E).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:l=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:_=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:O=this.allowStaleOnFetchRejection,ignoreFetchAbort:Y=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:w,forceRefresh:b=false,status:y,signal:M}=i;if(!e(this,at))return y&&(y.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:y});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:l,sizeCalculation:d,noUpdateTTL:_,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:tt,ignoreFetchAbort:Y,status:y,signal:M},N=e(this,T).get(t);if(N===void 0){y&&(y.fetch="miss");let A=u(this,h,It).call(this,t,N,k,w);return A.__returned=A}else {let A=e(this,g)[N];if(u(this,h,E).call(this,A)){let dt=s&&A.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",dt&&(y.returnedStale=true)),dt?A.__staleWhileFetching:A.__returned=A}let Et=e(this,P).call(this,N);if(!b&&!Et)return y&&(y.fetch="hit"),u(this,h,vt).call(this,N),r&&e(this,ut).call(this,N),y&&e(this,it).call(this,y,N),A;let ft=u(this,h,It).call(this,t,N,k,w),pt=ft.__staleWhileFetching!==void 0&&s;return y&&(y.fetch=Et?"stale":"refresh",pt&&Et&&(y.returnedStale=true)),pt?ft.__staleWhileFetching:ft.__returned=ft}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let l=s(t,a,{options:n,context:r});return this.set(t,l,n),l}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,T).get(t);if(a!==void 0){let l=e(this,g)[a],d=u(this,h,E).call(this,l);return n&&e(this,it).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&l.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?l.__staleWhileFetching:void 0):(o||u(this,h,ot).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?l:void 0)):(n&&(n.get="hit"),d?l.__staleWhileFetching:(u(this,h,vt).call(this,a),r&&e(this,ut).call(this,a),l))}else n&&(n.get="miss");}delete(t){return u(this,h,ot).call(this,t,"delete")}clear(){return u(this,h,Ft).call(this,"delete")}},W=new WeakMap,z=new WeakMap,j=new WeakMap,lt=new WeakMap,B=new WeakMap,yt=new WeakMap,mt=new WeakMap,q=new WeakMap,H=new WeakMap,$=new WeakMap,T=new WeakMap,v=new WeakMap,g=new WeakMap,L=new WeakMap,V=new WeakMap,D=new WeakMap,x=new WeakMap,X=new WeakMap,I=new WeakMap,J=new WeakMap,Q=new WeakMap,U=new WeakMap,K=new WeakMap,Z=new WeakMap,at=new WeakMap,G=new WeakMap,St=new WeakMap,h=new WeakSet,Nt=function(){let t=new Ht(e(this,W)),i=new Ht(e(this,W));p(this,U,t),p(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,W)):void 0;p(this,K,s),p(this,wt,(a,l,d=e(this,q).now())=>{i[a]=l!==0?d:0,t[a]=l,r(a,l);}),p(this,ut,a=>{i[a]=t[a]!==0?e(this,q).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,l)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),l&&l!==0&&s){let d=setTimeout(()=>{e(this,P).call(this,a)&&u(this,h,ot).call(this,e(this,v)[a],"expire");},l+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};p(this,it,(a,l)=>{if(t[l]){let d=t[l],_=i[l];if(!d||!_)return;a.ttl=d,a.start=_,a.now=o||n();let m=a.now-_;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,q).now();if(this.ttlResolution>0){o=a;let l=setTimeout(()=>o=0,this.ttlResolution);l.unref&&l.unref();}return a};this.getRemainingTTL=a=>{let l=e(this,T).get(a);if(l===void 0)return 0;let d=t[l],_=i[l];if(!d||!_)return 1/0;let m=(o||n())-_;return d-m},p(this,P,a=>{let l=i[a],d=t[a];return !!d&&!!l&&(o||n())-l>d});},ut=new WeakMap,it=new WeakMap,wt=new WeakMap,P=new WeakMap,qt=function(){let t=new Ht(e(this,W));p(this,$,0),p(this,J,t),p(this,ct,i=>{p(this,$,e(this,$)-t[i]),t[i]=0;}),p(this,At,(i,s,r,o)=>{if(u(this,h,E).call(this,s))return 0;if(!st(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!st(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}),p(this,_t,(i,s,r)=>{if(t[i]=s,e(this,z)){let o=e(this,z)-t[i];for(;e(this,$)>o;)u(this,h,xt).call(this,true);}p(this,$,e(this,$)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,$));});},ct=new WeakMap,_t=new WeakMap,At=new WeakMap,rt=function*({allowStale:t=this.allowStale}={}){if(e(this,H))for(let i=e(this,x);!(!u(this,h,Lt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,D)));)i=e(this,V)[i];},nt=function*({allowStale:t=this.allowStale}={}){if(e(this,H))for(let i=e(this,D);!(!u(this,h,Lt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,x)));)i=e(this,L)[i];},Lt=function(t){return t!==void 0&&e(this,T).get(e(this,v)[t])===t},xt=function(t){var o;let i=e(this,D),s=e(this,v)[i],r=e(this,g)[i];return e(this,at)&&u(this,h,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,G))&&(e(this,Z)&&((o=e(this,j))==null||o.call(this,r,s,"evict")),e(this,G)&&e(this,I)?.push([r,s,"evict"])),e(this,ct).call(this,i),e(this,K)?.[i]&&(clearTimeout(e(this,K)[i]),e(this,K)[i]=void 0),t&&(e(this,v)[i]=void 0,e(this,g)[i]=void 0,e(this,X).push(i)),e(this,H)===1?(p(this,D,p(this,x,0)),e(this,X).length=0):p(this,D,e(this,L)[i]),e(this,T).delete(s),Tt(this,H)._--,i},It=function(t,i,s,r){let o=i===void 0?void 0:e(this,g)[i];if(u(this,h,E).call(this,o))return o;let n=new Rt,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let l={signal:n.signal,options:s,context:r},d=(w,b=false)=>{let{aborted:y}=n.signal,M=s.ignoreFetchAbort&&w!==void 0,k=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(y&&!b?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),y&&!M&&!b)return m(n.signal.reason,k);let N=Y,A=e(this,g)[i];return (A===Y||M&&b&&A===void 0)&&(w===void 0?N.__staleWhileFetching!==void 0?e(this,g)[i]=N.__staleWhileFetching:u(this,h,ot).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,w,l.options))),w},_=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),m(w,false)),m=(w,b)=>{let{aborted:y}=n.signal,M=y&&s.allowStaleOnFetchAbort,k=M||s.allowStaleOnFetchRejection,N=k||s.noDeleteOnFetchRejection,A=Y;if(e(this,g)[i]===Y&&(!N||!b&&A.__staleWhileFetching===void 0?u(this,h,ot).call(this,t,"fetch"):M||(e(this,g)[i]=A.__staleWhileFetching)),k)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw w},O=(w,b)=>{var M;let y=(M=e(this,yt))==null?void 0:M.call(this,t,o,l);y&&y instanceof Promise&&y.then(k=>w(k===void 0?void 0:k),b),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=k=>d(k,true)));});};s.status&&(s.status.fetchDispatched=true);let Y=new Promise(O).then(d,_),tt=Object.assign(Y,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...l.options,status:void 0}),i=e(this,T).get(t)):e(this,g)[i]=tt,tt},E=function(t){if(!e(this,at))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Rt},Gt=function(t,i){e(this,V)[i]=t,e(this,L)[t]=i;},vt=function(t){t!==e(this,x)&&(t===e(this,D)?p(this,D,e(this,L)[t]):u(this,h,Gt).call(this,e(this,V)[t],e(this,L)[t]),u(this,h,Gt).call(this,e(this,x),t),p(this,x,t));},ot=function(t,i){var r,o;let s=false;if(e(this,H)!==0){let n=e(this,T).get(t);if(n!==void 0)if(e(this,K)?.[n]&&(clearTimeout(e(this,K)?.[n]),e(this,K)[n]=void 0),s=true,e(this,H)===1)u(this,h,Ft).call(this,i);else {e(this,ct).call(this,n);let a=e(this,g)[n];if(u(this,h,E).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,G))&&(e(this,Z)&&((r=e(this,j))==null||r.call(this,a,t,i)),e(this,G)&&e(this,I)?.push([a,t,i])),e(this,T).delete(t),e(this,v)[n]=void 0,e(this,g)[n]=void 0,n===e(this,x))p(this,x,e(this,V)[n]);else if(n===e(this,D))p(this,D,e(this,L)[n]);else {let l=e(this,V)[n];e(this,L)[l]=e(this,L)[n];let d=e(this,L)[n];e(this,V)[d]=e(this,V)[n];}Tt(this,H)._--,e(this,X).push(n);}}if(e(this,G)&&e(this,I)?.length){let n=e(this,I),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Ft=function(t){var i,s;for(let r of u(this,h,nt).call(this,{allowStale:true})){let o=e(this,g)[r];if(u(this,h,E).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,v)[r];e(this,Z)&&((i=e(this,j))==null||i.call(this,o,n,t)),e(this,G)&&e(this,I)?.push([o,n,t]);}}if(e(this,T).clear(),e(this,g).fill(void 0),e(this,v).fill(void 0),e(this,U)&&e(this,Q)){e(this,U).fill(0),e(this,Q).fill(0);for(let r of e(this,K)??[])r!==void 0&&clearTimeout(r);e(this,K)?.fill(void 0);}if(e(this,J)&&e(this,J).fill(0),p(this,D,0),p(this,x,0),e(this,X).length=0,p(this,$,0),p(this,H,0),e(this,G)&&e(this,I)){let r=e(this,I),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}},bt);var ht=class{cache;map=new Map;constructor(t){this.cache=new Bt({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var c=class f{static _diffHistory=new ht({cacheSize:5});static _stepsInfoHistory=new ht({cacheSize:5});static _narrationHistory=new ht({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return f._originalStepData?f._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){f._originalStepData=t;}};var C;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(C||={});var Ot=class{get stepsInfoMap(){return c._stepsInfoHistory}get diffMap(){return c._diffHistory}get narrationMap(){return c._narrationHistory}get size(){return c._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let t=null;for(let i of this.keys())(t===null||i>t)&&(t=i);return t}get lastDiffKey(){let t=null;for(let i of c._diffHistory.keys())(t===null||i>t)&&(t=i);return t}get goBackMode(){return c.goBackMode}set goBackMode(t){c.goBackMode=t;}keys(){return c._stepsInfoHistory.keys()}get(t){let i=c._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){c._stepsInfoHistory.delete(t),c._diffHistory.delete(t),c._narrationHistory.delete(t);}deleteFromKeyOnward(t){Array.from(this.keys()).filter(i=>i>=t).forEach(i=>{this.delete(i);});}previousCheckpointKey(t){let i=0;for(let s of c._diffHistory.keys())s<t&&s>i&&(i=s);return i}pendingInputRestoreValue;findPreviousInputAnswer(t){if(c._stepsInfoHistory.get(t-1)?.isRequiredInput)return c._stepsInfoHistory.get(t)?.inputValue}async getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastDiffKey;if(typeof s!="number")return C.warn("You can't go back, there is no step to go back"),i;let r=c._diffHistory.get(s);if(r)try{let o=await worker.restoreDiffMaybeOffloaded(i,r),n=this.previousCheckpointKey(s)+1;return core.GameUnifier.stepCounter=n,t===1&&(this.pendingInputRestoreValue=this.findPreviousInputAnswer(n)),this.deleteFromKeyOnward(n),this.getOldGameState(t-1,o)}catch(o){return C.error("Error applying diff",o),i}else return C.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){C.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){C.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(c._diffHistory.size<1){C.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{this.pendingInputRestoreValue=void 0;let r=await this.getOldGameState(s,c.originalStepData);if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate),this.pendingInputRestoreValue!==void 0&&core.GameUnifier.setVariable(zt,Vt.CURRENT_INPUT_VALUE_MEMORY_KEY,this.pendingInputRestoreValue);let o=core.GameUnifier.stepCounter-1,n=c._stepsInfoHistory.get(o),a=c._narrationHistory.get(o),l=a&&Object.keys(a).length===1&&a.stepIndex!==void 0;if(n&&(l||n.isRequiredInput)){let d=this.itemMapper({step:n,inputValue:n.isRequiredInput?this.pendingInputRestoreValue:void 0});c._narrationHistory.set(n.index,d);}}else C.error("Error going back");c.originalStepData=r;}catch(r){C.error("Error going back",r);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}isCheckpointStep(t,i){if(c.goBackMode==="step"||t.choices&&t.choices.length>0||t.isRequiredInput)return true;let s=t.openedLabels??[],r=i?.openedLabels??[];return s.length!==r.length?true:s.some((o,n)=>o.label!==r[n]?.label)}async add(t,i={}){let s=c.originalStepData,{ignoreSameStep:r}=i,o=await core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey,a=typeof n=="number"?c._stepsInfoHistory.get(n):void 0,l=t.index===0||this.isCheckpointStep(t,a);try{let d=typeof n=="number"?c._narrationHistory.get(n):void 0;c._stepsInfoHistory.set(t.index,t);let _={},m=this.itemMapper({step:t},_);if(c._narrationHistory.set(t.index,m),a&&d&&typeof n=="number"){let O=this.itemMapper({..._,step:a},{});c._narrationHistory.set(n,O);}}catch(d){C.error("Error adding history step",d);}t.index!==0&&l&&(async()=>{try{let d=await worker.diffMaybeOffloaded(s,o);d?c._diffHistory.set(t.index,d):C.warn("It was not possible to create the difference between the two steps");}catch(d){C.error("Error adding history step",d);}})(),(t.index===0||l)&&(c.originalStepData=o);}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let l=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||l||o){let d=l?.map((_,m)=>{let O=false;return _.oneTime&&s.alreadyMadeChoices?.includes(m)&&(O=true),{text:_.text,type:_.type,isResponse:false,hidden:O}});if(d){if(d.every(_=>_.hidden)){let _=d.find(m=>m.hidden===false);_&&(_.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o,openedLabelsNumber:s.openedLabels?.length}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((l,d)=>d-l);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=c._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((l,d)=>{let _=this.get(l);if(_){if(d===0)return t.push(_),true;let m=c._stepsInfoHistory.get(l);if(!m)return true;let O=m.openedLabels;if(!O||!Array.isArray(O)||O.length===0||O[0].label!==a||O[0].currentStepIndex>n)return false;n=O[0].currentStepIndex,t.push(_);}return true}),t.reverse()}get currentPageParagraphs(){let t=[],i;return this.currentLabelHistory.forEach(s=>{t.length===0||s.openedLabelsNumber!==i?t.push([s]):t[t.length-1].push(s),i=s.openedLabelsNumber;}),t}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{c._narrationHistory.delete(s),c._stepsInfoHistory.delete(s),c._diffHistory.delete(s);});}else c._stepsInfoHistory.clear(),c._diffHistory.clear(),c._narrationHistory.clear();}get canGoBack(){return c._diffHistory.size>0}blockGoBack(){core.GameUnifier.runningStepsCount===0&&c._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return C.error("Error comparing opened labels",s),true}return false}clear(){c._stepsInfoHistory.clear(),c._diffHistory.clear(),c._narrationHistory.clear(),c._originalStepData=void 0;}get stepLimitSaved(){return c.stepLimitSaved}set stepLimitSaved(t){c.stepLimitSaved=t;}async export(){let t=Array.from(this.keys()).sort((n,a)=>n-a);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];t.forEach(n=>{let a=c._stepsInfoHistory.get(n);if(a){let l=c._diffHistory.get(n);i.push({...a,diff:l});}});let s=c._originalStepData,[r,o]=await Promise.all([worker.cloneMaybeOffloaded(i),s?worker.cloneMaybeOffloaded(s):void 0]);return {stepsHistory:r,originalStepData:o}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=c._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&c._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{Object.hasOwn(t,"stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&c._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};c._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):C.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?c._originalStepData=t.originalStepData:C.warn("Could not import originalStepData data, so will be ignored");}catch(i){C.error("Error importing data",i);}}};var Ae=new Ot;exports.HistoryManagerStatic=c;exports.stepHistory=Ae;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core'),worker=require('@drincs/pixi-vn/worker');var qt=Object.defineProperty;var Ft=u=>{throw TypeError(u)};var $t=(u,t,i)=>t in u?qt(u,t,{enumerable:true,configurable:true,writable:true,value:i}):u[t]=i;var R=(u,t,i)=>$t(u,typeof t!="symbol"?t+"":t,i),vt=(u,t,i)=>t.has(u)||Ft("Cannot "+i);var e=(u,t,i)=>(vt(u,t,"read from private field"),i?i.call(u):t.get(u)),y=(u,t,i)=>t.has(u)?Ft("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,i),d=(u,t,i,s)=>(vt(u,t,"write to private field"),t.set(u,i),i),l=(u,t,i)=>(vt(u,t,"access private method"),i);var At=(u,t,i,s)=>({set _(n){d(u,t,n);},get _(){return e(u,t,s)}});var zt="narration";var kt={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ft=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Kt=new Set,xt=typeof process=="object"&&process?process:{},Yt=(u,t,i,s)=>{typeof xt.emitWarning=="function"?xt.emitWarning(u,t,i,s):console.error(`[${i}] ${t}: ${u}`);},Ht=globalThis.AbortController,Vt=globalThis.AbortSignal;if(typeof Ht>"u"){Vt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(s,n){this._onabort.push(n);}},Ht=class{constructor(){t();}signal=new Vt;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let n of this.signal._onabort)n(s);this.signal.onabort?.(s);}}};let u=xt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{u&&(u=false,Yt("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 Xt=u=>!Kt.has(u);var et=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),Wt=u=>et(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?ct:null:null,ct=class extends Array{constructor(t){super(t),this.fill(0);}},ut,at=class at{heap;length;static create(t){let i=Wt(t);if(!i)return [];d(at,ut,true);let s=new at(t,i);return d(at,ut,false),s}constructor(t,i){if(!e(at,ut))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};ut=new WeakMap,y(at,ut,false);var Rt=at,Pt,Ut,Y,F,W,j,dt,pt,O,B,H,A,p,D,z,C,I,q,v,$,X,k,J,rt,N,a,Mt,ht,Z,_t,V,jt,lt,gt,St,it,st,Ct,wt,Tt,E,Dt,mt,nt,Nt,Lt=class Lt{constructor(t){y(this,a);y(this,Y);y(this,F);y(this,W);y(this,j);y(this,dt);y(this,pt);R(this,"ttl");R(this,"ttlResolution");R(this,"ttlAutopurge");R(this,"updateAgeOnGet");R(this,"updateAgeOnHas");R(this,"allowStale");R(this,"noDisposeOnSet");R(this,"noUpdateTTL");R(this,"maxEntrySize");R(this,"sizeCalculation");R(this,"noDeleteOnFetchRejection");R(this,"noDeleteOnStaleGet");R(this,"allowStaleOnFetchAbort");R(this,"allowStaleOnFetchRejection");R(this,"ignoreFetchAbort");y(this,O);y(this,B);y(this,H);y(this,A);y(this,p);y(this,D);y(this,z);y(this,C);y(this,I);y(this,q);y(this,v);y(this,$);y(this,X);y(this,k);y(this,J);y(this,rt);y(this,N);y(this,ht,()=>{});y(this,Z,()=>{});y(this,_t,()=>{});y(this,V,()=>false);y(this,lt,t=>{});y(this,gt,(t,i,s)=>{});y(this,St,(t,i,s,n)=>{if(s||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});R(this,Pt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:r,updateAgeOnHas:h,allowStale:f,dispose:g,disposeAfter:b,noDisposeOnSet:m,noUpdateTTL:T,maxSize:P=0,maxEntrySize:Q=0,sizeCalculation:_,fetchMethod:w,memoMethod:S,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:K,ignoreFetchAbort:yt}=t;if(i!==0&&!et(i))throw new TypeError("max option must be a nonnegative integer");let tt=i?Wt(i):Array;if(!tt)throw new Error("invalid max value: "+i);if(d(this,Y,i),d(this,F,P),this.maxEntrySize=Q||e(this,F),this.sizeCalculation=_,this.sizeCalculation){if(!e(this,F)&&!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(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(d(this,pt,S),w!==void 0&&typeof w!="function")throw new TypeError("fetchMethod must be a function if specified");if(d(this,dt,w),d(this,rt,!!w),d(this,H,new Map),d(this,A,new Array(i).fill(void 0)),d(this,p,new Array(i).fill(void 0)),d(this,D,new tt(i)),d(this,z,new tt(i)),d(this,C,0),d(this,I,0),d(this,q,Rt.create(i)),d(this,O,0),d(this,B,0),typeof g=="function"&&d(this,W,g),typeof b=="function"?(d(this,j,b),d(this,v,[])):(d(this,j,void 0),d(this,v,void 0)),d(this,J,!!e(this,W)),d(this,N,!!e(this,j)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!K,this.ignoreFetchAbort=!!yt,this.maxEntrySize!==0){if(e(this,F)!==0&&!et(e(this,F)))throw new TypeError("maxSize must be a positive integer if specified");if(!et(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,a,jt).call(this);}if(this.allowStale=!!f,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!h,this.ttlResolution=et(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!et(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,a,Mt).call(this);}if(e(this,Y)===0&&this.ttl===0&&e(this,F)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,Y)&&!e(this,F)){let Et="LRU_CACHE_UNBOUNDED";Xt(Et)&&(Kt.add(Et),Yt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Et,Lt));}}static unsafeExposeInternals(t){return {starts:e(t,X),ttls:e(t,k),sizes:e(t,$),keyMap:e(t,H),keyList:e(t,A),valList:e(t,p),next:e(t,D),prev:e(t,z),get head(){return e(t,C)},get tail(){return e(t,I)},free:e(t,q),isBackgroundFetch:i=>{var s;return l(s=t,a,E).call(s,i)},backgroundFetch:(i,s,n,o)=>{var r;return l(r=t,a,Tt).call(r,i,s,n,o)},moveToTail:i=>{var s;return l(s=t,a,mt).call(s,i)},indexes:i=>{var s;return l(s=t,a,it).call(s,i)},rindexes:i=>{var s;return l(s=t,a,st).call(s,i)},isStale:i=>{var s;return e(s=t,V).call(s,i)}}}get max(){return e(this,Y)}get maxSize(){return e(this,F)}get calculatedSize(){return e(this,B)}get size(){return e(this,O)}get fetchMethod(){return e(this,dt)}get memoMethod(){return e(this,pt)}get dispose(){return e(this,W)}get disposeAfter(){return e(this,j)}getRemainingTTL(t){return e(this,H).has(t)?1/0:0}*entries(){for(let t of l(this,a,it).call(this))e(this,p)[t]!==void 0&&e(this,A)[t]!==void 0&&!l(this,a,E).call(this,e(this,p)[t])&&(yield [e(this,A)[t],e(this,p)[t]]);}*rentries(){for(let t of l(this,a,st).call(this))e(this,p)[t]!==void 0&&e(this,A)[t]!==void 0&&!l(this,a,E).call(this,e(this,p)[t])&&(yield [e(this,A)[t],e(this,p)[t]]);}*keys(){for(let t of l(this,a,it).call(this)){let i=e(this,A)[t];i!==void 0&&!l(this,a,E).call(this,e(this,p)[t])&&(yield i);}}*rkeys(){for(let t of l(this,a,st).call(this)){let i=e(this,A)[t];i!==void 0&&!l(this,a,E).call(this,e(this,p)[t])&&(yield i);}}*values(){for(let t of l(this,a,it).call(this))e(this,p)[t]!==void 0&&!l(this,a,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}*rvalues(){for(let t of l(this,a,st).call(this))e(this,p)[t]!==void 0&&!l(this,a,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}[(Ut=Symbol.iterator,Pt=Symbol.toStringTag,Ut)](){return this.entries()}find(t,i={}){for(let s of l(this,a,it).call(this)){let n=e(this,p)[s],o=l(this,a,E).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&t(o,e(this,A)[s],this))return this.get(e(this,A)[s],i)}}forEach(t,i=this){for(let s of l(this,a,it).call(this)){let n=e(this,p)[s],o=l(this,a,E).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(i,o,e(this,A)[s],this);}}rforEach(t,i=this){for(let s of l(this,a,st).call(this)){let n=e(this,p)[s],o=l(this,a,E).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&t.call(i,o,e(this,A)[s],this);}}purgeStale(){let t=false;for(let i of l(this,a,st).call(this,{allowStale:true}))e(this,V).call(this,i)&&(l(this,a,nt).call(this,e(this,A)[i],"expire"),t=true);return t}info(t){let i=e(this,H).get(t);if(i===void 0)return;let s=e(this,p)[i],n=l(this,a,E).call(this,s)?s.__staleWhileFetching:s;if(n===void 0)return;let o={value:n};if(e(this,k)&&e(this,X)){let r=e(this,k)[i],h=e(this,X)[i];if(r&&h){let f=r-(ft.now()-h);o.ttl=f,o.start=Date.now();}}return e(this,$)&&(o.size=e(this,$)[i]),o}dump(){let t=[];for(let i of l(this,a,it).call(this,{allowStale:true})){let s=e(this,A)[i],n=e(this,p)[i],o=l(this,a,E).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||s===void 0)continue;let r={value:o};if(e(this,k)&&e(this,X)){r.ttl=e(this,k)[i];let h=ft.now()-e(this,X)[i];r.start=Math.floor(Date.now()-h);}e(this,$)&&(r.size=e(this,$)[i]),t.unshift([s,r]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let n=Date.now()-s.start;s.start=ft.now()-n;}this.set(i,s.value,s);}}set(t,i,s={}){var T,P,Q;if(i===void 0)return this.delete(t),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:f}=s,{noUpdateTTL:g=this.noUpdateTTL}=s,b=e(this,St).call(this,t,i,s.size||0,h);if(this.maxEntrySize&&b>this.maxEntrySize)return f&&(f.set="miss",f.maxEntrySizeExceeded=true),l(this,a,nt).call(this,t,"set"),this;let m=e(this,O)===0?void 0:e(this,H).get(t);if(m===void 0)m=e(this,O)===0?e(this,I):e(this,q).length!==0?e(this,q).pop():e(this,O)===e(this,Y)?l(this,a,wt).call(this,false):e(this,O),e(this,A)[m]=t,e(this,p)[m]=i,e(this,H).set(t,m),e(this,D)[e(this,I)]=m,e(this,z)[m]=e(this,I),d(this,I,m),At(this,O)._++,e(this,gt).call(this,m,b,f),f&&(f.set="add"),g=false;else {l(this,a,mt).call(this,m);let _=e(this,p)[m];if(i!==_){if(e(this,rt)&&l(this,a,E).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=_;w!==void 0&&!r&&(e(this,J)&&((T=e(this,W))==null||T.call(this,w,t,"set")),e(this,N)&&e(this,v)?.push([w,t,"set"]));}else r||(e(this,J)&&((P=e(this,W))==null||P.call(this,_,t,"set")),e(this,N)&&e(this,v)?.push([_,t,"set"]));if(e(this,lt).call(this,m),e(this,gt).call(this,m,b,f),e(this,p)[m]=i,f){f.set="replace";let w=_&&l(this,a,E).call(this,_)?_.__staleWhileFetching:_;w!==void 0&&(f.oldValue=w);}}else f&&(f.set="update");}if(n!==0&&!e(this,k)&&l(this,a,Mt).call(this),e(this,k)&&(g||e(this,_t).call(this,m,n,o),f&&e(this,Z).call(this,f,m)),!r&&e(this,N)&&e(this,v)){let _=e(this,v),w;for(;w=_?.shift();)(Q=e(this,j))==null||Q.call(this,...w);}return this}pop(){var t;try{for(;e(this,O);){let i=e(this,p)[e(this,C)];if(l(this,a,wt).call(this,!0),l(this,a,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,N)&&e(this,v)){let i=e(this,v),s;for(;s=i?.shift();)(t=e(this,j))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:n}=i,o=e(this,H).get(t);if(o!==void 0){let r=e(this,p)[o];if(l(this,a,E).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(e(this,V).call(this,o))n&&(n.has="stale",e(this,Z).call(this,n,o));else return s&&e(this,ht).call(this,o),n&&(n.has="hit",e(this,Z).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,n=e(this,H).get(t);if(n===void 0||!s&&e(this,V).call(this,n))return;let o=e(this,p)[n];return l(this,a,E).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:f=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:b=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:T=this.allowStaleOnFetchRejection,ignoreFetchAbort:P=this.ignoreFetchAbort,allowStaleOnFetchAbort:Q=this.allowStaleOnFetchAbort,context:_,forceRefresh:w=false,status:S,signal:U}=i;if(!e(this,rt))return S&&(S.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:S});let G={allowStale:s,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:r,noDisposeOnSet:h,size:f,sizeCalculation:g,noUpdateTTL:b,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:Q,ignoreFetchAbort:P,status:S,signal:U},x=e(this,H).get(t);if(x===void 0){S&&(S.fetch="miss");let K=l(this,a,Tt).call(this,t,x,G,_);return K.__returned=K}else {let K=e(this,p)[x];if(l(this,a,E).call(this,K)){let Gt=s&&K.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",Gt&&(S.returnedStale=true)),Gt?K.__staleWhileFetching:K.__returned=K}let yt=e(this,V).call(this,x);if(!w&&!yt)return S&&(S.fetch="hit"),l(this,a,mt).call(this,x),n&&e(this,ht).call(this,x),S&&e(this,Z).call(this,S,x),K;let tt=l(this,a,Tt).call(this,t,x,G,_),It=tt.__staleWhileFetching!==void 0&&s;return S&&(S.fetch=yt?"stale":"refresh",It&&yt&&(S.returnedStale=true)),It?tt.__staleWhileFetching:tt.__returned=tt}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,pt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...r}=i,h=this.get(t,r);if(!o&&h!==void 0)return h;let f=s(t,h,{options:r,context:n});return this.set(t,f,r),f}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:r}=i,h=e(this,H).get(t);if(h!==void 0){let f=e(this,p)[h],g=l(this,a,E).call(this,f);return r&&e(this,Z).call(this,r,h),e(this,V).call(this,h)?(r&&(r.get="stale"),g?(r&&s&&f.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?f.__staleWhileFetching:void 0):(o||l(this,a,nt).call(this,t,"expire"),r&&s&&(r.returnedStale=true),s?f:void 0)):(r&&(r.get="hit"),g?f.__staleWhileFetching:(l(this,a,mt).call(this,h),n&&e(this,ht).call(this,h),f))}else r&&(r.get="miss");}delete(t){return l(this,a,nt).call(this,t,"delete")}clear(){return l(this,a,Nt).call(this,"delete")}};Y=new WeakMap,F=new WeakMap,W=new WeakMap,j=new WeakMap,dt=new WeakMap,pt=new WeakMap,O=new WeakMap,B=new WeakMap,H=new WeakMap,A=new WeakMap,p=new WeakMap,D=new WeakMap,z=new WeakMap,C=new WeakMap,I=new WeakMap,q=new WeakMap,v=new WeakMap,$=new WeakMap,X=new WeakMap,k=new WeakMap,J=new WeakMap,rt=new WeakMap,N=new WeakMap,a=new WeakSet,Mt=function(){let t=new ct(e(this,Y)),i=new ct(e(this,Y));d(this,k,t),d(this,X,i),d(this,_t,(o,r,h=ft.now())=>{if(i[o]=r!==0?h:0,t[o]=r,r!==0&&this.ttlAutopurge){let f=setTimeout(()=>{e(this,V).call(this,o)&&l(this,a,nt).call(this,e(this,A)[o],"expire");},r+1);f.unref&&f.unref();}}),d(this,ht,o=>{i[o]=t[o]!==0?ft.now():0;}),d(this,Z,(o,r)=>{if(t[r]){let h=t[r],f=i[r];if(!h||!f)return;o.ttl=h,o.start=f,o.now=s||n();let g=o.now-f;o.remainingTTL=h-g;}});let s=0,n=()=>{let o=ft.now();if(this.ttlResolution>0){s=o;let r=setTimeout(()=>s=0,this.ttlResolution);r.unref&&r.unref();}return o};this.getRemainingTTL=o=>{let r=e(this,H).get(o);if(r===void 0)return 0;let h=t[r],f=i[r];if(!h||!f)return 1/0;let g=(s||n())-f;return h-g},d(this,V,o=>{let r=i[o],h=t[o];return !!h&&!!r&&(s||n())-r>h});},ht=new WeakMap,Z=new WeakMap,_t=new WeakMap,V=new WeakMap,jt=function(){let t=new ct(e(this,Y));d(this,B,0),d(this,$,t),d(this,lt,i=>{d(this,B,e(this,B)-t[i]),t[i]=0;}),d(this,St,(i,s,n,o)=>{if(l(this,a,E).call(this,s))return 0;if(!et(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(s,i),!et(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}),d(this,gt,(i,s,n)=>{if(t[i]=s,e(this,F)){let o=e(this,F)-t[i];for(;e(this,B)>o;)l(this,a,wt).call(this,true);}d(this,B,e(this,B)+t[i]),n&&(n.entrySize=s,n.totalCalculatedSize=e(this,B));});},lt=new WeakMap,gt=new WeakMap,St=new WeakMap,it=function*({allowStale:t=this.allowStale}={}){if(e(this,O))for(let i=e(this,I);!(!l(this,a,Ct).call(this,i)||((t||!e(this,V).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,z)[i];},st=function*({allowStale:t=this.allowStale}={}){if(e(this,O))for(let i=e(this,C);!(!l(this,a,Ct).call(this,i)||((t||!e(this,V).call(this,i))&&(yield i),i===e(this,I)));)i=e(this,D)[i];},Ct=function(t){return t!==void 0&&e(this,H).get(e(this,A)[t])===t},wt=function(t){var o;let i=e(this,C),s=e(this,A)[i],n=e(this,p)[i];return e(this,rt)&&l(this,a,E).call(this,n)?n.__abortController.abort(new Error("evicted")):(e(this,J)||e(this,N))&&(e(this,J)&&((o=e(this,W))==null||o.call(this,n,s,"evict")),e(this,N)&&e(this,v)?.push([n,s,"evict"])),e(this,lt).call(this,i),t&&(e(this,A)[i]=void 0,e(this,p)[i]=void 0,e(this,q).push(i)),e(this,O)===1?(d(this,C,d(this,I,0)),e(this,q).length=0):d(this,C,e(this,D)[i]),e(this,H).delete(s),At(this,O)._--,i},Tt=function(t,i,s,n){let o=i===void 0?void 0:e(this,p)[i];if(l(this,a,E).call(this,o))return o;let r=new Ht,{signal:h}=s;h?.addEventListener("abort",()=>r.abort(h.reason),{signal:r.signal});let f={signal:r.signal,options:s,context:n},g=(_,w=false)=>{let{aborted:S}=r.signal,U=s.ignoreFetchAbort&&_!==void 0;if(s.status&&(S&&!w?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,U&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),S&&!U&&!w)return m(r.signal.reason);let G=P;return e(this,p)[i]===P&&(_===void 0?G.__staleWhileFetching?e(this,p)[i]=G.__staleWhileFetching:l(this,a,nt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,_,f.options))),_},b=_=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=_),m(_)),m=_=>{let{aborted:w}=r.signal,S=w&&s.allowStaleOnFetchAbort,U=S||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,x=P;if(e(this,p)[i]===P&&(!G||x.__staleWhileFetching===void 0?l(this,a,nt).call(this,t,"fetch"):S||(e(this,p)[i]=x.__staleWhileFetching)),U)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw _},T=(_,w)=>{var U;let S=(U=e(this,dt))==null?void 0:U.call(this,t,o,f);S&&S instanceof Promise&&S.then(G=>_(G===void 0?void 0:G),w),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(_(void 0),s.allowStaleOnFetchAbort&&(_=G=>g(G,true)));});};s.status&&(s.status.fetchDispatched=true);let P=new Promise(T).then(g,b),Q=Object.assign(P,{__abortController:r,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,Q,{...f.options,status:void 0}),i=e(this,H).get(t)):e(this,p)[i]=Q,Q},E=function(t){if(!e(this,rt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ht},Dt=function(t,i){e(this,z)[i]=t,e(this,D)[t]=i;},mt=function(t){t!==e(this,I)&&(t===e(this,C)?d(this,C,e(this,D)[t]):l(this,a,Dt).call(this,e(this,z)[t],e(this,D)[t]),l(this,a,Dt).call(this,e(this,I),t),d(this,I,t));},nt=function(t,i){var n,o;let s=false;if(e(this,O)!==0){let r=e(this,H).get(t);if(r!==void 0)if(s=true,e(this,O)===1)l(this,a,Nt).call(this,i);else {e(this,lt).call(this,r);let h=e(this,p)[r];if(l(this,a,E).call(this,h)?h.__abortController.abort(new Error("deleted")):(e(this,J)||e(this,N))&&(e(this,J)&&((n=e(this,W))==null||n.call(this,h,t,i)),e(this,N)&&e(this,v)?.push([h,t,i])),e(this,H).delete(t),e(this,A)[r]=void 0,e(this,p)[r]=void 0,r===e(this,I))d(this,I,e(this,z)[r]);else if(r===e(this,C))d(this,C,e(this,D)[r]);else {let f=e(this,z)[r];e(this,D)[f]=e(this,D)[r];let g=e(this,D)[r];e(this,z)[g]=e(this,z)[r];}At(this,O)._--,e(this,q).push(r);}}if(e(this,N)&&e(this,v)?.length){let r=e(this,v),h;for(;h=r?.shift();)(o=e(this,j))==null||o.call(this,...h);}return s},Nt=function(t){var i,s;for(let n of l(this,a,st).call(this,{allowStale:true})){let o=e(this,p)[n];if(l(this,a,E).call(this,o))o.__abortController.abort(new Error("deleted"));else {let r=e(this,A)[n];e(this,J)&&((i=e(this,W))==null||i.call(this,o,r,t)),e(this,N)&&e(this,v)?.push([o,r,t]);}}if(e(this,H).clear(),e(this,p).fill(void 0),e(this,A).fill(void 0),e(this,k)&&e(this,X)&&(e(this,k).fill(0),e(this,X).fill(0)),e(this,$)&&e(this,$).fill(0),d(this,C,0),d(this,I,0),e(this,q).length=0,d(this,B,0),d(this,O,0),e(this,N)&&e(this,v)){let n=e(this,v),o;for(;o=n?.shift();)(s=e(this,j))==null||s.call(this,...o);}};var Ot=Lt;var ot=class{cache;map=new Map;constructor(t){this.cache=new Ot({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var c=class u{static _diffHistory=new ot({cacheSize:5});static _stepsInfoHistory=new ot({cacheSize:5});static _narrationHistory=new ot({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return u._originalStepData?u._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){u._originalStepData=t;}};var M;(n=>(n.log=(o,...r)=>console.log(`[Pixi\u2019VN] ${o}`,...r),n.warn=(o,...r)=>console.warn(`[Pixi\u2019VN] ${o}`,...r),n.error=(o,...r)=>console.error(`[Pixi\u2019VN] ${o}`,...r),n.info=(o,...r)=>console.info(`[Pixi\u2019VN] ${o}`,...r)))(M||={});var bt=class{get stepsInfoMap(){return c._stepsInfoHistory}get diffMap(){return c._diffHistory}get narrationMap(){return c._narrationHistory}get size(){return c._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let t=null;for(let i of this.keys())(t===null||i>t)&&(t=i);return t}get lastDiffKey(){let t=null;for(let i of c._diffHistory.keys())(t===null||i>t)&&(t=i);return t}get goBackMode(){return c.goBackMode}set goBackMode(t){c.goBackMode=t;}keys(){return c._stepsInfoHistory.keys()}get(t){let i=c._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){c._stepsInfoHistory.delete(t),c._diffHistory.delete(t),c._narrationHistory.delete(t);}deleteFromKeyOnward(t){Array.from(this.keys()).filter(i=>i>=t).forEach(i=>{this.delete(i);});}previousCheckpointKey(t){let i=0;for(let s of c._diffHistory.keys())s<t&&s>i&&(i=s);return i}pendingInputRestoreValue;findPreviousInputAnswer(t){if(c._stepsInfoHistory.get(t-1)?.isRequiredInput)return c._stepsInfoHistory.get(t)?.inputValue}async getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastDiffKey;if(typeof s!="number")return M.warn("You can't go back, there is no step to go back"),i;let n=c._diffHistory.get(s);if(n)try{let o=await worker.restoreDiffMaybeOffloaded(i,n),r=this.previousCheckpointKey(s)+1;return core.GameUnifier.stepCounter=r,t===1&&(this.pendingInputRestoreValue=this.findPreviousInputAnswer(r)),this.deleteFromKeyOnward(r),this.getOldGameState(t-1,o)}catch(o){return M.error("Error applying diff",o),i}else return M.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){M.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){M.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(c._diffHistory.size<1){M.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{this.pendingInputRestoreValue=void 0;let n=await this.getOldGameState(s,c.originalStepData);if(n){await core.GameUnifier.restoreGameStepState(n,core.GameUnifier.navigate),this.pendingInputRestoreValue!==void 0&&core.GameUnifier.setVariable(zt,kt.CURRENT_INPUT_VALUE_MEMORY_KEY,this.pendingInputRestoreValue);let o=core.GameUnifier.stepCounter-1,r=c._stepsInfoHistory.get(o),h=c._narrationHistory.get(o),f=h&&Object.keys(h).length===1&&h.stepIndex!==void 0;if(r&&(f||r.isRequiredInput)){let g=this.itemMapper({step:r,inputValue:r.isRequiredInput?this.pendingInputRestoreValue:void 0});c._narrationHistory.set(r.index,g);}}else M.error("Error going back");c.originalStepData=n;}catch(n){M.error("Error going back",n);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}isCheckpointStep(t,i){if(c.goBackMode==="step"||t.choices&&t.choices.length>0||t.isRequiredInput)return true;let s=t.openedLabels??[],n=i?.openedLabels??[];return s.length!==n.length?true:s.some((o,r)=>o.label!==n[r]?.label)}async add(t,i={}){let s=c.originalStepData,{ignoreSameStep:n}=i,o=await core.GameUnifier.currentGameStepState;if(!n&&this.isSameStep(s,o))return;let r=this.lastKey,h=typeof r=="number"?c._stepsInfoHistory.get(r):void 0,f=t.index===0||this.isCheckpointStep(t,h);try{let g=typeof r=="number"?c._narrationHistory.get(r):void 0;c._stepsInfoHistory.set(t.index,t);let b={},m=this.itemMapper({step:t},b);if(c._narrationHistory.set(t.index,m),h&&g&&typeof r=="number"){let T=this.itemMapper({...b,step:h},{});c._narrationHistory.set(r,T);}}catch(g){M.error("Error adding history step",g);}t.index!==0&&f&&(async()=>{try{let g=await worker.diffMaybeOffloaded(s,o);g?c._diffHistory.set(t.index,g):M.warn("It was not possible to create the difference between the two steps");}catch(g){M.error("Error adding history step",g);}})(),(t.index===0||f)&&(c.originalStepData=o);}itemMapper(t,i){let{step:s,choiceIndexMade:n,inputValue:o,removeDialogue:r}=t,h=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),r&&(h=void 0);let f=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),h||f||o){let g=f?.map((b,m)=>{let T=false;return b.oneTime&&s.alreadyMadeChoices?.includes(m)&&(T=true),{text:b.text,type:b.type,isResponse:false,hidden:T}});if(g){if(g.every(b=>b.hidden)){let b=g.find(m=>m.hidden===false);b&&(b.hidden=false);}n!==void 0&&(g[n].isResponse=true);}return {dialogue:h?{...h,character:h.character?core.GameUnifier.getCharacter(h.character)||h.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:g,stepIndex:s.index,inputValue:o,openedLabelsNumber:s.openedLabels?.length}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,n)=>s-n).forEach(s=>{let n=this.get(s);n&&t.push(n);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((f,g)=>g-f);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let n=c._stepsInfoHistory.get(s);if(!n)return t;let o=n.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let r=o[0].currentStepIndex,h=o[0].label;return i.every((f,g)=>{let b=this.get(f);if(b){if(g===0)return t.push(b),true;let m=c._stepsInfoHistory.get(f);if(!m)return true;let T=m.openedLabels;if(!T||!Array.isArray(T)||T.length===0||T[0].label!==h||T[0].currentStepIndex>r)return false;r=T[0].currentStepIndex,t.push(b);}return true}),t.reverse()}get currentPageParagraphs(){let t=[],i;return this.currentLabelHistory.forEach(s=>{t.length===0||s.openedLabelsNumber!==i?t.push([s]):t[t.length-1].push(s),i=s.openedLabelsNumber;}),t}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,n)=>s-n);i=i.slice(0,t),i.forEach(s=>{c._narrationHistory.delete(s),c._stepsInfoHistory.delete(s),c._diffHistory.delete(s);});}else c._stepsInfoHistory.clear(),c._diffHistory.clear(),c._narrationHistory.clear();}get canGoBack(){return c._diffHistory.size>0}blockGoBack(){core.GameUnifier.runningStepsCount===0&&c._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),n=JSON.stringify(i.openedLabels);if(s===n&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return M.error("Error comparing opened labels",s),true}return false}clear(){c._stepsInfoHistory.clear(),c._diffHistory.clear(),c._narrationHistory.clear(),c._originalStepData=void 0;}get stepLimitSaved(){return c.stepLimitSaved}set stepLimitSaved(t){c.stepLimitSaved=t;}async export(){let t=Array.from(this.keys()).sort((r,h)=>r-h);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];t.forEach(r=>{let h=c._stepsInfoHistory.get(r);if(h){let f=c._diffHistory.get(r);i.push({...h,diff:f});}});let s=c._originalStepData,[n,o]=await Promise.all([worker.cloneMaybeOffloaded(i),s?worker.cloneMaybeOffloaded(s):void 0]);return {stepsHistory:n,originalStepData:o}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,n)=>s-n),i={};t.forEach(s=>{let n=c._stepsInfoHistory.get(s);if(n){let o={...i};i={};let r=this.itemMapper({step:n,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);r&&c._narrationHistory.set(s,r);}});}async restore(t){this.clear();try{Object.hasOwn(t,"stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&c._diffHistory.set(s.index,s.diff);let n={...s,diff:void 0};c._stepsInfoHistory.set(s.index,n);}),this.restoreNarrativeHistory()):M.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?c._originalStepData=t.originalStepData:M.warn("Could not import originalStepData data, so will be ignored");}catch(i){M.error("Error importing data",i);}}};var Se=new bt;exports.HistoryManagerStatic=c;exports.stepHistory=Se;
|
package/dist/history.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GameStepState, HistoryInfo } from '@drincs/pixi-vn';
|
|
2
2
|
import { Difference } from 'microdiff';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { CachedMap } from './index.cjs';
|
|
4
|
+
import { HistoryStep } from './narration.cjs';
|
|
5
5
|
import { H as HistoryGameState } from './HistoryGameState-CGfvq5iL.cjs';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { StepLabelPropsType, StepLabelResultType } from './narration.cjs';
|
|
7
|
+
import { NarrationHistory } from './narration.cjs';
|
|
8
8
|
import 'lru-cache';
|
|
9
9
|
import '@drincs/pixi-vn/canvas';
|
|
10
10
|
import './StorageElementType-C7ETezlL.cjs';
|
|
@@ -175,6 +175,11 @@ interface HistoryManagerInterface {
|
|
|
175
175
|
restore(data: object): Promise<void>;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
/**
|
|
179
|
+
* The global history manager instance. It records the narration steps (dialogues, choices, labels)
|
|
180
|
+
* so the player can go back to previous steps and review what happened.
|
|
181
|
+
*/
|
|
178
182
|
declare const stepHistory: HistoryManagerInterface;
|
|
179
183
|
|
|
180
|
-
export { HistoryGameState,
|
|
184
|
+
export { HistoryGameState, HistoryManagerStatic, stepHistory };
|
|
185
|
+
export type { HistoryGoBackModeType, HistoryManagerInterface };
|
package/dist/history.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { GameStepState, HistoryInfo } from '@drincs/pixi-vn';
|
|
2
2
|
import { Difference } from 'microdiff';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { CachedMap } from './index.js';
|
|
4
|
+
import { HistoryStep } from './narration.js';
|
|
5
5
|
import { H as HistoryGameState } from './HistoryGameState-C8ATx9K6.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { StepLabelPropsType, StepLabelResultType } from './narration.js';
|
|
7
|
+
import { NarrationHistory } from './narration.js';
|
|
8
8
|
import 'lru-cache';
|
|
9
9
|
import '@drincs/pixi-vn/canvas';
|
|
10
10
|
import './StorageElementType-C7ETezlL.js';
|
|
@@ -175,6 +175,11 @@ interface HistoryManagerInterface {
|
|
|
175
175
|
restore(data: object): Promise<void>;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
/**
|
|
179
|
+
* The global history manager instance. It records the narration steps (dialogues, choices, labels)
|
|
180
|
+
* so the player can go back to previous steps and review what happened.
|
|
181
|
+
*/
|
|
178
182
|
declare const stepHistory: HistoryManagerInterface;
|
|
179
183
|
|
|
180
|
-
export { HistoryGameState,
|
|
184
|
+
export { HistoryGameState, HistoryManagerStatic, stepHistory };
|
|
185
|
+
export type { HistoryGoBackModeType, HistoryManagerInterface };
|
package/dist/history.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-JMOSOAGB.mjs';import {k,m as m$1}from'./chunk-HD353M4B.mjs';import {d,e}from'./chunk-
|
|
1
|
+
import'./chunk-JMOSOAGB.mjs';import {k,m as m$1}from'./chunk-HD353M4B.mjs';import {d,e}from'./chunk-B46NFIFC.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import {restoreDiffMaybeOffloaded,diffMaybeOffloaded,cloneMaybeOffloaded}from'@drincs/pixi-vn/worker';var i=class g{static _diffHistory=new d({cacheSize:5});static _stepsInfoHistory=new d({cacheSize:5});static _narrationHistory=new d({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return g._originalStepData?g._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){g._originalStepData=e;}};var m=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let e=null;for(let r of this.keys())(e===null||r>e)&&(e=r);return e}get lastDiffKey(){let e=null;for(let r of i._diffHistory.keys())(e===null||r>e)&&(e=r);return e}get goBackMode(){return i.goBackMode}set goBackMode(e){i.goBackMode=e;}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}deleteFromKeyOnward(e){Array.from(this.keys()).filter(r=>r>=e).forEach(r=>{this.delete(r);});}previousCheckpointKey(e){let r=0;for(let t of i._diffHistory.keys())t<e&&t>r&&(r=t);return r}pendingInputRestoreValue;findPreviousInputAnswer(e){if(i._stepsInfoHistory.get(e-1)?.isRequiredInput)return i._stepsInfoHistory.get(e)?.inputValue}async getOldGameState(e$1,r){if(e$1<=0||this.size===0)return r;let t=this.lastDiffKey;if(typeof t!="number")return e.warn("You can't go back, there is no step to go back"),r;let n=i._diffHistory.get(t);if(n)try{let s=await restoreDiffMaybeOffloaded(r,n),a=this.previousCheckpointKey(t)+1;return GameUnifier.stepCounter=a,e$1===1&&(this.pendingInputRestoreValue=this.findPreviousInputAnswer(a)),this.deleteFromKeyOnward(a),this.getOldGameState(e$1-1,s)}catch(s){return e.error("Error applying diff",s),r}else return e.warn("No diff found for the last step, cannot go back"),r}async back(e$1,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){e.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){e.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){e.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{this.pendingInputRestoreValue=void 0;let n=await this.getOldGameState(t,i.originalStepData);if(n){await GameUnifier.restoreGameStepState(n,GameUnifier.navigate),this.pendingInputRestoreValue!==void 0&&GameUnifier.setVariable(k,m$1.CURRENT_INPUT_VALUE_MEMORY_KEY,this.pendingInputRestoreValue);let s=GameUnifier.stepCounter-1,a=i._stepsInfoHistory.get(s),o=i._narrationHistory.get(s),c=o&&Object.keys(o).length===1&&o.stepIndex!==void 0;if(a&&(c||a.isRequiredInput)){let p=this.itemMapper({step:a,inputValue:a.isRequiredInput?this.pendingInputRestoreValue:void 0});i._narrationHistory.set(a.index,p);}}else e.error("Error going back");i.originalStepData=n;}catch(n){e.error("Error going back",n);}if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1)}isCheckpointStep(e,r){if(i.goBackMode==="step"||e.choices&&e.choices.length>0||e.isRequiredInput)return true;let t=e.openedLabels??[],n=r?.openedLabels??[];return t.length!==n.length?true:t.some((s,a)=>s.label!==n[a]?.label)}async add(e$1,r={}){let t=i.originalStepData,{ignoreSameStep:n}=r,s=await GameUnifier.currentGameStepState;if(!n&&this.isSameStep(t,s))return;let a=this.lastKey,o=typeof a=="number"?i._stepsInfoHistory.get(a):void 0,c=e$1.index===0||this.isCheckpointStep(e$1,o);try{let p=typeof a=="number"?i._narrationHistory.get(a):void 0;i._stepsInfoHistory.set(e$1.index,e$1);let u={},y=this.itemMapper({step:e$1},u);if(i._narrationHistory.set(e$1.index,y),o&&p&&typeof a=="number"){let d=this.itemMapper({...u,step:o},{});i._narrationHistory.set(a,d);}}catch(p){e.error("Error adding history step",p);}e$1.index!==0&&c&&(async()=>{try{let p=await diffMaybeOffloaded(t,s);p?i._diffHistory.set(e$1.index,p):e.warn("It was not possible to create the difference between the two steps");}catch(p){e.error("Error adding history step",p);}})(),(e$1.index===0||c)&&(i.originalStepData=s);}itemMapper(e,r){let{step:t,choiceIndexMade:n,inputValue:s,removeDialogue:a}=e,o=t.dialogue;r&&t.isGlued&&(r.removeDialogue=true),a&&(o=void 0);let c=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||c||s){let p=c?.map((u,y)=>{let d=false;return u.oneTime&&t.alreadyMadeChoices?.includes(y)&&(d=true),{text:u.text,type:u.type,isResponse:false,hidden:d}});if(p){if(p.every(u=>u.hidden)){let u=p.find(y=>y.hidden===false);u&&(u.hidden=false);}n!==void 0&&(p[n].isResponse=true);}return {dialogue:o?{...o,character:o.character?GameUnifier.getCharacter(o.character)||o.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:p,stepIndex:t.index,inputValue:s,openedLabelsNumber:t.openedLabels?.length}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,n)=>t-n).forEach(t=>{let n=this.get(t);n&&e.push(n);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((c,p)=>p-c);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let n=i._stepsInfoHistory.get(t);if(!n)return e;let s=n.openedLabels;if(!s||!Array.isArray(s)||s.length===0)return e;let a=s[0].currentStepIndex,o=s[0].label;return r.every((c,p)=>{let u=this.get(c);if(u){if(p===0)return e.push(u),true;let y=i._stepsInfoHistory.get(c);if(!y)return true;let d=y.openedLabels;if(!d||!Array.isArray(d)||d.length===0||d[0].label!==o||d[0].currentStepIndex>a)return false;a=d[0].currentStepIndex,e.push(u);}return true}),e.reverse()}get currentPageParagraphs(){let e=[],r;return this.currentLabelHistory.forEach(t=>{e.length===0||t.openedLabelsNumber!==r?e.push([t]):e[e.length-1].push(t),r=t.openedLabelsNumber;}),e}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,n)=>t-n);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){return i._diffHistory.size>0}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e$1,r){if(e$1.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e$1.openedLabels),n=JSON.stringify(r.openedLabels);if(t===n&&e$1.path===r.path&&e$1.labelIndex===r.labelIndex)return !0}catch(t){return e.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}async export(){let e=Array.from(this.keys()).sort((a,o)=>a-o);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];e.forEach(a=>{let o=i._stepsInfoHistory.get(a);if(o){let c=i._diffHistory.get(a);r.push({...o,diff:c});}});let t=i._originalStepData,[n,s]=await Promise.all([cloneMaybeOffloaded(r),t?cloneMaybeOffloaded(t):void 0]);return {stepsHistory:n,originalStepData:s}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,n)=>t-n),r={};e.forEach(t=>{let n=i._stepsInfoHistory.get(t);if(n){let s={...r};r={};let a=this.itemMapper({step:n,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},r);a&&i._narrationHistory.set(t,a);}});}async restore(e$1){this.clear();try{Object.hasOwn(e$1,"stepsHistory")?(e$1.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let n={...t,diff:void 0};i._stepsInfoHistory.set(t.index,n);}),this.restoreNarrativeHistory()):e.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(e$1,"originalStepData")?i._originalStepData=e$1.originalStepData:e.warn("Could not import originalStepData data, so will be ignored");}catch(r){e.error("Error importing data",r);}}};var N=new m;export{i as HistoryManagerStatic,N as stepHistory};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var D=require('@drincs/pixi-vn/canvas'),Xt=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),ot=require('@drincs/pixi-vn/history'),O=require('@drincs/pixi-vn/narration'),_t=require('@drincs/pixi-vn/sound'),W=require('@drincs/pixi-vn/storage'),tickers=require('@drincs/pixi-vn/tickers'),worker=require('@drincs/pixi-vn/worker'),motion=require('@drincs/pixi-vn/motion');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var D__namespace=/*#__PURE__*/_interopNamespace(D);var Xt__namespace=/*#__PURE__*/_interopNamespace(Xt);var ot__namespace=/*#__PURE__*/_interopNamespace(ot);var O__namespace=/*#__PURE__*/_interopNamespace(O);var _t__namespace=/*#__PURE__*/_interopNamespace(_t);var W__namespace=/*#__PURE__*/_interopNamespace(W);var Jt=Object.defineProperty;var Qt=l=>{throw TypeError(l)};var be=(l,e,i)=>e in l?Jt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var Se=(l,e)=>{for(var i in e)Jt(l,i,{get:e[i],enumerable:true});};var F=(l,e,i)=>be(l,typeof e!="symbol"?e+"":e,i),Ft=(l,e,i)=>e.has(l)||Qt("Cannot "+i);var t=(l,e,i)=>(Ft(l,e,"read from private field"),i?i.call(l):e.get(l)),b=(l,e,i)=>e.has(l)?Qt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),u=(l,e,i,s)=>(Ft(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(Ft(l,e,"access private method"),i);var Pt=(l,e,i,s)=>({set _(r){u(l,e,r);},get _(){return t(l,e,s)}});var Te=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ie=new Set,Mt=typeof process=="object"&&process?process:{},se=(l,e,i,s)=>{typeof Mt.emitWarning=="function"?Mt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},jt=globalThis.AbortController,Zt=globalThis.AbortSignal;if(typeof jt>"u"){Zt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},jt=class{constructor(){e();}signal=new Zt;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=Mt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,se("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 we=l=>!ie.has(l);var dt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),re=l=>dt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?It:null:null,It=class extends Array{constructor(l){super(l),this.fill(0);}},lt,St,xe=(lt=class{heap;length;static create(e){let i=re(e);if(!i)return [];u(lt,St,true);let s=new lt(e,i);return u(lt,St,false),s}constructor(e,i){if(!t(lt,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,b(lt,St,false),lt),te,ee,X,K,Q,vt,Z,Tt,wt,tt,I,et,R,E,_,k,Y,z,G,it,j,st,rt,q,B,nt,mt,V,xt,a,zt,yt,ht,Ot,$,oe,bt,Et,Lt,pt,ut,kt,Ct,Gt,x,Vt,At,ft,Ht,Ut,ne=(Ut=class{constructor(e){b(this,a);b(this,X);b(this,K);b(this,Q);b(this,vt);b(this,Z);b(this,Tt);b(this,wt);b(this,tt);F(this,"ttl");F(this,"ttlResolution");F(this,"ttlAutopurge");F(this,"updateAgeOnGet");F(this,"updateAgeOnHas");F(this,"allowStale");F(this,"noDisposeOnSet");F(this,"noUpdateTTL");F(this,"maxEntrySize");F(this,"sizeCalculation");F(this,"noDeleteOnFetchRejection");F(this,"noDeleteOnStaleGet");F(this,"allowStaleOnFetchAbort");F(this,"allowStaleOnFetchRejection");F(this,"ignoreFetchAbort");b(this,I);b(this,et);b(this,R);b(this,E);b(this,_);b(this,k);b(this,Y);b(this,z);b(this,G);b(this,it);b(this,j);b(this,st);b(this,rt);b(this,q);b(this,B);b(this,nt);b(this,mt);b(this,V);b(this,xt);b(this,yt,()=>{});b(this,ht,()=>{});b(this,Ot,()=>{});b(this,$,()=>false);b(this,bt,e=>{});b(this,Et,(e,i,s)=>{});b(this,Lt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});F(this,te,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:h,allowStale:d,dispose:y,onInsert:U,disposeAfter:S,noDisposeOnSet:M,noUpdateTTL:N,maxSize:H=0,maxEntrySize:m=0,sizeCalculation:v,fetchMethod:g,memoMethod:L,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:p,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:at,ignoreFetchAbort:f,perf:w}=e;if(w!==void 0&&typeof w?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,tt,w??Te),i!==0&&!dt(i))throw new TypeError("max option must be a nonnegative integer");let C=i?re(i):Array;if(!C)throw new Error("invalid max value: "+i);if(u(this,X,i),u(this,K,H),this.maxEntrySize=m||t(this,K),this.sizeCalculation=v,this.sizeCalculation){if(!t(this,K)&&!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(L!==void 0&&typeof L!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,wt,L),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,Tt,g),u(this,mt,!!g),u(this,R,new Map),u(this,E,new Array(i).fill(void 0)),u(this,_,new Array(i).fill(void 0)),u(this,k,new C(i)),u(this,Y,new C(i)),u(this,z,0),u(this,G,0),u(this,it,xe.create(i)),u(this,I,0),u(this,et,0),typeof y=="function"&&u(this,Q,y),typeof U=="function"&&u(this,vt,U),typeof S=="function"?(u(this,Z,S),u(this,j,[])):(u(this,Z,void 0),u(this,j,void 0)),u(this,nt,!!t(this,Q)),u(this,xt,!!t(this,vt)),u(this,V,!!t(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!at,this.ignoreFetchAbort=!!f,this.maxEntrySize!==0){if(t(this,K)!==0&&!dt(t(this,K)))throw new TypeError("maxSize must be a positive integer if specified");if(!dt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,oe).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!p,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!h,this.ttlResolution=dt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!dt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,zt).call(this);}if(t(this,X)===0&&this.ttl===0&&t(this,K)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,X)&&!t(this,K)){let J="LRU_CACHE_UNBOUNDED";we(J)&&(ie.add(J),se("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",J,Ut));}}get perf(){return t(this,tt)}static unsafeExposeInternals(e){return {starts:t(e,rt),ttls:t(e,q),autopurgeTimers:t(e,B),sizes:t(e,st),keyMap:t(e,R),keyList:t(e,E),valList:t(e,_),next:t(e,k),prev:t(e,Y),get head(){return t(e,z)},get tail(){return t(e,G)},free:t(e,it),isBackgroundFetch:i=>{var s;return c(s=e,a,x).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=e,a,Gt).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=e,a,At).call(s,i)},indexes:i=>{var s;return c(s=e,a,pt).call(s,i)},rindexes:i=>{var s;return c(s=e,a,ut).call(s,i)},isStale:i=>{var s;return t(s=e,$).call(s,i)}}}get max(){return t(this,X)}get maxSize(){return t(this,K)}get calculatedSize(){return t(this,et)}get size(){return t(this,I)}get fetchMethod(){return t(this,Tt)}get memoMethod(){return t(this,wt)}get dispose(){return t(this,Q)}get onInsert(){return t(this,vt)}get disposeAfter(){return t(this,Z)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of c(this,a,pt).call(this))t(this,_)[e]!==void 0&&t(this,E)[e]!==void 0&&!c(this,a,x).call(this,t(this,_)[e])&&(yield [t(this,E)[e],t(this,_)[e]]);}*rentries(){for(let e of c(this,a,ut).call(this))t(this,_)[e]!==void 0&&t(this,E)[e]!==void 0&&!c(this,a,x).call(this,t(this,_)[e])&&(yield [t(this,E)[e],t(this,_)[e]]);}*keys(){for(let e of c(this,a,pt).call(this)){let i=t(this,E)[e];i!==void 0&&!c(this,a,x).call(this,t(this,_)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,ut).call(this)){let i=t(this,E)[e];i!==void 0&&!c(this,a,x).call(this,t(this,_)[e])&&(yield i);}}*values(){for(let e of c(this,a,pt).call(this))t(this,_)[e]!==void 0&&!c(this,a,x).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}*rvalues(){for(let e of c(this,a,ut).call(this))t(this,_)[e]!==void 0&&!c(this,a,x).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}[(ee=Symbol.iterator,te=Symbol.toStringTag,ee)](){return this.entries()}find(e,i={}){for(let s of c(this,a,pt).call(this)){let r=t(this,_)[s],o=c(this,a,x).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,E)[s],this))return this.get(t(this,E)[s],i)}}forEach(e,i=this){for(let s of c(this,a,pt).call(this)){let r=t(this,_)[s],o=c(this,a,x).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,E)[s],this);}}rforEach(e,i=this){for(let s of c(this,a,ut).call(this)){let r=t(this,_)[s],o=c(this,a,x).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,E)[s],this);}}purgeStale(){let e=false;for(let i of c(this,a,ut).call(this,{allowStale:true}))t(this,$).call(this,i)&&(c(this,a,ft).call(this,t(this,E)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,_)[i],r=c(this,a,x).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,q)&&t(this,rt)){let n=t(this,q)[i],h=t(this,rt)[i];if(n&&h){let d=n-(t(this,tt).now()-h);o.ttl=d,o.start=Date.now();}}return t(this,st)&&(o.size=t(this,st)[i]),o}dump(){let e=[];for(let i of c(this,a,pt).call(this,{allowStale:true})){let s=t(this,E)[i],r=t(this,_)[i],o=c(this,a,x).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(t(this,q)&&t(this,rt)){n.ttl=t(this,q)[i];let h=t(this,tt).now()-t(this,rt)[i];n.start=Math.floor(Date.now()-h);}t(this,st)&&(n.size=t(this,st)[i]),e.unshift([s,n]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,tt).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var M,N,H,m;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:d}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,U=t(this,Lt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&U>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),c(this,a,ft).call(this,e,"set"),this;let S=t(this,I)===0?void 0:t(this,R).get(e);if(S===void 0)S=t(this,I)===0?t(this,G):t(this,it).length!==0?t(this,it).pop():t(this,I)===t(this,X)?c(this,a,Ct).call(this,false):t(this,I),t(this,E)[S]=e,t(this,_)[S]=i,t(this,R).set(e,S),t(this,k)[t(this,G)]=S,t(this,Y)[S]=t(this,G),u(this,G,S),Pt(this,I)._++,t(this,Et).call(this,S,U,d),d&&(d.set="add"),y=false,t(this,xt)&&((M=t(this,vt))==null||M.call(this,i,e,"add"));else {c(this,a,At).call(this,S);let v=t(this,_)[S];if(i!==v){if(t(this,mt)&&c(this,a,x).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=v;g!==void 0&&!n&&(t(this,nt)&&((N=t(this,Q))==null||N.call(this,g,e,"set")),t(this,V)&&t(this,j)?.push([g,e,"set"]));}else n||(t(this,nt)&&((H=t(this,Q))==null||H.call(this,v,e,"set")),t(this,V)&&t(this,j)?.push([v,e,"set"]));if(t(this,bt).call(this,S),t(this,Et).call(this,S,U,d),t(this,_)[S]=i,d){d.set="replace";let g=v&&c(this,a,x).call(this,v)?v.__staleWhileFetching:v;g!==void 0&&(d.oldValue=g);}}else d&&(d.set="update");t(this,xt)&&this.onInsert?.(i,e,i===v?"update":"replace");}if(r!==0&&!t(this,q)&&c(this,a,zt).call(this),t(this,q)&&(y||t(this,Ot).call(this,S,r,o),d&&t(this,ht).call(this,d,S)),!n&&t(this,V)&&t(this,j)){let v=t(this,j),g;for(;g=v?.shift();)(m=t(this,Z))==null||m.call(this,...g);}return this}pop(){var e;try{for(;t(this,I);){let i=t(this,_)[t(this,z)];if(c(this,a,Ct).call(this,!0),c(this,a,x).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,j)){let i=t(this,j),s;for(;s=i?.shift();)(e=t(this,Z))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,R).get(e);if(o!==void 0){let n=t(this,_)[o];if(c(this,a,x).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(t(this,$).call(this,o))r&&(r.has="stale",t(this,ht).call(this,r,o));else return s&&t(this,yt).call(this,o),r&&(r.has="hit",t(this,ht).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,R).get(e);if(r===void 0||!s&&t(this,$).call(this,r))return;let o=t(this,_)[r];return c(this,a,x).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:d=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:U=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:m,forceRefresh:v=false,status:g,signal:L}=i;if(!t(this,mt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let A={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:h,size:d,sizeCalculation:y,noUpdateTTL:U,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:H,ignoreFetchAbort:N,status:g,signal:L},p=t(this,R).get(e);if(p===void 0){g&&(g.fetch="miss");let T=c(this,a,Gt).call(this,e,p,A,m);return T.__returned=T}else {let T=t(this,_)[p];if(c(this,a,x).call(this,T)){let C=s&&T.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",C&&(g.returnedStale=true)),C?T.__staleWhileFetching:T.__returned=T}let at=t(this,$).call(this,p);if(!v&&!at)return g&&(g.fetch="hit"),c(this,a,At).call(this,p),r&&t(this,yt).call(this,p),g&&t(this,ht).call(this,g,p),T;let f=c(this,a,Gt).call(this,e,p,A,m),w=f.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=at?"stale":"refresh",w&&at&&(g.returnedStale=true)),w?f.__staleWhileFetching:f.__returned=f}}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,wt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,h=this.get(e,n);if(!o&&h!==void 0)return h;let d=s(e,h,{options:n,context:r});return this.set(e,d,n),d}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,h=t(this,R).get(e);if(h!==void 0){let d=t(this,_)[h],y=c(this,a,x).call(this,d);return n&&t(this,ht).call(this,n,h),t(this,$).call(this,h)?(n&&(n.get="stale"),y?(n&&s&&d.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?d.__staleWhileFetching:void 0):(o||c(this,a,ft).call(this,e,"expire"),n&&s&&(n.returnedStale=true),s?d:void 0)):(n&&(n.get="hit"),y?d.__staleWhileFetching:(c(this,a,At).call(this,h),r&&t(this,yt).call(this,h),d))}else n&&(n.get="miss");}delete(e){return c(this,a,ft).call(this,e,"delete")}clear(){return c(this,a,Ht).call(this,"delete")}},X=new WeakMap,K=new WeakMap,Q=new WeakMap,vt=new WeakMap,Z=new WeakMap,Tt=new WeakMap,wt=new WeakMap,tt=new WeakMap,I=new WeakMap,et=new WeakMap,R=new WeakMap,E=new WeakMap,_=new WeakMap,k=new WeakMap,Y=new WeakMap,z=new WeakMap,G=new WeakMap,it=new WeakMap,j=new WeakMap,st=new WeakMap,rt=new WeakMap,q=new WeakMap,B=new WeakMap,nt=new WeakMap,mt=new WeakMap,V=new WeakMap,xt=new WeakMap,a=new WeakSet,zt=function(){let e=new It(t(this,X)),i=new It(t(this,X));u(this,q,e),u(this,rt,i);let s=this.ttlAutopurge?new Array(t(this,X)):void 0;u(this,B,s),u(this,Ot,(h,d,y=t(this,tt).now())=>{i[h]=d!==0?y:0,e[h]=d,r(h,d);}),u(this,yt,h=>{i[h]=e[h]!==0?t(this,tt).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,d)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),d&&d!==0&&s){let y=setTimeout(()=>{t(this,$).call(this,h)&&c(this,a,ft).call(this,t(this,E)[h],"expire");},d+1);y.unref&&y.unref(),s[h]=y;}}:()=>{};u(this,ht,(h,d)=>{if(e[d]){let y=e[d],U=i[d];if(!y||!U)return;h.ttl=y,h.start=U,h.now=o||n();let S=h.now-U;h.remainingTTL=y-S;}});let o=0,n=()=>{let h=t(this,tt).now();if(this.ttlResolution>0){o=h;let d=setTimeout(()=>o=0,this.ttlResolution);d.unref&&d.unref();}return h};this.getRemainingTTL=h=>{let d=t(this,R).get(h);if(d===void 0)return 0;let y=e[d],U=i[d];if(!y||!U)return 1/0;let S=(o||n())-U;return y-S},u(this,$,h=>{let d=i[h],y=e[h];return !!y&&!!d&&(o||n())-d>y});},yt=new WeakMap,ht=new WeakMap,Ot=new WeakMap,$=new WeakMap,oe=function(){let e=new It(t(this,X));u(this,et,0),u(this,st,e),u(this,bt,i=>{u(this,et,t(this,et)-e[i]),e[i]=0;}),u(this,Lt,(i,s,r,o)=>{if(c(this,a,x).call(this,s))return 0;if(!dt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!dt(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}),u(this,Et,(i,s,r)=>{if(e[i]=s,t(this,K)){let o=t(this,K)-e[i];for(;t(this,et)>o;)c(this,a,Ct).call(this,true);}u(this,et,t(this,et)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,et));});},bt=new WeakMap,Et=new WeakMap,Lt=new WeakMap,pt=function*({allowStale:e=this.allowStale}={}){if(t(this,I))for(let i=t(this,G);!(!c(this,a,kt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,z)));)i=t(this,Y)[i];},ut=function*({allowStale:e=this.allowStale}={}){if(t(this,I))for(let i=t(this,z);!(!c(this,a,kt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,G)));)i=t(this,k)[i];},kt=function(e){return e!==void 0&&t(this,R).get(t(this,E)[e])===e},Ct=function(e){var o;let i=t(this,z),s=t(this,E)[i],r=t(this,_)[i];return t(this,mt)&&c(this,a,x).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,nt)||t(this,V))&&(t(this,nt)&&((o=t(this,Q))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,j)?.push([r,s,"evict"])),t(this,bt).call(this,i),t(this,B)?.[i]&&(clearTimeout(t(this,B)[i]),t(this,B)[i]=void 0),e&&(t(this,E)[i]=void 0,t(this,_)[i]=void 0,t(this,it).push(i)),t(this,I)===1?(u(this,z,u(this,G,0)),t(this,it).length=0):u(this,z,t(this,k)[i]),t(this,R).delete(s),Pt(this,I)._--,i},Gt=function(e,i,s,r){let o=i===void 0?void 0:t(this,_)[i];if(c(this,a,x).call(this,o))return o;let n=new jt,{signal:h}=s;h?.addEventListener("abort",()=>n.abort(h.reason),{signal:n.signal});let d={signal:n.signal,options:s,context:r},y=(m,v=false)=>{let{aborted:g}=n.signal,L=s.ignoreFetchAbort&&m!==void 0,A=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&m!==void 0);if(s.status&&(g&&!v?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,L&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!L&&!v)return S(n.signal.reason,A);let p=N,T=t(this,_)[i];return (T===N||L&&v&&T===void 0)&&(m===void 0?p.__staleWhileFetching!==void 0?t(this,_)[i]=p.__staleWhileFetching:c(this,a,ft).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,m,d.options))),m},U=m=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=m),S(m,false)),S=(m,v)=>{let{aborted:g}=n.signal,L=g&&s.allowStaleOnFetchAbort,A=L||s.allowStaleOnFetchRejection,p=A||s.noDeleteOnFetchRejection,T=N;if(t(this,_)[i]===N&&(!p||!v&&T.__staleWhileFetching===void 0?c(this,a,ft).call(this,e,"fetch"):L||(t(this,_)[i]=T.__staleWhileFetching)),A)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw m},M=(m,v)=>{var L;let g=(L=t(this,Tt))==null?void 0:L.call(this,e,o,d);g&&g instanceof Promise&&g.then(A=>m(A===void 0?void 0:A),v),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(m(void 0),s.allowStaleOnFetchAbort&&(m=A=>y(A,true)));});};s.status&&(s.status.fetchDispatched=true);let N=new Promise(M).then(y,U),H=Object.assign(N,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,H,{...d.options,status:void 0}),i=t(this,R).get(e)):t(this,_)[i]=H,H},x=function(e){if(!t(this,mt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof jt},Vt=function(e,i){t(this,Y)[i]=e,t(this,k)[e]=i;},At=function(e){e!==t(this,G)&&(e===t(this,z)?u(this,z,t(this,k)[e]):c(this,a,Vt).call(this,t(this,Y)[e],t(this,k)[e]),c(this,a,Vt).call(this,t(this,G),e),u(this,G,e));},ft=function(e,i){var r,o;let s=false;if(t(this,I)!==0){let n=t(this,R).get(e);if(n!==void 0)if(t(this,B)?.[n]&&(clearTimeout(t(this,B)?.[n]),t(this,B)[n]=void 0),s=true,t(this,I)===1)c(this,a,Ht).call(this,i);else {t(this,bt).call(this,n);let h=t(this,_)[n];if(c(this,a,x).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,nt)||t(this,V))&&(t(this,nt)&&((r=t(this,Q))==null||r.call(this,h,e,i)),t(this,V)&&t(this,j)?.push([h,e,i])),t(this,R).delete(e),t(this,E)[n]=void 0,t(this,_)[n]=void 0,n===t(this,G))u(this,G,t(this,Y)[n]);else if(n===t(this,z))u(this,z,t(this,k)[n]);else {let d=t(this,Y)[n];t(this,k)[d]=t(this,k)[n];let y=t(this,k)[n];t(this,Y)[y]=t(this,Y)[n];}Pt(this,I)._--,t(this,it).push(n);}}if(t(this,V)&&t(this,j)?.length){let n=t(this,j),h;for(;h=n?.shift();)(o=t(this,Z))==null||o.call(this,...h);}return s},Ht=function(e){var i,s;for(let r of c(this,a,ut).call(this,{allowStale:true})){let o=t(this,_)[r];if(c(this,a,x).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=t(this,E)[r];t(this,nt)&&((i=t(this,Q))==null||i.call(this,o,n,e)),t(this,V)&&t(this,j)?.push([o,n,e]);}}if(t(this,R).clear(),t(this,_).fill(void 0),t(this,E).fill(void 0),t(this,q)&&t(this,rt)){t(this,q).fill(0),t(this,rt).fill(0);for(let r of t(this,B)??[])r!==void 0&&clearTimeout(r);t(this,B)?.fill(void 0);}if(t(this,st)&&t(this,st).fill(0),u(this,z,0),u(this,G,0),t(this,it).length=0,u(this,et,0),u(this,I,0),t(this,V)&&t(this,j)){let r=t(this,j),o;for(;o=r?.shift();)(s=t(this,Z))==null||s.call(this,...o);}},Ut);var Dt=class{cache;map=new Map;constructor(e){this.cache=new ne({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){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()}};var Rt="1.9.4";var Wt={version:Rt};var Kt="__game_layer__";var Ee={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var le={};var Yt={};Se(Yt,{createExportableElement:()=>he});var gt;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(gt||={});function he(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw gt.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}function de(l){let e,i={},s={};function r(y){i=y;}function o(y){s=y;}function n(y){e&&h();let U=y?.windowKey??"pixiVN",S=[],M=m=>({...i,...m}),N={Game:l,narration:O__namespace.narration,storage:W__namespace.storage,stepHistory:ot__namespace.stepHistory,get props(){return i},start:(m,v)=>s.start?s.start(m,v):l.start(m,M(v)),continue:(m,v)=>s.continue?s.continue():O__namespace.narration.continue(M(m),v),call:(m,v)=>s.call?s.call(m,v):O__namespace.narration.call(m,M(v)),jump:(m,v)=>s.jump?s.jump(m,v):O__namespace.narration.jump(m,M(v)),selectChoice:(m,v)=>{let g=O__namespace.narration.choices.list?.find(L=>L.choiceIndex===m);if(!g){let L=O__namespace.narration.choices.list?.map(A=>A.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${m}. Available: ${L}`)}return s.selectChoice?s.selectChoice(g):O__namespace.narration.choices.select(g,M(v))},setInput:m=>{O__namespace.narration.input.value=m;},goBack:(m,v)=>s.back?s.back():ot__namespace.stepHistory.back(M(m),v),closeCurrentLabel:()=>O__namespace.narration.labels.closeCurrent(),closeAllLabels:()=>O__namespace.narration.labels.closeAll(),getState:()=>({dialogue:O__namespace.narration.dialogue,dialogueGlue:O__namespace.narration.dialogGlue,choices:O__namespace.narration.choices.list,input:{isRequired:O__namespace.narration.input.isRequired,type:O__namespace.narration.input.type,value:O__namespace.narration.input.value},canContinue:O__namespace.narration.canContinue,canGoBack:ot__namespace.stepHistory.canGoBack,labelsOpened:O__namespace.narration.labels.opened,currentLabelId:O__namespace.narration.labels.current?.id,stepCounter:O__namespace.narration.stepCounter}),get errors(){return S.slice()},clearErrors:()=>{S.length=0;}},H=m=>{S.push({error:m,timestamp:Date.now()});};return l.addOnError(H),typeof window<"u"?window[U]=N:gt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),e={api:N,windowKey:U,errorHandler:H},N}function h(){e&&(l.removeOnError(e.errorHandler),typeof window<"u"&&window[e.windowKey]===e.api&&delete window[e.windowKey],e=void 0);}function d(){return e!==void 0}return {setProps:r,setActions:o,enable:n,disable:h,isEnabled:d}}var Ae=typeof window<"u"&&typeof document<"u",pe=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Wt.version}`],ue=31,Oe="background:#2f90da;color:#fff;font-weight:bold;",Le="background:#c832bb;color:#fff;font-weight:bold;",Re="background:transparent;font-weight:bold;",qt=` v${Wt.version}`;function fe(){if(!Ae)return;let l=[],e=[];for(let i=0;i<pe.length;i++){let s=pe[i],r=s.endsWith(qt),o=r?s.slice(0,-qt.length):s,n=o.slice(0,ue),h=o.slice(ue),d=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(d),e.push(Oe,n,Le,h),r&&e.push(Re,qt);}console.info(l.join(`
|
|
2
|
-
`),...e);}function
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var C=require('@drincs/pixi-vn/canvas'),$t=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),st=require('@drincs/pixi-vn/history'),U=require('@drincs/pixi-vn/narration'),pt=require('@drincs/pixi-vn/sound'),W=require('@drincs/pixi-vn/storage'),tickers=require('@drincs/pixi-vn/tickers'),worker=require('@drincs/pixi-vn/worker'),motion=require('@drincs/pixi-vn/motion'),Ee=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var C__namespace=/*#__PURE__*/_interopNamespace(C);var $t__namespace=/*#__PURE__*/_interopNamespace($t);var st__namespace=/*#__PURE__*/_interopNamespace(st);var U__namespace=/*#__PURE__*/_interopNamespace(U);var pt__namespace=/*#__PURE__*/_interopNamespace(pt);var W__namespace=/*#__PURE__*/_interopNamespace(W);var Ee__default=/*#__PURE__*/_interopDefault(Ee);var Xt=Object.defineProperty;var Jt=l=>{throw TypeError(l)};var be=(l,e,i)=>e in l?Xt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var Se=(l,e)=>{for(var i in e)Xt(l,i,{get:e[i],enumerable:true});};var D=(l,e,i)=>be(l,typeof e!="symbol"?e+"":e,i),jt=(l,e,i)=>e.has(l)||Jt("Cannot "+i);var t=(l,e,i)=>(jt(l,e,"read from private field"),i?i.call(l):e.get(l)),b=(l,e,i)=>e.has(l)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),f=(l,e,i,s)=>(jt(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(jt(l,e,"access private method"),i);var Lt=(l,e,i,s)=>({set _(a){f(l,e,a);},get _(){return t(l,e,s)}});var yt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ee=new Set,Dt=typeof process=="object"&&process?process:{},ie=(l,e,i,s)=>{typeof Dt.emitWarning=="function"?Dt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Rt=globalThis.AbortController,Qt=globalThis.AbortSignal;if(typeof Rt>"u"){Qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(s,a){this._onabort.push(a);}},Rt=class{constructor(){e();}signal=new Qt;abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let a of this.signal._onabort)a(s);this.signal.onabort?.(s);}}};let l=Dt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,ie("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 ve=l=>!ee.has(l);var lt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),se=l=>lt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?bt:null:null,bt=class extends Array{constructor(e){super(e),this.fill(0);}},St,mt=class mt{heap;length;static create(e){let i=se(e);if(!i)return [];f(mt,St,true);let s=new mt(e,i);return f(mt,St,false),s}constructor(e,i){if(!t(mt,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};St=new WeakMap,b(mt,St,false);var Nt=mt,Zt,te,$,K,X,J,vt,Tt,P,Q,L,w,g,z,Y,M,R,Z,I,tt,et,q,it,ut,k,o,Mt,gt,at,Ut,B,ne,_t,wt,At,ct,ht,Ft,Ot,Pt,T,zt,Et,dt,kt,Vt=class Vt{constructor(e){b(this,o);b(this,$);b(this,K);b(this,X);b(this,J);b(this,vt);b(this,Tt);D(this,"ttl");D(this,"ttlResolution");D(this,"ttlAutopurge");D(this,"updateAgeOnGet");D(this,"updateAgeOnHas");D(this,"allowStale");D(this,"noDisposeOnSet");D(this,"noUpdateTTL");D(this,"maxEntrySize");D(this,"sizeCalculation");D(this,"noDeleteOnFetchRejection");D(this,"noDeleteOnStaleGet");D(this,"allowStaleOnFetchAbort");D(this,"allowStaleOnFetchRejection");D(this,"ignoreFetchAbort");b(this,P);b(this,Q);b(this,L);b(this,w);b(this,g);b(this,z);b(this,Y);b(this,M);b(this,R);b(this,Z);b(this,I);b(this,tt);b(this,et);b(this,q);b(this,it);b(this,ut);b(this,k);b(this,gt,()=>{});b(this,at,()=>{});b(this,Ut,()=>{});b(this,B,()=>false);b(this,_t,e=>{});b(this,wt,(e,i,s)=>{});b(this,At,(e,i,s,a)=>{if(s||a)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});D(this,Zt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:a=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:p,allowStale:u,dispose:v,disposeAfter:V,noDisposeOnSet:S,noUpdateTTL:N,maxSize:G=0,maxEntrySize:H=0,sizeCalculation:h,fetchMethod:_,memoMethod:y,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:x,ignoreFetchAbort:nt}=e;if(i!==0&&!lt(i))throw new TypeError("max option must be a nonnegative integer");let m=i?se(i):Array;if(!m)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,K,G),this.maxEntrySize=H||t(this,K),this.sizeCalculation=h,this.sizeCalculation){if(!t(this,K)&&!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(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Tt,y),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,vt,_),f(this,ut,!!_),f(this,L,new Map),f(this,w,new Array(i).fill(void 0)),f(this,g,new Array(i).fill(void 0)),f(this,z,new m(i)),f(this,Y,new m(i)),f(this,M,0),f(this,R,0),f(this,Z,Nt.create(i)),f(this,P,0),f(this,Q,0),typeof v=="function"&&f(this,X,v),typeof V=="function"?(f(this,J,V),f(this,I,[])):(f(this,J,void 0),f(this,I,void 0)),f(this,it,!!t(this,X)),f(this,k,!!t(this,J)),this.noDisposeOnSet=!!S,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!d,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!nt,this.maxEntrySize!==0){if(t(this,K)!==0&&!lt(t(this,K)))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,o,ne).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!p,this.ttlResolution=lt(a)||a===0?a:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,o,Mt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,K)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,K)){let E="LRU_CACHE_UNBOUNDED";ve(E)&&(ee.add(E),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",E,Vt));}}static unsafeExposeInternals(e){return {starts:t(e,et),ttls:t(e,q),sizes:t(e,tt),keyMap:t(e,L),keyList:t(e,w),valList:t(e,g),next:t(e,z),prev:t(e,Y),get head(){return t(e,M)},get tail(){return t(e,R)},free:t(e,Z),isBackgroundFetch:i=>{var s;return c(s=e,o,T).call(s,i)},backgroundFetch:(i,s,a,n)=>{var r;return c(r=e,o,Pt).call(r,i,s,a,n)},moveToTail:i=>{var s;return c(s=e,o,Et).call(s,i)},indexes:i=>{var s;return c(s=e,o,ct).call(s,i)},rindexes:i=>{var s;return c(s=e,o,ht).call(s,i)},isStale:i=>{var s;return t(s=e,B).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,K)}get calculatedSize(){return t(this,Q)}get size(){return t(this,P)}get fetchMethod(){return t(this,vt)}get memoMethod(){return t(this,Tt)}get dispose(){return t(this,X)}get disposeAfter(){return t(this,J)}getRemainingTTL(e){return t(this,L).has(e)?1/0:0}*entries(){for(let e of c(this,o,ct).call(this))t(this,g)[e]!==void 0&&t(this,w)[e]!==void 0&&!c(this,o,T).call(this,t(this,g)[e])&&(yield [t(this,w)[e],t(this,g)[e]]);}*rentries(){for(let e of c(this,o,ht).call(this))t(this,g)[e]!==void 0&&t(this,w)[e]!==void 0&&!c(this,o,T).call(this,t(this,g)[e])&&(yield [t(this,w)[e],t(this,g)[e]]);}*keys(){for(let e of c(this,o,ct).call(this)){let i=t(this,w)[e];i!==void 0&&!c(this,o,T).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of c(this,o,ht).call(this)){let i=t(this,w)[e];i!==void 0&&!c(this,o,T).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of c(this,o,ct).call(this))t(this,g)[e]!==void 0&&!c(this,o,T).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of c(this,o,ht).call(this))t(this,g)[e]!==void 0&&!c(this,o,T).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(te=Symbol.iterator,Zt=Symbol.toStringTag,te)](){return this.entries()}find(e,i={}){for(let s of c(this,o,ct).call(this)){let a=t(this,g)[s],n=c(this,o,T).call(this,a)?a.__staleWhileFetching:a;if(n!==void 0&&e(n,t(this,w)[s],this))return this.get(t(this,w)[s],i)}}forEach(e,i=this){for(let s of c(this,o,ct).call(this)){let a=t(this,g)[s],n=c(this,o,T).call(this,a)?a.__staleWhileFetching:a;n!==void 0&&e.call(i,n,t(this,w)[s],this);}}rforEach(e,i=this){for(let s of c(this,o,ht).call(this)){let a=t(this,g)[s],n=c(this,o,T).call(this,a)?a.__staleWhileFetching:a;n!==void 0&&e.call(i,n,t(this,w)[s],this);}}purgeStale(){let e=false;for(let i of c(this,o,ht).call(this,{allowStale:true}))t(this,B).call(this,i)&&(c(this,o,dt).call(this,t(this,w)[i],"expire"),e=true);return e}info(e){let i=t(this,L).get(e);if(i===void 0)return;let s=t(this,g)[i],a=c(this,o,T).call(this,s)?s.__staleWhileFetching:s;if(a===void 0)return;let n={value:a};if(t(this,q)&&t(this,et)){let r=t(this,q)[i],p=t(this,et)[i];if(r&&p){let u=r-(yt.now()-p);n.ttl=u,n.start=Date.now();}}return t(this,tt)&&(n.size=t(this,tt)[i]),n}dump(){let e=[];for(let i of c(this,o,ct).call(this,{allowStale:true})){let s=t(this,w)[i],a=t(this,g)[i],n=c(this,o,T).call(this,a)?a.__staleWhileFetching:a;if(n===void 0||s===void 0)continue;let r={value:n};if(t(this,q)&&t(this,et)){r.ttl=t(this,q)[i];let p=yt.now()-t(this,et)[i];r.start=Math.floor(Date.now()-p);}t(this,tt)&&(r.size=t(this,tt)[i]),e.unshift([s,r]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let a=Date.now()-s.start;s.start=yt.now()-a;}this.set(i,s.value,s);}}set(e,i,s={}){var N,G,H;if(i===void 0)return this.delete(e),this;let{ttl:a=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:p=this.sizeCalculation,status:u}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,V=t(this,At).call(this,e,i,s.size||0,p);if(this.maxEntrySize&&V>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),c(this,o,dt).call(this,e,"set"),this;let S=t(this,P)===0?void 0:t(this,L).get(e);if(S===void 0)S=t(this,P)===0?t(this,R):t(this,Z).length!==0?t(this,Z).pop():t(this,P)===t(this,$)?c(this,o,Ot).call(this,false):t(this,P),t(this,w)[S]=e,t(this,g)[S]=i,t(this,L).set(e,S),t(this,z)[t(this,R)]=S,t(this,Y)[S]=t(this,R),f(this,R,S),Lt(this,P)._++,t(this,wt).call(this,S,V,u),u&&(u.set="add"),v=false;else {c(this,o,Et).call(this,S);let h=t(this,g)[S];if(i!==h){if(t(this,ut)&&c(this,o,T).call(this,h)){h.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=h;_!==void 0&&!r&&(t(this,it)&&((N=t(this,X))==null||N.call(this,_,e,"set")),t(this,k)&&t(this,I)?.push([_,e,"set"]));}else r||(t(this,it)&&((G=t(this,X))==null||G.call(this,h,e,"set")),t(this,k)&&t(this,I)?.push([h,e,"set"]));if(t(this,_t).call(this,S),t(this,wt).call(this,S,V,u),t(this,g)[S]=i,u){u.set="replace";let _=h&&c(this,o,T).call(this,h)?h.__staleWhileFetching:h;_!==void 0&&(u.oldValue=_);}}else u&&(u.set="update");}if(a!==0&&!t(this,q)&&c(this,o,Mt).call(this),t(this,q)&&(v||t(this,Ut).call(this,S,a,n),u&&t(this,at).call(this,u,S)),!r&&t(this,k)&&t(this,I)){let h=t(this,I),_;for(;_=h?.shift();)(H=t(this,J))==null||H.call(this,..._);}return this}pop(){var e;try{for(;t(this,P);){let i=t(this,g)[t(this,M)];if(c(this,o,Ot).call(this,!0),c(this,o,T).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,k)&&t(this,I)){let i=t(this,I),s;for(;s=i?.shift();)(e=t(this,J))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:a}=i,n=t(this,L).get(e);if(n!==void 0){let r=t(this,g)[n];if(c(this,o,T).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(t(this,B).call(this,n))a&&(a.has="stale",t(this,at).call(this,a,n));else return s&&t(this,gt).call(this,n),a&&(a.has="hit",t(this,at).call(this,a,n)),true}else a&&(a.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,a=t(this,L).get(e);if(a===void 0||!s&&t(this,B).call(this,a))return;let n=t(this,g)[a];return c(this,o,T).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:u=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:V=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:N=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:h,forceRefresh:_=false,status:y,signal:j}=i;if(!t(this,ut))return y&&(y.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:a,noDeleteOnStaleGet:n,status:y});let A={allowStale:s,updateAgeOnGet:a,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:p,size:u,sizeCalculation:v,noUpdateTTL:V,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:N,allowStaleOnFetchAbort:H,ignoreFetchAbort:G,status:y,signal:j},d=t(this,L).get(e);if(d===void 0){y&&(y.fetch="miss");let x=c(this,o,Pt).call(this,e,d,A,h);return x.__returned=x}else {let x=t(this,g)[d];if(c(this,o,T).call(this,x)){let rt=s&&x.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",rt&&(y.returnedStale=true)),rt?x.__staleWhileFetching:x.__returned=x}let nt=t(this,B).call(this,d);if(!_&&!nt)return y&&(y.fetch="hit"),c(this,o,Et).call(this,d),a&&t(this,gt).call(this,d),y&&t(this,at).call(this,y,d),x;let m=c(this,o,Pt).call(this,e,d,A,h),F=m.__staleWhileFetching!==void 0&&s;return y&&(y.fetch=nt?"stale":"refresh",F&&nt&&(y.returnedStale=true)),F?m.__staleWhileFetching:m.__returned=m}}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,Tt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:a,forceRefresh:n,...r}=i,p=this.get(e,r);if(!n&&p!==void 0)return p;let u=s(e,p,{options:r,context:a});return this.set(e,u,r),u}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=i,p=t(this,L).get(e);if(p!==void 0){let u=t(this,g)[p],v=c(this,o,T).call(this,u);return r&&t(this,at).call(this,r,p),t(this,B).call(this,p)?(r&&(r.get="stale"),v?(r&&s&&u.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?u.__staleWhileFetching:void 0):(n||c(this,o,dt).call(this,e,"expire"),r&&s&&(r.returnedStale=true),s?u:void 0)):(r&&(r.get="hit"),v?u.__staleWhileFetching:(c(this,o,Et).call(this,p),a&&t(this,gt).call(this,p),u))}else r&&(r.get="miss");}delete(e){return c(this,o,dt).call(this,e,"delete")}clear(){return c(this,o,kt).call(this,"delete")}};$=new WeakMap,K=new WeakMap,X=new WeakMap,J=new WeakMap,vt=new WeakMap,Tt=new WeakMap,P=new WeakMap,Q=new WeakMap,L=new WeakMap,w=new WeakMap,g=new WeakMap,z=new WeakMap,Y=new WeakMap,M=new WeakMap,R=new WeakMap,Z=new WeakMap,I=new WeakMap,tt=new WeakMap,et=new WeakMap,q=new WeakMap,it=new WeakMap,ut=new WeakMap,k=new WeakMap,o=new WeakSet,Mt=function(){let e=new bt(t(this,$)),i=new bt(t(this,$));f(this,q,e),f(this,et,i),f(this,Ut,(n,r,p=yt.now())=>{if(i[n]=r!==0?p:0,e[n]=r,r!==0&&this.ttlAutopurge){let u=setTimeout(()=>{t(this,B).call(this,n)&&c(this,o,dt).call(this,t(this,w)[n],"expire");},r+1);u.unref&&u.unref();}}),f(this,gt,n=>{i[n]=e[n]!==0?yt.now():0;}),f(this,at,(n,r)=>{if(e[r]){let p=e[r],u=i[r];if(!p||!u)return;n.ttl=p,n.start=u,n.now=s||a();let v=n.now-u;n.remainingTTL=p-v;}});let s=0,a=()=>{let n=yt.now();if(this.ttlResolution>0){s=n;let r=setTimeout(()=>s=0,this.ttlResolution);r.unref&&r.unref();}return n};this.getRemainingTTL=n=>{let r=t(this,L).get(n);if(r===void 0)return 0;let p=e[r],u=i[r];if(!p||!u)return 1/0;let v=(s||a())-u;return p-v},f(this,B,n=>{let r=i[n],p=e[n];return !!p&&!!r&&(s||a())-r>p});},gt=new WeakMap,at=new WeakMap,Ut=new WeakMap,B=new WeakMap,ne=function(){let e=new bt(t(this,$));f(this,Q,0),f(this,tt,e),f(this,_t,i=>{f(this,Q,t(this,Q)-e[i]),e[i]=0;}),f(this,At,(i,s,a,n)=>{if(c(this,o,T).call(this,s))return 0;if(!lt(a))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(a=n(s,i),!lt(a))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 a}),f(this,wt,(i,s,a)=>{if(e[i]=s,t(this,K)){let n=t(this,K)-e[i];for(;t(this,Q)>n;)c(this,o,Ot).call(this,true);}f(this,Q,t(this,Q)+e[i]),a&&(a.entrySize=s,a.totalCalculatedSize=t(this,Q));});},_t=new WeakMap,wt=new WeakMap,At=new WeakMap,ct=function*({allowStale:e=this.allowStale}={}){if(t(this,P))for(let i=t(this,R);!(!c(this,o,Ft).call(this,i)||((e||!t(this,B).call(this,i))&&(yield i),i===t(this,M)));)i=t(this,Y)[i];},ht=function*({allowStale:e=this.allowStale}={}){if(t(this,P))for(let i=t(this,M);!(!c(this,o,Ft).call(this,i)||((e||!t(this,B).call(this,i))&&(yield i),i===t(this,R)));)i=t(this,z)[i];},Ft=function(e){return e!==void 0&&t(this,L).get(t(this,w)[e])===e},Ot=function(e){var n;let i=t(this,M),s=t(this,w)[i],a=t(this,g)[i];return t(this,ut)&&c(this,o,T).call(this,a)?a.__abortController.abort(new Error("evicted")):(t(this,it)||t(this,k))&&(t(this,it)&&((n=t(this,X))==null||n.call(this,a,s,"evict")),t(this,k)&&t(this,I)?.push([a,s,"evict"])),t(this,_t).call(this,i),e&&(t(this,w)[i]=void 0,t(this,g)[i]=void 0,t(this,Z).push(i)),t(this,P)===1?(f(this,M,f(this,R,0)),t(this,Z).length=0):f(this,M,t(this,z)[i]),t(this,L).delete(s),Lt(this,P)._--,i},Pt=function(e,i,s,a){let n=i===void 0?void 0:t(this,g)[i];if(c(this,o,T).call(this,n))return n;let r=new Rt,{signal:p}=s;p?.addEventListener("abort",()=>r.abort(p.reason),{signal:r.signal});let u={signal:r.signal,options:s,context:a},v=(h,_=false)=>{let{aborted:y}=r.signal,j=s.ignoreFetchAbort&&h!==void 0;if(s.status&&(y&&!_?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,j&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),y&&!j&&!_)return S(r.signal.reason);let A=G;return t(this,g)[i]===G&&(h===void 0?A.__staleWhileFetching?t(this,g)[i]=A.__staleWhileFetching:c(this,o,dt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,h,u.options))),h},V=h=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=h),S(h)),S=h=>{let{aborted:_}=r.signal,y=_&&s.allowStaleOnFetchAbort,j=y||s.allowStaleOnFetchRejection,A=j||s.noDeleteOnFetchRejection,d=G;if(t(this,g)[i]===G&&(!A||d.__staleWhileFetching===void 0?c(this,o,dt).call(this,e,"fetch"):y||(t(this,g)[i]=d.__staleWhileFetching)),j)return s.status&&d.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),d.__staleWhileFetching;if(d.__returned===d)throw h},N=(h,_)=>{var j;let y=(j=t(this,vt))==null?void 0:j.call(this,e,n,u);y&&y instanceof Promise&&y.then(A=>h(A===void 0?void 0:A),_),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(h(void 0),s.allowStaleOnFetchAbort&&(h=A=>v(A,true)));});};s.status&&(s.status.fetchDispatched=true);let G=new Promise(N).then(v,V),H=Object.assign(G,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,H,{...u.options,status:void 0}),i=t(this,L).get(e)):t(this,g)[i]=H,H},T=function(e){if(!t(this,ut))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Rt},zt=function(e,i){t(this,Y)[i]=e,t(this,z)[e]=i;},Et=function(e){e!==t(this,R)&&(e===t(this,M)?f(this,M,t(this,z)[e]):c(this,o,zt).call(this,t(this,Y)[e],t(this,z)[e]),c(this,o,zt).call(this,t(this,R),e),f(this,R,e));},dt=function(e,i){var a,n;let s=false;if(t(this,P)!==0){let r=t(this,L).get(e);if(r!==void 0)if(s=true,t(this,P)===1)c(this,o,kt).call(this,i);else {t(this,_t).call(this,r);let p=t(this,g)[r];if(c(this,o,T).call(this,p)?p.__abortController.abort(new Error("deleted")):(t(this,it)||t(this,k))&&(t(this,it)&&((a=t(this,X))==null||a.call(this,p,e,i)),t(this,k)&&t(this,I)?.push([p,e,i])),t(this,L).delete(e),t(this,w)[r]=void 0,t(this,g)[r]=void 0,r===t(this,R))f(this,R,t(this,Y)[r]);else if(r===t(this,M))f(this,M,t(this,z)[r]);else {let u=t(this,Y)[r];t(this,z)[u]=t(this,z)[r];let v=t(this,z)[r];t(this,Y)[v]=t(this,Y)[r];}Lt(this,P)._--,t(this,Z).push(r);}}if(t(this,k)&&t(this,I)?.length){let r=t(this,I),p;for(;p=r?.shift();)(n=t(this,J))==null||n.call(this,...p);}return s},kt=function(e){var i,s;for(let a of c(this,o,ht).call(this,{allowStale:true})){let n=t(this,g)[a];if(c(this,o,T).call(this,n))n.__abortController.abort(new Error("deleted"));else {let r=t(this,w)[a];t(this,it)&&((i=t(this,X))==null||i.call(this,n,r,e)),t(this,k)&&t(this,I)?.push([n,r,e]);}}if(t(this,L).clear(),t(this,g).fill(void 0),t(this,w).fill(void 0),t(this,q)&&t(this,et)&&(t(this,q).fill(0),t(this,et).fill(0)),t(this,tt)&&t(this,tt).fill(0),f(this,M,0),f(this,R,0),t(this,Z).length=0,f(this,Q,0),f(this,P,0),t(this,k)&&t(this,I)){let a=t(this,I),n;for(;n=a?.shift();)(s=t(this,J))==null||s.call(this,...n);}};var It=Vt;var Ct=class{cache;map=new Map;constructor(e){this.cache=new It({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){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()}};var xt="1.9.6";var Ht={version:xt};var Wt="__game_layer__";var Te={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ae={};var Kt={};Se(Kt,{createExportableElement:()=>oe});var ft;(a=>(a.log=(n,...r)=>console.log(`[Pixi\u2019VN] ${n}`,...r),a.warn=(n,...r)=>console.warn(`[Pixi\u2019VN] ${n}`,...r),a.error=(n,...r)=>console.error(`[Pixi\u2019VN] ${n}`,...r),a.info=(n,...r)=>console.info(`[Pixi\u2019VN] ${n}`,...r)))(ft||={});function oe(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw ft.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}function ce(l){let e,i={},s={};function a(v){i=v;}function n(v){s=v;}function r(v){e&&p();let V=v?.windowKey??"pixiVN",S=[],N=h=>({...i,...h}),G={Game:l,narration:U__namespace.narration,storage:W__namespace.storage,stepHistory:st__namespace.stepHistory,get props(){return i},start:(h,_)=>s.start?s.start(h,_):l.start(h,N(_)),continue:(h,_)=>s.continue?s.continue():U__namespace.narration.continue(N(h),_),call:(h,_)=>s.call?s.call(h,_):U__namespace.narration.call(h,N(_)),jump:(h,_)=>s.jump?s.jump(h,_):U__namespace.narration.jump(h,N(_)),selectChoice:(h,_)=>{let y=U__namespace.narration.choices.list?.find(j=>j.choiceIndex===h);if(!y){let j=U__namespace.narration.choices.list?.map(A=>A.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${h}. Available: ${j}`)}return s.selectChoice?s.selectChoice(y):U__namespace.narration.choices.select(y,N(_))},setInput:h=>{U__namespace.narration.input.value=h;},goBack:(h,_)=>s.back?s.back():st__namespace.stepHistory.back(N(h),_),closeCurrentLabel:()=>U__namespace.narration.labels.closeCurrent(),closeAllLabels:()=>U__namespace.narration.labels.closeAll(),getLabelIds:()=>U__namespace.RegisteredLabels.keys(),getAssetIds:()=>{let h=Ee__default.default.Assets.resolver;return Object.keys(h._assetMap??{})},get navigate(){let h=s.navigate;return h?async _=>{await h(_);}:void 0},getState:()=>({dialogue:U__namespace.narration.dialogue,dialogueGlue:U__namespace.narration.dialogGlue,choices:U__namespace.narration.choices.list,input:{isRequired:U__namespace.narration.input.isRequired,type:U__namespace.narration.input.type,value:U__namespace.narration.input.value},canContinue:U__namespace.narration.canContinue,canGoBack:st__namespace.stepHistory.canGoBack,labelsOpened:U__namespace.narration.labels.opened,currentLabelId:U__namespace.narration.labels.current?.id,stepCounter:U__namespace.narration.stepCounter}),get errors(){return S.slice()},clearErrors:()=>{S.length=0;}},H=h=>{S.push({error:h,timestamp:Date.now()});};return l.addOnError(H),typeof window<"u"?window[V]=G:ft.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),e={api:G,windowKey:V,errorHandler:H},G}function p(){e&&(l.removeOnError(e.errorHandler),typeof window<"u"&&window[e.windowKey]===e.api&&delete window[e.windowKey],e=void 0);}function u(){return e!==void 0}return {setProps:a,setActions:n,enable:r,disable:p,isEnabled:u}}var Ue=typeof window<"u"&&typeof document<"u",he=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Ht.version}`],de=31,Ae="background:#2f90da;color:#fff;font-weight:bold;",xe="background:#c832bb;color:#fff;font-weight:bold;",Le="background:transparent;font-weight:bold;",Yt=` v${Ht.version}`;function ue(){if(!Ue)return;let l=[],e=[];for(let i=0;i<he.length;i++){let s=he[i],a=s.endsWith(Yt),n=a?s.slice(0,-Yt.length):s,r=n.slice(0,de),p=n.slice(de),u=a?"%c%s%c%s%c%s":"%c%s%c%s";l.push(u),e.push(Ae,r,xe,p),a&&e.push(Le,Yt);}console.info(l.join(`
|
|
2
|
+
`),...e);}function qt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}ue();exports.Game=void 0;(A=>{async function l(d,x,nt){if(core.GameUnifier.init({navigate:x?.navigate,getCurrentGameStepState:async()=>{let m=C__namespace.canvas.isInitialized?C__namespace.canvas.export():{};return {path:qt(),storage:await W__namespace.storage.export(),canvas:m,sound:pt__namespace.sound.export(),labelIndex:U__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:U__namespace.narration.openedLabels}},restoreGameStepState:async(m,E)=>{st__namespace.HistoryManagerStatic._originalStepData=m,U__namespace.NarrationManagerStatic.openedLabels=m.openedLabels,W__namespace.storage.restore(m.storage);try{C__namespace.canvas.isInitialized&&await C__namespace.canvas.restore(m.canvas),await pt__namespace.sound.restore(m.sound);}catch(F){ft.error("Error restoring game step state:",F);}await E(m.path);},getStepCounter:()=>U__namespace.narration.stepCounter,setStepCounter:m=>{U__namespace.NarrationManagerStatic._stepCounter=m;},getOpenedLabels:()=>U__namespace.narration.openedLabels.length,addHistoryItem:(m,E)=>st__namespace.stepHistory.add(m,E),getCharacter:m=>$t__namespace.RegisteredCharacters.get(m),processNavigationRequests:(m,E)=>{let F=m,rt=Promise.resolve();return m>0?(F--,rt=U__namespace.narration.continue(E)):m<0&&(F=0,rt=st__namespace.stepHistory.back(E,{steps:m*-1})),{newValue:F,result:rt}},animate:(m,E,F,rt)=>motion.motion.animate(m,E,F,rt),animateFilter:(m,E,F,rt,me,ge,_e,ye)=>motion.motion.animateFilter(m,E,F,rt,me,ge,_e,ye),removeCanvasComponent:m=>{C__namespace.canvas.isInitialized&&C__namespace.canvas.remove(m);},canvasComponentExists:m=>C__namespace.canvas.isInitialized?C__namespace.canvas.find(m)!==void 0:false,getVariable:(m,E)=>W__namespace.StorageRegistry.getVariable(m,E),setVariable:(m,E,F)=>W__namespace.StorageRegistry.setVariable(m,E,F),removeVariable:(m,E)=>W__namespace.StorageRegistry.removeVariable(m,E),getFlag:m=>W__namespace.storage.flags.get(m),setFlag:(m,E)=>W__namespace.storage.flags.set(m,E),onLabelClosing:m=>W__namespace.StorageRegistry.clearOldTempVariables(m)}),!d||!x){ft.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await C__namespace.canvas.init(d,x,nt)}A.init=l;function e(){W__namespace.storage.clear(),C__namespace.canvas.isInitialized&&C__namespace.canvas.clear(),pt__namespace.sound.clear(),U__namespace.narration.clear(),st__namespace.stepHistory.clear();}A.clear=e;async function i(){let d=C__namespace.canvas.isInitialized?C__namespace.canvas.export():{};return {pixivn_version:xt,stepData:U__namespace.narration.export(),storageData:await W__namespace.storage.export(),canvasData:d,soundData:pt__namespace.sound.export(),historyData:await st__namespace.stepHistory.export(),path:qt()}}A.exportGameState=i;async function s(d){st__namespace.stepHistory.restore(d.historyData);let x=st__namespace.stepHistory.lastKey;if(typeof x=="number"){let nt=st__namespace.stepHistory.stepsInfoMap.get(x)||null;await U__namespace.narration.restore(d.stepData,nt);}W__namespace.storage.restore(d.storageData);try{C__namespace.canvas.isInitialized&&await C__namespace.canvas.restore(d.canvasData),await pt__namespace.sound.restore(d.soundData);}catch{}await core.GameUnifier.navigate(d.path);}A.restoreGameState=s;async function a(d,x){return A.clear(),await U__namespace.narration.call(d,x)}A.start=a;function n(d){return JSON.parse(d)}A.jsonToGameState=n;function r(d){core.GameUnifier.onEnd=d;}A.onEnd=r;function p(d){return core.GameUnifier.addOnError(d)}A.addOnError=p;function u(d){return core.GameUnifier.removeOnError(d)}A.removeOnError=u;function v(d){U__namespace.NarrationManagerStatic.onStepStart=d;}A.onStepStart=v;function V(d){U__namespace.NarrationManagerStatic.onLoadingLabel=d;}A.onLoadingLabel=V;function S(d){U__namespace.NarrationManagerStatic.onStepEnd=d;}A.onStepEnd=S;function N(d){U__namespace.NarrationManagerStatic.onLabelStarting=d;}A.onLabelStarting=N;function G(d){U__namespace.NarrationManagerStatic.onLabelClosing=d;}A.onLabelClosing=G;function H(d){core.GameUnifier.navigate=d;}A.onNavigate=H;function h(d){return core.GameUnifier.addOnPreContinue(d)}A.addOnPreContinue=h;function _(d){return core.GameUnifier.removeOnPreContinue(d)}A.removeOnPreContinue=_,A.worker={register:d=>worker.GameWorkerManager.register(d),unregister:()=>worker.GameWorkerManager.unregister(),get isAvailable(){return worker.GameWorkerManager.isAvailable}},A.testing=ce(A);})(exports.Game||={});var ci={characterUtils:$t__namespace,canvasUtils:C__namespace,narrationUtils:U__namespace,soundUtils:pt__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Wt,PIXIVN_VERSION:xt,...Kt,...ae,canvas:C__namespace.canvas,narration:U__namespace.narration,sound:pt__namespace.sound,storage:W__namespace.storage,tickers:tickers.tickers,history:st__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Wt;exports.CachedMap=Ct;exports.PIXIVN_VERSION=xt;exports.SYSTEM_RESERVED_STORAGE_KEYS=Te;exports.createExportableElement=oe;exports.default=ci;Object.keys(C).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return C[k]}})});Object.keys($t).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return $t[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(st).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return st[k]}})});Object.keys(U).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return U[k]}})});Object.keys(pt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return pt[k]}})});Object.keys(W).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return W[k]}})});Object.keys(tickers).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return tickers[k]}})});Object.keys(worker).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return worker[k]}})});
|
package/dist/index.d.cts
CHANGED
|
@@ -18,11 +18,11 @@ export * from '@drincs/pixi-vn/sound';
|
|
|
18
18
|
export * from '@drincs/pixi-vn/tickers';
|
|
19
19
|
export * from '@drincs/pixi-vn/worker';
|
|
20
20
|
export { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { CanvasGameState } from './canvas.cjs';
|
|
22
|
+
import { HistoryGameState } from './history.cjs';
|
|
23
|
+
import { SoundGameState } from './sound.cjs';
|
|
24
|
+
import { StorageGameState } from './storage.cjs';
|
|
25
|
+
import { OpenedLabel } from './narration.cjs';
|
|
26
26
|
import { Devtools } from '@pixi/devtools';
|
|
27
27
|
import 'lru-cache';
|
|
28
28
|
import '@drincs/pixi-vn/filters';
|
|
@@ -110,6 +110,12 @@ interface GameTestingAPI<TGame, T extends {} = {}> {
|
|
|
110
110
|
closeAllLabels(): void;
|
|
111
111
|
/** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
|
|
112
112
|
getState(): GameTestingState;
|
|
113
|
+
/** All registered labels, including labels not currently open. */
|
|
114
|
+
getLabelIds(): narrationUtils.LabelIdType[];
|
|
115
|
+
/** Registered resolver aliases, including assets that have not been loaded. */
|
|
116
|
+
getAssetIds(): string[];
|
|
117
|
+
/** Present only when the application registers a screen navigation action. */
|
|
118
|
+
readonly navigate?: (screen: string) => Promise<void>;
|
|
113
119
|
/** Errors caught via `Game.addOnError` since `enable()` was called (or since the last {@link clearErrors}). */
|
|
114
120
|
readonly errors: GameTestingErrorEntry[];
|
|
115
121
|
clearErrors(): void;
|
|
@@ -128,6 +134,8 @@ interface GameTestingAPI<TGame, T extends {} = {}> {
|
|
|
128
134
|
* raw `choiceIndex`, since looking it up is already handled before the override runs.
|
|
129
135
|
*/
|
|
130
136
|
interface GameTestingActions<T extends {} = {}> {
|
|
137
|
+
/** Optional router-independent screen navigation supplied by the application. */
|
|
138
|
+
navigate?: (screen: string) => Promise<void>;
|
|
131
139
|
continue?: () => Promise<void>;
|
|
132
140
|
back?: () => Promise<void>;
|
|
133
141
|
selectChoice?: (item: narrationUtils.StoredIndexedChoiceInterface) => Promise<void>;
|
|
@@ -136,7 +144,7 @@ interface GameTestingActions<T extends {} = {}> {
|
|
|
136
144
|
call?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
|
|
147
|
+
declare let version: string;
|
|
140
148
|
|
|
141
149
|
/**
|
|
142
150
|
* Is a special alias to indicate the game layer.
|
|
@@ -553,4 +561,5 @@ declare const _default: {
|
|
|
553
561
|
PIXIVN_VERSION: string;
|
|
554
562
|
};
|
|
555
563
|
|
|
556
|
-
export { CANVAS_APP_GAME_LAYER_ALIAS, Game,
|
|
564
|
+
export { CANVAS_APP_GAME_LAYER_ALIAS, Game, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
|
|
565
|
+
export type { GameState, GameStepStateData, GameTestingAPI, GameTestingActions, GameTestingErrorEntry, GameTestingState };
|
package/dist/index.d.ts
CHANGED
|
@@ -18,11 +18,11 @@ export * from '@drincs/pixi-vn/sound';
|
|
|
18
18
|
export * from '@drincs/pixi-vn/tickers';
|
|
19
19
|
export * from '@drincs/pixi-vn/worker';
|
|
20
20
|
export { C as CachedMap } from './CachedMap-DZLvJAnA.js';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
21
|
+
import { CanvasGameState } from './canvas.js';
|
|
22
|
+
import { HistoryGameState } from './history.js';
|
|
23
|
+
import { SoundGameState } from './sound.js';
|
|
24
|
+
import { StorageGameState } from './storage.js';
|
|
25
|
+
import { OpenedLabel } from './narration.js';
|
|
26
26
|
import { Devtools } from '@pixi/devtools';
|
|
27
27
|
import 'lru-cache';
|
|
28
28
|
import '@drincs/pixi-vn/filters';
|
|
@@ -110,6 +110,12 @@ interface GameTestingAPI<TGame, T extends {} = {}> {
|
|
|
110
110
|
closeAllLabels(): void;
|
|
111
111
|
/** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
|
|
112
112
|
getState(): GameTestingState;
|
|
113
|
+
/** All registered labels, including labels not currently open. */
|
|
114
|
+
getLabelIds(): narrationUtils.LabelIdType[];
|
|
115
|
+
/** Registered resolver aliases, including assets that have not been loaded. */
|
|
116
|
+
getAssetIds(): string[];
|
|
117
|
+
/** Present only when the application registers a screen navigation action. */
|
|
118
|
+
readonly navigate?: (screen: string) => Promise<void>;
|
|
113
119
|
/** Errors caught via `Game.addOnError` since `enable()` was called (or since the last {@link clearErrors}). */
|
|
114
120
|
readonly errors: GameTestingErrorEntry[];
|
|
115
121
|
clearErrors(): void;
|
|
@@ -128,6 +134,8 @@ interface GameTestingAPI<TGame, T extends {} = {}> {
|
|
|
128
134
|
* raw `choiceIndex`, since looking it up is already handled before the override runs.
|
|
129
135
|
*/
|
|
130
136
|
interface GameTestingActions<T extends {} = {}> {
|
|
137
|
+
/** Optional router-independent screen navigation supplied by the application. */
|
|
138
|
+
navigate?: (screen: string) => Promise<void>;
|
|
131
139
|
continue?: () => Promise<void>;
|
|
132
140
|
back?: () => Promise<void>;
|
|
133
141
|
selectChoice?: (item: narrationUtils.StoredIndexedChoiceInterface) => Promise<void>;
|
|
@@ -136,7 +144,7 @@ interface GameTestingActions<T extends {} = {}> {
|
|
|
136
144
|
call?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
|
|
137
145
|
}
|
|
138
146
|
|
|
139
|
-
|
|
147
|
+
declare let version: string;
|
|
140
148
|
|
|
141
149
|
/**
|
|
142
150
|
* Is a special alias to indicate the game layer.
|
|
@@ -553,4 +561,5 @@ declare const _default: {
|
|
|
553
561
|
PIXIVN_VERSION: string;
|
|
554
562
|
};
|
|
555
563
|
|
|
556
|
-
export { CANVAS_APP_GAME_LAYER_ALIAS, Game,
|
|
564
|
+
export { CANVAS_APP_GAME_LAYER_ALIAS, Game, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
|
|
565
|
+
export type { GameState, GameStepStateData, GameTestingAPI, GameTestingActions, GameTestingErrorEntry, GameTestingState };
|