@drincs/pixi-vn 1.7.2 → 1.8.1

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.
Files changed (44) hide show
  1. package/dist/{HistoryChoiceMenuOption-DM4wqiGt.d.ts → HistoryChoiceMenuOption-BP9Tsbyd.d.ts} +1 -2
  2. package/dist/{HistoryChoiceMenuOption-iazqoVVm.d.cts → HistoryChoiceMenuOption-DSSNUXEq.d.cts} +1 -2
  3. package/dist/canvas.cjs +2 -2
  4. package/dist/canvas.mjs +2 -2
  5. package/dist/characters.cjs +1 -1
  6. package/dist/characters.mjs +1 -1
  7. package/dist/chunk-36I5IN5S.mjs +1 -0
  8. package/dist/chunk-3BBZHKU4.mjs +1 -0
  9. package/dist/{chunk-X4NBVTSJ.mjs → chunk-YCWXA3OR.mjs} +1 -1
  10. package/dist/chunk-Z4GZCINS.mjs +1 -0
  11. package/dist/core.cjs +1 -1
  12. package/dist/core.mjs +1 -1
  13. package/dist/history.cjs +1 -1
  14. package/dist/history.d.cts +1 -1
  15. package/dist/history.d.ts +1 -1
  16. package/dist/history.mjs +1 -1
  17. package/dist/index.cjs +2 -2
  18. package/dist/index.d.cts +272 -166
  19. package/dist/index.d.ts +272 -166
  20. package/dist/index.mjs +2 -2
  21. package/dist/narration.cjs +2 -2
  22. package/dist/narration.d.cts +3 -3
  23. package/dist/narration.d.ts +3 -3
  24. package/dist/narration.mjs +2 -2
  25. package/dist/sound.cjs +1 -1
  26. package/dist/sound.d.cts +330 -181
  27. package/dist/sound.d.ts +330 -181
  28. package/dist/sound.mjs +1 -1
  29. package/dist/storage.cjs +1 -1
  30. package/dist/storage.d.cts +9 -5
  31. package/dist/storage.d.ts +9 -5
  32. package/dist/storage.mjs +1 -1
  33. package/dist/vite-listener.cjs +1 -1
  34. package/dist/vite-listener.d.cts +20 -3
  35. package/dist/vite-listener.d.ts +20 -3
  36. package/dist/vite-listener.mjs +1 -1
  37. package/dist/vite.cjs +1 -1
  38. package/dist/vite.d.cts +48 -10
  39. package/dist/vite.d.ts +48 -10
  40. package/dist/vite.mjs +1 -1
  41. package/package.json +11 -8
  42. package/dist/chunk-4KCAZKAJ.mjs +0 -1
  43. package/dist/chunk-HNGW4ITF.mjs +0 -1
  44. package/dist/chunk-YDNEIPJP.mjs +0 -1
