@drincs/pixi-vn 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/storage.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var Ht=f=>{throw TypeError(f)};var ee=(f,e,i)=>e in f?te(f,e,{enumerable:true,configurable:true,writable:true,value:i}):f[e]=i;var D=(f,e,i)=>ee(f,typeof e!="symbol"?e+"":e,i),Ut=(f,e,i)=>e.has(f)||Ht("Cannot "+i);var t=(f,e,i)=>(Ut(f,e,"read from private field"),i?i.call(f):e.get(f)),d=(f,e,i)=>e.has(f)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,i),u=(f,e,i,s)=>(Ut(f,e,"write to private field"),e.set(f,i),i),l=(f,e,i)=>(Ut(f,e,"access private method"),i);var Nt=(f,e,i,s)=>({set _(r){u(f,e,r);},get _(){return t(f,e,s)}});var st="storage",ht="temp",H="narration",Ft="flags",j={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 ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Bt=new Set,zt=typeof process=="object"&&process?process:{},Xt=(f,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(f,e,i,s):console.error(`[${i}] ${e}: ${f}`);},Gt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Gt>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new jt;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=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,Xt("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 se=f=>!Bt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Jt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(f){super(f),this.fill(0);}},et,dt,re=(et=class{heap;length;static create(e){let i=Jt(e);if(!i)return [];u(et,dt,true);let s=new et(e,i);return u(et,dt,false),s}constructor(e,i){if(!t(et,dt))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]}},dt=new WeakMap,d(et,dt,false),et),$t,kt,$,z,k,ct,B,mt,St,X,R,J,x,O,g,L,Y,C,N,q,F,Q,Z,K,P,tt,lt,V,Et,n,Yt,ft,it,wt,W,Qt,ut,Tt,xt,at,ot,Kt,Ct,Mt,v,Pt,Ot,nt,Wt,bt,qt=(bt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ct);d(this,B);d(this,mt);d(this,St);d(this,X);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");d(this,R);d(this,J);d(this,x);d(this,O);d(this,g);d(this,L);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,K);d(this,P);d(this,tt);d(this,lt);d(this,V);d(this,Et);d(this,ft,()=>{});d(this,it,()=>{});d(this,wt,()=>{});d(this,W,()=>false);d(this,ut,e=>{});d(this,Tt,(e,i,s)=>{});d(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});D(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:S,onInsert:I,disposeAfter:p,noDisposeOnSet:b,noUpdateTTL:T,maxSize:E=0,maxEntrySize:y=0,sizeCalculation:A,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:vt,ignoreFetchAbort:gt,perf:pt}=e;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,X,pt??ie),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?Jt(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(u(this,$,i),u(this,z,E),this.maxEntrySize=y||t(this,z),this.sizeCalculation=A,this.sizeCalculation){if(!t(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(u(this,St,M),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,mt,_),u(this,lt,!!_),u(this,x,new Map),u(this,O,new Array(i).fill(void 0)),u(this,g,new Array(i).fill(void 0)),u(this,L,new _t(i)),u(this,Y,new _t(i)),u(this,C,0),u(this,N,0),u(this,q,re.create(i)),u(this,R,0),u(this,J,0),typeof S=="function"&&u(this,k,S),typeof I=="function"&&u(this,ct,I),typeof p=="function"?(u(this,B,p),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,tt,!!t(this,k)),u(this,Et,!!t(this,ct)),u(this,V,!!t(this,B)),this.noDisposeOnSet=!!b,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Qt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Vt="LRU_CACHE_UNBOUNDED";se(Vt)&&(Bt.add(Vt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,bt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,K),autopurgeTimers:t(e,P),sizes:t(e,Q),keyMap:t(e,x),keyList:t(e,O),valList:t(e,g),next:t(e,L),prev:t(e,Y),get head(){return t(e,C)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,v).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return l(a=e,n,Mt).call(a,i,s,r,o)},moveToTail:i=>{var s;return l(s=e,n,Ot).call(s,i)},indexes:i=>{var s;return l(s=e,n,at).call(s,i)},rindexes:i=>{var s;return l(s=e,n,ot).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,R)}get fetchMethod(){return t(this,mt)}get memoMethod(){return t(this,St)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,x).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(kt=Symbol.iterator,$t=Symbol.toStringTag,kt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,O)[s],this))return this.get(t(this,O)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,ot).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,O)[i],"expire"),e=true);return e}info(e){let i=t(this,x).get(e);if(i===void 0)return;let s=t(this,g)[i],r=l(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,K)&&t(this,Z)){let a=t(this,K)[i],h=t(this,Z)[i];if(a&&h){let c=a-(t(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of l(this,n,at).call(this,{allowStale:true})){let s=t(this,O)[i],r=t(this,g)[i],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,K)&&t(this,Z)){a.ttl=t(this,K)[i];let h=t(this,X).now()-t(this,Z)[i];a.start=Math.floor(Date.now()-h);}t(this,Q)&&(a.size=t(this,Q)[i]),e.unshift([s,a]);}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,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var b,T,E,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,I=t(this,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let p=t(this,R)===0?void 0:t(this,x).get(e);if(p===void 0)p=t(this,R)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,R)===t(this,$)?l(this,n,Ct).call(this,false):t(this,R),t(this,O)[p]=e,t(this,g)[p]=i,t(this,x).set(e,p),t(this,L)[t(this,N)]=p,t(this,Y)[p]=t(this,N),u(this,N,p),Nt(this,R)._++,t(this,Tt).call(this,p,I,c),c&&(c.set="add"),S=false,t(this,Et)&&((b=t(this,ct))==null||b.call(this,i,e,"add"));else {l(this,n,Ot).call(this,p);let A=t(this,g)[p];if(i!==A){if(t(this,lt)&&l(this,n,v).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=A;_!==void 0&&!a&&(t(this,tt)&&((T=t(this,k))==null||T.call(this,_,e,"set")),t(this,V)&&t(this,F)?.push([_,e,"set"]));}else a||(t(this,tt)&&((E=t(this,k))==null||E.call(this,A,e,"set")),t(this,V)&&t(this,F)?.push([A,e,"set"]));if(t(this,ut).call(this,p),t(this,Tt).call(this,p,I,c),t(this,g)[p]=i,c){c.set="replace";let _=A&&l(this,n,v).call(this,A)?A.__staleWhileFetching:A;_!==void 0&&(c.oldValue=_);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===A?"update":"replace");}if(r!==0&&!t(this,K)&&l(this,n,Yt).call(this),t(this,K)&&(S||t(this,wt).call(this,p,r,o),c&&t(this,it).call(this,c,p)),!a&&t(this,V)&&t(this,F)){let A=t(this,F),_;for(;_=A?.shift();)(y=t(this,B))==null||y.call(this,..._);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,g)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,x).get(e);if(o!==void 0){let a=t(this,g)[o];if(l(this,n,v).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ft).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,x).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,g)[r];return l(this,n,v).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:b=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:y,forceRefresh:A=false,status:_,signal:M}=i;if(!t(this,lt))return _&&(_.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:_});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:c,sizeCalculation:S,noUpdateTTL:I,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:_,signal:M},G=t(this,x).get(e);if(G===void 0){_&&(_.fetch="miss");let w=l(this,n,Mt).call(this,e,G,U,y);return w.__returned=w}else {let w=t(this,g)[G];if(l(this,n,v).call(this,w)){let _t=s&&w.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",_t&&(_.returnedStale=true)),_t?w.__staleWhileFetching:w.__returned=w}let vt=t(this,W).call(this,G);if(!A&&!vt)return _&&(_.fetch="hit"),l(this,n,Ot).call(this,G),r&&t(this,ft).call(this,G),_&&t(this,it).call(this,_,G),w;let gt=l(this,n,Mt).call(this,e,G,U,y),pt=gt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=vt?"stale":"refresh",pt&&vt&&(_.returnedStale=true)),pt?gt.__staleWhileFetching:gt.__returned=gt}}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,St);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,h=this.get(e,a);if(!o&&h!==void 0)return h;let c=s(e,h,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=t(this,x).get(e);if(h!==void 0){let c=t(this,g)[h],S=l(this,n,v).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),S?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,nt).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),S?c.__staleWhileFetching:(l(this,n,Ot).call(this,h),r&&t(this,ft).call(this,h),c))}else a&&(a.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ct=new WeakMap,B=new WeakMap,mt=new WeakMap,St=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,O=new WeakMap,g=new WeakMap,L=new WeakMap,Y=new WeakMap,C=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,K=new WeakMap,P=new WeakMap,tt=new WeakMap,lt=new WeakMap,V=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Dt(t(this,$)),i=new Dt(t(this,$));u(this,K,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;u(this,P,s),u(this,wt,(h,c,S=t(this,X).now())=>{i[h]=c!==0?S:0,e[h]=c,r(h,c);}),u(this,ft,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let S=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,O)[h],"expire");},c+1);S.unref&&S.unref(),s[h]=S;}}:()=>{};u(this,it,(h,c)=>{if(e[c]){let S=e[c],I=i[c];if(!S||!I)return;h.ttl=S,h.start=I,h.now=o||a();let p=h.now-I;h.remainingTTL=S-p;}});let o=0,a=()=>{let h=t(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,x).get(h);if(c===void 0)return 0;let S=e[c],I=i[c];if(!S||!I)return 1/0;let p=(o||a())-I;return S-p},u(this,W,h=>{let c=i[h],S=e[h];return !!S&&!!c&&(o||a())-c>S});},ft=new WeakMap,it=new WeakMap,wt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Dt(t(this,$));u(this,J,0),u(this,Q,e),u(this,ut,i=>{u(this,J,t(this,J)-e[i]),e[i]=0;}),u(this,xt,(i,s,r,o)=>{if(l(this,n,v).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(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,Tt,(i,s,r)=>{if(e[i]=s,t(this,z)){let o=t(this,z)-e[i];for(;t(this,J)>o;)l(this,n,Ct).call(this,true);}u(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ut=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,N);!(!l(this,n,Kt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,C);!(!l(this,n,Kt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,L)[i];},Kt=function(e){return e!==void 0&&t(this,x).get(t(this,O)[e])===e},Ct=function(e){var o;let i=t(this,C),s=t(this,O)[i],r=t(this,g)[i];return t(this,lt)&&l(this,n,v).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,F)?.push([r,s,"evict"])),t(this,ut).call(this,i),t(this,P)?.[i]&&(clearTimeout(t(this,P)[i]),t(this,P)[i]=void 0),e&&(t(this,O)[i]=void 0,t(this,g)[i]=void 0,t(this,q).push(i)),t(this,R)===1?(u(this,C,u(this,N,0)),t(this,q).length=0):u(this,C,t(this,L)[i]),t(this,x).delete(s),Nt(this,R)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(l(this,n,v).call(this,o))return o;let a=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},S=(y,A=false)=>{let{aborted:_}=a.signal,M=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(_&&!A?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!A)return p(a.signal.reason,U);let G=T,w=t(this,g)[i];return (w===T||M&&A&&w===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,g)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},I=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),p(y,false)),p=(y,A)=>{let{aborted:_}=a.signal,M=_&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,w=T;if(t(this,g)[i]===T&&(!G||!A&&w.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,g)[i]=w.__staleWhileFetching)),U)return s.status&&w.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw y},b=(y,A)=>{var M;let _=(M=t(this,mt))==null?void 0:M.call(this,e,o,c);_&&_ instanceof Promise&&_.then(U=>y(U===void 0?void 0:U),A),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>S(U,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(b).then(S,I),E=Object.assign(T,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,E,{...c.options,status:void 0}),i=t(this,x).get(e)):t(this,g)[i]=E,E},v=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Pt=function(e,i){t(this,Y)[i]=e,t(this,L)[e]=i;},Ot=function(e){e!==t(this,N)&&(e===t(this,C)?u(this,C,t(this,L)[e]):l(this,n,Pt).call(this,t(this,Y)[e],t(this,L)[e]),l(this,n,Pt).call(this,t(this,N),e),u(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,R)!==0){let a=t(this,x).get(e);if(a!==void 0)if(t(this,P)?.[a]&&(clearTimeout(t(this,P)?.[a]),t(this,P)[a]=void 0),s=true,t(this,R)===1)l(this,n,Wt).call(this,i);else {t(this,ut).call(this,a);let h=t(this,g)[a];if(l(this,n,v).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,V)&&t(this,F)?.push([h,e,i])),t(this,x).delete(e),t(this,O)[a]=void 0,t(this,g)[a]=void 0,a===t(this,N))u(this,N,t(this,Y)[a]);else if(a===t(this,C))u(this,C,t(this,L)[a]);else {let c=t(this,Y)[a];t(this,L)[c]=t(this,L)[a];let S=t(this,L)[a];t(this,Y)[S]=t(this,Y)[a];}Nt(this,R)._--,t(this,q).push(a);}}if(t(this,V)&&t(this,F)?.length){let a=t(this,F),h;for(;h=a?.shift();)(o=t(this,B))==null||o.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,ot).call(this,{allowStale:true})){let o=t(this,g)[r];if(l(this,n,v).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,O)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,V)&&t(this,F)?.push([o,a,e]);}}if(t(this,x).clear(),t(this,g).fill(void 0),t(this,O).fill(void 0),t(this,K)&&t(this,Z)){t(this,K).fill(0),t(this,Z).fill(0);for(let r of t(this,P)??[])r!==void 0&&clearTimeout(r);t(this,P)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,C,0),u(this,N,0),t(this,q).length=0,u(this,J,0),u(this,R,0),t(this,V)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var yt=class{cache;map=new Map;constructor(e){this.cache=new qt({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 At;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(At||={});function Rt(f){try{if(typeof f>"u")return f;let e=JSON.stringify(f);return JSON.parse(e)}catch(e){throw At.error("Error creating exportable element",f,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(p=>{p.storage=new yt({cacheSize:50}),p.defaultStorage=new yt({cacheSize:10}),p.tempStorageDeadlines=new Map;let s;function r(b){p.tempStorageDeadlines.forEach((T,E)=>{T>b&&(p.storage.delete(`${ht}:${E}`),s?.onClearOldTempVariable?.(E),p.tempStorageDeadlines.delete(E));});}p.clearOldTempVariables=r;function o(b){s=b;}p.setExternalStoreHandler=o;function a(b,T,E){E==null?p.storage.delete(`${b}:${T}`):p.storage.set(`${b}:${T}`,E),s?.onSetVariable?.(T,E);}p.setVariable=a;function h(b,T){let E=p.storage.get(`${b}:${T}`);return Rt(E)}p.getVariable=h;function c(b,T){p.storage.delete(`${b}:${T}`),s?.onRemoveVariable?.(T);}p.removeVariable=c;function S(b,T){let E=p.storage.get(Ft)||[];if(T)E.includes(b)||E.push(b);else {let y=E.indexOf(b);y>-1&&E.splice(y,1);}p.storage.set(Ft,E);}p.setFlag=S;function I(b){return (p.storage.get(Ft)||[]).includes(b)}p.getFlag=I;})(Zt||={});var m=Zt;var It=class{get base(){return m.storage.map}get cache(){return m.storage.cache}get tempStorageDeadlines(){return m.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{m.defaultStorage.map.set(i,s);});}temp={set:(e,i)=>this.setTemp(e,i),remove:e=>this.removeTemp(e),get deadlines(){return m.tempStorageDeadlines}};flags={set:(e,i)=>m.setFlag(e,i),get:e=>m.getFlag(e)};set(e,i){return m.setVariable(st,e,i)}get(e){let i=m.getVariable(ht,e);return i===void 0&&(i=m.getVariable(st,e)),i===void 0&&(i=Rt(m.defaultStorage.get(e))),i}remove(e){return this.temp.remove(e),m.removeVariable(st,e)}setTemp(e,i){if(i==null){this.temp.remove(e);return}else m.setVariable(ht,e,i),this.temp.deadlines.has(e)||this.temp.deadlines.set(e,core.GameUnifier.openedLabels);}removeTemp(e){m.removeVariable(ht,e),this.temp.deadlines.has(e)&&this.temp.deadlines.delete(e);}setTempVariable(e,i){this.temp.set(e,i);}removeTempVariable(e){this.temp.remove(e);}setFlag(e,i){this.flags.set(e,i);}getFlag(e){return this.flags.get(e)}setStorageHandler(e){m.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.temp.deadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...this.temp.deadlines.keys()].forEach(s=>{i.push({key:s,value:this.temp.deadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":m.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":m.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":m.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":m.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":m.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":m.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":m.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":m.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":m.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":m.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":m.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:m.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{m.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{m.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.temp.deadlines.set(i.key,i.value);})):At.warn("No storage data found");}catch(i){At.error("Error importing data",i);}}};var Lt=class{constructor(e,i){this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=m.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{m.setVariable(this.categoryId,`${s}:${o}`,a);});}),m.removeVariable(st,e));}id;categoryId;setStorageProperty(e,i){m.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return m.getVariable(this.categoryId,`${i}:${e}`)}};var Me=new It;exports.StorageRegistry=m;exports.StoredClassModel=Lt;exports.storage=Me;
1
+ 'use strict';var core=require('@drincs/pixi-vn/core'),worker=require('@drincs/pixi-vn/worker');var te=Object.defineProperty;var Ht=f=>{throw TypeError(f)};var ee=(f,e,i)=>e in f?te(f,e,{enumerable:true,configurable:true,writable:true,value:i}):f[e]=i;var D=(f,e,i)=>ee(f,typeof e!="symbol"?e+"":e,i),Ut=(f,e,i)=>e.has(f)||Ht("Cannot "+i);var t=(f,e,i)=>(Ut(f,e,"read from private field"),i?i.call(f):e.get(f)),_=(f,e,i)=>e.has(f)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,i),u=(f,e,i,s)=>(Ut(f,e,"write to private field"),e.set(f,i),i),l=(f,e,i)=>(Ut(f,e,"access private method"),i);var It=(f,e,i,s)=>({set _(r){u(f,e,r);},get _(){return t(f,e,s)}});var st="storage",ht="temp",H="narration",Nt="flags",j={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 ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Bt=new Set,zt=typeof process=="object"&&process?process:{},Xt=(f,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(f,e,i,s):console.error(`[${i}] ${e}: ${f}`);},Ct=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Ct>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Ct=class{constructor(){e();}signal=new jt;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=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,Xt("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 se=f=>!Bt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Jt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(f){super(f),this.fill(0);}},et,_t,re=(et=class{heap;length;static create(e){let i=Jt(e);if(!i)return [];u(et,_t,true);let s=new et(e,i);return u(et,_t,false),s}constructor(e,i){if(!t(et,_t))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]}},_t=new WeakMap,_(et,_t,false),et),$t,kt,$,z,k,ct,B,mt,St,X,R,J,x,O,g,L,Y,M,N,q,F,Q,Z,P,K,tt,lt,V,Et,n,Yt,ft,it,wt,W,Qt,ut,Tt,xt,at,ot,Pt,Dt,Mt,v,Kt,Ot,nt,Wt,bt,qt=(bt=class{constructor(e){_(this,n);_(this,$);_(this,z);_(this,k);_(this,ct);_(this,B);_(this,mt);_(this,St);_(this,X);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");_(this,R);_(this,J);_(this,x);_(this,O);_(this,g);_(this,L);_(this,Y);_(this,M);_(this,N);_(this,q);_(this,F);_(this,Q);_(this,Z);_(this,P);_(this,K);_(this,tt);_(this,lt);_(this,V);_(this,Et);_(this,ft,()=>{});_(this,it,()=>{});_(this,wt,()=>{});_(this,W,()=>false);_(this,ut,e=>{});_(this,Tt,(e,i,s)=>{});_(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});D(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:S,onInsert:I,disposeAfter:p,noDisposeOnSet:b,noUpdateTTL:T,maxSize:E=0,maxEntrySize:y=0,sizeCalculation:A,fetchMethod:d,memoMethod:C,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:vt,ignoreFetchAbort:gt,perf:pt}=e;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,X,pt??ie),i!==0&&!rt(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(u(this,$,i),u(this,z,E),this.maxEntrySize=y||t(this,z),this.sizeCalculation=A,this.sizeCalculation){if(!t(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(C!==void 0&&typeof C!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,St,C),d!==void 0&&typeof d!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,mt,d),u(this,lt,!!d),u(this,x,new Map),u(this,O,new Array(i).fill(void 0)),u(this,g,new Array(i).fill(void 0)),u(this,L,new dt(i)),u(this,Y,new dt(i)),u(this,M,0),u(this,N,0),u(this,q,re.create(i)),u(this,R,0),u(this,J,0),typeof S=="function"&&u(this,k,S),typeof I=="function"&&u(this,ct,I),typeof p=="function"?(u(this,B,p),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,tt,!!t(this,k)),u(this,Et,!!t(this,ct)),u(this,V,!!t(this,B)),this.noDisposeOnSet=!!b,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Qt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Vt="LRU_CACHE_UNBOUNDED";se(Vt)&&(Bt.add(Vt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,bt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,P),autopurgeTimers:t(e,K),sizes:t(e,Q),keyMap:t(e,x),keyList:t(e,O),valList:t(e,g),next:t(e,L),prev:t(e,Y),get head(){return t(e,M)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,v).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return l(a=e,n,Mt).call(a,i,s,r,o)},moveToTail:i=>{var s;return l(s=e,n,Ot).call(s,i)},indexes:i=>{var s;return l(s=e,n,at).call(s,i)},rindexes:i=>{var s;return l(s=e,n,ot).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,R)}get fetchMethod(){return t(this,mt)}get memoMethod(){return t(this,St)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,x).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(kt=Symbol.iterator,$t=Symbol.toStringTag,kt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,O)[s],this))return this.get(t(this,O)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,ot).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,O)[i],"expire"),e=true);return e}info(e){let i=t(this,x).get(e);if(i===void 0)return;let s=t(this,g)[i],r=l(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,P)&&t(this,Z)){let a=t(this,P)[i],h=t(this,Z)[i];if(a&&h){let c=a-(t(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of l(this,n,at).call(this,{allowStale:true})){let s=t(this,O)[i],r=t(this,g)[i],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,P)&&t(this,Z)){a.ttl=t(this,P)[i];let h=t(this,X).now()-t(this,Z)[i];a.start=Math.floor(Date.now()-h);}t(this,Q)&&(a.size=t(this,Q)[i]),e.unshift([s,a]);}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,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var b,T,E,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,I=t(this,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let p=t(this,R)===0?void 0:t(this,x).get(e);if(p===void 0)p=t(this,R)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,R)===t(this,$)?l(this,n,Dt).call(this,false):t(this,R),t(this,O)[p]=e,t(this,g)[p]=i,t(this,x).set(e,p),t(this,L)[t(this,N)]=p,t(this,Y)[p]=t(this,N),u(this,N,p),It(this,R)._++,t(this,Tt).call(this,p,I,c),c&&(c.set="add"),S=false,t(this,Et)&&((b=t(this,ct))==null||b.call(this,i,e,"add"));else {l(this,n,Ot).call(this,p);let A=t(this,g)[p];if(i!==A){if(t(this,lt)&&l(this,n,v).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=A;d!==void 0&&!a&&(t(this,tt)&&((T=t(this,k))==null||T.call(this,d,e,"set")),t(this,V)&&t(this,F)?.push([d,e,"set"]));}else a||(t(this,tt)&&((E=t(this,k))==null||E.call(this,A,e,"set")),t(this,V)&&t(this,F)?.push([A,e,"set"]));if(t(this,ut).call(this,p),t(this,Tt).call(this,p,I,c),t(this,g)[p]=i,c){c.set="replace";let d=A&&l(this,n,v).call(this,A)?A.__staleWhileFetching:A;d!==void 0&&(c.oldValue=d);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===A?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(S||t(this,wt).call(this,p,r,o),c&&t(this,it).call(this,c,p)),!a&&t(this,V)&&t(this,F)){let A=t(this,F),d;for(;d=A?.shift();)(y=t(this,B))==null||y.call(this,...d);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,g)[t(this,M)];if(l(this,n,Dt).call(this,!0),l(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,x).get(e);if(o!==void 0){let a=t(this,g)[o];if(l(this,n,v).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ft).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,x).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,g)[r];return l(this,n,v).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:b=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:y,forceRefresh:A=false,status:d,signal:C}=i;if(!t(this,lt))return d&&(d.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:d});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:c,sizeCalculation:S,noUpdateTTL:I,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:d,signal:C},G=t(this,x).get(e);if(G===void 0){d&&(d.fetch="miss");let w=l(this,n,Mt).call(this,e,G,U,y);return w.__returned=w}else {let w=t(this,g)[G];if(l(this,n,v).call(this,w)){let dt=s&&w.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",dt&&(d.returnedStale=true)),dt?w.__staleWhileFetching:w.__returned=w}let vt=t(this,W).call(this,G);if(!A&&!vt)return d&&(d.fetch="hit"),l(this,n,Ot).call(this,G),r&&t(this,ft).call(this,G),d&&t(this,it).call(this,d,G),w;let gt=l(this,n,Mt).call(this,e,G,U,y),pt=gt.__staleWhileFetching!==void 0&&s;return d&&(d.fetch=vt?"stale":"refresh",pt&&vt&&(d.returnedStale=true)),pt?gt.__staleWhileFetching:gt.__returned=gt}}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,St);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,h=this.get(e,a);if(!o&&h!==void 0)return h;let c=s(e,h,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=t(this,x).get(e);if(h!==void 0){let c=t(this,g)[h],S=l(this,n,v).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),S?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,nt).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),S?c.__staleWhileFetching:(l(this,n,Ot).call(this,h),r&&t(this,ft).call(this,h),c))}else a&&(a.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ct=new WeakMap,B=new WeakMap,mt=new WeakMap,St=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,O=new WeakMap,g=new WeakMap,L=new WeakMap,Y=new WeakMap,M=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,K=new WeakMap,tt=new WeakMap,lt=new WeakMap,V=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));u(this,P,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;u(this,K,s),u(this,wt,(h,c,S=t(this,X).now())=>{i[h]=c!==0?S:0,e[h]=c,r(h,c);}),u(this,ft,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let S=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,O)[h],"expire");},c+1);S.unref&&S.unref(),s[h]=S;}}:()=>{};u(this,it,(h,c)=>{if(e[c]){let S=e[c],I=i[c];if(!S||!I)return;h.ttl=S,h.start=I,h.now=o||a();let p=h.now-I;h.remainingTTL=S-p;}});let o=0,a=()=>{let h=t(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,x).get(h);if(c===void 0)return 0;let S=e[c],I=i[c];if(!S||!I)return 1/0;let p=(o||a())-I;return S-p},u(this,W,h=>{let c=i[h],S=e[h];return !!S&&!!c&&(o||a())-c>S});},ft=new WeakMap,it=new WeakMap,wt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Ft(t(this,$));u(this,J,0),u(this,Q,e),u(this,ut,i=>{u(this,J,t(this,J)-e[i]),e[i]=0;}),u(this,xt,(i,s,r,o)=>{if(l(this,n,v).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(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,Tt,(i,s,r)=>{if(e[i]=s,t(this,z)){let o=t(this,z)-e[i];for(;t(this,J)>o;)l(this,n,Dt).call(this,true);}u(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ut=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,N);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,M)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,M);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,L)[i];},Pt=function(e){return e!==void 0&&t(this,x).get(t(this,O)[e])===e},Dt=function(e){var o;let i=t(this,M),s=t(this,O)[i],r=t(this,g)[i];return t(this,lt)&&l(this,n,v).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,F)?.push([r,s,"evict"])),t(this,ut).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,O)[i]=void 0,t(this,g)[i]=void 0,t(this,q).push(i)),t(this,R)===1?(u(this,M,u(this,N,0)),t(this,q).length=0):u(this,M,t(this,L)[i]),t(this,x).delete(s),It(this,R)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(l(this,n,v).call(this,o))return o;let a=new Ct,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},S=(y,A=false)=>{let{aborted:d}=a.signal,C=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(d&&!A?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,C&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),d&&!C&&!A)return p(a.signal.reason,U);let G=T,w=t(this,g)[i];return (w===T||C&&A&&w===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,g)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},I=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),p(y,false)),p=(y,A)=>{let{aborted:d}=a.signal,C=d&&s.allowStaleOnFetchAbort,U=C||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,w=T;if(t(this,g)[i]===T&&(!G||!A&&w.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):C||(t(this,g)[i]=w.__staleWhileFetching)),U)return s.status&&w.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw y},b=(y,A)=>{var C;let d=(C=t(this,mt))==null?void 0:C.call(this,e,o,c);d&&d instanceof Promise&&d.then(U=>y(U===void 0?void 0:U),A),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>S(U,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(b).then(S,I),E=Object.assign(T,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,E,{...c.options,status:void 0}),i=t(this,x).get(e)):t(this,g)[i]=E,E},v=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ct},Kt=function(e,i){t(this,Y)[i]=e,t(this,L)[e]=i;},Ot=function(e){e!==t(this,N)&&(e===t(this,M)?u(this,M,t(this,L)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,L)[e]),l(this,n,Kt).call(this,t(this,N),e),u(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,R)!==0){let a=t(this,x).get(e);if(a!==void 0)if(t(this,K)?.[a]&&(clearTimeout(t(this,K)?.[a]),t(this,K)[a]=void 0),s=true,t(this,R)===1)l(this,n,Wt).call(this,i);else {t(this,ut).call(this,a);let h=t(this,g)[a];if(l(this,n,v).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,V)&&t(this,F)?.push([h,e,i])),t(this,x).delete(e),t(this,O)[a]=void 0,t(this,g)[a]=void 0,a===t(this,N))u(this,N,t(this,Y)[a]);else if(a===t(this,M))u(this,M,t(this,L)[a]);else {let c=t(this,Y)[a];t(this,L)[c]=t(this,L)[a];let S=t(this,L)[a];t(this,Y)[S]=t(this,Y)[a];}It(this,R)._--,t(this,q).push(a);}}if(t(this,V)&&t(this,F)?.length){let a=t(this,F),h;for(;h=a?.shift();)(o=t(this,B))==null||o.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,ot).call(this,{allowStale:true})){let o=t(this,g)[r];if(l(this,n,v).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,O)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,V)&&t(this,F)?.push([o,a,e]);}}if(t(this,x).clear(),t(this,g).fill(void 0),t(this,O).fill(void 0),t(this,P)&&t(this,Z)){t(this,P).fill(0),t(this,Z).fill(0);for(let r of t(this,K)??[])r!==void 0&&clearTimeout(r);t(this,K)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,M,0),u(this,N,0),t(this,q).length=0,u(this,J,0),u(this,R,0),t(this,V)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var yt=class{cache;map=new Map;constructor(e){this.cache=new qt({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 At;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(At||={});function Gt(f){try{if(typeof f>"u")return f;let e=JSON.stringify(f);return JSON.parse(e)}catch(e){throw At.error("Error creating exportable element",f,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(p=>{p.storage=new yt({cacheSize:50}),p.defaultStorage=new yt({cacheSize:10}),p.tempStorageDeadlines=new Map;let s;function r(b){p.tempStorageDeadlines.forEach((T,E)=>{T>b&&(p.storage.delete(`${ht}:${E}`),s?.onClearOldTempVariable?.(E),p.tempStorageDeadlines.delete(E));});}p.clearOldTempVariables=r;function o(b){s=b;}p.setExternalStoreHandler=o;function a(b,T,E){E==null?p.storage.delete(`${b}:${T}`):p.storage.set(`${b}:${T}`,E),s?.onSetVariable?.(T,E);}p.setVariable=a;function h(b,T){let E=p.storage.get(`${b}:${T}`);return Gt(E)}p.getVariable=h;function c(b,T){p.storage.delete(`${b}:${T}`),s?.onRemoveVariable?.(T);}p.removeVariable=c;function S(b,T){let E=p.storage.get(Nt)||[];if(T)E.includes(b)||E.push(b);else {let y=E.indexOf(b);y>-1&&E.splice(y,1);}p.storage.set(Nt,E);}p.setFlag=S;function I(b){return (p.storage.get(Nt)||[]).includes(b)}p.getFlag=I;})(Zt||={});var m=Zt;var Rt=class{get base(){return m.storage.map}get cache(){return m.storage.cache}get tempStorageDeadlines(){return m.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{m.defaultStorage.map.set(i,s);});}temp={set:(e,i)=>this.setTemp(e,i),remove:e=>this.removeTemp(e),get deadlines(){return m.tempStorageDeadlines}};flags={set:(e,i)=>m.setFlag(e,i),get:e=>m.getFlag(e)};set(e,i){return m.setVariable(st,e,i)}get(e){let i=m.getVariable(ht,e);return i===void 0&&(i=m.getVariable(st,e)),i===void 0&&(i=Gt(m.defaultStorage.get(e))),i}remove(e){return this.temp.remove(e),m.removeVariable(st,e)}setTemp(e,i){if(i==null){this.temp.remove(e);return}else m.setVariable(ht,e,i),this.temp.deadlines.has(e)||this.temp.deadlines.set(e,core.GameUnifier.openedLabels);}removeTemp(e){m.removeVariable(ht,e),this.temp.deadlines.has(e)&&this.temp.deadlines.delete(e);}setTempVariable(e,i){this.temp.set(e,i);}removeTempVariable(e){this.temp.remove(e);}setFlag(e,i){this.flags.set(e,i);}getFlag(e){return this.flags.get(e)}setStorageHandler(e){m.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.temp.deadlines.clear();}async export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...this.temp.deadlines.keys()].forEach(s=>{i.push({key:s,value:this.temp.deadlines.get(s)});}),worker.cloneMaybeOffloaded({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":m.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":m.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":m.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":m.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":m.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":m.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":m.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":m.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":m.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":m.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":m.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:m.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{m.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{m.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.temp.deadlines.set(i.key,i.value);})):At.warn("No storage data found");}catch(i){At.error("Error importing data",i);}}};var Lt=class{constructor(e,i){this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=m.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{m.setVariable(this.categoryId,`${s}:${o}`,a);});}),m.removeVariable(st,e));}id;categoryId;setStorageProperty(e,i){m.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return m.getVariable(this.categoryId,`${i}:${e}`)}};var Le=new Rt;exports.StorageRegistry=m;exports.StoredClassModel=Lt;exports.storage=Le;
@@ -187,7 +187,7 @@ interface StorageManagerInterface {
187
187
  * Export the storage to an object
188
188
  * @returns The object
189
189
  */
190
- export(): StorageGameState;
190
+ export(): Promise<StorageGameState>;
191
191
  /**
192
192
  * Restore the storage from an object
193
193
  * @param data The object
package/dist/storage.d.ts CHANGED
@@ -187,7 +187,7 @@ interface StorageManagerInterface {
187
187
  * Export the storage to an object
188
188
  * @returns The object
189
189
  */
190
- export(): StorageGameState;
190
+ export(): Promise<StorageGameState>;
191
191
  /**
192
192
  * Restore the storage from an object
193
193
  * @param data The object
package/dist/storage.mjs CHANGED
@@ -1 +1 @@
1
- export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-I7DOUH5V.mjs';import'./chunk-HD353M4B.mjs';import'./chunk-HQQ5WH6C.mjs';
1
+ export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-QOBPVPCY.mjs';import'./chunk-YBA63R27.mjs';import'./chunk-U5BSF6X3.mjs';
package/dist/vite.cjs CHANGED
@@ -1,4 +1,6 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var Q=Object.create;var k=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var nt=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var rt=(n,t,d,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of q(t))!et.call(n,o)&&o!==d&&k(n,o,{get:()=>t[o],enumerable:!(m=Z(t,o))||m.enumerable});return n};var st=(n,t,d)=>(d=n!=null?Q(tt(n)):{},rt(k(d,"default",{value:n,enumerable:true}),n));var G=nt((vt,M)=>{var w=process||{},X=w.argv||[],A=w.env||{},it=!(A.NO_COLOR||X.includes("--no-color"))&&(!!A.FORCE_COLOR||X.includes("--color")||w.platform==="win32"||(w.stdout||{}).isTTY&&A.TERM!=="dumb"||!!A.CI),at=(n,t,d=n)=>m=>{let o=""+m,l=o.indexOf(t,n.length);return ~l?n+ot(o,t,d,l)+t:n+o+t},ot=(n,t,d,m)=>{let o="",l=0;do o+=n.substring(l,m)+d,l=m+t.length,m=n.indexOf(t,l);while(~m);return o+n.substring(l)},j=(n=it)=>{let t=n?at:()=>String;return {isColorSupported:n,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};M.exports=j();M.exports.createColors=j;});var O="/__pixi-vn/characters",C="/__pixi-vn/labels",N="/__pixi-vn/assets/manifest",V="/__pixi-vn/canvas-options";var L=st(G());var v=L.default.cyan("(pixi-vn)"),R="virtual:pixi-vn-testing",H=`\0${R}`;function x(n){return n?Array.isArray(n)?n:[n]:[]}function gt(n){return n?n.bundles.map(t=>t.name):[]}function bt(n){if(!n)return [];let t=new Set;for(let d of n.bundles){let m=d.assets;if(Array.isArray(m))for(let o of m){let l=o.alias;if(l)for(let g of Array.isArray(l)?l:[l])t.add(g);}else if(m&&typeof m=="object")for(let o of Object.keys(m))t.add(o);}return Array.from(t)}function pt(n){let t=[],d=[];for(let m of n)try{let o=fs.readFileSync(m,"utf-8"),l=/newLabel\(\s*["']([^"']+)["']/g,g;for(;(g=l.exec(o))!==null;)d.push(g[1]);let p=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(g=p.exec(o))!==null;)t.push(g[1]);}catch{}return {charIds:t,labelIds:d}}function ht(n){let t,d,m=new Promise(e=>{d=e;}),o=[...x(n?.content),...x(n?.characters),...x(n?.labels)],l=[],g=[],p=new Set,F=[],I=typeof n?.assetsManifest=="function",U=n?.testing===false,T=typeof n?.testing=="object"?n.testing.windowKey:void 0,y=typeof n?.assetsManifest=="function"?void 0:n?.assetsManifest;async function P(e){if(typeof n?.assetsManifest=="function")try{let r=await n.assetsManifest(e);y=r,h.manifest=r??null;}catch(r){t?.logger.error(`${v} Failed to resolve the assets manifest.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}let _=new Map;function $(){if(!n?.typeFilePath||!t)return null;let e=n.typeFilePath;return path.isAbsolute(e)?e:path.resolve(t.root,e)}function B(){let e=[...g,...Array.from(_.values()).flat()];return Array.from(new Set(e))}function z(e,r,s,i,u){fs.mkdirSync(path.dirname(e),{recursive:true});let a=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(r.length>0){a.push('declare module "@drincs/pixi-vn/characters" {'),a.push(" interface PixivnCharacterIds {");for(let c of r)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }"),a.push("}");}if(s.length>0){a.push('declare module "@drincs/pixi-vn/narration" {'),a.push(" interface PixivnLabelIds {");for(let c of s)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }"),a.push("}");}if(i.length>0||u.length>0){if(a.push('declare module "@drincs/pixi-vn/canvas" {'),i.length>0){a.push(" interface PixivnBundleIds {");for(let c of i)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }");}if(u.length>0){a.push(" interface PixivnAssetAliasIds {");for(let c of u)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }");}a.push("}");}a.push(`export const characterIds = ${JSON.stringify(r)} as const;`);{let c=Object.fromEntries(r.map(f=>[f,f]));a.push(`export const characterIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let c=Object.fromEntries(s.map(f=>[f,f]));a.push(`export const labelIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const bundleIds = ${JSON.stringify(i)} as const;`);{let c=Object.fromEntries(i.map(f=>[f,f]));a.push(`export const bundleIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const assetAliasIds = ${JSON.stringify(u)} as const;`);{let c=Object.fromEntries(u.map(f=>[f,f]));a.push(`export const assetAliasIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(""),fs.writeFileSync(e,a.join(`
2
- `),"utf-8");}function W(){h.characters=l,h.labels=B();}function b(){W();let e=$();if(e)try{z(e,l.map(r=>r.id),B(),gt(y),bt(y));}catch(r){t?.logger.error(`${v} Failed to write keys file "${e}".`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}async function E(e,r=[]){try{l=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{l=[];}try{g=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{g=[];}if(r.length>0){let{charIds:i,labelIds:u}=pt(r),a=new Set(l.map(f=>f.id)),c=new Set(g);for(let f of i)a.has(f)||l.push({id:f});for(let f of u)c.has(f)||g.push(f);}let s=l.map(i=>i.id).join(", ")||"none";t?.logger.info(`${v} ${L.default.dim(`${l.length} character(s): [${s}], ${g.length} label(s)`)}`,{timestamp:true});}async function D(e,r){let s=[],i=[...x(n?.characters),...x(n?.labels)],u=await tinyglobby.glob(i,{cwd:r,absolute:true,onlyFiles:true});for(let c of u){p.add(c);try{await e(c);}catch{s.push(c);}}await E(e,s),b();let a=await tinyglobby.glob(x(n?.content),{cwd:r,absolute:true,onlyFiles:true});for(let c of a){p.add(c);try{await e(c);}catch{s.push(c);}}return s}async function J(e,r){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let s=await D(e,r);await E(e,s),await P(e),b(),d();}async function Y(e){for(let s of p)for(let i of e.moduleGraph.getModulesByFile(s)??[])e.moduleGraph.invalidateModule(i);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let r=await D(s=>e.ssrLoadModule(s),t.root);await E(s=>e.ssrLoadModule(s),r),await P(s=>e.ssrLoadModule(s)),b();for(let s of F)s();}let h={characters:null,labels:null,manifest:y??null,canvasOptions:null};function S(e,r){return (s,i)=>{if(i.setHeader("Content-Type","application/json"),s.method==="GET"){let u=h[e];if(u===null){i.statusCode=404,i.end(JSON.stringify({error:`${r} not initialized`}));return}i.statusCode=200,i.end(JSON.stringify(u));return}if(s.method==="POST"){let u="";s.on("data",a=>{u+=a.toString();}),s.on("end",()=>{try{h[e]=JSON.parse(u),i.statusCode=201,i.end(JSON.stringify({message:`${r} updated successfully`}));}catch{i.statusCode=400,i.end(JSON.stringify({error:`Invalid JSON format for ${r}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return l},onReload(e){F.push(e);},setExternalLabels(e,r){_.set(e,r),b();},clearExternalLabels(e){_.delete(e),b();},setAssetsManifest(e){y=e,h.manifest=e,b();}},resolveId(e){if(e===R)return H},load(e){if(e===H)return `import { Game } from "@drincs/pixi-vn";
3
- Game.testing.enable(${T?JSON.stringify({windowKey:T}):""});
4
- `},transformIndexHtml(){if(!(U||t?.command!=="serve"))return [{tag:"script",attrs:{type:"module",src:`/@id/${R}`},injectTo:"head-prepend"}]},config(e,r){if(r.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,o.length===0&&!I&&(b(),d());},async buildStart(){if(t?.command!=="build"||o.length===0&&!I)return;let{createServer:e}=await import('vite'),r=await e({root:t.root,configFile:false,resolve:t.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await J(s=>r.ssrLoadModule(s),t.root);}catch{d();}finally{await r.close();}},configureServer(e){(o.length>0||I)&&J(r=>e.ssrLoadModule(r),t.root).catch(()=>{d();}),e.middlewares.use(O,S("characters","Characters")),e.middlewares.use(C,S("labels","Labels")),e.middlewares.use(N,S("manifest","Manifest")),e.middlewares.use(V,S("canvasOptions","Canvas options"));},async hotUpdate({file:e,server:r}){let s=$();if(s&&e===s)return [];if(o.length>0&&p.has(e)){try{await Y(r);}catch(i){t?.logger.error(`${v} Failed to reload content.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}return []}if(I)try{await P(i=>r.ssrLoadModule(i)),b();}catch(i){t?.logger.error(`${v} Failed to refresh the assets manifest.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=N;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=V;exports.PIXIVN_DEV_API_CHARACTERS=O;exports.PIXIVN_DEV_API_LABELS=C;exports.vitePluginPixivn=ht;
1
+ 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var ae=Object.create;var X=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,ue=Object.prototype.hasOwnProperty;var fe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var de=(r,e,u,f)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ce(e))!ue.call(r,o)&&o!==u&&X(r,o,{get:()=>e[o],enumerable:!(f=oe(e,o))||f.enumerable});return r};var me=(r,e,u)=>(u=r!=null?ae(le(r)):{},de(X(u,"default",{value:r,enumerable:true}),r));var K=fe((Pe,M)=>{var A=process||{},j=A.argv||[],P=A.env||{},ge=!(P.NO_COLOR||j.includes("--no-color"))&&(!!P.FORCE_COLOR||j.includes("--color")||A.platform==="win32"||(A.stdout||{}).isTTY&&P.TERM!=="dumb"||!!P.CI),be=(r,e,u=r)=>f=>{let o=""+f,l=o.indexOf(e,r.length);return ~l?r+pe(o,e,u,l)+e:r+o+e},pe=(r,e,u,f)=>{let o="",l=0;do o+=r.substring(l,f)+u,l=f+e.length,f=r.indexOf(e,l);while(~f);return o+r.substring(l)},W=(r=ge)=>{let e=r?be:()=>String;return {isColorSupported:r,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};M.exports=W();M.exports.createColors=W;});var R="/__pixi-vn/characters",C="/__pixi-vn/labels",N="/__pixi-vn/assets/manifest",V="/__pixi-vn/canvas-options";var F=me(K());var p=F.default.cyan("(pixi-vn)"),k="virtual:pixi-vn-testing",q=`\0${k}`,T="virtual:pixi-vn-worker-register",ee=`\0${T}`;function y(r){return r?Array.isArray(r)?r:[r]:[]}function xe(r){return r?r.bundles.map(e=>e.name):[]}function ye(r){if(!r)return [];let e=new Set;for(let u of r.bundles){let f=u.assets;if(Array.isArray(f))for(let o of f){let l=o.alias;if(l)for(let g of Array.isArray(l)?l:[l])e.add(g);}else if(f&&typeof f=="object")for(let o of Object.keys(f))e.add(o);}return Array.from(e)}function ve(r){let e=[],u=[];for(let f of r)try{let o=fs.readFileSync(f,"utf-8"),l=/newLabel\(\s*["']([^"']+)["']/g,g;for(;(g=l.exec(o))!==null;)u.push(g[1]);let h=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(g=h.exec(o))!==null;)e.push(g[1]);}catch{}return {charIds:e,labelIds:u}}function Ie(r){let e,u,f=new Promise(t=>{u=t;}),o=[...y(r?.content),...y(r?.characters),...y(r?.labels)],l=[],g=[],h=new Set,$=[],I=typeof r?.assetsManifest=="function",te=r?.testing===false,L=typeof r?.testing=="object"?r.testing.windowKey:void 0,v=typeof r?.assetsManifest=="function"?void 0:r?.assetsManifest;async function _(t){if(typeof r?.assetsManifest=="function")try{let n=await r.assetsManifest(t);v=n,x.manifest=n??null;}catch(n){e?.logger.error(`${p} Failed to resolve the assets manifest.`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}let E=new Map;function B(){if(!r?.typeFilePath||!e)return null;let t=r.typeFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function w(){if(!r?.workerFilePath||!e)return null;let t=r.workerFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function re(){let t=w();if(t)try{fs.mkdirSync(path.dirname(t),{recursive:!0}),fs.writeFileSync(t,["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually.",'import { handleGameWorkerMessage } from "@drincs/pixi-vn/worker";',"","self.onmessage = async (event) => {"," const response = await handleGameWorkerMessage(event.data);"," if (response) self.postMessage(response);","};",""].join(`
2
+ `),"utf-8");}catch(n){e?.logger.error(`${p} Failed to write worker file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}function D(){let t=[...g,...Array.from(E.values()).flat()];return Array.from(new Set(t))}function ne(t,n,s,i,m){fs.mkdirSync(path.dirname(t),{recursive:true});let a=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(n.length>0){a.push('declare module "@drincs/pixi-vn/characters" {'),a.push(" interface PixivnCharacterIds {");for(let c of n)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }"),a.push("}");}if(s.length>0){a.push('declare module "@drincs/pixi-vn/narration" {'),a.push(" interface PixivnLabelIds {");for(let c of s)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }"),a.push("}");}if(i.length>0||m.length>0){if(a.push('declare module "@drincs/pixi-vn/canvas" {'),i.length>0){a.push(" interface PixivnBundleIds {");for(let c of i)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }");}if(m.length>0){a.push(" interface PixivnAssetAliasIds {");for(let c of m)a.push(` ${JSON.stringify(c)}: never;`);a.push(" }");}a.push("}");}a.push(`export const characterIds = ${JSON.stringify(n)} as const;`);{let c=Object.fromEntries(n.map(d=>[d,d]));a.push(`export const characterIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let c=Object.fromEntries(s.map(d=>[d,d]));a.push(`export const labelIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const bundleIds = ${JSON.stringify(i)} as const;`);{let c=Object.fromEntries(i.map(d=>[d,d]));a.push(`export const bundleIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(`export const assetAliasIds = ${JSON.stringify(m)} as const;`);{let c=Object.fromEntries(m.map(d=>[d,d]));a.push(`export const assetAliasIdsEnum = ${JSON.stringify(c)} as const;`);}a.push(""),fs.writeFileSync(t,a.join(`
3
+ `),"utf-8");}function se(){x.characters=l,x.labels=D();}function b(){se();let t=B();if(t)try{ne(t,l.map(n=>n.id),D(),xe(v),ye(v));}catch(n){e?.logger.error(`${p} Failed to write keys file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function O(t,n=[]){try{l=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{l=[];}try{g=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{g=[];}if(n.length>0){let{charIds:i,labelIds:m}=ve(n),a=new Set(l.map(d=>d.id)),c=new Set(g);for(let d of i)a.has(d)||l.push({id:d});for(let d of m)c.has(d)||g.push(d);}let s=l.map(i=>i.id).join(", ")||"none";e?.logger.info(`${p} ${F.default.dim(`${l.length} character(s): [${s}], ${g.length} label(s)`)}`,{timestamp:true});}async function J(t,n){let s=[],i=[...y(r?.characters),...y(r?.labels)],m=await tinyglobby.glob(i,{cwd:n,absolute:true,onlyFiles:true});for(let c of m){h.add(c);try{await t(c);}catch{s.push(c);}}await O(t,s),b();let a=await tinyglobby.glob(y(r?.content),{cwd:n,absolute:true,onlyFiles:true});for(let c of a){h.add(c);try{await t(c);}catch{s.push(c);}}return s}async function G(t,n){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let s=await J(t,n);await O(t,s),await _(t),b(),u();}async function ie(t){for(let s of h)for(let i of t.moduleGraph.getModulesByFile(s)??[])t.moduleGraph.invalidateModule(i);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await J(s=>t.ssrLoadModule(s),e.root);await O(s=>t.ssrLoadModule(s),n),await _(s=>t.ssrLoadModule(s)),b();for(let s of $)s();}let x={characters:null,labels:null,manifest:v??null,canvasOptions:null};function S(t,n){return (s,i)=>{if(i.setHeader("Content-Type","application/json"),s.method==="GET"){let m=x[t];if(m===null){i.statusCode=404,i.end(JSON.stringify({error:`${n} not initialized`}));return}i.statusCode=200,i.end(JSON.stringify(m));return}if(s.method==="POST"){let m="";s.on("data",a=>{m+=a.toString();}),s.on("end",()=>{try{x[t]=JSON.parse(m),i.statusCode=201,i.end(JSON.stringify({message:`${n} updated successfully`}));}catch{i.statusCode=400,i.end(JSON.stringify({error:`Invalid JSON format for ${n}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:f,get characters(){return l},onReload(t){$.push(t);},setExternalLabels(t,n){E.set(t,n),b();},clearExternalLabels(t){E.delete(t),b();},setAssetsManifest(t){v=t,x.manifest=t,b();}},resolveId(t){if(t===k)return q;if(t===T)return ee},load(t){if(t===q)return `import { Game } from "@drincs/pixi-vn";
4
+ Game.testing.enable(${L?JSON.stringify({windowKey:L}):""});
5
+ `;if(t===ee){let n=w();return n?['import { Game } from "@drincs/pixi-vn";',`import PixivnWorker from ${JSON.stringify(`${n}?worker`)};`,"Game.worker.register(new PixivnWorker());",""].join(`
6
+ `):""}},transformIndexHtml(){let t=[];return !te&&e?.command==="serve"&&t.push({tag:"script",attrs:{type:"module",src:`/@id/${k}`},injectTo:"head-prepend"}),r?.autoRegisterWorker&&w()&&t.push({tag:"script",attrs:{type:"module",src:`/@id/${T}`},injectTo:"head-prepend"}),t},config(t,n){if(n.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,re(),r?.autoRegisterWorker&&!w()&&e.logger.warn(`${p} "autoRegisterWorker" has no effect without "workerFilePath" - set both to auto-register the generated worker.`,{timestamp:true}),o.length===0&&!I&&(b(),u());},async buildStart(){if(e?.command!=="build"||o.length===0&&!I)return;let{createServer:t}=await import('vite'),n=await t({root:e.root,configFile:false,resolve:e.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await G(s=>n.ssrLoadModule(s),e.root);}catch{u();}finally{await n.close();}},configureServer(t){(o.length>0||I)&&G(n=>t.ssrLoadModule(n),e.root).catch(()=>{u();}),t.middlewares.use(R,S("characters","Characters")),t.middlewares.use(C,S("labels","Labels")),t.middlewares.use(N,S("manifest","Manifest")),t.middlewares.use(V,S("canvasOptions","Canvas options"));},async hotUpdate({file:t,server:n}){let s=B();if(s&&t===s)return [];if(o.length>0&&h.has(t)){try{await ie(n);}catch(i){e?.logger.error(`${p} Failed to reload content.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}return []}if(I)try{await _(i=>n.ssrLoadModule(i)),b();}catch(i){e?.logger.error(`${p} Failed to refresh the assets manifest.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=N;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=V;exports.PIXIVN_DEV_API_CHARACTERS=R;exports.PIXIVN_DEV_API_LABELS=C;exports.vitePluginPixivn=Ie;
package/dist/vite.d.cts CHANGED
@@ -74,6 +74,61 @@ interface VitePluginPixivnOptions {
74
74
  * @example "./src/pixi-vn.keys.gen.ts"
75
75
  */
76
76
  typeFilePath?: string;
77
+ /**
78
+ * Path to an auto-generated Worker entry file that hands every message it receives to
79
+ * `handleGameWorkerMessage` from `@drincs/pixi-vn/worker` — the file a project needs to make
80
+ * `Game.worker.register(...)` (see that function's doc comment) actually do something,
81
+ * without having to hand-write and maintain that file itself.
82
+ *
83
+ * Written once, when the plugin's config resolves (its content never changes, so unlike
84
+ * {@link typeFilePath} there's nothing to regenerate on content reload). Wire it up with
85
+ * Vite's own `?worker` import:
86
+ *
87
+ * ```ts
88
+ * // vite.config.ts
89
+ * vitePluginPixivn({ workerFilePath: "./src/pixi-vn.worker.gen.ts" })
90
+ *
91
+ * // wherever the app calls Game.init(...)
92
+ * import { Game } from "@drincs/pixi-vn";
93
+ * import PixivnWorker from "./pixi-vn.worker.gen?worker";
94
+ * Game.worker.register(new PixivnWorker());
95
+ * ```
96
+ *
97
+ * Purely a convenience: a project that wants a different worker setup (e.g. combining this
98
+ * with its own message types on the same worker) can just write the file by hand instead and
99
+ * skip this option entirely - `Game.worker.register` doesn't care which side created the file.
100
+ *
101
+ * The path may be absolute or relative to Vite `root`.
102
+ *
103
+ * @example "./src/pixi-vn.worker.gen.ts"
104
+ */
105
+ workerFilePath?: string;
106
+ /**
107
+ * Auto-registers the worker generated by {@link VitePluginPixivnOptions.workerFilePath} by
108
+ * injecting a small module into `index.html` that creates it and calls
109
+ * `Game.worker.register(...)` on page load - no app code required for this part, mirroring
110
+ * how {@link VitePluginPixivnOptions.testing} auto-injects its own bridge.
111
+ *
112
+ * Unlike `testing`, this **is** injected during `vite build` too - the worker offloads real
113
+ * runtime work (`back()`, save/export diffing), not a dev-only hook, so shipping without it
114
+ * would silently lose the optimization in production.
115
+ *
116
+ * Requires {@link VitePluginPixivnOptions.workerFilePath} to also be set; a project that needs
117
+ * more control over the worker's lifecycle (e.g. combining it with its own message types)
118
+ * should keep calling `Game.worker.register(new PixivnWorker())` by hand instead and leave
119
+ * this option unset - don't do both, the second registration would just replace the first.
120
+ *
121
+ * @default false
122
+ * @example
123
+ * ```ts
124
+ * // vite.config.ts — the entire worker setup, no app code needed
125
+ * vitePluginPixivn({
126
+ * workerFilePath: "./src/pixi-vn.worker.gen.ts",
127
+ * autoRegisterWorker: true,
128
+ * })
129
+ * ```
130
+ */
131
+ autoRegisterWorker?: boolean;
77
132
  /**
78
133
  * A PIXI.js {@link AssetsManifest} describing all asset bundles and their aliases — or a
79
134
  * function that resolves one, for manifests that aren't known synchronously at
@@ -180,6 +235,15 @@ interface VitePluginPixivnOptions {
180
235
  * The file is regenerated whenever the character or label set changes (content reload or
181
236
  * external-label updates). It is **excluded from HMR** so regenerating it never triggers a page reload.
182
237
  *
238
+ * **Auto-generated worker file**
239
+ *
240
+ * When {@link VitePluginPixivnOptions.workerFilePath} is provided, the plugin writes a Worker
241
+ * entry file wired to `handleGameWorkerMessage` from `@drincs/pixi-vn/worker` - see that option's
242
+ * doc comment for what it's for (`Game.worker.register(...)`) and how to import it. Written once
243
+ * (its content never changes), not regenerated on the triggers above. Add
244
+ * {@link VitePluginPixivnOptions.autoRegisterWorker} to also skip the manual
245
+ * `Game.worker.register(...)` call - the plugin creates and registers the worker itself.
246
+ *
183
247
  * **Auto-generated list file**
184
248
  *
185
249
  * When {@link VitePluginPixivnOptions.listFilePath} is provided, the plugin writes a
package/dist/vite.d.ts CHANGED
@@ -74,6 +74,61 @@ interface VitePluginPixivnOptions {
74
74
  * @example "./src/pixi-vn.keys.gen.ts"
75
75
  */
76
76
  typeFilePath?: string;
77
+ /**
78
+ * Path to an auto-generated Worker entry file that hands every message it receives to
79
+ * `handleGameWorkerMessage` from `@drincs/pixi-vn/worker` — the file a project needs to make
80
+ * `Game.worker.register(...)` (see that function's doc comment) actually do something,
81
+ * without having to hand-write and maintain that file itself.
82
+ *
83
+ * Written once, when the plugin's config resolves (its content never changes, so unlike
84
+ * {@link typeFilePath} there's nothing to regenerate on content reload). Wire it up with
85
+ * Vite's own `?worker` import:
86
+ *
87
+ * ```ts
88
+ * // vite.config.ts
89
+ * vitePluginPixivn({ workerFilePath: "./src/pixi-vn.worker.gen.ts" })
90
+ *
91
+ * // wherever the app calls Game.init(...)
92
+ * import { Game } from "@drincs/pixi-vn";
93
+ * import PixivnWorker from "./pixi-vn.worker.gen?worker";
94
+ * Game.worker.register(new PixivnWorker());
95
+ * ```
96
+ *
97
+ * Purely a convenience: a project that wants a different worker setup (e.g. combining this
98
+ * with its own message types on the same worker) can just write the file by hand instead and
99
+ * skip this option entirely - `Game.worker.register` doesn't care which side created the file.
100
+ *
101
+ * The path may be absolute or relative to Vite `root`.
102
+ *
103
+ * @example "./src/pixi-vn.worker.gen.ts"
104
+ */
105
+ workerFilePath?: string;
106
+ /**
107
+ * Auto-registers the worker generated by {@link VitePluginPixivnOptions.workerFilePath} by
108
+ * injecting a small module into `index.html` that creates it and calls
109
+ * `Game.worker.register(...)` on page load - no app code required for this part, mirroring
110
+ * how {@link VitePluginPixivnOptions.testing} auto-injects its own bridge.
111
+ *
112
+ * Unlike `testing`, this **is** injected during `vite build` too - the worker offloads real
113
+ * runtime work (`back()`, save/export diffing), not a dev-only hook, so shipping without it
114
+ * would silently lose the optimization in production.
115
+ *
116
+ * Requires {@link VitePluginPixivnOptions.workerFilePath} to also be set; a project that needs
117
+ * more control over the worker's lifecycle (e.g. combining it with its own message types)
118
+ * should keep calling `Game.worker.register(new PixivnWorker())` by hand instead and leave
119
+ * this option unset - don't do both, the second registration would just replace the first.
120
+ *
121
+ * @default false
122
+ * @example
123
+ * ```ts
124
+ * // vite.config.ts — the entire worker setup, no app code needed
125
+ * vitePluginPixivn({
126
+ * workerFilePath: "./src/pixi-vn.worker.gen.ts",
127
+ * autoRegisterWorker: true,
128
+ * })
129
+ * ```
130
+ */
131
+ autoRegisterWorker?: boolean;
77
132
  /**
78
133
  * A PIXI.js {@link AssetsManifest} describing all asset bundles and their aliases — or a
79
134
  * function that resolves one, for manifests that aren't known synchronously at
@@ -180,6 +235,15 @@ interface VitePluginPixivnOptions {
180
235
  * The file is regenerated whenever the character or label set changes (content reload or
181
236
  * external-label updates). It is **excluded from HMR** so regenerating it never triggers a page reload.
182
237
  *
238
+ * **Auto-generated worker file**
239
+ *
240
+ * When {@link VitePluginPixivnOptions.workerFilePath} is provided, the plugin writes a Worker
241
+ * entry file wired to `handleGameWorkerMessage` from `@drincs/pixi-vn/worker` - see that option's
242
+ * doc comment for what it's for (`Game.worker.register(...)`) and how to import it. Written once
243
+ * (its content never changes), not regenerated on the triggers above. Add
244
+ * {@link VitePluginPixivnOptions.autoRegisterWorker} to also skip the manual
245
+ * `Game.worker.register(...)` call - the plugin creates and registers the worker itself.
246
+ *
183
247
  * **Auto-generated list file**
184
248
  *
185
249
  * When {@link VitePluginPixivnOptions.listFilePath} is provided, the plugin writes a
package/dist/vite.mjs CHANGED
@@ -1,4 +1,6 @@
1
- import {a as a$1,b,c as c$1,d}from'./chunk-3BBZHKU4.mjs';export{c as PIXIVN_DEV_API_ASSETS_MANIFEST,d as PIXIVN_DEV_API_CANVAS_OPTIONS,a as PIXIVN_DEV_API_CHARACTERS,b as PIXIVN_DEV_API_LABELS}from'./chunk-3BBZHKU4.mjs';import {a,c}from'./chunk-K7JIC2F2.mjs';import {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var G=a((me,R)=>{var A=process||{},D=A.argv||[],I=A.env||{},Z=!(I.NO_COLOR||D.includes("--no-color"))&&(!!I.FORCE_COLOR||D.includes("--color")||A.platform==="win32"||(A.stdout||{}).isTTY&&I.TERM!=="dumb"||!!I.CI),q=(r,e,u=r)=>m=>{let l=""+m,c=l.indexOf(e,r.length);return ~c?r+ee(l,e,u,c)+e:r+l+e},ee=(r,e,u,m)=>{let l="",c=0;do l+=r.substring(c,m)+u,c=m+e.length,m=r.indexOf(e,c);while(~m);return l+r.substring(c)},j=(r=Z)=>{let e=r?q:()=>String;return {isColorSupported:r,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};R.exports=j();R.exports.createColors=j;});var F=c(G(),1);var v=F.default.cyan("(pixi-vn)"),V="virtual:pixi-vn-testing",K=`\0${V}`;function x(r){return r?Array.isArray(r)?r:[r]:[]}function oe(r){return r?r.bundles.map(e=>e.name):[]}function ce(r){if(!r)return [];let e=new Set;for(let u of r.bundles){let m=u.assets;if(Array.isArray(m))for(let l of m){let c=l.alias;if(c)for(let g of Array.isArray(c)?c:[c])e.add(g);}else if(m&&typeof m=="object")for(let l of Object.keys(m))e.add(l);}return Array.from(e)}function le(r){let e=[],u=[];for(let m of r)try{let l=readFileSync(m,"utf-8"),c=/newLabel\(\s*["']([^"']+)["']/g,g;for(;(g=c.exec(l))!==null;)u.push(g[1]);let h=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(g=h.exec(l))!==null;)e.push(g[1]);}catch{}return {charIds:e,labelIds:u}}function de(r){let e,u,m=new Promise(t=>{u=t;}),l=[...x(r?.content),...x(r?.characters),...x(r?.labels)],c=[],g=[],h=new Set,L=[],w=typeof r?.assetsManifest=="function",H=r?.testing===false,$=typeof r?.testing=="object"?r.testing.windowKey:void 0,y=typeof r?.assetsManifest=="function"?void 0:r?.assetsManifest;async function P(t){if(typeof r?.assetsManifest=="function")try{let n=await r.assetsManifest(t);y=n,p.manifest=n??null;}catch(n){e?.logger.error(`${v} Failed to resolve the assets manifest.`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}let E=new Map;function B(){if(!r?.typeFilePath||!e)return null;let t=r.typeFilePath;return isAbsolute(t)?t:resolve(e.root,t)}function T(){let t=[...g,...Array.from(E.values()).flat()];return Array.from(new Set(t))}function U(t,n,s,i,f){mkdirSync(dirname(t),{recursive:true});let a=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(n.length>0){a.push('declare module "@drincs/pixi-vn/characters" {'),a.push(" interface PixivnCharacterIds {");for(let o of n)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }"),a.push("}");}if(s.length>0){a.push('declare module "@drincs/pixi-vn/narration" {'),a.push(" interface PixivnLabelIds {");for(let o of s)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }"),a.push("}");}if(i.length>0||f.length>0){if(a.push('declare module "@drincs/pixi-vn/canvas" {'),i.length>0){a.push(" interface PixivnBundleIds {");for(let o of i)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }");}if(f.length>0){a.push(" interface PixivnAssetAliasIds {");for(let o of f)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }");}a.push("}");}a.push(`export const characterIds = ${JSON.stringify(n)} as const;`);{let o=Object.fromEntries(n.map(d=>[d,d]));a.push(`export const characterIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let o=Object.fromEntries(s.map(d=>[d,d]));a.push(`export const labelIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(`export const bundleIds = ${JSON.stringify(i)} as const;`);{let o=Object.fromEntries(i.map(d=>[d,d]));a.push(`export const bundleIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(`export const assetAliasIds = ${JSON.stringify(f)} as const;`);{let o=Object.fromEntries(f.map(d=>[d,d]));a.push(`export const assetAliasIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(""),writeFileSync(t,a.join(`
2
- `),"utf-8");}function z(){p.characters=c,p.labels=T();}function b$1(){z();let t=B();if(t)try{U(t,c.map(n=>n.id),T(),oe(y),ce(y));}catch(n){e?.logger.error(`${v} Failed to write keys file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function O(t,n=[]){try{c=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{c=[];}try{g=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{g=[];}if(n.length>0){let{charIds:i,labelIds:f}=le(n),a=new Set(c.map(d=>d.id)),o=new Set(g);for(let d of i)a.has(d)||c.push({id:d});for(let d of f)o.has(d)||g.push(d);}let s=c.map(i=>i.id).join(", ")||"none";e?.logger.info(`${v} ${F.default.dim(`${c.length} character(s): [${s}], ${g.length} label(s)`)}`,{timestamp:true});}async function J(t,n){let s=[],i=[...x(r?.characters),...x(r?.labels)],f=await glob(i,{cwd:n,absolute:true,onlyFiles:true});for(let o of f){h.add(o);try{await t(o);}catch{s.push(o);}}await O(t,s),b$1();let a=await glob(x(r?.content),{cwd:n,absolute:true,onlyFiles:true});for(let o of a){h.add(o);try{await t(o);}catch{s.push(o);}}return s}async function k(t,n){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let s=await J(t,n);await O(t,s),await P(t),b$1(),u();}async function W(t){for(let s of h)for(let i of t.moduleGraph.getModulesByFile(s)??[])t.moduleGraph.invalidateModule(i);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await J(s=>t.ssrLoadModule(s),e.root);await O(s=>t.ssrLoadModule(s),n),await P(s=>t.ssrLoadModule(s)),b$1();for(let s of L)s();}let p={characters:null,labels:null,manifest:y??null,canvasOptions:null};function S(t,n){return (s,i)=>{if(i.setHeader("Content-Type","application/json"),s.method==="GET"){let f=p[t];if(f===null){i.statusCode=404,i.end(JSON.stringify({error:`${n} not initialized`}));return}i.statusCode=200,i.end(JSON.stringify(f));return}if(s.method==="POST"){let f="";s.on("data",a=>{f+=a.toString();}),s.on("end",()=>{try{p[t]=JSON.parse(f),i.statusCode=201,i.end(JSON.stringify({message:`${n} updated successfully`}));}catch{i.statusCode=400,i.end(JSON.stringify({error:`Invalid JSON format for ${n}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return c},onReload(t){L.push(t);},setExternalLabels(t,n){E.set(t,n),b$1();},clearExternalLabels(t){E.delete(t),b$1();},setAssetsManifest(t){y=t,p.manifest=t,b$1();}},resolveId(t){if(t===V)return K},load(t){if(t===K)return `import { Game } from "@drincs/pixi-vn";
3
- Game.testing.enable(${$?JSON.stringify({windowKey:$}):""});
4
- `},transformIndexHtml(){if(!(H||e?.command!=="serve"))return [{tag:"script",attrs:{type:"module",src:`/@id/${V}`},injectTo:"head-prepend"}]},config(t,n){if(n.command==="serve"&&l.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,l.length===0&&!w&&(b$1(),u());},async buildStart(){if(e?.command!=="build"||l.length===0&&!w)return;let{createServer:t}=await import('vite'),n=await t({root:e.root,configFile:false,resolve:e.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await k(s=>n.ssrLoadModule(s),e.root);}catch{u();}finally{await n.close();}},configureServer(t){(l.length>0||w)&&k(n=>t.ssrLoadModule(n),e.root).catch(()=>{u();}),t.middlewares.use(a$1,S("characters","Characters")),t.middlewares.use(b,S("labels","Labels")),t.middlewares.use(c$1,S("manifest","Manifest")),t.middlewares.use(d,S("canvasOptions","Canvas options"));},async hotUpdate({file:t,server:n}){let s=B();if(s&&t===s)return [];if(l.length>0&&h.has(t)){try{await W(n);}catch(i){e?.logger.error(`${v} Failed to reload content.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}return []}if(w)try{await P(i=>n.ssrLoadModule(i)),b$1();}catch(i){e?.logger.error(`${v} Failed to refresh the assets manifest.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}}}export{de as vitePluginPixivn};
1
+ import {a as a$1,b,c as c$1,d}from'./chunk-3BBZHKU4.mjs';export{c as PIXIVN_DEV_API_ASSETS_MANIFEST,d as PIXIVN_DEV_API_CANVAS_OPTIONS,a as PIXIVN_DEV_API_CHARACTERS,b as PIXIVN_DEV_API_LABELS}from'./chunk-3BBZHKU4.mjs';import {a,c}from'./chunk-K7JIC2F2.mjs';import {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var X=a((be,k)=>{var A=process||{},j=A.argv||[],P=A.env||{},oe=!(P.NO_COLOR||j.includes("--no-color"))&&(!!P.FORCE_COLOR||j.includes("--color")||A.platform==="win32"||(A.stdout||{}).isTTY&&P.TERM!=="dumb"||!!P.CI),ce=(n,t,m=n)=>d=>{let l=""+d,c=l.indexOf(t,n.length);return ~c?n+le(l,t,m,c)+t:n+l+t},le=(n,t,m,d)=>{let l="",c=0;do l+=n.substring(c,d)+m,c=d+t.length,d=n.indexOf(t,c);while(~d);return l+n.substring(c)},W=(n=oe)=>{let t=n?ce:()=>String;return {isColorSupported:n,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};k.exports=W();k.exports.createColors=W;});var $=c(X(),1);var h=$.default.cyan("(pixi-vn)"),V="virtual:pixi-vn-testing",Z=`\0${V}`,F="virtual:pixi-vn-worker-register",q=`\0${F}`;function y(n){return n?Array.isArray(n)?n:[n]:[]}function de(n){return n?n.bundles.map(t=>t.name):[]}function fe(n){if(!n)return [];let t=new Set;for(let m of n.bundles){let d=m.assets;if(Array.isArray(d))for(let l of d){let c=l.alias;if(c)for(let g of Array.isArray(c)?c:[c])t.add(g);}else if(d&&typeof d=="object")for(let l of Object.keys(d))t.add(l);}return Array.from(t)}function me(n){let t=[],m=[];for(let d of n)try{let l=readFileSync(d,"utf-8"),c=/newLabel\(\s*["']([^"']+)["']/g,g;for(;(g=c.exec(l))!==null;)m.push(g[1]);let p=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(g=p.exec(l))!==null;)t.push(g[1]);}catch{}return {charIds:t,labelIds:m}}function ge(n){let t,m,d$1=new Promise(e=>{m=e;}),l=[...y(n?.content),...y(n?.characters),...y(n?.labels)],c=[],g=[],p=new Set,T=[],w=typeof n?.assetsManifest=="function",ee=n?.testing===false,L=typeof n?.testing=="object"?n.testing.windowKey:void 0,v=typeof n?.assetsManifest=="function"?void 0:n?.assetsManifest;async function E(e){if(typeof n?.assetsManifest=="function")try{let r=await n.assetsManifest(e);v=r,x.manifest=r??null;}catch(r){t?.logger.error(`${h} Failed to resolve the assets manifest.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}let O=new Map;function B(){if(!n?.typeFilePath||!t)return null;let e=n.typeFilePath;return isAbsolute(e)?e:resolve(t.root,e)}function I(){if(!n?.workerFilePath||!t)return null;let e=n.workerFilePath;return isAbsolute(e)?e:resolve(t.root,e)}function te(){let e=I();if(e)try{mkdirSync(dirname(e),{recursive:!0}),writeFileSync(e,["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually.",'import { handleGameWorkerMessage } from "@drincs/pixi-vn/worker";',"","self.onmessage = async (event) => {"," const response = await handleGameWorkerMessage(event.data);"," if (response) self.postMessage(response);","};",""].join(`
2
+ `),"utf-8");}catch(r){t?.logger.error(`${h} Failed to write worker file "${e}".`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}function J(){let e=[...g,...Array.from(O.values()).flat()];return Array.from(new Set(e))}function re(e,r,s,i,f){mkdirSync(dirname(e),{recursive:true});let a=["/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(r.length>0){a.push('declare module "@drincs/pixi-vn/characters" {'),a.push(" interface PixivnCharacterIds {");for(let o of r)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }"),a.push("}");}if(s.length>0){a.push('declare module "@drincs/pixi-vn/narration" {'),a.push(" interface PixivnLabelIds {");for(let o of s)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }"),a.push("}");}if(i.length>0||f.length>0){if(a.push('declare module "@drincs/pixi-vn/canvas" {'),i.length>0){a.push(" interface PixivnBundleIds {");for(let o of i)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }");}if(f.length>0){a.push(" interface PixivnAssetAliasIds {");for(let o of f)a.push(` ${JSON.stringify(o)}: never;`);a.push(" }");}a.push("}");}a.push(`export const characterIds = ${JSON.stringify(r)} as const;`);{let o=Object.fromEntries(r.map(u=>[u,u]));a.push(`export const characterIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(`export const labelIds = ${JSON.stringify(s)} as const;`);{let o=Object.fromEntries(s.map(u=>[u,u]));a.push(`export const labelIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(`export const bundleIds = ${JSON.stringify(i)} as const;`);{let o=Object.fromEntries(i.map(u=>[u,u]));a.push(`export const bundleIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(`export const assetAliasIds = ${JSON.stringify(f)} as const;`);{let o=Object.fromEntries(f.map(u=>[u,u]));a.push(`export const assetAliasIdsEnum = ${JSON.stringify(o)} as const;`);}a.push(""),writeFileSync(e,a.join(`
3
+ `),"utf-8");}function ne(){x.characters=c,x.labels=J();}function b$1(){ne();let e=B();if(e)try{re(e,c.map(r=>r.id),J(),de(v),fe(v));}catch(r){t?.logger.error(`${h} Failed to write keys file "${e}".`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}}async function _(e,r=[]){try{c=(await e("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{c=[];}try{g=(await e("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{g=[];}if(r.length>0){let{charIds:i,labelIds:f}=me(r),a=new Set(c.map(u=>u.id)),o=new Set(g);for(let u of i)a.has(u)||c.push({id:u});for(let u of f)o.has(u)||g.push(u);}let s=c.map(i=>i.id).join(", ")||"none";t?.logger.info(`${h} ${$.default.dim(`${c.length} character(s): [${s}], ${g.length} label(s)`)}`,{timestamp:true});}async function D(e,r){let s=[],i=[...y(n?.characters),...y(n?.labels)],f=await glob(i,{cwd:r,absolute:true,onlyFiles:true});for(let o of f){p.add(o);try{await e(o);}catch{s.push(o);}}await _(e,s),b$1();let a=await glob(y(n?.content),{cwd:r,absolute:true,onlyFiles:true});for(let o of a){p.add(o);try{await e(o);}catch{s.push(o);}}return s}async function G(e,r){try{await e("@drincs/pixi-vn/characters");}catch{}try{await e("@drincs/pixi-vn/narration");}catch{}let s=await D(e,r);await _(e,s),await E(e),b$1(),m();}async function se(e){for(let s of p)for(let i of e.moduleGraph.getModulesByFile(s)??[])e.moduleGraph.invalidateModule(i);try{(await e.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await e.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let r=await D(s=>e.ssrLoadModule(s),t.root);await _(s=>e.ssrLoadModule(s),r),await E(s=>e.ssrLoadModule(s)),b$1();for(let s of T)s();}let x={characters:null,labels:null,manifest:v??null,canvasOptions:null};function S(e,r){return (s,i)=>{if(i.setHeader("Content-Type","application/json"),s.method==="GET"){let f=x[e];if(f===null){i.statusCode=404,i.end(JSON.stringify({error:`${r} not initialized`}));return}i.statusCode=200,i.end(JSON.stringify(f));return}if(s.method==="POST"){let f="";s.on("data",a=>{f+=a.toString();}),s.on("end",()=>{try{x[e]=JSON.parse(f),i.statusCode=201,i.end(JSON.stringify({message:`${r} updated successfully`}));}catch{i.statusCode=400,i.end(JSON.stringify({error:`Invalid JSON format for ${r}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:d$1,get characters(){return c},onReload(e){T.push(e);},setExternalLabels(e,r){O.set(e,r),b$1();},clearExternalLabels(e){O.delete(e),b$1();},setAssetsManifest(e){v=e,x.manifest=e,b$1();}},resolveId(e){if(e===V)return Z;if(e===F)return q},load(e){if(e===Z)return `import { Game } from "@drincs/pixi-vn";
4
+ Game.testing.enable(${L?JSON.stringify({windowKey:L}):""});
5
+ `;if(e===q){let r=I();return r?['import { Game } from "@drincs/pixi-vn";',`import PixivnWorker from ${JSON.stringify(`${r}?worker`)};`,"Game.worker.register(new PixivnWorker());",""].join(`
6
+ `):""}},transformIndexHtml(){let e=[];return !ee&&t?.command==="serve"&&e.push({tag:"script",attrs:{type:"module",src:`/@id/${V}`},injectTo:"head-prepend"}),n?.autoRegisterWorker&&I()&&e.push({tag:"script",attrs:{type:"module",src:`/@id/${F}`},injectTo:"head-prepend"}),e},config(e,r){if(r.command==="serve"&&l.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(e){t=e,te(),n?.autoRegisterWorker&&!I()&&t.logger.warn(`${h} "autoRegisterWorker" has no effect without "workerFilePath" - set both to auto-register the generated worker.`,{timestamp:true}),l.length===0&&!w&&(b$1(),m());},async buildStart(){if(t?.command!=="build"||l.length===0&&!w)return;let{createServer:e}=await import('vite'),r=await e({root:t.root,configFile:false,resolve:t.resolve,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await G(s=>r.ssrLoadModule(s),t.root);}catch{m();}finally{await r.close();}},configureServer(e){(l.length>0||w)&&G(r=>e.ssrLoadModule(r),t.root).catch(()=>{m();}),e.middlewares.use(a$1,S("characters","Characters")),e.middlewares.use(b,S("labels","Labels")),e.middlewares.use(c$1,S("manifest","Manifest")),e.middlewares.use(d,S("canvasOptions","Canvas options"));},async hotUpdate({file:e,server:r}){let s=B();if(s&&e===s)return [];if(l.length>0&&p.has(e)){try{await se(r);}catch(i){t?.logger.error(`${h} Failed to reload content.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}return []}if(w)try{await E(i=>r.ssrLoadModule(i)),b$1();}catch(i){t?.logger.error(`${h} Failed to refresh the assets manifest.`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}}}export{ge as vitePluginPixivn};
@@ -0,0 +1 @@
1
+ 'use strict';var i=class extends Error{code;constructor(t,r,a,o,m){super(`[Pixi\u2019VN] ${r}`),this.code=t,a==="canvas"&&(this.canvasElementInfo=o,this.parent=m);}canvasElementInfo;parent};var n;(o=>(o.log=(m,...l)=>console.log(`[Pixi\u2019VN] ${m}`,...l),o.warn=(m,...l)=>console.warn(`[Pixi\u2019VN] ${m}`,...l),o.error=(m,...l)=>console.error(`[Pixi\u2019VN] ${m}`,...l),o.info=(m,...l)=>console.info(`[Pixi\u2019VN] ${m}`,...l)))(n||={});(class e{static init(t){t.navigate&&(e._navigate=t.navigate),e._getStepCounter=t.getStepCounter,e._setStepCounter=t.setStepCounter,e._getCurrentGameStepState=t.getCurrentGameStepState,e._restoreGameStepState=t.restoreGameStepState,e._getOpenedLabels=t.getOpenedLabels,e._processNavigationRequests=t.processNavigationRequests,e._getVariable=t.getVariable,e._setVariable=t.setVariable,e._removeVariable=t.removeVariable,e._getFlag=t.getFlag,e._setFlag=t.setFlag,t.onLabelClosing&&(e._onLabelClosing=t.onLabelClosing),e._addHistoryItem=t.addHistoryItem,e._getCharacter=t.getCharacter,e._animate=t.animate;}static _navigate=()=>{n.warn("Navigate function not initialized. You should add the navigate function in the Game.init() method.");};static get navigate(){return e._navigate}static set navigate(t){e._navigate=t;}static _getStepCounter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return e._getStepCounter()}static set stepCounter(t){e._setStepCounter(t);}static _getCurrentGameStepState=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return e._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return e._restoreGameStepState}static _getOpenedLabels=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return e._getOpenedLabels()}static _onPreContinueHandlers=[];static addOnPreContinue(t){e._onPreContinueHandlers.push(t);}static removeOnPreContinue(t){e._onPreContinueHandlers=e._onPreContinueHandlers.filter(r=>r!==t);}static clearOnPreContinueHandlers(){e._onPreContinueHandlers=[];}static async runOnPreContinue(){let t=e._onPreContinueHandlers.slice();await Promise.all(t.map(r=>r()));}static get onPreContinue(){return e.runOnPreContinue}static navigationRequestsCount=0;static processNavigationLock=Promise.resolve();static get continueRequestsCount(){return e.navigationRequestsCount}static increaseContinueRequest(t=1){e.navigationRequestsCount+=t;}static get backRequestsCount(){return -1*e.navigationRequestsCount}static increaseBackRequest(t=1){e.navigationRequestsCount-=t;}static _processNavigationRequests=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static async processNavigationRequests(t){let r=e._processNavigationRequests(e.navigationRequestsCount,t);return e.navigationRequestsCount=r.newValue,await r.result}static _getVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return e._getVariable}static _setVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return e._setVariable}static _removeVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return e._removeVariable}static _getFlag=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return e._getFlag}static _setFlag=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return e._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return e._onLabelClosing}static _addHistoryItem=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return e._addHistoryItem}static runningStepsCount=0;static _getCharacter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented.")};static get getCharacter(){return e._getCharacter}static onEnd;static _onErrorHandlers=[];static addOnError(t){return e._onErrorHandlers.push(t),()=>e.removeOnError(t)}static removeOnError(t){e._onErrorHandlers=e._onErrorHandlers.filter(r=>r!==t);}static clearOnErrorHandlers(){e._onErrorHandlers.length=0;}static async runOnError(t,r){for(let a of e._onErrorHandlers.slice())try{await a(t,r);}catch(o){n.error("Error in onError handler",o);}}static _animate=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get animate(){return e._animate}});function y(e){try{if(typeof e>"u")return e;let t=JSON.stringify(e);return JSON.parse(t)}catch(t){throw n.error("Error creating exportable element",e,t),new i("not_json_serializable","Error creating exportable element")}}function h(e,t){let r=y(e);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(a=>{E(r,a);}),r}function E(e,t){let r=e;t.path&&t.path.length>0?t.path.forEach((a,o)=>{if(t.path&&o===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":r[a]=t.oldValue;break;case "CREATE":Array.isArray(r)&&typeof a=="number"?r.splice(a,1):delete r[a];break}else r=r[a];}):n.warn("No path found, skipping diff",t);}var w=["Date","RegExp","String","Number"],S=Object.getOwnPropertyNames(globalThis.Temporal||{});function c(e,t,r={cyclesFix:true},a=[]){let o=[],m=Array.isArray(e);for(let p in e){let s=e[p],v=m?+p:p;if(!(p in t)){o.push({type:"REMOVE",path:[v],oldValue:s});continue}let u=t[p],G=typeof s=="object"&&typeof u=="object"&&Array.isArray(s)===Array.isArray(u),g=G&&s?Object.getPrototypeOf(s)?.constructor?.name:void 0;if(s&&u&&G&&!w.includes(g)&&!S.includes(g)&&(!r.cyclesFix||!a.includes(s))){r.cyclesFix&&a.push(s);let k=c(s,u,r,a);r.cyclesFix&&a.pop();for(let C of k)C.path.unshift(v),o.push(C);}else Object.is(s,u)||S.includes(g)&&String(s)===String(u)||w.includes(g)&&(isNaN(s)?s+""==u+"":+s==+u)||o.push({path:[v],type:"CHANGE",value:u,oldValue:s});}let l=Array.isArray(t);for(let p in t)p in e||o.push({type:"CREATE",path:[l?+p:p],value:t[p]});return o}var b=new Map;function x(e,t){b.set(e,t);}function P(e){b.delete(e);}function T(e){return b.get(e)}async function M(e){try{switch(e.type){case "restore-diff":{let t=h(e.state,e.diff);return {id:e.id,type:"restore-diff-result",result:t}}case "diff":{let t=c(e.before,e.after);return {id:e.id,type:"diff-result",result:t}}case "clone":{let t=JSON.parse(JSON.stringify(e.value));return {id:e.id,type:"clone-result",result:t}}case "custom":{let t=T(e.kind);if(!t)throw new Error(`No game worker handler registered for kind "${e.kind}"`);let r=await t(e.payload);return {id:e.id,type:"custom-result",result:r}}}}catch(t){return {id:e.id,type:"error",error:t instanceof Error?t.message:String(t)}}}var d=class e{static _worker;static _pending=new Map;static _nextId=0;static get isAvailable(){return e._worker!==void 0}static register(t){e.unregister(),e._worker=t,t.addEventListener("message",e._handleMessage);}static unregister(){let t=e._worker;if(t){t.removeEventListener("message",e._handleMessage),e._worker=void 0;for(let{reject:r}of e._pending.values())r(new Error("Game worker was unregistered"));e._pending.clear();}}static _handleMessage=t=>{let r=e._pending.get(t.data.id);r&&(e._pending.delete(t.data.id),t.data.type==="error"?r.reject(new Error(t.data.error)):r.resolve(t.data.result));};static _request(t){let r=e._worker;if(!r)return Promise.reject(new Error("No game worker is registered"));let a=e._nextId++;return new Promise((o,m)=>{e._pending.set(a,{resolve:o,reject:m});try{r.postMessage({...t,id:a});}catch(l){e._pending.delete(a),n.error("Error posting message to game worker",l),m(l);}})}static async restoreDiff(t,r){return await e._request({type:"restore-diff",state:t,diff:r})}static async diff(t,r){return await e._request({type:"diff",before:t,after:r})}static async clone(t){return await e._request({type:"clone",value:t})}static async custom(t,r){return await e._request({type:"custom",kind:t,payload:r})}};async function R(e,t){if(d.isAvailable)try{return await d.restoreDiff(e,t)}catch(r){n.warn("Game worker failed to restore diff, falling back to the main thread",r);}return h(e,t)}async function O(e,t){if(d.isAvailable)try{return await d.diff(e,t)}catch(r){n.warn("Game worker failed to compute diff, falling back to the main thread",r);}return c(e,t)}async function H(e){if(d.isAvailable)try{return await d.clone(e)}catch(t){n.warn("Game worker failed to clone value, falling back to the main thread",t);}return y(e)}exports.GameWorkerManager=d;exports.cloneMaybeOffloaded=H;exports.diffMaybeOffloaded=O;exports.handleGameWorkerMessage=M;exports.registerGameWorkerHandler=x;exports.restoreDiffMaybeOffloaded=R;exports.unregisterGameWorkerHandler=P;