@drincs/pixi-vn 1.6.4 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -53
- package/dist/{HistoryChoiceMenuOption-DM4wqiGt.d.ts → HistoryChoiceMenuOption-BP9Tsbyd.d.ts} +1 -2
- package/dist/{HistoryChoiceMenuOption-iazqoVVm.d.cts → HistoryChoiceMenuOption-DSSNUXEq.d.cts} +1 -2
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +56 -51
- package/dist/canvas.d.ts +56 -51
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-L4IHQ3VT.mjs → chunk-3SLELYPF.mjs} +1 -1
- package/dist/chunk-6HI66YQL.mjs +1 -0
- package/dist/chunk-XYO5SLSM.mjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -9
- package/dist/index.d.cts +289 -114
- package/dist/index.d.ts +289 -114
- package/dist/index.mjs +2 -9
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +3 -1
- package/dist/motion.d.ts +3 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.d.cts +3 -3
- package/dist/narration.d.ts +3 -3
- package/dist/narration.mjs +2 -2
- package/dist/pixi/browser.js +183 -171
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +337 -132
- package/dist/sound.d.ts +337 -132
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +63 -12
- package/dist/storage.d.ts +63 -12
- package/dist/storage.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +10 -1
- package/dist/vite.d.ts +10 -1
- package/dist/vite.mjs +1 -1
- package/package.json +21 -13
- package/dist/chunk-D45QSSXG.mjs +0 -1
- package/dist/chunk-EWW7VYPM.mjs +0 -1
- package/dist/chunk-ZW3MIPMS.mjs +0 -1
- /package/dist/{chunk-XSN6P5JL.mjs → chunk-JMOSOAGB.mjs} +0 -0
package/dist/sound.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-XSN6P5JL.mjs';import {i}from'./chunk-IWAXXFXE.mjs';import {d,j,k}from'./chunk-D45QSSXG.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import g from'@drincs/pixi-vn/pixi.js';import {filters,sound,Sound}from'@pixi/sound';function S(u,t){return u===void 0&&t===void 0?1:t===void 0?u:u===void 0?t:u*t}var s=class{constructor(){}};d(s,"mediaInstances",{}),d(s,"channels",{}),d(s,"delayTimeoutInstances",[]);function C(u,t,e){return new Proxy(t,{get(n,i,o){switch(i){case "volume":case "muted":{let r=s.mediaInstances[u];return r?r.options[i]:Reflect.get(n,i,o)}default:return Reflect.get(n,i,o)}},set(n,i,o,r){if(u in s.mediaInstances)switch(i){case "volume":return s.mediaInstances[u].options[i]=o,o=S(o,e.channelOptions.volume),Reflect.set(n,i,o,r);case "muted":return s.mediaInstances[u].options[i]=o,e.channelOptions.muted?Reflect.set(n,i,true,r):Reflect.set(n,i,o,r);case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":s.mediaInstances[u].options[i]=o;default:return Reflect.set(n,i,o,r)}return Reflect.set(n,i,o,r)}})}var y=class{constructor(t,e={}){this.alias=t;this.channelOptions=e;}alias;channelOptions;async play(t,e,n){let i,o;if(typeof e=="string"?(i=t,o=e):(i=t,o=t,n=e),i in s.mediaInstances){let a=s.mediaInstances[i];a.instance.stop(),n={...a.options,...n};}let r=C(i,await sound.play(o,{...n??{},filters:[...this.channelOptions.filters||[],...n?.filters||[]],muted:!!this.channelOptions.muted||!!n?.muted,volume:S(n?.volume,this.channelOptions.volume)}),this);if(n?.delay){r.paused=true;let a=setTimeout(()=>{r.paused=false,s.delayTimeoutInstances=s.delayTimeoutInstances.filter(h=>h[0]!==a);},n.delay*1e3);s.delayTimeoutInstances.push([a,i]);}return s.mediaInstances[i]={channelAlias:this.alias,soundAlias:o,instance:r,stepCounter:GameUnifier.stepCounter,options:{volume:n?.volume??1,muted:n?.muted??false,loop:n?.loop??false,...n??{}}},r.on("end",()=>{delete s.mediaInstances[i];}),r}updateMediaVolume(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.volume??1;e.instance.volume=n;}}}get volume(){return this.channelOptions.volume??1}set volume(t){this.channelOptions.volume=t,this.updateMediaVolume();}updateMediaMuted(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];if(e.channelAlias===this.alias){let n=e.options.muted??false;e.instance.muted=n;}}}get muted(){return this.channelOptions.muted??false}set muted(t){this.channelOptions.muted=t,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Object.values(s.mediaInstances).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e.instance),t),[])}get background(){return this.channelOptions.background||false}stopAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.channelAlias===this.alias&&(e.instance.stop(),delete s.mediaInstances[t]);}return this}pauseAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);}return this}resumeAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);}return this}};function I(u){let t=[];for(let e of u)e.type==="TelephoneFilter"?t.push(new filters.TelephoneFilter):e.type==="StreamFilter"?t.push(new filters.StreamFilter):e.type==="StereoFilter"?t.push(new filters.StereoFilter(e.pan)):e.type==="ReverbFilter"?t.push(new filters.ReverbFilter(e.seconds,e.decay,e.reverse)):e.type==="MonoFilter"?t.push(new filters.MonoFilter):e.type==="EqualizerFilter"?t.push(new filters.EqualizerFilter(e.f32,e.f64,e.f125,e.f250,e.f500,e.f1k,e.f2k,e.f4k,e.f8k,e.f16k)):e.type==="DistortionFilter"?t.push(new filters.DistortionFilter(e.amount)):j.error("Unknown sound filter type");return t}function b(u){if(!u)return;let t=[];for(let e of u)e instanceof filters.TelephoneFilter?t.push({type:"TelephoneFilter"}):e instanceof filters.StreamFilter?t.push({type:"StreamFilter"}):e instanceof filters.StereoFilter?t.push({type:"StereoFilter",pan:e.pan}):e instanceof filters.ReverbFilter?t.push({type:"ReverbFilter",seconds:e.seconds,decay:e.decay,reverse:e.reverse}):e instanceof filters.MonoFilter?t.push({type:"MonoFilter"}):e instanceof filters.EqualizerFilter?t.push({type:"EqualizerFilter",f32:e.f32,f64:e.f64,f125:e.f125,f250:e.f250,f500:e.f500,f1k:e.f1k,f2k:e.f2k,f4k:e.f4k,f8k:e.f8k,f16k:e.f16k}):e instanceof filters.DistortionFilter?t.push({type:"DistortionFilter",amount:e.amount}):j.error("Unknown sound filter type");return t}var A=class{constructor(){d(this,"_defaultChannelAlias",i);}get context(){return sound.context}get filtersAll(){return sound.filtersAll}set filtersAll(t){sound.filtersAll=t.filter(e=>!(e instanceof filters.Filter));}get supported(){return sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){return sound.add(t,e)}async edit(t,e){let n=sound.find(t);if(!n&&(await this.load(t),n=sound.find(t),!n)){j.error(`Sound with alias ${t} not found after loading.`);return}n.options=e;}get useLegacy(){return sound.useLegacy}set useLegacy(t){sound.useLegacy=t;}get disableAutoPause(){return sound.disableAutoPause}set disableAutoPause(t){sound.disableAutoPause=t;}get volumeAll(){return sound.volumeAll}set volumeAll(t){sound.volumeAll=t;}get speedAll(){return sound.speedAll}set speedAll(t){sound.speedAll=t;}pauseAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.instance.paused||(e.instance.paused=true);}return this}resumeAll(){for(let t in s.mediaInstances){let e=s.mediaInstances[t];e.instance.paused&&(e.instance.paused=false);}return this}toggleMuteAll(){return sound.toggleMuteAll()}muteAll(){return sound.muteAll(),this}unmuteAll(){return sound.unmuteAll(),this}stopAll(){return s.mediaInstances={},sound.stopAll(),this}isPlaying(){return sound.isPlaying()}async play(t,e,n){let i,o;typeof e=="string"?(i=t,o=e):(i=t,o=t,n=e),sound.exists(o)||await this.load(o);let{channel:r=this.defaultChannelAlias,...a}=n??{};return await this.findChannel(r).play(i,o,a)}find(t){return s.mediaInstances[t]?.instance}stop(t){let e=this.find(t);e?(e.stop(),delete s.mediaInstances[t]):j.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){j.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){j.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return sound.duration(t)}async load(t){typeof t=="string"&&(t=[t]);let e=t.map(async n=>{let i=await g.Assets.load(n);return sound.exists(n)||sound.add(n,i),i});return await Promise.all(e)}backgroundLoad(t){let e=g.Assets.backgroundLoad(t);return e.then(()=>{typeof t=="string"&&(t=[t]),t.forEach(n=>{let i=g.Assets.get(n);sound.exists(n)||sound.add(n,i);});}),e}backgroundLoadBundle(t){let e=g.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await g.Assets.loadBundle(t);for(let i in n){let o=n[i];o instanceof Sound&&(sound.exists(i)||sound.add(i,o));}}catch(n){j.error("Error loading sound bundle",n);}}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(i=>{let o={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(i,o);});return}if(s.channels[t]){j.warn(`Channel with alias ${t} already exists.`);return}let n=new y(t,e);return s.channels[t]=n,n}findChannel(t){let e=s.channels[t];return e||this.addChannel(t)}get channels(){return Object.values(s.channels)}export(){let t=Object.entries(s.mediaInstances).reduce((e,[n,i])=>(e[n]={channelAlias:i.channelAlias,soundAlias:i.soundAlias,stepCounter:i.stepCounter,options:{...i.options,filters:b(i.options.filters)},paused:i.instance.paused},e),{});return {mediaInstances:k(t),filters:k(b(this.filtersAll))}}async restore(t){try{if(t.hasOwnProperty("soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async i=>{await this.load(i),await this.play(i);});await Promise.all(n);}}if(t.hasOwnProperty("mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,i=Object.values(e).map(async({soundAlias:r,channelAlias:a})=>(n.add(a),await this.load(r)));await Promise.all(i),this.channels.forEach(r=>{(!r.background||!n.has(r.alias))&&r.stopAll();});let o=Object.keys(e).map(async r=>{let a=e[r],h=this.findChannel(a.channelAlias);if(h.background)if(a.stepCounter===GameUnifier.stepCounter||!this.find(r)){let d=await h.play(r,a.soundAlias,{...a.options,filters:I(a.options.filters||[])});a.paused&&(d.paused=a.paused);}else {let d=this.find(r);d&&(s.mediaInstances[r].options={...a.options,filters:I(a.options.filters||[])},d.paused!==a.paused&&(d.paused=a.paused),d.loop!==(a.options.loop||!1)&&(d.loop=a.options.loop||!1),d.volume!==(a.options.volume??1)&&(d.volume=a.options.volume??1),d.muted!==(a.options.muted||!1)&&(d.muted=a.options.muted||!1),d.speed!==(a.options.speed??1)&&(d.speed=a.options.speed??1));}else {let d=await h.play(r,a.soundAlias,{...a.options,filters:I(a.options.filters||[])});a.paused&&(d.paused=a.paused);}});await Promise.all(o);}}if(t.hasOwnProperty("filters")){let e=t.filters;e&&(this.filtersAll=I(e));}}catch(e){j.error("Error importing data",e);}}};var v={DistortionFilter:filters.DistortionFilter,EqualizerFilter:filters.EqualizerFilter,MonoFilter:filters.MonoFilter,ReverbFilter:filters.ReverbFilter,StereoFilter:filters.StereoFilter,StreamFilter:filters.StreamFilter,TelephoneFilter:filters.TelephoneFilter};var ce=new A;GameUnifier.addOnPreContinue(async()=>{try{s.delayTimeoutInstances.forEach(u=>{clearTimeout(u[0]);let t=s.mediaInstances[u[1]];t&&(t.instance.paused=!1);}),s.delayTimeoutInstances=[],Object.values(s.channels).forEach(u=>{u.background||u.stopAll();});}catch{}});export{s as SoundManagerStatic,v as filters,ce as sound};
|
|
1
|
+
import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {e,d,f,g as g$1}from'./chunk-6HI66YQL.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import se 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;(o=>(o.mediaInstances=new Map,o.channels=new Map,o.transients=new Set,o.systemPausedAliases=new Set,o.bufferRegistry=new e({cacheSize:10})))(C||(C={}));var i=C;function w(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 oe(a){if(a)return Array.from(a).reduce((t,e)=>(e instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:Time(e.decay).toSeconds(),preDelay:Time(e.preDelay).toSeconds()}):e instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):f.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function J(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function m(a){return a<=0?-1/0:20*Math.log10(a)}function g(a){return a<=-1/0?0:10**(a/20)}async function T(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=se.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 b=class extends Player{constructor(e,n,r,o,s={},l){super(s);d(this,"alias",e);d(this,"channelAlias",n);d(this,"soundAlias",r);d(this,"stepCounter",o);d(this,"delay",l);d(this,"options");d(this,"filters",new Set);d(this,"pausedAt");d(this,"playStartTime",now());this.options=s;}get memory(){let e=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!==m(e.volume??1)&&(this.volume.value=m(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?super.start(`+${this.delay}`,r):super.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)}chain(...e){return e.forEach(n=>{J(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return J(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var v=class{constructor(t,e={}){d(this,"alias",t);d(this,"toneChannel");d(this,"background");this.background=e.background??false,this.toneChannel=new Channel({volume:m(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=m(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:o,elapsed:s,filters:l=[],muted:h,autostart:y=true,speed:p,volume:P,...f$1}=n;h!==void 0&&(f.warn(`MediaInstance "${t}" is being created with muted=${h}. This will override the channel's muted state (${this.muted}).`),f$1.mute=h),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 A=new b(t,this.alias,e,GameUnifier.stepCounter,{...f$1,volume:P!==void 0?m(P):void 0,url:r},o).chain(...l,this.toneChannel);return y&&(o?A.start(`+${o}`,s):A.start(void 0,s)),A}async play(t,e,n){let r,o;if(typeof e=="string"?(r=t,o=e):(r=t,o=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 T(o);let s=this._createPlayer(r,o,n);return i.mediaInstances.set(r,s),s}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 F=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=m(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,o;typeof e=="string"?(r=t,o=e):(r=t,o=t,n=e),i.bufferRegistry.has(o)||await this.load(o);let{channel:s=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(s).play(r,o,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,...o}=e??{},s=new c.Player({...o,url:n}).toDestination();return r&&s.start(),i.transients.add(s),s.onstop=()=>{s.dispose(),i.transients.delete(s);},s}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(T);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{f.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=se.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await se.Assets.loadBundle(t),r=[];for(let o in n)i.bufferRegistry.has(o)||r.push(this.load(o));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 o={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(r,o);});return}if(i.channels.has(t)){f.warn(`Channel with alias ${t} already exists.`);return}let n=new v(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:oe(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:s,channelAlias:l})=>(n.add(l),await this.load(s)));await Promise.all(r),this.channels.forEach(s=>{(!s.background||!n.has(s.alias))&&s.stopAll();});let o=Object.keys(e).map(async s=>{let l=e[s],h=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(h.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(s)){let p=await h.play(s,l.soundAlias,{...l.options,autostart:!y,filters:w(l.options.filters||[]),delay:l.options.delay});p.paused=y;}else {let p=i.mediaInstances.get(s);if(!p){f.warn(`No media instance found with alias ${s} while restoring background state.`);return}p.memory={...l.options,paused:y},[...p.filters].forEach(f=>{p.disconnect(f),f.dispose();}),p.chain(...w(l.options.filters||[]));}else {let p=await h.play(s,l.soundAlias,{...l.options,autostart:!y,filters:w(l.options.filters||[]),delay:l.options.delay});p.paused=y;}});await Promise.all(o);}}}catch(e){f.error("Error importing data",e);}}};var te=new F;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 $t=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var m=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),zt=(u,e,i)=>e.has(u)||$t("Cannot "+i);var t=(u,e,i)=>(zt(u,e,"read from private field"),i?i.call(u):e.get(u)),g=(u,e,i)=>e.has(u)?$t("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(zt(u,e,"write to private field"),e.set(u,i),i),h=(u,e,i)=>(zt(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,e,s)}});var rt="storage",ct="temp",W="narration",Ft="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ut;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(ut||(ut={}));function Ot(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw ut.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xt=new Set,Yt=typeof process=="object"&&process?process:{},Jt=(u,e,i,s)=>{typeof Yt.emitWarning=="function"?Yt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Lt=globalThis.AbortController,kt=globalThis.AbortSignal;if(typeof Lt>"u"){kt=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Lt=class{constructor(){m(this,"signal",new kt);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let u=Yt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,Jt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var re=u=>!Xt.has(u);var at=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),qt=u=>at(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ct:null:null,Ct=class extends Array{constructor(u){super(u),this.fill(0);}},et,St,ae=(et=class{constructor(e,i){m(this,"heap");m(this,"length");if(!t(et,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=qt(e);if(!i)return [];f(et,St,true);let s=new et(e,i);return f(et,St,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,g(et,St,false),et),Ht,Bt,$,V,k,ft,H,bt,Tt,B,O,X,w,A,_,C,U,N,R,J,x,q,Q,z,Y,Z,lt,M,At,n,Pt,_t,it,xt,P,Zt,pt,yt,Dt,ot,nt,Kt,Mt,Gt,T,Wt,Rt,ht,jt,vt,Qt=(vt=class{constructor(e){g(this,n);g(this,$);g(this,V);g(this,k);g(this,ft);g(this,H);g(this,bt);g(this,Tt);g(this,B);m(this,"ttl");m(this,"ttlResolution");m(this,"ttlAutopurge");m(this,"updateAgeOnGet");m(this,"updateAgeOnHas");m(this,"allowStale");m(this,"noDisposeOnSet");m(this,"noUpdateTTL");m(this,"maxEntrySize");m(this,"sizeCalculation");m(this,"noDeleteOnFetchRejection");m(this,"noDeleteOnStaleGet");m(this,"allowStaleOnFetchAbort");m(this,"allowStaleOnFetchRejection");m(this,"ignoreFetchAbort");g(this,O);g(this,X);g(this,w);g(this,A);g(this,_);g(this,C);g(this,U);g(this,N);g(this,R);g(this,J);g(this,x);g(this,q);g(this,Q);g(this,z);g(this,Y);g(this,Z);g(this,lt);g(this,M);g(this,At);g(this,_t,()=>{});g(this,it,()=>{});g(this,xt,()=>{});g(this,P,()=>false);g(this,pt,e=>{});g(this,yt,(e,i,s)=>{});g(this,Dt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,Ht,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:c,dispose:E,onInsert:D,disposeAfter:S,noDisposeOnSet:st,noUpdateTTL:K,maxSize:tt=0,maxEntrySize:y=0,sizeCalculation:b,fetchMethod:p,memoMethod:I,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:F,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:wt,ignoreFetchAbort:gt,perf:mt}=e;if(mt!==void 0&&typeof mt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,B,mt??se),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let Et=i?qt(i):Array;if(!Et)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,V,tt),this.maxEntrySize=y||t(this,V),this.sizeCalculation=b,this.sizeCalculation){if(!t(this,V)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(I!==void 0&&typeof I!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Tt,I),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,bt,p),f(this,lt,!!p),f(this,w,new Map),f(this,A,new Array(i).fill(void 0)),f(this,_,new Array(i).fill(void 0)),f(this,C,new Et(i)),f(this,U,new Et(i)),f(this,N,0),f(this,R,0),f(this,J,ae.create(i)),f(this,O,0),f(this,X,0),typeof E=="function"&&f(this,k,E),typeof D=="function"&&f(this,ft,D),typeof S=="function"?(f(this,H,S),f(this,x,[])):(f(this,H,void 0),f(this,x,void 0)),f(this,Z,!!t(this,k)),f(this,At,!!t(this,ft)),f(this,M,!!t(this,H)),this.noDisposeOnSet=!!st,this.noUpdateTTL=!!K,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!wt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,V)!==0&&!at(t(this,V)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,n,Zt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!F,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,n,Pt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,V)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,V)){let Ut="LRU_CACHE_UNBOUNDED";re(Ut)&&(Xt.add(Ut),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ut,vt));}}get perf(){return t(this,B)}static unsafeExposeInternals(e){return {starts:t(e,Q),ttls:t(e,z),autopurgeTimers:t(e,Y),sizes:t(e,q),keyMap:t(e,w),keyList:t(e,A),valList:t(e,_),next:t(e,C),prev:t(e,U),get head(){return t(e,N)},get tail(){return t(e,R)},free:t(e,J),isBackgroundFetch:i=>{var s;return h(s=e,n,T).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return h(a=e,n,Gt).call(a,i,s,r,o)},moveToTail:i=>{var s;return h(s=e,n,Rt).call(s,i)},indexes:i=>{var s;return h(s=e,n,ot).call(s,i)},rindexes:i=>{var s;return h(s=e,n,nt).call(s,i)},isStale:i=>{var s;return t(s=e,P).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,V)}get calculatedSize(){return t(this,X)}get size(){return t(this,O)}get fetchMethod(){return t(this,bt)}get memoMethod(){return t(this,Tt)}get dispose(){return t(this,k)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,H)}getRemainingTTL(e){return t(this,w).has(e)?1/0:0}*entries(){for(let e of h(this,n,ot).call(this))t(this,_)[e]!==void 0&&t(this,A)[e]!==void 0&&!h(this,n,T).call(this,t(this,_)[e])&&(yield [t(this,A)[e],t(this,_)[e]]);}*rentries(){for(let e of h(this,n,nt).call(this))t(this,_)[e]!==void 0&&t(this,A)[e]!==void 0&&!h(this,n,T).call(this,t(this,_)[e])&&(yield [t(this,A)[e],t(this,_)[e]]);}*keys(){for(let e of h(this,n,ot).call(this)){let i=t(this,A)[e];i!==void 0&&!h(this,n,T).call(this,t(this,_)[e])&&(yield i);}}*rkeys(){for(let e of h(this,n,nt).call(this)){let i=t(this,A)[e];i!==void 0&&!h(this,n,T).call(this,t(this,_)[e])&&(yield i);}}*values(){for(let e of h(this,n,ot).call(this))t(this,_)[e]!==void 0&&!h(this,n,T).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}*rvalues(){for(let e of h(this,n,nt).call(this))t(this,_)[e]!==void 0&&!h(this,n,T).call(this,t(this,_)[e])&&(yield t(this,_)[e]);}[(Bt=Symbol.iterator,Ht=Symbol.toStringTag,Bt)](){return this.entries()}find(e,i={}){for(let s of h(this,n,ot).call(this)){let r=t(this,_)[s],o=h(this,n,T).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,A)[s],this))return this.get(t(this,A)[s],i)}}forEach(e,i=this){for(let s of h(this,n,ot).call(this)){let r=t(this,_)[s],o=h(this,n,T).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,A)[s],this);}}rforEach(e,i=this){for(let s of h(this,n,nt).call(this)){let r=t(this,_)[s],o=h(this,n,T).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,A)[s],this);}}purgeStale(){let e=false;for(let i of h(this,n,nt).call(this,{allowStale:true}))t(this,P).call(this,i)&&(h(this,n,ht).call(this,t(this,A)[i],"expire"),e=true);return e}info(e){let i=t(this,w).get(e);if(i===void 0)return;let s=t(this,_)[i],r=h(this,n,T).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,z)&&t(this,Q)){let a=t(this,z)[i],l=t(this,Q)[i];if(a&&l){let c=a-(t(this,B).now()-l);o.ttl=c,o.start=Date.now();}}return t(this,q)&&(o.size=t(this,q)[i]),o}dump(){let e=[];for(let i of h(this,n,ot).call(this,{allowStale:true})){let s=t(this,A)[i],r=t(this,_)[i],o=h(this,n,T).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,z)&&t(this,Q)){a.ttl=t(this,z)[i];let l=t(this,B).now()-t(this,Q)[i];a.start=Math.floor(Date.now()-l);}t(this,q)&&(a.size=t(this,q)[i]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,B).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var st,K,tt,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,{noUpdateTTL:E=this.noUpdateTTL}=s,D=t(this,Dt).call(this,e,i,s.size||0,l);if(this.maxEntrySize&&D>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,n,ht).call(this,e,"set"),this;let S=t(this,O)===0?void 0:t(this,w).get(e);if(S===void 0)S=t(this,O)===0?t(this,R):t(this,J).length!==0?t(this,J).pop():t(this,O)===t(this,$)?h(this,n,Mt).call(this,false):t(this,O),t(this,A)[S]=e,t(this,_)[S]=i,t(this,w).set(e,S),t(this,C)[t(this,R)]=S,t(this,U)[S]=t(this,R),f(this,R,S),It(this,O)._++,t(this,yt).call(this,S,D,c),c&&(c.set="add"),E=false,t(this,At)&&((st=t(this,ft))==null||st.call(this,i,e,"add"));else {h(this,n,Rt).call(this,S);let b=t(this,_)[S];if(i!==b){if(t(this,lt)&&h(this,n,T).call(this,b)){b.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=b;p!==void 0&&!a&&(t(this,Z)&&((K=t(this,k))==null||K.call(this,p,e,"set")),t(this,M)&&t(this,x)?.push([p,e,"set"]));}else a||(t(this,Z)&&((tt=t(this,k))==null||tt.call(this,b,e,"set")),t(this,M)&&t(this,x)?.push([b,e,"set"]));if(t(this,pt).call(this,S),t(this,yt).call(this,S,D,c),t(this,_)[S]=i,c){c.set="replace";let p=b&&h(this,n,T).call(this,b)?b.__staleWhileFetching:b;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");t(this,At)&&this.onInsert?.(i,e,i===b?"update":"replace");}if(r!==0&&!t(this,z)&&h(this,n,Pt).call(this),t(this,z)&&(E||t(this,xt).call(this,S,r,o),c&&t(this,it).call(this,c,S)),!a&&t(this,M)&&t(this,x)){let b=t(this,x),p;for(;p=b?.shift();)(y=t(this,H))==null||y.call(this,...p);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,_)[t(this,N)];if(h(this,n,Mt).call(this,!0),h(this,n,T).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,M)&&t(this,x)){let i=t(this,x),s;for(;s=i?.shift();)(e=t(this,H))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,w).get(e);if(o!==void 0){let a=t(this,_)[o];if(h(this,n,T).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,P).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,_t).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,w).get(e);if(r===void 0||!s&&t(this,P).call(this,r))return;let o=t(this,_)[r];return h(this,n,T).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:E=this.sizeCalculation,noUpdateTTL:D=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:st=this.allowStaleOnFetchRejection,ignoreFetchAbort:K=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:y,forceRefresh:b=false,status:p,signal:I}=i;if(!t(this,lt))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});let L={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:c,sizeCalculation:E,noUpdateTTL:D,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:st,allowStaleOnFetchAbort:tt,ignoreFetchAbort:K,status:p,signal:I},F=t(this,w).get(e);if(F===void 0){p&&(p.fetch="miss");let v=h(this,n,Gt).call(this,e,F,L,y);return v.__returned=v}else {let v=t(this,_)[F];if(h(this,n,T).call(this,v)){let Et=s&&v.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",Et&&(p.returnedStale=true)),Et?v.__staleWhileFetching:v.__returned=v}let wt=t(this,P).call(this,F);if(!b&&!wt)return p&&(p.fetch="hit"),h(this,n,Rt).call(this,F),r&&t(this,_t).call(this,F),p&&t(this,it).call(this,p,F),v;let gt=h(this,n,Gt).call(this,e,F,L,y),mt=gt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=wt?"stale":"refresh",mt&&wt&&(p.returnedStale=true)),mt?gt.__staleWhileFetching:gt.__returned=gt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,Tt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,l=this.get(e,a);if(!o&&l!==void 0)return l;let c=s(e,l,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,l=t(this,w).get(e);if(l!==void 0){let c=t(this,_)[l],E=h(this,n,T).call(this,c);return a&&t(this,it).call(this,a,l),t(this,P).call(this,l)?(a&&(a.get="stale"),E?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||h(this,n,ht).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),E?c.__staleWhileFetching:(h(this,n,Rt).call(this,l),r&&t(this,_t).call(this,l),c))}else a&&(a.get="miss");}delete(e){return h(this,n,ht).call(this,e,"delete")}clear(){return h(this,n,jt).call(this,"delete")}},$=new WeakMap,V=new WeakMap,k=new WeakMap,ft=new WeakMap,H=new WeakMap,bt=new WeakMap,Tt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,w=new WeakMap,A=new WeakMap,_=new WeakMap,C=new WeakMap,U=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,q=new WeakMap,Q=new WeakMap,z=new WeakMap,Y=new WeakMap,Z=new WeakMap,lt=new WeakMap,M=new WeakMap,At=new WeakMap,n=new WeakSet,Pt=function(){let e=new Ct(t(this,$)),i=new Ct(t(this,$));f(this,z,e),f(this,Q,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,Y,s),f(this,xt,(l,c,E=t(this,B).now())=>{i[l]=c!==0?E:0,e[l]=c,r(l,c);}),f(this,_t,l=>{i[l]=e[l]!==0?t(this,B).now():0,r(l,e[l]);});let r=this.ttlAutopurge?(l,c)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),c&&c!==0&&s){let E=setTimeout(()=>{t(this,P).call(this,l)&&h(this,n,ht).call(this,t(this,A)[l],"expire");},c+1);E.unref&&E.unref(),s[l]=E;}}:()=>{};f(this,it,(l,c)=>{if(e[c]){let E=e[c],D=i[c];if(!E||!D)return;l.ttl=E,l.start=D,l.now=o||a();let S=l.now-D;l.remainingTTL=E-S;}});let o=0,a=()=>{let l=t(this,B).now();if(this.ttlResolution>0){o=l;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return l};this.getRemainingTTL=l=>{let c=t(this,w).get(l);if(c===void 0)return 0;let E=e[c],D=i[c];if(!E||!D)return 1/0;let S=(o||a())-D;return E-S},f(this,P,l=>{let c=i[l],E=e[l];return !!E&&!!c&&(o||a())-c>E});},_t=new WeakMap,it=new WeakMap,xt=new WeakMap,P=new WeakMap,Zt=function(){let e=new Ct(t(this,$));f(this,X,0),f(this,q,e),f(this,pt,i=>{f(this,X,t(this,X)-e[i]),e[i]=0;}),f(this,Dt,(i,s,r,o)=>{if(h(this,n,T).call(this,s))return 0;if(!at(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!at(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),f(this,yt,(i,s,r)=>{if(e[i]=s,t(this,V)){let o=t(this,V)-e[i];for(;t(this,X)>o;)h(this,n,Mt).call(this,true);}f(this,X,t(this,X)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,X));});},pt=new WeakMap,yt=new WeakMap,Dt=new WeakMap,ot=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,R);!(!h(this,n,Kt).call(this,i)||((e||!t(this,P).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,U)[i];},nt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,N);!(!h(this,n,Kt).call(this,i)||((e||!t(this,P).call(this,i))&&(yield i),i===t(this,R)));)i=t(this,C)[i];},Kt=function(e){return e!==void 0&&t(this,w).get(t(this,A)[e])===e},Mt=function(e){var o;let i=t(this,N),s=t(this,A)[i],r=t(this,_)[i];return t(this,lt)&&h(this,n,T).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,Z)||t(this,M))&&(t(this,Z)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,M)&&t(this,x)?.push([r,s,"evict"])),t(this,pt).call(this,i),t(this,Y)?.[i]&&(clearTimeout(t(this,Y)[i]),t(this,Y)[i]=void 0),e&&(t(this,A)[i]=void 0,t(this,_)[i]=void 0,t(this,J).push(i)),t(this,O)===1?(f(this,N,f(this,R,0)),t(this,J).length=0):f(this,N,t(this,C)[i]),t(this,w).delete(s),It(this,O)._--,i},Gt=function(e,i,s,r){let o=i===void 0?void 0:t(this,_)[i];if(h(this,n,T).call(this,o))return o;let a=new Lt,{signal:l}=s;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},E=(y,b=false)=>{let{aborted:p}=a.signal,I=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(p&&!b?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!I&&!b)return S(a.signal.reason,L);let F=K,v=t(this,_)[i];return (v===K||I&&b&&v===void 0)&&(y===void 0?F.__staleWhileFetching!==void 0?t(this,_)[i]=F.__staleWhileFetching:h(this,n,ht).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},D=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),S(y,false)),S=(y,b)=>{let{aborted:p}=a.signal,I=p&&s.allowStaleOnFetchAbort,L=I||s.allowStaleOnFetchRejection,F=L||s.noDeleteOnFetchRejection,v=K;if(t(this,_)[i]===K&&(!F||!b&&v.__staleWhileFetching===void 0?h(this,n,ht).call(this,e,"fetch"):I||(t(this,_)[i]=v.__staleWhileFetching)),L)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw y},st=(y,b)=>{var I;let p=(I=t(this,bt))==null?void 0:I.call(this,e,o,c);p&&p instanceof Promise&&p.then(L=>y(L===void 0?void 0:L),b),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>E(L,true)));});};s.status&&(s.status.fetchDispatched=true);let K=new Promise(st).then(E,D),tt=Object.assign(K,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,tt,{...c.options,status:void 0}),i=t(this,w).get(e)):t(this,_)[i]=tt,tt},T=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Lt},Wt=function(e,i){t(this,U)[i]=e,t(this,C)[e]=i;},Rt=function(e){e!==t(this,R)&&(e===t(this,N)?f(this,N,t(this,C)[e]):h(this,n,Wt).call(this,t(this,U)[e],t(this,C)[e]),h(this,n,Wt).call(this,t(this,R),e),f(this,R,e));},ht=function(e,i){var r,o;let s=false;if(t(this,O)!==0){let a=t(this,w).get(e);if(a!==void 0)if(t(this,Y)?.[a]&&(clearTimeout(t(this,Y)?.[a]),t(this,Y)[a]=void 0),s=true,t(this,O)===1)h(this,n,jt).call(this,i);else {t(this,pt).call(this,a);let l=t(this,_)[a];if(h(this,n,T).call(this,l)?l.__abortController.abort(new Error("deleted")):(t(this,Z)||t(this,M))&&(t(this,Z)&&((r=t(this,k))==null||r.call(this,l,e,i)),t(this,M)&&t(this,x)?.push([l,e,i])),t(this,w).delete(e),t(this,A)[a]=void 0,t(this,_)[a]=void 0,a===t(this,R))f(this,R,t(this,U)[a]);else if(a===t(this,N))f(this,N,t(this,C)[a]);else {let c=t(this,U)[a];t(this,C)[c]=t(this,C)[a];let E=t(this,C)[a];t(this,U)[E]=t(this,U)[a];}It(this,O)._--,t(this,J).push(a);}}if(t(this,M)&&t(this,x)?.length){let a=t(this,x),l;for(;l=a?.shift();)(o=t(this,H))==null||o.call(this,...l);}return s},jt=function(e){var i,s;for(let r of h(this,n,nt).call(this,{allowStale:true})){let o=t(this,_)[r];if(h(this,n,T).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,A)[r];t(this,Z)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,M)&&t(this,x)?.push([o,a,e]);}}if(t(this,w).clear(),t(this,_).fill(void 0),t(this,A).fill(void 0),t(this,z)&&t(this,Q)){t(this,z).fill(0),t(this,Q).fill(0);for(let r of t(this,Y)??[])r!==void 0&&clearTimeout(r);t(this,Y)?.fill(void 0);}if(t(this,q)&&t(this,q).fill(0),f(this,N,0),f(this,R,0),t(this,J).length=0,f(this,X,0),f(this,O,0),t(this,M)&&t(this,x)){let r=t(this,x),o;for(;o=r?.shift();)(s=t(this,H))==null||s.call(this,...o);}},vt);var dt=class{constructor(e){m(this,"cache");m(this,"map",new Map);this.cache=new Qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var G=class G{constructor(){}static clearOldTempVariables(e){G.tempStorageDeadlines.forEach((i,s)=>{i>e&&(G.removeVariable(ct,s),G.tempStorageDeadlines.delete(s));});}static setVariable(e,i,s){s==null?G.storage.delete(`${e}:${i}`):G.storage.set(`${e}:${i}`,s);}static getVariable(e,i){let s=G.storage.get(`${e}:${i}`);return Ot(s)}static removeVariable(e,i){G.storage.delete(`${e}:${i}`);}static setFlag(e,i){let s=G.storage.get(Ft)||[];if(i)s.includes(e)||s.push(e);else {let r=s.indexOf(e);r>-1&&s.splice(r,1);}G.storage.set(Ft,s);}static getFlag(e){return (G.storage.get(Ft)||[]).includes(e)}};m(G,"storage",new dt({cacheSize:50})),m(G,"default",new dt({cacheSize:10})),m(G,"tempStorageDeadlines",new Map);var d=G;var Nt=class{get base(){return d.storage.map}get cache(){return d.storage.cache}get tempStorageDeadlines(){return d.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{d.default.map.set(i,s);});}set(e,i){return d.setVariable(rt,e,i)}get(e){let i=d.getVariable(ct,e);return i===void 0&&(i=d.getVariable(rt,e)),i===void 0&&(i=Ot(d.default.get(e))),i}remove(e){return this.removeTempVariable(e),d.removeVariable(rt,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else d.setVariable(ct,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){d.removeVariable(ct,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return d.setFlag(e,i)}getFlag(e){return d.getFlag(e)}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...d.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Ot({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":d.setVariable(W,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":d.setVariable(W,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":d.setVariable(W,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":d.setVariable(W,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":d.setVariable(W,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":d.setVariable(W,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":d.setVariable(W,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":d.setVariable(W,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":d.setVariable(W,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":d.setVariable(W,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":d.setVariable(W,j.LAST_STEP_GLUED,i.value);break;default:d.setVariable(rt,i.key,i.value);}}),e.temp?.forEach(i=>{d.setVariable(ct,i.key,i.value);}),e.flags?.forEach(i=>{d.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):ut.warn("No storage data found");}catch(i){ut.error("Error importing data",i);}}};var Vt=class{constructor(e,i){m(this,"id");m(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=d.getVariable(rt,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{d.setVariable(this.categoryId,`${s}:${o}`,a);});}),d.removeVariable(rt,e));}setStorageProperty(e,i){d.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return d.getVariable(this.categoryId,`${i}:${e}`)}};var ze=new Nt;exports.StorageManagerStatic=d;exports.StoredClassModel=Vt;exports.storage=ze;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var jt=u=>{throw TypeError(u)};var ee=(u,e,i)=>e in u?te(u,e,{enumerable:true,configurable:true,writable:true,value:i}):u[e]=i;var E=(u,e,i)=>ee(u,typeof e!="symbol"?e+"":e,i),Ut=(u,e,i)=>e.has(u)||jt("Cannot "+i);var t=(u,e,i)=>(Ut(u,e,"read from private field"),i?i.call(u):e.get(u)),d=(u,e,i)=>e.has(u)?jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,i),f=(u,e,i,s)=>(Ut(u,e,"write to private field"),e.set(u,i),i),l=(u,e,i)=>(Ut(u,e,"access private method"),i);var It=(u,e,i,s)=>({set _(r){f(u,e,r);},get _(){return t(u,e,s)}});var st="storage",ht="temp",H="narration",Nt="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ct;(r=>(r.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),r.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),r.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),r.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(ct||(ct={}));function Ot(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw ct.error("Error creating exportable element",u,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Xt=new Set,zt=typeof process=="object"&&process?process:{},Jt=(u,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(u,e,i,s):console.error(`[${i}] ${e}: ${u}`);},Gt=globalThis.AbortController,$t=globalThis.AbortSignal;if(typeof Gt>"u"){$t=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){E(this,"signal",new $t);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let u=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,Jt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var re=u=>!Xt.has(u);var rt=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),qt=u=>rt(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(u){super(u),this.fill(0);}},et,St,oe=(et=class{constructor(e,i){E(this,"heap");E(this,"length");if(!t(et,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=qt(e);if(!i)return [];f(et,St,true);let s=new et(e,i);return f(et,St,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,d(et,St,false),et),kt,Bt,$,z,k,ut,B,mt,Et,X,D,J,R,w,p,V,Y,C,N,q,F,Q,Z,P,K,tt,lt,L,Tt,n,Yt,ft,it,xt,W,Zt,pt,bt,Rt,ot,at,Pt,Ct,Mt,O,Kt,wt,nt,Wt,yt,Qt=(yt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ut);d(this,B);d(this,mt);d(this,Et);d(this,X);E(this,"ttl");E(this,"ttlResolution");E(this,"ttlAutopurge");E(this,"updateAgeOnGet");E(this,"updateAgeOnHas");E(this,"allowStale");E(this,"noDisposeOnSet");E(this,"noUpdateTTL");E(this,"maxEntrySize");E(this,"sizeCalculation");E(this,"noDeleteOnFetchRejection");E(this,"noDeleteOnStaleGet");E(this,"allowStaleOnFetchAbort");E(this,"allowStaleOnFetchRejection");E(this,"ignoreFetchAbort");d(this,D);d(this,J);d(this,R);d(this,w);d(this,p);d(this,V);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,P);d(this,K);d(this,tt);d(this,lt);d(this,L);d(this,Tt);d(this,ft,()=>{});d(this,it,()=>{});d(this,xt,()=>{});d(this,W,()=>false);d(this,pt,e=>{});d(this,bt,(e,i,s)=>{});d(this,Rt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});E(this,kt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:c,dispose:m,onInsert:I,disposeAfter:_,noDisposeOnSet:y,noUpdateTTL:b,maxSize:T=0,maxEntrySize:A=0,sizeCalculation:v,fetchMethod:g,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:vt,ignoreFetchAbort:_t,perf:gt}=e;if(gt!==void 0&&typeof gt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,gt??se),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?qt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(f(this,$,i),f(this,z,T),this.maxEntrySize=A||t(this,z),this.sizeCalculation=v,this.sizeCalculation){if(!t(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Et,M),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,mt,g),f(this,lt,!!g),f(this,R,new Map),f(this,w,new Array(i).fill(void 0)),f(this,p,new Array(i).fill(void 0)),f(this,V,new dt(i)),f(this,Y,new dt(i)),f(this,C,0),f(this,N,0),f(this,q,oe.create(i)),f(this,D,0),f(this,J,0),typeof m=="function"&&f(this,k,m),typeof I=="function"&&f(this,ut,I),typeof _=="function"?(f(this,B,_),f(this,F,[])):(f(this,B,void 0),f(this,F,void 0)),f(this,tt,!!t(this,k)),f(this,Tt,!!t(this,ut)),f(this,L,!!t(this,B)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!_t,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Zt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!a,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Lt="LRU_CACHE_UNBOUNDED";re(Lt)&&(Xt.add(Lt),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Lt,yt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,P),autopurgeTimers:t(e,K),sizes:t(e,Q),keyMap:t(e,R),keyList:t(e,w),valList:t(e,p),next:t(e,V),prev:t(e,Y),get head(){return t(e,C)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,O).call(s,i)},backgroundFetch:(i,s,r,a)=>{var o;return l(o=e,n,Mt).call(o,i,s,r,a)},moveToTail:i=>{var s;return l(s=e,n,wt).call(s,i)},indexes:i=>{var s;return l(s=e,n,ot).call(s,i)},rindexes:i=>{var s;return l(s=e,n,at).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,D)}get fetchMethod(){return t(this,mt)}get memoMethod(){return t(this,Et)}get dispose(){return t(this,k)}get onInsert(){return t(this,ut)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&t(this,w)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield [t(this,w)[e],t(this,p)[e]]);}*rentries(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&t(this,w)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield [t(this,w)[e],t(this,p)[e]]);}*keys(){for(let e of l(this,n,ot).call(this)){let i=t(this,w)[e];i!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,at).call(this)){let i=t(this,w)[e];i!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield i);}}*values(){for(let e of l(this,n,ot).call(this))t(this,p)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}*rvalues(){for(let e of l(this,n,at).call(this))t(this,p)[e]!==void 0&&!l(this,n,O).call(this,t(this,p)[e])&&(yield t(this,p)[e]);}[(Bt=Symbol.iterator,kt=Symbol.toStringTag,Bt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(a!==void 0&&e(a,t(this,w)[s],this))return this.get(t(this,w)[s],i)}}forEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,p)[s],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&e.call(i,a,t(this,w)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,p)[s],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;a!==void 0&&e.call(i,a,t(this,w)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,at).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,w)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,p)[i],r=l(this,n,O).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let a={value:r};if(t(this,P)&&t(this,Z)){let o=t(this,P)[i],h=t(this,Z)[i];if(o&&h){let c=o-(t(this,X).now()-h);a.ttl=c,a.start=Date.now();}}return t(this,Q)&&(a.size=t(this,Q)[i]),a}dump(){let e=[];for(let i of l(this,n,ot).call(this,{allowStale:true})){let s=t(this,w)[i],r=t(this,p)[i],a=l(this,n,O).call(this,r)?r.__staleWhileFetching:r;if(a===void 0||s===void 0)continue;let o={value:a};if(t(this,P)&&t(this,Z)){o.ttl=t(this,P)[i];let h=t(this,X).now()-t(this,Z)[i];o.start=Math.floor(Date.now()-h);}t(this,Q)&&(o.size=t(this,Q)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var y,b,T,A;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:m=this.noUpdateTTL}=s,I=t(this,Rt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let _=t(this,D)===0?void 0:t(this,R).get(e);if(_===void 0)_=t(this,D)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,D)===t(this,$)?l(this,n,Ct).call(this,false):t(this,D),t(this,w)[_]=e,t(this,p)[_]=i,t(this,R).set(e,_),t(this,V)[t(this,N)]=_,t(this,Y)[_]=t(this,N),f(this,N,_),It(this,D)._++,t(this,bt).call(this,_,I,c),c&&(c.set="add"),m=false,t(this,Tt)&&((y=t(this,ut))==null||y.call(this,i,e,"add"));else {l(this,n,wt).call(this,_);let v=t(this,p)[_];if(i!==v){if(t(this,lt)&&l(this,n,O).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=v;g!==void 0&&!o&&(t(this,tt)&&((b=t(this,k))==null||b.call(this,g,e,"set")),t(this,L)&&t(this,F)?.push([g,e,"set"]));}else o||(t(this,tt)&&((T=t(this,k))==null||T.call(this,v,e,"set")),t(this,L)&&t(this,F)?.push([v,e,"set"]));if(t(this,pt).call(this,_),t(this,bt).call(this,_,I,c),t(this,p)[_]=i,c){c.set="replace";let g=v&&l(this,n,O).call(this,v)?v.__staleWhileFetching:v;g!==void 0&&(c.oldValue=g);}}else c&&(c.set="update");t(this,Tt)&&this.onInsert?.(i,e,i===v?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(m||t(this,xt).call(this,_,r,a),c&&t(this,it).call(this,c,_)),!o&&t(this,L)&&t(this,F)){let v=t(this,F),g;for(;g=v?.shift();)(A=t(this,B))==null||A.call(this,...g);}return this}pop(){var e;try{for(;t(this,D);){let i=t(this,p)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,O).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,a=t(this,R).get(e);if(a!==void 0){let o=t(this,p)[a];if(l(this,n,O).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,a))r&&(r.has="stale",t(this,it).call(this,r,a));else return s&&t(this,ft).call(this,a),r&&(r.has="hit",t(this,it).call(this,r,a)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,R).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let a=t(this,p)[r];return l(this,n,O).call(this,a)?a.__staleWhileFetching:a}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:m=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:b=this.ignoreFetchAbort,allowStaleOnFetchAbort:T=this.allowStaleOnFetchAbort,context:A,forceRefresh:v=false,status:g,signal:M}=i;if(!t(this,lt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,status:g});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:h,size:c,sizeCalculation:m,noUpdateTTL:I,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:T,ignoreFetchAbort:b,status:g,signal:M},G=t(this,R).get(e);if(G===void 0){g&&(g.fetch="miss");let x=l(this,n,Mt).call(this,e,G,U,A);return x.__returned=x}else {let x=t(this,p)[G];if(l(this,n,O).call(this,x)){let dt=s&&x.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",dt&&(g.returnedStale=true)),dt?x.__staleWhileFetching:x.__returned=x}let vt=t(this,W).call(this,G);if(!v&&!vt)return g&&(g.fetch="hit"),l(this,n,wt).call(this,G),r&&t(this,ft).call(this,G),g&&t(this,it).call(this,g,G),x;let _t=l(this,n,Mt).call(this,e,G,U,A),gt=_t.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=vt?"stale":"refresh",gt&&vt&&(g.returnedStale=true)),gt?_t.__staleWhileFetching:_t.__returned=_t}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,Et);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:a,...o}=i,h=this.get(e,o);if(!a&&h!==void 0)return h;let c=s(e,h,{options:o,context:r});return this.set(e,c,o),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=i,h=t(this,R).get(e);if(h!==void 0){let c=t(this,p)[h],m=l(this,n,O).call(this,c);return o&&t(this,it).call(this,o,h),t(this,W).call(this,h)?(o&&(o.get="stale"),m?(o&&s&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?c.__staleWhileFetching:void 0):(a||l(this,n,nt).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?c:void 0)):(o&&(o.get="hit"),m?c.__staleWhileFetching:(l(this,n,wt).call(this,h),r&&t(this,ft).call(this,h),c))}else o&&(o.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ut=new WeakMap,B=new WeakMap,mt=new WeakMap,Et=new WeakMap,X=new WeakMap,D=new WeakMap,J=new WeakMap,R=new WeakMap,w=new WeakMap,p=new WeakMap,V=new WeakMap,Y=new WeakMap,C=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,K=new WeakMap,tt=new WeakMap,lt=new WeakMap,L=new WeakMap,Tt=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));f(this,P,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;f(this,K,s),f(this,xt,(h,c,m=t(this,X).now())=>{i[h]=c!==0?m:0,e[h]=c,r(h,c);}),f(this,ft,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let m=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,w)[h],"expire");},c+1);m.unref&&m.unref(),s[h]=m;}}:()=>{};f(this,it,(h,c)=>{if(e[c]){let m=e[c],I=i[c];if(!m||!I)return;h.ttl=m,h.start=I,h.now=a||o();let _=h.now-I;h.remainingTTL=m-_;}});let a=0,o=()=>{let h=t(this,X).now();if(this.ttlResolution>0){a=h;let c=setTimeout(()=>a=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,R).get(h);if(c===void 0)return 0;let m=e[c],I=i[c];if(!m||!I)return 1/0;let _=(a||o())-I;return m-_},f(this,W,h=>{let c=i[h],m=e[h];return !!m&&!!c&&(a||o())-c>m});},ft=new WeakMap,it=new WeakMap,xt=new WeakMap,W=new WeakMap,Zt=function(){let e=new Ft(t(this,$));f(this,J,0),f(this,Q,e),f(this,pt,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,Rt,(i,s,r,a)=>{if(l(this,n,O).call(this,s))return 0;if(!rt(r))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(r=a(s,i),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),f(this,bt,(i,s,r)=>{if(e[i]=s,t(this,z)){let a=t(this,z)-e[i];for(;t(this,J)>a;)l(this,n,Ct).call(this,true);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},pt=new WeakMap,bt=new WeakMap,Rt=new WeakMap,ot=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,N);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,Y)[i];},at=function*({allowStale:e=this.allowStale}={}){if(t(this,D))for(let i=t(this,C);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,V)[i];},Pt=function(e){return e!==void 0&&t(this,R).get(t(this,w)[e])===e},Ct=function(e){var a;let i=t(this,C),s=t(this,w)[i],r=t(this,p)[i];return t(this,lt)&&l(this,n,O).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((a=t(this,k))==null||a.call(this,r,s,"evict")),t(this,L)&&t(this,F)?.push([r,s,"evict"])),t(this,pt).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,w)[i]=void 0,t(this,p)[i]=void 0,t(this,q).push(i)),t(this,D)===1?(f(this,C,f(this,N,0)),t(this,q).length=0):f(this,C,t(this,V)[i]),t(this,R).delete(s),It(this,D)._--,i},Mt=function(e,i,s,r){let a=i===void 0?void 0:t(this,p)[i];if(l(this,n,O).call(this,a))return a;let o=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let c={signal:o.signal,options:s,context:r},m=(A,v=false)=>{let{aborted:g}=o.signal,M=s.ignoreFetchAbort&&A!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(g&&!v?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!M&&!v)return _(o.signal.reason,U);let G=b,x=t(this,p)[i];return (x===b||M&&v&&x===void 0)&&(A===void 0?G.__staleWhileFetching!==void 0?t(this,p)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,A,c.options))),A},I=A=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=A),_(A,false)),_=(A,v)=>{let{aborted:g}=o.signal,M=g&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,x=b;if(t(this,p)[i]===b&&(!G||!v&&x.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,p)[i]=x.__staleWhileFetching)),U)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw A},y=(A,v)=>{var M;let g=(M=t(this,mt))==null?void 0:M.call(this,e,a,c);g&&g instanceof Promise&&g.then(U=>A(U===void 0?void 0:U),v),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(A(void 0),s.allowStaleOnFetchAbort&&(A=U=>m(U,true)));});};s.status&&(s.status.fetchDispatched=true);let b=new Promise(y).then(m,I),T=Object.assign(b,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return i===void 0?(this.set(e,T,{...c.options,status:void 0}),i=t(this,R).get(e)):t(this,p)[i]=T,T},O=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Kt=function(e,i){t(this,Y)[i]=e,t(this,V)[e]=i;},wt=function(e){e!==t(this,N)&&(e===t(this,C)?f(this,C,t(this,V)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,V)[e]),l(this,n,Kt).call(this,t(this,N),e),f(this,N,e));},nt=function(e,i){var r,a;let s=false;if(t(this,D)!==0){let o=t(this,R).get(e);if(o!==void 0)if(t(this,K)?.[o]&&(clearTimeout(t(this,K)?.[o]),t(this,K)[o]=void 0),s=true,t(this,D)===1)l(this,n,Wt).call(this,i);else {t(this,pt).call(this,o);let h=t(this,p)[o];if(l(this,n,O).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,L))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,L)&&t(this,F)?.push([h,e,i])),t(this,R).delete(e),t(this,w)[o]=void 0,t(this,p)[o]=void 0,o===t(this,N))f(this,N,t(this,Y)[o]);else if(o===t(this,C))f(this,C,t(this,V)[o]);else {let c=t(this,Y)[o];t(this,V)[c]=t(this,V)[o];let m=t(this,V)[o];t(this,Y)[m]=t(this,Y)[o];}It(this,D)._--,t(this,q).push(o);}}if(t(this,L)&&t(this,F)?.length){let o=t(this,F),h;for(;h=o?.shift();)(a=t(this,B))==null||a.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,at).call(this,{allowStale:true})){let a=t(this,p)[r];if(l(this,n,O).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=t(this,w)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,a,o,e)),t(this,L)&&t(this,F)?.push([a,o,e]);}}if(t(this,R).clear(),t(this,p).fill(void 0),t(this,w).fill(void 0),t(this,P)&&t(this,Z)){t(this,P).fill(0),t(this,Z).fill(0);for(let r of t(this,K)??[])r!==void 0&&clearTimeout(r);t(this,K)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),f(this,C,0),f(this,N,0),t(this,q).length=0,f(this,J,0),f(this,D,0),t(this,L)&&t(this,F)){let r=t(this,F),a;for(;a=r?.shift();)(s=t(this,B))==null||s.call(this,...a);}},yt);var At=class{constructor(e){E(this,"cache");E(this,"map",new Map);this.cache=new Qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ht;(_=>{_.storage=new At({cacheSize:50}),_.defaultStorage=new At({cacheSize:10}),_.tempStorageDeadlines=new Map;let s;function r(y){_.tempStorageDeadlines.forEach((b,T)=>{b>y&&(_.storage.delete(`${ht}:${T}`),s?.onClearOldTempVariable?.(T),_.tempStorageDeadlines.delete(T));});}_.clearOldTempVariables=r;function a(y){s=y;}_.setExternalStoreHandler=a;function o(y,b,T){T==null?_.storage.delete(`${y}:${b}`):_.storage.set(`${y}:${b}`,T),s?.onSetVariable?.(b,T);}_.setVariable=o;function h(y,b){let T=_.storage.get(`${y}:${b}`);return Ot(T)}_.getVariable=h;function c(y,b){_.storage.delete(`${y}:${b}`),s?.onRemoveVariable?.(b);}_.removeVariable=c;function m(y,b){let T=_.storage.get(Nt)||[];if(b)T.includes(y)||T.push(y);else {let A=T.indexOf(y);A>-1&&T.splice(A,1);}_.storage.set(Nt,T);}_.setFlag=m;function I(y){return (_.storage.get(Nt)||[]).includes(y)}_.getFlag=I;})(Ht||(Ht={}));var S=Ht;var Dt=class{get base(){return S.storage.map}get cache(){return S.storage.cache}get tempStorageDeadlines(){return S.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{S.defaultStorage.map.set(i,s);});}set(e,i){return S.setVariable(st,e,i)}get(e){let i=S.getVariable(ht,e);return i===void 0&&(i=S.getVariable(st,e)),i===void 0&&(i=Ot(S.defaultStorage.get(e))),i}remove(e){return this.removeTempVariable(e),S.removeVariable(st,e)}setTempVariable(e,i){if(i==null){this.removeTempVariable(e);return}else S.setVariable(ht,e,i),this.tempStorageDeadlines.has(e)||this.tempStorageDeadlines.set(e,core.GameUnifier.openedLabels);}removeTempVariable(e){S.removeVariable(ht,e),this.tempStorageDeadlines.has(e)&&this.tempStorageDeadlines.delete(e);}setFlag(e,i){return S.setFlag(e,i)}getFlag(e){return S.getFlag(e)}setStorageHandler(e){S.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...S.tempStorageDeadlines.keys()].forEach(s=>{i.push({key:s,value:this.tempStorageDeadlines.get(s)});}),Ot({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":S.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":S.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":S.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":S.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":S.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":S.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":S.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":S.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":S.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":S.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":S.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:S.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{S.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{S.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.tempStorageDeadlines.set(i.key,i.value);})):ct.warn("No storage data found");}catch(i){ct.error("Error importing data",i);}}};var Vt=class{constructor(e,i){E(this,"id");E(this,"categoryId");this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=S.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([a,o])=>{S.setVariable(this.categoryId,`${s}:${a}`,o);});}),S.removeVariable(st,e));}setStorageProperty(e,i){S.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return S.getVariable(this.categoryId,`${i}:${e}`)}};var Ve=new Dt;exports.StorageManagerStatic=S;exports.StoredClassModel=Vt;exports.storage=Ve;
|
package/dist/storage.d.cts
CHANGED
|
@@ -4,6 +4,24 @@ export { S as StorageObjectType } from './StorageElementType-DkJ394kq.cjs';
|
|
|
4
4
|
export { S as StoredClassModel } from './StoredClassModel-LtyakzOw.cjs';
|
|
5
5
|
import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
|
|
6
6
|
|
|
7
|
+
interface StorageExternalStoreHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Triggered when {@link StorageManagerStatic.setVariable} is called.
|
|
10
|
+
* The key is provided without any storage prefix.
|
|
11
|
+
*/
|
|
12
|
+
onSetVariable?: (key: string, value: StorageElementType) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
|
|
15
|
+
* The key is provided without any storage prefix.
|
|
16
|
+
*/
|
|
17
|
+
onClearOldTempVariable?: (key: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when {@link StorageManagerStatic.removeVariable} is called.
|
|
20
|
+
* The key is provided without any storage prefix.
|
|
21
|
+
*/
|
|
22
|
+
onRemoveVariable?: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
interface StorageGameStateItem<T = StorageElementType> {
|
|
8
26
|
key: string;
|
|
9
27
|
value: T;
|
|
@@ -103,6 +121,39 @@ interface StorageManagerInterface {
|
|
|
103
121
|
* @returns The value of the flag
|
|
104
122
|
*/
|
|
105
123
|
getFlag(key: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Configure the handler used to mirror game storage changes into an external reactive store.
|
|
126
|
+
* Call this at any time to start/stop mirroring.
|
|
127
|
+
* @param value The handler to set. If undefined, the handler will be removed.
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { Store } from '@tanstack/store'
|
|
131
|
+
*
|
|
132
|
+
* // Create a TanStack store that mirrors the game storage variables
|
|
133
|
+
* const gameStore = new Store<Record<string, unknown>>({})
|
|
134
|
+
*
|
|
135
|
+
* storage.setStorageHandler({
|
|
136
|
+
* onSetVariable: (key, value) => {
|
|
137
|
+
* gameStore.setState((state) => ({ ...state, [key]: value }))
|
|
138
|
+
* },
|
|
139
|
+
* onRemoveVariable: (key) => {
|
|
140
|
+
* gameStore.setState((state) => {
|
|
141
|
+
* const next = { ...state }
|
|
142
|
+
* delete next[key]
|
|
143
|
+
* return next
|
|
144
|
+
* })
|
|
145
|
+
* },
|
|
146
|
+
* onClearOldTempVariable: (key) => {
|
|
147
|
+
* gameStore.setState((state) => {
|
|
148
|
+
* const next = { ...state }
|
|
149
|
+
* delete next[key]
|
|
150
|
+
* return next
|
|
151
|
+
* })
|
|
152
|
+
* },
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
setStorageHandler(value?: StorageExternalStoreHandler): void;
|
|
106
157
|
/**
|
|
107
158
|
* Clear the storage and the oidsUsed
|
|
108
159
|
* @returns
|
|
@@ -120,19 +171,19 @@ interface StorageManagerInterface {
|
|
|
120
171
|
restore(data: StorageGameState): void;
|
|
121
172
|
}
|
|
122
173
|
|
|
123
|
-
declare
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
174
|
+
declare namespace StorageManagerStatic {
|
|
175
|
+
const storage: CachedMap<string, any>;
|
|
176
|
+
const defaultStorage: CachedMap<string, any>;
|
|
177
|
+
const tempStorageDeadlines: Map<string, number>;
|
|
178
|
+
function clearOldTempVariables(openedLabelsNumber: number): void;
|
|
179
|
+
function setExternalStoreHandler(handler?: StorageExternalStoreHandler): void;
|
|
180
|
+
function setVariable(prefix: string, key: string, value: StorageElementType): void;
|
|
181
|
+
function getVariable<T = StorageElementType>(prefix: string, key: string): T | undefined;
|
|
182
|
+
function removeVariable(prefix: string, key: string): void;
|
|
183
|
+
function setFlag(key: string, value: boolean): void;
|
|
184
|
+
function getFlag(key: string): boolean;
|
|
134
185
|
}
|
|
135
186
|
|
|
136
187
|
declare const storage: StorageManagerInterface;
|
|
137
188
|
|
|
138
|
-
export { StorageElementType, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
|
189
|
+
export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
package/dist/storage.d.ts
CHANGED
|
@@ -4,6 +4,24 @@ export { S as StorageObjectType } from './StorageElementType-DkJ394kq.js';
|
|
|
4
4
|
export { S as StoredClassModel } from './StoredClassModel-a4pvgJXD.js';
|
|
5
5
|
import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
|
|
6
6
|
|
|
7
|
+
interface StorageExternalStoreHandler {
|
|
8
|
+
/**
|
|
9
|
+
* Triggered when {@link StorageManagerStatic.setVariable} is called.
|
|
10
|
+
* The key is provided without any storage prefix.
|
|
11
|
+
*/
|
|
12
|
+
onSetVariable?: (key: string, value: StorageElementType) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Triggered when a temp variable is removed by {@link StorageManagerStatic.clearOldTempVariables}.
|
|
15
|
+
* The key is provided without any storage prefix.
|
|
16
|
+
*/
|
|
17
|
+
onClearOldTempVariable?: (key: string) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Triggered when {@link StorageManagerStatic.removeVariable} is called.
|
|
20
|
+
* The key is provided without any storage prefix.
|
|
21
|
+
*/
|
|
22
|
+
onRemoveVariable?: (key: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
7
25
|
interface StorageGameStateItem<T = StorageElementType> {
|
|
8
26
|
key: string;
|
|
9
27
|
value: T;
|
|
@@ -103,6 +121,39 @@ interface StorageManagerInterface {
|
|
|
103
121
|
* @returns The value of the flag
|
|
104
122
|
*/
|
|
105
123
|
getFlag(key: string): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Configure the handler used to mirror game storage changes into an external reactive store.
|
|
126
|
+
* Call this at any time to start/stop mirroring.
|
|
127
|
+
* @param value The handler to set. If undefined, the handler will be removed.
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { Store } from '@tanstack/store'
|
|
131
|
+
*
|
|
132
|
+
* // Create a TanStack store that mirrors the game storage variables
|
|
133
|
+
* const gameStore = new Store<Record<string, unknown>>({})
|
|
134
|
+
*
|
|
135
|
+
* storage.setStorageHandler({
|
|
136
|
+
* onSetVariable: (key, value) => {
|
|
137
|
+
* gameStore.setState((state) => ({ ...state, [key]: value }))
|
|
138
|
+
* },
|
|
139
|
+
* onRemoveVariable: (key) => {
|
|
140
|
+
* gameStore.setState((state) => {
|
|
141
|
+
* const next = { ...state }
|
|
142
|
+
* delete next[key]
|
|
143
|
+
* return next
|
|
144
|
+
* })
|
|
145
|
+
* },
|
|
146
|
+
* onClearOldTempVariable: (key) => {
|
|
147
|
+
* gameStore.setState((state) => {
|
|
148
|
+
* const next = { ...state }
|
|
149
|
+
* delete next[key]
|
|
150
|
+
* return next
|
|
151
|
+
* })
|
|
152
|
+
* },
|
|
153
|
+
* })
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
setStorageHandler(value?: StorageExternalStoreHandler): void;
|
|
106
157
|
/**
|
|
107
158
|
* Clear the storage and the oidsUsed
|
|
108
159
|
* @returns
|
|
@@ -120,19 +171,19 @@ interface StorageManagerInterface {
|
|
|
120
171
|
restore(data: StorageGameState): void;
|
|
121
172
|
}
|
|
122
173
|
|
|
123
|
-
declare
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
174
|
+
declare namespace StorageManagerStatic {
|
|
175
|
+
const storage: CachedMap<string, any>;
|
|
176
|
+
const defaultStorage: CachedMap<string, any>;
|
|
177
|
+
const tempStorageDeadlines: Map<string, number>;
|
|
178
|
+
function clearOldTempVariables(openedLabelsNumber: number): void;
|
|
179
|
+
function setExternalStoreHandler(handler?: StorageExternalStoreHandler): void;
|
|
180
|
+
function setVariable(prefix: string, key: string, value: StorageElementType): void;
|
|
181
|
+
function getVariable<T = StorageElementType>(prefix: string, key: string): T | undefined;
|
|
182
|
+
function removeVariable(prefix: string, key: string): void;
|
|
183
|
+
function setFlag(key: string, value: boolean): void;
|
|
184
|
+
function getFlag(key: string): boolean;
|
|
134
185
|
}
|
|
135
186
|
|
|
136
187
|
declare const storage: StorageManagerInterface;
|
|
137
188
|
|
|
138
|
-
export { StorageElementType, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
|
189
|
+
export { StorageElementType, type StorageExternalStoreHandler, type StorageGameState, type StorageManagerInterface, StorageManagerStatic, storage };
|
package/dist/storage.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-
|
|
1
|
+
export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-XYO5SLSM.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-6HI66YQL.mjs';
|
package/dist/vite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var s=null,o=null,d=null,
|
|
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;
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
|
|
3
|
+
type Plugin = {
|
|
4
|
+
name: string;
|
|
5
|
+
apply: "serve";
|
|
6
|
+
configureServer: (server: {
|
|
7
|
+
middlewares: {
|
|
8
|
+
use: (path: string, handler: (req: IncomingMessage, res: ServerResponse) => void) => void;
|
|
9
|
+
};
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
13
|
* Vite plugin to handle pixi-vn related endpoints.
|
|
5
14
|
* This plugin only runs in development mode (serve).
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
|
|
3
|
+
type Plugin = {
|
|
4
|
+
name: string;
|
|
5
|
+
apply: "serve";
|
|
6
|
+
configureServer: (server: {
|
|
7
|
+
middlewares: {
|
|
8
|
+
use: (path: string, handler: (req: IncomingMessage, res: ServerResponse) => void) => void;
|
|
9
|
+
};
|
|
10
|
+
}) => void;
|
|
11
|
+
};
|
|
3
12
|
/**
|
|
4
13
|
* Vite plugin to handle pixi-vn related endpoints.
|
|
5
14
|
* This plugin only runs in development mode (serve).
|
package/dist/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-TTRUPDAB.mjs';var s=null,o=null,d=null,
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pixi'VN is a npm package that provides various features for creating visual novels.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -12,7 +12,11 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "tsup --watch",
|
|
14
14
|
"build": "tsup --config tsup.config.ts",
|
|
15
|
-
"
|
|
15
|
+
"lint": "biome lint",
|
|
16
|
+
"check": "biome check",
|
|
17
|
+
"format": "biome format --write",
|
|
18
|
+
"test": "vitest",
|
|
19
|
+
"docs": "typedoc"
|
|
16
20
|
},
|
|
17
21
|
"exports": {
|
|
18
22
|
".": {
|
|
@@ -138,31 +142,35 @@
|
|
|
138
142
|
"funding": "https://github.com/DRincs-Productions/pixi-vn?sponsor=1",
|
|
139
143
|
"dependencies": {
|
|
140
144
|
"@pixi/devtools": "^2.0.1",
|
|
141
|
-
"@pixi/sound": "^6.0.1",
|
|
142
145
|
"motion": "^12.38.0",
|
|
143
|
-
"pixi.js": "^8.
|
|
146
|
+
"pixi.js": "^8.18.1",
|
|
147
|
+
"tone": "^15.1.22"
|
|
144
148
|
},
|
|
145
149
|
"peerDependencies": {
|
|
146
|
-
"@pixi/devtools": "
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
+
"@pixi/devtools": ">=2.0.0",
|
|
151
|
+
"motion": ">=12.38.0",
|
|
152
|
+
"pixi.js": ">=8.17.0",
|
|
153
|
+
"tone": ">=15.1.0"
|
|
150
154
|
},
|
|
151
155
|
"devDependencies": {
|
|
156
|
+
"@biomejs/biome": "^2.4.12",
|
|
152
157
|
"@types/crypto-js": "^4.2.2",
|
|
153
158
|
"@types/mime-db": "^1.43.6",
|
|
154
159
|
"crypto-js": "^4.2.0",
|
|
155
|
-
"jsdom": "^29.0.
|
|
160
|
+
"jsdom": "^29.0.2",
|
|
156
161
|
"keyv": "^5.6.0",
|
|
157
|
-
"lru-cache": "
|
|
162
|
+
"lru-cache": "11.2.7",
|
|
158
163
|
"microdiff": "^1.5.0",
|
|
159
164
|
"mime-db": "^1.54.0",
|
|
160
165
|
"ts-node": "^10.9.2",
|
|
166
|
+
"tsconfig-paths": "^4.2.0",
|
|
161
167
|
"tsup": "^8.5.1",
|
|
168
|
+
"typedoc": "^0.28.19",
|
|
169
|
+
"typedoc-plugin-markdown": "^4.11.0",
|
|
162
170
|
"typescript": "^5.9.3",
|
|
163
|
-
"vite": "^
|
|
164
|
-
"vite-tsconfig-paths": "^6.
|
|
165
|
-
"vitest": "^4.
|
|
171
|
+
"vite": "^8.0.9",
|
|
172
|
+
"vite-tsconfig-paths": "^6.1.1",
|
|
173
|
+
"vitest": "^4.1.5"
|
|
166
174
|
},
|
|
167
175
|
"keywords": [
|
|
168
176
|
"2d",
|
package/dist/chunk-D45QSSXG.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {PixiError}from'@drincs/pixi-vn/core';var y=Object.create;var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var s=r=>{throw TypeError(r)};var E=(r,o,n)=>o in r?p(r,o,{enumerable:true,configurable:true,writable:true,value:n}):r[o]=n;var V=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports);var P=(r,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of l(o))!N.call(r,e)&&e!==n&&p(r,e,{get:()=>o[e],enumerable:!(t=f(o,e))||t.enumerable});return r};var S=(r,o,n)=>(n=r!=null?y(m(r)):{},P(o||!r||!r.__esModule?p(n,"default",{value:r,enumerable:true}):n,r));var T=(r,o,n)=>E(r,typeof o!="symbol"?o+"":o,n),x=(r,o,n)=>o.has(r)||s("Cannot "+n);var b=(r,o,n)=>(x(r,o,"read from private field"),n?n.call(r):o.get(r)),d=(r,o,n)=>o.has(r)?s("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,n),u=(r,o,n,t)=>(x(r,o,"write to private field"),t?t.call(r,n):o.set(r,n),n),h=(r,o,n)=>(x(r,o,"access private method"),n);var J=(r,o,n,t)=>({set _(e){u(r,o,e,n);},get _(){return b(r,o,t)}});var c;(e=>(e.log=(i,...a)=>console.log(`[Pixi\u2019VN] ${i}`,...a),e.warn=(i,...a)=>console.warn(`[Pixi\u2019VN] ${i}`,...a),e.error=(i,...a)=>console.error(`[Pixi\u2019VN] ${i}`,...a),e.info=(i,...a)=>console.info(`[Pixi\u2019VN] ${i}`,...a)))(c||(c={}));function k(r){try{if(typeof r>"u")return r;let o=JSON.stringify(r);return JSON.parse(o)}catch(o){throw c.error("Error creating exportable element",r,o),new PixiError("not_json_serializable","Error creating exportable element")}}export{V as a,$ as b,S as c,T as d,b as e,d as f,u as g,h,J as i,c as j,k};
|
package/dist/chunk-EWW7VYPM.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-ZW3MIPMS.mjs';import {k,m,j,l,n}from'./chunk-IWAXXFXE.mjs';import {d,k as k$1,j as j$1}from'./chunk-D45QSSXG.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var s=class s{constructor(){}static clearOldTempVariables(t){s.tempStorageDeadlines.forEach((e,r)=>{e>t&&(s.removeVariable(k,r),s.tempStorageDeadlines.delete(r));});}static setVariable(t,e,r){r==null?s.storage.delete(`${t}:${e}`):s.storage.set(`${t}:${e}`,r);}static getVariable(t,e){let r=s.storage.get(`${t}:${e}`);return k$1(r)}static removeVariable(t,e){s.storage.delete(`${t}:${e}`);}static setFlag(t,e){let r=s.storage.get(m)||[];if(e)r.includes(t)||r.push(t);else {let g=r.indexOf(t);g>-1&&r.splice(g,1);}s.storage.set(m,r);}static getFlag(t){return (s.storage.get(m)||[]).includes(t)}};d(s,"storage",new a$1({cacheSize:50})),d(s,"default",new a$1({cacheSize:10})),d(s,"tempStorageDeadlines",new Map);var a=s;var p=class{get base(){return a.storage.map}get cache(){return a.storage.cache}get tempStorageDeadlines(){return a.tempStorageDeadlines}set default(t){Object.entries(t).forEach(([e,r])=>{a.default.map.set(e,r);});}set(t,e){return a.setVariable(j,t,e)}get(t){let e=a.getVariable(k,t);return e===void 0&&(e=a.getVariable(j,t)),e===void 0&&(e=k$1(a.default.get(t))),e}remove(t){return this.removeTempVariable(t),a.removeVariable(j,t)}setTempVariable(t,e){if(e==null){this.removeTempVariable(t);return}else a.setVariable(k,t,e),this.tempStorageDeadlines.has(t)||this.tempStorageDeadlines.set(t,GameUnifier.openedLabels);}removeTempVariable(t){a.removeVariable(k,t),this.tempStorageDeadlines.has(t)&&this.tempStorageDeadlines.delete(t);}setFlag(t,e){return a.setFlag(t,e)}getFlag(t){return a.getFlag(t)}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let t=[];[...this.base.keys()].forEach(r=>{t.push({key:r,value:this.base.get(r)});});let e=[];return [...a.tempStorageDeadlines.keys()].forEach(r=>{e.push({key:r,value:this.tempStorageDeadlines.get(r)});}),k$1({main:t,tempDeadlines:e})}restore(t){this.clear();try{t?(t.base?.forEach(e=>{switch(e.key){case "___current_dialogue_memory___":a.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,e.value);break;case "___last_dialogue_added_in_step_memory___":a.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_menu_options_memory___":a.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,e.value);break;case "___last_menu_options_added_in_step_memory___":a.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "_input_value_":a.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e.value);break;case "___last_input_added_in_step_memory___":a.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_input_info_memory___":a.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e.value);break;case "___opened_labels_counter___":a.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e.value);break;case "___all_choices_made___":a.setVariable(l,n.ALL_CHOICES_MADE_KEY,e.value);break;case "___current_step_times_counter___":a.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,e.value);break;case "___last_step_glued___":a.setVariable(l,n.LAST_STEP_GLUED,e.value);break;default:a.setVariable(j,e.key,e.value);}}),t.temp?.forEach(e=>{a.setVariable(k,e.key,e.value);}),t.flags?.forEach(e=>{a.setFlag(e,!0);}),t.main?.forEach(e=>{this.base.set(e.key,e.value);}),t.tempDeadlines?.forEach(e=>{this.tempStorageDeadlines.set(e.key,e.value);})):j$1.warn("No storage data found");}catch(e){j$1.error("Error importing data",e);}}};var E=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let e=a.getVariable(j,t);e&&(Object.entries(e).forEach(([r,g])=>{typeof g=="object"&&g!==null&&Object.entries(g).forEach(([f,b])=>{a.setVariable(this.categoryId,`${r}:${f}`,b);});}),a.removeVariable(j,t));}setStorageProperty(t,e){a.setVariable(this.categoryId,`${this.id}:${t}`,e);}getStorageProperty(t,e=this.id){return a.getVariable(this.categoryId,`${e}:${t}`)}};var L=new p;export{a,E as b,L as c};
|