package/dist/sound.mjs CHANGED
@@ -1 +1 @@
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};
1
+ import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {e,d,f,g as g$1}from'./chunk-Z4GZCINS.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import le from'@drincs/pixi-vn/pixi.js';import*as c from'tone';import {ToneAudioBuffer,Channel,Reverb,Time,PingPongDelay,FeedbackDelay,BitCrusher,Compressor,Delay,Distortion,FeedbackCombFilter,Freeverb,Gate,GreaterThan,GreaterThanZero,Limiter,MidSideCompressor,MultibandCompressor,Panner3D,Phaser,StereoWidener,AutoFilter,Chorus,Tremolo,Vibrato,AutoPanner,BiquadFilter,OnePoleFilter,Filter,Player,now}from'tone';var C;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new e({cacheSize:10})))(C||(C={}));var i=C;function T(a){return a.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new GreaterThanZero);break;case "LimiterFilter":t.push(new Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function se(a){if(a)return Array.from(a).reduce((t,e)=>(e instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:Time(e.decay).toSeconds(),preDelay:Time(e.preDelay).toSeconds()}):e instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):f.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function K(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function h(a){return a<=0?-1/0:20*Math.log10(a)}function g(a){return a<=-1/0?0:10**(a/20)}async function P(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=le.Assets.resolver.resolve(a);e?.src&&(t=e.src);}catch{}try{let e=await ToneAudioBuffer.load(t),n=new ToneAudioBuffer(e);i.bufferRegistry.set(a,n);}catch(e){f.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e instanceof Error?e.message:e}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var v=class extends Player{constructor(e,n,r,s,o={},l){super(o);d(this,"alias",e);d(this,"channelAlias",n);d(this,"soundAlias",r);d(this,"stepCounter",s);d(this,"delay",l);d(this,"options");d(this,"filters",new Set);d(this,"pausedAt");d(this,"playStartTime",now());this.options=o,this.playStartTime=now()+(l??0);}get memory(){let e=Math.max(0,this.pausedAt?this.pausedAt-this.playStartTime:now()-this.playStartTime),n=this.paused;return n&&i.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:g(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==h(e.volume??1)&&(this.volume.value=h(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=now(),n==="started"&&super.stop();else {let r;typeof this.pausedAt=="number"&&(r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.start(void 0,r));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return i.mediaInstances.delete(this.alias),super.stop(e)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let m=Number(e.slice(1));Number.isNaN(m)||(o=s+m);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{K(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return K(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var F=class{constructor(t,e={}){d(this,"alias",t);d(this,"toneChannel");d(this,"background");this.background=e.background??false,this.toneChannel=new Channel({volume:h(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return g(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=h(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let r=i.bufferRegistry.get(e);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:m,autostart:y=true,speed:p,volume:A,...f$1}=n;m!==void 0&&(f.warn(`MediaInstance "${t}" is being created with muted=${m}. This will override the channel's muted state (${this.muted}).`),f$1.mute=m),p!==void 0&&(f.warn(`MediaInstance "${t}" is being created with speed=${p}. This will override the default playback speed of 1.`),f$1.playbackRate=p);let O=new v(t,this.alias,e,GameUnifier.stepCounter,{...f$1,volume:A!==void 0?h(A):void 0,url:r},s).chain(...l,this.toneChannel),ne=o!==void 0?Math.max(0,o):void 0;return y&&(s?O.start(`+${s}`,ne):O.start(void 0,ne)),O}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.mediaInstances.has(r)){let l=i.mediaInstances.get(r);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await P(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{i.mediaInstances.delete(e);}),this}};var w=class{constructor(){d(this,"_speedAll",1);d(this,"_defaultChannelAlias",i$1);}get volumeAll(){return g(c.getDestination().volume.value)}set volumeAll(t){c.getDestination().volume.value=h(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of i.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new c.ToneAudioBuffer(e);i.bufferRegistry.set(t,n);}}pauseAll(){for(let t of i.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return c.getDestination().mute}toggleMuteAll(){let t=!c.getDestination().mute;return c.getDestination().mute=t,t}muteAll(){return c.getDestination().mute=true,this}unmuteAll(){return c.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of i.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,i.systemPausedAliases.add(e));if(!t){for(let e of i.transients)e.stop();i.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of i.systemPausedAliases){let r=i.mediaInstances.get(n);if(!r){e.push(n);continue}t&&r.channelAlias!==t||(r.paused=false,e.push(n));}for(let n of e)i.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of i.transients)t.stop();return i.transients.clear(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(o).play(r,s,l)}async playTransient(t,e){i.bufferRegistry.has(t)||await this.load(t);let n=i.bufferRegistry.get(t);if(!n)throw new PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:r=true,...s}=e??{},o=new c.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}find(t){return i.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),i.mediaInstances.delete(t)):f.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){f.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(P);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{f.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=le.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await le.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){f.error("Error loading sound bundle",n);}}).catch(n=>{f.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(r=>{let s={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(r,s);});return}if(i.channels.has(t)){f.warn(`Channel with alias ${t} already exists.`);return}let n=new F(t,e);return i.channels.set(t,n),n}findChannel(t){let e=i.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(i.channels.values())}export(){let t=Array.from(i.mediaInstances.entries()).reduce((e,[n,r])=>(e[n]={channelAlias:r.channelAlias,soundAlias:r.soundAlias,stepCounter:r.stepCounter,paused:r.paused,options:{...r.memory,filters:se(r.filters)}},e),{});return {mediaInstances:g$1(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async r=>{await this.load(r),await this.play(r);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,r=Object.values(e).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e).map(async o=>{let l=e[o],m=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(m.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}else {let p=i.mediaInstances.get(o);if(!p){f.warn(`No media instance found with alias ${o} while restoring background state.`);return}p.memory={...l.options,paused:y},[...p.filters].forEach(f=>{p.disconnect(f),f.dispose();}),p.chain(...T(l.options.filters||[]));}else {let p=await m.play(o,l.soundAlias,{...l.options,autostart:!y,filters:T(l.options.filters||[]),delay:l.options.delay});p.paused=y;}});await Promise.all(s);}}}catch(e){f.error("Error importing data",e);}}};var te=new w;GameUnifier.addOnPreContinue(async()=>{try{i.channels.forEach(a=>{a.background||a.stopAll();});}catch{}});if(typeof document<"u"){let a=false;document.addEventListener("visibilitychange",()=>{document.hidden?te.muted||(te.muteAll(),a=true):a&&(te.unmuteAll(),a=false);});}export{i as SoundRegistry,te as sound};
package/dist/storage.cjs CHANGED
@@ -1 +1 @@
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;
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 ie=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 se=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,re=(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,ct,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,ut,it,wt,W,Zt,ft,bt,xt,ot,at,Pt,Ct,Mt,O,Kt,Ot,nt,Wt,yt,Qt=(yt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ct);d(this,B);d(this,mt);d(this,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,ut,()=>{});d(this,it,()=>{});d(this,wt,()=>{});d(this,W,()=>false);d(this,ft,e=>{});d(this,bt,(e,i,s)=>{});d(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});E(this,kt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:I,disposeAfter:g,noDisposeOnSet:y,noUpdateTTL:b,maxSize:T=0,maxEntrySize:A=0,sizeCalculation:v,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:vt,ignoreFetchAbort:gt,perf:_t}=e;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,_t??ie),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),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,mt,_),f(this,lt,!!_),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,re.create(i)),f(this,D,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof I=="function"&&f(this,ct,I),typeof g=="function"?(f(this,B,g),f(this,F,[])):(f(this,B,void 0),f(this,F,void 0)),f(this,tt,!!t(this,k)),f(this,Tt,!!t(this,ct)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,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";se(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,Ot).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,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of l(this,n,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,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let g=t(this,D)===0?void 0:t(this,R).get(e);if(g===void 0)g=t(this,D)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,D)===t(this,$)?l(this,n,Ct).call(this,false):t(this,D),t(this,w)[g]=e,t(this,p)[g]=i,t(this,R).set(e,g),t(this,V)[t(this,N)]=g,t(this,Y)[g]=t(this,N),f(this,N,g),It(this,D)._++,t(this,bt).call(this,g,I,c),c&&(c.set="add"),m=false,t(this,Tt)&&((y=t(this,ct))==null||y.call(this,i,e,"add"));else {l(this,n,Ot).call(this,g);let v=t(this,p)[g];if(i!==v){if(t(this,lt)&&l(this,n,O).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=v;_!==void 0&&!o&&(t(this,tt)&&((b=t(this,k))==null||b.call(this,_,e,"set")),t(this,L)&&t(this,F)?.push([_,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,ft).call(this,g),t(this,bt).call(this,g,I,c),t(this,p)[g]=i,c){c.set="replace";let _=v&&l(this,n,O).call(this,v)?v.__staleWhileFetching:v;_!==void 0&&(c.oldValue=_);}}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,wt).call(this,g,r,a),c&&t(this,it).call(this,c,g)),!o&&t(this,L)&&t(this,F)){let v=t(this,F),_;for(;_=v?.shift();)(A=t(this,B))==null||A.call(this,..._);}return this}pop(){var e;try{for(;t(this,D);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,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,ut).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:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:A,forceRefresh:v=false,status:_,signal:M}=i;if(!t(this,lt))return _&&(_.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,status:_});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:h,size:c,sizeCalculation:m,noUpdateTTL:I,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:_,signal:M},G=t(this,R).get(e);if(G===void 0){_&&(_.fetch="miss");let x=l(this,n,Mt).call(this,e,G,U,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 _&&(_.fetch="inflight",dt&&(_.returnedStale=true)),dt?x.__staleWhileFetching:x.__returned=x}let vt=t(this,W).call(this,G);if(!v&&!vt)return _&&(_.fetch="hit"),l(this,n,Ot).call(this,G),r&&t(this,ut).call(this,G),_&&t(this,it).call(this,_,G),x;let gt=l(this,n,Mt).call(this,e,G,U,A),_t=gt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=vt?"stale":"refresh",_t&&vt&&(_.returnedStale=true)),_t?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,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,Ot).call(this,h),r&&t(this,ut).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,ct=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,wt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ut,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,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 g=h.now-I;h.remainingTTL=m-g;}});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 g=(a||o())-I;return m-g},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(a||o())-c>m});},ut=new WeakMap,it=new WeakMap,wt=new WeakMap,W=new WeakMap,Zt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,ft,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,xt,(i,s,r,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));});},ft=new WeakMap,bt=new WeakMap,xt=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,ft).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:_}=o.signal,M=s.ignoreFetchAbort&&A!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(_&&!v?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!v)return g(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),g(A,false)),g=(A,v)=>{let{aborted:_}=o.signal,M=_&&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 _=(M=t(this,mt))==null?void 0:M.call(this,e,a,c);_&&_ instanceof Promise&&_.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;},Ot=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,ft).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(){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 pt;(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)))(pt||(pt={}));function Rt(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw pt.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Ht;(g=>{g.storage=new At({cacheSize:50}),g.defaultStorage=new At({cacheSize:10}),g.tempStorageDeadlines=new Map;let s;function r(y){g.tempStorageDeadlines.forEach((b,T)=>{b>y&&(g.storage.delete(`${ht}:${T}`),s?.onClearOldTempVariable?.(T),g.tempStorageDeadlines.delete(T));});}g.clearOldTempVariables=r;function a(y){s=y;}g.setExternalStoreHandler=a;function o(y,b,T){T==null?g.storage.delete(`${y}:${b}`):g.storage.set(`${y}:${b}`,T),s?.onSetVariable?.(b,T);}g.setVariable=o;function h(y,b){let T=g.storage.get(`${y}:${b}`);return Rt(T)}g.getVariable=h;function c(y,b){g.storage.delete(`${y}:${b}`),s?.onRemoveVariable?.(b);}g.removeVariable=c;function m(y,b){let T=g.storage.get(Nt)||[];if(b)T.includes(y)||T.push(y);else {let A=T.indexOf(y);A>-1&&T.splice(A,1);}g.storage.set(Nt,T);}g.setFlag=m;function I(y){return (g.storage.get(Nt)||[]).includes(y)}g.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=Rt(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):pt.warn("No storage data found");}catch(i){pt.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.StorageRegistry=S;exports.StoredClassModel=Vt;exports.storage=Ve;
@@ -6,17 +6,17 @@ import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
6
6
 
7
7
  interface StorageExternalStoreHandler {
8
8
  /**
9
- * Triggered when {@link StorageManagerStatic.setVariable} is called.
9
+ * Triggered when {@link StorageRegistry.setVariable} is called.
10
10
  * The key is provided without any storage prefix.
11
11
  */
12
12
  onSetVariable?: (key: string, value: StorageElementType) => void;
13
13
  /**
14
- * Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
14
+ * Triggered when a temp variable is removed by {@link StorageRegistry.clearOldTempVariables}.
15
15
  * The key is provided without any storage prefix.
16
16
  */
17
17
  onClearOldTempVariable?: (key: string) => void;
18
18
  /**
19
- * Triggered when {@link StorageManagerStatic.removeVariable} is called.
19
+ * Triggered when {@link StorageRegistry.removeVariable} is called.
20
20
  * The key is provided without any storage prefix.
21
21
  */
22
22
  onRemoveVariable?: (key: string) => void;
@@ -171,7 +171,11 @@ interface StorageManagerInterface {
171
171
  restore(data: StorageGameState): void;
172
172
  }
173
173
 
174
- declare namespace StorageManagerStatic {
174
+ /**
175
+ * StorageRegistry is a singleton namespace that holds global state for the storage system.
176
+ * **DO NOT** import this module directly; use `storage`.
177
+ */
178
+ declare namespace StorageRegistry {
175
179
  const storage: CachedMap<string, any>;
176
180
  const defaultStorage: CachedMap<string, any>;
177
181
  const tempStorageDeadlines: Map<string, number>;
@@ -186,4 +190,4 @@ declare namespace StorageManagerStatic {
186
190
 
187
191
  declare const storage: StorageManagerInterface;
188
192
 
189
- export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
193
+ export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageRegistry, storage };
package/dist/storage.d.ts CHANGED
@@ -6,17 +6,17 @@ import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
6
6
 
7
7
  interface StorageExternalStoreHandler {
8
8
  /**
9
- * Triggered when {@link StorageManagerStatic.setVariable} is called.
9
+ * Triggered when {@link StorageRegistry.setVariable} is called.
10
10
  * The key is provided without any storage prefix.
11
11
  */
12
12
  onSetVariable?: (key: string, value: StorageElementType) => void;
13
13
  /**
14
- * Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
14
+ * Triggered when a temp variable is removed by {@link StorageRegistry.clearOldTempVariables}.
15
15
  * The key is provided without any storage prefix.
16
16
  */
17
17
  onClearOldTempVariable?: (key: string) => void;
18
18
  /**
19
- * Triggered when {@link StorageManagerStatic.removeVariable} is called.
19
+ * Triggered when {@link StorageRegistry.removeVariable} is called.
20
20
  * The key is provided without any storage prefix.
21
21
  */
22
22
  onRemoveVariable?: (key: string) => void;
@@ -171,7 +171,11 @@ interface StorageManagerInterface {
171
171
  restore(data: StorageGameState): void;
172
172
  }
173
173
 
174
- declare namespace StorageManagerStatic {
174
+ /**
175
+ * StorageRegistry is a singleton namespace that holds global state for the storage system.
176
+ * **DO NOT** import this module directly; use `storage`.
177
+ */
178
+ declare namespace StorageRegistry {
175
179
  const storage: CachedMap<string, any>;
176
180
  const defaultStorage: CachedMap<string, any>;
177
181
  const tempStorageDeadlines: Map<string, number>;
@@ -186,4 +190,4 @@ declare namespace StorageManagerStatic {
186
190
 
187
191
  declare const storage: StorageManagerInterface;
188
192
 
189
- export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
193
+ export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageRegistry, storage };
package/dist/storage.mjs CHANGED
@@ -1 +1 @@
1
- export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-4KCAZKAJ.mjs';import'./chunk-YDNEIPJP.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-HNGW4ITF.mjs';
1
+ export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-36I5IN5S.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-Z4GZCINS.mjs';
@@ -1 +1 @@
1
- 'use strict';var canvas=require('@drincs/pixi-vn/canvas'),characters=require('@drincs/pixi-vn/characters'),narration=require('@drincs/pixi-vn/narration'),o=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var o__default=/*#__PURE__*/_interopDefault(o);function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=characters.RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=narration.RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o__default.default.Assets.resolver._assetMap,r=o__default.default.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}exports.setupPixivnViteData=l;
1
+ 'use strict';var canvas=require('@drincs/pixi-vn/canvas'),characters=require('@drincs/pixi-vn/characters'),narration=require('@drincs/pixi-vn/narration'),l=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var o="/__pixi-vn/characters",i="/__pixi-vn/labels",a="/__pixi-vn/assets/manifest",c="/__pixi-vn/canvas-options";function f(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function r(t,n,s="data"){try{fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).catch(e=>{console.warn(`Failed to send ${s} to ${t}:`,e);});}catch(e){console.warn(`Error sending ${s} to ${t}:`,e);}}function m(){let t=l__default.default.Assets.resolver._assetMap,n=l__default.default.Assets.resolver._bundles;return {bundles:Object.entries(n).map(([s,e])=>({name:s,assets:e.flatMap(_=>t[_]??[])}))}}function P(){if(f()){try{let t=characters.RegisteredCharacters.values();r(o,t,"characters");}catch(t){console.warn("Error collecting characters:",t);}try{let t=narration.RegisteredLabels.keys();r(i,t,"labels");}catch(t){console.warn("Error collecting labels:",t);}try{let t=m();r(a,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}try{let t={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};r(c,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}exports.setupPixivnViteData=P;
@@ -1,7 +1,24 @@
1
1
  /**
2
- * Function that setup the pixivn vite data.
3
- * This function should be called in the client side, after the RegisteredCharacters and RegisteredLabels are populated.
4
- * **Note:** This function only runs in development mode and does nothing in production.
2
+ * Initializes Pixi VN development tools by syncing game state with the Vite dev server.
3
+ * Sends registered characters, labels, assets manifest, and canvas options.
4
+ *
5
+ * **Note:** This function only operates in Vite development mode and is a no-op in production.
6
+ *
7
+ * **Call this function:** After RegisteredCharacters and RegisteredLabels are populated,
8
+ * typically in your client-side initialization code.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // In your main game initialization file
13
+ * import { setupPixivnViteData } from '@drincs/pixi-vn/vite-listener';
14
+ *
15
+ * await Promise.all([import("@/content")]);
16
+ * // After game setup
17
+ * setupPixivnViteData();
18
+ * ```
19
+ *
20
+ * @returns {void}
21
+ * @public
5
22
  */
