@drincs/pixi-vn 1.6.0 → 1.6.2
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 +2 -3
- package/dist/canvas.mjs +2 -3
- package/dist/characters.cjs +1 -2
- package/dist/characters.mjs +1 -2
- package/dist/{chunk-FIGGUFAM.mjs → chunk-D45QSSXG.mjs} +1 -2
- package/dist/{chunk-TKYEUKV4.mjs → chunk-HACUDOYJ.mjs} +1 -2
- package/dist/{chunk-UIXKMF72.mjs → chunk-IWAXXFXE.mjs} +1 -2
- package/dist/{chunk-2ZJFDDPE.mjs → chunk-L4IHQ3VT.mjs} +1 -2
- package/dist/{chunk-JJFD2BVW.mjs → chunk-TTRUPDAB.mjs} +1 -2
- package/dist/chunk-XSN6P5JL.mjs +0 -0
- package/dist/{chunk-EC6URLQW.mjs → chunk-ZW3MIPMS.mjs} +1 -2
- package/dist/history.cjs +1 -2
- package/dist/history.mjs +1 -2
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -3
- package/dist/motion.cjs +1 -2
- package/dist/motion.mjs +1 -2
- package/dist/narration.cjs +1 -2
- package/dist/narration.mjs +2 -3
- package/dist/sound.cjs +1 -2
- package/dist/sound.d.cts +1 -1
- package/dist/sound.d.ts +1 -1
- package/dist/sound.mjs +1 -2
- package/dist/storage.cjs +1 -2
- package/dist/storage.mjs +1 -2
- package/dist/vite-listener.cjs +1 -2
- package/dist/vite-listener.mjs +1 -2
- package/dist/vite.cjs +1 -2
- package/dist/vite.mjs +1 -2
- package/package.json +1 -1
- package/dist/canvas.cjs.map +0 -1
- package/dist/canvas.mjs.map +0 -1
- package/dist/characters.cjs.map +0 -1
- package/dist/characters.mjs.map +0 -1
- package/dist/chunk-2ZJFDDPE.mjs.map +0 -1
- package/dist/chunk-52EK6LYW.mjs +0 -2
- package/dist/chunk-52EK6LYW.mjs.map +0 -1
- package/dist/chunk-EC6URLQW.mjs.map +0 -1
- package/dist/chunk-FIGGUFAM.mjs.map +0 -1
- package/dist/chunk-JJFD2BVW.mjs.map +0 -1
- package/dist/chunk-TKYEUKV4.mjs.map +0 -1
- package/dist/chunk-UIXKMF72.mjs.map +0 -1
- package/dist/history.cjs.map +0 -1
- package/dist/history.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/motion.cjs.map +0 -1
- package/dist/motion.mjs.map +0 -1
- package/dist/narration.cjs.map +0 -1
- package/dist/narration.mjs.map +0 -1
- package/dist/sound.cjs.map +0 -1
- package/dist/sound.mjs.map +0 -1
- package/dist/storage.cjs.map +0 -1
- package/dist/storage.mjs.map +0 -1
- package/dist/vite-listener.cjs.map +0 -1
- package/dist/vite-listener.mjs.map +0 -1
- package/dist/vite.cjs.map +0 -1
- package/dist/vite.mjs.map +0 -1
package/dist/narration.cjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
'use strict';var core=require('@drincs/pixi-vn/core');var St=Object.create;var Be=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var tt=h=>{throw TypeError(h)};var Tt=(h,e,t)=>e in h?Be(h,e,{enumerable:true,configurable:true,writable:true,value:t}):h[e]=t;var je=(h=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(h,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):h)(function(h){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+h+'" is not supported')});var rt=(h,e)=>()=>(e||h((e={exports:{}}).exports,e),e.exports);var Et=(h,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yt(e))!_t.call(h,n)&&n!==t&&Be(h,n,{get:()=>e[n],enumerable:!(i=gt(e,n))||i.enumerable});return h};var Ct=(h,e,t)=>(t=h!=null?St(Lt(h)):{},Et(Be(t,"default",{value:h,enumerable:true}),h));var E=(h,e,t)=>Tt(h,typeof e!="symbol"?e+"":e,t),ke=(h,e,t)=>e.has(h)||tt("Cannot "+t);var r=(h,e,t)=>(ke(h,e,"read from private field"),t?t.call(h):e.get(h)),x=(h,e,t)=>e.has(h)?tt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,t),g=(h,e,t,i)=>(ke(h,e,"write to private field"),e.set(h,t),t),f=(h,e,t)=>(ke(h,e,"access private method"),t);var Ye=(h,e,t,i)=>({set _(n){g(h,e,n);},get _(){return r(h,e,i)}});var ct=rt((Ke,pt)=>{(function(h,e){typeof Ke=="object"?pt.exports=Ke=e():typeof define=="function"&&define.amd?define([],e):h.CryptoJS=e();})(Ke,function(){var h=h||(function(e,t){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof je=="function")try{i=je("crypto");}catch{}var n=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||(function(){function o(){}return function(d){var O;return o.prototype=d,O=new o,o.prototype=null,O}})(),a={},l=a.lib={},u=l.Base=(function(){return {extend:function(o){var d=s(this);return o&&d.mixIn(o),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var d in o)o.hasOwnProperty(d)&&(this[d]=o[d]);o.hasOwnProperty("toString")&&(this.toString=o.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),S=l.WordArray=u.extend({init:function(o,d){o=this.words=o||[],d!=t?this.sigBytes=d:this.sigBytes=o.length*4;},toString:function(o){return (o||_).stringify(this)},concat:function(o){var d=this.words,O=o.words,I=this.sigBytes,w=o.sigBytes;if(this.clamp(),I%4)for(var Y=0;Y<w;Y++){var le=O[Y>>>2]>>>24-Y%4*8&255;d[I+Y>>>2]|=le<<24-(I+Y)%4*8;}else for(var K=0;K<w;K+=4)d[I+K>>>2]=O[K>>>2];return this.sigBytes+=w,this},clamp:function(){var o=this.words,d=this.sigBytes;o[d>>>2]&=4294967295<<32-d%4*8,o.length=e.ceil(d/4);},clone:function(){var o=u.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var d=[],O=0;O<o;O+=4)d.push(n());return new S.init(d,o)}}),c=a.enc={},_=c.Hex={stringify:function(o){for(var d=o.words,O=o.sigBytes,I=[],w=0;w<O;w++){var Y=d[w>>>2]>>>24-w%4*8&255;I.push((Y>>>4).toString(16)),I.push((Y&15).toString(16));}return I.join("")},parse:function(o){for(var d=o.length,O=[],I=0;I<d;I+=2)O[I>>>3]|=parseInt(o.substr(I,2),16)<<24-I%8*4;return new S.init(O,d/2)}},D=c.Latin1={stringify:function(o){for(var d=o.words,O=o.sigBytes,I=[],w=0;w<O;w++){var Y=d[w>>>2]>>>24-w%4*8&255;I.push(String.fromCharCode(Y));}return I.join("")},parse:function(o){for(var d=o.length,O=[],I=0;I<d;I++)O[I>>>2]|=(o.charCodeAt(I)&255)<<24-I%4*8;return new S.init(O,d)}},P=c.Utf8={stringify:function(o){try{return decodeURIComponent(escape(D.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return D.parse(unescape(encodeURIComponent(o)))}},U=l.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new S.init,this._nDataBytes=0;},_append:function(o){typeof o=="string"&&(o=P.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes;},_process:function(o){var d,O=this._data,I=O.words,w=O.sigBytes,Y=this.blockSize,le=Y*4,K=w/le;o?K=e.ceil(K):K=e.max((K|0)-this._minBufferSize,0);var Q=K*Y,_e=e.min(Q*4,w);if(Q){for(var We=0;We<Q;We+=Y)this._doProcessBlock(I,We);d=I.splice(0,Q),O.sigBytes-=_e;}return new S.init(d,_e)},clone:function(){var o=u.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});l.Hasher=U.extend({cfg:u.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset();},reset:function(){U.reset.call(this),this._doReset();},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(o){return function(d,O){return new o.init(O).finalize(d)}},_createHmacHelper:function(o){return function(d,O){return new C.HMAC.init(o,O).finalize(d)}}});var C=a.algo={};return a})(Math);return h});});var ft=rt((He,dt)=>{(function(h,e){typeof He=="object"?dt.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(h.CryptoJS);})(He,function(h){return (function(){var e=h,t=e.lib,i=t.WordArray,n=t.Hasher,s=e.algo,a=[],l=s.SHA1=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,S){for(var c=this._hash.words,_=c[0],D=c[1],P=c[2],U=c[3],A=c[4],C=0;C<80;C++){if(C<16)a[C]=u[S+C]|0;else {var o=a[C-3]^a[C-8]^a[C-14]^a[C-16];a[C]=o<<1|o>>>31;}var d=(_<<5|_>>>27)+A+a[C];C<20?d+=(D&P|~D&U)+1518500249:C<40?d+=(D^P^U)+1859775393:C<60?d+=(D&P|D&U|P&U)-1894007588:d+=(D^P^U)-899497514,A=U,U=P,P=D<<30|D>>>2,D=_,_=d;}c[0]=c[0]+_|0,c[1]=c[1]+D|0,c[2]=c[2]+P|0,c[3]=c[3]+U|0,c[4]=c[4]+A|0;},_doFinalize:function(){var u=this._data,S=u.words,c=this._nDataBytes*8,_=u.sigBytes*8;return S[_>>>5]|=128<<24-_%32,S[(_+64>>>9<<4)+14]=Math.floor(c/4294967296),S[(_+64>>>9<<4)+15]=c,u.sigBytes=S.length*4,this._process(),this._hash},clone:function(){var u=n.clone.call(this);return u._hash=this._hash.clone(),u}});e.SHA1=n._createHelper(l),e.HmacSHA1=n._createHmacHelper(l);})(),h.SHA1});});var v="narration";var R={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 L;(n=>(n.log=(s,...a)=>console.log(`[Pixi\u2019VN] ${s}`,...a),n.warn=(s,...a)=>console.warn(`[Pixi\u2019VN] ${s}`,...a),n.error=(s,...a)=>console.error(`[Pixi\u2019VN] ${s}`,...a),n.info=(s,...a)=>console.info(`[Pixi\u2019VN] ${s}`,...a)))(L||(L={}));function he(h){try{if(typeof h>"u")return h;let e=JSON.stringify(h);return JSON.parse(e)}catch(e){throw L.error("Error creating exportable element",h,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Ot=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,at=new Set,$e=typeof process=="object"&&process?process:{},ot=(h,e,t,i)=>{typeof $e.emitWarning=="function"?$e.emitWarning(h,e,t,i):console.error(`[${t}] ${e}: ${h}`);},ze=globalThis.AbortController,it=globalThis.AbortSignal;if(typeof ze>"u"){it=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(t,i){this._onabort.push(i);}},ze=class{constructor(){E(this,"signal",new it);e();}abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let i of this.signal._onabort)i(t);this.signal.onabort?.(t);}}};let h=$e.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{h&&(h=false,ot("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 Rt=h=>!at.has(h);var de=h=>h&&h===Math.floor(h)&&h>0&&isFinite(h),lt=h=>de(h)?h<=Math.pow(2,8)?Uint8Array:h<=Math.pow(2,16)?Uint16Array:h<=Math.pow(2,32)?Uint32Array:h<=Number.MAX_SAFE_INTEGER?Fe:null:null,Fe=class extends Array{constructor(h){super(h),this.fill(0);}},ue,Te,wt=(ue=class{constructor(e,t){E(this,"heap");E(this,"length");if(!r(ue,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=lt(e);if(!t)return [];g(ue,Te,true);let i=new ue(e,t);return g(ue,Te,false),i}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,x(ue,Te,false),ue),nt,st,J,j,Z,ge,ee,Ee,Ce,te,V,re,F,N,T,W,k,H,G,ie,z,ne,se,$,q,ae,Se,B,Ie,p,qe,ye,pe,De,X,ut,Le,Oe,Pe,fe,be,Xe,Ve,Ge,M,Je,Ne,me,Qe,Re,ht=(Re=class{constructor(e){x(this,p);x(this,J);x(this,j);x(this,Z);x(this,ge);x(this,ee);x(this,Ee);x(this,Ce);x(this,te);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");x(this,V);x(this,re);x(this,F);x(this,N);x(this,T);x(this,W);x(this,k);x(this,H);x(this,G);x(this,ie);x(this,z);x(this,ne);x(this,se);x(this,$);x(this,q);x(this,ae);x(this,Se);x(this,B);x(this,Ie);x(this,ye,()=>{});x(this,pe,()=>{});x(this,De,()=>{});x(this,X,()=>false);x(this,Le,e=>{});x(this,Oe,(e,t,i)=>{});x(this,Pe,(e,t,i,n)=>{if(i||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});E(this,nt,"LRUCache");let{max:t=0,ttl:i,ttlResolution:n=1,ttlAutopurge:s,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:S,onInsert:c,disposeAfter:_,noDisposeOnSet:D,noUpdateTTL:P,maxSize:U=0,maxEntrySize:A=0,sizeCalculation:C,fetchMethod:o,memoMethod:d,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:I,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:Y,ignoreFetchAbort:le,perf:K}=e;if(K!==void 0&&typeof K?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,te,K??Ot),t!==0&&!de(t))throw new TypeError("max option must be a nonnegative integer");let Q=t?lt(t):Array;if(!Q)throw new Error("invalid max value: "+t);if(g(this,J,t),g(this,j,U),this.maxEntrySize=A||r(this,j),this.sizeCalculation=C,this.sizeCalculation){if(!r(this,j)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,Ce,d),o!==void 0&&typeof o!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,Ee,o),g(this,Se,!!o),g(this,F,new Map),g(this,N,new Array(t).fill(void 0)),g(this,T,new Array(t).fill(void 0)),g(this,W,new Q(t)),g(this,k,new Q(t)),g(this,H,0),g(this,G,0),g(this,ie,wt.create(t)),g(this,V,0),g(this,re,0),typeof S=="function"&&g(this,Z,S),typeof c=="function"&&g(this,ge,c),typeof _=="function"?(g(this,ee,_),g(this,z,[])):(g(this,ee,void 0),g(this,z,void 0)),g(this,ae,!!r(this,Z)),g(this,Ie,!!r(this,ge)),g(this,B,!!r(this,ee)),this.noDisposeOnSet=!!D,this.noUpdateTTL=!!P,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!Y,this.ignoreFetchAbort=!!le,this.maxEntrySize!==0){if(r(this,j)!==0&&!de(r(this,j)))throw new TypeError("maxSize must be a positive integer if specified");if(!de(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,p,ut).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!I,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=de(n)||n===0?n:1,this.ttlAutopurge=!!s,this.ttl=i||0,this.ttl){if(!de(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,p,qe).call(this);}if(r(this,J)===0&&this.ttl===0&&r(this,j)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,J)&&!r(this,j)){let _e="LRU_CACHE_UNBOUNDED";Rt(_e)&&(at.add(_e),ot("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_e,Re));}}get perf(){return r(this,te)}static unsafeExposeInternals(e){return {starts:r(e,se),ttls:r(e,$),autopurgeTimers:r(e,q),sizes:r(e,ne),keyMap:r(e,F),keyList:r(e,N),valList:r(e,T),next:r(e,W),prev:r(e,k),get head(){return r(e,H)},get tail(){return r(e,G)},free:r(e,ie),isBackgroundFetch:t=>{var i;return f(i=e,p,M).call(i,t)},backgroundFetch:(t,i,n,s)=>{var a;return f(a=e,p,Ge).call(a,t,i,n,s)},moveToTail:t=>{var i;return f(i=e,p,Ne).call(i,t)},indexes:t=>{var i;return f(i=e,p,fe).call(i,t)},rindexes:t=>{var i;return f(i=e,p,be).call(i,t)},isStale:t=>{var i;return r(i=e,X).call(i,t)}}}get max(){return r(this,J)}get maxSize(){return r(this,j)}get calculatedSize(){return r(this,re)}get size(){return r(this,V)}get fetchMethod(){return r(this,Ee)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,Z)}get onInsert(){return r(this,ge)}get disposeAfter(){return r(this,ee)}getRemainingTTL(e){return r(this,F).has(e)?1/0:0}*entries(){for(let e of f(this,p,fe).call(this))r(this,T)[e]!==void 0&&r(this,N)[e]!==void 0&&!f(this,p,M).call(this,r(this,T)[e])&&(yield [r(this,N)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,p,be).call(this))r(this,T)[e]!==void 0&&r(this,N)[e]!==void 0&&!f(this,p,M).call(this,r(this,T)[e])&&(yield [r(this,N)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,p,fe).call(this)){let t=r(this,N)[e];t!==void 0&&!f(this,p,M).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,p,be).call(this)){let t=r(this,N)[e];t!==void 0&&!f(this,p,M).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,p,fe).call(this))r(this,T)[e]!==void 0&&!f(this,p,M).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,p,be).call(this))r(this,T)[e]!==void 0&&!f(this,p,M).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(st=Symbol.iterator,nt=Symbol.toStringTag,st)](){return this.entries()}find(e,t={}){for(let i of f(this,p,fe).call(this)){let n=r(this,T)[i],s=f(this,p,M).call(this,n)?n.__staleWhileFetching:n;if(s!==void 0&&e(s,r(this,N)[i],this))return this.get(r(this,N)[i],t)}}forEach(e,t=this){for(let i of f(this,p,fe).call(this)){let n=r(this,T)[i],s=f(this,p,M).call(this,n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,r(this,N)[i],this);}}rforEach(e,t=this){for(let i of f(this,p,be).call(this)){let n=r(this,T)[i],s=f(this,p,M).call(this,n)?n.__staleWhileFetching:n;s!==void 0&&e.call(t,s,r(this,N)[i],this);}}purgeStale(){let e=false;for(let t of f(this,p,be).call(this,{allowStale:true}))r(this,X).call(this,t)&&(f(this,p,me).call(this,r(this,N)[t],"expire"),e=true);return e}info(e){let t=r(this,F).get(e);if(t===void 0)return;let i=r(this,T)[t],n=f(this,p,M).call(this,i)?i.__staleWhileFetching:i;if(n===void 0)return;let s={value:n};if(r(this,$)&&r(this,se)){let a=r(this,$)[t],l=r(this,se)[t];if(a&&l){let u=a-(r(this,te).now()-l);s.ttl=u,s.start=Date.now();}}return r(this,ne)&&(s.size=r(this,ne)[t]),s}dump(){let e=[];for(let t of f(this,p,fe).call(this,{allowStale:true})){let i=r(this,N)[t],n=r(this,T)[t],s=f(this,p,M).call(this,n)?n.__staleWhileFetching:n;if(s===void 0||i===void 0)continue;let a={value:s};if(r(this,$)&&r(this,se)){a.ttl=r(this,$)[t];let l=r(this,te).now()-r(this,se)[t];a.start=Math.floor(Date.now()-l);}r(this,ne)&&(a.size=r(this,ne)[t]),e.unshift([i,a]);}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let n=Date.now()-i.start;i.start=r(this,te).now()-n;}this.set(t,i.value,i);}}set(e,t,i={}){var D,P,U,A;if(t===void 0)return this.delete(e),this;let{ttl:n=this.ttl,start:s,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=i,{noUpdateTTL:S=this.noUpdateTTL}=i,c=r(this,Pe).call(this,e,t,i.size||0,l);if(this.maxEntrySize&&c>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),f(this,p,me).call(this,e,"set"),this;let _=r(this,V)===0?void 0:r(this,F).get(e);if(_===void 0)_=r(this,V)===0?r(this,G):r(this,ie).length!==0?r(this,ie).pop():r(this,V)===r(this,J)?f(this,p,Ve).call(this,false):r(this,V),r(this,N)[_]=e,r(this,T)[_]=t,r(this,F).set(e,_),r(this,W)[r(this,G)]=_,r(this,k)[_]=r(this,G),g(this,G,_),Ye(this,V)._++,r(this,Oe).call(this,_,c,u),u&&(u.set="add"),S=false,r(this,Ie)&&((D=r(this,ge))==null||D.call(this,t,e,"add"));else {f(this,p,Ne).call(this,_);let C=r(this,T)[_];if(t!==C){if(r(this,Se)&&f(this,p,M).call(this,C)){C.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:o}=C;o!==void 0&&!a&&(r(this,ae)&&((P=r(this,Z))==null||P.call(this,o,e,"set")),r(this,B)&&r(this,z)?.push([o,e,"set"]));}else a||(r(this,ae)&&((U=r(this,Z))==null||U.call(this,C,e,"set")),r(this,B)&&r(this,z)?.push([C,e,"set"]));if(r(this,Le).call(this,_),r(this,Oe).call(this,_,c,u),r(this,T)[_]=t,u){u.set="replace";let o=C&&f(this,p,M).call(this,C)?C.__staleWhileFetching:C;o!==void 0&&(u.oldValue=o);}}else u&&(u.set="update");r(this,Ie)&&this.onInsert?.(t,e,t===C?"update":"replace");}if(n!==0&&!r(this,$)&&f(this,p,qe).call(this),r(this,$)&&(S||r(this,De).call(this,_,n,s),u&&r(this,pe).call(this,u,_)),!a&&r(this,B)&&r(this,z)){let C=r(this,z),o;for(;o=C?.shift();)(A=r(this,ee))==null||A.call(this,...o);}return this}pop(){var e;try{for(;r(this,V);){let t=r(this,T)[r(this,H)];if(f(this,p,Ve).call(this,!0),f(this,p,M).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,B)&&r(this,z)){let t=r(this,z),i;for(;i=t?.shift();)(e=r(this,ee))==null||e.call(this,...i);}}}has(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:n}=t,s=r(this,F).get(e);if(s!==void 0){let a=r(this,T)[s];if(f(this,p,M).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(r(this,X).call(this,s))n&&(n.has="stale",r(this,pe).call(this,n,s));else return i&&r(this,ye).call(this,s),n&&(n.has="hit",r(this,pe).call(this,n,s)),true}else n&&(n.has="miss");return false}peek(e,t={}){let{allowStale:i=this.allowStale}=t,n=r(this,F).get(e);if(n===void 0||!i&&r(this,X).call(this,n))return;let s=r(this,T)[n];return f(this,p,M).call(this,s)?s.__staleWhileFetching:s}async fetch(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:D=this.allowStaleOnFetchRejection,ignoreFetchAbort:P=this.ignoreFetchAbort,allowStaleOnFetchAbort:U=this.allowStaleOnFetchAbort,context:A,forceRefresh:C=false,status:o,signal:d}=t;if(!r(this,Se))return o&&(o.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:s,status:o});let O={allowStale:i,updateAgeOnGet:n,noDeleteOnStaleGet:s,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:S,noUpdateTTL:c,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:D,allowStaleOnFetchAbort:U,ignoreFetchAbort:P,status:o,signal:d},I=r(this,F).get(e);if(I===void 0){o&&(o.fetch="miss");let w=f(this,p,Ge).call(this,e,I,O,A);return w.__returned=w}else {let w=r(this,T)[I];if(f(this,p,M).call(this,w)){let Q=i&&w.__staleWhileFetching!==void 0;return o&&(o.fetch="inflight",Q&&(o.returnedStale=true)),Q?w.__staleWhileFetching:w.__returned=w}let Y=r(this,X).call(this,I);if(!C&&!Y)return o&&(o.fetch="hit"),f(this,p,Ne).call(this,I),n&&r(this,ye).call(this,I),o&&r(this,pe).call(this,o,I),w;let le=f(this,p,Ge).call(this,e,I,O,A),K=le.__staleWhileFetching!==void 0&&i;return o&&(o.fetch=Y?"stale":"refresh",K&&Y&&(o.returnedStale=true)),K?le.__staleWhileFetching:le.__returned=le}}async forceFetch(e,t={}){let i=await this.fetch(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let i=r(this,Ce);if(!i)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:s,...a}=t,l=this.get(e,a);if(!s&&l!==void 0)return l;let u=i(e,l,{options:a,context:n});return this.set(e,u,a),u}get(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:a}=t,l=r(this,F).get(e);if(l!==void 0){let u=r(this,T)[l],S=f(this,p,M).call(this,u);return a&&r(this,pe).call(this,a,l),r(this,X).call(this,l)?(a&&(a.get="stale"),S?(a&&i&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),i?u.__staleWhileFetching:void 0):(s||f(this,p,me).call(this,e,"expire"),a&&i&&(a.returnedStale=true),i?u:void 0)):(a&&(a.get="hit"),S?u.__staleWhileFetching:(f(this,p,Ne).call(this,l),n&&r(this,ye).call(this,l),u))}else a&&(a.get="miss");}delete(e){return f(this,p,me).call(this,e,"delete")}clear(){return f(this,p,Qe).call(this,"delete")}},J=new WeakMap,j=new WeakMap,Z=new WeakMap,ge=new WeakMap,ee=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,te=new WeakMap,V=new WeakMap,re=new WeakMap,F=new WeakMap,N=new WeakMap,T=new WeakMap,W=new WeakMap,k=new WeakMap,H=new WeakMap,G=new WeakMap,ie=new WeakMap,z=new WeakMap,ne=new WeakMap,se=new WeakMap,$=new WeakMap,q=new WeakMap,ae=new WeakMap,Se=new WeakMap,B=new WeakMap,Ie=new WeakMap,p=new WeakSet,qe=function(){let e=new Fe(r(this,J)),t=new Fe(r(this,J));g(this,$,e),g(this,se,t);let i=this.ttlAutopurge?new Array(r(this,J)):void 0;g(this,q,i),g(this,De,(l,u,S=r(this,te).now())=>{t[l]=u!==0?S:0,e[l]=u,n(l,u);}),g(this,ye,l=>{t[l]=e[l]!==0?r(this,te).now():0,n(l,e[l]);});let n=this.ttlAutopurge?(l,u)=>{if(i?.[l]&&(clearTimeout(i[l]),i[l]=void 0),u&&u!==0&&i){let S=setTimeout(()=>{r(this,X).call(this,l)&&f(this,p,me).call(this,r(this,N)[l],"expire");},u+1);S.unref&&S.unref(),i[l]=S;}}:()=>{};g(this,pe,(l,u)=>{if(e[u]){let S=e[u],c=t[u];if(!S||!c)return;l.ttl=S,l.start=c,l.now=s||a();let _=l.now-c;l.remainingTTL=S-_;}});let s=0,a=()=>{let l=r(this,te).now();if(this.ttlResolution>0){s=l;let u=setTimeout(()=>s=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=r(this,F).get(l);if(u===void 0)return 0;let S=e[u],c=t[u];if(!S||!c)return 1/0;let _=(s||a())-c;return S-_},g(this,X,l=>{let u=t[l],S=e[l];return !!S&&!!u&&(s||a())-u>S});},ye=new WeakMap,pe=new WeakMap,De=new WeakMap,X=new WeakMap,ut=function(){let e=new Fe(r(this,J));g(this,re,0),g(this,ne,e),g(this,Le,t=>{g(this,re,r(this,re)-e[t]),e[t]=0;}),g(this,Pe,(t,i,n,s)=>{if(f(this,p,M).call(this,i))return 0;if(!de(n))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(n=s(i,t),!de(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return n}),g(this,Oe,(t,i,n)=>{if(e[t]=i,r(this,j)){let s=r(this,j)-e[t];for(;r(this,re)>s;)f(this,p,Ve).call(this,true);}g(this,re,r(this,re)+e[t]),n&&(n.entrySize=i,n.totalCalculatedSize=r(this,re));});},Le=new WeakMap,Oe=new WeakMap,Pe=new WeakMap,fe=function*({allowStale:e=this.allowStale}={}){if(r(this,V))for(let t=r(this,G);!(!f(this,p,Xe).call(this,t)||((e||!r(this,X).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,k)[t];},be=function*({allowStale:e=this.allowStale}={}){if(r(this,V))for(let t=r(this,H);!(!f(this,p,Xe).call(this,t)||((e||!r(this,X).call(this,t))&&(yield t),t===r(this,G)));)t=r(this,W)[t];},Xe=function(e){return e!==void 0&&r(this,F).get(r(this,N)[e])===e},Ve=function(e){var s;let t=r(this,H),i=r(this,N)[t],n=r(this,T)[t];return r(this,Se)&&f(this,p,M).call(this,n)?n.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,B))&&(r(this,ae)&&((s=r(this,Z))==null||s.call(this,n,i,"evict")),r(this,B)&&r(this,z)?.push([n,i,"evict"])),r(this,Le).call(this,t),r(this,q)?.[t]&&(clearTimeout(r(this,q)[t]),r(this,q)[t]=void 0),e&&(r(this,N)[t]=void 0,r(this,T)[t]=void 0,r(this,ie).push(t)),r(this,V)===1?(g(this,H,g(this,G,0)),r(this,ie).length=0):g(this,H,r(this,W)[t]),r(this,F).delete(i),Ye(this,V)._--,t},Ge=function(e,t,i,n){let s=t===void 0?void 0:r(this,T)[t];if(f(this,p,M).call(this,s))return s;let a=new ze,{signal:l}=i;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:i,context:n},S=(A,C=false)=>{let{aborted:o}=a.signal,d=i.ignoreFetchAbort&&A!==void 0,O=i.ignoreFetchAbort||!!(i.allowStaleOnFetchAbort&&A!==void 0);if(i.status&&(o&&!C?(i.status.fetchAborted=true,i.status.fetchError=a.signal.reason,d&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),o&&!d&&!C)return _(a.signal.reason,O);let I=P,w=r(this,T)[t];return (w===P||d&&C&&w===void 0)&&(A===void 0?I.__staleWhileFetching!==void 0?r(this,T)[t]=I.__staleWhileFetching:f(this,p,me).call(this,e,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(e,A,u.options))),A},c=A=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=A),_(A,false)),_=(A,C)=>{let{aborted:o}=a.signal,d=o&&i.allowStaleOnFetchAbort,O=d||i.allowStaleOnFetchRejection,I=O||i.noDeleteOnFetchRejection,w=P;if(r(this,T)[t]===P&&(!I||!C&&w.__staleWhileFetching===void 0?f(this,p,me).call(this,e,"fetch"):d||(r(this,T)[t]=w.__staleWhileFetching)),O)return i.status&&w.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw A},D=(A,C)=>{var d;let o=(d=r(this,Ee))==null?void 0:d.call(this,e,s,u);o&&o instanceof Promise&&o.then(O=>A(O===void 0?void 0:O),C),a.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(A(void 0),i.allowStaleOnFetchAbort&&(A=O=>S(O,true)));});};i.status&&(i.status.fetchDispatched=true);let P=new Promise(D).then(S,c),U=Object.assign(P,{__abortController:a,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,U,{...u.options,status:void 0}),t=r(this,F).get(e)):r(this,T)[t]=U,U},M=function(e){if(!r(this,Se))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof ze},Je=function(e,t){r(this,k)[t]=e,r(this,W)[e]=t;},Ne=function(e){e!==r(this,G)&&(e===r(this,H)?g(this,H,r(this,W)[e]):f(this,p,Je).call(this,r(this,k)[e],r(this,W)[e]),f(this,p,Je).call(this,r(this,G),e),g(this,G,e));},me=function(e,t){var n,s;let i=false;if(r(this,V)!==0){let a=r(this,F).get(e);if(a!==void 0)if(r(this,q)?.[a]&&(clearTimeout(r(this,q)?.[a]),r(this,q)[a]=void 0),i=true,r(this,V)===1)f(this,p,Qe).call(this,t);else {r(this,Le).call(this,a);let l=r(this,T)[a];if(f(this,p,M).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,B))&&(r(this,ae)&&((n=r(this,Z))==null||n.call(this,l,e,t)),r(this,B)&&r(this,z)?.push([l,e,t])),r(this,F).delete(e),r(this,N)[a]=void 0,r(this,T)[a]=void 0,a===r(this,G))g(this,G,r(this,k)[a]);else if(a===r(this,H))g(this,H,r(this,W)[a]);else {let u=r(this,k)[a];r(this,W)[u]=r(this,W)[a];let S=r(this,W)[a];r(this,k)[S]=r(this,k)[a];}Ye(this,V)._--,r(this,ie).push(a);}}if(r(this,B)&&r(this,z)?.length){let a=r(this,z),l;for(;l=a?.shift();)(s=r(this,ee))==null||s.call(this,...l);}return i},Qe=function(e){var t,i;for(let n of f(this,p,be).call(this,{allowStale:true})){let s=r(this,T)[n];if(f(this,p,M).call(this,s))s.__abortController.abort(new Error("deleted"));else {let a=r(this,N)[n];r(this,ae)&&((t=r(this,Z))==null||t.call(this,s,a,e)),r(this,B)&&r(this,z)?.push([s,a,e]);}}if(r(this,F).clear(),r(this,T).fill(void 0),r(this,N).fill(void 0),r(this,$)&&r(this,se)){r(this,$).fill(0),r(this,se).fill(0);for(let n of r(this,q)??[])n!==void 0&&clearTimeout(n);r(this,q)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),g(this,H,0),g(this,G,0),r(this,ie).length=0,g(this,re,0),g(this,V,0),r(this,B)&&r(this,z)){let n=r(this,z),s;for(;s=n?.shift();)(i=r(this,ee))==null||i.call(this,...s);}},Re);var we=class{constructor(e){E(this,"cache");E(this,"map",new Map);this.cache=new ht({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var ve=new we({cacheSize:10}),Ze;(s=>{function h(a){let l=ve.get(a);if(!l){L.error(`Label "${a}" not found`);return}return l}s.get=h;function e(a){if(Array.isArray(a)){a.forEach(l=>e(l));return}ve.has(a.id)&&L.info(`Label "${a.id}" already exists, it will be overwritten`),ve.set(a.id,a);}s.add=e;function t(){return Array.from(ve.values())}s.values=t;function i(a){return ve.has(a)}s.has=i;function n(){return Array.from(ve.keys())}s.keys=n;})(Ze||(Ze={}));var oe=Ze;var m=class m{constructor(){}static get allOpenedLabels(){return core.GameUnifier.getVariable(v,R.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(v,R.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=m.currentLabelStepIndex;if(t===null)return L.error("currentLabelStepIndex is null"),null;let i=`${t}${e}`,n=m.currentLabelId,s=m._currentLabel;if(!n||t===null||!s)return L.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let a=s.getStepSha(t)||"error",l=core.GameUnifier.getVariable(v,R.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return l[n]||(l[n]={}),(!l[n][i]||l[n][i].stepSha1!=a)&&(l[n][i]={stepSha1:a}),l[n][i]}static setCurrentStepTimesCounterData(e="",t){let i=m.currentLabelStepIndex,n=i+e,s=m.currentLabelId;if(!s||i===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(v,R.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[s]||(a[s]={}),a[s][n]=t,core.GameUnifier.setVariable(v,R.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static getCurrentStepTimesCounter(e=""){let t=m._stepCounter,i=m.getCurrentStepTimesCounterData(e);if(!i)return L.error("getCurrentStepTimesCounter obj is null"),0;let n=i.stepCounters||[];return n.find(a=>a===t)||(n.push(t),i.stepCounters=n,m.setCurrentStepTimesCounterData(e,i)),n.length}static getRandomNumber(e,t,i={}){let n=i.nestedId||"";if(i.onceOnly||false){let a=m.getCurrentStepTimesCounterData(n);if(!a)return;let l=a.usedRandomNumbers||{},u=Array.from({length:t-e+1},(_,D)=>D+e).filter(_=>!l[`${e}-${t}`]?.includes(_));if(u.length===0)return;let S=Math.floor(Math.random()*u.length),c=u[S];return l[`${e}-${t}`]||(l[`${e}-${t}`]=[]),l[`${e}-${t}`].push(c),a.usedRandomNumbers=l,m.setCurrentStepTimesCounterData(n,a),c}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=m.currentLabelStepIndex,i=t+e,n=m.currentLabelId;if(!n||t===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let s=core.GameUnifier.getVariable(v,R.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[n]||(s[n]={}),s[n][i]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(v,R.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static get allChoicesMade(){return core.GameUnifier.getVariable(v,R.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(v,R.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){m._stepCounter++;}static get openedLabels(){return he(m._openedLabels)}static set openedLabels(e){m._openedLabels=he(e);}static get originalOpenedLabels(){return he(m._originalOpenedLabels)}static set originalOpenedLabels(e){m._originalOpenedLabels=he(e);}static get _currentLabel(){if(m.currentLabelId)return oe.get(m.currentLabelId)}static get currentLabelId(){if(m._openedLabels.length>0)return m._openedLabels[m._openedLabels.length-1].label}static get currentLabelStepIndex(){return m._openedLabels.length>0?m._openedLabels[m._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let i=m.allOpenedLabels,n=m.allOpenedLabels[e]?.biggestStep||0,s=m.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(i[e]={biggestStep:t,openCount:s},m.allOpenedLabels=i);}static addChoicesMade(e,t,i,n){let s=m.allChoicesMade,a=s.findIndex(l=>l.labelId===e&&l.stepIndex===t&&l.choiceIndex===n&&l.stepSha1===i);a<0?s.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:i,madeTimes:1}):s[a].madeTimes++,m.allChoicesMade=s;}static pushNewLabel(e){if(!oe.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);m._openedLabels.push({label:e,currentStepIndex:0});let i=m.allOpenedLabels,n=m.allOpenedLabels[e]?.biggestStep||0,s=m.allOpenedLabels[e]?.openCount||0;i[e]={biggestStep:n,openCount:s+1},m.allOpenedLabels=i;}static increaseCurrentStepIndex(){if(m._openedLabels.length>0){let e=m._openedLabels[m._openedLabels.length-1];m._openedLabels[m._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){m._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let i=[];return m.onLoadingLabel&&e===0&&i.push(m.onLoadingLabel(e,t)),m._onStepStart&&i.push(m._onStepStart(e,t)),await Promise.all(i)}}};E(m,"choiceMadeTemp"),E(m,"lastHistoryStep",null),E(m,"_stepCounter",0),E(m,"_openedLabels",[]),E(m,"_originalOpenedLabels",[]),E(m,"_onStepStart"),E(m,"onLoadingLabel"),E(m,"onStepEnd");var b=m;var Ue=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,i={}){return b.getRandomNumber(e,t,i)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:i,ignoreSameStep:n}=t,s,a,l,u=core.GameUnifier.getVariable(v,R.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(v,R.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=core.GameUnifier.getVariable(v,R.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(v,R.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(v,R.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(v,R.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l=core.GameUnifier.getVariable(v,R.CURRENT_INPUT_VALUE_MEMORY_KEY));let S=b.openedLabels,c={currentLabel:b.currentLabelId,dialogue:s,choices:a,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:i,inputValue:l,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:u,openedLabels:S};b.originalOpenedLabels=S,core.GameUnifier.addHistoryItem(c,{ignoreSameStep:n}),b.lastHistoryStep=c,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){L.warn("No label to close");return}if(!this.currentLabel){L.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=b.allOpenedLabels[t]?.biggestStep||0;if(n){let s=oe.get(t);if(s)return s.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let i=t.getStepSha(e);return i||(L.warn("stepSha not found, setting to ERROR"),i="error"),b.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===i)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,i=this.choices;return i&&i.length>0?(t&&L.warn("The player must make a choice"),false):this.isRequiredInput?(t&&L.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let i=[];return e.onStepStart&&i.push(e.onStepStart(t,e)),b.onStepStart&&i.push(b.onStepStart(t,e)),await Promise.all(i)}async onStepEnd(e,t){let i=[];return e.onStepEnd&&i.push(e.onStepEnd(t,e)),b.onStepEnd&&i.push(b.onStepEnd(t,e)),await Promise.all(i)}async continue(e,t={}){let{runNow:i=false,steps:n=1}=t;if(!Number.isFinite(n)){L.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){L.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!i&&!this.getCanContinue({showWarn:true}))return;if(!i&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(n);return}n>1&&core.GameUnifier.increaseContinueRequest(n-1),core.GameUnifier.runningStepsCount++;let s;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),s=await this.runCurrentStep(e,t);}catch(a){throw L.error("Error continuing",a),a}finally{core.GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep(e)||s;}return s}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});L.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:i}=t;if(b.currentLabelId){let n=b.currentLabelStepIndex;if(n===null){L.error("currentLabelStepIndex is null");return}let s=b._currentLabel;if(!s){L.error("currentLabel not found");return}if(s.stepCount>n){try{await this.onStepStart(s,n);}catch(c){L.error("Error running onStepStart",c),this.onStepError&&await this.onStepError(c,e);return}let a=s.getStepById(n);if(!a){L.error("step not found");return}let l=s.getStepSha(n);l||(L.warn("stepSha not found, setting to ERROR"),l="error");let u,S;try{u=await a(e,{labelId:s.id});}catch(c){L.error("Error running step",c),S=c;}try{let c=this.choices;if(c?.length===1&&c[0].autoSelect){let _=c[0];u=await this.selectChoice(_,e);}}catch(c){L.error("Error auto-selecting choice",c),S===void 0&&(S=c);}try{let c=b.lastHistoryStep;i!==void 0&&c&&(l=c.stepSha1,l||(L.warn("stepSha not found, setting to ERROR"),l="error"),b.addChoicesMade(c.currentLabel||"error",typeof c.labelStepIndex=="number"?c.labelStepIndex:-1,c.stepSha1||"error",i),b.choiceMadeTemp=i);}catch(c){L.warn("Error adding choice made to history",c);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(s.id,n),this.addStepHistory(l,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(c){L.warn("Error adding step to history",c);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(c){L.warn("Error running onStepEnd",c);}return S&&this.onStepError&&await this.onStepError(S,e),u}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){b.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;L.error("currentLabelId not found");}}async call(e,t,i){let{choiceMade:n}=i||{},s;typeof e=="string"?s=e:s=e.id,core.GameUnifier.runningStepsCount++;let a;try{let l=oe.get(s);if(!l)throw new core.PixiError("unregistered_element",`Label ${s} not found`);b.pushNewLabel(l.id),a=await this.runCurrentStep(t,{choiceMade:n});}catch(l){throw L.error("Error calling label",l),l}finally{core.GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep(t)||a;}return a}async jump(e,t,i){if(this.stepCounter===0)return await this.call(e,t,i);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=i||{},s;typeof e=="string"?s=e:s=e.id,core.GameUnifier.runningStepsCount++;let a;try{let l=oe.get(s);if(!l)throw new core.PixiError("unregistered_element",`Label ${s} not found`);b.pushNewLabel(l.id),a=await this.runCurrentStep(t,{choiceMade:n});}catch(l){throw L.error("Error jumping to label",l),l}finally{core.GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep(t)||a;}return a}async selectChoice(e,t){this.choices=void 0;let i=e.type;switch(i){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw L.error(`Type ${i} not found`),new core.PixiError("invalid_usage",`Type ${i} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw L.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let i;return typeof e.choiceIndex=="number"&&(i=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:i})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(i){L.error("Error in onError handler",i);}}}get dialogue(){let e=core.GameUnifier.getVariable(v,R.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(v,R.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(v,R.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let i=[];Array.isArray(t.text)?i=[...t.text]:i=[t.text],Array.isArray(e.text)?i=[...i,...e.text]:i=[...i,e.text],e.text=i,e.character=e.character||t.character;}core.GameUnifier.setVariable(v,R.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(v,R.CURRENT_DIALOGUE_MEMORY_KEY,he({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(v,R.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=core.GameUnifier.getVariable(v,R.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],i=e.map((s,a)=>({...s,choiceIndex:a})),n=this.alreadyCurrentStepMadeChoices;if(i=i.filter((s,a)=>s.oneTime&&n&&n.includes(a)?false:s.onlyHaveNoChoice?(t.push(s),false):true),i.length>0)return i;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){core.GameUnifier.setVariable(v,R.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(v,R.CURRENT_MENU_OPTIONS_MEMORY_KEY,he(e)),core.GameUnifier.setVariable(v,R.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return core.GameUnifier.getFlag(R.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(R.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(v,R.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(v,R.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(v,R.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(v,R.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(v,R.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,core.GameUnifier.setVariable(v,R.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(v,R.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(v,R.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(v,R.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(v,R.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:he(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async i=>{let n=[],s=oe.get(i.label);return s&&(s.onLoadingLabel&&n.push(s.onLoadingLabel(e,s)),b.onLoadingLabel&&n.push(b.onLoadingLabel(e,s))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,e.hasOwnProperty("openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):L.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?b._stepCounter=e.stepCounter:L.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(i){L.error("Error running onLoadingLabel",i);}}catch(i){L.error("Error importing data",i);}}};function At(h,e,t,i){let n=typeof e=="string"?e:e.id;return {...i,label:n,props:t,text:h,type:i?.type||"call"}}var et="close";function Mt(h,e){return {...e,type:et,text:h}}var bt=Ct(ft());var Ae=class{constructor(e,t){E(this,"id");E(this,"_onStepStart");E(this,"_onLoadingLabel");E(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var Me=class extends Ae{constructor(t,i,n){super(t,n);E(this,"_steps");this._steps=i;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return L.warn("stepSha not found, setting to ERROR"),"error";try{let i=this.steps[t];return (0,bt.default)(i.toString().toLocaleLowerCase()).toString()}catch(i){return L.warn("stepSha not found, setting to ERROR",i),"error"}}};function mt(h,e,t){let i=new Me(h,e,t);return oe.add(i),i}var Nr=new Ue;
|
|
2
|
-
exports.Close=et;exports.Label=Me;exports.LabelAbstract=Ae;exports.NarrationManagerStatic=b;exports.RegisteredLabels=oe;exports.narration=Nr;exports.newChoiceOption=At;exports.newCloseChoiceOption=Mt;exports.newLabel=mt
|
|
3
|
-
//# sourceMappingURL=narration.cjs.map
|
|
2
|
+
exports.Close=et;exports.Label=Me;exports.LabelAbstract=Ae;exports.NarrationManagerStatic=b;exports.RegisteredLabels=oe;exports.narration=Nr;exports.newChoiceOption=At;exports.newCloseChoiceOption=Mt;exports.newLabel=mt;
|
package/dist/narration.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-2ZJFDDPE.mjs';import'./chunk-52EK6LYW.mjs';import {a}from'./chunk-EC6URLQW.mjs';import {l,n}from'./chunk-UIXKMF72.mjs';import {d,c,j,k}from'./chunk-FIGGUFAM.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var C=new a({cacheSize:10}),O;(a=>{function h(l){let u=C.get(l);if(!u){j.error(`Label "${l}" not found`);return}return u}a.get=h;function e(l){if(Array.isArray(l)){l.forEach(u=>e(u));return}C.has(l.id)&&j.info(`Label "${l.id}" already exists, it will be overwritten`),C.set(l.id,l);}a.add=e;function t(){return Array.from(C.values())}a.values=t;function r(l){return C.has(l)}a.has=r;function n(){return Array.from(C.keys())}a.keys=n;})(O||(O={}));var L=O;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return j.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return j.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let l$1=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!=l$1)&&(u[n$1][r]={stepSha1:l$1}),u[n$1][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n$1=r+e,a=i.currentLabelId;if(!a||r===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let l$1=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};l$1[a]||(l$1[a]={}),l$1[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,l$1);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return j.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(l=>l===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let l=i.getCurrentStepTimesCounterData(n);if(!l)return;let u=l.usedRandomNumbers||{},S=Array.from({length:t-e+1},(R,A)=>A+e).filter(R=>!u[`${e}-${t}`]?.includes(R));if(S.length===0)return;let m=Math.floor(Math.random()*S.length),b=S[m];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),l.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,l),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n$1=i.currentLabelId;if(!n$1||t===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return k(i._openedLabels)}static set openedLabels(e){i._openedLabels=k(e);}static get originalOpenedLabels(){return k(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=k(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,l=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);l<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[l].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;var _=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,l$1,u,S=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l$1=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let m=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:l$1,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:m};o.originalOpenedLabels=m,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){j.warn("No label to close");return}if(!this.currentLabel){j.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(j.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&j.warn("The player must make a choice"),false):this.isRequiredInput?(t&&j.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){j.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){j.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(l){throw j.error("Error continuing",l),l}finally{GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep(e)||a;}return a}async afterRunCurrentStep(e){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});j.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){j.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){j.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){j.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e);return}let l=a.getStepById(n);if(!l){j.error("step not found");return}let u=a.getStepSha(n);u||(j.warn("stepSha not found, setting to ERROR"),u="error");let S,m;try{S=await l(e,{labelId:a.id});}catch(b){j.error("Error running step",b),m=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let R=b[0];S=await this.selectChoice(R,e);}}catch(b){j.error("Error auto-selecting choice",b),m===void 0&&(m=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(j.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){j.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){j.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){j.warn("Error running onStepEnd",b);}return m&&this.onStepError&&await this.onStepError(m,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;j.error("currentLabelId not found");}}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let l;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),l=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error calling label",u),u}finally{GameUnifier.runningStepsCount--,l=await this.afterRunCurrentStep(t)||l;}return l}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let l;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),l=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error jumping to label",u),u}finally{GameUnifier.runningStepsCount--,l=await this.afterRunCurrentStep(t)||l;}return l}async selectChoice(e,t){this.choices=void 0;let r=e.type;switch(r){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw j.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw j.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e.choiceIndex=="number"&&(r=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e,t)=>{try{await GameUnifier.runOnError(e,t);}catch(r){j.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,e.character=e.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,k({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw j.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,l)=>({...a,choiceIndex:l})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,l)=>a.oneTime&&n&&n.includes(l)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,k(e)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw j.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:k(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,e.hasOwnProperty("openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):j.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?o._stepCounter=e.stepCounter:j.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){j.error("Error running onLoadingLabel",r);}}catch(r){j.error("Error importing data",r);}}};function Y(h,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:h,type:r?.type||"call"}}var M="close";function V(h,e){return {...e,type:M,text:h}}var N=c(a$1(),1);var I=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var E=class extends I{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return j.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,N.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return j.warn("stepSha not found, setting to ERROR",r),"error"}}};function w(h,e,t){let r=new E(h,e,t);return L.add(r),r}var Te=new _;
|
|
2
|
-
export{M as Close,E as Label,I as LabelAbstract,o as NarrationManagerStatic,L as RegisteredLabels,Te as narration,Y as newChoiceOption,V as newCloseChoiceOption,w as newLabel}
|
|
3
|
-
//# sourceMappingURL=narration.mjs.map
|
|
1
|
+
import {a as a$1}from'./chunk-L4IHQ3VT.mjs';import'./chunk-XSN6P5JL.mjs';import {a}from'./chunk-ZW3MIPMS.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {d,c,j,k}from'./chunk-D45QSSXG.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var C=new a({cacheSize:10}),O;(a=>{function h(l){let u=C.get(l);if(!u){j.error(`Label "${l}" not found`);return}return u}a.get=h;function e(l){if(Array.isArray(l)){l.forEach(u=>e(u));return}C.has(l.id)&&j.info(`Label "${l.id}" already exists, it will be overwritten`),C.set(l.id,l);}a.add=e;function t(){return Array.from(C.values())}a.values=t;function r(l){return C.has(l)}a.has=r;function n(){return Array.from(C.keys())}a.keys=n;})(O||(O={}));var L=O;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return j.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return j.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let l$1=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!=l$1)&&(u[n$1][r]={stepSha1:l$1}),u[n$1][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n$1=r+e,a=i.currentLabelId;if(!a||r===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let l$1=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};l$1[a]||(l$1[a]={}),l$1[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,l$1);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return j.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(l=>l===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let l=i.getCurrentStepTimesCounterData(n);if(!l)return;let u=l.usedRandomNumbers||{},S=Array.from({length:t-e+1},(R,A)=>A+e).filter(R=>!u[`${e}-${t}`]?.includes(R));if(S.length===0)return;let m=Math.floor(Math.random()*S.length),b=S[m];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),l.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,l),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n$1=i.currentLabelId;if(!n$1||t===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return k(i._openedLabels)}static set openedLabels(e){i._openedLabels=k(e);}static get originalOpenedLabels(){return k(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=k(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,l=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);l<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[l].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;var _=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,l$1,u,S=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l$1=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let m=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:l$1,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:m};o.originalOpenedLabels=m,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){j.warn("No label to close");return}if(!this.currentLabel){j.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(j.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&j.warn("The player must make a choice"),false):this.isRequiredInput?(t&&j.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){j.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){j.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(l){throw j.error("Error continuing",l),l}finally{GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep(e)||a;}return a}async afterRunCurrentStep(e){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});j.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){j.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){j.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){j.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e);return}let l=a.getStepById(n);if(!l){j.error("step not found");return}let u=a.getStepSha(n);u||(j.warn("stepSha not found, setting to ERROR"),u="error");let S,m;try{S=await l(e,{labelId:a.id});}catch(b){j.error("Error running step",b),m=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let R=b[0];S=await this.selectChoice(R,e);}}catch(b){j.error("Error auto-selecting choice",b),m===void 0&&(m=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(j.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){j.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){j.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){j.warn("Error running onStepEnd",b);}return m&&this.onStepError&&await this.onStepError(m,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;j.error("currentLabelId not found");}}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let l;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),l=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error calling label",u),u}finally{GameUnifier.runningStepsCount--,l=await this.afterRunCurrentStep(t)||l;}return l}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let l;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),l=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error jumping to label",u),u}finally{GameUnifier.runningStepsCount--,l=await this.afterRunCurrentStep(t)||l;}return l}async selectChoice(e,t){this.choices=void 0;let r=e.type;switch(r){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw j.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw j.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e.choiceIndex=="number"&&(r=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e,t)=>{try{await GameUnifier.runOnError(e,t);}catch(r){j.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,e.character=e.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,k({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw j.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,l)=>({...a,choiceIndex:l})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,l)=>a.oneTime&&n&&n.includes(l)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,k(e)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw j.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:k(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,e.hasOwnProperty("openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):j.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?o._stepCounter=e.stepCounter:j.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){j.error("Error running onLoadingLabel",r);}}catch(r){j.error("Error importing data",r);}}};function Y(h,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:h,type:r?.type||"call"}}var M="close";function V(h,e){return {...e,type:M,text:h}}var N=c(a$1(),1);var I=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var E=class extends I{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return j.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,N.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return j.warn("stepSha not found, setting to ERROR",r),"error"}}};function w(h,e,t){let r=new E(h,e,t);return L.add(r),r}var Te=new _;
|
|
2
|
+
export{M as Close,E as Label,I as LabelAbstract,o as NarrationManagerStatic,L as RegisteredLabels,Te as narration,Y as newChoiceOption,V as newCloseChoiceOption,w as newLabel};
|
package/dist/sound.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core'),h=require('@drincs/pixi-vn/pixi.js'),sound=require('@pixi/sound');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var h__default=/*#__PURE__*/_interopDefault(h);var O=Object.defineProperty;var P=(o,t,e)=>t in o?O(o,t,{enumerable:true,configurable:true,writable:true,value:e}):o[t]=e;var m=(o,t,e)=>P(o,typeof t!="symbol"?t+"":t,e);var C="general";var c;(s=>(s.log=(a,...r)=>console.log(`[Pixi\u2019VN] ${a}`,...r),s.warn=(a,...r)=>console.warn(`[Pixi\u2019VN] ${a}`,...r),s.error=(a,...r)=>console.error(`[Pixi\u2019VN] ${a}`,...r),s.info=(a,...r)=>console.info(`[Pixi\u2019VN] ${a}`,...r)))(c||(c={}));function S(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")}}function E(o,t){return o===void 0&&t===void 0?1:t===void 0?o:o===void 0?t:o*t}var i=class{constructor(){}};m(i,"mediaInstances",{}),m(i,"channels",{}),m(i,"delayTimeoutInstances",[]);function M(o,t,e){return new Proxy(t,{get(n,s,a){switch(s){case "volume":case "muted":{let r=i.mediaInstances[o];return r?r.options[s]:Reflect.get(n,s,a)}default:return Reflect.get(n,s,a)}},set(n,s,a,r){if(o in i.mediaInstances)switch(s){case "volume":return i.mediaInstances[o].options[s]=a,a=E(a,e.channelOptions.volume),Reflect.set(n,s,a,r);case "muted":return i.mediaInstances[o].options[s]=a,e.channelOptions.muted?Reflect.set(n,s,true,r):Reflect.set(n,s,a,r);case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":i.mediaInstances[o].options[s]=a;default:return Reflect.set(n,s,a,r)}return Reflect.set(n,s,a,r)}})}var y=class{constructor(t,e={}){this.alias=t;this.channelOptions=e;}async play(t,e,n){let s,a;if(typeof e=="string"?(s=t,a=e):(s=t,a=t,n=e),s in i.mediaInstances){let l=i.mediaInstances[s];l.instance.stop(),n={...l.options,...n};}let r=M(s,await sound.sound.play(a,{...n??{},filters:[...this.channelOptions.filters||[],...n?.filters||[]],muted:!!this.channelOptions.muted||!!n?.muted,volume:E(n?.volume,this.channelOptions.volume)}),this);if(n?.delay){r.paused=true;let l=setTimeout(()=>{r.paused=false,i.delayTimeoutInstances=i.delayTimeoutInstances.filter(I=>I[0]!==l);},n.delay*1e3);i.delayTimeoutInstances.push([l,s]);}return i.mediaInstances[s]={channelAlias:this.alias,soundAlias:a,instance:r,stepCounter:core.GameUnifier.stepCounter,options:{volume:n?.volume??1,muted:n?.muted??false,loop:n?.loop??false,...n??{}}},r.on("end",()=>{delete i.mediaInstances[s];}),r}updateMediaVolume(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.volume??1;e.instance.volume=n;}}}get volume(){return this.channelOptions.volume??1}set volume(t){this.channelOptions.volume=t,this.updateMediaVolume();}updateMediaMuted(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.muted??false;e.instance.muted=n;}}}get muted(){return this.channelOptions.muted??false}set muted(t){this.channelOptions.muted=t,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Object.values(i.mediaInstances).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e.instance),t),[])}get background(){return this.channelOptions.background||false}stopAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.channelAlias===this.alias&&(e.instance.stop(),delete i.mediaInstances[t]);}return this}pauseAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);}return this}resumeAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);}return this}};function A(o){let t=[];for(let e of o)e.type==="TelephoneFilter"?t.push(new sound.filters.TelephoneFilter):e.type==="StreamFilter"?t.push(new sound.filters.StreamFilter):e.type==="StereoFilter"?t.push(new sound.filters.StereoFilter(e.pan)):e.type==="ReverbFilter"?t.push(new sound.filters.ReverbFilter(e.seconds,e.decay,e.reverse)):e.type==="MonoFilter"?t.push(new sound.filters.MonoFilter):e.type==="EqualizerFilter"?t.push(new sound.filters.EqualizerFilter(e.f32,e.f64,e.f125,e.f250,e.f500,e.f1k,e.f2k,e.f4k,e.f8k,e.f16k)):e.type==="DistortionFilter"?t.push(new sound.filters.DistortionFilter(e.amount)):c.error("Unknown sound filter type");return t}function _(o){if(!o)return;let t=[];for(let e of o)e instanceof sound.filters.TelephoneFilter?t.push({type:"TelephoneFilter"}):e instanceof sound.filters.StreamFilter?t.push({type:"StreamFilter"}):e instanceof sound.filters.StereoFilter?t.push({type:"StereoFilter",pan:e.pan}):e instanceof sound.filters.ReverbFilter?t.push({type:"ReverbFilter",seconds:e.seconds,decay:e.decay,reverse:e.reverse}):e instanceof sound.filters.MonoFilter?t.push({type:"MonoFilter"}):e instanceof sound.filters.EqualizerFilter?t.push({type:"EqualizerFilter",f32:e.f32,f64:e.f64,f125:e.f125,f250:e.f250,f500:e.f500,f1k:e.f1k,f2k:e.f2k,f4k:e.f4k,f8k:e.f8k,f16k:e.f16k}):e instanceof sound.filters.DistortionFilter?t.push({type:"DistortionFilter",amount:e.amount}):c.error("Unknown sound filter type");return t}var g=class{constructor(){m(this,"_defaultChannelAlias",C);}get context(){return sound.sound.context}get filtersAll(){return sound.sound.filtersAll}set filtersAll(t){sound.sound.filtersAll=t.filter(e=>!(e instanceof sound.filters.Filter));}get supported(){return sound.sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){return sound.sound.add(t,e)}async edit(t,e){let n=sound.sound.find(t);if(!n&&(await this.load(t),n=sound.sound.find(t),!n)){c.error(`Sound with alias ${t} not found after loading.`);return}n.options=e;}get useLegacy(){return sound.sound.useLegacy}set useLegacy(t){sound.sound.useLegacy=t;}get disableAutoPause(){return sound.sound.disableAutoPause}set disableAutoPause(t){sound.sound.disableAutoPause=t;}get volumeAll(){return sound.sound.volumeAll}set volumeAll(t){sound.sound.volumeAll=t;}get speedAll(){return sound.sound.speedAll}set speedAll(t){sound.sound.speedAll=t;}pauseAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.instance.paused||(e.instance.paused=true);}return this}resumeAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.instance.paused&&(e.instance.paused=false);}return this}toggleMuteAll(){return sound.sound.toggleMuteAll()}muteAll(){return sound.sound.muteAll(),this}unmuteAll(){return sound.sound.unmuteAll(),this}stopAll(){return i.mediaInstances={},sound.sound.stopAll(),this}isPlaying(){return sound.sound.isPlaying()}async play(t,e,n){let s,a;typeof e=="string"?(s=t,a=e):(s=t,a=t,n=e);let{channel:r=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(r).play(s,a,l)}find(t){return i.mediaInstances[t]?.instance}stop(t){let e=this.find(t);e?(e.stop(),delete i.mediaInstances[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 sound.sound.duration(t)}async load(t){await h__default.default.Assets.load(t),typeof t=="string"&&(t=[t]),t.forEach(e=>{let n=h__default.default.Assets.get(e);sound.sound.exists(e)||sound.sound.add(e,n);});}backgroundLoad(t){let e=h__default.default.Assets.backgroundLoad(t);return e.then(()=>{typeof t=="string"&&(t=[t]),t.forEach(n=>{let s=h__default.default.Assets.get(n);sound.sound.exists(n)||sound.sound.add(n,s);});}),e}backgroundLoadBundle(t){let e=h__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await h__default.default.Assets.loadBundle(t);for(let s in n){let a=n[s];a instanceof sound.Sound&&(sound.sound.exists(s)||sound.sound.add(s,a));}}catch(n){c.error("Error loading sound bundle",n);}}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let a={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,a);});return}if(i.channels[t]){c.warn(`Channel with alias ${t} already exists.`);return}let n=new y(t,e);return i.channels[t]=n,n}findChannel(t){let e=i.channels[t];return e||this.addChannel(t)}get channels(){return Object.values(i.channels)}export(){let t=Object.entries(i.mediaInstances).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,options:{...s.options,filters:_(s.options.filters)},paused:s.instance.paused},e),{});return {mediaInstances:S(t),filters:S(_(this.filtersAll))}}async restore(t){try{if(t.hasOwnProperty("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(t.hasOwnProperty("mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:r,channelAlias:l})=>(n.add(l),await this.load(r)));await Promise.all(s),this.channels.forEach(r=>{(!r.background||!n.has(r.alias))&&r.stopAll();});let a=Object.keys(e).map(async r=>{let l=e[r],I=this.findChannel(l.channelAlias);if(I.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(r)){let d=await I.play(r,l.soundAlias,{...l.options,filters:A(l.options.filters||[])});l.paused&&(d.paused=l.paused);}else {let d=this.find(r);d&&(i.mediaInstances[r].options={...l.options,filters:A(l.options.filters||[])},d.paused!==l.paused&&(d.paused=l.paused),d.loop!==(l.options.loop||!1)&&(d.loop=l.options.loop||!1),d.volume!==(l.options.volume??1)&&(d.volume=l.options.volume??1),d.muted!==(l.options.muted||!1)&&(d.muted=l.options.muted||!1),d.speed!==(l.options.speed??1)&&(d.speed=l.options.speed??1));}else {let d=await I.play(r,l.soundAlias,{...l.options,filters:A(l.options.filters||[])});l.paused&&(d.paused=l.paused);}});await Promise.all(a);}}if(t.hasOwnProperty("filters")){let e=t.filters;e&&(this.filtersAll=A(e));}}catch(e){c.error("Error importing data",e);}}};var w={DistortionFilter:sound.filters.DistortionFilter,EqualizerFilter:sound.filters.EqualizerFilter,MonoFilter:sound.filters.MonoFilter,ReverbFilter:sound.filters.ReverbFilter,StereoFilter:sound.filters.StereoFilter,StreamFilter:sound.filters.StreamFilter,TelephoneFilter:sound.filters.TelephoneFilter};var Ce=new g;core.GameUnifier.addOnPreContinue(async()=>{try{i.delayTimeoutInstances.forEach(o=>{clearTimeout(o[0]);let t=i.mediaInstances[o[1]];t&&(t.instance.paused=!1);}),i.delayTimeoutInstances=[],Object.values(i.channels).forEach(o=>{o.background||o.stopAll();});}catch{}});exports.SoundManagerStatic=i;exports.filters=w;exports.sound=Ce;//# sourceMappingURL=sound.cjs.map
|
|
2
|
-
//# sourceMappingURL=sound.cjs.map
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core'),A=require('@drincs/pixi-vn/pixi.js'),sound=require('@pixi/sound');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var A__default=/*#__PURE__*/_interopDefault(A);var O=Object.defineProperty;var P=(r,t,e)=>t in r?O(r,t,{enumerable:true,configurable:true,writable:true,value:e}):r[t]=e;var m=(r,t,e)=>P(r,typeof t!="symbol"?t+"":t,e);var C="general";var c;(s=>(s.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),s.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),s.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),s.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(c||(c={}));function g(r){try{if(typeof r>"u")return r;let t=JSON.stringify(r);return JSON.parse(t)}catch(t){throw c.error("Error creating exportable element",r,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}function _(r,t){return r===void 0&&t===void 0?1:t===void 0?r:r===void 0?t:r*t}var i=class{constructor(){}};m(i,"mediaInstances",{}),m(i,"channels",{}),m(i,"delayTimeoutInstances",[]);function M(r,t,e){return new Proxy(t,{get(n,s,o){switch(s){case "volume":case "muted":{let a=i.mediaInstances[r];return a?a.options[s]:Reflect.get(n,s,o)}default:return Reflect.get(n,s,o)}},set(n,s,o,a){if(r in i.mediaInstances)switch(s){case "volume":return i.mediaInstances[r].options[s]=o,o=_(o,e.channelOptions.volume),Reflect.set(n,s,o,a);case "muted":return i.mediaInstances[r].options[s]=o,e.channelOptions.muted?Reflect.set(n,s,true,a):Reflect.set(n,s,o,a);case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":i.mediaInstances[r].options[s]=o;default:return Reflect.set(n,s,o,a)}return Reflect.set(n,s,o,a)}})}var I=class{constructor(t,e={}){this.alias=t;this.channelOptions=e;}alias;channelOptions;async play(t,e,n){let s,o;if(typeof e=="string"?(s=t,o=e):(s=t,o=t,n=e),s in i.mediaInstances){let l=i.mediaInstances[s];l.instance.stop(),n={...l.options,...n};}let a=M(s,await sound.sound.play(o,{...n??{},filters:[...this.channelOptions.filters||[],...n?.filters||[]],muted:!!this.channelOptions.muted||!!n?.muted,volume:_(n?.volume,this.channelOptions.volume)}),this);if(n?.delay){a.paused=true;let l=setTimeout(()=>{a.paused=false,i.delayTimeoutInstances=i.delayTimeoutInstances.filter(h=>h[0]!==l);},n.delay*1e3);i.delayTimeoutInstances.push([l,s]);}return i.mediaInstances[s]={channelAlias:this.alias,soundAlias:o,instance:a,stepCounter:core.GameUnifier.stepCounter,options:{volume:n?.volume??1,muted:n?.muted??false,loop:n?.loop??false,...n??{}}},a.on("end",()=>{delete i.mediaInstances[s];}),a}updateMediaVolume(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.volume??1;e.instance.volume=n;}}}get volume(){return this.channelOptions.volume??1}set volume(t){this.channelOptions.volume=t,this.updateMediaVolume();}updateMediaMuted(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.muted??false;e.instance.muted=n;}}}get muted(){return this.channelOptions.muted??false}set muted(t){this.channelOptions.muted=t,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Object.values(i.mediaInstances).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e.instance),t),[])}get background(){return this.channelOptions.background||false}stopAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.channelAlias===this.alias&&(e.instance.stop(),delete i.mediaInstances[t]);}return this}pauseAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);}return this}resumeAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);}return this}};function y(r){let t=[];for(let e of r)e.type==="TelephoneFilter"?t.push(new sound.filters.TelephoneFilter):e.type==="StreamFilter"?t.push(new sound.filters.StreamFilter):e.type==="StereoFilter"?t.push(new sound.filters.StereoFilter(e.pan)):e.type==="ReverbFilter"?t.push(new sound.filters.ReverbFilter(e.seconds,e.decay,e.reverse)):e.type==="MonoFilter"?t.push(new sound.filters.MonoFilter):e.type==="EqualizerFilter"?t.push(new sound.filters.EqualizerFilter(e.f32,e.f64,e.f125,e.f250,e.f500,e.f1k,e.f2k,e.f4k,e.f8k,e.f16k)):e.type==="DistortionFilter"?t.push(new sound.filters.DistortionFilter(e.amount)):c.error("Unknown sound filter type");return t}function E(r){if(!r)return;let t=[];for(let e of r)e instanceof sound.filters.TelephoneFilter?t.push({type:"TelephoneFilter"}):e instanceof sound.filters.StreamFilter?t.push({type:"StreamFilter"}):e instanceof sound.filters.StereoFilter?t.push({type:"StereoFilter",pan:e.pan}):e instanceof sound.filters.ReverbFilter?t.push({type:"ReverbFilter",seconds:e.seconds,decay:e.decay,reverse:e.reverse}):e instanceof sound.filters.MonoFilter?t.push({type:"MonoFilter"}):e instanceof sound.filters.EqualizerFilter?t.push({type:"EqualizerFilter",f32:e.f32,f64:e.f64,f125:e.f125,f250:e.f250,f500:e.f500,f1k:e.f1k,f2k:e.f2k,f4k:e.f4k,f8k:e.f8k,f16k:e.f16k}):e instanceof sound.filters.DistortionFilter?t.push({type:"DistortionFilter",amount:e.amount}):c.error("Unknown sound filter type");return t}var S=class{constructor(){m(this,"_defaultChannelAlias",C);}get context(){return sound.sound.context}get filtersAll(){return sound.sound.filtersAll}set filtersAll(t){sound.sound.filtersAll=t.filter(e=>!(e instanceof sound.filters.Filter));}get supported(){return sound.sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){return sound.sound.add(t,e)}async edit(t,e){let n=sound.sound.find(t);if(!n&&(await this.load(t),n=sound.sound.find(t),!n)){c.error(`Sound with alias ${t} not found after loading.`);return}n.options=e;}get useLegacy(){return sound.sound.useLegacy}set useLegacy(t){sound.sound.useLegacy=t;}get disableAutoPause(){return sound.sound.disableAutoPause}set disableAutoPause(t){sound.sound.disableAutoPause=t;}get volumeAll(){return sound.sound.volumeAll}set volumeAll(t){sound.sound.volumeAll=t;}get speedAll(){return sound.sound.speedAll}set speedAll(t){sound.sound.speedAll=t;}pauseAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.instance.paused||(e.instance.paused=true);}return this}resumeAll(){for(let t in i.mediaInstances){let e=i.mediaInstances[t];e.instance.paused&&(e.instance.paused=false);}return this}toggleMuteAll(){return sound.sound.toggleMuteAll()}muteAll(){return sound.sound.muteAll(),this}unmuteAll(){return sound.sound.unmuteAll(),this}stopAll(){return i.mediaInstances={},sound.sound.stopAll(),this}isPlaying(){return sound.sound.isPlaying()}async play(t,e,n){let s,o;typeof e=="string"?(s=t,o=e):(s=t,o=t,n=e),sound.sound.exists(o)||await this.load(o);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,o,l)}find(t){return i.mediaInstances[t]?.instance}stop(t){let e=this.find(t);e?(e.stop(),delete i.mediaInstances[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 sound.sound.duration(t)}async load(t){typeof t=="string"&&(t=[t]);let e=t.map(async n=>{let s=await A__default.default.Assets.load(n);return sound.sound.exists(n)||sound.sound.add(n,s),s});return await Promise.all(e)}backgroundLoad(t){let e=A__default.default.Assets.backgroundLoad(t);return e.then(()=>{typeof t=="string"&&(t=[t]),t.forEach(n=>{let s=A__default.default.Assets.get(n);sound.sound.exists(n)||sound.sound.add(n,s);});}),e}backgroundLoadBundle(t){let e=A__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await A__default.default.Assets.loadBundle(t);for(let s in n){let o=n[s];o instanceof sound.Sound&&(sound.sound.exists(s)||sound.sound.add(s,o));}}catch(n){c.error("Error loading sound bundle",n);}}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let o={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,o);});return}if(i.channels[t]){c.warn(`Channel with alias ${t} already exists.`);return}let n=new I(t,e);return i.channels[t]=n,n}findChannel(t){let e=i.channels[t];return e||this.addChannel(t)}get channels(){return Object.values(i.channels)}export(){let t=Object.entries(i.mediaInstances).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,options:{...s.options,filters:E(s.options.filters)},paused:s.instance.paused},e),{});return {mediaInstances:g(t),filters:g(E(this.filtersAll))}}async restore(t){try{if(t.hasOwnProperty("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(t.hasOwnProperty("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 o=Object.keys(e).map(async a=>{let l=e[a],h=this.findChannel(l.channelAlias);if(h.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let d=await h.play(a,l.soundAlias,{...l.options,filters:y(l.options.filters||[])});l.paused&&(d.paused=l.paused);}else {let d=this.find(a);d&&(i.mediaInstances[a].options={...l.options,filters:y(l.options.filters||[])},d.paused!==l.paused&&(d.paused=l.paused),d.loop!==(l.options.loop||!1)&&(d.loop=l.options.loop||!1),d.volume!==(l.options.volume??1)&&(d.volume=l.options.volume??1),d.muted!==(l.options.muted||!1)&&(d.muted=l.options.muted||!1),d.speed!==(l.options.speed??1)&&(d.speed=l.options.speed??1));}else {let d=await h.play(a,l.soundAlias,{...l.options,filters:y(l.options.filters||[])});l.paused&&(d.paused=l.paused);}});await Promise.all(o);}}if(t.hasOwnProperty("filters")){let e=t.filters;e&&(this.filtersAll=y(e));}}catch(e){c.error("Error importing data",e);}}};var w={DistortionFilter:sound.filters.DistortionFilter,EqualizerFilter:sound.filters.EqualizerFilter,MonoFilter:sound.filters.MonoFilter,ReverbFilter:sound.filters.ReverbFilter,StereoFilter:sound.filters.StereoFilter,StreamFilter:sound.filters.StreamFilter,TelephoneFilter:sound.filters.TelephoneFilter};var Ce=new S;core.GameUnifier.addOnPreContinue(async()=>{try{i.delayTimeoutInstances.forEach(r=>{clearTimeout(r[0]);let t=i.mediaInstances[r[1]];t&&(t.instance.paused=!1);}),i.delayTimeoutInstances=[],Object.values(i.channels).forEach(r=>{r.background||r.stopAll();});}catch{}});exports.SoundManagerStatic=i;exports.filters=w;exports.sound=Ce;
|
package/dist/sound.d.cts
CHANGED
|
@@ -230,7 +230,7 @@ interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "a
|
|
|
230
230
|
* @return Instance for chaining.
|
|
231
231
|
*/
|
|
232
232
|
stopAll(): this;
|
|
233
|
-
load(alias: string | string[]): Promise<
|
|
233
|
+
load(alias: string | string[]): Promise<Sound[]>;
|
|
234
234
|
backgroundLoad(alias: string | string[]): Promise<void>;
|
|
235
235
|
backgroundLoadBundle(alias: string): Promise<void>;
|
|
236
236
|
clear(): void;
|
package/dist/sound.d.ts
CHANGED
|
@@ -230,7 +230,7 @@ interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "a
|
|
|
230
230
|
* @return Instance for chaining.
|
|
231
231
|
*/
|
|
232
232
|
stopAll(): this;
|
|
233
|
-
load(alias: string | string[]): Promise<
|
|
233
|
+
load(alias: string | string[]): Promise<Sound[]>;
|
|
234
234
|
backgroundLoad(alias: string | string[]): Promise<void>;
|
|
235
235
|
backgroundLoadBundle(alias: string): Promise<void>;
|
|
236
236
|
clear(): void;
|
package/dist/sound.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
2
|
-
//# sourceMappingURL=sound.mjs.map
|
|
1
|
+
import'./chunk-XSN6P5JL.mjs';import {i}from'./chunk-IWAXXFXE.mjs';import {d,j,k}from'./chunk-D45QSSXG.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import g from'@drincs/pixi-vn/pixi.js';import {filters,sound,Sound}from'@pixi/sound';function S(u,t){return u===void 0&&t===void 0?1:t===void 0?u:u===void 0?t:u*t}var s=class{constructor(){}};d(s,"mediaInstances",{}),d(s,"channels",{}),d(s,"delayTimeoutInstances",[]);function C(u,t,e){return new Proxy(t,{get(n,i,o){switch(i){case "volume":case "muted":{let r=s.mediaInstances[u];return r?r.options[i]:Reflect.get(n,i,o)}default:return Reflect.get(n,i,o)}},set(n,i,o,r){if(u in s.mediaInstances)switch(i){case "volume":return s.mediaInstances[u].options[i]=o,o=S(o,e.channelOptions.volume),Reflect.set(n,i,o,r);case "muted":return s.mediaInstances[u].options[i]=o,e.channelOptions.muted?Reflect.set(n,i,true,r):Reflect.set(n,i,o,r);case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":s.mediaInstances[u].options[i]=o;default:return Reflect.set(n,i,o,r)}return Reflect.set(n,i,o,r)}})}var y=class{constructor(t,e={}){this.alias=t;this.channelOptions=e;}alias;channelOptions;async play(t,e,n){let i,o;if(typeof e=="string"?(i=t,o=e):(i=t,o=t,n=e),i in s.mediaInstances){let a=s.mediaInstances[i];a.instance.stop(),n={...a.options,...n};}let r=C(i,await sound.play(o,{...n??{},filters:[...this.channelOptions.filters||[],...n?.filters||[]],muted:!!this.channelOptions.muted||!!n?.muted,volume:S(n?.volume,this.channelOptions.volume)}),this);if(n?.delay){r.paused=true;let a=setTimeout(()=>{r.paused=false,s.delayTimeoutInstances=s.delayTimeoutInstances.filter(h=>h[0]!==a);},n.delay*1e3);s.delayTimeoutInstances.push([a,i]);}return s.mediaInstances[i]={channelAlias:this.alias,soundAlias:o,instance:r,stepCounter:GameUnifier.stepCounter,options:{volume:n?.volume??1,muted:n?.muted??false,loop:n?.loop??false,...n??{}}},r.on("end",()=>{delete s.mediaInstances[i];}),r}updateMediaVolume(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.volume??1;e.instance.volume=n;}}}get volume(){return this.channelOptions.volume??1}set volume(t){this.channelOptions.volume=t,this.updateMediaVolume();}updateMediaMuted(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.muted??false;e.instance.muted=n;}}}get muted(){return this.channelOptions.muted??false}set muted(t){this.channelOptions.muted=t,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Object.values(s.mediaInstances).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e.instance),t),[])}get background(){return this.channelOptions.background||false}stopAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.channelAlias===this.alias&&(e.instance.stop(),delete s.mediaInstances[t]);}return this}pauseAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);}return this}resumeAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);}return this}};function I(u){let t=[];for(let e of u)e.type==="TelephoneFilter"?t.push(new filters.TelephoneFilter):e.type==="StreamFilter"?t.push(new filters.StreamFilter):e.type==="StereoFilter"?t.push(new filters.StereoFilter(e.pan)):e.type==="ReverbFilter"?t.push(new filters.ReverbFilter(e.seconds,e.decay,e.reverse)):e.type==="MonoFilter"?t.push(new filters.MonoFilter):e.type==="EqualizerFilter"?t.push(new filters.EqualizerFilter(e.f32,e.f64,e.f125,e.f250,e.f500,e.f1k,e.f2k,e.f4k,e.f8k,e.f16k)):e.type==="DistortionFilter"?t.push(new filters.DistortionFilter(e.amount)):j.error("Unknown sound filter type");return t}function b(u){if(!u)return;let t=[];for(let e of u)e instanceof filters.TelephoneFilter?t.push({type:"TelephoneFilter"}):e instanceof filters.StreamFilter?t.push({type:"StreamFilter"}):e instanceof filters.StereoFilter?t.push({type:"StereoFilter",pan:e.pan}):e instanceof filters.ReverbFilter?t.push({type:"ReverbFilter",seconds:e.seconds,decay:e.decay,reverse:e.reverse}):e instanceof filters.MonoFilter?t.push({type:"MonoFilter"}):e instanceof filters.EqualizerFilter?t.push({type:"EqualizerFilter",f32:e.f32,f64:e.f64,f125:e.f125,f250:e.f250,f500:e.f500,f1k:e.f1k,f2k:e.f2k,f4k:e.f4k,f8k:e.f8k,f16k:e.f16k}):e instanceof filters.DistortionFilter?t.push({type:"DistortionFilter",amount:e.amount}):j.error("Unknown sound filter type");return t}var A=class{constructor(){d(this,"_defaultChannelAlias",i);}get context(){return sound.context}get filtersAll(){return sound.filtersAll}set filtersAll(t){sound.filtersAll=t.filter(e=>!(e instanceof filters.Filter));}get supported(){return sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){return sound.add(t,e)}async edit(t,e){let n=sound.find(t);if(!n&&(await this.load(t),n=sound.find(t),!n)){j.error(`Sound with alias ${t} not found after loading.`);return}n.options=e;}get useLegacy(){return sound.useLegacy}set useLegacy(t){sound.useLegacy=t;}get disableAutoPause(){return sound.disableAutoPause}set disableAutoPause(t){sound.disableAutoPause=t;}get volumeAll(){return sound.volumeAll}set volumeAll(t){sound.volumeAll=t;}get speedAll(){return sound.speedAll}set speedAll(t){sound.speedAll=t;}pauseAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.instance.paused||(e.instance.paused=true);}return this}resumeAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.instance.paused&&(e.instance.paused=false);}return this}toggleMuteAll(){return sound.toggleMuteAll()}muteAll(){return sound.muteAll(),this}unmuteAll(){return sound.unmuteAll(),this}stopAll(){return s.mediaInstances={},sound.stopAll(),this}isPlaying(){return sound.isPlaying()}async play(t,e,n){let i,o;typeof e=="string"?(i=t,o=e):(i=t,o=t,n=e),sound.exists(o)||await this.load(o);let{channel:r=this.defaultChannelAlias,...a}=n??{};return await this.findChannel(r).play(i,o,a)}find(t){return s.mediaInstances[t]?.instance}stop(t){let e=this.find(t);e?(e.stop(),delete s.mediaInstances[t]):j.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){j.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){j.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return sound.duration(t)}async load(t){typeof t=="string"&&(t=[t]);let e=t.map(async n=>{let i=await g.Assets.load(n);return sound.exists(n)||sound.add(n,i),i});return await Promise.all(e)}backgroundLoad(t){let e=g.Assets.backgroundLoad(t);return e.then(()=>{typeof t=="string"&&(t=[t]),t.forEach(n=>{let i=g.Assets.get(n);sound.exists(n)||sound.add(n,i);});}),e}backgroundLoadBundle(t){let e=g.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await g.Assets.loadBundle(t);for(let i in n){let o=n[i];o instanceof Sound&&(sound.exists(i)||sound.add(i,o));}}catch(n){j.error("Error loading sound bundle",n);}}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(i=>{let o={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(i,o);});return}if(s.channels[t]){j.warn(`Channel with alias ${t} already exists.`);return}let n=new y(t,e);return s.channels[t]=n,n}findChannel(t){let e=s.channels[t];return e||this.addChannel(t)}get channels(){return Object.values(s.channels)}export(){let t=Object.entries(s.mediaInstances).reduce((e,[n,i])=>(e[n]={channelAlias:i.channelAlias,soundAlias:i.soundAlias,stepCounter:i.stepCounter,options:{...i.options,filters:b(i.options.filters)},paused:i.instance.paused},e),{});return {mediaInstances:k(t),filters:k(b(this.filtersAll))}}async restore(t){try{if(t.hasOwnProperty("soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async i=>{await this.load(i),await this.play(i);});await Promise.all(n);}}if(t.hasOwnProperty("mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,i=Object.values(e).map(async({soundAlias:r,channelAlias:a})=>(n.add(a),await this.load(r)));await Promise.all(i),this.channels.forEach(r=>{(!r.background||!n.has(r.alias))&&r.stopAll();});let o=Object.keys(e).map(async r=>{let a=e[r],h=this.findChannel(a.channelAlias);if(h.background)if(a.stepCounter===GameUnifier.stepCounter||!this.find(r)){let d=await h.play(r,a.soundAlias,{...a.options,filters:I(a.options.filters||[])});a.paused&&(d.paused=a.paused);}else {let d=this.find(r);d&&(s.mediaInstances[r].options={...a.options,filters:I(a.options.filters||[])},d.paused!==a.paused&&(d.paused=a.paused),d.loop!==(a.options.loop||!1)&&(d.loop=a.options.loop||!1),d.volume!==(a.options.volume??1)&&(d.volume=a.options.volume??1),d.muted!==(a.options.muted||!1)&&(d.muted=a.options.muted||!1),d.speed!==(a.options.speed??1)&&(d.speed=a.options.speed??1));}else {let d=await h.play(r,a.soundAlias,{...a.options,filters:I(a.options.filters||[])});a.paused&&(d.paused=a.paused);}});await Promise.all(o);}}if(t.hasOwnProperty("filters")){let e=t.filters;e&&(this.filtersAll=I(e));}}catch(e){j.error("Error importing data",e);}}};var v={DistortionFilter:filters.DistortionFilter,EqualizerFilter:filters.EqualizerFilter,MonoFilter:filters.MonoFilter,ReverbFilter:filters.ReverbFilter,StereoFilter:filters.StereoFilter,StreamFilter:filters.StreamFilter,TelephoneFilter:filters.TelephoneFilter};var ce=new A;GameUnifier.addOnPreContinue(async()=>{try{s.delayTimeoutInstances.forEach(u=>{clearTimeout(u[0]);let t=s.mediaInstances[u[1]];t&&(t.instance.paused=!1);}),s.delayTimeoutInstances=[],Object.values(s.channels).forEach(u=>{u.background||u.stopAll();});}catch{}});export{s as SoundManagerStatic,v as filters,ce as sound};
|
package/dist/storage.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var $t=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 m=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),zt=(u,e,i)=>e.has(u)||$t("Cannot "+i);var t=(u,e,i)=>(zt(u,e,"read from private field"),i?i.call(u):e.get(u)),g=(u,e,i)=>e.has(u)?$t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(zt(u,e,"write to private field"),e.set(u,i),i),h=(u,e,i)=>(zt(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 rt="storage",ct="temp",W="narration",Ft="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ut;(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)))(ut||(ut={}));function Ot(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw ut.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xt=new Set,Yt=typeof process=="object"&&process?process:{},Jt=(u,e,i,s)=>{typeof Yt.emitWarning=="function"?Yt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Lt=globalThis.AbortController,kt=globalThis.AbortSignal;if(typeof Lt>"u"){kt=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Lt=class{constructor(){m(this,"signal",new kt);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=Yt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,Jt("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 re=u=>!Xt.has(u);var at=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),qt=u=>at(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ct:null:null,Ct=class extends Array{constructor(u){super(u),this.fill(0);}},et,St,ae=(et=class{constructor(e,i){m(this,"heap");m(this,"length");if(!t(et,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=qt(e);if(!i)return [];f(et,St,true);let s=new et(e,i);return f(et,St,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,g(et,St,false),et),Ht,Bt,$,V,k,ft,H,Tt,bt,B,O,X,w,A,_,C,U,N,R,J,x,q,Q,z,Y,Z,lt,M,At,n,Pt,_t,it,xt,P,Zt,pt,yt,Dt,ot,nt,Kt,Mt,Gt,b,Wt,Rt,ht,jt,vt,Qt=(vt=class{constructor(e){g(this,n);g(this,$);g(this,V);g(this,k);g(this,ft);g(this,H);g(this,Tt);g(this,bt);g(this,B);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");g(this,O);g(this,X);g(this,w);g(this,A);g(this,_);g(this,C);g(this,U);g(this,N);g(this,R);g(this,J);g(this,x);g(this,q);g(this,Q);g(this,z);g(this,Y);g(this,Z);g(this,lt);g(this,M);g(this,At);g(this,_t,()=>{});g(this,it,()=>{});g(this,xt,()=>{});g(this,P,()=>false);g(this,pt,e=>{});g(this,yt,(e,i,s)=>{});g(this,Dt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,Ht,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:c,dispose:E,onInsert:D,disposeAfter:S,noDisposeOnSet:st,noUpdateTTL:K,maxSize:tt=0,maxEntrySize:y=0,sizeCalculation:T,fetchMethod:p,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:F,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:wt,ignoreFetchAbort:gt,perf:mt}=e;if(mt!==void 0&&typeof mt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,B,mt??se),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let Et=i?qt(i):Array;if(!Et)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,V,tt),this.maxEntrySize=y||t(this,V),this.sizeCalculation=T,this.sizeCalculation){if(!t(this,V)&&!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(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,bt,I),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Tt,p),f(this,lt,!!p),f(this,w,new Map),f(this,A,new Array(i).fill(void 0)),f(this,_,new Array(i).fill(void 0)),f(this,C,new Et(i)),f(this,U,new Et(i)),f(this,N,0),f(this,R,0),f(this,J,ae.create(i)),f(this,O,0),f(this,X,0),typeof E=="function"&&f(this,k,E),typeof D=="function"&&f(this,ft,D),typeof S=="function"?(f(this,H,S),f(this,x,[])):(f(this,H,void 0),f(this,x,void 0)),f(this,Z,!!t(this,k)),f(this,At,!!t(this,ft)),f(this,M,!!t(this,H)),this.noDisposeOnSet=!!st,this.noUpdateTTL=!!K,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!wt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,V)!==0&&!at(t(this,V)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,n,Zt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!F,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,n,Pt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,V)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,V)){let Ut="LRU_CACHE_UNBOUNDED";re(Ut)&&(Xt.add(Ut),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ut,vt));}}get perf(){return t(this,B)}static unsafeExposeInternals(e){return {starts:t(e,Q),ttls:t(e,z),autopurgeTimers:t(e,Y),sizes:t(e,q),keyMap:t(e,w),keyList:t(e,A),valList:t(e,_),next:t(e,C),prev:t(e,U),get head(){return t(e,N)},get tail(){return t(e,R)},free:t(e,J),isBackgroundFetch:i=>{var s;return h(s=e,n,b).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return h(a=e,n,Gt).call(a,i,s,r,o)},moveToTail:i=>{var s;return h(s=e,n,Rt).call(s,i)},indexes:i=>{var s;return h(s=e,n,ot).call(s,i)},rindexes:i=>{var s;return h(s=e,n,nt).call(s,i)},isStale:i=>{var s;return t(s=e,P).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,V)}get calculatedSize(){return t(this,X)}get size(){return t(this,O)}get fetchMethod(){return t(this,Tt)}get memoMethod(){return t(this,bt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,H)}getRemainingTTL(e){return t(this,w).has(e)?1/0:0}*entries(){for(let e of h(this,n,ot).call(this))t(this,_)[e]!==void 0&&t(this,A)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield [t(this,A)[e],t(this,_)[e]]);}*rentries(){for(let e of h(this,n,nt).call(this))t(this,_)[e]!==void 0&&t(this,A)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield [t(this,A)[e],t(this,_)[e]]);}*keys(){for(let e of h(this,n,ot).call(this)){let i=t(this,A)[e];i!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield i);}}*rkeys(){for(let e of h(this,n,nt).call(this)){let i=t(this,A)[e];i!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield i);}}*values(){for(let e of h(this,n,ot).call(this))t(this,_)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}*rvalues(){for(let e of h(this,n,nt).call(this))t(this,_)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}[(Bt=Symbol.iterator,Ht=Symbol.toStringTag,Bt)](){return this.entries()}find(e,i={}){for(let s of h(this,n,ot).call(this)){let r=t(this,_)[s],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,A)[s],this))return this.get(t(this,A)[s],i)}}forEach(e,i=this){for(let s of h(this,n,ot).call(this)){let r=t(this,_)[s],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,A)[s],this);}}rforEach(e,i=this){for(let s of h(this,n,nt).call(this)){let r=t(this,_)[s],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,A)[s],this);}}purgeStale(){let e=false;for(let i of h(this,n,nt).call(this,{allowStale:true}))t(this,P).call(this,i)&&(h(this,n,ht).call(this,t(this,A)[i],"expire"),e=true);return e}info(e){let i=t(this,w).get(e);if(i===void 0)return;let s=t(this,_)[i],r=h(this,n,b).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,z)&&t(this,Q)){let a=t(this,z)[i],l=t(this,Q)[i];if(a&&l){let c=a-(t(this,B).now()-l);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 h(this,n,ot).call(this,{allowStale:true})){let s=t(this,A)[i],r=t(this,_)[i],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,z)&&t(this,Q)){a.ttl=t(this,z)[i];let l=t(this,B).now()-t(this,Q)[i];a.start=Math.floor(Date.now()-l);}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,B).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var st,K,tt,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,{noUpdateTTL:E=this.noUpdateTTL}=s,D=t(this,Dt).call(this,e,i,s.size||0,l);if(this.maxEntrySize&&D>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,n,ht).call(this,e,"set"),this;let S=t(this,O)===0?void 0:t(this,w).get(e);if(S===void 0)S=t(this,O)===0?t(this,R):t(this,J).length!==0?t(this,J).pop():t(this,O)===t(this,$)?h(this,n,Mt).call(this,false):t(this,O),t(this,A)[S]=e,t(this,_)[S]=i,t(this,w).set(e,S),t(this,C)[t(this,R)]=S,t(this,U)[S]=t(this,R),f(this,R,S),It(this,O)._++,t(this,yt).call(this,S,D,c),c&&(c.set="add"),E=false,t(this,At)&&((st=t(this,ft))==null||st.call(this,i,e,"add"));else {h(this,n,Rt).call(this,S);let T=t(this,_)[S];if(i!==T){if(t(this,lt)&&h(this,n,b).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=T;p!==void 0&&!a&&(t(this,Z)&&((K=t(this,k))==null||K.call(this,p,e,"set")),t(this,M)&&t(this,x)?.push([p,e,"set"]));}else a||(t(this,Z)&&((tt=t(this,k))==null||tt.call(this,T,e,"set")),t(this,M)&&t(this,x)?.push([T,e,"set"]));if(t(this,pt).call(this,S),t(this,yt).call(this,S,D,c),t(this,_)[S]=i,c){c.set="replace";let p=T&&h(this,n,b).call(this,T)?T.__staleWhileFetching:T;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");t(this,At)&&this.onInsert?.(i,e,i===T?"update":"replace");}if(r!==0&&!t(this,z)&&h(this,n,Pt).call(this),t(this,z)&&(E||t(this,xt).call(this,S,r,o),c&&t(this,it).call(this,c,S)),!a&&t(this,M)&&t(this,x)){let T=t(this,x),p;for(;p=T?.shift();)(y=t(this,H))==null||y.call(this,...p);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,_)[t(this,N)];if(h(this,n,Mt).call(this,!0),h(this,n,b).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,M)&&t(this,x)){let i=t(this,x),s;for(;s=i?.shift();)(e=t(this,H))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,w).get(e);if(o!==void 0){let a=t(this,_)[o];if(h(this,n,b).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,P).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,_t).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,w).get(e);if(r===void 0||!s&&t(this,P).call(this,r))return;let o=t(this,_)[r];return h(this,n,b).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:l=this.noDisposeOnSet,size:c=0,sizeCalculation:E=this.sizeCalculation,noUpdateTTL:D=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:st=this.allowStaleOnFetchRejection,ignoreFetchAbort:K=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:y,forceRefresh:T=false,status:p,signal:I}=i;if(!t(this,lt))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:c,sizeCalculation:E,noUpdateTTL:D,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:st,allowStaleOnFetchAbort:tt,ignoreFetchAbort:K,status:p,signal:I},F=t(this,w).get(e);if(F===void 0){p&&(p.fetch="miss");let v=h(this,n,Gt).call(this,e,F,L,y);return v.__returned=v}else {let v=t(this,_)[F];if(h(this,n,b).call(this,v)){let Et=s&&v.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",Et&&(p.returnedStale=true)),Et?v.__staleWhileFetching:v.__returned=v}let wt=t(this,P).call(this,F);if(!T&&!wt)return p&&(p.fetch="hit"),h(this,n,Rt).call(this,F),r&&t(this,_t).call(this,F),p&&t(this,it).call(this,p,F),v;let gt=h(this,n,Gt).call(this,e,F,L,y),mt=gt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=wt?"stale":"refresh",mt&&wt&&(p.returnedStale=true)),mt?gt.__staleWhileFetching:gt.__returned=gt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,bt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,l=this.get(e,a);if(!o&&l!==void 0)return l;let c=s(e,l,{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,l=t(this,w).get(e);if(l!==void 0){let c=t(this,_)[l],E=h(this,n,b).call(this,c);return a&&t(this,it).call(this,a,l),t(this,P).call(this,l)?(a&&(a.get="stale"),E?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||h(this,n,ht).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),E?c.__staleWhileFetching:(h(this,n,Rt).call(this,l),r&&t(this,_t).call(this,l),c))}else a&&(a.get="miss");}delete(e){return h(this,n,ht).call(this,e,"delete")}clear(){return h(this,n,jt).call(this,"delete")}},$=new WeakMap,V=new WeakMap,k=new WeakMap,ft=new WeakMap,H=new WeakMap,Tt=new WeakMap,bt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,w=new WeakMap,A=new WeakMap,_=new WeakMap,C=new WeakMap,U=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,q=new WeakMap,Q=new WeakMap,z=new WeakMap,Y=new WeakMap,Z=new WeakMap,lt=new WeakMap,M=new WeakMap,At=new WeakMap,n=new WeakSet,Pt=function(){let e=new Ct(t(this,$)),i=new Ct(t(this,$));f(this,z,e),f(this,Q,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,Y,s),f(this,xt,(l,c,E=t(this,B).now())=>{i[l]=c!==0?E:0,e[l]=c,r(l,c);}),f(this,_t,l=>{i[l]=e[l]!==0?t(this,B).now():0,r(l,e[l]);});let r=this.ttlAutopurge?(l,c)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),c&&c!==0&&s){let E=setTimeout(()=>{t(this,P).call(this,l)&&h(this,n,ht).call(this,t(this,A)[l],"expire");},c+1);E.unref&&E.unref(),s[l]=E;}}:()=>{};f(this,it,(l,c)=>{if(e[c]){let E=e[c],D=i[c];if(!E||!D)return;l.ttl=E,l.start=D,l.now=o||a();let S=l.now-D;l.remainingTTL=E-S;}});let o=0,a=()=>{let l=t(this,B).now();if(this.ttlResolution>0){o=l;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return l};this.getRemainingTTL=l=>{let c=t(this,w).get(l);if(c===void 0)return 0;let E=e[c],D=i[c];if(!E||!D)return 1/0;let S=(o||a())-D;return E-S},f(this,P,l=>{let c=i[l],E=e[l];return !!E&&!!c&&(o||a())-c>E});},_t=new WeakMap,it=new WeakMap,xt=new WeakMap,P=new WeakMap,Zt=function(){let e=new Ct(t(this,$));f(this,X,0),f(this,q,e),f(this,pt,i=>{f(this,X,t(this,X)-e[i]),e[i]=0;}),f(this,Dt,(i,s,r,o)=>{if(h(this,n,b).call(this,s))return 0;if(!at(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!at(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,yt,(i,s,r)=>{if(e[i]=s,t(this,V)){let o=t(this,V)-e[i];for(;t(this,X)>o;)h(this,n,Mt).call(this,true);}f(this,X,t(this,X)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,X));});},pt=new WeakMap,yt=new WeakMap,Dt=new WeakMap,ot=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,R);!(!h(this,n,Kt).call(this,i)||((e||!t(this,P).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,U)[i];},nt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,N);!(!h(this,n,Kt).call(this,i)||((e||!t(this,P).call(this,i))&&(yield i),i===t(this,R)));)i=t(this,C)[i];},Kt=function(e){return e!==void 0&&t(this,w).get(t(this,A)[e])===e},Mt=function(e){var o;let i=t(this,N),s=t(this,A)[i],r=t(this,_)[i];return t(this,lt)&&h(this,n,b).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,Z)||t(this,M))&&(t(this,Z)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,M)&&t(this,x)?.push([r,s,"evict"])),t(this,pt).call(this,i),t(this,Y)?.[i]&&(clearTimeout(t(this,Y)[i]),t(this,Y)[i]=void 0),e&&(t(this,A)[i]=void 0,t(this,_)[i]=void 0,t(this,J).push(i)),t(this,O)===1?(f(this,N,f(this,R,0)),t(this,J).length=0):f(this,N,t(this,C)[i]),t(this,w).delete(s),It(this,O)._--,i},Gt=function(e,i,s,r){let o=i===void 0?void 0:t(this,_)[i];if(h(this,n,b).call(this,o))return o;let a=new Lt,{signal:l}=s;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},E=(y,T=false)=>{let{aborted:p}=a.signal,I=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!T?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!I&&!T)return S(a.signal.reason,L);let F=K,v=t(this,_)[i];return (v===K||I&&T&&v===void 0)&&(y===void 0?F.__staleWhileFetching!==void 0?t(this,_)[i]=F.__staleWhileFetching:h(this,n,ht).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},D=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),S(y,false)),S=(y,T)=>{let{aborted:p}=a.signal,I=p&&s.allowStaleOnFetchAbort,L=I||s.allowStaleOnFetchRejection,F=L||s.noDeleteOnFetchRejection,v=K;if(t(this,_)[i]===K&&(!F||!T&&v.__staleWhileFetching===void 0?h(this,n,ht).call(this,e,"fetch"):I||(t(this,_)[i]=v.__staleWhileFetching)),L)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw y},st=(y,T)=>{var I;let p=(I=t(this,Tt))==null?void 0:I.call(this,e,o,c);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>E(L,true)));});};s.status&&(s.status.fetchDispatched=true);let K=new Promise(st).then(E,D),tt=Object.assign(K,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,tt,{...c.options,status:void 0}),i=t(this,w).get(e)):t(this,_)[i]=tt,tt},b=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Lt},Wt=function(e,i){t(this,U)[i]=e,t(this,C)[e]=i;},Rt=function(e){e!==t(this,R)&&(e===t(this,N)?f(this,N,t(this,C)[e]):h(this,n,Wt).call(this,t(this,U)[e],t(this,C)[e]),h(this,n,Wt).call(this,t(this,R),e),f(this,R,e));},ht=function(e,i){var r,o;let s=false;if(t(this,O)!==0){let a=t(this,w).get(e);if(a!==void 0)if(t(this,Y)?.[a]&&(clearTimeout(t(this,Y)?.[a]),t(this,Y)[a]=void 0),s=true,t(this,O)===1)h(this,n,jt).call(this,i);else {t(this,pt).call(this,a);let l=t(this,_)[a];if(h(this,n,b).call(this,l)?l.__abortController.abort(new Error("deleted")):(t(this,Z)||t(this,M))&&(t(this,Z)&&((r=t(this,k))==null||r.call(this,l,e,i)),t(this,M)&&t(this,x)?.push([l,e,i])),t(this,w).delete(e),t(this,A)[a]=void 0,t(this,_)[a]=void 0,a===t(this,R))f(this,R,t(this,U)[a]);else if(a===t(this,N))f(this,N,t(this,C)[a]);else {let c=t(this,U)[a];t(this,C)[c]=t(this,C)[a];let E=t(this,C)[a];t(this,U)[E]=t(this,U)[a];}It(this,O)._--,t(this,J).push(a);}}if(t(this,M)&&t(this,x)?.length){let a=t(this,x),l;for(;l=a?.shift();)(o=t(this,H))==null||o.call(this,...l);}return s},jt=function(e){var i,s;for(let r of h(this,n,nt).call(this,{allowStale:true})){let o=t(this,_)[r];if(h(this,n,b).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,A)[r];t(this,Z)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,M)&&t(this,x)?.push([o,a,e]);}}if(t(this,w).clear(),t(this,_).fill(void 0),t(this,A).fill(void 0),t(this,z)&&t(this,Q)){t(this,z).fill(0),t(this,Q).fill(0);for(let r of t(this,Y)??[])r!==void 0&&clearTimeout(r);t(this,Y)?.fill(void 0);}if(t(this,q)&&t(this,q).fill(0),f(this,N,0),f(this,R,0),t(this,J).length=0,f(this,X,0),f(this,O,0),t(this,M)&&t(this,x)){let r=t(this,x),o;for(;o=r?.shift();)(s=t(this,H))==null||s.call(this,...o);}},vt);var dt=class{constructor(e){m(this,"cache");m(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(){return this.cache.clear(),this.map.clear()}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var G=class G{constructor(){}static clearOldTempVariables(e){G.tempStorageDeadlines.forEach((i,s)=>{i>e&&(G.removeVariable(ct,s),G.tempStorageDeadlines.delete(s));});}static setVariable(e,i,s){s==null?G.storage.delete(`${e}:${i}`):G.storage.set(`${e}:${i}`,s);}static getVariable(e,i){let s=G.storage.get(`${e}:${i}`);return Ot(s)}static removeVariable(e,i){G.storage.delete(`${e}:${i}`);}static setFlag(e,i){let s=G.storage.get(Ft)||[];if(i)s.includes(e)||s.push(e);else {let r=s.indexOf(e);r>-1&&s.splice(r,1);}G.storage.set(Ft,s);}static getFlag(e){return (G.storage.get(Ft)||[]).includes(e)}};m(G,"storage",new dt({cacheSize:50})),m(G,"default",new dt({cacheSize:10})),m(G,"tempStorageDeadlines",new Map);var d=G;var Nt=class{get base(){return d.storage.map}get cache(){return d.storage.cache}get tempStorageDeadlines(){return d.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{d.default.map.set(i,s);});}set(e,i){return d.setVariable(rt,e,i)}get(e){let i=d.getVariable(ct,e);return i===void 0&&(i=d.getVariable(rt,e)),i===void 0&&(i=Ot(d.default.get(e))),i}remove(e){return this.removeTempVariable(e),d.removeVariable(rt,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else d.setVariable(ct,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){d.removeVariable(ct,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return d.setFlag(e,i)}getFlag(e){return d.getFlag(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 [...d.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Ot({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":d.setVariable(W,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":d.setVariable(W,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":d.setVariable(W,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":d.setVariable(W,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":d.setVariable(W,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":d.setVariable(W,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":d.setVariable(W,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":d.setVariable(W,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":d.setVariable(W,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":d.setVariable(W,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":d.setVariable(W,j.LAST_STEP_GLUED,i.value);break;default:d.setVariable(rt,i.key,i.value);}}),e.temp?.forEach(i=>{d.setVariable(ct,i.key,i.value);}),e.flags?.forEach(i=>{d.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);})):ut.warn("No storage data found");}catch(i){ut.error("Error importing data",i);}}};var Vt=class{constructor(e,i){m(this,"id");m(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=d.getVariable(rt,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{d.setVariable(this.categoryId,`${s}:${o}`,a);});}),d.removeVariable(rt,e));}setStorageProperty(e,i){d.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return d.getVariable(this.categoryId,`${i}:${e}`)}};var ze=new Nt;exports.StorageManagerStatic=d;exports.StoredClassModel=Vt;exports.storage=ze;//# sourceMappingURL=storage.cjs.map
|
|
2
|
-
//# sourceMappingURL=storage.cjs.map
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var $t=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 m=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),zt=(u,e,i)=>e.has(u)||$t("Cannot "+i);var t=(u,e,i)=>(zt(u,e,"read from private field"),i?i.call(u):e.get(u)),g=(u,e,i)=>e.has(u)?$t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(zt(u,e,"write to private field"),e.set(u,i),i),h=(u,e,i)=>(zt(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 rt="storage",ct="temp",W="narration",Ft="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ut;(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)))(ut||(ut={}));function Ot(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw ut.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xt=new Set,Yt=typeof process=="object"&&process?process:{},Jt=(u,e,i,s)=>{typeof Yt.emitWarning=="function"?Yt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Lt=globalThis.AbortController,kt=globalThis.AbortSignal;if(typeof Lt>"u"){kt=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Lt=class{constructor(){m(this,"signal",new kt);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=Yt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,Jt("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 re=u=>!Xt.has(u);var at=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),qt=u=>at(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ct:null:null,Ct=class extends Array{constructor(u){super(u),this.fill(0);}},et,St,ae=(et=class{constructor(e,i){m(this,"heap");m(this,"length");if(!t(et,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=qt(e);if(!i)return [];f(et,St,true);let s=new et(e,i);return f(et,St,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,g(et,St,false),et),Ht,Bt,$,V,k,ft,H,Tt,bt,B,O,X,w,A,_,C,U,N,R,J,x,q,Q,z,Y,Z,lt,M,At,n,Pt,_t,it,xt,P,Zt,pt,yt,Dt,ot,nt,Kt,Mt,Gt,b,Wt,Rt,ht,jt,vt,Qt=(vt=class{constructor(e){g(this,n);g(this,$);g(this,V);g(this,k);g(this,ft);g(this,H);g(this,Tt);g(this,bt);g(this,B);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");g(this,O);g(this,X);g(this,w);g(this,A);g(this,_);g(this,C);g(this,U);g(this,N);g(this,R);g(this,J);g(this,x);g(this,q);g(this,Q);g(this,z);g(this,Y);g(this,Z);g(this,lt);g(this,M);g(this,At);g(this,_t,()=>{});g(this,it,()=>{});g(this,xt,()=>{});g(this,P,()=>false);g(this,pt,e=>{});g(this,yt,(e,i,s)=>{});g(this,Dt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,Ht,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:c,dispose:E,onInsert:D,disposeAfter:S,noDisposeOnSet:st,noUpdateTTL:K,maxSize:tt=0,maxEntrySize:y=0,sizeCalculation:T,fetchMethod:p,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:F,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:wt,ignoreFetchAbort:gt,perf:mt}=e;if(mt!==void 0&&typeof mt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,B,mt??se),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let Et=i?qt(i):Array;if(!Et)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,V,tt),this.maxEntrySize=y||t(this,V),this.sizeCalculation=T,this.sizeCalculation){if(!t(this,V)&&!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(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,bt,I),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Tt,p),f(this,lt,!!p),f(this,w,new Map),f(this,A,new Array(i).fill(void 0)),f(this,_,new Array(i).fill(void 0)),f(this,C,new Et(i)),f(this,U,new Et(i)),f(this,N,0),f(this,R,0),f(this,J,ae.create(i)),f(this,O,0),f(this,X,0),typeof E=="function"&&f(this,k,E),typeof D=="function"&&f(this,ft,D),typeof S=="function"?(f(this,H,S),f(this,x,[])):(f(this,H,void 0),f(this,x,void 0)),f(this,Z,!!t(this,k)),f(this,At,!!t(this,ft)),f(this,M,!!t(this,H)),this.noDisposeOnSet=!!st,this.noUpdateTTL=!!K,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!wt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,V)!==0&&!at(t(this,V)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,n,Zt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!F,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,n,Pt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,V)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,V)){let Ut="LRU_CACHE_UNBOUNDED";re(Ut)&&(Xt.add(Ut),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ut,vt));}}get perf(){return t(this,B)}static unsafeExposeInternals(e){return {starts:t(e,Q),ttls:t(e,z),autopurgeTimers:t(e,Y),sizes:t(e,q),keyMap:t(e,w),keyList:t(e,A),valList:t(e,_),next:t(e,C),prev:t(e,U),get head(){return t(e,N)},get tail(){return t(e,R)},free:t(e,J),isBackgroundFetch:i=>{var s;return h(s=e,n,b).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return h(a=e,n,Gt).call(a,i,s,r,o)},moveToTail:i=>{var s;return h(s=e,n,Rt).call(s,i)},indexes:i=>{var s;return h(s=e,n,ot).call(s,i)},rindexes:i=>{var s;return h(s=e,n,nt).call(s,i)},isStale:i=>{var s;return t(s=e,P).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,V)}get calculatedSize(){return t(this,X)}get size(){return t(this,O)}get fetchMethod(){return t(this,Tt)}get memoMethod(){return t(this,bt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,H)}getRemainingTTL(e){return t(this,w).has(e)?1/0:0}*entries(){for(let e of h(this,n,ot).call(this))t(this,_)[e]!==void 0&&t(this,A)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield [t(this,A)[e],t(this,_)[e]]);}*rentries(){for(let e of h(this,n,nt).call(this))t(this,_)[e]!==void 0&&t(this,A)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield [t(this,A)[e],t(this,_)[e]]);}*keys(){for(let e of h(this,n,ot).call(this)){let i=t(this,A)[e];i!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield i);}}*rkeys(){for(let e of h(this,n,nt).call(this)){let i=t(this,A)[e];i!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield i);}}*values(){for(let e of h(this,n,ot).call(this))t(this,_)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}*rvalues(){for(let e of h(this,n,nt).call(this))t(this,_)[e]!==void 0&&!h(this,n,b).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}[(Bt=Symbol.iterator,Ht=Symbol.toStringTag,Bt)](){return this.entries()}find(e,i={}){for(let s of h(this,n,ot).call(this)){let r=t(this,_)[s],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,A)[s],this))return this.get(t(this,A)[s],i)}}forEach(e,i=this){for(let s of h(this,n,ot).call(this)){let r=t(this,_)[s],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,A)[s],this);}}rforEach(e,i=this){for(let s of h(this,n,nt).call(this)){let r=t(this,_)[s],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,A)[s],this);}}purgeStale(){let e=false;for(let i of h(this,n,nt).call(this,{allowStale:true}))t(this,P).call(this,i)&&(h(this,n,ht).call(this,t(this,A)[i],"expire"),e=true);return e}info(e){let i=t(this,w).get(e);if(i===void 0)return;let s=t(this,_)[i],r=h(this,n,b).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,z)&&t(this,Q)){let a=t(this,z)[i],l=t(this,Q)[i];if(a&&l){let c=a-(t(this,B).now()-l);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 h(this,n,ot).call(this,{allowStale:true})){let s=t(this,A)[i],r=t(this,_)[i],o=h(this,n,b).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,z)&&t(this,Q)){a.ttl=t(this,z)[i];let l=t(this,B).now()-t(this,Q)[i];a.start=Math.floor(Date.now()-l);}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,B).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var st,K,tt,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,{noUpdateTTL:E=this.noUpdateTTL}=s,D=t(this,Dt).call(this,e,i,s.size||0,l);if(this.maxEntrySize&&D>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,n,ht).call(this,e,"set"),this;let S=t(this,O)===0?void 0:t(this,w).get(e);if(S===void 0)S=t(this,O)===0?t(this,R):t(this,J).length!==0?t(this,J).pop():t(this,O)===t(this,$)?h(this,n,Mt).call(this,false):t(this,O),t(this,A)[S]=e,t(this,_)[S]=i,t(this,w).set(e,S),t(this,C)[t(this,R)]=S,t(this,U)[S]=t(this,R),f(this,R,S),It(this,O)._++,t(this,yt).call(this,S,D,c),c&&(c.set="add"),E=false,t(this,At)&&((st=t(this,ft))==null||st.call(this,i,e,"add"));else {h(this,n,Rt).call(this,S);let T=t(this,_)[S];if(i!==T){if(t(this,lt)&&h(this,n,b).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=T;p!==void 0&&!a&&(t(this,Z)&&((K=t(this,k))==null||K.call(this,p,e,"set")),t(this,M)&&t(this,x)?.push([p,e,"set"]));}else a||(t(this,Z)&&((tt=t(this,k))==null||tt.call(this,T,e,"set")),t(this,M)&&t(this,x)?.push([T,e,"set"]));if(t(this,pt).call(this,S),t(this,yt).call(this,S,D,c),t(this,_)[S]=i,c){c.set="replace";let p=T&&h(this,n,b).call(this,T)?T.__staleWhileFetching:T;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");t(this,At)&&this.onInsert?.(i,e,i===T?"update":"replace");}if(r!==0&&!t(this,z)&&h(this,n,Pt).call(this),t(this,z)&&(E||t(this,xt).call(this,S,r,o),c&&t(this,it).call(this,c,S)),!a&&t(this,M)&&t(this,x)){let T=t(this,x),p;for(;p=T?.shift();)(y=t(this,H))==null||y.call(this,...p);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,_)[t(this,N)];if(h(this,n,Mt).call(this,!0),h(this,n,b).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,M)&&t(this,x)){let i=t(this,x),s;for(;s=i?.shift();)(e=t(this,H))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,w).get(e);if(o!==void 0){let a=t(this,_)[o];if(h(this,n,b).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,P).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,_t).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,w).get(e);if(r===void 0||!s&&t(this,P).call(this,r))return;let o=t(this,_)[r];return h(this,n,b).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:l=this.noDisposeOnSet,size:c=0,sizeCalculation:E=this.sizeCalculation,noUpdateTTL:D=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:st=this.allowStaleOnFetchRejection,ignoreFetchAbort:K=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:y,forceRefresh:T=false,status:p,signal:I}=i;if(!t(this,lt))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:c,sizeCalculation:E,noUpdateTTL:D,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:st,allowStaleOnFetchAbort:tt,ignoreFetchAbort:K,status:p,signal:I},F=t(this,w).get(e);if(F===void 0){p&&(p.fetch="miss");let v=h(this,n,Gt).call(this,e,F,L,y);return v.__returned=v}else {let v=t(this,_)[F];if(h(this,n,b).call(this,v)){let Et=s&&v.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",Et&&(p.returnedStale=true)),Et?v.__staleWhileFetching:v.__returned=v}let wt=t(this,P).call(this,F);if(!T&&!wt)return p&&(p.fetch="hit"),h(this,n,Rt).call(this,F),r&&t(this,_t).call(this,F),p&&t(this,it).call(this,p,F),v;let gt=h(this,n,Gt).call(this,e,F,L,y),mt=gt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=wt?"stale":"refresh",mt&&wt&&(p.returnedStale=true)),mt?gt.__staleWhileFetching:gt.__returned=gt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,bt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,l=this.get(e,a);if(!o&&l!==void 0)return l;let c=s(e,l,{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,l=t(this,w).get(e);if(l!==void 0){let c=t(this,_)[l],E=h(this,n,b).call(this,c);return a&&t(this,it).call(this,a,l),t(this,P).call(this,l)?(a&&(a.get="stale"),E?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||h(this,n,ht).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),E?c.__staleWhileFetching:(h(this,n,Rt).call(this,l),r&&t(this,_t).call(this,l),c))}else a&&(a.get="miss");}delete(e){return h(this,n,ht).call(this,e,"delete")}clear(){return h(this,n,jt).call(this,"delete")}},$=new WeakMap,V=new WeakMap,k=new WeakMap,ft=new WeakMap,H=new WeakMap,Tt=new WeakMap,bt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,w=new WeakMap,A=new WeakMap,_=new WeakMap,C=new WeakMap,U=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,q=new WeakMap,Q=new WeakMap,z=new WeakMap,Y=new WeakMap,Z=new WeakMap,lt=new WeakMap,M=new WeakMap,At=new WeakMap,n=new WeakSet,Pt=function(){let e=new Ct(t(this,$)),i=new Ct(t(this,$));f(this,z,e),f(this,Q,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,Y,s),f(this,xt,(l,c,E=t(this,B).now())=>{i[l]=c!==0?E:0,e[l]=c,r(l,c);}),f(this,_t,l=>{i[l]=e[l]!==0?t(this,B).now():0,r(l,e[l]);});let r=this.ttlAutopurge?(l,c)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),c&&c!==0&&s){let E=setTimeout(()=>{t(this,P).call(this,l)&&h(this,n,ht).call(this,t(this,A)[l],"expire");},c+1);E.unref&&E.unref(),s[l]=E;}}:()=>{};f(this,it,(l,c)=>{if(e[c]){let E=e[c],D=i[c];if(!E||!D)return;l.ttl=E,l.start=D,l.now=o||a();let S=l.now-D;l.remainingTTL=E-S;}});let o=0,a=()=>{let l=t(this,B).now();if(this.ttlResolution>0){o=l;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return l};this.getRemainingTTL=l=>{let c=t(this,w).get(l);if(c===void 0)return 0;let E=e[c],D=i[c];if(!E||!D)return 1/0;let S=(o||a())-D;return E-S},f(this,P,l=>{let c=i[l],E=e[l];return !!E&&!!c&&(o||a())-c>E});},_t=new WeakMap,it=new WeakMap,xt=new WeakMap,P=new WeakMap,Zt=function(){let e=new Ct(t(this,$));f(this,X,0),f(this,q,e),f(this,pt,i=>{f(this,X,t(this,X)-e[i]),e[i]=0;}),f(this,Dt,(i,s,r,o)=>{if(h(this,n,b).call(this,s))return 0;if(!at(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!at(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,yt,(i,s,r)=>{if(e[i]=s,t(this,V)){let o=t(this,V)-e[i];for(;t(this,X)>o;)h(this,n,Mt).call(this,true);}f(this,X,t(this,X)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,X));});},pt=new WeakMap,yt=new WeakMap,Dt=new WeakMap,ot=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,R);!(!h(this,n,Kt).call(this,i)||((e||!t(this,P).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,U)[i];},nt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,N);!(!h(this,n,Kt).call(this,i)||((e||!t(this,P).call(this,i))&&(yield i),i===t(this,R)));)i=t(this,C)[i];},Kt=function(e){return e!==void 0&&t(this,w).get(t(this,A)[e])===e},Mt=function(e){var o;let i=t(this,N),s=t(this,A)[i],r=t(this,_)[i];return t(this,lt)&&h(this,n,b).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,Z)||t(this,M))&&(t(this,Z)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,M)&&t(this,x)?.push([r,s,"evict"])),t(this,pt).call(this,i),t(this,Y)?.[i]&&(clearTimeout(t(this,Y)[i]),t(this,Y)[i]=void 0),e&&(t(this,A)[i]=void 0,t(this,_)[i]=void 0,t(this,J).push(i)),t(this,O)===1?(f(this,N,f(this,R,0)),t(this,J).length=0):f(this,N,t(this,C)[i]),t(this,w).delete(s),It(this,O)._--,i},Gt=function(e,i,s,r){let o=i===void 0?void 0:t(this,_)[i];if(h(this,n,b).call(this,o))return o;let a=new Lt,{signal:l}=s;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},E=(y,T=false)=>{let{aborted:p}=a.signal,I=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!T?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!I&&!T)return S(a.signal.reason,L);let F=K,v=t(this,_)[i];return (v===K||I&&T&&v===void 0)&&(y===void 0?F.__staleWhileFetching!==void 0?t(this,_)[i]=F.__staleWhileFetching:h(this,n,ht).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},D=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),S(y,false)),S=(y,T)=>{let{aborted:p}=a.signal,I=p&&s.allowStaleOnFetchAbort,L=I||s.allowStaleOnFetchRejection,F=L||s.noDeleteOnFetchRejection,v=K;if(t(this,_)[i]===K&&(!F||!T&&v.__staleWhileFetching===void 0?h(this,n,ht).call(this,e,"fetch"):I||(t(this,_)[i]=v.__staleWhileFetching)),L)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw y},st=(y,T)=>{var I;let p=(I=t(this,Tt))==null?void 0:I.call(this,e,o,c);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>E(L,true)));});};s.status&&(s.status.fetchDispatched=true);let K=new Promise(st).then(E,D),tt=Object.assign(K,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,tt,{...c.options,status:void 0}),i=t(this,w).get(e)):t(this,_)[i]=tt,tt},b=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Lt},Wt=function(e,i){t(this,U)[i]=e,t(this,C)[e]=i;},Rt=function(e){e!==t(this,R)&&(e===t(this,N)?f(this,N,t(this,C)[e]):h(this,n,Wt).call(this,t(this,U)[e],t(this,C)[e]),h(this,n,Wt).call(this,t(this,R),e),f(this,R,e));},ht=function(e,i){var r,o;let s=false;if(t(this,O)!==0){let a=t(this,w).get(e);if(a!==void 0)if(t(this,Y)?.[a]&&(clearTimeout(t(this,Y)?.[a]),t(this,Y)[a]=void 0),s=true,t(this,O)===1)h(this,n,jt).call(this,i);else {t(this,pt).call(this,a);let l=t(this,_)[a];if(h(this,n,b).call(this,l)?l.__abortController.abort(new Error("deleted")):(t(this,Z)||t(this,M))&&(t(this,Z)&&((r=t(this,k))==null||r.call(this,l,e,i)),t(this,M)&&t(this,x)?.push([l,e,i])),t(this,w).delete(e),t(this,A)[a]=void 0,t(this,_)[a]=void 0,a===t(this,R))f(this,R,t(this,U)[a]);else if(a===t(this,N))f(this,N,t(this,C)[a]);else {let c=t(this,U)[a];t(this,C)[c]=t(this,C)[a];let E=t(this,C)[a];t(this,U)[E]=t(this,U)[a];}It(this,O)._--,t(this,J).push(a);}}if(t(this,M)&&t(this,x)?.length){let a=t(this,x),l;for(;l=a?.shift();)(o=t(this,H))==null||o.call(this,...l);}return s},jt=function(e){var i,s;for(let r of h(this,n,nt).call(this,{allowStale:true})){let o=t(this,_)[r];if(h(this,n,b).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,A)[r];t(this,Z)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,M)&&t(this,x)?.push([o,a,e]);}}if(t(this,w).clear(),t(this,_).fill(void 0),t(this,A).fill(void 0),t(this,z)&&t(this,Q)){t(this,z).fill(0),t(this,Q).fill(0);for(let r of t(this,Y)??[])r!==void 0&&clearTimeout(r);t(this,Y)?.fill(void 0);}if(t(this,q)&&t(this,q).fill(0),f(this,N,0),f(this,R,0),t(this,J).length=0,f(this,X,0),f(this,O,0),t(this,M)&&t(this,x)){let r=t(this,x),o;for(;o=r?.shift();)(s=t(this,H))==null||s.call(this,...o);}},vt);var dt=class{constructor(e){m(this,"cache");m(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(){return this.cache.clear(),this.map.clear()}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var G=class G{constructor(){}static clearOldTempVariables(e){G.tempStorageDeadlines.forEach((i,s)=>{i>e&&(G.removeVariable(ct,s),G.tempStorageDeadlines.delete(s));});}static setVariable(e,i,s){s==null?G.storage.delete(`${e}:${i}`):G.storage.set(`${e}:${i}`,s);}static getVariable(e,i){let s=G.storage.get(`${e}:${i}`);return Ot(s)}static removeVariable(e,i){G.storage.delete(`${e}:${i}`);}static setFlag(e,i){let s=G.storage.get(Ft)||[];if(i)s.includes(e)||s.push(e);else {let r=s.indexOf(e);r>-1&&s.splice(r,1);}G.storage.set(Ft,s);}static getFlag(e){return (G.storage.get(Ft)||[]).includes(e)}};m(G,"storage",new dt({cacheSize:50})),m(G,"default",new dt({cacheSize:10})),m(G,"tempStorageDeadlines",new Map);var d=G;var Nt=class{get base(){return d.storage.map}get cache(){return d.storage.cache}get tempStorageDeadlines(){return d.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{d.default.map.set(i,s);});}set(e,i){return d.setVariable(rt,e,i)}get(e){let i=d.getVariable(ct,e);return i===void 0&&(i=d.getVariable(rt,e)),i===void 0&&(i=Ot(d.default.get(e))),i}remove(e){return this.removeTempVariable(e),d.removeVariable(rt,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else d.setVariable(ct,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){d.removeVariable(ct,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return d.setFlag(e,i)}getFlag(e){return d.getFlag(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 [...d.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Ot({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":d.setVariable(W,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":d.setVariable(W,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":d.setVariable(W,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":d.setVariable(W,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":d.setVariable(W,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":d.setVariable(W,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":d.setVariable(W,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":d.setVariable(W,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":d.setVariable(W,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":d.setVariable(W,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":d.setVariable(W,j.LAST_STEP_GLUED,i.value);break;default:d.setVariable(rt,i.key,i.value);}}),e.temp?.forEach(i=>{d.setVariable(ct,i.key,i.value);}),e.flags?.forEach(i=>{d.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);})):ut.warn("No storage data found");}catch(i){ut.error("Error importing data",i);}}};var Vt=class{constructor(e,i){m(this,"id");m(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=d.getVariable(rt,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{d.setVariable(this.categoryId,`${s}:${o}`,a);});}),d.removeVariable(rt,e));}setStorageProperty(e,i){d.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return d.getVariable(this.categoryId,`${i}:${e}`)}};var ze=new Nt;exports.StorageManagerStatic=d;exports.StoredClassModel=Vt;exports.storage=ze;
|
package/dist/storage.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=storage.mjs.map
|
|
1
|
+
export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-HACUDOYJ.mjs';import'./chunk-ZW3MIPMS.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-D45QSSXG.mjs';
|
package/dist/vite-listener.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var canvas=require('@drincs/pixi-vn/canvas'),characters=require('@drincs/pixi-vn/characters'),narration=require('@drincs/pixi-vn/narration'),o=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=characters.RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=narration.RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o__default.default.Assets.resolver._assetMap,r=o__default.default.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}exports.setupPixivnViteData=l
|
|
2
|
-
//# sourceMappingURL=vite-listener.cjs.map
|
|
1
|
+
'use strict';var canvas=require('@drincs/pixi-vn/canvas'),characters=require('@drincs/pixi-vn/characters'),narration=require('@drincs/pixi-vn/narration'),o=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=characters.RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=narration.RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o__default.default.Assets.resolver._assetMap,r=o__default.default.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}exports.setupPixivnViteData=l;
|
package/dist/vite-listener.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
2
|
-
//# sourceMappingURL=vite-listener.mjs.map
|
|
1
|
+
import'./chunk-TTRUPDAB.mjs';import {canvas}from'@drincs/pixi-vn/canvas';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {RegisteredLabels}from'@drincs/pixi-vn/narration';import o from'@drincs/pixi-vn/pixi.js';function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o.Assets.resolver._assetMap,r=o.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.app.screen.height,width:canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}export{l as setupPixivnViteData};
|
package/dist/vite.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
'use strict';var s=null,o=null,d=null,l=null;function u(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{s=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{o=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{d=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!l){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(l));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{l=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}exports.vitePluginPixivn=u
|
|
2
|
-
//# sourceMappingURL=vite.cjs.map
|
|
1
|
+
'use strict';var s=null,o=null,d=null,l=null;function u(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{s=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{o=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{d=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!l){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(l));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{l=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}exports.vitePluginPixivn=u;
|
package/dist/vite.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import'./chunk-
|
|
2
|
-
//# sourceMappingURL=vite.mjs.map
|
|
1
|
+
import'./chunk-TTRUPDAB.mjs';var s=null,o=null,d=null,l=null;function u(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{s=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{o=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{d=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!l){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(l));}if(i.method==="POST"){let n="";i.on("data",e=>n+=e),i.on("end",()=>{try{l=JSON.parse(n),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}export{u as vitePluginPixivn};
|