@drincs/pixi-vn 1.6.4 → 1.7.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/README.md +47 -53
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +56 -51
- package/dist/canvas.d.ts +56 -51
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/chunk-4KCAZKAJ.mjs +1 -0
- package/dist/{chunk-D45QSSXG.mjs → chunk-HNGW4ITF.mjs} +1 -1
- package/dist/{chunk-L4IHQ3VT.mjs → chunk-X4NBVTSJ.mjs} +1 -1
- package/dist/{chunk-ZW3MIPMS.mjs → chunk-YDNEIPJP.mjs} +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -9
- package/dist/index.d.cts +73 -4
- package/dist/index.d.ts +73 -4
- package/dist/index.mjs +2 -9
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +3 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.mjs +2 -2
- package/dist/pixi/browser.js +183 -171
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +74 -14
- package/dist/sound.d.ts +74 -14
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +63 -12
- package/dist/storage.d.ts +63 -12
- package/dist/storage.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +10 -1
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-EWW7VYPM.mjs +0 -1
- /package/dist/{chunk-XSN6P5JL.mjs → chunk-JMOSOAGB.mjs} +0 -0
package/dist/sound.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core'),_=require('@drincs/pixi-vn/pixi.js'),sound=require('@pixi/sound');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ___default=/*#__PURE__*/_interopDefault(_);var F=Object.defineProperty;var b=(r,e,t)=>e in r?F(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t;var y=(r,e,t)=>b(r,typeof e!="symbol"?e+"":e,t);var O="general";function A(r,e){return r===void 0&&e===void 0?1:e===void 0?r:r===void 0?e:r*e}var i=class{constructor(){}};y(i,"mediaInstances",new Map),y(i,"channels",new Map),y(i,"delayTimeoutInstances",[]);function T(r,e,t){return new Proxy(e,{get(s,n,a){switch(n){case "volume":case "paused":case "muted":{let l=i.mediaInstances.get(r);return l?l.options[n]:Reflect.get(s,n,a)}default:return Reflect.get(s,n,a)}},set(s,n,a,l){let o=i.mediaInstances.get(r);if(o){let f=a;switch(n){case "volume":o.options[n]=a,f=A(a,t.channelOptions.volume);break;case "muted":o.options[n]=a,t.channelOptions.muted&&(f=true);break;case "paused":o.options[n]=a,t.channelOptions.paused&&(f=true);break;case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":o.options[n]=a;break;}return Reflect.set(s,n,f,l)}return Reflect.set(s,n,a,l)}})}var g=class{constructor(e,t={}){y(this,"alias",e);y(this,"channelOptions",t);y(this,"_transientInstances",new Set);}async play(e,t,s){let n,a;if(typeof t=="string"?(n=e,a=t):(n=e,a=e,s=t),i.mediaInstances.has(n)){let h=i.mediaInstances.get(n);h&&(h.instance.stop(),s={...h.options,...s});}let{paused:l,...o}=s||{},f=!!this.channelOptions.paused||!!l,p=T(n,await sound.sound.play(a,{...o??{},filters:[...this.channelOptions.filters||[],...o?.filters||[]],muted:!!this.channelOptions.muted||!!o?.muted,volume:A(o?.volume,this.channelOptions.volume)}),this);if(p.paused=f,s?.delay){p.paused=true;let h=setTimeout(()=>{p.paused=f,i.delayTimeoutInstances=i.delayTimeoutInstances.filter(m=>m[0]!==h);},s.delay*1e3);i.delayTimeoutInstances.push([h,n]);}return i.mediaInstances.set(n,{channelAlias:this.alias,soundAlias:a,instance:p,stepCounter:core.GameUnifier.stepCounter,options:{volume:s?.volume??1,muted:s?.muted??false,loop:s?.loop??false,...s??{},paused:f}}),p.on("end",()=>{i.mediaInstances.delete(n);}),p}async playTransient(e,t){let{paused:s,...n}=t||{},a=await sound.sound.play(e,{...n,filters:[...this.channelOptions.filters||[],...n?.filters||[]],muted:!!this.channelOptions.muted||!!n?.muted,volume:A(n?.volume,this.channelOptions.volume)}),l=!!s||!!this.channelOptions.paused;a.paused=l;let o;return t?.delay&&(a.paused=true,o=setTimeout(()=>{a.paused=l,o=void 0;},t.delay*1e3)),this._transientInstances.add(a),a.on("end",()=>{o!==void 0&&(clearTimeout(o),o=void 0),this._transientInstances.delete(a);}),a}stopTransientAll(){for(let e of this._transientInstances)e.stop();return this._transientInstances.clear(),this}updateMediaVolume(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.volume??1;e.instance.volume=t;}}get volume(){return this.channelOptions.volume??1}set volume(e){this.channelOptions.volume=e,this.updateMediaVolume();}updateMediaMuted(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.muted??false;e.instance.muted=t;}}get muted(){return this.channelOptions.muted??false}set muted(e){this.channelOptions.muted=e,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((e,t)=>(t.channelAlias===this.alias&&e.push(t.instance),e),[])}get background(){return this.channelOptions.background||false}stopAll(){let e=[];for(let[t,s]of i.mediaInstances.entries())s.channelAlias===this.alias&&(s.instance.stop(),e.push(t));return e.forEach(t=>{i.mediaInstances.delete(t);}),this}pauseAll(){for(let e of i.mediaInstances.values())e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);return this}resumeAll(){for(let e of i.mediaInstances.values())e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);return this}updateMediaPaused(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.paused??false;e.instance.paused=t;}}get paused(){return this.channelOptions.paused??false}set paused(e){this.channelOptions.paused=e,this.updateMediaPaused();}pauseUnsavedAll(){return this.paused=true,this}resumeUnsavedAll(){return this.paused=false,this}};var d;(n=>(n.log=(a,...l)=>console.log(`[Pixi\u2019VN] ${a}`,...l),n.warn=(a,...l)=>console.warn(`[Pixi\u2019VN] ${a}`,...l),n.error=(a,...l)=>console.error(`[Pixi\u2019VN] ${a}`,...l),n.info=(a,...l)=>console.info(`[Pixi\u2019VN] ${a}`,...l)))(d||(d={}));function S(r){let e=[];for(let t of r)t.type==="TelephoneFilter"?e.push(new sound.filters.TelephoneFilter):t.type==="StreamFilter"?e.push(new sound.filters.StreamFilter):t.type==="StereoFilter"?e.push(new sound.filters.StereoFilter(t.pan)):t.type==="ReverbFilter"?e.push(new sound.filters.ReverbFilter(t.seconds,t.decay,t.reverse)):t.type==="MonoFilter"?e.push(new sound.filters.MonoFilter):t.type==="EqualizerFilter"?e.push(new sound.filters.EqualizerFilter(t.f32,t.f64,t.f125,t.f250,t.f500,t.f1k,t.f2k,t.f4k,t.f8k,t.f16k)):t.type==="DistortionFilter"?e.push(new sound.filters.DistortionFilter(t.amount)):d.error("Unknown sound filter type");return e}function M(r){if(!r)return;let e=[];for(let t of r)t instanceof sound.filters.TelephoneFilter?e.push({type:"TelephoneFilter"}):t instanceof sound.filters.StreamFilter?e.push({type:"StreamFilter"}):t instanceof sound.filters.StereoFilter?e.push({type:"StereoFilter",pan:t.pan}):t instanceof sound.filters.ReverbFilter?e.push({type:"ReverbFilter",seconds:t.seconds,decay:t.decay,reverse:t.reverse}):t instanceof sound.filters.MonoFilter?e.push({type:"MonoFilter"}):t instanceof sound.filters.EqualizerFilter?e.push({type:"EqualizerFilter",f32:t.f32,f64:t.f64,f125:t.f125,f250:t.f250,f500:t.f500,f1k:t.f1k,f2k:t.f2k,f4k:t.f4k,f8k:t.f8k,f16k:t.f16k}):t instanceof sound.filters.DistortionFilter?e.push({type:"DistortionFilter",amount:t.amount}):d.error("Unknown sound filter type");return e}function C(r){try{if(typeof r>"u")return r;let e=JSON.stringify(r);return JSON.parse(e)}catch(e){throw d.error("Error creating exportable element",r,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var E=class{constructor(){y(this,"_defaultChannelAlias",O);}get context(){return sound.sound.context}get filtersAll(){return sound.sound.filtersAll}set filtersAll(e){sound.sound.filtersAll=e.filter(t=>!(t instanceof sound.filters.Filter));}get supported(){return sound.sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(e){this._defaultChannelAlias=e;}add(e,t){return sound.sound.add(e,t)}async edit(e,t){let s=sound.sound.find(e);if(!s&&(await this.load(e),s=sound.sound.find(e),!s)){d.error(`Sound with alias ${e} not found after loading.`);return}s.options=t;}get useLegacy(){return sound.sound.useLegacy}set useLegacy(e){sound.sound.useLegacy=e;}get disableAutoPause(){return sound.sound.disableAutoPause}set disableAutoPause(e){sound.sound.disableAutoPause=e;}get volumeAll(){return sound.sound.volumeAll}set volumeAll(e){sound.sound.volumeAll=e;}get speedAll(){return sound.sound.speedAll}set speedAll(e){sound.sound.speedAll=e;}pauseAll(){for(let e of i.mediaInstances.values())e.instance.paused||(e.instance.paused=true);return this}resumeAll(){for(let e of i.mediaInstances.values())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.clear(),sound.sound.stopAll(),this}pauseUnsavedAll(e){if(e!==void 0)this.findChannel(e).pauseUnsavedAll();else for(let t of i.channels.values())t.pauseUnsavedAll();return this}resumeUnsavedAll(e){if(e!==void 0)this.findChannel(e).resumeUnsavedAll();else for(let t of i.channels.values())t.resumeUnsavedAll();return this}stopTransientAll(e){if(e!==void 0)this.findChannel(e).stopTransientAll();else for(let t of i.channels.values())t.stopTransientAll();return this}isPlaying(){return sound.sound.isPlaying()}async play(e,t,s){let n,a;typeof t=="string"?(n=e,a=t):(n=e,a=e,s=t),sound.sound.exists(a)||await this.load(a);let{channel:l=this.defaultChannelAlias,...o}=s??{};return await this.findChannel(l).play(n,a,o)}async playTransient(e,t){sound.sound.exists(e)||await this.load(e);let{channel:s=this.defaultChannelAlias,...n}=t??{};return await this.findChannel(s).playTransient(e,n)}find(e){return i.mediaInstances.get(e)?.instance}stop(e){let t=this.find(e);t?(t.stop(),i.mediaInstances.delete(e)):d.warn(`No media instance found with alias ${e} to stop.`);}pause(e){let t=this.find(e);if(!t){d.warn(`No media instance found with alias ${e} to pause.`);return}return t.paused=true,t}resume(e){let t=this.find(e);if(!t){d.warn(`No media instance found with alias ${e} to resume.`);return}return t.paused=false,t}duration(e){return sound.sound.duration(e)}async load(e){typeof e=="string"&&(e=[e]);let t=e.map(async s=>{let n=await ___default.default.Assets.load(s);return sound.sound.exists(s)||sound.sound.add(s,n),n});return await Promise.all(t)}backgroundLoad(e){let t=___default.default.Assets.backgroundLoad(e);return t.then(()=>{typeof e=="string"&&(e=[e]),e.forEach(s=>{let n=___default.default.Assets.get(s);sound.sound.exists(s)||sound.sound.add(s,n);});}),t}backgroundLoadBundle(e){let t=___default.default.Assets.backgroundLoadBundle(e);return t.then(async()=>{try{let s=await ___default.default.Assets.loadBundle(e);for(let n in s){let a=s[n];a instanceof sound.Sound&&(sound.sound.exists(n)||sound.sound.add(n,a));}}catch(s){d.error("Error loading sound bundle",s);}}),t}clear(){this.stopAll();}addChannel(e,t={}){if(typeof e!="string"){e.forEach(n=>{let a={...t,filters:t.filters?[...t.filters]:t.filters};this.addChannel(n,a);});return}if(i.channels.has(e)){d.warn(`Channel with alias ${e} already exists.`);return}let s=new g(e,t);return i.channels.set(e,s),s}findChannel(e){let t=i.channels.get(e);return t||this.addChannel(e)}get channels(){return Array.from(i.channels.values())}export(){let e=Array.from(i.mediaInstances.entries()).reduce((t,[s,n])=>(t[s]={channelAlias:n.channelAlias,soundAlias:n.soundAlias,stepCounter:n.stepCounter,options:{...n.options,filters:M(n.options.filters)}},t),{});return {mediaInstances:C(e),filters:C(M(this.filtersAll))}}async restore(e){try{if(Object.hasOwn(e,"soundsPlaying")){let t=e.soundsPlaying;if(t){let s=Object.keys(t).map(async n=>{await this.load(n),await this.play(n);});await Promise.all(s);}}if(Object.hasOwn(e,"mediaInstances")){let t=e.mediaInstances;if(t){let s=new Set,n=Object.values(t).map(async({soundAlias:l,channelAlias:o})=>(s.add(o),await this.load(l)));await Promise.all(n),this.channels.forEach(l=>{(!l.background||!s.has(l.alias))&&l.stopAll();});let a=Object.keys(t).map(async l=>{let o=t[l],f=this.findChannel(o.channelAlias),p=o.options.paused??o.paused??!1;if(!f.background)await f.play(l,o.soundAlias,{...o.options,paused:p,filters:S(o.options.filters||[])});else if(o.stepCounter===core.GameUnifier.stepCounter||!this.find(l))await f.play(l,o.soundAlias,{...o.options,paused:p,filters:S(o.options.filters||[])});else {let h=i.mediaInstances.get(l);if(!h){d.warn(`No media instance found with alias ${l} while restoring background state.`);return}let m=h.instance;m.paused!==p&&(m.paused=p),m.loop!==(o.options.loop||!1)&&(m.loop=o.options.loop||!1),m.volume!==(o.options.volume??1)&&(m.volume=o.options.volume??1),m.muted!==(o.options.muted||!1)&&(m.muted=o.options.muted||!1),m.speed!==(o.options.speed??1)&&(m.speed=o.options.speed??1),h.options={...o.options,paused:p,filters:S(o.options.filters||[])};}});await Promise.all(a);}}if(Object.hasOwn(e,"filters")){let t=e.filters;t&&(this.filtersAll=S(t));}}catch(t){d.error("Error importing data",t);}}};var k={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 _e=new E;core.GameUnifier.addOnPreContinue(async()=>{try{i.delayTimeoutInstances.forEach(r=>{clearTimeout(r[0]);let e=i.mediaInstances.get(r[1]);e&&(e.instance.paused=!1);}),i.delayTimeoutInstances=[],i.channels.forEach(r=>{r.background||r.stopAll();});}catch{}});exports.SoundManagerStatic=i;exports.filters=k;exports.sound=_e;
|
package/dist/sound.d.cts
CHANGED
|
@@ -9,6 +9,10 @@ interface SoundPlayOptions extends Omit<PlayOptions, "complete" | "loaded"> {
|
|
|
9
9
|
* The delay in seconds before playback becomes audible or resumes. If specified, the sound will be started immediately but delayed (for example, via pause/unpause) so that it is effectively heard only after the delay. If not specified, the sound will play without any additional delay.
|
|
10
10
|
*/
|
|
11
11
|
delay?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the sound is paused. If specified, the sound will be paused or unpaused according to the value. If not specified, the sound will play without being paused or unpaused.
|
|
14
|
+
*/
|
|
15
|
+
paused?: boolean;
|
|
12
16
|
}
|
|
13
17
|
interface SoundPlayOptionsWithChannel extends SoundPlayOptions {
|
|
14
18
|
/**
|
|
@@ -17,7 +21,7 @@ interface SoundPlayOptionsWithChannel extends SoundPlayOptions {
|
|
|
17
21
|
*/
|
|
18
22
|
channel?: string;
|
|
19
23
|
}
|
|
20
|
-
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume"> {
|
|
24
|
+
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume" | "paused"> {
|
|
21
25
|
/**
|
|
22
26
|
* Whether this channel is a background channel.
|
|
23
27
|
* Background channels are special channels. Unlike normal channels, media connected to a background channel does not stop when a scene changes, but continues to play in the background.
|
|
@@ -49,6 +53,21 @@ interface AudioChannelInterface {
|
|
|
49
53
|
* has not yet loaded.
|
|
50
54
|
*/
|
|
51
55
|
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptions): Promise<IMediaInstance>;
|
|
56
|
+
/**
|
|
57
|
+
* Plays a non-persistent sound on this channel.
|
|
58
|
+
* The returned media is not tracked by the sound manager and is therefore excluded from save/export state.
|
|
59
|
+
* @param soundAlias The sound (asset) alias reference.
|
|
60
|
+
* @param options The options.
|
|
61
|
+
* @return The sound instance.
|
|
62
|
+
*/
|
|
63
|
+
playTransient(soundAlias: string, options?: SoundPlayOptions): Promise<IMediaInstance>;
|
|
64
|
+
/**
|
|
65
|
+
* Stops all media instances that were started with {@link playTransient} on this channel.
|
|
66
|
+
* Instances that have already ended are automatically removed, so this only affects
|
|
67
|
+
* those that are still playing or paused.
|
|
68
|
+
* @return Instance for chaining.
|
|
69
|
+
*/
|
|
70
|
+
stopTransientAll(): this;
|
|
52
71
|
/**
|
|
53
72
|
* The volume of the audio channel, between 0 and 1. This is multiplied with the volume of each sound played through this channel.
|
|
54
73
|
*/
|
|
@@ -76,6 +95,17 @@ interface AudioChannelInterface {
|
|
|
76
95
|
* @return Instance for chaining.
|
|
77
96
|
*/
|
|
78
97
|
pauseAll(): this;
|
|
98
|
+
/**
|
|
99
|
+
* Temporarily pauses this channel without mutating each media instance's persisted paused option.
|
|
100
|
+
* Useful for overlays (for example settings/pause menus) where pause state must not be saved.
|
|
101
|
+
* @return Instance for chaining.
|
|
102
|
+
*/
|
|
103
|
+
pauseUnsavedAll(): this;
|
|
104
|
+
/**
|
|
105
|
+
* Restores this channel after `pauseUnsavedAll()`, reapplying each media instance's persisted paused option.
|
|
106
|
+
* @return Instance for chaining.
|
|
107
|
+
*/
|
|
108
|
+
resumeUnsavedAll(): this;
|
|
79
109
|
/**
|
|
80
110
|
* Resumes any sounds.
|
|
81
111
|
* @return Instance for chaining.
|
|
@@ -157,7 +187,10 @@ interface SoundGameState {
|
|
|
157
187
|
options: Omit<SoundPlayOptions, "filters"> & {
|
|
158
188
|
filters?: SoundFilterMemory[];
|
|
159
189
|
};
|
|
160
|
-
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated Use options.paused instead.
|
|
192
|
+
*/
|
|
193
|
+
paused?: boolean;
|
|
161
194
|
};
|
|
162
195
|
};
|
|
163
196
|
}
|
|
@@ -177,6 +210,22 @@ interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "a
|
|
|
177
210
|
*/
|
|
178
211
|
play(alias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
179
212
|
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
213
|
+
/**
|
|
214
|
+
* Plays a non-persistent sound (for example UI/menu sounds).
|
|
215
|
+
* This playback is not tracked in save/export state.
|
|
216
|
+
* @param alias The sound (asset) alias reference.
|
|
217
|
+
* @param options The options.
|
|
218
|
+
* @return The sound instance.
|
|
219
|
+
*/
|
|
220
|
+
playTransient(alias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
221
|
+
/**
|
|
222
|
+
* Stops all transient media instances started with {@link playTransient}.
|
|
223
|
+
* If `channel` is provided only instances on that channel are stopped;
|
|
224
|
+
* otherwise all channels are affected.
|
|
225
|
+
* @param channel Optional channel alias to limit the operation to.
|
|
226
|
+
* @return Instance for chaining.
|
|
227
|
+
*/
|
|
228
|
+
stopTransientAll(channel?: string): this;
|
|
180
229
|
/**
|
|
181
230
|
* Find a media by alias.
|
|
182
231
|
* @param alias - The media alias reference.
|
|
@@ -215,6 +264,21 @@ interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "a
|
|
|
215
264
|
* @return Instance for chaining.
|
|
216
265
|
*/
|
|
217
266
|
resumeAll(): this;
|
|
267
|
+
/**
|
|
268
|
+
* Temporarily pauses all sounds across all channels (or just the given channel) without
|
|
269
|
+
* mutating each media instance's persisted paused option.
|
|
270
|
+
* Useful for overlays (for example settings/pause menus) where pause state must not be saved.
|
|
271
|
+
* @param channel Optional channel alias to limit the operation to.
|
|
272
|
+
* @return Instance for chaining.
|
|
273
|
+
*/
|
|
274
|
+
pauseUnsavedAll(channel?: string): this;
|
|
275
|
+
/**
|
|
276
|
+
* Restores all channels (or just the given channel) after `pauseUnsavedAll()`,
|
|
277
|
+
* reapplying each media instance's persisted paused option.
|
|
278
|
+
* @param channel Optional channel alias to limit the operation to.
|
|
279
|
+
* @return Instance for chaining.
|
|
280
|
+
*/
|
|
281
|
+
resumeUnsavedAll(channel?: string): this;
|
|
218
282
|
/**
|
|
219
283
|
* Mutes all playing sounds.
|
|
220
284
|
* @return Instance for chaining.
|
|
@@ -271,18 +335,14 @@ declare const filters: {
|
|
|
271
335
|
|
|
272
336
|
declare class SoundManagerStatic {
|
|
273
337
|
private constructor();
|
|
274
|
-
static mediaInstances: {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
};
|
|
283
|
-
static channels: {
|
|
284
|
-
[alias: string]: AudioChannelInterface;
|
|
285
|
-
};
|
|
338
|
+
static mediaInstances: Map<string, {
|
|
339
|
+
channelAlias: string;
|
|
340
|
+
soundAlias: string;
|
|
341
|
+
instance: IMediaInstance;
|
|
342
|
+
stepCounter: number;
|
|
343
|
+
options: SoundPlayOptions;
|
|
344
|
+
}>;
|
|
345
|
+
static readonly channels: Map<string, AudioChannelInterface>;
|
|
286
346
|
static delayTimeoutInstances: [number | NodeJS.Timeout, string][];
|
|
287
347
|
}
|
|
288
348
|
|
package/dist/sound.d.ts
CHANGED
|
@@ -9,6 +9,10 @@ interface SoundPlayOptions extends Omit<PlayOptions, "complete" | "loaded"> {
|
|
|
9
9
|
* The delay in seconds before playback becomes audible or resumes. If specified, the sound will be started immediately but delayed (for example, via pause/unpause) so that it is effectively heard only after the delay. If not specified, the sound will play without any additional delay.
|
|
10
10
|
*/
|
|
11
11
|
delay?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the sound is paused. If specified, the sound will be paused or unpaused according to the value. If not specified, the sound will play without being paused or unpaused.
|
|
14
|
+
*/
|
|
15
|
+
paused?: boolean;
|
|
12
16
|
}
|
|
13
17
|
interface SoundPlayOptionsWithChannel extends SoundPlayOptions {
|
|
14
18
|
/**
|
|
@@ -17,7 +21,7 @@ interface SoundPlayOptionsWithChannel extends SoundPlayOptions {
|
|
|
17
21
|
*/
|
|
18
22
|
channel?: string;
|
|
19
23
|
}
|
|
20
|
-
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume"> {
|
|
24
|
+
interface ChannelOptions extends Pick<SoundPlayOptions, "filters" | "muted" | "volume" | "paused"> {
|
|
21
25
|
/**
|
|
22
26
|
* Whether this channel is a background channel.
|
|
23
27
|
* Background channels are special channels. Unlike normal channels, media connected to a background channel does not stop when a scene changes, but continues to play in the background.
|
|
@@ -49,6 +53,21 @@ interface AudioChannelInterface {
|
|
|
49
53
|
* has not yet loaded.
|
|
50
54
|
*/
|
|
51
55
|
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptions): Promise<IMediaInstance>;
|
|
56
|
+
/**
|
|
57
|
+
* Plays a non-persistent sound on this channel.
|
|
58
|
+
* The returned media is not tracked by the sound manager and is therefore excluded from save/export state.
|
|
59
|
+
* @param soundAlias The sound (asset) alias reference.
|
|
60
|
+
* @param options The options.
|
|
61
|
+
* @return The sound instance.
|
|
62
|
+
*/
|
|
63
|
+
playTransient(soundAlias: string, options?: SoundPlayOptions): Promise<IMediaInstance>;
|
|
64
|
+
/**
|
|
65
|
+
* Stops all media instances that were started with {@link playTransient} on this channel.
|
|
66
|
+
* Instances that have already ended are automatically removed, so this only affects
|
|
67
|
+
* those that are still playing or paused.
|
|
68
|
+
* @return Instance for chaining.
|
|
69
|
+
*/
|
|
70
|
+
stopTransientAll(): this;
|
|
52
71
|
/**
|
|
53
72
|
* The volume of the audio channel, between 0 and 1. This is multiplied with the volume of each sound played through this channel.
|
|
54
73
|
*/
|
|
@@ -76,6 +95,17 @@ interface AudioChannelInterface {
|
|
|
76
95
|
* @return Instance for chaining.
|
|
77
96
|
*/
|
|
78
97
|
pauseAll(): this;
|
|
98
|
+
/**
|
|
99
|
+
* Temporarily pauses this channel without mutating each media instance's persisted paused option.
|
|
100
|
+
* Useful for overlays (for example settings/pause menus) where pause state must not be saved.
|
|
101
|
+
* @return Instance for chaining.
|
|
102
|
+
*/
|
|
103
|
+
pauseUnsavedAll(): this;
|
|
104
|
+
/**
|
|
105
|
+
* Restores this channel after `pauseUnsavedAll()`, reapplying each media instance's persisted paused option.
|
|
106
|
+
* @return Instance for chaining.
|
|
107
|
+
*/
|
|
108
|
+
resumeUnsavedAll(): this;
|
|
79
109
|
/**
|
|
80
110
|
* Resumes any sounds.
|
|
81
111
|
* @return Instance for chaining.
|
|
@@ -157,7 +187,10 @@ interface SoundGameState {
|
|
|
157
187
|
options: Omit<SoundPlayOptions, "filters"> & {
|
|
158
188
|
filters?: SoundFilterMemory[];
|
|
159
189
|
};
|
|
160
|
-
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated Use options.paused instead.
|
|
192
|
+
*/
|
|
193
|
+
paused?: boolean;
|
|
161
194
|
};
|
|
162
195
|
};
|
|
163
196
|
}
|
|
@@ -177,6 +210,22 @@ interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "a
|
|
|
177
210
|
*/
|
|
178
211
|
play(alias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
179
212
|
play(mediaAlias: string, soundAlias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
213
|
+
/**
|
|
214
|
+
* Plays a non-persistent sound (for example UI/menu sounds).
|
|
215
|
+
* This playback is not tracked in save/export state.
|
|
216
|
+
* @param alias The sound (asset) alias reference.
|
|
217
|
+
* @param options The options.
|
|
218
|
+
* @return The sound instance.
|
|
219
|
+
*/
|
|
220
|
+
playTransient(alias: string, options?: SoundPlayOptionsWithChannel): Promise<IMediaInstance>;
|
|
221
|
+
/**
|
|
222
|
+
* Stops all transient media instances started with {@link playTransient}.
|
|
223
|
+
* If `channel` is provided only instances on that channel are stopped;
|
|
224
|
+
* otherwise all channels are affected.
|
|
225
|
+
* @param channel Optional channel alias to limit the operation to.
|
|
226
|
+
* @return Instance for chaining.
|
|
227
|
+
*/
|
|
228
|
+
stopTransientAll(channel?: string): this;
|
|
180
229
|
/**
|
|
181
230
|
* Find a media by alias.
|
|
182
231
|
* @param alias - The media alias reference.
|
|
@@ -215,6 +264,21 @@ interface SoundManagerInterface extends Omit<SoundLibrary, "init" | "close" | "a
|
|
|
215
264
|
* @return Instance for chaining.
|
|
216
265
|
*/
|
|
217
266
|
resumeAll(): this;
|
|
267
|
+
/**
|
|
268
|
+
* Temporarily pauses all sounds across all channels (or just the given channel) without
|
|
269
|
+
* mutating each media instance's persisted paused option.
|
|
270
|
+
* Useful for overlays (for example settings/pause menus) where pause state must not be saved.
|
|
271
|
+
* @param channel Optional channel alias to limit the operation to.
|
|
272
|
+
* @return Instance for chaining.
|
|
273
|
+
*/
|
|
274
|
+
pauseUnsavedAll(channel?: string): this;
|
|
275
|
+
/**
|
|
276
|
+
* Restores all channels (or just the given channel) after `pauseUnsavedAll()`,
|
|
277
|
+
* reapplying each media instance's persisted paused option.
|
|
278
|
+
* @param channel Optional channel alias to limit the operation to.
|
|
279
|
+
* @return Instance for chaining.
|
|
280
|
+
*/
|
|
281
|
+
resumeUnsavedAll(channel?: string): this;
|
|
218
282
|
/**
|
|
219
283
|
* Mutes all playing sounds.
|
|
220
284
|
* @return Instance for chaining.
|
|
@@ -271,18 +335,14 @@ declare const filters: {
|
|
|
271
335
|
|
|
272
336
|
declare class SoundManagerStatic {
|
|
273
337
|
private constructor();
|
|
274
|
-
static mediaInstances: {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
};
|
|
283
|
-
static channels: {
|
|
284
|
-
[alias: string]: AudioChannelInterface;
|
|
285
|
-
};
|
|
338
|
+
static mediaInstances: Map<string, {
|
|
339
|
+
channelAlias: string;
|
|
340
|
+
soundAlias: string;
|
|
341
|
+
instance: IMediaInstance;
|
|
342
|
+
stepCounter: number;
|
|
343
|
+
options: SoundPlayOptions;
|
|
344
|
+
}>;
|
|
345
|
+
static readonly channels: Map<string, AudioChannelInterface>;
|
|
286
346
|
static delayTimeoutInstances: [number | NodeJS.Timeout, string][];
|
|
287
347
|
}
|
|
288
348
|
|
package/dist/sound.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {d,j,k}from'./chunk-HNGW4ITF.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import M from'@drincs/pixi-vn/pixi.js';import {filters,sound,Sound}from'@pixi/sound';function g(u,e){return u===void 0&&e===void 0?1:e===void 0?u:u===void 0?e:u*e}var i=class{constructor(){}};d(i,"mediaInstances",new Map),d(i,"channels",new Map),d(i,"delayTimeoutInstances",[]);function P(u,e,t){return new Proxy(e,{get(n,s,o){switch(s){case "volume":case "paused":case "muted":{let l=i.mediaInstances.get(u);return l?l.options[s]:Reflect.get(n,s,o)}default:return Reflect.get(n,s,o)}},set(n,s,o,l){let a=i.mediaInstances.get(u);if(a){let f=o;switch(s){case "volume":a.options[s]=o,f=g(o,t.channelOptions.volume);break;case "muted":a.options[s]=o,t.channelOptions.muted&&(f=true);break;case "paused":a.options[s]=o,t.channelOptions.paused&&(f=true);break;case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":a.options[s]=o;break;}return Reflect.set(n,s,f,l)}return Reflect.set(n,s,o,l)}})}var A=class{constructor(e,t={}){d(this,"alias",e);d(this,"channelOptions",t);d(this,"_transientInstances",new Set);}async play(e,t,n){let s,o;if(typeof t=="string"?(s=e,o=t):(s=e,o=e,n=t),i.mediaInstances.has(s)){let h=i.mediaInstances.get(s);h&&(h.instance.stop(),n={...h.options,...n});}let{paused:l,...a}=n||{},f=!!this.channelOptions.paused||!!l,c=P(s,await sound.play(o,{...a??{},filters:[...this.channelOptions.filters||[],...a?.filters||[]],muted:!!this.channelOptions.muted||!!a?.muted,volume:g(a?.volume,this.channelOptions.volume)}),this);if(c.paused=f,n?.delay){c.paused=true;let h=setTimeout(()=>{c.paused=f,i.delayTimeoutInstances=i.delayTimeoutInstances.filter(p=>p[0]!==h);},n.delay*1e3);i.delayTimeoutInstances.push([h,s]);}return i.mediaInstances.set(s,{channelAlias:this.alias,soundAlias:o,instance:c,stepCounter:GameUnifier.stepCounter,options:{volume:n?.volume??1,muted:n?.muted??false,loop:n?.loop??false,...n??{},paused:f}}),c.on("end",()=>{i.mediaInstances.delete(s);}),c}async playTransient(e,t){let{paused:n,...s}=t||{},o=await sound.play(e,{...s,filters:[...this.channelOptions.filters||[],...s?.filters||[]],muted:!!this.channelOptions.muted||!!s?.muted,volume:g(s?.volume,this.channelOptions.volume)}),l=!!n||!!this.channelOptions.paused;o.paused=l;let a;return t?.delay&&(o.paused=true,a=setTimeout(()=>{o.paused=l,a=void 0;},t.delay*1e3)),this._transientInstances.add(o),o.on("end",()=>{a!==void 0&&(clearTimeout(a),a=void 0),this._transientInstances.delete(o);}),o}stopTransientAll(){for(let e of this._transientInstances)e.stop();return this._transientInstances.clear(),this}updateMediaVolume(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.volume??1;e.instance.volume=t;}}get volume(){return this.channelOptions.volume??1}set volume(e){this.channelOptions.volume=e,this.updateMediaVolume();}updateMediaMuted(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.muted??false;e.instance.muted=t;}}get muted(){return this.channelOptions.muted??false}set muted(e){this.channelOptions.muted=e,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((e,t)=>(t.channelAlias===this.alias&&e.push(t.instance),e),[])}get background(){return this.channelOptions.background||false}stopAll(){let e=[];for(let[t,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.instance.stop(),e.push(t));return e.forEach(t=>{i.mediaInstances.delete(t);}),this}pauseAll(){for(let e of i.mediaInstances.values())e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);return this}resumeAll(){for(let e of i.mediaInstances.values())e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);return this}updateMediaPaused(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.paused??false;e.instance.paused=t;}}get paused(){return this.channelOptions.paused??false}set paused(e){this.channelOptions.paused=e,this.updateMediaPaused();}pauseUnsavedAll(){return this.paused=true,this}resumeUnsavedAll(){return this.paused=false,this}};function S(u){let e=[];for(let t of u)t.type==="TelephoneFilter"?e.push(new filters.TelephoneFilter):t.type==="StreamFilter"?e.push(new filters.StreamFilter):t.type==="StereoFilter"?e.push(new filters.StereoFilter(t.pan)):t.type==="ReverbFilter"?e.push(new filters.ReverbFilter(t.seconds,t.decay,t.reverse)):t.type==="MonoFilter"?e.push(new filters.MonoFilter):t.type==="EqualizerFilter"?e.push(new filters.EqualizerFilter(t.f32,t.f64,t.f125,t.f250,t.f500,t.f1k,t.f2k,t.f4k,t.f8k,t.f16k)):t.type==="DistortionFilter"?e.push(new filters.DistortionFilter(t.amount)):j.error("Unknown sound filter type");return e}function b(u){if(!u)return;let e=[];for(let t of u)t instanceof filters.TelephoneFilter?e.push({type:"TelephoneFilter"}):t instanceof filters.StreamFilter?e.push({type:"StreamFilter"}):t instanceof filters.StereoFilter?e.push({type:"StereoFilter",pan:t.pan}):t instanceof filters.ReverbFilter?e.push({type:"ReverbFilter",seconds:t.seconds,decay:t.decay,reverse:t.reverse}):t instanceof filters.MonoFilter?e.push({type:"MonoFilter"}):t instanceof filters.EqualizerFilter?e.push({type:"EqualizerFilter",f32:t.f32,f64:t.f64,f125:t.f125,f250:t.f250,f500:t.f500,f1k:t.f1k,f2k:t.f2k,f4k:t.f4k,f8k:t.f8k,f16k:t.f16k}):t instanceof filters.DistortionFilter?e.push({type:"DistortionFilter",amount:t.amount}):j.error("Unknown sound filter type");return e}var F=class{constructor(){d(this,"_defaultChannelAlias",i$1);}get context(){return sound.context}get filtersAll(){return sound.filtersAll}set filtersAll(e){sound.filtersAll=e.filter(t=>!(t instanceof filters.Filter));}get supported(){return sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(e){this._defaultChannelAlias=e;}add(e,t){return sound.add(e,t)}async edit(e,t){let n=sound.find(e);if(!n&&(await this.load(e),n=sound.find(e),!n)){j.error(`Sound with alias ${e} not found after loading.`);return}n.options=t;}get useLegacy(){return sound.useLegacy}set useLegacy(e){sound.useLegacy=e;}get disableAutoPause(){return sound.disableAutoPause}set disableAutoPause(e){sound.disableAutoPause=e;}get volumeAll(){return sound.volumeAll}set volumeAll(e){sound.volumeAll=e;}get speedAll(){return sound.speedAll}set speedAll(e){sound.speedAll=e;}pauseAll(){for(let e of i.mediaInstances.values())e.instance.paused||(e.instance.paused=true);return this}resumeAll(){for(let e of i.mediaInstances.values())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 i.mediaInstances.clear(),sound.stopAll(),this}pauseUnsavedAll(e){if(e!==void 0)this.findChannel(e).pauseUnsavedAll();else for(let t of i.channels.values())t.pauseUnsavedAll();return this}resumeUnsavedAll(e){if(e!==void 0)this.findChannel(e).resumeUnsavedAll();else for(let t of i.channels.values())t.resumeUnsavedAll();return this}stopTransientAll(e){if(e!==void 0)this.findChannel(e).stopTransientAll();else for(let t of i.channels.values())t.stopTransientAll();return this}isPlaying(){return sound.isPlaying()}async play(e,t,n){let s,o;typeof t=="string"?(s=e,o=t):(s=e,o=e,n=t),sound.exists(o)||await this.load(o);let{channel:l=this.defaultChannelAlias,...a}=n??{};return await this.findChannel(l).play(s,o,a)}async playTransient(e,t){sound.exists(e)||await this.load(e);let{channel:n=this.defaultChannelAlias,...s}=t??{};return await this.findChannel(n).playTransient(e,s)}find(e){return i.mediaInstances.get(e)?.instance}stop(e){let t=this.find(e);t?(t.stop(),i.mediaInstances.delete(e)):j.warn(`No media instance found with alias ${e} to stop.`);}pause(e){let t=this.find(e);if(!t){j.warn(`No media instance found with alias ${e} to pause.`);return}return t.paused=true,t}resume(e){let t=this.find(e);if(!t){j.warn(`No media instance found with alias ${e} to resume.`);return}return t.paused=false,t}duration(e){return sound.duration(e)}async load(e){typeof e=="string"&&(e=[e]);let t=e.map(async n=>{let s=await M.Assets.load(n);return sound.exists(n)||sound.add(n,s),s});return await Promise.all(t)}backgroundLoad(e){let t=M.Assets.backgroundLoad(e);return t.then(()=>{typeof e=="string"&&(e=[e]),e.forEach(n=>{let s=M.Assets.get(n);sound.exists(n)||sound.add(n,s);});}),t}backgroundLoadBundle(e){let t=M.Assets.backgroundLoadBundle(e);return t.then(async()=>{try{let n=await M.Assets.loadBundle(e);for(let s in n){let o=n[s];o instanceof Sound&&(sound.exists(s)||sound.add(s,o));}}catch(n){j.error("Error loading sound bundle",n);}}),t}clear(){this.stopAll();}addChannel(e,t={}){if(typeof e!="string"){e.forEach(s=>{let o={...t,filters:t.filters?[...t.filters]:t.filters};this.addChannel(s,o);});return}if(i.channels.has(e)){j.warn(`Channel with alias ${e} already exists.`);return}let n=new A(e,t);return i.channels.set(e,n),n}findChannel(e){let t=i.channels.get(e);return t||this.addChannel(e)}get channels(){return Array.from(i.channels.values())}export(){let e=Array.from(i.mediaInstances.entries()).reduce((t,[n,s])=>(t[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,options:{...s.options,filters:b(s.options.filters)}},t),{});return {mediaInstances:k(e),filters:k(b(this.filtersAll))}}async restore(e){try{if(Object.hasOwn(e,"soundsPlaying")){let t=e.soundsPlaying;if(t){let n=Object.keys(t).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(e,"mediaInstances")){let t=e.mediaInstances;if(t){let n=new Set,s=Object.values(t).map(async({soundAlias:l,channelAlias:a})=>(n.add(a),await this.load(l)));await Promise.all(s),this.channels.forEach(l=>{(!l.background||!n.has(l.alias))&&l.stopAll();});let o=Object.keys(t).map(async l=>{let a=t[l],f=this.findChannel(a.channelAlias),c=a.options.paused??a.paused??!1;if(!f.background)await f.play(l,a.soundAlias,{...a.options,paused:c,filters:S(a.options.filters||[])});else if(a.stepCounter===GameUnifier.stepCounter||!this.find(l))await f.play(l,a.soundAlias,{...a.options,paused:c,filters:S(a.options.filters||[])});else {let h=i.mediaInstances.get(l);if(!h){j.warn(`No media instance found with alias ${l} while restoring background state.`);return}let p=h.instance;p.paused!==c&&(p.paused=c),p.loop!==(a.options.loop||!1)&&(p.loop=a.options.loop||!1),p.volume!==(a.options.volume??1)&&(p.volume=a.options.volume??1),p.muted!==(a.options.muted||!1)&&(p.muted=a.options.muted||!1),p.speed!==(a.options.speed??1)&&(p.speed=a.options.speed??1),h.options={...a.options,paused:c,filters:S(a.options.filters||[])};}});await Promise.all(o);}}if(Object.hasOwn(e,"filters")){let t=e.filters;t&&(this.filtersAll=S(t));}}catch(t){j.error("Error importing data",t);}}};var E={DistortionFilter:filters.DistortionFilter,EqualizerFilter:filters.EqualizerFilter,MonoFilter:filters.MonoFilter,ReverbFilter:filters.ReverbFilter,StereoFilter:filters.StereoFilter,StreamFilter:filters.StreamFilter,TelephoneFilter:filters.TelephoneFilter};var ce=new F;GameUnifier.addOnPreContinue(async()=>{try{i.delayTimeoutInstances.forEach(u=>{clearTimeout(u[0]);let e=i.mediaInstances.get(u[1]);e&&(e.instance.paused=!1);}),i.delayTimeoutInstances=[],i.channels.forEach(u=>{u.background||u.stopAll();});}catch{}});export{i as SoundManagerStatic,E as filters,ce as sound};
|
package/dist/storage.cjs
CHANGED
|
@@ -1 +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,bt,Tt,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,T,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,bt);g(this,Tt);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:b,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=b,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,Tt,I),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,bt,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,T).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,bt)}get memoMethod(){return t(this,Tt)}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,T).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,T).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,T).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,T).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,T).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,T).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,T).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,T).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,T).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,T).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,T).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 b=t(this,_)[S];if(i!==b){if(t(this,lt)&&h(this,n,T).call(this,b)){b.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=b;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,b,e,"set")),t(this,M)&&t(this,x)?.push([b,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=b&&h(this,n,T).call(this,b)?b.__staleWhileFetching:b;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");t(this,At)&&this.onInsert?.(i,e,i===b?"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 b=t(this,x),p;for(;p=b?.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,T).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,T).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,T).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:b=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,T).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(!b&&!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,Tt);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,T).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,bt=new WeakMap,Tt=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,T).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,T).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,T).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,b=false)=>{let{aborted:p}=a.signal,I=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!b?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!I&&!b)return S(a.signal.reason,L);let F=K,v=t(this,_)[i];return (v===K||I&&b&&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,b)=>{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||!b&&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,b)=>{var I;let p=(I=t(this,bt))==null?void 0:I.call(this,e,o,c);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),b),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},T=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,T).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,T).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;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var jt=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var E=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),Ut=(u,e,i)=>e.has(u)||jt("Cannot "+i);var t=(u,e,i)=>(Ut(u,e,"read from private field"),i?i.call(u):e.get(u)),d=(u,e,i)=>e.has(u)?jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(Ut(u,e,"write to private field"),e.set(u,i),i),l=(u,e,i)=>(Ut(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,e,s)}});var st="storage",ht="temp",H="narration",Nt="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ct;(r=>(r.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),r.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),r.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),r.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(ct||(ct={}));function Ot(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw ct.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,zt=typeof process=="object"&&process?process:{},Jt=(u,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Gt=globalThis.AbortController,$t=globalThis.AbortSignal;if(typeof Gt>"u"){$t=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){E(this,"signal",new $t);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let u=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,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 rt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),qt=u=>rt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(u){super(u),this.fill(0);}},et,St,oe=(et=class{constructor(e,i){E(this,"heap");E(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,d(et,St,false),et),kt,Bt,$,z,k,ut,B,mt,Et,X,D,J,R,w,p,V,Y,C,N,q,F,Q,Z,P,K,tt,lt,L,Tt,n,Yt,ft,it,xt,W,Zt,pt,bt,Rt,ot,at,Pt,Ct,Mt,O,Kt,wt,nt,Wt,yt,Qt=(yt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ut);d(this,B);d(this,mt);d(this,Et);d(this,X);E(this,"ttl");E(this,"ttlResolution");E(this,"ttlAutopurge");E(this,"updateAgeOnGet");E(this,"updateAgeOnHas");E(this,"allowStale");E(this,"noDisposeOnSet");E(this,"noUpdateTTL");E(this,"maxEntrySize");E(this,"sizeCalculation");E(this,"noDeleteOnFetchRejection");E(this,"noDeleteOnStaleGet");E(this,"allowStaleOnFetchAbort");E(this,"allowStaleOnFetchRejection");E(this,"ignoreFetchAbort");d(this,D);d(this,J);d(this,R);d(this,w);d(this,p);d(this,V);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,P);d(this,K);d(this,tt);d(this,lt);d(this,L);d(this,Tt);d(this,ft,()=>{});d(this,it,()=>{});d(this,xt,()=>{});d(this,W,()=>false);d(this,pt,e=>{});d(this,bt,(e,i,s)=>{});d(this,Rt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});E(this,kt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:I,disposeAfter:_,noDisposeOnSet:y,noUpdateTTL:b,maxSize:T=0,maxEntrySize:A=0,sizeCalculation:v,fetchMethod:g,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:vt,ignoreFetchAbort:_t,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,gt??se),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?qt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,z,T),this.maxEntrySize=A||t(this,z),this.sizeCalculation=v,this.sizeCalculation){if(!t(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Et,M),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,mt,g),f(this,lt,!!g),f(this,R,new Map),f(this,w,new Array(i).fill(void 0)),f(this,p,new Array(i).fill(void 0)),f(this,V,new dt(i)),f(this,Y,new dt(i)),f(this,C,0),f(this,N,0),f(this,q,oe.create(i)),f(this,D,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof I=="function"&&f(this,ut,I),typeof _=="function"?(f(this,B,_),f(this,F,[])):(f(this,B,void 0),f(this,F,void 0)),f(this,tt,!!t(this,k)),f(this,Tt,!!t(this,ut)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!_t,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Zt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!a,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Lt="LRU_CACHE_UNBOUNDED";re(Lt)&&(Xt.add(Lt),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Lt,yt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,P),autopurgeTimers:t(e,K),sizes:t(e,Q),keyMap:t(e,R),keyList:t(e,w),valList:t(e,p),next:t(e,V),prev:t(e,Y),get head(){return t(e,C)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,O).call(s,i)},backgroundFetch:(i,s,r,a)=>{var o;return l(o=e,n,Mt).call(o,i,s,r,a)},moveToTail:i=>{var s;return l(s=e,n,wt).call(s,i)},indexes:i=>{var s;return l(s=e,n,ot).call(s,i)},rindexes:i=>{var s;return l(s=e,n,at).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,D)}get fetchMethod(){return t(this,mt)}get memoMethod(){return t(this,Et)}get dispose(){return t(this,k)}get onInsert(){return t(this,ut)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&t(this,w)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield [t(this,w)[e],t(this,p)[e]]);}*rentries(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&t(this,w)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield [t(this,w)[e],t(this,p)[e]]);}*keys(){for(let e of l(this,n,ot).call(this)){let i=t(this,w)[e];i!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,at).call(this)){let i=t(this,w)[e];i!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield i);}}*values(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}*rvalues(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}[(Bt=Symbol.iterator,kt=Symbol.toStringTag,Bt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(a!==void 0&&e(a,t(this,w)[s],this))return this.get(t(this,w)[s],i)}}forEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&e.call(i,a,t(this,w)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&e.call(i,a,t(this,w)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,at).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,w)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,p)[i],r=l(this,n,O).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let a={value:r};if(t(this,P)&&t(this,Z)){let o=t(this,P)[i],h=t(this,Z)[i];if(o&&h){let c=o-(t(this,X).now()-h);a.ttl=c,a.start=Date.now();}}return t(this,Q)&&(a.size=t(this,Q)[i]),a}dump(){let e=[];for(let i of l(this,n,ot).call(this,{allowStale:true})){let s=t(this,w)[i],r=t(this,p)[i],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(a===void 0||s===void 0)continue;let o={value:a};if(t(this,P)&&t(this,Z)){o.ttl=t(this,P)[i];let h=t(this,X).now()-t(this,Z)[i];o.start=Math.floor(Date.now()-h);}t(this,Q)&&(o.size=t(this,Q)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var y,b,T,A;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:m=this.noUpdateTTL}=s,I=t(this,Rt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let _=t(this,D)===0?void 0:t(this,R).get(e);if(_===void 0)_=t(this,D)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,D)===t(this,$)?l(this,n,Ct).call(this,false):t(this,D),t(this,w)[_]=e,t(this,p)[_]=i,t(this,R).set(e,_),t(this,V)[t(this,N)]=_,t(this,Y)[_]=t(this,N),f(this,N,_),It(this,D)._++,t(this,bt).call(this,_,I,c),c&&(c.set="add"),m=false,t(this,Tt)&&((y=t(this,ut))==null||y.call(this,i,e,"add"));else {l(this,n,wt).call(this,_);let v=t(this,p)[_];if(i!==v){if(t(this,lt)&&l(this,n,O).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=v;g!==void 0&&!o&&(t(this,tt)&&((b=t(this,k))==null||b.call(this,g,e,"set")),t(this,L)&&t(this,F)?.push([g,e,"set"]));}else o||(t(this,tt)&&((T=t(this,k))==null||T.call(this,v,e,"set")),t(this,L)&&t(this,F)?.push([v,e,"set"]));if(t(this,pt).call(this,_),t(this,bt).call(this,_,I,c),t(this,p)[_]=i,c){c.set="replace";let g=v&&l(this,n,O).call(this,v)?v.__staleWhileFetching:v;g!==void 0&&(c.oldValue=g);}}else c&&(c.set="update");t(this,Tt)&&this.onInsert?.(i,e,i===v?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(m||t(this,xt).call(this,_,r,a),c&&t(this,it).call(this,c,_)),!o&&t(this,L)&&t(this,F)){let v=t(this,F),g;for(;g=v?.shift();)(A=t(this,B))==null||A.call(this,...g);}return this}pop(){var e;try{for(;t(this,D);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,O).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,a=t(this,R).get(e);if(a!==void 0){let o=t(this,p)[a];if(l(this,n,O).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,a))r&&(r.has="stale",t(this,it).call(this,r,a));else return s&&t(this,ft).call(this,a),r&&(r.has="hit",t(this,it).call(this,r,a)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,R).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let a=t(this,p)[r];return l(this,n,O).call(this,a)?a.__staleWhileFetching:a}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:m=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:A,forceRefresh:v=false,status:g,signal:M}=i;if(!t(this,lt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,status:g});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:h,size:c,sizeCalculation:m,noUpdateTTL:I,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:g,signal:M},G=t(this,R).get(e);if(G===void 0){g&&(g.fetch="miss");let x=l(this,n,Mt).call(this,e,G,U,A);return x.__returned=x}else {let x=t(this,p)[G];if(l(this,n,O).call(this,x)){let dt=s&&x.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",dt&&(g.returnedStale=true)),dt?x.__staleWhileFetching:x.__returned=x}let vt=t(this,W).call(this,G);if(!v&&!vt)return g&&(g.fetch="hit"),l(this,n,wt).call(this,G),r&&t(this,ft).call(this,G),g&&t(this,it).call(this,g,G),x;let _t=l(this,n,Mt).call(this,e,G,U,A),gt=_t.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=vt?"stale":"refresh",gt&&vt&&(g.returnedStale=true)),gt?_t.__staleWhileFetching:_t.__returned=_t}}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,Et);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:a,...o}=i,h=this.get(e,o);if(!a&&h!==void 0)return h;let c=s(e,h,{options:o,context:r});return this.set(e,c,o),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=i,h=t(this,R).get(e);if(h!==void 0){let c=t(this,p)[h],m=l(this,n,O).call(this,c);return o&&t(this,it).call(this,o,h),t(this,W).call(this,h)?(o&&(o.get="stale"),m?(o&&s&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?c.__staleWhileFetching:void 0):(a||l(this,n,nt).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?c:void 0)):(o&&(o.get="hit"),m?c.__staleWhileFetching:(l(this,n,wt).call(this,h),r&&t(this,ft).call(this,h),c))}else o&&(o.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ut=new WeakMap,B=new WeakMap,mt=new WeakMap,Et=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,R=new WeakMap,w=new WeakMap,p=new WeakMap,V=new WeakMap,Y=new WeakMap,C=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,K=new WeakMap,tt=new WeakMap,lt=new WeakMap,L=new WeakMap,Tt=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));f(this,P,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,K,s),f(this,xt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ft,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,w)[h],"expire");},c+1);m.unref&&m.unref(),s[h]=m;}}:()=>{};f(this,it,(h,c)=>{if(e[c]){let m=e[c],I=i[c];if(!m||!I)return;h.ttl=m,h.start=I,h.now=a||o();let _=h.now-I;h.remainingTTL=m-_;}});let a=0,o=()=>{let h=t(this,X).now();if(this.ttlResolution>0){a=h;let c=setTimeout(()=>a=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,R).get(h);if(c===void 0)return 0;let m=e[c],I=i[c];if(!m||!I)return 1/0;let _=(a||o())-I;return m-_},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(a||o())-c>m});},ft=new WeakMap,it=new WeakMap,xt=new WeakMap,W=new WeakMap,Zt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,pt,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,Rt,(i,s,r,a)=>{if(l(this,n,O).call(this,s))return 0;if(!rt(r))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(r=a(s,i),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),f(this,bt,(i,s,r)=>{if(e[i]=s,t(this,z)){let a=t(this,z)-e[i];for(;t(this,J)>a;)l(this,n,Ct).call(this,true);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},pt=new WeakMap,bt=new WeakMap,Rt=new WeakMap,ot=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,N);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,Y)[i];},at=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,C);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,V)[i];},Pt=function(e){return e!==void 0&&t(this,R).get(t(this,w)[e])===e},Ct=function(e){var a;let i=t(this,C),s=t(this,w)[i],r=t(this,p)[i];return t(this,lt)&&l(this,n,O).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((a=t(this,k))==null||a.call(this,r,s,"evict")),t(this,L)&&t(this,F)?.push([r,s,"evict"])),t(this,pt).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,w)[i]=void 0,t(this,p)[i]=void 0,t(this,q).push(i)),t(this,D)===1?(f(this,C,f(this,N,0)),t(this,q).length=0):f(this,C,t(this,V)[i]),t(this,R).delete(s),It(this,D)._--,i},Mt=function(e,i,s,r){let a=i===void 0?void 0:t(this,p)[i];if(l(this,n,O).call(this,a))return a;let o=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let c={signal:o.signal,options:s,context:r},m=(A,v=false)=>{let{aborted:g}=o.signal,M=s.ignoreFetchAbort&&A!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(g&&!v?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!M&&!v)return _(o.signal.reason,U);let G=b,x=t(this,p)[i];return (x===b||M&&v&&x===void 0)&&(A===void 0?G.__staleWhileFetching!==void 0?t(this,p)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,A,c.options))),A},I=A=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=A),_(A,false)),_=(A,v)=>{let{aborted:g}=o.signal,M=g&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,x=b;if(t(this,p)[i]===b&&(!G||!v&&x.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,p)[i]=x.__staleWhileFetching)),U)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw A},y=(A,v)=>{var M;let g=(M=t(this,mt))==null?void 0:M.call(this,e,a,c);g&&g instanceof Promise&&g.then(U=>A(U===void 0?void 0:U),v),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(A(void 0),s.allowStaleOnFetchAbort&&(A=U=>m(U,true)));});};s.status&&(s.status.fetchDispatched=true);let b=new Promise(y).then(m,I),T=Object.assign(b,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return i===void 0?(this.set(e,T,{...c.options,status:void 0}),i=t(this,R).get(e)):t(this,p)[i]=T,T},O=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Kt=function(e,i){t(this,Y)[i]=e,t(this,V)[e]=i;},wt=function(e){e!==t(this,N)&&(e===t(this,C)?f(this,C,t(this,V)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,V)[e]),l(this,n,Kt).call(this,t(this,N),e),f(this,N,e));},nt=function(e,i){var r,a;let s=false;if(t(this,D)!==0){let o=t(this,R).get(e);if(o!==void 0)if(t(this,K)?.[o]&&(clearTimeout(t(this,K)?.[o]),t(this,K)[o]=void 0),s=true,t(this,D)===1)l(this,n,Wt).call(this,i);else {t(this,pt).call(this,o);let h=t(this,p)[o];if(l(this,n,O).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,L)&&t(this,F)?.push([h,e,i])),t(this,R).delete(e),t(this,w)[o]=void 0,t(this,p)[o]=void 0,o===t(this,N))f(this,N,t(this,Y)[o]);else if(o===t(this,C))f(this,C,t(this,V)[o]);else {let c=t(this,Y)[o];t(this,V)[c]=t(this,V)[o];let m=t(this,V)[o];t(this,Y)[m]=t(this,Y)[o];}It(this,D)._--,t(this,q).push(o);}}if(t(this,L)&&t(this,F)?.length){let o=t(this,F),h;for(;h=o?.shift();)(a=t(this,B))==null||a.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,at).call(this,{allowStale:true})){let a=t(this,p)[r];if(l(this,n,O).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=t(this,w)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,a,o,e)),t(this,L)&&t(this,F)?.push([a,o,e]);}}if(t(this,R).clear(),t(this,p).fill(void 0),t(this,w).fill(void 0),t(this,P)&&t(this,Z)){t(this,P).fill(0),t(this,Z).fill(0);for(let r of t(this,K)??[])r!==void 0&&clearTimeout(r);t(this,K)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),f(this,C,0),f(this,N,0),t(this,q).length=0,f(this,J,0),f(this,D,0),t(this,L)&&t(this,F)){let r=t(this,F),a;for(;a=r?.shift();)(s=t(this,B))==null||s.call(this,...a);}},yt);var At=class{constructor(e){E(this,"cache");E(this,"map",new Map);this.cache=new Qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){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 Ht;(_=>{_.storage=new At({cacheSize:50}),_.defaultStorage=new At({cacheSize:10}),_.tempStorageDeadlines=new Map;let s;function r(y){_.tempStorageDeadlines.forEach((b,T)=>{b>y&&(_.storage.delete(`${ht}:${T}`),s?.onClearOldTempVariable?.(T),_.tempStorageDeadlines.delete(T));});}_.clearOldTempVariables=r;function a(y){s=y;}_.setExternalStoreHandler=a;function o(y,b,T){T==null?_.storage.delete(`${y}:${b}`):_.storage.set(`${y}:${b}`,T),s?.onSetVariable?.(b,T);}_.setVariable=o;function h(y,b){let T=_.storage.get(`${y}:${b}`);return Ot(T)}_.getVariable=h;function c(y,b){_.storage.delete(`${y}:${b}`),s?.onRemoveVariable?.(b);}_.removeVariable=c;function m(y,b){let T=_.storage.get(Nt)||[];if(b)T.includes(y)||T.push(y);else {let A=T.indexOf(y);A>-1&&T.splice(A,1);}_.storage.set(Nt,T);}_.setFlag=m;function I(y){return (_.storage.get(Nt)||[]).includes(y)}_.getFlag=I;})(Ht||(Ht={}));var S=Ht;var Dt=class{get base(){return S.storage.map}get cache(){return S.storage.cache}get tempStorageDeadlines(){return S.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{S.defaultStorage.map.set(i,s);});}set(e,i){return S.setVariable(st,e,i)}get(e){let i=S.getVariable(ht,e);return i===void 0&&(i=S.getVariable(st,e)),i===void 0&&(i=Ot(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Ot({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):ct.warn("No storage data found");}catch(i){ct.error("Error importing data",i);}}};var Vt=class{constructor(e,i){E(this,"id");E(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=S.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([a,o])=>{S.setVariable(this.categoryId,`${s}:${a}`,o);});}),S.removeVariable(st,e));}setStorageProperty(e,i){S.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return S.getVariable(this.categoryId,`${i}:${e}`)}};var Ve=new Dt;exports.StorageManagerStatic=S;exports.StoredClassModel=Vt;exports.storage=Ve;
|