6
23
  declare function setupPixivnViteData(): void;
7
24
 
@@ -1,7 +1,24 @@
1
1
  /**
2
- * Function that setup the pixivn vite data.
3
- * This function should be called in the client side, after the RegisteredCharacters and RegisteredLabels are populated.
4
- * **Note:** This function only runs in development mode and does nothing in production.
2
+ * Initializes Pixi VN development tools by syncing game state with the Vite dev server.
3
+ * Sends registered characters, labels, assets manifest, and canvas options.
4
+ *
5
+ * **Note:** This function only operates in Vite development mode and is a no-op in production.
6
+ *
7
+ * **Call this function:** After RegisteredCharacters and RegisteredLabels are populated,
8
+ * typically in your client-side initialization code.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // In your main game initialization file
13
+ * import { setupPixivnViteData } from '@drincs/pixi-vn/vite-listener';
14
+ *
15
+ * await Promise.all([import("@/content")]);
16
+ * // After game setup
17
+ * setupPixivnViteData();
18
+ * ```
19
+ *
20
+ * @returns {void}
21
+ * @public
5
22
  */
6
23
  declare function setupPixivnViteData(): void;
7
24
 
@@ -1 +1 @@
1
- import'./chunk-TTRUPDAB.mjs';import {canvas}from'@drincs/pixi-vn/canvas';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {RegisteredLabels}from'@drincs/pixi-vn/narration';import o from'@drincs/pixi-vn/pixi.js';function h(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function l(){if(h()){try{let e=RegisteredCharacters.values();fetch("/pixi-vn/characters",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=RegisteredLabels.keys();fetch("/pixi-vn/labels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}try{let e=o.Assets.resolver._assetMap,r=o.Assets.resolver._bundles,s={bundles:[]};Object.entries(r).forEach(([a,p])=>{let t=[];p.forEach(n=>{if(e[n]){let c=e[n];t=[...t,...c];}}),s.bundles.push({name:a,assets:t});}),fetch("/pixi-vn/assets/manifest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch{}try{let e={height:canvas.app.screen.height,width:canvas.app.screen.width};fetch("/pixi-vn/canvas/options",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch{}}}export{l as setupPixivnViteData};
1
+ import {a,b,c,d}from'./chunk-3BBZHKU4.mjs';import'./chunk-TTRUPDAB.mjs';import {canvas}from'@drincs/pixi-vn/canvas';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {RegisteredLabels}from'@drincs/pixi-vn/narration';import p from'@drincs/pixi-vn/pixi.js';function u(){try{return new Function('return typeof import !== "undefined" && typeof import.meta !== "undefined" && import.meta.env?.DEV === true')()}catch{return false}}function s(t,n,r="data"){try{fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).catch(e=>{console.warn(`Failed to send ${r} to ${t}:`,e);});}catch(e){console.warn(`Error sending ${r} to ${t}:`,e);}}function h(){let t=p.Assets.resolver._assetMap,n=p.Assets.resolver._bundles;return {bundles:Object.entries(n).map(([r,e])=>({name:r,assets:e.flatMap(f=>t[f]??[])}))}}function A(){if(u()){try{let t=RegisteredCharacters.values();s(a,t,"characters");}catch(t){console.warn("Error collecting characters:",t);}try{let t=RegisteredLabels.keys();s(b,t,"labels");}catch(t){console.warn("Error collecting labels:",t);}try{let t=h();s(c,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}try{let t={height:canvas.app.screen.height,width:canvas.app.screen.width};s(d,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}export{A as setupPixivnViteData};
package/dist/vite.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var s=null,o=null,d=null,r=null;function l(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{s=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{o=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{d=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!r){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(r));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{r=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}exports.vitePluginPixivn=l;
1
+ 'use strict';var s="/__pixi-vn/characters",o="/__pixi-vn/labels",a="/__pixi-vn/assets/manifest",_="/__pixi-vn/canvas-options";var p=null,c=null,u=null,A=null;function S(){let t=(e,r)=>(i,n)=>{if(n.setHeader("Content-Type","application/json"),i.method==="GET"){if(e.current===null){n.statusCode=404,n.end(JSON.stringify({error:`${r} not initialized`}));return}n.statusCode=200,n.end(JSON.stringify(e.current));return}if(i.method==="POST"){let l="";i.on("data",I=>l+=I),i.on("end",()=>{try{e.current=JSON.parse(l),n.statusCode=201,n.end(JSON.stringify({message:`${r} updated successfully`}));}catch{n.statusCode=400,n.end(JSON.stringify({error:`Invalid JSON format for ${r}`}));}});}};return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(e){e.middlewares.use(s,t({current:p},"Characters")),e.middlewares.use(o,t({current:c},"Labels")),e.middlewares.use(a,t({current:u},"Manifest")),e.middlewares.use(_,t({current:A},"Canvas options"));}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=a;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=_;exports.PIXIVN_DEV_API_CHARACTERS=s;exports.PIXIVN_DEV_API_LABELS=o;exports.vitePluginPixivn=S;
package/dist/vite.d.cts CHANGED
@@ -1,5 +1,23 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
 
3
+ /** @const {string} API endpoint for characters data - GET to retrieve, POST to update */
4
+ declare const PIXIVN_DEV_API_CHARACTERS = "/__pixi-vn/characters";
5
+ /** @const {string} API endpoint for narration labels - GET to retrieve, POST to update */
6
+ declare const PIXIVN_DEV_API_LABELS = "/__pixi-vn/labels";
7
+ /** @const {string} API endpoint for assets manifest - GET to retrieve, POST to update */
8
+ declare const PIXIVN_DEV_API_ASSETS_MANIFEST = "/__pixi-vn/assets/manifest";
9
+ /** @const {string} API endpoint for canvas options - GET to retrieve, POST to update */
10
+ declare const PIXIVN_DEV_API_CANVAS_OPTIONS = "/__pixi-vn/canvas-options";
11
+
12
+ /**
13
+ * Represents a Vite plugin configuration object.
14
+ * Defines the structure for registering middleware and handling server requests.
15
+ *
16
+ * @typedef {Object} Plugin
17
+ * @property {string} name - Unique identifier for the plugin
18
+ * @property {"serve"} apply - Plugin application scope (development server only)
19
+ * @property {Function} configureServer - Middleware configuration function
20
+ */
3
21
  type Plugin = {
4
22
  name: string;
5
23
  apply: "serve";
@@ -10,16 +28,36 @@ type Plugin = {
10
28
  }) => void;
11
29
  };
12
30
  /**
13
- * Vite plugin to handle pixi-vn related endpoints.
14
- * This plugin only runs in development mode (serve).
15
- * Endpoints:
16
- * - GET /pixi-vn/characters -> list of registered characters
17
- * - POST /pixi-vn/characters -> update the list of registered characters
18
- * - GET /pixi-vn/labels -> list of registered labels
19
- * - POST /pixi-vn/labels -> update the list of registered labels
20
- * - GET /pixi-vn/assets/manifest -> assets manifest
21
- * - POST /pixi-vn/assets/manifest -> update assets manifest
31
+ * Creates a Vite development server plugin for Pixi VN integration.
32
+ *
33
+ * This plugin provides four API endpoints to sync game state between the client
34
+ * and the development server. Only active in development mode (serve).
35
+ *
36
+ * **Endpoints:**
37
+ * - `GET /__pixi-vn/characters` - Retrieve cached registered characters
38
+ * - `POST /__pixi-vn/characters` - Update registered characters from client
39
+ * - `GET /__pixi-vn/labels` - Retrieve cached narration labels
40
+ * - `POST /__pixi-vn/labels` - Update narration labels from client
41
+ * - `GET /__pixi-vn/assets/manifest` - Retrieve PIXI assets manifest
42
+ * - `POST /__pixi-vn/assets/manifest` - Update assets manifest from client
43
+ * - `GET /__pixi-vn/canvas-options` - Retrieve canvas rendering options
44
+ * - `POST /__pixi-vn/canvas-options` - Update canvas options from client
45
+ *
46
+ * @returns {Plugin} Configured Vite plugin object
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // vite.config.ts
51
+ * import { defineConfig } from 'vite';
52
+ * import { vitePluginPixivn } from '@drincs/pixi-vn/vite';
53
+ *
54
+ * export default defineConfig({
55
+ * plugins: [vitePluginPixivn()],
56
+ * });
57
+ * ```
58
+ *
59
+ * @public
22
60
  */
23
61
  declare function vitePluginPixivn(): Plugin;
24
62
 
25
- export { vitePluginPixivn };
63
+ export { PIXIVN_DEV_API_ASSETS_MANIFEST, PIXIVN_DEV_API_CANVAS_OPTIONS, PIXIVN_DEV_API_CHARACTERS, PIXIVN_DEV_API_LABELS, vitePluginPixivn };
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,23 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
 
3
+ /** @const {string} API endpoint for characters data - GET to retrieve, POST to update */
4
+ declare const PIXIVN_DEV_API_CHARACTERS = "/__pixi-vn/characters";
5
+ /** @const {string} API endpoint for narration labels - GET to retrieve, POST to update */
6
+ declare const PIXIVN_DEV_API_LABELS = "/__pixi-vn/labels";
7
+ /** @const {string} API endpoint for assets manifest - GET to retrieve, POST to update */
8
+ declare const PIXIVN_DEV_API_ASSETS_MANIFEST = "/__pixi-vn/assets/manifest";
9
+ /** @const {string} API endpoint for canvas options - GET to retrieve, POST to update */
10
+ declare const PIXIVN_DEV_API_CANVAS_OPTIONS = "/__pixi-vn/canvas-options";
11
+
12
+ /**
13
+ * Represents a Vite plugin configuration object.
14
+ * Defines the structure for registering middleware and handling server requests.
15
+ *
16
+ * @typedef {Object} Plugin
17
+ * @property {string} name - Unique identifier for the plugin
18
+ * @property {"serve"} apply - Plugin application scope (development server only)
19
+ * @property {Function} configureServer - Middleware configuration function
20
+ */
3
21
  type Plugin = {
4
22
  name: string;
5
23
  apply: "serve";
@@ -10,16 +28,36 @@ type Plugin = {
10
28
  }) => void;
11
29
  };
12
30
  /**
13
- * Vite plugin to handle pixi-vn related endpoints.
14
- * This plugin only runs in development mode (serve).
15
- * Endpoints:
16
- * - GET /pixi-vn/characters -> list of registered characters
17
- * - POST /pixi-vn/characters -> update the list of registered characters
18
- * - GET /pixi-vn/labels -> list of registered labels
19
- * - POST /pixi-vn/labels -> update the list of registered labels
20
- * - GET /pixi-vn/assets/manifest -> assets manifest
21
- * - POST /pixi-vn/assets/manifest -> update assets manifest
31
+ * Creates a Vite development server plugin for Pixi VN integration.
32
+ *
33
+ * This plugin provides four API endpoints to sync game state between the client
34
+ * and the development server. Only active in development mode (serve).
35
+ *
36
+ * **Endpoints:**
37
+ * - `GET /__pixi-vn/characters` - Retrieve cached registered characters
38
+ * - `POST /__pixi-vn/characters` - Update registered characters from client
39
+ * - `GET /__pixi-vn/labels` - Retrieve cached narration labels
40
+ * - `POST /__pixi-vn/labels` - Update narration labels from client
41
+ * - `GET /__pixi-vn/assets/manifest` - Retrieve PIXI assets manifest
42
+ * - `POST /__pixi-vn/assets/manifest` - Update assets manifest from client
43
+ * - `GET /__pixi-vn/canvas-options` - Retrieve canvas rendering options
44
+ * - `POST /__pixi-vn/canvas-options` - Update canvas options from client
45
+ *
46
+ * @returns {Plugin} Configured Vite plugin object
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * // vite.config.ts
51
+ * import { defineConfig } from 'vite';
52
+ * import { vitePluginPixivn } from '@drincs/pixi-vn/vite';
53
+ *
54
+ * export default defineConfig({
55
+ * plugins: [vitePluginPixivn()],
56
+ * });
57
+ * ```
58
+ *
59
+ * @public
22
60
  */
23
61
  declare function vitePluginPixivn(): Plugin;
24
62
 
25
- export { vitePluginPixivn };
63
+ export { PIXIVN_DEV_API_ASSETS_MANIFEST, PIXIVN_DEV_API_CANVAS_OPTIONS, PIXIVN_DEV_API_CHARACTERS, PIXIVN_DEV_API_LABELS, vitePluginPixivn };
package/dist/vite.mjs CHANGED
@@ -1 +1 @@
1
- import'./chunk-TTRUPDAB.mjs';var s=null,o=null,d=null,r=null;function l(){return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(a){a.middlewares.use("/pixi-vn/characters",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!s){t.statusCode=404,t.end(JSON.stringify({error:"Characters not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(s));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{s=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Characters updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/labels",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!o){t.statusCode=404,t.end(JSON.stringify({error:"Labels not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(o));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{o=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Labels updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/assets/manifest",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!d){t.statusCode=404,t.end(JSON.stringify({error:"Manifest not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(d));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{d=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Manifest updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}}),a.middlewares.use("/pixi-vn/canvas/options",(i,t)=>{if(t.setHeader("Content-Type","application/json"),i.method==="GET"){if(!r){t.statusCode=404,t.end(JSON.stringify({error:"Options not initialized"}));return}t.statusCode=200,t.end(JSON.stringify(r));}if(i.method==="POST"){let e="";i.on("data",n=>e+=n),i.on("end",()=>{try{r=JSON.parse(e),t.statusCode=201,t.end(JSON.stringify({message:"Options updated successfully"}));}catch{t.statusCode=400,t.end(JSON.stringify({error:"Invalid JSON format"}));}});}});}}}export{l as vitePluginPixivn};
1
+ import {a,b,c as c$1,d as d$1}from'./chunk-3BBZHKU4.mjs';export{c as PIXIVN_DEV_API_ASSETS_MANIFEST,d as PIXIVN_DEV_API_CANVAS_OPTIONS,a as PIXIVN_DEV_API_CHARACTERS,b as PIXIVN_DEV_API_LABELS}from'./chunk-3BBZHKU4.mjs';import'./chunk-TTRUPDAB.mjs';var c=null,d=null,I=null,S=null;function _(){let t=(n,i)=>(r,e)=>{if(e.setHeader("Content-Type","application/json"),r.method==="GET"){if(n.current===null){e.statusCode=404,e.end(JSON.stringify({error:`${i} not initialized`}));return}e.statusCode=200,e.end(JSON.stringify(n.current));return}if(r.method==="POST"){let u="";r.on("data",p=>u+=p),r.on("end",()=>{try{n.current=JSON.parse(u),e.statusCode=201,e.end(JSON.stringify({message:`${i} updated successfully`}));}catch{e.statusCode=400,e.end(JSON.stringify({error:`Invalid JSON format for ${i}`}));}});}};return {name:"vite-plugin-pixi-vn",apply:"serve",configureServer(n){n.middlewares.use(a,t({current:c},"Characters")),n.middlewares.use(b,t({current:d},"Labels")),n.middlewares.use(c$1,t({current:I},"Manifest")),n.middlewares.use(d$1,t({current:S},"Canvas options"));}}}export{_ as vitePluginPixivn};