@drincs/pixi-vn 1.8.7 → 1.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/chunk-3M6A7TU2.mjs +1 -1
- package/dist/chunk-BQRPDCUT.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +1 -1
- package/dist/narration.d.cts +8 -8
- package/dist/narration.d.ts +8 -8
- package/dist/narration.mjs +1 -1
- package/dist/sound.cjs +1 -1
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/vite-listener.cjs +1 -1
- package/dist/vite-listener.mjs +1 -1
- package/package.json +7 -3
package/dist/sound.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core'),kt=require('@drincs/pixi-vn/pixi.js'),B=require('tone');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var kt__default=/*#__PURE__*/_interopDefault(kt);var B__namespace=/*#__PURE__*/_interopNamespace(B);var Rt=Object.defineProperty;var wt=o=>{throw TypeError(o)};var Nt=(o,t,e)=>t in o?Rt(o,t,{enumerable:true,configurable:true,writable:true,value:e}):o[t]=e;var m=(o,t,e)=>Nt(o,typeof t!="symbol"?t+"":t,e),ze=(o,t,e)=>t.has(o)||wt("Cannot "+e);var i=(o,t,e)=>(ze(o,t,"read from private field"),e?e.call(o):t.get(o)),v=(o,t,e)=>t.has(o)?wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),c=(o,t,e,n)=>(ze(o,t,"write to private field"),t.set(o,e),e),d=(o,t,e)=>(ze(o,t,"access private method"),e);var De=(o,t,e,n)=>({set _(s){c(o,t,s);},get _(){return i(o,t,n)}});var Tt="general";var Gt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ot=new Set,qe=typeof process=="object"&&process?process:{},_t=(o,t,e,n)=>{typeof qe.emitWarning=="function"?qe.emitWarning(o,t,e,n):console.error(`[${e}] ${t}: ${o}`);},Re=globalThis.AbortController,At=globalThis.AbortSignal;if(typeof Re>"u"){At=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(e,n){this._onabort.push(n);}},Re=class{constructor(){m(this,"signal",new At);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let n of this.signal._onabort)n(e);this.signal.onabort?.(e);}}};let o=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{o&&(o=false,_t("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var Lt=o=>!Ot.has(o);var se=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),Ct=o=>se(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ie:null:null,Ie=class extends Array{constructor(o){super(o),this.fill(0);}},te,fe,zt=(te=class{constructor(t,e){m(this,"heap");m(this,"length");if(!i(te,fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Ct(t);if(!e)return [];c(te,fe,true);let n=new te(t,e);return c(te,fe,false),n}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},fe=new WeakMap,v(te,fe,false),te),St,Ft,j,q,K,he,$,ye,ge,H,E,X,_,S,f,N,U,I,P,Q,x,Z,J,W,V,ee,le,G,ve,h,Ue,ue,ie,Fe,Y,Pt,de,be,Oe,ae,re,We,Me,ke,A,Ve,Se,oe,Ye,we,Et=(we=class{constructor(t){v(this,h);v(this,j);v(this,q);v(this,K);v(this,he);v(this,$);v(this,ye);v(this,ge);v(this,H);m(this,"ttl");m(this,"ttlResolution");m(this,"ttlAutopurge");m(this,"updateAgeOnGet");m(this,"updateAgeOnHas");m(this,"allowStale");m(this,"noDisposeOnSet");m(this,"noUpdateTTL");m(this,"maxEntrySize");m(this,"sizeCalculation");m(this,"noDeleteOnFetchRejection");m(this,"noDeleteOnStaleGet");m(this,"allowStaleOnFetchAbort");m(this,"allowStaleOnFetchRejection");m(this,"ignoreFetchAbort");v(this,E);v(this,X);v(this,_);v(this,S);v(this,f);v(this,N);v(this,U);v(this,I);v(this,P);v(this,Q);v(this,x);v(this,Z);v(this,J);v(this,W);v(this,V);v(this,ee);v(this,le);v(this,G);v(this,ve);v(this,ue,()=>{});v(this,ie,()=>{});v(this,Fe,()=>{});v(this,Y,()=>false);v(this,de,t=>{});v(this,be,(t,e,n)=>{});v(this,Oe,(t,e,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,St,"LRUCache");let{max:e=0,ttl:n,ttlResolution:s=1,ttlAutopurge:r,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:g,onInsert:w,disposeAfter:b,noDisposeOnSet:M,noUpdateTTL:D,maxSize:z=0,maxEntrySize:F=0,sizeCalculation:T,fetchMethod:y,memoMethod:k,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:Ae,ignoreFetchAbort:ce,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,H,pe??Gt),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let me=e?Ct(e):Array;if(!me)throw new Error("invalid max value: "+e);if(c(this,j,e),c(this,q,z),this.maxEntrySize=F||i(this,q),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,q)&&!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(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,ge,k),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,ye,y),c(this,le,!!y),c(this,_,new Map),c(this,S,new Array(e).fill(void 0)),c(this,f,new Array(e).fill(void 0)),c(this,N,new me(e)),c(this,U,new me(e)),c(this,I,0),c(this,P,0),c(this,Q,zt.create(e)),c(this,E,0),c(this,X,0),typeof g=="function"&&c(this,K,g),typeof w=="function"&&c(this,he,w),typeof b=="function"?(c(this,$,b),c(this,x,[])):(c(this,$,void 0),c(this,x,void 0)),c(this,ee,!!i(this,K)),c(this,ve,!!i(this,he)),c(this,G,!!i(this,$)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!Ae,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(i(this,q)!==0&&!se(i(this,q)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,h,Pt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,h,Ue).call(this);}if(i(this,j)===0&&this.ttl===0&&i(this,q)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,j)&&!i(this,q)){let Le="LRU_CACHE_UNBOUNDED";Lt(Le)&&(Ot.add(Le),_t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,we));}}get perf(){return i(this,H)}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,W),autopurgeTimers:i(t,V),sizes:i(t,Z),keyMap:i(t,_),keyList:i(t,S),valList:i(t,f),next:i(t,N),prev:i(t,U),get head(){return i(t,I)},get tail(){return i(t,P)},free:i(t,Q),isBackgroundFetch:e=>{var n;return d(n=t,h,A).call(n,e)},backgroundFetch:(e,n,s,r)=>{var a;return d(a=t,h,ke).call(a,e,n,s,r)},moveToTail:e=>{var n;return d(n=t,h,Se).call(n,e)},indexes:e=>{var n;return d(n=t,h,ae).call(n,e)},rindexes:e=>{var n;return d(n=t,h,re).call(n,e)},isStale:e=>{var n;return i(n=t,Y).call(n,e)}}}get max(){return i(this,j)}get maxSize(){return i(this,q)}get calculatedSize(){return i(this,X)}get size(){return i(this,E)}get fetchMethod(){return i(this,ye)}get memoMethod(){return i(this,ge)}get dispose(){return i(this,K)}get onInsert(){return i(this,he)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,_).has(t)?1/0:0}*entries(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*rentries(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*keys(){for(let t of d(this,h,ae).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*rkeys(){for(let t of d(this,h,re).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*values(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}*rvalues(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}[(Ft=Symbol.iterator,St=Symbol.toStringTag,Ft)](){return this.entries()}find(t,e={}){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r!==void 0&&t(r,i(this,S)[n],this))return this.get(i(this,S)[n],e)}}forEach(t,e=this){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}rforEach(t,e=this){for(let n of d(this,h,re).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}purgeStale(){let t=false;for(let e of d(this,h,re).call(this,{allowStale:true}))i(this,Y).call(this,e)&&(d(this,h,oe).call(this,i(this,S)[e],"expire"),t=true);return t}info(t){let e=i(this,_).get(t);if(e===void 0)return;let n=i(this,f)[e],s=d(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(s===void 0)return;let r={value:s};if(i(this,W)&&i(this,J)){let a=i(this,W)[e],l=i(this,J)[e];if(a&&l){let u=a-(i(this,H).now()-l);r.ttl=u,r.start=Date.now();}}return i(this,Z)&&(r.size=i(this,Z)[e]),r}dump(){let t=[];for(let e of d(this,h,ae).call(this,{allowStale:true})){let n=i(this,S)[e],s=i(this,f)[e],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0||n===void 0)continue;let a={value:r};if(i(this,W)&&i(this,J)){a.ttl=i(this,W)[e];let l=i(this,H).now()-i(this,J)[e];a.start=Math.floor(Date.now()-l);}i(this,Z)&&(a.size=i(this,Z)[e]),t.unshift([n,a]);}return t}load(t){this.clear();for(let[e,n]of t){if(n.start){let s=Date.now()-n.start;n.start=i(this,H).now()-s;}this.set(e,n.value,n);}}set(t,e,n={}){var M,D,z,F;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,{noUpdateTTL:g=this.noUpdateTTL}=n,w=i(this,Oe).call(this,t,e,n.size||0,l);if(this.maxEntrySize&&w>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),d(this,h,oe).call(this,t,"set"),this;let b=i(this,E)===0?void 0:i(this,_).get(t);if(b===void 0)b=i(this,E)===0?i(this,P):i(this,Q).length!==0?i(this,Q).pop():i(this,E)===i(this,j)?d(this,h,Me).call(this,false):i(this,E),i(this,S)[b]=t,i(this,f)[b]=e,i(this,_).set(t,b),i(this,N)[i(this,P)]=b,i(this,U)[b]=i(this,P),c(this,P,b),De(this,E)._++,i(this,be).call(this,b,w,u),u&&(u.set="add"),g=false,i(this,ve)&&((M=i(this,he))==null||M.call(this,e,t,"add"));else {d(this,h,Se).call(this,b);let T=i(this,f)[b];if(e!==T){if(i(this,le)&&d(this,h,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=T;y!==void 0&&!a&&(i(this,ee)&&((D=i(this,K))==null||D.call(this,y,t,"set")),i(this,G)&&i(this,x)?.push([y,t,"set"]));}else a||(i(this,ee)&&((z=i(this,K))==null||z.call(this,T,t,"set")),i(this,G)&&i(this,x)?.push([T,t,"set"]));if(i(this,de).call(this,b),i(this,be).call(this,b,w,u),i(this,f)[b]=e,u){u.set="replace";let y=T&&d(this,h,A).call(this,T)?T.__staleWhileFetching:T;y!==void 0&&(u.oldValue=y);}}else u&&(u.set="update");i(this,ve)&&this.onInsert?.(e,t,e===T?"update":"replace");}if(s!==0&&!i(this,W)&&d(this,h,Ue).call(this),i(this,W)&&(g||i(this,Fe).call(this,b,s,r),u&&i(this,ie).call(this,u,b)),!a&&i(this,G)&&i(this,x)){let T=i(this,x),y;for(;y=T?.shift();)(F=i(this,$))==null||F.call(this,...y);}return this}pop(){var t;try{for(;i(this,E);){let e=i(this,f)[i(this,I)];if(d(this,h,Me).call(this,!0),d(this,h,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,G)&&i(this,x)){let e=i(this,x),n;for(;n=e?.shift();)(t=i(this,$))==null||t.call(this,...n);}}}has(t,e={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=e,r=i(this,_).get(t);if(r!==void 0){let a=i(this,f)[r];if(d(this,h,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Y).call(this,r))s&&(s.has="stale",i(this,ie).call(this,s,r));else return n&&i(this,ue).call(this,r),s&&(s.has="hit",i(this,ie).call(this,s,r)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:n=this.allowStale}=e,s=i(this,_).get(t);if(s===void 0||!n&&i(this,Y).call(this,s))return;let r=i(this,f)[s];return d(this,h,A).call(this,r)?r.__staleWhileFetching:r}async fetch(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:w=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:F,forceRefresh:T=false,status:y,signal:k}=e;if(!i(this,le))return y&&(y.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,status:y});let L={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:g,noUpdateTTL:w,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:z,ignoreFetchAbort:D,status:y,signal:k},R=i(this,_).get(t);if(R===void 0){y&&(y.fetch="miss");let O=d(this,h,ke).call(this,t,R,L,F);return O.__returned=O}else {let O=i(this,f)[R];if(d(this,h,A).call(this,O)){let me=n&&O.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",me&&(y.returnedStale=true)),me?O.__staleWhileFetching:O.__returned=O}let Ae=i(this,Y).call(this,R);if(!T&&!Ae)return y&&(y.fetch="hit"),d(this,h,Se).call(this,R),s&&i(this,ue).call(this,R),y&&i(this,ie).call(this,y,R),O;let ce=d(this,h,ke).call(this,t,R,L,F),pe=ce.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=Ae?"stale":"refresh",pe&&Ae&&(y.returnedStale=true)),pe?ce.__staleWhileFetching:ce.__returned=ce}}async forceFetch(t,e={}){let n=await this.fetch(t,e);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,e={}){let n=i(this,ge);if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:r,...a}=e,l=this.get(t,a);if(!r&&l!==void 0)return l;let u=n(t,l,{options:a,context:s});return this.set(t,u,a),u}get(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}=e,l=i(this,_).get(t);if(l!==void 0){let u=i(this,f)[l],g=d(this,h,A).call(this,u);return a&&i(this,ie).call(this,a,l),i(this,Y).call(this,l)?(a&&(a.get="stale"),g?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),n?u.__staleWhileFetching:void 0):(r||d(this,h,oe).call(this,t,"expire"),a&&n&&(a.returnedStale=true),n?u:void 0)):(a&&(a.get="hit"),g?u.__staleWhileFetching:(d(this,h,Se).call(this,l),s&&i(this,ue).call(this,l),u))}else a&&(a.get="miss");}delete(t){return d(this,h,oe).call(this,t,"delete")}clear(){return d(this,h,Ye).call(this,"delete")}},j=new WeakMap,q=new WeakMap,K=new WeakMap,he=new WeakMap,$=new WeakMap,ye=new WeakMap,ge=new WeakMap,H=new WeakMap,E=new WeakMap,X=new WeakMap,_=new WeakMap,S=new WeakMap,f=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,P=new WeakMap,Q=new WeakMap,x=new WeakMap,Z=new WeakMap,J=new WeakMap,W=new WeakMap,V=new WeakMap,ee=new WeakMap,le=new WeakMap,G=new WeakMap,ve=new WeakMap,h=new WeakSet,Ue=function(){let t=new Ie(i(this,j)),e=new Ie(i(this,j));c(this,W,t),c(this,J,e);let n=this.ttlAutopurge?new Array(i(this,j)):void 0;c(this,V,n),c(this,Fe,(l,u,g=i(this,H).now())=>{e[l]=u!==0?g:0,t[l]=u,s(l,u);}),c(this,ue,l=>{e[l]=t[l]!==0?i(this,H).now():0,s(l,t[l]);});let s=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let g=setTimeout(()=>{i(this,Y).call(this,l)&&d(this,h,oe).call(this,i(this,S)[l],"expire");},u+1);g.unref&&g.unref(),n[l]=g;}}:()=>{};c(this,ie,(l,u)=>{if(t[u]){let g=t[u],w=e[u];if(!g||!w)return;l.ttl=g,l.start=w,l.now=r||a();let b=l.now-w;l.remainingTTL=g-b;}});let r=0,a=()=>{let l=i(this,H).now();if(this.ttlResolution>0){r=l;let u=setTimeout(()=>r=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=i(this,_).get(l);if(u===void 0)return 0;let g=t[u],w=e[u];if(!g||!w)return 1/0;let b=(r||a())-w;return g-b},c(this,Y,l=>{let u=e[l],g=t[l];return !!g&&!!u&&(r||a())-u>g});},ue=new WeakMap,ie=new WeakMap,Fe=new WeakMap,Y=new WeakMap,Pt=function(){let t=new Ie(i(this,j));c(this,X,0),c(this,Z,t),c(this,de,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,Oe,(e,n,s,r)=>{if(d(this,h,A).call(this,n))return 0;if(!se(s))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(s=r(n,e),!se(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s}),c(this,be,(e,n,s)=>{if(t[e]=n,i(this,q)){let r=i(this,q)-t[e];for(;i(this,X)>r;)d(this,h,Me).call(this,true);}c(this,X,i(this,X)+t[e]),s&&(s.entrySize=n,s.totalCalculatedSize=i(this,X));});},de=new WeakMap,be=new WeakMap,Oe=new WeakMap,ae=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,P);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,I)));)e=i(this,U)[e];},re=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,I);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,P)));)e=i(this,N)[e];},We=function(t){return t!==void 0&&i(this,_).get(i(this,S)[t])===t},Me=function(t){var r;let e=i(this,I),n=i(this,S)[e],s=i(this,f)[e];return i(this,le)&&d(this,h,A).call(this,s)?s.__abortController.abort(new Error("evicted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((r=i(this,K))==null||r.call(this,s,n,"evict")),i(this,G)&&i(this,x)?.push([s,n,"evict"])),i(this,de).call(this,e),i(this,V)?.[e]&&(clearTimeout(i(this,V)[e]),i(this,V)[e]=void 0),t&&(i(this,S)[e]=void 0,i(this,f)[e]=void 0,i(this,Q).push(e)),i(this,E)===1?(c(this,I,c(this,P,0)),i(this,Q).length=0):c(this,I,i(this,N)[e]),i(this,_).delete(n),De(this,E)._--,e},ke=function(t,e,n,s){let r=e===void 0?void 0:i(this,f)[e];if(d(this,h,A).call(this,r))return r;let a=new Re,{signal:l}=n;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:n,context:s},g=(F,T=false)=>{let{aborted:y}=a.signal,k=n.ignoreFetchAbort&&F!==void 0,L=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&F!==void 0);if(n.status&&(y&&!T?(n.status.fetchAborted=true,n.status.fetchError=a.signal.reason,k&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),y&&!k&&!T)return b(a.signal.reason,L);let R=D,O=i(this,f)[e];return (O===D||k&&T&&O===void 0)&&(F===void 0?R.__staleWhileFetching!==void 0?i(this,f)[e]=R.__staleWhileFetching:d(this,h,oe).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(t,F,u.options))),F},w=F=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=F),b(F,false)),b=(F,T)=>{let{aborted:y}=a.signal,k=y&&n.allowStaleOnFetchAbort,L=k||n.allowStaleOnFetchRejection,R=L||n.noDeleteOnFetchRejection,O=D;if(i(this,f)[e]===D&&(!R||!T&&O.__staleWhileFetching===void 0?d(this,h,oe).call(this,t,"fetch"):k||(i(this,f)[e]=O.__staleWhileFetching)),L)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw F},M=(F,T)=>{var k;let y=(k=i(this,ye))==null?void 0:k.call(this,t,r,u);y&&y instanceof Promise&&y.then(L=>F(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(F(void 0),n.allowStaleOnFetchAbort&&(F=L=>g(L,true)));});};n.status&&(n.status.fetchDispatched=true);let D=new Promise(M).then(g,w),z=Object.assign(D,{__abortController:a,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,z,{...u.options,status:void 0}),e=i(this,_).get(t)):i(this,f)[e]=z,z},A=function(t){if(!i(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Re},Ve=function(t,e){i(this,U)[e]=t,i(this,N)[t]=e;},Se=function(t){t!==i(this,P)&&(t===i(this,I)?c(this,I,i(this,N)[t]):d(this,h,Ve).call(this,i(this,U)[t],i(this,N)[t]),d(this,h,Ve).call(this,i(this,P),t),c(this,P,t));},oe=function(t,e){var s,r;let n=false;if(i(this,E)!==0){let a=i(this,_).get(t);if(a!==void 0)if(i(this,V)?.[a]&&(clearTimeout(i(this,V)?.[a]),i(this,V)[a]=void 0),n=true,i(this,E)===1)d(this,h,Ye).call(this,e);else {i(this,de).call(this,a);let l=i(this,f)[a];if(d(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((s=i(this,K))==null||s.call(this,l,t,e)),i(this,G)&&i(this,x)?.push([l,t,e])),i(this,_).delete(t),i(this,S)[a]=void 0,i(this,f)[a]=void 0,a===i(this,P))c(this,P,i(this,U)[a]);else if(a===i(this,I))c(this,I,i(this,N)[a]);else {let u=i(this,U)[a];i(this,N)[u]=i(this,N)[a];let g=i(this,N)[a];i(this,U)[g]=i(this,U)[a];}De(this,E)._--,i(this,Q).push(a);}}if(i(this,G)&&i(this,x)?.length){let a=i(this,x),l;for(;l=a?.shift();)(r=i(this,$))==null||r.call(this,...l);}return n},Ye=function(t){var e,n;for(let s of d(this,h,re).call(this,{allowStale:true})){let r=i(this,f)[s];if(d(this,h,A).call(this,r))r.__abortController.abort(new Error("deleted"));else {let a=i(this,S)[s];i(this,ee)&&((e=i(this,K))==null||e.call(this,r,a,t)),i(this,G)&&i(this,x)?.push([r,a,t]);}}if(i(this,_).clear(),i(this,f).fill(void 0),i(this,S).fill(void 0),i(this,W)&&i(this,J)){i(this,W).fill(0),i(this,J).fill(0);for(let s of i(this,V)??[])s!==void 0&&clearTimeout(s);i(this,V)?.fill(void 0);}if(i(this,Z)&&i(this,Z).fill(0),c(this,I,0),c(this,P,0),i(this,Q).length=0,c(this,X,0),c(this,E,0),i(this,G)&&i(this,x)){let s=i(this,x),r;for(;r=s?.shift();)(n=i(this,$))==null||n.call(this,...r);}},we);var _e=class{constructor(t){m(this,"cache");m(this,"map",new Map);this.cache=new Et({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var xt;(r=>(r.mediaInstances=new Map,r.channels=new Map,r.transients=new Set,r.systemPausedAliases=new Set,r.bufferRegistry=new _e({cacheSize:10})))(xt||={});var p=xt;var C;(s=>(s.log=(r,...a)=>console.log(`[Pixi\u2019VN] ${r}`,...a),s.warn=(r,...a)=>console.warn(`[Pixi\u2019VN] ${r}`,...a),s.error=(r,...a)=>console.error(`[Pixi\u2019VN] ${r}`,...a),s.info=(r,...a)=>console.info(`[Pixi\u2019VN] ${r}`,...a)))(C||={});function Ne(o){return o.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new B.Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new B.FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new B.BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new B.Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new B.Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new B.Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new B.FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new B.Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new B.Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new B.GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new B.GreaterThanZero);break;case "LimiterFilter":t.push(new B.Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new B.MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new B.MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new B.Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new B.Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new B.StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new B.PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new B.AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new B.BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new B.OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new B.Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new B.Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new B.Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new B.Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new B.AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function It(o){if(o)return Array.from(o).reduce((t,e)=>(e instanceof B.Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:B.Time(e.decay).toSeconds(),preDelay:B.Time(e.preDelay).toSeconds()}):e instanceof B.PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof B.FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof B.BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof B.Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof B.Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof B.Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof B.FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof B.Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof B.Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof B.GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof B.GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof B.Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof B.MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof B.MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof B.Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof B.Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof B.StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof B.AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof B.Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof B.Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof B.Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof B.AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof B.BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof B.OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof B.Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):C.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function gt(o){return o instanceof B.Reverb||o instanceof B.FeedbackDelay||o instanceof B.PingPongDelay||o instanceof B.BitCrusher||o instanceof B.Compressor||o instanceof B.Delay||o instanceof B.Distortion||o instanceof B.FeedbackCombFilter||o instanceof B.Freeverb||o instanceof B.Gate||o instanceof B.GreaterThan||o instanceof B.GreaterThanZero||o instanceof B.Limiter||o instanceof B.MidSideCompressor||o instanceof B.MultibandCompressor||o instanceof B.Panner3D||o instanceof B.Phaser||o instanceof B.StereoWidener||o instanceof B.AutoFilter||o instanceof B.Chorus||o instanceof B.Vibrato||o instanceof B.Tremolo||o instanceof B.AutoPanner||o instanceof B.BiquadFilter||o instanceof B.OnePoleFilter||o instanceof B.Filter}function ne(o){return o<=0?-1/0:20*Math.log10(o)}function Te(o){return o<=-1/0?0:10**(o/20)}async function Ge(o){if(p.bufferRegistry.has(o))return;let t=o;try{let e=kt__default.default.Assets.resolver.resolve(o);e?.src&&(t=e.src);}catch{}try{let e=await B.ToneAudioBuffer.load(t),n=new B.ToneAudioBuffer(e);p.bufferRegistry.set(o,n);}catch(e){C.warn(`Failed to load audio buffer for "${o}" (url: "${t}"): ${e instanceof Error?e.message:e}`),p.bufferRegistry.set(o,new B.ToneAudioBuffer);}}var Ee=class extends B.Player{constructor(e,n,s,r,a={},l){super(a);m(this,"alias",e);m(this,"channelAlias",n);m(this,"soundAlias",s);m(this,"stepCounter",r);m(this,"delay",l);m(this,"options");m(this,"filters",new Set);m(this,"pausedAt");m(this,"playStartTime",B.now());this.options=a,this.playStartTime=B.now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:B.now()-this.playStartTime),n=this.paused;return n&&p.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:Te(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==ne(e.volume??1)&&(this.volume.value=ne(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=B.now(),n==="started"&&super.stop();else {let s;typeof this.pausedAt=="number"&&(s=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,s):this.start(void 0,s));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return p.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,s){let r=B.now(),a=r;if(typeof e=="number")a=e;else if(typeof e=="string"&&e.startsWith("+")){let u=Number(e.slice(1));Number.isNaN(u)||(a=r+u);}let l=typeof n=="number"?n:0;return this.playStartTime=a-l,super.start(e,n,s)}chain(...e){return e.forEach(n=>{gt(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return gt(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var Pe=class{constructor(t,e={}){m(this,"alias",t);m(this,"toneChannel");m(this,"background");this.background=e.background??false,this.toneChannel=new B.Channel({volume:ne(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return Te(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=ne(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let s=p.bufferRegistry.get(e);if(!s)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:r,elapsed:a,filters:l=[],muted:u,autostart:g=true,speed:w,volume:b,...M}=n;u!==void 0&&(C.warn(`MediaInstance "${t}" is being created with muted=${u}. This will override the channel's muted state (${this.muted}).`),M.mute=u),w!==void 0&&(C.warn(`MediaInstance "${t}" is being created with speed=${w}. This will override the default playback speed of 1.`),M.playbackRate=w);let D=new Ee(t,this.alias,e,core.GameUnifier.stepCounter,{...M,volume:b!==void 0?ne(b):void 0,url:s},r).chain(...l,this.toneChannel),z=a!==void 0?Math.max(0,a):void 0;return g&&(r?D.start(`+${r}`,z):D.start(void 0,z)),D}async play(t,e,n){let s,r;if(typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.mediaInstances.has(s)){let l=p.mediaInstances.get(s);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await Ge(r);let a=this._createPlayer(s,r,n);return p.mediaInstances.set(s,a),a}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(p.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of p.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{p.mediaInstances.delete(e);}),this}};function Mt(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw C.error("Error creating exportable element",o,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var xe=class{constructor(){m(this,"_speedAll",1);m(this,"_defaultChannelAlias",Tt);}get volumeAll(){return Te(B__namespace.getDestination().volume.value)}set volumeAll(t){B__namespace.getDestination().volume.value=ne(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of p.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!p.bufferRegistry.has(t)){let n=new B__namespace.ToneAudioBuffer(e);p.bufferRegistry.set(t,n);}}pauseAll(){for(let t of p.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return B__namespace.getDestination().mute}toggleMuteAll(){let t=!B__namespace.getDestination().mute;return B__namespace.getDestination().mute=t,t}muteAll(){return B__namespace.getDestination().mute=true,this}unmuteAll(){return B__namespace.getDestination().mute=false,this}stopAll(){for(let t of p.mediaInstances.values())t.stop();return p.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of p.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,p.systemPausedAliases.add(e));if(!t){for(let e of p.transients)e.stop();p.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of p.systemPausedAliases){let s=p.mediaInstances.get(n);if(!s){e.push(n);continue}t&&s.channelAlias!==t||(s.paused=false,e.push(n));}for(let n of e)p.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of p.transients)t.stop();return p.transients.clear(),this}async play(t,e,n){let s,r;typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.bufferRegistry.has(r)||await this.load(r);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,r,l)}async playTransient(t,e){p.bufferRegistry.has(t)||await this.load(t);let n=p.bufferRegistry.get(t);if(!n)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:s=true,...r}=e??{},a=new B__namespace.Player({...r,url:n}).toDestination();return s&&a.start(),p.transients.add(a),a.onstop=()=>{a.dispose(),p.transients.delete(a);},a}find(t){return p.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),p.mediaInstances.delete(t)):C.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){C.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){C.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return p.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(Ge);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{C.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=kt__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await kt__default.default.Assets.loadBundle(t),s=[];for(let r in n)p.bufferRegistry.has(r)||s.push(this.load(r));await Promise.all(s);}catch(n){C.error("Error loading sound bundle",n);}}).catch(n=>{C.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let r={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,r);});return}if(p.channels.has(t)){C.warn(`Channel with alias ${t} already exists.`);return}let n=new Pe(t,e);return p.channels.set(t,n),n}findChannel(t){let e=p.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(p.channels.values())}export(){let t=Array.from(p.mediaInstances.entries()).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,paused:s.paused,options:{...s.memory,filters:It(s.filters)}},e),{});return {mediaInstances:Mt(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:a,channelAlias:l})=>(n.add(l),await this.load(a)));await Promise.all(s),this.channels.forEach(a=>{(!a.background||!n.has(a.alias))&&a.stopAll();});let r=Object.keys(e).map(async a=>{let l=e[a],u=this.findChannel(l.channelAlias),g=l.options.paused??l.paused??!1;if(u.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}else {let w=p.mediaInstances.get(a);if(!w){C.warn(`No media instance found with alias ${a} while restoring background state.`);return}w.memory={...l.options,paused:g},[...w.filters].forEach(M=>{w.disconnect(M),M.dispose();}),w.chain(...Ne(l.options.filters||[]));}else {let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}});await Promise.all(r);}}}catch(e){C.error("Error importing data",e);}}};var bt=new xe;core.GameUnifier.addOnPreContinue(async()=>{try{p.channels.forEach(o=>{o.background||o.stopAll();});}catch{}});if(typeof document<"u"){let o=false;document.addEventListener("visibilitychange",()=>{document.hidden?bt.muted||(bt.muteAll(),o=true):o&&(bt.unmuteAll(),o=false);});}exports.SoundRegistry=p;exports.sound=bt;
|
|
1
|
+
'use strict';var core=require('./core.cjs'),kt=require('./pixi/index.js'),B=require('tone');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var kt__default=/*#__PURE__*/_interopDefault(kt);var B__namespace=/*#__PURE__*/_interopNamespace(B);var Rt=Object.defineProperty;var wt=o=>{throw TypeError(o)};var Nt=(o,t,e)=>t in o?Rt(o,t,{enumerable:true,configurable:true,writable:true,value:e}):o[t]=e;var m=(o,t,e)=>Nt(o,typeof t!="symbol"?t+"":t,e),ze=(o,t,e)=>t.has(o)||wt("Cannot "+e);var i=(o,t,e)=>(ze(o,t,"read from private field"),e?e.call(o):t.get(o)),v=(o,t,e)=>t.has(o)?wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(o):t.set(o,e),c=(o,t,e,n)=>(ze(o,t,"write to private field"),t.set(o,e),e),d=(o,t,e)=>(ze(o,t,"access private method"),e);var De=(o,t,e,n)=>({set _(s){c(o,t,s);},get _(){return i(o,t,n)}});var Tt="general";var Gt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ot=new Set,qe=typeof process=="object"&&process?process:{},_t=(o,t,e,n)=>{typeof qe.emitWarning=="function"?qe.emitWarning(o,t,e,n):console.error(`[${e}] ${t}: ${o}`);},Re=globalThis.AbortController,At=globalThis.AbortSignal;if(typeof Re>"u"){At=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(e,n){this._onabort.push(n);}},Re=class{constructor(){m(this,"signal",new At);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let n of this.signal._onabort)n(e);this.signal.onabort?.(e);}}};let o=qe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{o&&(o=false,_t("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var Lt=o=>!Ot.has(o);var se=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),Ct=o=>se(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ie:null:null,Ie=class extends Array{constructor(o){super(o),this.fill(0);}},te,fe,zt=(te=class{constructor(t,e){m(this,"heap");m(this,"length");if(!i(te,fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Ct(t);if(!e)return [];c(te,fe,true);let n=new te(t,e);return c(te,fe,false),n}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},fe=new WeakMap,v(te,fe,false),te),St,Ft,j,q,K,he,$,ye,ge,H,E,X,_,S,f,N,U,I,P,Q,x,Z,J,W,V,ee,le,G,ve,h,Ue,ue,ie,Fe,Y,Pt,de,be,Oe,ae,re,We,Me,ke,A,Ve,Se,oe,Ye,we,Et=(we=class{constructor(t){v(this,h);v(this,j);v(this,q);v(this,K);v(this,he);v(this,$);v(this,ye);v(this,ge);v(this,H);m(this,"ttl");m(this,"ttlResolution");m(this,"ttlAutopurge");m(this,"updateAgeOnGet");m(this,"updateAgeOnHas");m(this,"allowStale");m(this,"noDisposeOnSet");m(this,"noUpdateTTL");m(this,"maxEntrySize");m(this,"sizeCalculation");m(this,"noDeleteOnFetchRejection");m(this,"noDeleteOnStaleGet");m(this,"allowStaleOnFetchAbort");m(this,"allowStaleOnFetchRejection");m(this,"ignoreFetchAbort");v(this,E);v(this,X);v(this,_);v(this,S);v(this,f);v(this,N);v(this,U);v(this,I);v(this,P);v(this,Q);v(this,x);v(this,Z);v(this,J);v(this,W);v(this,V);v(this,ee);v(this,le);v(this,G);v(this,ve);v(this,ue,()=>{});v(this,ie,()=>{});v(this,Fe,()=>{});v(this,Y,()=>false);v(this,de,t=>{});v(this,be,(t,e,n)=>{});v(this,Oe,(t,e,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,St,"LRUCache");let{max:e=0,ttl:n,ttlResolution:s=1,ttlAutopurge:r,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:g,onInsert:w,disposeAfter:b,noDisposeOnSet:M,noUpdateTTL:D,maxSize:z=0,maxEntrySize:F=0,sizeCalculation:T,fetchMethod:y,memoMethod:k,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:Ae,ignoreFetchAbort:ce,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,H,pe??Gt),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let me=e?Ct(e):Array;if(!me)throw new Error("invalid max value: "+e);if(c(this,j,e),c(this,q,z),this.maxEntrySize=F||i(this,q),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,q)&&!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(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,ge,k),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,ye,y),c(this,le,!!y),c(this,_,new Map),c(this,S,new Array(e).fill(void 0)),c(this,f,new Array(e).fill(void 0)),c(this,N,new me(e)),c(this,U,new me(e)),c(this,I,0),c(this,P,0),c(this,Q,zt.create(e)),c(this,E,0),c(this,X,0),typeof g=="function"&&c(this,K,g),typeof w=="function"&&c(this,he,w),typeof b=="function"?(c(this,$,b),c(this,x,[])):(c(this,$,void 0),c(this,x,void 0)),c(this,ee,!!i(this,K)),c(this,ve,!!i(this,he)),c(this,G,!!i(this,$)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!Ae,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(i(this,q)!==0&&!se(i(this,q)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,h,Pt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,h,Ue).call(this);}if(i(this,j)===0&&this.ttl===0&&i(this,q)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,j)&&!i(this,q)){let Le="LRU_CACHE_UNBOUNDED";Lt(Le)&&(Ot.add(Le),_t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,we));}}get perf(){return i(this,H)}static unsafeExposeInternals(t){return {starts:i(t,J),ttls:i(t,W),autopurgeTimers:i(t,V),sizes:i(t,Z),keyMap:i(t,_),keyList:i(t,S),valList:i(t,f),next:i(t,N),prev:i(t,U),get head(){return i(t,I)},get tail(){return i(t,P)},free:i(t,Q),isBackgroundFetch:e=>{var n;return d(n=t,h,A).call(n,e)},backgroundFetch:(e,n,s,r)=>{var a;return d(a=t,h,ke).call(a,e,n,s,r)},moveToTail:e=>{var n;return d(n=t,h,Se).call(n,e)},indexes:e=>{var n;return d(n=t,h,ae).call(n,e)},rindexes:e=>{var n;return d(n=t,h,re).call(n,e)},isStale:e=>{var n;return i(n=t,Y).call(n,e)}}}get max(){return i(this,j)}get maxSize(){return i(this,q)}get calculatedSize(){return i(this,X)}get size(){return i(this,E)}get fetchMethod(){return i(this,ye)}get memoMethod(){return i(this,ge)}get dispose(){return i(this,K)}get onInsert(){return i(this,he)}get disposeAfter(){return i(this,$)}getRemainingTTL(t){return i(this,_).has(t)?1/0:0}*entries(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*rentries(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&i(this,S)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,S)[t],i(this,f)[t]]);}*keys(){for(let t of d(this,h,ae).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*rkeys(){for(let t of d(this,h,re).call(this)){let e=i(this,S)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*values(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}*rvalues(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}[(Ft=Symbol.iterator,St=Symbol.toStringTag,Ft)](){return this.entries()}find(t,e={}){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r!==void 0&&t(r,i(this,S)[n],this))return this.get(i(this,S)[n],e)}}forEach(t,e=this){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}rforEach(t,e=this){for(let n of d(this,h,re).call(this)){let s=i(this,f)[n],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;r!==void 0&&t.call(e,r,i(this,S)[n],this);}}purgeStale(){let t=false;for(let e of d(this,h,re).call(this,{allowStale:true}))i(this,Y).call(this,e)&&(d(this,h,oe).call(this,i(this,S)[e],"expire"),t=true);return t}info(t){let e=i(this,_).get(t);if(e===void 0)return;let n=i(this,f)[e],s=d(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(s===void 0)return;let r={value:s};if(i(this,W)&&i(this,J)){let a=i(this,W)[e],l=i(this,J)[e];if(a&&l){let u=a-(i(this,H).now()-l);r.ttl=u,r.start=Date.now();}}return i(this,Z)&&(r.size=i(this,Z)[e]),r}dump(){let t=[];for(let e of d(this,h,ae).call(this,{allowStale:true})){let n=i(this,S)[e],s=i(this,f)[e],r=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(r===void 0||n===void 0)continue;let a={value:r};if(i(this,W)&&i(this,J)){a.ttl=i(this,W)[e];let l=i(this,H).now()-i(this,J)[e];a.start=Math.floor(Date.now()-l);}i(this,Z)&&(a.size=i(this,Z)[e]),t.unshift([n,a]);}return t}load(t){this.clear();for(let[e,n]of t){if(n.start){let s=Date.now()-n.start;n.start=i(this,H).now()-s;}this.set(e,n.value,n);}}set(t,e,n={}){var M,D,z,F;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:r,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,{noUpdateTTL:g=this.noUpdateTTL}=n,w=i(this,Oe).call(this,t,e,n.size||0,l);if(this.maxEntrySize&&w>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),d(this,h,oe).call(this,t,"set"),this;let b=i(this,E)===0?void 0:i(this,_).get(t);if(b===void 0)b=i(this,E)===0?i(this,P):i(this,Q).length!==0?i(this,Q).pop():i(this,E)===i(this,j)?d(this,h,Me).call(this,false):i(this,E),i(this,S)[b]=t,i(this,f)[b]=e,i(this,_).set(t,b),i(this,N)[i(this,P)]=b,i(this,U)[b]=i(this,P),c(this,P,b),De(this,E)._++,i(this,be).call(this,b,w,u),u&&(u.set="add"),g=false,i(this,ve)&&((M=i(this,he))==null||M.call(this,e,t,"add"));else {d(this,h,Se).call(this,b);let T=i(this,f)[b];if(e!==T){if(i(this,le)&&d(this,h,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=T;y!==void 0&&!a&&(i(this,ee)&&((D=i(this,K))==null||D.call(this,y,t,"set")),i(this,G)&&i(this,x)?.push([y,t,"set"]));}else a||(i(this,ee)&&((z=i(this,K))==null||z.call(this,T,t,"set")),i(this,G)&&i(this,x)?.push([T,t,"set"]));if(i(this,de).call(this,b),i(this,be).call(this,b,w,u),i(this,f)[b]=e,u){u.set="replace";let y=T&&d(this,h,A).call(this,T)?T.__staleWhileFetching:T;y!==void 0&&(u.oldValue=y);}}else u&&(u.set="update");i(this,ve)&&this.onInsert?.(e,t,e===T?"update":"replace");}if(s!==0&&!i(this,W)&&d(this,h,Ue).call(this),i(this,W)&&(g||i(this,Fe).call(this,b,s,r),u&&i(this,ie).call(this,u,b)),!a&&i(this,G)&&i(this,x)){let T=i(this,x),y;for(;y=T?.shift();)(F=i(this,$))==null||F.call(this,...y);}return this}pop(){var t;try{for(;i(this,E);){let e=i(this,f)[i(this,I)];if(d(this,h,Me).call(this,!0),d(this,h,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,G)&&i(this,x)){let e=i(this,x),n;for(;n=e?.shift();)(t=i(this,$))==null||t.call(this,...n);}}}has(t,e={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=e,r=i(this,_).get(t);if(r!==void 0){let a=i(this,f)[r];if(d(this,h,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,Y).call(this,r))s&&(s.has="stale",i(this,ie).call(this,s,r));else return n&&i(this,ue).call(this,r),s&&(s.has="hit",i(this,ie).call(this,s,r)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:n=this.allowStale}=e,s=i(this,_).get(t);if(s===void 0||!n&&i(this,Y).call(this,s))return;let r=i(this,f)[s];return d(this,h,A).call(this,r)?r.__staleWhileFetching:r}async fetch(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:w=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:z=this.allowStaleOnFetchAbort,context:F,forceRefresh:T=false,status:y,signal:k}=e;if(!i(this,le))return y&&(y.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,status:y});let L={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:r,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:g,noUpdateTTL:w,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:z,ignoreFetchAbort:D,status:y,signal:k},R=i(this,_).get(t);if(R===void 0){y&&(y.fetch="miss");let O=d(this,h,ke).call(this,t,R,L,F);return O.__returned=O}else {let O=i(this,f)[R];if(d(this,h,A).call(this,O)){let me=n&&O.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",me&&(y.returnedStale=true)),me?O.__staleWhileFetching:O.__returned=O}let Ae=i(this,Y).call(this,R);if(!T&&!Ae)return y&&(y.fetch="hit"),d(this,h,Se).call(this,R),s&&i(this,ue).call(this,R),y&&i(this,ie).call(this,y,R),O;let ce=d(this,h,ke).call(this,t,R,L,F),pe=ce.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=Ae?"stale":"refresh",pe&&Ae&&(y.returnedStale=true)),pe?ce.__staleWhileFetching:ce.__returned=ce}}async forceFetch(t,e={}){let n=await this.fetch(t,e);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,e={}){let n=i(this,ge);if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:r,...a}=e,l=this.get(t,a);if(!r&&l!==void 0)return l;let u=n(t,l,{options:a,context:s});return this.set(t,u,a),u}get(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:a}=e,l=i(this,_).get(t);if(l!==void 0){let u=i(this,f)[l],g=d(this,h,A).call(this,u);return a&&i(this,ie).call(this,a,l),i(this,Y).call(this,l)?(a&&(a.get="stale"),g?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),n?u.__staleWhileFetching:void 0):(r||d(this,h,oe).call(this,t,"expire"),a&&n&&(a.returnedStale=true),n?u:void 0)):(a&&(a.get="hit"),g?u.__staleWhileFetching:(d(this,h,Se).call(this,l),s&&i(this,ue).call(this,l),u))}else a&&(a.get="miss");}delete(t){return d(this,h,oe).call(this,t,"delete")}clear(){return d(this,h,Ye).call(this,"delete")}},j=new WeakMap,q=new WeakMap,K=new WeakMap,he=new WeakMap,$=new WeakMap,ye=new WeakMap,ge=new WeakMap,H=new WeakMap,E=new WeakMap,X=new WeakMap,_=new WeakMap,S=new WeakMap,f=new WeakMap,N=new WeakMap,U=new WeakMap,I=new WeakMap,P=new WeakMap,Q=new WeakMap,x=new WeakMap,Z=new WeakMap,J=new WeakMap,W=new WeakMap,V=new WeakMap,ee=new WeakMap,le=new WeakMap,G=new WeakMap,ve=new WeakMap,h=new WeakSet,Ue=function(){let t=new Ie(i(this,j)),e=new Ie(i(this,j));c(this,W,t),c(this,J,e);let n=this.ttlAutopurge?new Array(i(this,j)):void 0;c(this,V,n),c(this,Fe,(l,u,g=i(this,H).now())=>{e[l]=u!==0?g:0,t[l]=u,s(l,u);}),c(this,ue,l=>{e[l]=t[l]!==0?i(this,H).now():0,s(l,t[l]);});let s=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let g=setTimeout(()=>{i(this,Y).call(this,l)&&d(this,h,oe).call(this,i(this,S)[l],"expire");},u+1);g.unref&&g.unref(),n[l]=g;}}:()=>{};c(this,ie,(l,u)=>{if(t[u]){let g=t[u],w=e[u];if(!g||!w)return;l.ttl=g,l.start=w,l.now=r||a();let b=l.now-w;l.remainingTTL=g-b;}});let r=0,a=()=>{let l=i(this,H).now();if(this.ttlResolution>0){r=l;let u=setTimeout(()=>r=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=i(this,_).get(l);if(u===void 0)return 0;let g=t[u],w=e[u];if(!g||!w)return 1/0;let b=(r||a())-w;return g-b},c(this,Y,l=>{let u=e[l],g=t[l];return !!g&&!!u&&(r||a())-u>g});},ue=new WeakMap,ie=new WeakMap,Fe=new WeakMap,Y=new WeakMap,Pt=function(){let t=new Ie(i(this,j));c(this,X,0),c(this,Z,t),c(this,de,e=>{c(this,X,i(this,X)-t[e]),t[e]=0;}),c(this,Oe,(e,n,s,r)=>{if(d(this,h,A).call(this,n))return 0;if(!se(s))if(r){if(typeof r!="function")throw new TypeError("sizeCalculation must be a function");if(s=r(n,e),!se(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s}),c(this,be,(e,n,s)=>{if(t[e]=n,i(this,q)){let r=i(this,q)-t[e];for(;i(this,X)>r;)d(this,h,Me).call(this,true);}c(this,X,i(this,X)+t[e]),s&&(s.entrySize=n,s.totalCalculatedSize=i(this,X));});},de=new WeakMap,be=new WeakMap,Oe=new WeakMap,ae=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,P);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,I)));)e=i(this,U)[e];},re=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,I);!(!d(this,h,We).call(this,e)||((t||!i(this,Y).call(this,e))&&(yield e),e===i(this,P)));)e=i(this,N)[e];},We=function(t){return t!==void 0&&i(this,_).get(i(this,S)[t])===t},Me=function(t){var r;let e=i(this,I),n=i(this,S)[e],s=i(this,f)[e];return i(this,le)&&d(this,h,A).call(this,s)?s.__abortController.abort(new Error("evicted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((r=i(this,K))==null||r.call(this,s,n,"evict")),i(this,G)&&i(this,x)?.push([s,n,"evict"])),i(this,de).call(this,e),i(this,V)?.[e]&&(clearTimeout(i(this,V)[e]),i(this,V)[e]=void 0),t&&(i(this,S)[e]=void 0,i(this,f)[e]=void 0,i(this,Q).push(e)),i(this,E)===1?(c(this,I,c(this,P,0)),i(this,Q).length=0):c(this,I,i(this,N)[e]),i(this,_).delete(n),De(this,E)._--,e},ke=function(t,e,n,s){let r=e===void 0?void 0:i(this,f)[e];if(d(this,h,A).call(this,r))return r;let a=new Re,{signal:l}=n;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:n,context:s},g=(F,T=false)=>{let{aborted:y}=a.signal,k=n.ignoreFetchAbort&&F!==void 0,L=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&F!==void 0);if(n.status&&(y&&!T?(n.status.fetchAborted=true,n.status.fetchError=a.signal.reason,k&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),y&&!k&&!T)return b(a.signal.reason,L);let R=D,O=i(this,f)[e];return (O===D||k&&T&&O===void 0)&&(F===void 0?R.__staleWhileFetching!==void 0?i(this,f)[e]=R.__staleWhileFetching:d(this,h,oe).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(t,F,u.options))),F},w=F=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=F),b(F,false)),b=(F,T)=>{let{aborted:y}=a.signal,k=y&&n.allowStaleOnFetchAbort,L=k||n.allowStaleOnFetchRejection,R=L||n.noDeleteOnFetchRejection,O=D;if(i(this,f)[e]===D&&(!R||!T&&O.__staleWhileFetching===void 0?d(this,h,oe).call(this,t,"fetch"):k||(i(this,f)[e]=O.__staleWhileFetching)),L)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw F},M=(F,T)=>{var k;let y=(k=i(this,ye))==null?void 0:k.call(this,t,r,u);y&&y instanceof Promise&&y.then(L=>F(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(F(void 0),n.allowStaleOnFetchAbort&&(F=L=>g(L,true)));});};n.status&&(n.status.fetchDispatched=true);let D=new Promise(M).then(g,w),z=Object.assign(D,{__abortController:a,__staleWhileFetching:r,__returned:void 0});return e===void 0?(this.set(t,z,{...u.options,status:void 0}),e=i(this,_).get(t)):i(this,f)[e]=z,z},A=function(t){if(!i(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Re},Ve=function(t,e){i(this,U)[e]=t,i(this,N)[t]=e;},Se=function(t){t!==i(this,P)&&(t===i(this,I)?c(this,I,i(this,N)[t]):d(this,h,Ve).call(this,i(this,U)[t],i(this,N)[t]),d(this,h,Ve).call(this,i(this,P),t),c(this,P,t));},oe=function(t,e){var s,r;let n=false;if(i(this,E)!==0){let a=i(this,_).get(t);if(a!==void 0)if(i(this,V)?.[a]&&(clearTimeout(i(this,V)?.[a]),i(this,V)[a]=void 0),n=true,i(this,E)===1)d(this,h,Ye).call(this,e);else {i(this,de).call(this,a);let l=i(this,f)[a];if(d(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,ee)||i(this,G))&&(i(this,ee)&&((s=i(this,K))==null||s.call(this,l,t,e)),i(this,G)&&i(this,x)?.push([l,t,e])),i(this,_).delete(t),i(this,S)[a]=void 0,i(this,f)[a]=void 0,a===i(this,P))c(this,P,i(this,U)[a]);else if(a===i(this,I))c(this,I,i(this,N)[a]);else {let u=i(this,U)[a];i(this,N)[u]=i(this,N)[a];let g=i(this,N)[a];i(this,U)[g]=i(this,U)[a];}De(this,E)._--,i(this,Q).push(a);}}if(i(this,G)&&i(this,x)?.length){let a=i(this,x),l;for(;l=a?.shift();)(r=i(this,$))==null||r.call(this,...l);}return n},Ye=function(t){var e,n;for(let s of d(this,h,re).call(this,{allowStale:true})){let r=i(this,f)[s];if(d(this,h,A).call(this,r))r.__abortController.abort(new Error("deleted"));else {let a=i(this,S)[s];i(this,ee)&&((e=i(this,K))==null||e.call(this,r,a,t)),i(this,G)&&i(this,x)?.push([r,a,t]);}}if(i(this,_).clear(),i(this,f).fill(void 0),i(this,S).fill(void 0),i(this,W)&&i(this,J)){i(this,W).fill(0),i(this,J).fill(0);for(let s of i(this,V)??[])s!==void 0&&clearTimeout(s);i(this,V)?.fill(void 0);}if(i(this,Z)&&i(this,Z).fill(0),c(this,I,0),c(this,P,0),i(this,Q).length=0,c(this,X,0),c(this,E,0),i(this,G)&&i(this,x)){let s=i(this,x),r;for(;r=s?.shift();)(n=i(this,$))==null||n.call(this,...r);}},we);var _e=class{constructor(t){m(this,"cache");m(this,"map",new Map);this.cache=new Et({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var xt;(r=>(r.mediaInstances=new Map,r.channels=new Map,r.transients=new Set,r.systemPausedAliases=new Set,r.bufferRegistry=new _e({cacheSize:10})))(xt||={});var p=xt;var C;(s=>(s.log=(r,...a)=>console.log(`[Pixi\u2019VN] ${r}`,...a),s.warn=(r,...a)=>console.warn(`[Pixi\u2019VN] ${r}`,...a),s.error=(r,...a)=>console.error(`[Pixi\u2019VN] ${r}`,...a),s.info=(r,...a)=>console.info(`[Pixi\u2019VN] ${r}`,...a)))(C||={});function Ne(o){return o.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new B.Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new B.FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new B.BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new B.Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new B.Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new B.Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new B.FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new B.Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new B.Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new B.GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new B.GreaterThanZero);break;case "LimiterFilter":t.push(new B.Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new B.MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new B.MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new B.Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new B.Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new B.StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new B.PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new B.AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new B.BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new B.OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new B.Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new B.Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new B.Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new B.Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new B.AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function It(o){if(o)return Array.from(o).reduce((t,e)=>(e instanceof B.Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:B.Time(e.decay).toSeconds(),preDelay:B.Time(e.preDelay).toSeconds()}):e instanceof B.PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof B.FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof B.BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof B.Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof B.Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof B.Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof B.FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof B.Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof B.Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof B.GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof B.GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof B.Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof B.MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof B.MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof B.Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof B.Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof B.StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof B.AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof B.Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof B.Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof B.Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof B.AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof B.BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof B.OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof B.Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):C.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function gt(o){return o instanceof B.Reverb||o instanceof B.FeedbackDelay||o instanceof B.PingPongDelay||o instanceof B.BitCrusher||o instanceof B.Compressor||o instanceof B.Delay||o instanceof B.Distortion||o instanceof B.FeedbackCombFilter||o instanceof B.Freeverb||o instanceof B.Gate||o instanceof B.GreaterThan||o instanceof B.GreaterThanZero||o instanceof B.Limiter||o instanceof B.MidSideCompressor||o instanceof B.MultibandCompressor||o instanceof B.Panner3D||o instanceof B.Phaser||o instanceof B.StereoWidener||o instanceof B.AutoFilter||o instanceof B.Chorus||o instanceof B.Vibrato||o instanceof B.Tremolo||o instanceof B.AutoPanner||o instanceof B.BiquadFilter||o instanceof B.OnePoleFilter||o instanceof B.Filter}function ne(o){return o<=0?-1/0:20*Math.log10(o)}function Te(o){return o<=-1/0?0:10**(o/20)}async function Ge(o){if(p.bufferRegistry.has(o))return;let t=o;try{let e=kt__default.default.Assets.resolver.resolve(o);e?.src&&(t=e.src);}catch{}try{let e=await B.ToneAudioBuffer.load(t),n=new B.ToneAudioBuffer(e);p.bufferRegistry.set(o,n);}catch(e){C.warn(`Failed to load audio buffer for "${o}" (url: "${t}"): ${e instanceof Error?e.message:e}`),p.bufferRegistry.set(o,new B.ToneAudioBuffer);}}var Ee=class extends B.Player{constructor(e,n,s,r,a={},l){super(a);m(this,"alias",e);m(this,"channelAlias",n);m(this,"soundAlias",s);m(this,"stepCounter",r);m(this,"delay",l);m(this,"options");m(this,"filters",new Set);m(this,"pausedAt");m(this,"playStartTime",B.now());this.options=a,this.playStartTime=B.now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:B.now()-this.playStartTime),n=this.paused;return n&&p.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:Te(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==ne(e.volume??1)&&(this.volume.value=ne(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=B.now(),n==="started"&&super.stop();else {let s;typeof this.pausedAt=="number"&&(s=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,s):this.start(void 0,s));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return p.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,s){let r=B.now(),a=r;if(typeof e=="number")a=e;else if(typeof e=="string"&&e.startsWith("+")){let u=Number(e.slice(1));Number.isNaN(u)||(a=r+u);}let l=typeof n=="number"?n:0;return this.playStartTime=a-l,super.start(e,n,s)}chain(...e){return e.forEach(n=>{gt(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return gt(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var Pe=class{constructor(t,e={}){m(this,"alias",t);m(this,"toneChannel");m(this,"background");this.background=e.background??false,this.toneChannel=new B.Channel({volume:ne(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return Te(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=ne(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let s=p.bufferRegistry.get(e);if(!s)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:r,elapsed:a,filters:l=[],muted:u,autostart:g=true,speed:w,volume:b,...M}=n;u!==void 0&&(C.warn(`MediaInstance "${t}" is being created with muted=${u}. This will override the channel's muted state (${this.muted}).`),M.mute=u),w!==void 0&&(C.warn(`MediaInstance "${t}" is being created with speed=${w}. This will override the default playback speed of 1.`),M.playbackRate=w);let D=new Ee(t,this.alias,e,core.GameUnifier.stepCounter,{...M,volume:b!==void 0?ne(b):void 0,url:s},r).chain(...l,this.toneChannel),z=a!==void 0?Math.max(0,a):void 0;return g&&(r?D.start(`+${r}`,z):D.start(void 0,z)),D}async play(t,e,n){let s,r;if(typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.mediaInstances.has(s)){let l=p.mediaInstances.get(s);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await Ge(r);let a=this._createPlayer(s,r,n);return p.mediaInstances.set(s,a),a}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(p.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of p.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{p.mediaInstances.delete(e);}),this}};function Mt(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw C.error("Error creating exportable element",o,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var xe=class{constructor(){m(this,"_speedAll",1);m(this,"_defaultChannelAlias",Tt);}get volumeAll(){return Te(B__namespace.getDestination().volume.value)}set volumeAll(t){B__namespace.getDestination().volume.value=ne(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of p.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!p.bufferRegistry.has(t)){let n=new B__namespace.ToneAudioBuffer(e);p.bufferRegistry.set(t,n);}}pauseAll(){for(let t of p.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return B__namespace.getDestination().mute}toggleMuteAll(){let t=!B__namespace.getDestination().mute;return B__namespace.getDestination().mute=t,t}muteAll(){return B__namespace.getDestination().mute=true,this}unmuteAll(){return B__namespace.getDestination().mute=false,this}stopAll(){for(let t of p.mediaInstances.values())t.stop();return p.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of p.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,p.systemPausedAliases.add(e));if(!t){for(let e of p.transients)e.stop();p.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of p.systemPausedAliases){let s=p.mediaInstances.get(n);if(!s){e.push(n);continue}t&&s.channelAlias!==t||(s.paused=false,e.push(n));}for(let n of e)p.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of p.transients)t.stop();return p.transients.clear(),this}async play(t,e,n){let s,r;typeof e=="string"?(s=t,r=e):(s=t,r=t,n=e),p.bufferRegistry.has(r)||await this.load(r);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,r,l)}async playTransient(t,e){p.bufferRegistry.has(t)||await this.load(t);let n=p.bufferRegistry.get(t);if(!n)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:s=true,...r}=e??{},a=new B__namespace.Player({...r,url:n}).toDestination();return s&&a.start(),p.transients.add(a),a.onstop=()=>{a.dispose(),p.transients.delete(a);},a}find(t){return p.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),p.mediaInstances.delete(t)):C.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){C.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){C.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return p.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(Ge);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{C.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=kt__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await kt__default.default.Assets.loadBundle(t),s=[];for(let r in n)p.bufferRegistry.has(r)||s.push(this.load(r));await Promise.all(s);}catch(n){C.error("Error loading sound bundle",n);}}).catch(n=>{C.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let r={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,r);});return}if(p.channels.has(t)){C.warn(`Channel with alias ${t} already exists.`);return}let n=new Pe(t,e);return p.channels.set(t,n),n}findChannel(t){let e=p.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(p.channels.values())}export(){let t=Array.from(p.mediaInstances.entries()).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,paused:s.paused,options:{...s.memory,filters:It(s.filters)}},e),{});return {mediaInstances:Mt(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:a,channelAlias:l})=>(n.add(l),await this.load(a)));await Promise.all(s),this.channels.forEach(a=>{(!a.background||!n.has(a.alias))&&a.stopAll();});let r=Object.keys(e).map(async a=>{let l=e[a],u=this.findChannel(l.channelAlias),g=l.options.paused??l.paused??!1;if(u.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}else {let w=p.mediaInstances.get(a);if(!w){C.warn(`No media instance found with alias ${a} while restoring background state.`);return}w.memory={...l.options,paused:g},[...w.filters].forEach(M=>{w.disconnect(M),M.dispose();}),w.chain(...Ne(l.options.filters||[]));}else {let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Ne(l.options.filters||[]),delay:l.options.delay});w.paused=g;}});await Promise.all(r);}}}catch(e){C.error("Error importing data",e);}}};var bt=new xe;core.GameUnifier.addOnPreContinue(async()=>{try{p.channels.forEach(o=>{o.background||o.stopAll();});}catch{}});if(typeof document<"u"){let o=false;document.addEventListener("visibilitychange",()=>{document.hidden?bt.muted||(bt.muteAll(),o=true):o&&(bt.unmuteAll(),o=false);});}exports.SoundRegistry=p;exports.sound=bt;
|
package/dist/sound.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {e,d,f,g as g$1}from'./chunk-3M6A7TU2.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import le from'@drincs/pixi-vn/pixi.js';import*as c from'tone';import {ToneAudioBuffer,Channel,Reverb,Time,PingPongDelay,FeedbackDelay,BitCrusher,Compressor,Delay,Distortion,FeedbackCombFilter,Freeverb,Gate,GreaterThan,GreaterThanZero,Limiter,MidSideCompressor,MultibandCompressor,Panner3D,Phaser,StereoWidener,AutoFilter,Chorus,Tremolo,Vibrato,AutoPanner,BiquadFilter,OnePoleFilter,Filter,Player,now}from'tone';var re;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new e({cacheSize:10})))(re||={});var i=re;function T(a){return a.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new GreaterThanZero);break;case "LimiterFilter":t.push(new Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function se(a){if(a)return Array.from(a).reduce((t,e)=>(e instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:Time(e.decay).toSeconds(),preDelay:Time(e.preDelay).toSeconds()}):e instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):f.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function J(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function h(a){return a<=0?-1/0:20*Math.log10(a)}function g(a){return a<=-1/0?0:10**(a/20)}async function P(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=le.Assets.resolver.resolve(a);e?.src&&(t=e.src);}catch{}try{let e=await ToneAudioBuffer.load(t),n=new ToneAudioBuffer(e);i.bufferRegistry.set(a,n);}catch(e){f.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e instanceof Error?e.message:e}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var v=class extends Player{constructor(e,n,r,s,o={},l){super(o);d(this,"alias",e);d(this,"channelAlias",n);d(this,"soundAlias",r);d(this,"stepCounter",s);d(this,"delay",l);d(this,"options");d(this,"filters",new Set);d(this,"pausedAt");d(this,"playStartTime",now());this.options=o,this.playStartTime=now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:now()-this.playStartTime),n=this.paused;return n&&i.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:g(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==h(e.volume??1)&&(this.volume.value=h(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=now(),n==="started"&&super.stop();else {let r;typeof this.pausedAt=="number"&&(r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.start(void 0,r));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return i.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let m=Number(e.slice(1));Number.isNaN(m)||(o=s+m);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{J(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return J(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var F=class{constructor(t,e={}){d(this,"alias",t);d(this,"toneChannel");d(this,"background");this.background=e.background??false,this.toneChannel=new Channel({volume:h(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return g(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=h(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let r=i.bufferRegistry.get(e);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:m,autostart:y=true,speed:p,volume:A,...f$1}=n;m!==void 0&&(f.warn(`MediaInstance "${t}" is being created with muted=${m}. This will override the channel's muted state (${this.muted}).`),f$1.mute=m),p!==void 0&&(f.warn(`MediaInstance "${t}" is being created with speed=${p}. This will override the default playback speed of 1.`),f$1.playbackRate=p);let O=new v(t,this.alias,e,GameUnifier.stepCounter,{...f$1,volume:A!==void 0?h(A):void 0,url:r},s).chain(...l,this.toneChannel),te=o!==void 0?Math.max(0,o):void 0;return y&&(s?O.start(`+${s}`,te):O.start(void 0,te)),O}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.mediaInstances.has(r)){let l=i.mediaInstances.get(r);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await P(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{i.mediaInstances.delete(e);}),this}};var w=class{constructor(){d(this,"_speedAll",1);d(this,"_defaultChannelAlias",i$1);}get volumeAll(){return g(c.getDestination().volume.value)}set volumeAll(t){c.getDestination().volume.value=h(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of i.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new c.ToneAudioBuffer(e);i.bufferRegistry.set(t,n);}}pauseAll(){for(let t of i.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return c.getDestination().mute}toggleMuteAll(){let t=!c.getDestination().mute;return c.getDestination().mute=t,t}muteAll(){return c.getDestination().mute=true,this}unmuteAll(){return c.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of i.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,i.systemPausedAliases.add(e));if(!t){for(let e of i.transients)e.stop();i.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of i.systemPausedAliases){let r=i.mediaInstances.get(n);if(!r){e.push(n);continue}t&&r.channelAlias!==t||(r.paused=false,e.push(n));}for(let n of e)i.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of i.transients)t.stop();return i.transients.clear(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(o).play(r,s,l)}async playTransient(t,e){i.bufferRegistry.has(t)||await this.load(t);let n=i.bufferRegistry.get(t);if(!n)throw new PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:r=true,...s}=e??{},o=new c.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}find(t){return i.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),i.mediaInstances.delete(t)):f.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(P);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{f.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=le.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await le.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){f.error("Error loading sound bundle",n);}}).catch(n=>{f.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(r=>{let s={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(r,s);});return}if(i.channels.has(t)){f.warn(`Channel with alias ${t} already exists.`);return}let n=new F(t,e);return i.channels.set(t,n),n}findChannel(t){let e=i.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(i.channels.values())}export(){let t=Array.from(i.mediaInstances.entries()).reduce((e,[n,r])=>(e[n]={channelAlias:r.channelAlias,soundAlias:r.soundAlias,stepCounter:r.stepCounter,paused:r.paused,options:{...r.memory,filters:se(r.filters)}},e),{});return {mediaInstances:g$1(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async r=>{await this.load(r),await this.play(r);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,r=Object.values(e).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e).map(async o=>{let l=e[o],m=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(m.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}else {let p=i.mediaInstances.get(o);if(!p){f.warn(`No media instance found with alias ${o} while restoring background state.`);return}p.memory={...l.options,paused:y},[...p.filters].forEach(f=>{p.disconnect(f),f.dispose();}),p.chain(...T(l.options.filters||[]));}else {let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}});await Promise.all(s);}}}catch(e){f.error("Error importing data",e);}}};var ee=new w;GameUnifier.addOnPreContinue(async()=>{try{i.channels.forEach(a=>{a.background||a.stopAll();});}catch{}});if(typeof document<"u"){let a=false;document.addEventListener("visibilitychange",()=>{document.hidden?ee.muted||(ee.muteAll(),a=true):a&&(ee.unmuteAll(),a=false);});}export{i as SoundRegistry,ee as sound};
|
|
1
|
+
import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {e,d,f,g as g$1}from'./chunk-3M6A7TU2.mjs';import {GameUnifier,PixiError}from'./core.mjs';import le from'./pixi/index.js';import*as c from'tone';import {ToneAudioBuffer,Channel,Reverb,Time,PingPongDelay,FeedbackDelay,BitCrusher,Compressor,Delay,Distortion,FeedbackCombFilter,Freeverb,Gate,GreaterThan,GreaterThanZero,Limiter,MidSideCompressor,MultibandCompressor,Panner3D,Phaser,StereoWidener,AutoFilter,Chorus,Tremolo,Vibrato,AutoPanner,BiquadFilter,OnePoleFilter,Filter,Player,now}from'tone';var re;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new e({cacheSize:10})))(re||={});var i=re;function T(a){return a.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new GreaterThanZero);break;case "LimiterFilter":t.push(new Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function se(a){if(a)return Array.from(a).reduce((t,e)=>(e instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:Time(e.decay).toSeconds(),preDelay:Time(e.preDelay).toSeconds()}):e instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):f.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function J(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function h(a){return a<=0?-1/0:20*Math.log10(a)}function g(a){return a<=-1/0?0:10**(a/20)}async function P(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=le.Assets.resolver.resolve(a);e?.src&&(t=e.src);}catch{}try{let e=await ToneAudioBuffer.load(t),n=new ToneAudioBuffer(e);i.bufferRegistry.set(a,n);}catch(e){f.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e instanceof Error?e.message:e}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var v=class extends Player{constructor(e,n,r,s,o={},l){super(o);d(this,"alias",e);d(this,"channelAlias",n);d(this,"soundAlias",r);d(this,"stepCounter",s);d(this,"delay",l);d(this,"options");d(this,"filters",new Set);d(this,"pausedAt");d(this,"playStartTime",now());this.options=o,this.playStartTime=now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:now()-this.playStartTime),n=this.paused;return n&&i.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:g(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==h(e.volume??1)&&(this.volume.value=h(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=now(),n==="started"&&super.stop();else {let r;typeof this.pausedAt=="number"&&(r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.start(void 0,r));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return i.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let m=Number(e.slice(1));Number.isNaN(m)||(o=s+m);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{J(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return J(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var F=class{constructor(t,e={}){d(this,"alias",t);d(this,"toneChannel");d(this,"background");this.background=e.background??false,this.toneChannel=new Channel({volume:h(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return g(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=h(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let r=i.bufferRegistry.get(e);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:m,autostart:y=true,speed:p,volume:A,...f$1}=n;m!==void 0&&(f.warn(`MediaInstance "${t}" is being created with muted=${m}. This will override the channel's muted state (${this.muted}).`),f$1.mute=m),p!==void 0&&(f.warn(`MediaInstance "${t}" is being created with speed=${p}. This will override the default playback speed of 1.`),f$1.playbackRate=p);let O=new v(t,this.alias,e,GameUnifier.stepCounter,{...f$1,volume:A!==void 0?h(A):void 0,url:r},s).chain(...l,this.toneChannel),te=o!==void 0?Math.max(0,o):void 0;return y&&(s?O.start(`+${s}`,te):O.start(void 0,te)),O}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.mediaInstances.has(r)){let l=i.mediaInstances.get(r);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await P(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{i.mediaInstances.delete(e);}),this}};var w=class{constructor(){d(this,"_speedAll",1);d(this,"_defaultChannelAlias",i$1);}get volumeAll(){return g(c.getDestination().volume.value)}set volumeAll(t){c.getDestination().volume.value=h(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of i.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new c.ToneAudioBuffer(e);i.bufferRegistry.set(t,n);}}pauseAll(){for(let t of i.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return c.getDestination().mute}toggleMuteAll(){let t=!c.getDestination().mute;return c.getDestination().mute=t,t}muteAll(){return c.getDestination().mute=true,this}unmuteAll(){return c.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of i.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,i.systemPausedAliases.add(e));if(!t){for(let e of i.transients)e.stop();i.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of i.systemPausedAliases){let r=i.mediaInstances.get(n);if(!r){e.push(n);continue}t&&r.channelAlias!==t||(r.paused=false,e.push(n));}for(let n of e)i.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of i.transients)t.stop();return i.transients.clear(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(o).play(r,s,l)}async playTransient(t,e){i.bufferRegistry.has(t)||await this.load(t);let n=i.bufferRegistry.get(t);if(!n)throw new PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:r=true,...s}=e??{},o=new c.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}find(t){return i.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),i.mediaInstances.delete(t)):f.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(P);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{f.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=le.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await le.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){f.error("Error loading sound bundle",n);}}).catch(n=>{f.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(r=>{let s={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(r,s);});return}if(i.channels.has(t)){f.warn(`Channel with alias ${t} already exists.`);return}let n=new F(t,e);return i.channels.set(t,n),n}findChannel(t){let e=i.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(i.channels.values())}export(){let t=Array.from(i.mediaInstances.entries()).reduce((e,[n,r])=>(e[n]={channelAlias:r.channelAlias,soundAlias:r.soundAlias,stepCounter:r.stepCounter,paused:r.paused,options:{...r.memory,filters:se(r.filters)}},e),{});return {mediaInstances:g$1(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async r=>{await this.load(r),await this.play(r);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,r=Object.values(e).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e).map(async o=>{let l=e[o],m=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(m.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}else {let p=i.mediaInstances.get(o);if(!p){f.warn(`No media instance found with alias ${o} while restoring background state.`);return}p.memory={...l.options,paused:y},[...p.filters].forEach(f=>{p.disconnect(f),f.dispose();}),p.chain(...T(l.options.filters||[]));}else {let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}});await Promise.all(s);}}}catch(e){f.error("Error importing data",e);}}};var ee=new w;GameUnifier.addOnPreContinue(async()=>{try{i.channels.forEach(a=>{a.background||a.stopAll();});}catch{}});if(typeof document<"u"){let a=false;document.addEventListener("visibilitychange",()=>{document.hidden?ee.muted||(ee.muteAll(),a=true):a&&(ee.unmuteAll(),a=false);});}export{i as SoundRegistry,ee as sound};
|
package/dist/storage.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var Ht=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var E=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),Ut=(u,e,i)=>e.has(u)||Ht("Cannot "+i);var t=(u,e,i)=>(Ut(u,e,"read from private field"),i?i.call(u):e.get(u)),d=(u,e,i)=>e.has(u)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(Ut(u,e,"write to private field"),e.set(u,i),i),l=(u,e,i)=>(Ut(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,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=(u,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Gt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Gt>"u"){jt=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){E(this,"signal",new jt);e();}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 u=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=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=u=>!Bt.has(u);var rt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),Jt=u=>rt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(u){super(u),this.fill(0);}},et,dt,re=(et=class{constructor(e,i){E(this,"heap");E(this,"length");if(!t(et,dt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=Jt(e);if(!i)return [];f(et,dt,true);let s=new et(e,i);return f(et,dt,false),s}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,St,mt,X,D,J,R,v,p,V,Y,C,N,q,F,Q,Z,P,K,tt,lt,L,Et,n,Yt,ut,it,vt,W,Qt,ft,Tt,xt,at,ot,Pt,Ct,Mt,w,Kt,wt,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,St);d(this,mt);d(this,X);E(this,"ttl");E(this,"ttlResolution");E(this,"ttlAutopurge");E(this,"updateAgeOnGet");E(this,"updateAgeOnHas");E(this,"allowStale");E(this,"noDisposeOnSet");E(this,"noUpdateTTL");E(this,"maxEntrySize");E(this,"sizeCalculation");E(this,"noDeleteOnFetchRejection");E(this,"noDeleteOnStaleGet");E(this,"allowStaleOnFetchAbort");E(this,"allowStaleOnFetchRejection");E(this,"ignoreFetchAbort");d(this,D);d(this,J);d(this,R);d(this,v);d(this,p);d(this,V);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,P);d(this,K);d(this,tt);d(this,lt);d(this,L);d(this,Et);d(this,ut,()=>{});d(this,it,()=>{});d(this,vt,()=>{});d(this,W,()=>false);d(this,ft,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});E(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:I,disposeAfter:g,noDisposeOnSet:A,noUpdateTTL:b,maxSize:T=0,maxEntrySize:y=0,sizeCalculation:O,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:Ot,ignoreFetchAbort:pt,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,gt??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(f(this,$,i),f(this,z,T),this.maxEntrySize=y||t(this,z),this.sizeCalculation=O,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(f(this,mt,M),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,St,_),f(this,lt,!!_),f(this,R,new Map),f(this,v,new Array(i).fill(void 0)),f(this,p,new Array(i).fill(void 0)),f(this,V,new _t(i)),f(this,Y,new _t(i)),f(this,C,0),f(this,N,0),f(this,q,re.create(i)),f(this,D,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof I=="function"&&f(this,ct,I),typeof g=="function"?(f(this,B,g),f(this,F,[])):(f(this,B,void 0),f(this,F,void 0)),f(this,tt,!!t(this,k)),f(this,Et,!!t(this,ct)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!A,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!Ot,this.ignoreFetchAbort=!!pt,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 Lt="LRU_CACHE_UNBOUNDED";se(Lt)&&(Bt.add(Lt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Lt,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,R),keyList:t(e,v),valList:t(e,p),next:t(e,V),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,w).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,wt).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,D)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,mt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&t(this,v)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield [t(this,v)[e],t(this,p)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&t(this,v)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield [t(this,v)[e],t(this,p)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,v)[e];i!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,v)[e];i!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield t(this,p)[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,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,v)[s],this))return this.get(t(this,v)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,v)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,v)[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,v)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,p)[i],r=l(this,n,w).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,v)[i],r=t(this,p)[i],o=l(this,n,w).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 A,b,T,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:m=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 g=t(this,D)===0?void 0:t(this,R).get(e);if(g===void 0)g=t(this,D)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,D)===t(this,$)?l(this,n,Ct).call(this,false):t(this,D),t(this,v)[g]=e,t(this,p)[g]=i,t(this,R).set(e,g),t(this,V)[t(this,N)]=g,t(this,Y)[g]=t(this,N),f(this,N,g),It(this,D)._++,t(this,Tt).call(this,g,I,c),c&&(c.set="add"),m=false,t(this,Et)&&((A=t(this,ct))==null||A.call(this,i,e,"add"));else {l(this,n,wt).call(this,g);let O=t(this,p)[g];if(i!==O){if(t(this,lt)&&l(this,n,w).call(this,O)){O.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=O;_!==void 0&&!a&&(t(this,tt)&&((b=t(this,k))==null||b.call(this,_,e,"set")),t(this,L)&&t(this,F)?.push([_,e,"set"]));}else a||(t(this,tt)&&((T=t(this,k))==null||T.call(this,O,e,"set")),t(this,L)&&t(this,F)?.push([O,e,"set"]));if(t(this,ft).call(this,g),t(this,Tt).call(this,g,I,c),t(this,p)[g]=i,c){c.set="replace";let _=O&&l(this,n,w).call(this,O)?O.__staleWhileFetching:O;_!==void 0&&(c.oldValue=_);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===O?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(m||t(this,vt).call(this,g,r,o),c&&t(this,it).call(this,c,g)),!a&&t(this,L)&&t(this,F)){let O=t(this,F),_;for(;_=O?.shift();)(y=t(this,B))==null||y.call(this,..._);}return this}pop(){var e;try{for(;t(this,D);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&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,R).get(e);if(o!==void 0){let a=t(this,p)[o];if(l(this,n,w).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,ut).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,R).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,p)[r];return l(this,n,w).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:m=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:y,forceRefresh:O=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:m,noUpdateTTL:I,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:_,signal:M},G=t(this,R).get(e);if(G===void 0){_&&(_.fetch="miss");let x=l(this,n,Mt).call(this,e,G,U,y);return x.__returned=x}else {let x=t(this,p)[G];if(l(this,n,w).call(this,x)){let _t=s&&x.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",_t&&(_.returnedStale=true)),_t?x.__staleWhileFetching:x.__returned=x}let Ot=t(this,W).call(this,G);if(!O&&!Ot)return _&&(_.fetch="hit"),l(this,n,wt).call(this,G),r&&t(this,ut).call(this,G),_&&t(this,it).call(this,_,G),x;let pt=l(this,n,Mt).call(this,e,G,U,y),gt=pt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=Ot?"stale":"refresh",gt&&Ot&&(_.returnedStale=true)),gt?pt.__staleWhileFetching:pt.__returned=pt}}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,mt);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,R).get(e);if(h!==void 0){let c=t(this,p)[h],m=l(this,n,w).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),m?(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"),m?c.__staleWhileFetching:(l(this,n,wt).call(this,h),r&&t(this,ut).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,St=new WeakMap,mt=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,R=new WeakMap,v=new WeakMap,p=new WeakMap,V=new WeakMap,Y=new WeakMap,C=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,L=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));f(this,P,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,K,s),f(this,vt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ut,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 m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,v)[h],"expire");},c+1);m.unref&&m.unref(),s[h]=m;}}:()=>{};f(this,it,(h,c)=>{if(e[c]){let m=e[c],I=i[c];if(!m||!I)return;h.ttl=m,h.start=I,h.now=o||a();let g=h.now-I;h.remainingTTL=m-g;}});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,R).get(h);if(c===void 0)return 0;let m=e[c],I=i[c];if(!m||!I)return 1/0;let g=(o||a())-I;return m-g},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(o||a())-c>m});},ut=new WeakMap,it=new WeakMap,vt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,ft,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,xt,(i,s,r,o)=>{if(l(this,n,w).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}),f(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);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ft=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,D))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,C)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,C);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,V)[i];},Pt=function(e){return e!==void 0&&t(this,R).get(t(this,v)[e])===e},Ct=function(e){var o;let i=t(this,C),s=t(this,v)[i],r=t(this,p)[i];return t(this,lt)&&l(this,n,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,L)&&t(this,F)?.push([r,s,"evict"])),t(this,ft).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,v)[i]=void 0,t(this,p)[i]=void 0,t(this,q).push(i)),t(this,D)===1?(f(this,C,f(this,N,0)),t(this,q).length=0):f(this,C,t(this,V)[i]),t(this,R).delete(s),It(this,D)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,p)[i];if(l(this,n,w).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},m=(y,O=false)=>{let{aborted:_}=a.signal,M=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(_&&!O?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!O)return g(a.signal.reason,U);let G=b,x=t(this,p)[i];return (x===b||M&&O&&x===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,p)[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),g(y,false)),g=(y,O)=>{let{aborted:_}=a.signal,M=_&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,x=b;if(t(this,p)[i]===b&&(!G||!O&&x.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,p)[i]=x.__staleWhileFetching)),U)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw y},A=(y,O)=>{var M;let _=(M=t(this,St))==null?void 0:M.call(this,e,o,c);_&&_ instanceof Promise&&_.then(U=>y(U===void 0?void 0:U),O),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>m(U,true)));});};s.status&&(s.status.fetchDispatched=true);let b=new Promise(A).then(m,I),T=Object.assign(b,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,T,{...c.options,status:void 0}),i=t(this,R).get(e)):t(this,p)[i]=T,T},w=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Kt=function(e,i){t(this,Y)[i]=e,t(this,V)[e]=i;},wt=function(e){e!==t(this,N)&&(e===t(this,C)?f(this,C,t(this,V)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,V)[e]),l(this,n,Kt).call(this,t(this,N),e),f(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,D)!==0){let a=t(this,R).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,D)===1)l(this,n,Wt).call(this,i);else {t(this,ft).call(this,a);let h=t(this,p)[a];if(l(this,n,w).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,L)&&t(this,F)?.push([h,e,i])),t(this,R).delete(e),t(this,v)[a]=void 0,t(this,p)[a]=void 0,a===t(this,N))f(this,N,t(this,Y)[a]);else if(a===t(this,C))f(this,C,t(this,V)[a]);else {let c=t(this,Y)[a];t(this,V)[c]=t(this,V)[a];let m=t(this,V)[a];t(this,Y)[m]=t(this,Y)[a];}It(this,D)._--,t(this,q).push(a);}}if(t(this,L)&&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,p)[r];if(l(this,n,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,v)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,L)&&t(this,F)?.push([o,a,e]);}}if(t(this,R).clear(),t(this,p).fill(void 0),t(this,v).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),f(this,C,0),f(this,N,0),t(this,q).length=0,f(this,J,0),f(this,D,0),t(this,L)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var At=class{constructor(e){E(this,"cache");E(this,"map",new Map);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 yt;(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)))(yt||={});function Rt(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw yt.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(g=>{g.storage=new At({cacheSize:50}),g.defaultStorage=new At({cacheSize:10}),g.tempStorageDeadlines=new Map;let s;function r(A){g.tempStorageDeadlines.forEach((b,T)=>{b>A&&(g.storage.delete(`${ht}:${T}`),s?.onClearOldTempVariable?.(T),g.tempStorageDeadlines.delete(T));});}g.clearOldTempVariables=r;function o(A){s=A;}g.setExternalStoreHandler=o;function a(A,b,T){T==null?g.storage.delete(`${A}:${b}`):g.storage.set(`${A}:${b}`,T),s?.onSetVariable?.(b,T);}g.setVariable=a;function h(A,b){let T=g.storage.get(`${A}:${b}`);return Rt(T)}g.getVariable=h;function c(A,b){g.storage.delete(`${A}:${b}`),s?.onRemoveVariable?.(b);}g.removeVariable=c;function m(A,b){let T=g.storage.get(Nt)||[];if(b)T.includes(A)||T.push(A);else {let y=T.indexOf(A);y>-1&&T.splice(y,1);}g.storage.set(Nt,T);}g.setFlag=m;function I(A){return (g.storage.get(Nt)||[]).includes(A)}g.getFlag=I;})(Zt||={});var S=Zt;var Dt=class{get base(){return S.storage.map}get cache(){return S.storage.cache}get tempStorageDeadlines(){return S.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{S.defaultStorage.map.set(i,s);});}set(e,i){return S.setVariable(st,e,i)}get(e){let i=S.getVariable(ht,e);return i===void 0&&(i=S.getVariable(st,e)),i===void 0&&(i=Rt(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):yt.warn("No storage data found");}catch(i){yt.error("Error importing data",i);}}};var Vt=class{constructor(e,i){E(this,"id");E(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=S.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{S.setVariable(this.categoryId,`${s}:${o}`,a);});}),S.removeVariable(st,e));}setStorageProperty(e,i){S.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return S.getVariable(this.categoryId,`${i}:${e}`)}};var Ve=new Dt;exports.StorageRegistry=S;exports.StoredClassModel=Vt;exports.storage=Ve;
|
|
1
|
+
'use strict';var core=require('./core.cjs');var te=Object.defineProperty;var Ht=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var E=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),Ut=(u,e,i)=>e.has(u)||Ht("Cannot "+i);var t=(u,e,i)=>(Ut(u,e,"read from private field"),i?i.call(u):e.get(u)),d=(u,e,i)=>e.has(u)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(Ut(u,e,"write to private field"),e.set(u,i),i),l=(u,e,i)=>(Ut(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,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=(u,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Gt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Gt>"u"){jt=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){E(this,"signal",new jt);e();}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 u=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=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=u=>!Bt.has(u);var rt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),Jt=u=>rt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(u){super(u),this.fill(0);}},et,dt,re=(et=class{constructor(e,i){E(this,"heap");E(this,"length");if(!t(et,dt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=Jt(e);if(!i)return [];f(et,dt,true);let s=new et(e,i);return f(et,dt,false),s}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,St,mt,X,D,J,R,v,p,V,Y,C,N,q,F,Q,Z,P,K,tt,lt,L,Et,n,Yt,ut,it,vt,W,Qt,ft,Tt,xt,at,ot,Pt,Ct,Mt,w,Kt,wt,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,St);d(this,mt);d(this,X);E(this,"ttl");E(this,"ttlResolution");E(this,"ttlAutopurge");E(this,"updateAgeOnGet");E(this,"updateAgeOnHas");E(this,"allowStale");E(this,"noDisposeOnSet");E(this,"noUpdateTTL");E(this,"maxEntrySize");E(this,"sizeCalculation");E(this,"noDeleteOnFetchRejection");E(this,"noDeleteOnStaleGet");E(this,"allowStaleOnFetchAbort");E(this,"allowStaleOnFetchRejection");E(this,"ignoreFetchAbort");d(this,D);d(this,J);d(this,R);d(this,v);d(this,p);d(this,V);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,P);d(this,K);d(this,tt);d(this,lt);d(this,L);d(this,Et);d(this,ut,()=>{});d(this,it,()=>{});d(this,vt,()=>{});d(this,W,()=>false);d(this,ft,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});E(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:I,disposeAfter:g,noDisposeOnSet:A,noUpdateTTL:b,maxSize:T=0,maxEntrySize:y=0,sizeCalculation:O,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:Ot,ignoreFetchAbort:pt,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,gt??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(f(this,$,i),f(this,z,T),this.maxEntrySize=y||t(this,z),this.sizeCalculation=O,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(f(this,mt,M),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,St,_),f(this,lt,!!_),f(this,R,new Map),f(this,v,new Array(i).fill(void 0)),f(this,p,new Array(i).fill(void 0)),f(this,V,new _t(i)),f(this,Y,new _t(i)),f(this,C,0),f(this,N,0),f(this,q,re.create(i)),f(this,D,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof I=="function"&&f(this,ct,I),typeof g=="function"?(f(this,B,g),f(this,F,[])):(f(this,B,void 0),f(this,F,void 0)),f(this,tt,!!t(this,k)),f(this,Et,!!t(this,ct)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!A,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!Ot,this.ignoreFetchAbort=!!pt,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 Lt="LRU_CACHE_UNBOUNDED";se(Lt)&&(Bt.add(Lt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Lt,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,R),keyList:t(e,v),valList:t(e,p),next:t(e,V),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,w).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,wt).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,D)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,mt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&t(this,v)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield [t(this,v)[e],t(this,p)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&t(this,v)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield [t(this,v)[e],t(this,p)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,v)[e];i!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,v)[e];i!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&!l(this,n,w).call(this,t(this,p)[e])&&(yield t(this,p)[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,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,v)[s],this))return this.get(t(this,v)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,v)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],o=l(this,n,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,v)[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,v)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,p)[i],r=l(this,n,w).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,v)[i],r=t(this,p)[i],o=l(this,n,w).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 A,b,T,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:m=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 g=t(this,D)===0?void 0:t(this,R).get(e);if(g===void 0)g=t(this,D)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,D)===t(this,$)?l(this,n,Ct).call(this,false):t(this,D),t(this,v)[g]=e,t(this,p)[g]=i,t(this,R).set(e,g),t(this,V)[t(this,N)]=g,t(this,Y)[g]=t(this,N),f(this,N,g),It(this,D)._++,t(this,Tt).call(this,g,I,c),c&&(c.set="add"),m=false,t(this,Et)&&((A=t(this,ct))==null||A.call(this,i,e,"add"));else {l(this,n,wt).call(this,g);let O=t(this,p)[g];if(i!==O){if(t(this,lt)&&l(this,n,w).call(this,O)){O.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=O;_!==void 0&&!a&&(t(this,tt)&&((b=t(this,k))==null||b.call(this,_,e,"set")),t(this,L)&&t(this,F)?.push([_,e,"set"]));}else a||(t(this,tt)&&((T=t(this,k))==null||T.call(this,O,e,"set")),t(this,L)&&t(this,F)?.push([O,e,"set"]));if(t(this,ft).call(this,g),t(this,Tt).call(this,g,I,c),t(this,p)[g]=i,c){c.set="replace";let _=O&&l(this,n,w).call(this,O)?O.__staleWhileFetching:O;_!==void 0&&(c.oldValue=_);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===O?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(m||t(this,vt).call(this,g,r,o),c&&t(this,it).call(this,c,g)),!a&&t(this,L)&&t(this,F)){let O=t(this,F),_;for(;_=O?.shift();)(y=t(this,B))==null||y.call(this,..._);}return this}pop(){var e;try{for(;t(this,D);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&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,R).get(e);if(o!==void 0){let a=t(this,p)[o];if(l(this,n,w).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,ut).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,R).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,p)[r];return l(this,n,w).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:m=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:A=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:y,forceRefresh:O=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:m,noUpdateTTL:I,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:_,signal:M},G=t(this,R).get(e);if(G===void 0){_&&(_.fetch="miss");let x=l(this,n,Mt).call(this,e,G,U,y);return x.__returned=x}else {let x=t(this,p)[G];if(l(this,n,w).call(this,x)){let _t=s&&x.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",_t&&(_.returnedStale=true)),_t?x.__staleWhileFetching:x.__returned=x}let Ot=t(this,W).call(this,G);if(!O&&!Ot)return _&&(_.fetch="hit"),l(this,n,wt).call(this,G),r&&t(this,ut).call(this,G),_&&t(this,it).call(this,_,G),x;let pt=l(this,n,Mt).call(this,e,G,U,y),gt=pt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=Ot?"stale":"refresh",gt&&Ot&&(_.returnedStale=true)),gt?pt.__staleWhileFetching:pt.__returned=pt}}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,mt);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,R).get(e);if(h!==void 0){let c=t(this,p)[h],m=l(this,n,w).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),m?(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"),m?c.__staleWhileFetching:(l(this,n,wt).call(this,h),r&&t(this,ut).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,St=new WeakMap,mt=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,R=new WeakMap,v=new WeakMap,p=new WeakMap,V=new WeakMap,Y=new WeakMap,C=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,L=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));f(this,P,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,K,s),f(this,vt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ut,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 m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,v)[h],"expire");},c+1);m.unref&&m.unref(),s[h]=m;}}:()=>{};f(this,it,(h,c)=>{if(e[c]){let m=e[c],I=i[c];if(!m||!I)return;h.ttl=m,h.start=I,h.now=o||a();let g=h.now-I;h.remainingTTL=m-g;}});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,R).get(h);if(c===void 0)return 0;let m=e[c],I=i[c];if(!m||!I)return 1/0;let g=(o||a())-I;return m-g},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(o||a())-c>m});},ut=new WeakMap,it=new WeakMap,vt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,ft,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,xt,(i,s,r,o)=>{if(l(this,n,w).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}),f(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);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ft=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,D))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,C)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,C);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,V)[i];},Pt=function(e){return e!==void 0&&t(this,R).get(t(this,v)[e])===e},Ct=function(e){var o;let i=t(this,C),s=t(this,v)[i],r=t(this,p)[i];return t(this,lt)&&l(this,n,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,L)&&t(this,F)?.push([r,s,"evict"])),t(this,ft).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,v)[i]=void 0,t(this,p)[i]=void 0,t(this,q).push(i)),t(this,D)===1?(f(this,C,f(this,N,0)),t(this,q).length=0):f(this,C,t(this,V)[i]),t(this,R).delete(s),It(this,D)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,p)[i];if(l(this,n,w).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},m=(y,O=false)=>{let{aborted:_}=a.signal,M=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(_&&!O?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!O)return g(a.signal.reason,U);let G=b,x=t(this,p)[i];return (x===b||M&&O&&x===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,p)[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),g(y,false)),g=(y,O)=>{let{aborted:_}=a.signal,M=_&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,x=b;if(t(this,p)[i]===b&&(!G||!O&&x.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,p)[i]=x.__staleWhileFetching)),U)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw y},A=(y,O)=>{var M;let _=(M=t(this,St))==null?void 0:M.call(this,e,o,c);_&&_ instanceof Promise&&_.then(U=>y(U===void 0?void 0:U),O),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>m(U,true)));});};s.status&&(s.status.fetchDispatched=true);let b=new Promise(A).then(m,I),T=Object.assign(b,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,T,{...c.options,status:void 0}),i=t(this,R).get(e)):t(this,p)[i]=T,T},w=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Kt=function(e,i){t(this,Y)[i]=e,t(this,V)[e]=i;},wt=function(e){e!==t(this,N)&&(e===t(this,C)?f(this,C,t(this,V)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,V)[e]),l(this,n,Kt).call(this,t(this,N),e),f(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,D)!==0){let a=t(this,R).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,D)===1)l(this,n,Wt).call(this,i);else {t(this,ft).call(this,a);let h=t(this,p)[a];if(l(this,n,w).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,L)&&t(this,F)?.push([h,e,i])),t(this,R).delete(e),t(this,v)[a]=void 0,t(this,p)[a]=void 0,a===t(this,N))f(this,N,t(this,Y)[a]);else if(a===t(this,C))f(this,C,t(this,V)[a]);else {let c=t(this,Y)[a];t(this,V)[c]=t(this,V)[a];let m=t(this,V)[a];t(this,Y)[m]=t(this,Y)[a];}It(this,D)._--,t(this,q).push(a);}}if(t(this,L)&&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,p)[r];if(l(this,n,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,v)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,L)&&t(this,F)?.push([o,a,e]);}}if(t(this,R).clear(),t(this,p).fill(void 0),t(this,v).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),f(this,C,0),f(this,N,0),t(this,q).length=0,f(this,J,0),f(this,D,0),t(this,L)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var At=class{constructor(e){E(this,"cache");E(this,"map",new Map);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 yt;(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)))(yt||={});function Rt(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw yt.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(g=>{g.storage=new At({cacheSize:50}),g.defaultStorage=new At({cacheSize:10}),g.tempStorageDeadlines=new Map;let s;function r(A){g.tempStorageDeadlines.forEach((b,T)=>{b>A&&(g.storage.delete(`${ht}:${T}`),s?.onClearOldTempVariable?.(T),g.tempStorageDeadlines.delete(T));});}g.clearOldTempVariables=r;function o(A){s=A;}g.setExternalStoreHandler=o;function a(A,b,T){T==null?g.storage.delete(`${A}:${b}`):g.storage.set(`${A}:${b}`,T),s?.onSetVariable?.(b,T);}g.setVariable=a;function h(A,b){let T=g.storage.get(`${A}:${b}`);return Rt(T)}g.getVariable=h;function c(A,b){g.storage.delete(`${A}:${b}`),s?.onRemoveVariable?.(b);}g.removeVariable=c;function m(A,b){let T=g.storage.get(Nt)||[];if(b)T.includes(A)||T.push(A);else {let y=T.indexOf(A);y>-1&&T.splice(y,1);}g.storage.set(Nt,T);}g.setFlag=m;function I(A){return (g.storage.get(Nt)||[]).includes(A)}g.getFlag=I;})(Zt||={});var S=Zt;var Dt=class{get base(){return S.storage.map}get cache(){return S.storage.cache}get tempStorageDeadlines(){return S.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{S.defaultStorage.map.set(i,s);});}set(e,i){return S.setVariable(st,e,i)}get(e){let i=S.getVariable(ht,e);return i===void 0&&(i=S.getVariable(st,e)),i===void 0&&(i=Rt(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):yt.warn("No storage data found");}catch(i){yt.error("Error importing data",i);}}};var Vt=class{constructor(e,i){E(this,"id");E(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=S.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{S.setVariable(this.categoryId,`${s}:${o}`,a);});}),S.removeVariable(st,e));}setStorageProperty(e,i){S.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return S.getVariable(this.categoryId,`${i}:${e}`)}};var Ve=new Dt;exports.StorageRegistry=S;exports.StoredClassModel=Vt;exports.storage=Ve;
|
package/dist/vite-listener.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var canvas=require('
|
|
1
|
+
'use strict';var canvas=require('./canvas.cjs'),characters=require('./characters.cjs'),narration=require('./narration.cjs'),l=require('./pixi/index.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var i="/__pixi-vn/characters",a="/__pixi-vn/labels",c="/__pixi-vn/assets/manifest",p="/__pixi-vn/canvas-options";async function e(t,s,r="data"){try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(n){console.warn(`Failed to send ${r} to ${t}:`,n);}}function d(){let t=l__default.default.Assets.resolver._assetMap,s=l__default.default.Assets.resolver._bundles;return {bundles:Object.entries(s).map(([r,n])=>({name:r,assets:n.flatMap(I=>t[I]??[])}))}}function _(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function m(){if(_()){try{let t=characters.RegisteredCharacters.values();await e(i,t,"characters");}catch(t){console.warn("Error collecting characters:",t);}try{let t=narration.RegisteredLabels.keys();await e(a,t,"labels");}catch(t){console.warn("Error collecting labels:",t);}try{let t=d();await e(c,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}if(canvas.canvas.isInitialized)try{let t={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};await e(p,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}exports.isViteDevelopmentMode=_;exports.setupPixivnViteData=m;
|
package/dist/vite-listener.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {a,b,c,d}from'./chunk-3BBZHKU4.mjs';import'./chunk-K7JIC2F2.mjs';import {canvas}from'
|
|
1
|
+
import {a,b,c,d}from'./chunk-3BBZHKU4.mjs';import'./chunk-K7JIC2F2.mjs';import {canvas}from'./canvas.mjs';import {RegisteredCharacters}from'./characters.mjs';import {RegisteredLabels}from'./narration.mjs';import p from'./pixi/index.js';async function t(e,s,r="data"){try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(o){console.warn(`Failed to send ${r} to ${e}:`,o);}}function A(){let e=p.Assets.resolver._assetMap,s=p.Assets.resolver._bundles;return {bundles:Object.entries(s).map(([r,o])=>({name:r,assets:o.flatMap(d=>e[d]??[])}))}}function f(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function h(){if(f()){try{let e=RegisteredCharacters.values();await t(a,e,"characters");}catch(e){console.warn("Error collecting characters:",e);}try{let e=RegisteredLabels.keys();await t(b,e,"labels");}catch(e){console.warn("Error collecting labels:",e);}try{let e=A();await t(c,e,"assets manifest");}catch(e){console.warn("Error collecting assets manifest:",e);}if(canvas.isInitialized)try{let e={height:canvas.app.screen.height,width:canvas.app.screen.width};await t(d,e,"canvas options");}catch(e){console.warn("Error collecting canvas options:",e);}}}export{f as isViteDevelopmentMode,h as setupPixivnViteData};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pixi'VN is a npm package that provides various features for creating visual novels.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -9,14 +9,18 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
|
+
"workspaces": [
|
|
13
|
+
"sandbox"
|
|
14
|
+
],
|
|
12
15
|
"scripts": {
|
|
13
16
|
"dev": "tsup --watch",
|
|
14
|
-
"build": "tsup --config tsup.config.ts",
|
|
17
|
+
"build": "tsup --config tsup.config.ts && node scripts/fix-imports.mjs",
|
|
15
18
|
"lint": "biome lint",
|
|
16
19
|
"check": "biome check",
|
|
17
20
|
"format": "biome format --write",
|
|
18
21
|
"test": "vitest",
|
|
19
|
-
"docs": "typedoc"
|
|
22
|
+
"docs": "typedoc",
|
|
23
|
+
"sandbox": "npm run build && npm install && npm run start --workspace=sandbox"
|
|
20
24
|
},
|
|
21
25
|
"exports": {
|
|
22
26
|
".": {
|