@drincs/pixi-vn 1.5.3 → 1.5.5
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 +21 -68
- package/dist/history.cjs +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +2 -2
- package/dist/narration.cjs +1 -1
- package/dist/narration.mjs +1 -1
- package/dist/unifier.cjs +1 -1
- package/dist/unifier.d.cts +307 -0
- package/dist/unifier.d.ts +307 -0
- package/dist/unifier.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,77 +34,11 @@ Pixi’VN does not provide built-in components to create the game UI. Instead, y
|
|
|
34
34
|
* [Templates](https://pixi-vn.web.app/start/templates)
|
|
35
35
|
* Make your first:
|
|
36
36
|
* [Visual Novel](https://pixi-vn.web.app/start/make-visual-novel)
|
|
37
|
-
* [Point
|
|
37
|
+
* [Point & Click Adventure](https://pixi-vn.web.app/nqtr/make-point-and-click)
|
|
38
38
|
* [RPG game](https://pixi-vn.web.app/start/make-rpg)
|
|
39
|
+
* [IDE or graphical editor](https://pixi-vn.web.app/start/make-ide)
|
|
39
40
|
* [Game engine](https://pixi-vn.web.app/start/make-game-engine)
|
|
40
41
|
|
|
41
|
-
## First steps
|
|
42
|
-
|
|
43
|
-
* [Characters](https://pixi-vn.web.app/start/character)
|
|
44
|
-
* [Narration](https://pixi-vn.web.app/start/narration):
|
|
45
|
-
* [Narration with ink](https://pixi-vn.web.app/ink/ink):
|
|
46
|
-
* [Characters](https://pixi-vn.web.app/ink/ink-character)
|
|
47
|
-
* [Open a knot](https://pixi-vn.web.app/ink/ink-label)
|
|
48
|
-
* [Variables](https://pixi-vn.web.app/ink/ink-variables)
|
|
49
|
-
* [Markup language (to add text style)](https://pixi-vn.web.app/ink/ink-markup)
|
|
50
|
-
* [Input](https://pixi-vn.web.app/ink/ink-input)
|
|
51
|
-
* [Canvas](https://pixi-vn.web.app/ink/ink-canvas)
|
|
52
|
-
* [Sounds and Music](https://pixi-vn.web.app/ink/ink-sound)
|
|
53
|
-
* [Assets management](https://pixi-vn.web.app/ink/ink-assets)
|
|
54
|
-
* [Pause](https://pixi-vn.web.app/ink/ink-pause)
|
|
55
|
-
* [Text replacement](https://pixi-vn.web.app/ink/ink-replacement)
|
|
56
|
-
* [Translating](https://pixi-vn.web.app/ink/ink-translate)
|
|
57
|
-
* [Custom Hashtag Script](https://pixi-vn.web.app/ink/ink-hashtag)
|
|
58
|
-
* [Narration with Ren’Py](https://pixi-vn.web.app/renpy/renpy)
|
|
59
|
-
* Narration with JS/TS:
|
|
60
|
-
* [Dialogue](https://pixi-vn.web.app/start/dialogue)
|
|
61
|
-
* [Label and Game Step](https://pixi-vn.web.app/start/labels)
|
|
62
|
-
* [Game flow with labels](https://pixi-vn.web.app/start/labels-flow)
|
|
63
|
-
* [Label features](https://pixi-vn.web.app/start/labels-advanced)
|
|
64
|
-
* [Choice Menus](https://pixi-vn.web.app/start/choices)
|
|
65
|
-
* [Input prompt](https://pixi-vn.web.app/start/input)
|
|
66
|
-
* [History](https://pixi-vn.web.app/start/history)
|
|
67
|
-
* [Translating](https://pixi-vn.web.app/start/translate)
|
|
68
|
-
* [Other features](https://pixi-vn.web.app/start/other-narrative-features)
|
|
69
|
-
* [Markup language (to add text style)](https://pixi-vn.web.app/start/markup)
|
|
70
|
-
* [Markdown](https://pixi-vn.web.app/start/markup-markdown)
|
|
71
|
-
* [Tailwind CSS](https://pixi-vn.web.app/it/start/markup-tailwindcss)
|
|
72
|
-
* [Game canvas](https://pixi-vn.web.app/start/canvas):
|
|
73
|
-
* [Canvas alias](https://pixi-vn.web.app/start/canvas-alias)
|
|
74
|
-
* [Canvas Components](https://pixi-vn.web.app/start/canvas-components)
|
|
75
|
-
* [ImageSprite](https://pixi-vn.web.app/start/canvas-images)
|
|
76
|
-
* [ImageContainer](https://pixi-vn.web.app/start/canvas-image-container)
|
|
77
|
-
* [VideoSprite](https://pixi-vn.web.app/start/canvas-videos)
|
|
78
|
-
* [Filters](https://pixi-vn.web.app/start/canvas-filters)
|
|
79
|
-
* [Lights](https://pixi-vn.web.app/start/canvas-lights)
|
|
80
|
-
* [Spine 2D](https://pixi-vn.web.app/start/canvas-spine2d)
|
|
81
|
-
* [Three.js](https://pixi-vn.web.app/it/start/canvas-threejs)
|
|
82
|
-
* [Canvas functions](https://pixi-vn.web.app/start/canvas-functions)
|
|
83
|
-
* [Position properties](https://pixi-vn.web.app/start/canvas-position)
|
|
84
|
-
* [Transitions](https://pixi-vn.web.app/start/canvas-transition)
|
|
85
|
-
* [Animations and Effects](https://pixi-vn.web.app/start/canvas-animations-effects)
|
|
86
|
-
* [Primitives (ticker)](https://pixi-vn.web.app/start/canvas-tickers)
|
|
87
|
-
* [Tickers methods](https://pixi-vn.web.app/start/canvas-tickers-functions)
|
|
88
|
-
* [Articulated](https://pixi-vn.web.app/start/canvas-articulated-animations-effects)
|
|
89
|
-
* [Sounds and Music](https://pixi-vn.web.app/start/sound)
|
|
90
|
-
* [Assets](https://pixi-vn.web.app/start/assets)
|
|
91
|
-
* [Assets management](https://pixi-vn.web.app/start/assets-management)
|
|
92
|
-
* [Game storage](https://pixi-vn.web.app/start/storage):
|
|
93
|
-
* [Flags Management](https://pixi-vn.web.app/start/flags)
|
|
94
|
-
* [Stored Classes](https://pixi-vn.web.app/start/stored-classes)
|
|
95
|
-
* [User Interface (UI)](https://pixi-vn.web.app/start/interface)
|
|
96
|
-
* JavaScript Frameworks
|
|
97
|
-
* [React](https://pixi-vn.web.app/start/interface-react)
|
|
98
|
-
* [Vue](https://pixi-vn.web.app/start/interface-vue)
|
|
99
|
-
* [PixiJS](https://pixi-vn.web.app/start/interface-pixijs)
|
|
100
|
-
* [UI screen examples](https://pixi-vn.web.app/start/interface-examples)
|
|
101
|
-
* [Navigate/switch between UI screens](https://pixi-vn.web.app/start/interface-navigate)
|
|
102
|
-
* [Connect the UI with the storage](https://pixi-vn.web.app/start/interface-connect-storage)
|
|
103
|
-
* [Save and Load](https://pixi-vn.web.app/start/save)
|
|
104
|
-
* [Distribution](https://pixi-vn.web.app/start/distribution)
|
|
105
|
-
* [Website distribution](https://pixi-vn.web.app/start/distribution-website)
|
|
106
|
-
* [Desktop & mobile devices](https://pixi-vn.web.app/start/distribution-desktop-mobile)
|
|
107
|
-
|
|
108
42
|
## Prerequisites
|
|
109
43
|
|
|
110
44
|
Before starting, you must have the following tools installed:
|
|
@@ -190,6 +124,7 @@ Game.init(body, {
|
|
|
190
124
|
height: 1080,
|
|
191
125
|
width: 1920,
|
|
192
126
|
backgroundColor: "#303030",
|
|
127
|
+
resizeMode: "contain",
|
|
193
128
|
}).then(() => {
|
|
194
129
|
// ...
|
|
195
130
|
});
|
|
@@ -219,3 +154,21 @@ Game.onError((type, error, { notify }) => {
|
|
|
219
154
|
</body>
|
|
220
155
|
</html>
|
|
221
156
|
```
|
|
157
|
+
|
|
158
|
+
```css title="src/styles.css"
|
|
159
|
+
:root {
|
|
160
|
+
background-color: #242424;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
html,
|
|
164
|
+
body {
|
|
165
|
+
height: 100%;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
body {
|
|
169
|
+
margin: 0;
|
|
170
|
+
min-height: 100vh;
|
|
171
|
+
display: flex;
|
|
172
|
+
overflow: hidden;
|
|
173
|
+
}
|
|
174
|
+
```
|
package/dist/history.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var Qt=Object.defineProperty;var Pt=f=>{throw TypeError(f)};var Zt=(f,t,i)=>t in f?Qt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var w=(f,t,i)=>Zt(f,typeof t!="symbol"?t+"":t,i),Mt=(f,t,i)=>t.has(f)||Pt("Cannot "+i);var e=(f,t,i)=>(Mt(f,t,"read from private field"),i?i.call(f):t.get(f)),S=(f,t,i)=>t.has(f)?Pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),u=(f,t,i,s)=>(Mt(f,t,"write to private field"),t.set(f,i),i),c=(f,t,i)=>(Mt(f,t,"access private method"),i);var Dt=(f,t,i,s)=>({set _(r){u(f,t,r);},get _(){return e(f,t,s)}});var te={Date:true,RegExp:true,String:true,Number:true};function Ct(f,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(f);for(let a in f){let h=f[a],y=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[y],oldValue:f[a]});continue}let m=t[a],b=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&b&&!te[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,Ct(h,m,i,i.cyclesFix?s.concat([h]):[]).map(_=>(_.path.unshift(y),_))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(b&&(isNaN(h)?h+""==m+"":+h==+m))&&r.push({path:[y],type:"CHANGE",value:m,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in f||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var T;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(T||(T={}));function et(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw T.error("Error creating exportable element",f,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Ut(f,t){let i=et(f);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(s=>{"type"in s?ee(i,s):ie(i,s);}),i}function ee(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):T.warn("No path found, skipping diff",t);}function ie(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1){if(t.kind==="E"||t.kind==="D")i[s]=t.lhs;else if(t.kind==="N")Number.isInteger(s)?Array.isArray(i)&&i.splice(s,1):typeof s=="string"&&delete i[s];else if(t.kind==="A"){let o=t.index;t.item.kind==="N"?i[s].splice(o,1):t.item.kind==="E"||t.item.kind==="D"?i[s][o]=t.item.lhs:t.item.kind==="A"?T.warn("Nested array found, skipping diff",t):T.warn("No array found, skipping diff",t);}}else i=i[s];}):T.warn("No path found, skipping diff",t);}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Lt=typeof process=="object"&&process?process:{},Jt=(f,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},It=globalThis.AbortController,Kt=globalThis.AbortSignal;if(typeof It>"u"){Kt=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},It=class{constructor(){w(this,"signal",new Kt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=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",t));};}var re=f=>!qt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Yt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?St:null:null,St=class extends Array{constructor(t){super(t),this.fill(0);}},bt,ft=class ft{constructor(t,i){w(this,"heap");w(this,"length");if(!e(ft,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Yt(t);if(!i)return [];u(ft,bt,true);let s=new ft(t,i);return u(ft,bt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};bt=new WeakMap,S(ft,bt,false);var kt=ft,$t,Bt,K,R,$,ct,B,wt,_t,q,D,J,O,H,p,M,W,z,C,Y,F,X,Q,V,j,Z,ht,L,At,l,Gt,ut,st,Tt,P,Xt,dt,Et,xt,nt,ot,Rt,Ft,zt,E,Wt,Ht,at,Vt,jt=class jt{constructor(t){S(this,l);S(this,K);S(this,R);S(this,$);S(this,ct);S(this,B);S(this,wt);S(this,_t);S(this,q);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");S(this,D);S(this,J);S(this,O);S(this,H);S(this,p);S(this,M);S(this,W);S(this,z);S(this,C);S(this,Y);S(this,F);S(this,X);S(this,Q);S(this,V);S(this,j);S(this,Z);S(this,ht);S(this,L);S(this,At);S(this,ut,()=>{});S(this,st,()=>{});S(this,Tt,()=>{});S(this,P,()=>false);S(this,dt,t=>{});S(this,Et,(t,i,s)=>{});S(this,xt,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:y,onInsert:m,disposeAfter:b,noDisposeOnSet:_,noUpdateTTL:U,maxSize:tt=0,maxEntrySize:x=0,sizeCalculation:A,fetchMethod:g,memoMethod:I,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:pt,ignoreFetchAbort:yt,perf:Ot}=t;if(Ot!==void 0&&typeof Ot?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,q,Ot??se),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let mt=i?Yt(i):Array;if(!mt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,R,tt),this.maxEntrySize=x||e(this,R),this.sizeCalculation=A,this.sizeCalculation){if(!e(this,R)&&!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(u(this,_t,I),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,wt,g),u(this,ht,!!g),u(this,O,new Map),u(this,H,new Array(i).fill(void 0)),u(this,p,new Array(i).fill(void 0)),u(this,M,new mt(i)),u(this,W,new mt(i)),u(this,z,0),u(this,C,0),u(this,Y,kt.create(i)),u(this,D,0),u(this,J,0),typeof y=="function"&&u(this,$,y),typeof m=="function"&&u(this,ct,m),typeof b=="function"?(u(this,B,b),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,Z,!!e(this,$)),u(this,At,!!e(this,ct)),u(this,L,!!e(this,B)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!U,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!pt,this.ignoreFetchAbort=!!yt,this.maxEntrySize!==0){if(e(this,R)!==0&&!rt(e(this,R)))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");c(this,l,Xt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,l,Gt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,R)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,R)){let gt="LRU_CACHE_UNBOUNDED";re(gt)&&(qt.add(gt),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",gt,jt));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,V),autopurgeTimers:e(t,j),sizes:e(t,X),keyMap:e(t,O),keyList:e(t,H),valList:e(t,p),next:e(t,M),prev:e(t,W),get head(){return e(t,z)},get tail(){return e(t,C)},free:e(t,Y),isBackgroundFetch:i=>{var s;return c(s=t,l,E).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=t,l,zt).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=t,l,Ht).call(s,i)},indexes:i=>{var s;return c(s=t,l,nt).call(s,i)},rindexes:i=>{var s;return c(s=t,l,ot).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,R)}get calculatedSize(){return e(this,J)}get size(){return e(this,D)}get fetchMethod(){return e(this,wt)}get memoMethod(){return e(this,_t)}get dispose(){return e(this,$)}get onInsert(){return e(this,ct)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,O).has(t)?1/0:0}*entries(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*rentries(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*keys(){for(let t of c(this,l,nt).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*rkeys(){for(let t of c(this,l,ot).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*values(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}*rvalues(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}[(Bt=Symbol.iterator,$t=Symbol.toStringTag,Bt)](){return this.entries()}find(t,i={}){for(let s of c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,H)[s],this))return this.get(e(this,H)[s],i)}}forEach(t,i=this){for(let s of c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,H)[s],this);}}rforEach(t,i=this){for(let s of c(this,l,ot).call(this)){let r=e(this,p)[s],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,H)[s],this);}}purgeStale(){let t=false;for(let i of c(this,l,ot).call(this,{allowStale:true}))e(this,P).call(this,i)&&(c(this,l,at).call(this,e(this,H)[i],"expire"),t=true);return t}info(t){let i=e(this,O).get(t);if(i===void 0)return;let s=e(this,p)[i],r=c(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,V)&&e(this,Q)){let n=e(this,V)[i],a=e(this,Q)[i];if(n&&a){let h=n-(e(this,q).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,X)&&(o.size=e(this,X)[i]),o}dump(){let t=[];for(let i of c(this,l,nt).call(this,{allowStale:true})){let s=e(this,H)[i],r=e(this,p)[i],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,V)&&e(this,Q)){n.ttl=e(this,V)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,X)&&(n.size=e(this,X)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var _,U,tt,x;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,m=e(this,xt).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&m>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),c(this,l,at).call(this,t,"set"),this;let b=e(this,D)===0?void 0:e(this,O).get(t);if(b===void 0)b=e(this,D)===0?e(this,C):e(this,Y).length!==0?e(this,Y).pop():e(this,D)===e(this,K)?c(this,l,Ft).call(this,false):e(this,D),e(this,H)[b]=t,e(this,p)[b]=i,e(this,O).set(t,b),e(this,M)[e(this,C)]=b,e(this,W)[b]=e(this,C),u(this,C,b),Dt(this,D)._++,e(this,Et).call(this,b,m,h),h&&(h.set="add"),y=false,e(this,At)&&((_=e(this,ct))==null||_.call(this,i,t,"add"));else {c(this,l,Ht).call(this,b);let A=e(this,p)[b];if(i!==A){if(e(this,ht)&&c(this,l,E).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=A;g!==void 0&&!n&&(e(this,Z)&&((U=e(this,$))==null||U.call(this,g,t,"set")),e(this,L)&&e(this,F)?.push([g,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,A,t,"set")),e(this,L)&&e(this,F)?.push([A,t,"set"]));if(e(this,dt).call(this,b),e(this,Et).call(this,b,m,h),e(this,p)[b]=i,h){h.set="replace";let g=A&&c(this,l,E).call(this,A)?A.__staleWhileFetching:A;g!==void 0&&(h.oldValue=g);}}else h&&(h.set="update");e(this,At)&&this.onInsert?.(i,t,i===A?"update":"replace");}if(r!==0&&!e(this,V)&&c(this,l,Gt).call(this),e(this,V)&&(y||e(this,Tt).call(this,b,r,o),h&&e(this,st).call(this,h,b)),!n&&e(this,L)&&e(this,F)){let A=e(this,F),g;for(;g=A?.shift();)(x=e(this,B))==null||x.call(this,...g);}return this}pop(){var t;try{for(;e(this,D);){let i=e(this,p)[e(this,z)];if(c(this,l,Ft).call(this,!0),c(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,L)&&e(this,F)){let i=e(this,F),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,O).get(t);if(o!==void 0){let n=e(this,p)[o];if(c(this,l,E).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,st).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,st).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,O).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,p)[r];return c(this,l,E).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:U=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:x,forceRefresh:A=false,status:g,signal:I}=i;if(!e(this,ht))return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:y,noUpdateTTL:m,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:tt,ignoreFetchAbort:U,status:g,signal:I},N=e(this,O).get(t);if(N===void 0){g&&(g.fetch="miss");let v=c(this,l,zt).call(this,t,N,k,x);return v.__returned=v}else {let v=e(this,p)[N];if(c(this,l,E).call(this,v)){let gt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",gt&&(g.returnedStale=true)),gt?v.__staleWhileFetching:v.__returned=v}let pt=e(this,P).call(this,N);if(!A&&!pt)return g&&(g.fetch="hit"),c(this,l,Ht).call(this,N),r&&e(this,ut).call(this,N),g&&e(this,st).call(this,g,N),v;let yt=c(this,l,zt).call(this,t,N,k,x),mt=yt.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=pt?"stale":"refresh",mt&&pt&&(g.returnedStale=true)),mt?yt.__staleWhileFetching:yt.__returned=yt}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,_t);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,O).get(t);if(a!==void 0){let h=e(this,p)[a],y=c(this,l,E).call(this,h);return n&&e(this,st).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),y?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||c(this,l,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),y?h.__staleWhileFetching:(c(this,l,Ht).call(this,a),r&&e(this,ut).call(this,a),h))}else n&&(n.get="miss");}delete(t){return c(this,l,at).call(this,t,"delete")}clear(){return c(this,l,Vt).call(this,"delete")}};K=new WeakMap,R=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,wt=new WeakMap,_t=new WeakMap,q=new WeakMap,D=new WeakMap,J=new WeakMap,O=new WeakMap,H=new WeakMap,p=new WeakMap,M=new WeakMap,W=new WeakMap,z=new WeakMap,C=new WeakMap,Y=new WeakMap,F=new WeakMap,X=new WeakMap,Q=new WeakMap,V=new WeakMap,j=new WeakMap,Z=new WeakMap,ht=new WeakMap,L=new WeakMap,At=new WeakMap,l=new WeakSet,Gt=function(){let t=new St(e(this,K)),i=new St(e(this,K));u(this,V,t),u(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,K)):void 0;u(this,j,s),u(this,Tt,(n,a,h=e(this,q).now())=>{if(i[n]=a!==0?h:0,t[n]=a,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),a!==0&&s){let y=setTimeout(()=>{e(this,P).call(this,n)&&c(this,l,at).call(this,e(this,H)[n],"expire");},a+1);y.unref&&y.unref(),s[n]=y;}}),u(this,ut,n=>{i[n]=t[n]!==0?e(this,q).now():0;}),u(this,st,(n,a)=>{if(t[a]){let h=t[a],y=i[a];if(!h||!y)return;n.ttl=h,n.start=y,n.now=r||o();let m=n.now-y;n.remainingTTL=h-m;}});let r=0,o=()=>{let n=e(this,q).now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref();}return n};this.getRemainingTTL=n=>{let a=e(this,O).get(n);if(a===void 0)return 0;let h=t[a],y=i[a];if(!h||!y)return 1/0;let m=(r||o())-y;return h-m},u(this,P,n=>{let a=i[n],h=t[n];return !!h&&!!a&&(r||o())-a>h});},ut=new WeakMap,st=new WeakMap,Tt=new WeakMap,P=new WeakMap,Xt=function(){let t=new St(e(this,K));u(this,J,0),u(this,X,t),u(this,dt,i=>{u(this,J,e(this,J)-t[i]),t[i]=0;}),u(this,xt,(i,s,r,o)=>{if(c(this,l,E).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),u(this,Et,(i,s,r)=>{if(t[i]=s,e(this,R)){let o=e(this,R)-t[i];for(;e(this,J)>o;)c(this,l,Ft).call(this,true);}u(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},dt=new WeakMap,Et=new WeakMap,xt=new WeakMap,nt=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,C);!(!c(this,l,Rt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},ot=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,z);!(!c(this,l,Rt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,M)[i];},Rt=function(t){return t!==void 0&&e(this,O).get(e(this,H)[t])===t},Ft=function(t){var o;let i=e(this,z),s=e(this,H)[i],r=e(this,p)[i];return e(this,ht)&&c(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,L))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,L)&&e(this,F)?.push([r,s,"evict"])),e(this,dt).call(this,i),e(this,j)?.[i]&&(clearTimeout(e(this,j)[i]),e(this,j)[i]=void 0),t&&(e(this,H)[i]=void 0,e(this,p)[i]=void 0,e(this,Y).push(i)),e(this,D)===1?(u(this,z,u(this,C,0)),e(this,Y).length=0):u(this,z,e(this,M)[i]),e(this,O).delete(s),Dt(this,D)._--,i},zt=function(t,i,s,r){let o=i===void 0?void 0:e(this,p)[i];if(c(this,l,E).call(this,o))return o;let n=new It,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},y=(x,A=false)=>{let{aborted:g}=n.signal,I=s.ignoreFetchAbort&&x!==void 0,k=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&x!==void 0);if(s.status&&(g&&!A?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!I&&!A)return b(n.signal.reason,k);let N=U,v=e(this,p)[i];return (v===U||I&&A&&v===void 0)&&(x===void 0?N.__staleWhileFetching!==void 0?e(this,p)[i]=N.__staleWhileFetching:c(this,l,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,x,h.options))),x},m=x=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=x),b(x,false)),b=(x,A)=>{let{aborted:g}=n.signal,I=g&&s.allowStaleOnFetchAbort,k=I||s.allowStaleOnFetchRejection,N=k||s.noDeleteOnFetchRejection,v=U;if(e(this,p)[i]===U&&(!N||!A&&v.__staleWhileFetching===void 0?c(this,l,at).call(this,t,"fetch"):I||(e(this,p)[i]=v.__staleWhileFetching)),k)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw x},_=(x,A)=>{var I;let g=(I=e(this,wt))==null?void 0:I.call(this,t,o,h);g&&g instanceof Promise&&g.then(k=>x(k===void 0?void 0:k),A),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(x(void 0),s.allowStaleOnFetchAbort&&(x=k=>y(k,true)));});};s.status&&(s.status.fetchDispatched=true);let U=new Promise(_).then(y,m),tt=Object.assign(U,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,O).get(t)):e(this,p)[i]=tt,tt},E=function(t){if(!e(this,ht))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof It},Wt=function(t,i){e(this,W)[i]=t,e(this,M)[t]=i;},Ht=function(t){t!==e(this,C)&&(t===e(this,z)?u(this,z,e(this,M)[t]):c(this,l,Wt).call(this,e(this,W)[t],e(this,M)[t]),c(this,l,Wt).call(this,e(this,C),t),u(this,C,t));},at=function(t,i){var r,o;let s=false;if(e(this,D)!==0){let n=e(this,O).get(t);if(n!==void 0)if(e(this,j)?.[n]&&(clearTimeout(e(this,j)?.[n]),e(this,j)[n]=void 0),s=true,e(this,D)===1)c(this,l,Vt).call(this,i);else {e(this,dt).call(this,n);let a=e(this,p)[n];if(c(this,l,E).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,L))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,L)&&e(this,F)?.push([a,t,i])),e(this,O).delete(t),e(this,H)[n]=void 0,e(this,p)[n]=void 0,n===e(this,C))u(this,C,e(this,W)[n]);else if(n===e(this,z))u(this,z,e(this,M)[n]);else {let h=e(this,W)[n];e(this,M)[h]=e(this,M)[n];let y=e(this,M)[n];e(this,W)[y]=e(this,W)[n];}Dt(this,D)._--,e(this,Y).push(n);}}if(e(this,L)&&e(this,F)?.length){let n=e(this,F),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Vt=function(t){var i,s;for(let r of c(this,l,ot).call(this,{allowStale:true})){let o=e(this,p)[r];if(c(this,l,E).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,H)[r];e(this,Z)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,L)&&e(this,F)?.push([o,n,t]);}}if(e(this,O).clear(),e(this,p).fill(void 0),e(this,H).fill(void 0),e(this,V)&&e(this,Q)){e(this,V).fill(0),e(this,Q).fill(0);for(let r of e(this,j)??[])r!==void 0&&clearTimeout(r);e(this,j)?.fill(void 0);}if(e(this,X)&&e(this,X).fill(0),u(this,z,0),u(this,C,0),e(this,Y).length=0,u(this,J,0),u(this,D,0),e(this,L)&&e(this,F)){let r=e(this,F),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}};var Nt=jt;var lt=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Nt({max:t.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(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var it=class it{static get originalStepData(){return it._originalStepData?et(it._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){it._originalStepData=et(t);}};w(it,"_diffHistory",new lt({cacheSize:5})),w(it,"_stepsInfoHistory",new lt({cacheSize:5})),w(it,"_narrationHistory",new lt({cacheSize:50})),w(it,"stepLimitSaved",20),w(it,"_originalStepData");var d=it;var vt=class{get stepsInfoMap(){return d._stepsInfoHistory}get diffMap(){return d._diffHistory}get narrationMap(){return d._narrationHistory}get size(){return d._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return d._stepsInfoHistory.keys()}get(t){let i=d._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){d._stepsInfoHistory.delete(t),d._diffHistory.delete(t),d._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size==0)return i;let s=this.lastKey;if(typeof s!="number")return T.warn("You can't go back, there is no step to go back"),i;let r=d._diffHistory.get(s);if(r)try{let o=Ut(i,r);return unifier.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return T.error("Error applying diff",o),i}else return T.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){T.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){T.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(unifier.GameUnifier.runningStepsCount>0){unifier.GameUnifier.increaseBackRequest(s);return}if(d._diffHistory.size<1){T.warn("You can't go back, there is no step to go back");return}unifier.GameUnifier.runningStepsCount++;try{let r=et(this.getOldGameState(s,d.originalStepData));if(r){await unifier.GameUnifier.restoreGameStepState(r,unifier.GameUnifier.navigate);let o=unifier.GameUnifier.stepCounter-1,n=d._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=d._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});d._narrationHistory.set(a.index,h);}}}else T.error("Error going back");d.originalStepData=r;}catch(r){T.error("Error going back",r);}finally{if(unifier.GameUnifier.runningStepsCount--,unifier.GameUnifier.runningStepsCount===0&&unifier.GameUnifier.backRequestsCount!==0)return await unifier.GameUnifier.processNavigationRequests()}}add(t,i={}){let s=d.originalStepData,{ignoreSameStep:r}=i,o=unifier.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,y;if(typeof n=="number"&&(h=d._stepsInfoHistory.get(n),y=d._narrationHistory.get(n)),d._stepsInfoHistory.set(t.index,t),t.index!==0){let _=Ct(s,o);_?d._diffHistory.set(t.index,_):T.warn("It was not possible to create the difference between the two steps");}let m={},b=this.itemMapper({step:t},m);if(d._narrationHistory.set(t.index,b),h&&y&&typeof n=="number"){let _=this.itemMapper({...m,step:h},{});d._narrationHistory.set(n,_);}}catch(h){T.error("Error adding history step",h);}})(),d.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue||s.dialoge;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let y=h?.map((m,b)=>{let _=false;return m.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(b)&&(_=true),{text:m.text,type:m.type,isResponse:false,hidden:_}});if(y){if(y.every(m=>m.hidden)){let m=y.find(b=>b.hidden===false);m&&(m.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?unifier.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,stepIndex:s.index,inputValue:o}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((h,y)=>y-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=d._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,y)=>{let m=this.get(h);if(m){if(y===0)return t.push(m),true;let b=d._stepsInfoHistory.get(h);if(!b)return true;let _=b.openedLabels;if(!_||!Array.isArray(_)||_.length===0||_[0].label!==a||_[0].currentStepIndex>=n)return false;n=_[0].currentStepIndex,t.push(m);}return true}),t.reverse()}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{d._narrationHistory.delete(s),d._stepsInfoHistory.delete(s),d._diffHistory.delete(s);});}else d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:d._diffHistory.has(t)}blockGoBack(){unifier.GameUnifier.runningStepsCount===0&&d._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return T.error("Error comparing opened labels",s),true}return false}clear(){d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear(),d._originalStepData=void 0;}get stepLimitSaved(){return d.stepLimitSaved}set stepLimitSaved(t){d.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];return t.forEach(s=>{let r=d._stepsInfoHistory.get(s);if(r){let o=d._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:et(i),originalStepData:et(d._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=d._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&d._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&d._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};d._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):T.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?d._originalStepData=t.originalStepData:T.warn("Could not import originalStepData data, so will be ignored");}catch(i){T.error("Error importing data",i);}}};var ke=new vt;exports.HistoryManagerStatic=d;exports.stepHistory=ke;
|
|
1
|
+
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var Qt=Object.defineProperty;var Pt=f=>{throw TypeError(f)};var Zt=(f,t,i)=>t in f?Qt(f,t,{enumerable:true,configurable:true,writable:true,value:i}):f[t]=i;var w=(f,t,i)=>Zt(f,typeof t!="symbol"?t+"":t,i),Mt=(f,t,i)=>t.has(f)||Pt("Cannot "+i);var e=(f,t,i)=>(Mt(f,t,"read from private field"),i?i.call(f):t.get(f)),S=(f,t,i)=>t.has(f)?Pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(f):t.set(f,i),u=(f,t,i,s)=>(Mt(f,t,"write to private field"),t.set(f,i),i),c=(f,t,i)=>(Mt(f,t,"access private method"),i);var Dt=(f,t,i,s)=>({set _(r){u(f,t,r);},get _(){return e(f,t,s)}});var te={Date:true,RegExp:true,String:true,Number:true};function Ct(f,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(f);for(let a in f){let h=f[a],y=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[y],oldValue:f[a]});continue}let m=t[a],b=typeof h=="object"&&typeof m=="object"&&Array.isArray(h)===Array.isArray(m);h&&m&&b&&!te[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,Ct(h,m,i,i.cyclesFix?s.concat([h]):[]).map(_=>(_.path.unshift(y),_))):h!==m&&!(Number.isNaN(h)&&Number.isNaN(m))&&!(b&&(isNaN(h)?h+""==m+"":+h==+m))&&r.push({path:[y],type:"CHANGE",value:m,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in f||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var T;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(T||(T={}));function et(f){try{if(typeof f>"u")return f;let t=JSON.stringify(f);return JSON.parse(t)}catch(t){throw T.error("Error creating exportable element",f,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Ut(f,t){let i=et(f);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(s=>{"type"in s?ee(i,s):ie(i,s);}),i}function ee(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):T.warn("No path found, skipping diff",t);}function ie(f,t){let i=f;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1){if(t.kind==="E"||t.kind==="D")i[s]=t.lhs;else if(t.kind==="N")Number.isInteger(s)?Array.isArray(i)&&i.splice(s,1):typeof s=="string"&&delete i[s];else if(t.kind==="A"){let o=t.index;t.item.kind==="N"?i[s].splice(o,1):t.item.kind==="E"||t.item.kind==="D"?i[s][o]=t.item.lhs:t.item.kind==="A"?T.warn("Nested array found, skipping diff",t):T.warn("No array found, skipping diff",t);}}else i=i[s];}):T.warn("No path found, skipping diff",t);}var se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Lt=typeof process=="object"&&process?process:{},Jt=(f,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(f,t,i,s):console.error(`[${i}] ${t}: ${f}`);},It=globalThis.AbortController,Kt=globalThis.AbortSignal;if(typeof It>"u"){Kt=class{constructor(){w(this,"onabort");w(this,"_onabort",[]);w(this,"reason");w(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},It=class{constructor(){w(this,"signal",new Kt);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let f=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{f&&(f=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",t));};}var re=f=>!qt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Yt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?St:null:null,St=class extends Array{constructor(t){super(t),this.fill(0);}},bt,ft=class ft{constructor(t,i){w(this,"heap");w(this,"length");if(!e(ft,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Yt(t);if(!i)return [];u(ft,bt,true);let s=new ft(t,i);return u(ft,bt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};bt=new WeakMap,S(ft,bt,false);var kt=ft,$t,Bt,K,R,$,ct,B,wt,_t,q,D,J,O,H,p,M,W,z,C,Y,F,X,Q,V,j,Z,ht,L,At,l,Gt,ut,st,Tt,P,Xt,dt,Et,xt,nt,ot,Rt,Ft,zt,E,Wt,Ht,at,Vt,jt=class jt{constructor(t){S(this,l);S(this,K);S(this,R);S(this,$);S(this,ct);S(this,B);S(this,wt);S(this,_t);S(this,q);w(this,"ttl");w(this,"ttlResolution");w(this,"ttlAutopurge");w(this,"updateAgeOnGet");w(this,"updateAgeOnHas");w(this,"allowStale");w(this,"noDisposeOnSet");w(this,"noUpdateTTL");w(this,"maxEntrySize");w(this,"sizeCalculation");w(this,"noDeleteOnFetchRejection");w(this,"noDeleteOnStaleGet");w(this,"allowStaleOnFetchAbort");w(this,"allowStaleOnFetchRejection");w(this,"ignoreFetchAbort");S(this,D);S(this,J);S(this,O);S(this,H);S(this,p);S(this,M);S(this,W);S(this,z);S(this,C);S(this,Y);S(this,F);S(this,X);S(this,Q);S(this,V);S(this,j);S(this,Z);S(this,ht);S(this,L);S(this,At);S(this,ut,()=>{});S(this,st,()=>{});S(this,Tt,()=>{});S(this,P,()=>false);S(this,dt,t=>{});S(this,Et,(t,i,s)=>{});S(this,xt,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});w(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:y,onInsert:m,disposeAfter:b,noDisposeOnSet:_,noUpdateTTL:U,maxSize:tt=0,maxEntrySize:x=0,sizeCalculation:A,fetchMethod:g,memoMethod:I,noDeleteOnFetchRejection:k,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:pt,ignoreFetchAbort:yt,perf:Ot}=t;if(Ot!==void 0&&typeof Ot?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,q,Ot??se),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let mt=i?Yt(i):Array;if(!mt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,R,tt),this.maxEntrySize=x||e(this,R),this.sizeCalculation=A,this.sizeCalculation){if(!e(this,R)&&!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(u(this,_t,I),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,wt,g),u(this,ht,!!g),u(this,O,new Map),u(this,H,new Array(i).fill(void 0)),u(this,p,new Array(i).fill(void 0)),u(this,M,new mt(i)),u(this,W,new mt(i)),u(this,z,0),u(this,C,0),u(this,Y,kt.create(i)),u(this,D,0),u(this,J,0),typeof y=="function"&&u(this,$,y),typeof m=="function"&&u(this,ct,m),typeof b=="function"?(u(this,B,b),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,Z,!!e(this,$)),u(this,At,!!e(this,ct)),u(this,L,!!e(this,B)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!U,this.noDeleteOnFetchRejection=!!k,this.allowStaleOnFetchRejection=!!v,this.allowStaleOnFetchAbort=!!pt,this.ignoreFetchAbort=!!yt,this.maxEntrySize!==0){if(e(this,R)!==0&&!rt(e(this,R)))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");c(this,l,Xt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,l,Gt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,R)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,R)){let gt="LRU_CACHE_UNBOUNDED";re(gt)&&(qt.add(gt),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",gt,jt));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,V),autopurgeTimers:e(t,j),sizes:e(t,X),keyMap:e(t,O),keyList:e(t,H),valList:e(t,p),next:e(t,M),prev:e(t,W),get head(){return e(t,z)},get tail(){return e(t,C)},free:e(t,Y),isBackgroundFetch:i=>{var s;return c(s=t,l,E).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=t,l,zt).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=t,l,Ht).call(s,i)},indexes:i=>{var s;return c(s=t,l,nt).call(s,i)},rindexes:i=>{var s;return c(s=t,l,ot).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,R)}get calculatedSize(){return e(this,J)}get size(){return e(this,D)}get fetchMethod(){return e(this,wt)}get memoMethod(){return e(this,_t)}get dispose(){return e(this,$)}get onInsert(){return e(this,ct)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,O).has(t)?1/0:0}*entries(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*rentries(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&e(this,H)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield [e(this,H)[t],e(this,p)[t]]);}*keys(){for(let t of c(this,l,nt).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*rkeys(){for(let t of c(this,l,ot).call(this)){let i=e(this,H)[t];i!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield i);}}*values(){for(let t of c(this,l,nt).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}*rvalues(){for(let t of c(this,l,ot).call(this))e(this,p)[t]!==void 0&&!c(this,l,E).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}[(Bt=Symbol.iterator,$t=Symbol.toStringTag,Bt)](){return this.entries()}find(t,i={}){for(let s of c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,H)[s],this))return this.get(e(this,H)[s],i)}}forEach(t,i=this){for(let s of c(this,l,nt).call(this)){let r=e(this,p)[s],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,H)[s],this);}}rforEach(t,i=this){for(let s of c(this,l,ot).call(this)){let r=e(this,p)[s],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,H)[s],this);}}purgeStale(){let t=false;for(let i of c(this,l,ot).call(this,{allowStale:true}))e(this,P).call(this,i)&&(c(this,l,at).call(this,e(this,H)[i],"expire"),t=true);return t}info(t){let i=e(this,O).get(t);if(i===void 0)return;let s=e(this,p)[i],r=c(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,V)&&e(this,Q)){let n=e(this,V)[i],a=e(this,Q)[i];if(n&&a){let h=n-(e(this,q).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,X)&&(o.size=e(this,X)[i]),o}dump(){let t=[];for(let i of c(this,l,nt).call(this,{allowStale:true})){let s=e(this,H)[i],r=e(this,p)[i],o=c(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,V)&&e(this,Q)){n.ttl=e(this,V)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,X)&&(n.size=e(this,X)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var _,U,tt,x;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,m=e(this,xt).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&m>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),c(this,l,at).call(this,t,"set"),this;let b=e(this,D)===0?void 0:e(this,O).get(t);if(b===void 0)b=e(this,D)===0?e(this,C):e(this,Y).length!==0?e(this,Y).pop():e(this,D)===e(this,K)?c(this,l,Ft).call(this,false):e(this,D),e(this,H)[b]=t,e(this,p)[b]=i,e(this,O).set(t,b),e(this,M)[e(this,C)]=b,e(this,W)[b]=e(this,C),u(this,C,b),Dt(this,D)._++,e(this,Et).call(this,b,m,h),h&&(h.set="add"),y=false,e(this,At)&&((_=e(this,ct))==null||_.call(this,i,t,"add"));else {c(this,l,Ht).call(this,b);let A=e(this,p)[b];if(i!==A){if(e(this,ht)&&c(this,l,E).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=A;g!==void 0&&!n&&(e(this,Z)&&((U=e(this,$))==null||U.call(this,g,t,"set")),e(this,L)&&e(this,F)?.push([g,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,A,t,"set")),e(this,L)&&e(this,F)?.push([A,t,"set"]));if(e(this,dt).call(this,b),e(this,Et).call(this,b,m,h),e(this,p)[b]=i,h){h.set="replace";let g=A&&c(this,l,E).call(this,A)?A.__staleWhileFetching:A;g!==void 0&&(h.oldValue=g);}}else h&&(h.set="update");e(this,At)&&this.onInsert?.(i,t,i===A?"update":"replace");}if(r!==0&&!e(this,V)&&c(this,l,Gt).call(this),e(this,V)&&(y||e(this,Tt).call(this,b,r,o),h&&e(this,st).call(this,h,b)),!n&&e(this,L)&&e(this,F)){let A=e(this,F),g;for(;g=A?.shift();)(x=e(this,B))==null||x.call(this,...g);}return this}pop(){var t;try{for(;e(this,D);){let i=e(this,p)[e(this,z)];if(c(this,l,Ft).call(this,!0),c(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,L)&&e(this,F)){let i=e(this,F),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,O).get(t);if(o!==void 0){let n=e(this,p)[o];if(c(this,l,E).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,st).call(this,r,o));else return s&&e(this,ut).call(this,o),r&&(r.has="hit",e(this,st).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,O).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,p)[r];return c(this,l,E).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:m=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:_=this.allowStaleOnFetchRejection,ignoreFetchAbort:U=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:x,forceRefresh:A=false,status:g,signal:I}=i;if(!e(this,ht))return g&&(g.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let k={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:y,noUpdateTTL:m,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:tt,ignoreFetchAbort:U,status:g,signal:I},N=e(this,O).get(t);if(N===void 0){g&&(g.fetch="miss");let v=c(this,l,zt).call(this,t,N,k,x);return v.__returned=v}else {let v=e(this,p)[N];if(c(this,l,E).call(this,v)){let gt=s&&v.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",gt&&(g.returnedStale=true)),gt?v.__staleWhileFetching:v.__returned=v}let pt=e(this,P).call(this,N);if(!A&&!pt)return g&&(g.fetch="hit"),c(this,l,Ht).call(this,N),r&&e(this,ut).call(this,N),g&&e(this,st).call(this,g,N),v;let yt=c(this,l,zt).call(this,t,N,k,x),mt=yt.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=pt?"stale":"refresh",mt&&pt&&(g.returnedStale=true)),mt?yt.__staleWhileFetching:yt.__returned=yt}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,_t);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,O).get(t);if(a!==void 0){let h=e(this,p)[a],y=c(this,l,E).call(this,h);return n&&e(this,st).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),y?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||c(this,l,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),y?h.__staleWhileFetching:(c(this,l,Ht).call(this,a),r&&e(this,ut).call(this,a),h))}else n&&(n.get="miss");}delete(t){return c(this,l,at).call(this,t,"delete")}clear(){return c(this,l,Vt).call(this,"delete")}};K=new WeakMap,R=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,wt=new WeakMap,_t=new WeakMap,q=new WeakMap,D=new WeakMap,J=new WeakMap,O=new WeakMap,H=new WeakMap,p=new WeakMap,M=new WeakMap,W=new WeakMap,z=new WeakMap,C=new WeakMap,Y=new WeakMap,F=new WeakMap,X=new WeakMap,Q=new WeakMap,V=new WeakMap,j=new WeakMap,Z=new WeakMap,ht=new WeakMap,L=new WeakMap,At=new WeakMap,l=new WeakSet,Gt=function(){let t=new St(e(this,K)),i=new St(e(this,K));u(this,V,t),u(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,K)):void 0;u(this,j,s),u(this,Tt,(n,a,h=e(this,q).now())=>{if(i[n]=a!==0?h:0,t[n]=a,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),a!==0&&s){let y=setTimeout(()=>{e(this,P).call(this,n)&&c(this,l,at).call(this,e(this,H)[n],"expire");},a+1);y.unref&&y.unref(),s[n]=y;}}),u(this,ut,n=>{i[n]=t[n]!==0?e(this,q).now():0;}),u(this,st,(n,a)=>{if(t[a]){let h=t[a],y=i[a];if(!h||!y)return;n.ttl=h,n.start=y,n.now=r||o();let m=n.now-y;n.remainingTTL=h-m;}});let r=0,o=()=>{let n=e(this,q).now();if(this.ttlResolution>0){r=n;let a=setTimeout(()=>r=0,this.ttlResolution);a.unref&&a.unref();}return n};this.getRemainingTTL=n=>{let a=e(this,O).get(n);if(a===void 0)return 0;let h=t[a],y=i[a];if(!h||!y)return 1/0;let m=(r||o())-y;return h-m},u(this,P,n=>{let a=i[n],h=t[n];return !!h&&!!a&&(r||o())-a>h});},ut=new WeakMap,st=new WeakMap,Tt=new WeakMap,P=new WeakMap,Xt=function(){let t=new St(e(this,K));u(this,J,0),u(this,X,t),u(this,dt,i=>{u(this,J,e(this,J)-t[i]),t[i]=0;}),u(this,xt,(i,s,r,o)=>{if(c(this,l,E).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),u(this,Et,(i,s,r)=>{if(t[i]=s,e(this,R)){let o=e(this,R)-t[i];for(;e(this,J)>o;)c(this,l,Ft).call(this,true);}u(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},dt=new WeakMap,Et=new WeakMap,xt=new WeakMap,nt=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,C);!(!c(this,l,Rt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},ot=function*({allowStale:t=this.allowStale}={}){if(e(this,D))for(let i=e(this,z);!(!c(this,l,Rt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,M)[i];},Rt=function(t){return t!==void 0&&e(this,O).get(e(this,H)[t])===t},Ft=function(t){var o;let i=e(this,z),s=e(this,H)[i],r=e(this,p)[i];return e(this,ht)&&c(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,L))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,L)&&e(this,F)?.push([r,s,"evict"])),e(this,dt).call(this,i),e(this,j)?.[i]&&(clearTimeout(e(this,j)[i]),e(this,j)[i]=void 0),t&&(e(this,H)[i]=void 0,e(this,p)[i]=void 0,e(this,Y).push(i)),e(this,D)===1?(u(this,z,u(this,C,0)),e(this,Y).length=0):u(this,z,e(this,M)[i]),e(this,O).delete(s),Dt(this,D)._--,i},zt=function(t,i,s,r){let o=i===void 0?void 0:e(this,p)[i];if(c(this,l,E).call(this,o))return o;let n=new It,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},y=(x,A=false)=>{let{aborted:g}=n.signal,I=s.ignoreFetchAbort&&x!==void 0,k=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&x!==void 0);if(s.status&&(g&&!A?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,I&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!I&&!A)return b(n.signal.reason,k);let N=U,v=e(this,p)[i];return (v===U||I&&A&&v===void 0)&&(x===void 0?N.__staleWhileFetching!==void 0?e(this,p)[i]=N.__staleWhileFetching:c(this,l,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,x,h.options))),x},m=x=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=x),b(x,false)),b=(x,A)=>{let{aborted:g}=n.signal,I=g&&s.allowStaleOnFetchAbort,k=I||s.allowStaleOnFetchRejection,N=k||s.noDeleteOnFetchRejection,v=U;if(e(this,p)[i]===U&&(!N||!A&&v.__staleWhileFetching===void 0?c(this,l,at).call(this,t,"fetch"):I||(e(this,p)[i]=v.__staleWhileFetching)),k)return s.status&&v.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),v.__staleWhileFetching;if(v.__returned===v)throw x},_=(x,A)=>{var I;let g=(I=e(this,wt))==null?void 0:I.call(this,t,o,h);g&&g instanceof Promise&&g.then(k=>x(k===void 0?void 0:k),A),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(x(void 0),s.allowStaleOnFetchAbort&&(x=k=>y(k,true)));});};s.status&&(s.status.fetchDispatched=true);let U=new Promise(_).then(y,m),tt=Object.assign(U,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,O).get(t)):e(this,p)[i]=tt,tt},E=function(t){if(!e(this,ht))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof It},Wt=function(t,i){e(this,W)[i]=t,e(this,M)[t]=i;},Ht=function(t){t!==e(this,C)&&(t===e(this,z)?u(this,z,e(this,M)[t]):c(this,l,Wt).call(this,e(this,W)[t],e(this,M)[t]),c(this,l,Wt).call(this,e(this,C),t),u(this,C,t));},at=function(t,i){var r,o;let s=false;if(e(this,D)!==0){let n=e(this,O).get(t);if(n!==void 0)if(e(this,j)?.[n]&&(clearTimeout(e(this,j)?.[n]),e(this,j)[n]=void 0),s=true,e(this,D)===1)c(this,l,Vt).call(this,i);else {e(this,dt).call(this,n);let a=e(this,p)[n];if(c(this,l,E).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,L))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,L)&&e(this,F)?.push([a,t,i])),e(this,O).delete(t),e(this,H)[n]=void 0,e(this,p)[n]=void 0,n===e(this,C))u(this,C,e(this,W)[n]);else if(n===e(this,z))u(this,z,e(this,M)[n]);else {let h=e(this,W)[n];e(this,M)[h]=e(this,M)[n];let y=e(this,M)[n];e(this,W)[y]=e(this,W)[n];}Dt(this,D)._--,e(this,Y).push(n);}}if(e(this,L)&&e(this,F)?.length){let n=e(this,F),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},Vt=function(t){var i,s;for(let r of c(this,l,ot).call(this,{allowStale:true})){let o=e(this,p)[r];if(c(this,l,E).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,H)[r];e(this,Z)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,L)&&e(this,F)?.push([o,n,t]);}}if(e(this,O).clear(),e(this,p).fill(void 0),e(this,H).fill(void 0),e(this,V)&&e(this,Q)){e(this,V).fill(0),e(this,Q).fill(0);for(let r of e(this,j)??[])r!==void 0&&clearTimeout(r);e(this,j)?.fill(void 0);}if(e(this,X)&&e(this,X).fill(0),u(this,z,0),u(this,C,0),e(this,Y).length=0,u(this,J,0),u(this,D,0),e(this,L)&&e(this,F)){let r=e(this,F),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}};var Nt=jt;var lt=class{constructor(t){w(this,"cache");w(this,"map",new Map);this.cache=new Nt({max:t.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(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var it=class it{static get originalStepData(){return it._originalStepData?et(it._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){it._originalStepData=et(t);}};w(it,"_diffHistory",new lt({cacheSize:5})),w(it,"_stepsInfoHistory",new lt({cacheSize:5})),w(it,"_narrationHistory",new lt({cacheSize:50})),w(it,"stepLimitSaved",20),w(it,"_originalStepData");var d=it;var vt=class{get stepsInfoMap(){return d._stepsInfoHistory}get diffMap(){return d._diffHistory}get narrationMap(){return d._narrationHistory}get size(){return d._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return d._stepsInfoHistory.keys()}get(t){let i=d._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){d._stepsInfoHistory.delete(t),d._diffHistory.delete(t),d._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size==0)return i;let s=this.lastKey;if(typeof s!="number")return T.warn("You can't go back, there is no step to go back"),i;let r=d._diffHistory.get(s);if(r)try{let o=Ut(i,r);return unifier.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return T.error("Error applying diff",o),i}else return T.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){T.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){T.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(unifier.GameUnifier.runningStepsCount>0){unifier.GameUnifier.increaseBackRequest(s);return}if(d._diffHistory.size<1){T.warn("You can't go back, there is no step to go back");return}unifier.GameUnifier.runningStepsCount++;try{let r=et(this.getOldGameState(s,d.originalStepData));if(r){await unifier.GameUnifier.restoreGameStepState(r,unifier.GameUnifier.navigate);let o=unifier.GameUnifier.stepCounter-1,n=d._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=d._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});d._narrationHistory.set(a.index,h);}}}else T.error("Error going back");d.originalStepData=r;}catch(r){T.error("Error going back",r);}finally{if(unifier.GameUnifier.runningStepsCount--,unifier.GameUnifier.runningStepsCount===0&&unifier.GameUnifier.backRequestsCount!==0)return await unifier.GameUnifier.processNavigationRequests(t)}}add(t,i={}){let s=d.originalStepData,{ignoreSameStep:r}=i,o=unifier.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,y;if(typeof n=="number"&&(h=d._stepsInfoHistory.get(n),y=d._narrationHistory.get(n)),d._stepsInfoHistory.set(t.index,t),t.index!==0){let _=Ct(s,o);_?d._diffHistory.set(t.index,_):T.warn("It was not possible to create the difference between the two steps");}let m={},b=this.itemMapper({step:t},m);if(d._narrationHistory.set(t.index,b),h&&y&&typeof n=="number"){let _=this.itemMapper({...m,step:h},{});d._narrationHistory.set(n,_);}}catch(h){T.error("Error adding history step",h);}})(),d.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue||s.dialoge;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let y=h?.map((m,b)=>{let _=false;return m.oneTime&&s.alreadyMadeChoices&&s.alreadyMadeChoices.includes(b)&&(_=true),{text:m.text,type:m.type,isResponse:false,hidden:_}});if(y){if(y.every(m=>m.hidden)){let m=y.find(b=>b.hidden===false);m&&(m.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?unifier.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,stepIndex:s.index,inputValue:o}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((h,y)=>y-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=d._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,y)=>{let m=this.get(h);if(m){if(y===0)return t.push(m),true;let b=d._stepsInfoHistory.get(h);if(!b)return true;let _=b.openedLabels;if(!_||!Array.isArray(_)||_.length===0||_[0].label!==a||_[0].currentStepIndex>=n)return false;n=_[0].currentStepIndex,t.push(m);}return true}),t.reverse()}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{d._narrationHistory.delete(s),d._stepsInfoHistory.delete(s),d._diffHistory.delete(s);});}else d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:d._diffHistory.has(t)}blockGoBack(){unifier.GameUnifier.runningStepsCount===0&&d._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return T.error("Error comparing opened labels",s),true}return false}clear(){d._stepsInfoHistory.clear(),d._diffHistory.clear(),d._narrationHistory.clear(),d._originalStepData=void 0;}get stepLimitSaved(){return d.stepLimitSaved}set stepLimitSaved(t){d.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];return t.forEach(s=>{let r=d._stepsInfoHistory.get(s);if(r){let o=d._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:et(i),originalStepData:et(d._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=d._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&d._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&d._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};d._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):T.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?d._originalStepData=t.originalStepData:T.warn("Could not import originalStepData data, so will be ignored");}catch(i){T.error("Error importing data",i);}}};var ke=new vt;exports.HistoryManagerStatic=d;exports.stepHistory=ke;
|
package/dist/history.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import'./chunk-XSN6P5JL.mjs';import {a}from'./chunk-GFG3MDHE.mjs';import {d,k as k$1,j}from'./chunk-GNJIUFU2.mjs';import {GameUnifier}from'@drincs/pixi-vn/unifier';var k={Date:true,RegExp:true,String:true,Number:true};function x(d,e,r={cyclesFix:true},t=[]){let a=[],n=Array.isArray(d);for(let o in d){let s=d[o],u=n?+o:o;if(!(o in e)){a.push({type:"REMOVE",path:[u],oldValue:d[o]});continue}let p=e[o],m=typeof s=="object"&&typeof p=="object"&&Array.isArray(s)===Array.isArray(p);s&&p&&m&&!k[Object.getPrototypeOf(s)?.constructor?.name]&&(!r.cyclesFix||!t.includes(s))?a.push.apply(a,x(s,p,r,r.cyclesFix?t.concat([s]):[]).map(c=>(c.path.unshift(u),c))):s!==p&&!(Number.isNaN(s)&&Number.isNaN(p))&&!(m&&(isNaN(s)?s+""==p+"":+s==+p))&&a.push({path:[u],type:"CHANGE",value:p,oldValue:s});}let f=Array.isArray(e);for(let o in e)o in d||a.push({type:"CREATE",path:[f?+o:o],value:e[o]});return a}function D(d,e){let r=k$1(d);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(t=>{"type"in t?I(r,t):E(r,t);}),r}function I(d,e){let r=d;e.path&&e.path.length>0?e.path.forEach((t,a)=>{if(e.path&&a===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":r[t]=e.oldValue;break;case "CREATE":Array.isArray(r)&&typeof t=="number"?r.splice(t,1):delete r[t];break}else r=r[t];}):j.warn("No path found, skipping diff",e);}function E(d,e){let r=d;e.path&&e.path.length>0?e.path.forEach((t,a)=>{if(e.path&&a===e.path.length-1){if(e.kind==="E"||e.kind==="D")r[t]=e.lhs;else if(e.kind==="N")Number.isInteger(t)?Array.isArray(r)&&r.splice(t,1):typeof t=="string"&&delete r[t];else if(e.kind==="A"){let n=e.index;e.item.kind==="N"?r[t].splice(n,1):e.item.kind==="E"||e.item.kind==="D"?r[t][n]=e.item.lhs:e.item.kind==="A"?j.warn("Nested array found, skipping diff",e):j.warn("No array found, skipping diff",e);}}else r=r[t];}):j.warn("No path found, skipping diff",e);}var g=class g{static get originalStepData(){return g._originalStepData?k$1(g._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){g._originalStepData=k$1(e);}};d(g,"_diffHistory",new a({cacheSize:5})),d(g,"_stepsInfoHistory",new a({cacheSize:5})),d(g,"_narrationHistory",new a({cacheSize:50})),d(g,"stepLimitSaved",20),d(g,"_originalStepData");var i=g;var b=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}getOldGameState(e,r){if(e<=0||this.size==0)return r;let t=this.lastKey;if(typeof t!="number")return j.warn("You can't go back, there is no step to go back"),r;let a=i._diffHistory.get(t);if(a)try{let n=D(r,a);return GameUnifier.stepCounter=t,this.delete(t),this.getOldGameState(e-1,n)}catch(n){return j.error("Error applying diff",n),r}else return j.warn("No diff found for the last step, cannot go back"),r}async back(e,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){j.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){j.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){j.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{let a=k$1(this.getOldGameState(t,i.originalStepData));if(a){await GameUnifier.restoreGameStepState(a,GameUnifier.navigate);let n=GameUnifier.stepCounter-1,f=i._narrationHistory.get(n);if(f&&Object.keys(f).length===1&&f.stepIndex!==void 0){let o=i._stepsInfoHistory.get(n);if(o){let s=this.itemMapper({step:o});i._narrationHistory.set(o.index,s);}}}else j.error("Error going back");i.originalStepData=a;}catch(a){j.error("Error going back",a);}finally{if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests()}}add(e,r={}){let t=i.originalStepData,{ignoreSameStep:a}=r,n=GameUnifier.currentGameStepState;if(!a&&this.isSameStep(t,n))return;let f=this.lastKey;(async()=>{try{let s,u;if(typeof f=="number"&&(s=i._stepsInfoHistory.get(f),u=i._narrationHistory.get(f)),i._stepsInfoHistory.set(e.index,e),e.index!==0){let c=x(t,n);c?i._diffHistory.set(e.index,c):j.warn("It was not possible to create the difference between the two steps");}let p={},m=this.itemMapper({step:e},p);if(i._narrationHistory.set(e.index,m),s&&u&&typeof f=="number"){let c=this.itemMapper({...p,step:s},{});i._narrationHistory.set(f,c);}}catch(s){j.error("Error adding history step",s);}})(),i.originalStepData=n;}itemMapper(e,r){let{step:t,choiceIndexMade:a,inputValue:n,removeDialogue:f}=e,o=t.dialogue||t.dialoge;r&&t.isGlued&&(r.removeDialogue=true),f&&(o=void 0);let s=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||s||n){let u=s?.map((p,m)=>{let c=false;return p.oneTime&&t.alreadyMadeChoices&&t.alreadyMadeChoices.includes(m)&&(c=true),{text:p.text,type:p.type,isResponse:false,hidden:c}});if(u){if(u.every(p=>p.hidden)){let p=u.find(m=>m.hidden===false);p&&(p.hidden=false);}a!==void 0&&(u[a].isResponse=true);}return {dialogue:o?{...o,character:o.character?GameUnifier.getCharacter(o.character)||o.character:void 0}:void 0,playerMadeChoice:typeof a=="number",choices:u,stepIndex:t.index,inputValue:n}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,a)=>t-a).forEach(t=>{let a=this.get(t);a&&e.push(a);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((s,u)=>u-s);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let a=i._stepsInfoHistory.get(t);if(!a)return e;let n=a.openedLabels;if(!n||!Array.isArray(n)||n.length===0)return e;let f=n[0].currentStepIndex,o=n[0].label;return r.every((s,u)=>{let p=this.get(s);if(p){if(u===0)return e.push(p),true;let m=i._stepsInfoHistory.get(s);if(!m)return true;let c=m.openedLabels;if(!c||!Array.isArray(c)||c.length===0||c[0].label!==o||c[0].currentStepIndex>=f)return false;f=c[0].currentStepIndex,e.push(p);}return true}),e.reverse()}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,a)=>t-a);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:i._diffHistory.has(e)}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e,r){if(e.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e.openedLabels),a=JSON.stringify(r.openedLabels);if(t===a&&e.path===r.path&&e.labelIndex===r.labelIndex)return !0}catch(t){return j.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((t,a)=>t-a);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];return e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let n=i._diffHistory.get(t);r.push({...a,diff:n});}}),{stepsHistory:k$1(r),originalStepData:k$1(i._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,a)=>t-a),r={};e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let n={...r};r={};let f=this.itemMapper({step:a,choiceIndexMade:n.choiceIndexMade,inputValue:n.inputValue,removeDialogue:n.removeDialogue},r);f&&i._narrationHistory.set(t,f);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let a={...t,diff:void 0};i._stepsInfoHistory.set(t.index,a);}),this.restoreNarrativeHistory()):j.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?i._originalStepData=e.originalStepData:j.warn("Could not import originalStepData data, so will be ignored");}catch(r){j.error("Error importing data",r);}}};var P=new b;export{i as HistoryManagerStatic,P as stepHistory};
|
|
1
|
+
import'./chunk-XSN6P5JL.mjs';import {a}from'./chunk-GFG3MDHE.mjs';import {d,k as k$1,j}from'./chunk-GNJIUFU2.mjs';import {GameUnifier}from'@drincs/pixi-vn/unifier';var k={Date:true,RegExp:true,String:true,Number:true};function x(d,e,r={cyclesFix:true},t=[]){let a=[],n=Array.isArray(d);for(let o in d){let s=d[o],u=n?+o:o;if(!(o in e)){a.push({type:"REMOVE",path:[u],oldValue:d[o]});continue}let p=e[o],m=typeof s=="object"&&typeof p=="object"&&Array.isArray(s)===Array.isArray(p);s&&p&&m&&!k[Object.getPrototypeOf(s)?.constructor?.name]&&(!r.cyclesFix||!t.includes(s))?a.push.apply(a,x(s,p,r,r.cyclesFix?t.concat([s]):[]).map(c=>(c.path.unshift(u),c))):s!==p&&!(Number.isNaN(s)&&Number.isNaN(p))&&!(m&&(isNaN(s)?s+""==p+"":+s==+p))&&a.push({path:[u],type:"CHANGE",value:p,oldValue:s});}let f=Array.isArray(e);for(let o in e)o in d||a.push({type:"CREATE",path:[f?+o:o],value:e[o]});return a}function D(d,e){let r=k$1(d);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(t=>{"type"in t?I(r,t):E(r,t);}),r}function I(d,e){let r=d;e.path&&e.path.length>0?e.path.forEach((t,a)=>{if(e.path&&a===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":r[t]=e.oldValue;break;case "CREATE":Array.isArray(r)&&typeof t=="number"?r.splice(t,1):delete r[t];break}else r=r[t];}):j.warn("No path found, skipping diff",e);}function E(d,e){let r=d;e.path&&e.path.length>0?e.path.forEach((t,a)=>{if(e.path&&a===e.path.length-1){if(e.kind==="E"||e.kind==="D")r[t]=e.lhs;else if(e.kind==="N")Number.isInteger(t)?Array.isArray(r)&&r.splice(t,1):typeof t=="string"&&delete r[t];else if(e.kind==="A"){let n=e.index;e.item.kind==="N"?r[t].splice(n,1):e.item.kind==="E"||e.item.kind==="D"?r[t][n]=e.item.lhs:e.item.kind==="A"?j.warn("Nested array found, skipping diff",e):j.warn("No array found, skipping diff",e);}}else r=r[t];}):j.warn("No path found, skipping diff",e);}var g=class g{static get originalStepData(){return g._originalStepData?k$1(g._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){g._originalStepData=k$1(e);}};d(g,"_diffHistory",new a({cacheSize:5})),d(g,"_stepsInfoHistory",new a({cacheSize:5})),d(g,"_narrationHistory",new a({cacheSize:50})),d(g,"stepLimitSaved",20),d(g,"_originalStepData");var i=g;var b=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}getOldGameState(e,r){if(e<=0||this.size==0)return r;let t=this.lastKey;if(typeof t!="number")return j.warn("You can't go back, there is no step to go back"),r;let a=i._diffHistory.get(t);if(a)try{let n=D(r,a);return GameUnifier.stepCounter=t,this.delete(t),this.getOldGameState(e-1,n)}catch(n){return j.error("Error applying diff",n),r}else return j.warn("No diff found for the last step, cannot go back"),r}async back(e,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){j.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){j.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){j.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{let a=k$1(this.getOldGameState(t,i.originalStepData));if(a){await GameUnifier.restoreGameStepState(a,GameUnifier.navigate);let n=GameUnifier.stepCounter-1,f=i._narrationHistory.get(n);if(f&&Object.keys(f).length===1&&f.stepIndex!==void 0){let o=i._stepsInfoHistory.get(n);if(o){let s=this.itemMapper({step:o});i._narrationHistory.set(o.index,s);}}}else j.error("Error going back");i.originalStepData=a;}catch(a){j.error("Error going back",a);}finally{if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e)}}add(e,r={}){let t=i.originalStepData,{ignoreSameStep:a}=r,n=GameUnifier.currentGameStepState;if(!a&&this.isSameStep(t,n))return;let f=this.lastKey;(async()=>{try{let s,u;if(typeof f=="number"&&(s=i._stepsInfoHistory.get(f),u=i._narrationHistory.get(f)),i._stepsInfoHistory.set(e.index,e),e.index!==0){let c=x(t,n);c?i._diffHistory.set(e.index,c):j.warn("It was not possible to create the difference between the two steps");}let p={},m=this.itemMapper({step:e},p);if(i._narrationHistory.set(e.index,m),s&&u&&typeof f=="number"){let c=this.itemMapper({...p,step:s},{});i._narrationHistory.set(f,c);}}catch(s){j.error("Error adding history step",s);}})(),i.originalStepData=n;}itemMapper(e,r){let{step:t,choiceIndexMade:a,inputValue:n,removeDialogue:f}=e,o=t.dialogue||t.dialoge;r&&t.isGlued&&(r.removeDialogue=true),f&&(o=void 0);let s=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||s||n){let u=s?.map((p,m)=>{let c=false;return p.oneTime&&t.alreadyMadeChoices&&t.alreadyMadeChoices.includes(m)&&(c=true),{text:p.text,type:p.type,isResponse:false,hidden:c}});if(u){if(u.every(p=>p.hidden)){let p=u.find(m=>m.hidden===false);p&&(p.hidden=false);}a!==void 0&&(u[a].isResponse=true);}return {dialogue:o?{...o,character:o.character?GameUnifier.getCharacter(o.character)||o.character:void 0}:void 0,playerMadeChoice:typeof a=="number",choices:u,stepIndex:t.index,inputValue:n}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,a)=>t-a).forEach(t=>{let a=this.get(t);a&&e.push(a);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((s,u)=>u-s);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let a=i._stepsInfoHistory.get(t);if(!a)return e;let n=a.openedLabels;if(!n||!Array.isArray(n)||n.length===0)return e;let f=n[0].currentStepIndex,o=n[0].label;return r.every((s,u)=>{let p=this.get(s);if(p){if(u===0)return e.push(p),true;let m=i._stepsInfoHistory.get(s);if(!m)return true;let c=m.openedLabels;if(!c||!Array.isArray(c)||c.length===0||c[0].label!==o||c[0].currentStepIndex>=f)return false;f=c[0].currentStepIndex,e.push(p);}return true}),e.reverse()}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,a)=>t-a);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:i._diffHistory.has(e)}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e,r){if(e.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e.openedLabels),a=JSON.stringify(r.openedLabels);if(t===a&&e.path===r.path&&e.labelIndex===r.labelIndex)return !0}catch(t){return j.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((t,a)=>t-a);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];return e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let n=i._diffHistory.get(t);r.push({...a,diff:n});}}),{stepsHistory:k$1(r),originalStepData:k$1(i._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,a)=>t-a),r={};e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let n={...r};r={};let f=this.itemMapper({step:a,choiceIndexMade:n.choiceIndexMade,inputValue:n.inputValue,removeDialogue:n.removeDialogue},r);f&&i._narrationHistory.set(t,f);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let a={...t,diff:void 0};i._stepsInfoHistory.set(t.index,a);}),this.restoreNarrativeHistory()):j.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?i._originalStepData=e.originalStepData:j.warn("Could not import originalStepData data, so will be ignored");}catch(r){j.error("Error importing data",r);}}};var P=new b;export{i as HistoryManagerStatic,P as stepHistory};
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var N=require('@drincs/pixi-vn/canvas'),Yt=require('@drincs/pixi-vn/characters'),et=require('@drincs/pixi-vn/history'),j=require('@drincs/pixi-vn/narration'),ht=require('@drincs/pixi-vn/sound'),V=require('@drincs/pixi-vn/storage'),unifier=require('@drincs/pixi-vn/unifier');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var N__namespace=/*#__PURE__*/_interopNamespace(N);var Yt__namespace=/*#__PURE__*/_interopNamespace(Yt);var et__namespace=/*#__PURE__*/_interopNamespace(et);var j__namespace=/*#__PURE__*/_interopNamespace(j);var ht__namespace=/*#__PURE__*/_interopNamespace(ht);var V__namespace=/*#__PURE__*/_interopNamespace(V);var Jt=Object.defineProperty;var Qt=l=>{throw TypeError(l)};var le=(l,e,i)=>e in l?Jt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var ce=(l,e)=>{for(var i in e)Jt(l,i,{get:e[i],enumerable:true});};var v=(l,e,i)=>le(l,typeof e!="symbol"?e+"":e,i),It=(l,e,i)=>e.has(l)||Qt("Cannot "+i);var t=(l,e,i)=>(It(l,e,"read from private field"),i?i.call(l):e.get(l)),y=(l,e,i)=>e.has(l)?Qt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),f=(l,e,i,s)=>(It(l,e,"write to private field"),e.set(l,i),i),h=(l,e,i)=>(It(l,e,"access private method"),i);var Ct=(l,e,i,s)=>({set _(r){f(l,e,r);},get _(){return t(l,e,s)}});var fe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ie=new Set,Rt=typeof process=="object"&&process?process:{},se=(l,e,i,s)=>{typeof Rt.emitWarning=="function"?Rt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Pt=globalThis.AbortController,Zt=globalThis.AbortSignal;if(typeof Pt>"u"){Zt=class{constructor(){v(this,"onabort");v(this,"_onabort",[]);v(this,"reason");v(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},Pt=class{constructor(){v(this,"signal",new Zt);e();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let l=Rt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,se("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 de=l=>!ie.has(l);var st=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),ne=l=>st(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?_t:null:null,_t=class extends Array{constructor(e){super(e),this.fill(0);}},yt,lt=class lt{constructor(e,i){v(this,"heap");v(this,"length");if(!t(lt,yt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=ne(e);if(!i)return [];f(lt,yt,true);let s=new lt(e,i);return f(lt,yt,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};yt=new WeakMap,y(lt,yt,false);var Nt=lt,te,ee,K,G,$,ct,B,St,vt,X,U,Y,E,x,g,I,W,P,O,J,D,Q,Z,H,k,tt,at,R,bt,a,Mt,ft,it,Tt,q,re,dt,wt,Et,nt,rt,Vt,Ft,jt,w,Gt,At,ot,Wt,Ht=class Ht{constructor(e){y(this,a);y(this,K);y(this,G);y(this,$);y(this,ct);y(this,B);y(this,St);y(this,vt);y(this,X);v(this,"ttl");v(this,"ttlResolution");v(this,"ttlAutopurge");v(this,"updateAgeOnGet");v(this,"updateAgeOnHas");v(this,"allowStale");v(this,"noDisposeOnSet");v(this,"noUpdateTTL");v(this,"maxEntrySize");v(this,"sizeCalculation");v(this,"noDeleteOnFetchRejection");v(this,"noDeleteOnStaleGet");v(this,"allowStaleOnFetchAbort");v(this,"allowStaleOnFetchRejection");v(this,"ignoreFetchAbort");y(this,U);y(this,Y);y(this,E);y(this,x);y(this,g);y(this,I);y(this,W);y(this,P);y(this,O);y(this,J);y(this,D);y(this,Q);y(this,Z);y(this,H);y(this,k);y(this,tt);y(this,at);y(this,R);y(this,bt);y(this,ft,()=>{});y(this,it,()=>{});y(this,Tt,()=>{});y(this,q,()=>false);y(this,dt,e=>{});y(this,wt,(e,i,s)=>{});y(this,Et,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});v(this,te,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:d,allowStale:u,dispose:S,onInsert:L,disposeAfter:b,noDisposeOnSet:m,noUpdateTTL:A,maxSize:C=0,maxEntrySize:c=0,sizeCalculation:_,fetchMethod:p,memoMethod:F,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:z,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:ut,ignoreFetchAbort:pt,perf:Dt}=e;if(Dt!==void 0&&typeof Dt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,Dt??fe),i!==0&&!st(i))throw new TypeError("max option must be a nonnegative integer");let mt=i?ne(i):Array;if(!mt)throw new Error("invalid max value: "+i);if(f(this,K,i),f(this,G,C),this.maxEntrySize=c||t(this,G),this.sizeCalculation=_,this.sizeCalculation){if(!t(this,G)&&!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(F!==void 0&&typeof F!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,vt,F),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,St,p),f(this,at,!!p),f(this,E,new Map),f(this,x,new Array(i).fill(void 0)),f(this,g,new Array(i).fill(void 0)),f(this,I,new mt(i)),f(this,W,new mt(i)),f(this,P,0),f(this,O,0),f(this,J,Nt.create(i)),f(this,U,0),f(this,Y,0),typeof S=="function"&&f(this,$,S),typeof L=="function"&&f(this,ct,L),typeof b=="function"?(f(this,B,b),f(this,D,[])):(f(this,B,void 0),f(this,D,void 0)),f(this,tt,!!t(this,$)),f(this,bt,!!t(this,ct)),f(this,R,!!t(this,B)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!A,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!ut,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(t(this,G)!==0&&!st(t(this,G)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,a,re).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!z,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!d,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,a,Mt).call(this);}if(t(this,K)===0&&this.ttl===0&&t(this,G)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,K)&&!t(this,G)){let gt="LRU_CACHE_UNBOUNDED";de(gt)&&(ie.add(gt),se("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",gt,Ht));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,H),autopurgeTimers:t(e,k),sizes:t(e,Q),keyMap:t(e,E),keyList:t(e,x),valList:t(e,g),next:t(e,I),prev:t(e,W),get head(){return t(e,P)},get tail(){return t(e,O)},free:t(e,J),isBackgroundFetch:i=>{var s;return h(s=e,a,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return h(n=e,a,jt).call(n,i,s,r,o)},moveToTail:i=>{var s;return h(s=e,a,At).call(s,i)},indexes:i=>{var s;return h(s=e,a,nt).call(s,i)},rindexes:i=>{var s;return h(s=e,a,rt).call(s,i)},isStale:i=>{var s;return t(s=e,q).call(s,i)}}}get max(){return t(this,K)}get maxSize(){return t(this,G)}get calculatedSize(){return t(this,Y)}get size(){return t(this,U)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,vt)}get dispose(){return t(this,$)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,E).has(e)?1/0:0}*entries(){for(let e of h(this,a,nt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*rentries(){for(let e of h(this,a,rt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*keys(){for(let e of h(this,a,nt).call(this)){let i=t(this,x)[e];i!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of h(this,a,rt).call(this)){let i=t(this,x)[e];i!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of h(this,a,nt).call(this))t(this,g)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of h(this,a,rt).call(this))t(this,g)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(ee=Symbol.iterator,te=Symbol.toStringTag,ee)](){return this.entries()}find(e,i={}){for(let s of h(this,a,nt).call(this)){let r=t(this,g)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,x)[s],this))return this.get(t(this,x)[s],i)}}forEach(e,i=this){for(let s of h(this,a,nt).call(this)){let r=t(this,g)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,x)[s],this);}}rforEach(e,i=this){for(let s of h(this,a,rt).call(this)){let r=t(this,g)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,x)[s],this);}}purgeStale(){let e=false;for(let i of h(this,a,rt).call(this,{allowStale:true}))t(this,q).call(this,i)&&(h(this,a,ot).call(this,t(this,x)[i],"expire"),e=true);return e}info(e){let i=t(this,E).get(e);if(i===void 0)return;let s=t(this,g)[i],r=h(this,a,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,H)&&t(this,Z)){let n=t(this,H)[i],d=t(this,Z)[i];if(n&&d){let u=n-(t(this,X).now()-d);o.ttl=u,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of h(this,a,nt).call(this,{allowStale:true})){let s=t(this,x)[i],r=t(this,g)[i],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(t(this,H)&&t(this,Z)){n.ttl=t(this,H)[i];let d=t(this,X).now()-t(this,Z)[i];n.start=Math.floor(Date.now()-d);}t(this,Q)&&(n.size=t(this,Q)[i]),e.unshift([s,n]);}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 m,A,C,c;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:d=this.sizeCalculation,status:u}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,L=t(this,Et).call(this,e,i,s.size||0,d);if(this.maxEntrySize&&L>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,a,ot).call(this,e,"set"),this;let b=t(this,U)===0?void 0:t(this,E).get(e);if(b===void 0)b=t(this,U)===0?t(this,O):t(this,J).length!==0?t(this,J).pop():t(this,U)===t(this,K)?h(this,a,Ft).call(this,false):t(this,U),t(this,x)[b]=e,t(this,g)[b]=i,t(this,E).set(e,b),t(this,I)[t(this,O)]=b,t(this,W)[b]=t(this,O),f(this,O,b),Ct(this,U)._++,t(this,wt).call(this,b,L,u),u&&(u.set="add"),S=false,t(this,bt)&&((m=t(this,ct))==null||m.call(this,i,e,"add"));else {h(this,a,At).call(this,b);let _=t(this,g)[b];if(i!==_){if(t(this,at)&&h(this,a,w).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=_;p!==void 0&&!n&&(t(this,tt)&&((A=t(this,$))==null||A.call(this,p,e,"set")),t(this,R)&&t(this,D)?.push([p,e,"set"]));}else n||(t(this,tt)&&((C=t(this,$))==null||C.call(this,_,e,"set")),t(this,R)&&t(this,D)?.push([_,e,"set"]));if(t(this,dt).call(this,b),t(this,wt).call(this,b,L,u),t(this,g)[b]=i,u){u.set="replace";let p=_&&h(this,a,w).call(this,_)?_.__staleWhileFetching:_;p!==void 0&&(u.oldValue=p);}}else u&&(u.set="update");t(this,bt)&&this.onInsert?.(i,e,i===_?"update":"replace");}if(r!==0&&!t(this,H)&&h(this,a,Mt).call(this),t(this,H)&&(S||t(this,Tt).call(this,b,r,o),u&&t(this,it).call(this,u,b)),!n&&t(this,R)&&t(this,D)){let _=t(this,D),p;for(;p=_?.shift();)(c=t(this,B))==null||c.call(this,...p);}return this}pop(){var e;try{for(;t(this,U);){let i=t(this,g)[t(this,P)];if(h(this,a,Ft).call(this,!0),h(this,a,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,R)&&t(this,D)){let i=t(this,D),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,E).get(e);if(o!==void 0){let n=t(this,g)[o];if(h(this,a,w).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(t(this,q).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ft).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,E).get(e);if(r===void 0||!s&&t(this,q).call(this,r))return;let o=t(this,g)[r];return h(this,a,w).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:d=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:A=this.ignoreFetchAbort,allowStaleOnFetchAbort:C=this.allowStaleOnFetchAbort,context:c,forceRefresh:_=false,status:p,signal:F}=i;if(!t(this,at))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});let M={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:d,size:u,sizeCalculation:S,noUpdateTTL:L,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:C,ignoreFetchAbort:A,status:p,signal:F},z=t(this,E).get(e);if(z===void 0){p&&(p.fetch="miss");let T=h(this,a,jt).call(this,e,z,M,c);return T.__returned=T}else {let T=t(this,g)[z];if(h(this,a,w).call(this,T)){let gt=s&&T.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",gt&&(p.returnedStale=true)),gt?T.__staleWhileFetching:T.__returned=T}let ut=t(this,q).call(this,z);if(!_&&!ut)return p&&(p.fetch="hit"),h(this,a,At).call(this,z),r&&t(this,ft).call(this,z),p&&t(this,it).call(this,p,z),T;let pt=h(this,a,jt).call(this,e,z,M,c),mt=pt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=ut?"stale":"refresh",mt&&ut&&(p.returnedStale=true)),mt?pt.__staleWhileFetching:pt.__returned=pt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,vt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,d=this.get(e,n);if(!o&&d!==void 0)return d;let u=s(e,d,{options:n,context:r});return this.set(e,u,n),u}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,d=t(this,E).get(e);if(d!==void 0){let u=t(this,g)[d],S=h(this,a,w).call(this,u);return n&&t(this,it).call(this,n,d),t(this,q).call(this,d)?(n&&(n.get="stale"),S?(n&&s&&u.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?u.__staleWhileFetching:void 0):(o||h(this,a,ot).call(this,e,"expire"),n&&s&&(n.returnedStale=true),s?u:void 0)):(n&&(n.get="hit"),S?u.__staleWhileFetching:(h(this,a,At).call(this,d),r&&t(this,ft).call(this,d),u))}else n&&(n.get="miss");}delete(e){return h(this,a,ot).call(this,e,"delete")}clear(){return h(this,a,Wt).call(this,"delete")}};K=new WeakMap,G=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,St=new WeakMap,vt=new WeakMap,X=new WeakMap,U=new WeakMap,Y=new WeakMap,E=new WeakMap,x=new WeakMap,g=new WeakMap,I=new WeakMap,W=new WeakMap,P=new WeakMap,O=new WeakMap,J=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,H=new WeakMap,k=new WeakMap,tt=new WeakMap,at=new WeakMap,R=new WeakMap,bt=new WeakMap,a=new WeakSet,Mt=function(){let e=new _t(t(this,K)),i=new _t(t(this,K));f(this,H,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,K)):void 0;f(this,k,s),f(this,Tt,(n,d,u=t(this,X).now())=>{if(i[n]=d!==0?u:0,e[n]=d,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),d!==0&&s){let S=setTimeout(()=>{t(this,q).call(this,n)&&h(this,a,ot).call(this,t(this,x)[n],"expire");},d+1);S.unref&&S.unref(),s[n]=S;}}),f(this,ft,n=>{i[n]=e[n]!==0?t(this,X).now():0;}),f(this,it,(n,d)=>{if(e[d]){let u=e[d],S=i[d];if(!u||!S)return;n.ttl=u,n.start=S,n.now=r||o();let L=n.now-S;n.remainingTTL=u-L;}});let r=0,o=()=>{let n=t(this,X).now();if(this.ttlResolution>0){r=n;let d=setTimeout(()=>r=0,this.ttlResolution);d.unref&&d.unref();}return n};this.getRemainingTTL=n=>{let d=t(this,E).get(n);if(d===void 0)return 0;let u=e[d],S=i[d];if(!u||!S)return 1/0;let L=(r||o())-S;return u-L},f(this,q,n=>{let d=i[n],u=e[n];return !!u&&!!d&&(r||o())-d>u});},ft=new WeakMap,it=new WeakMap,Tt=new WeakMap,q=new WeakMap,re=function(){let e=new _t(t(this,K));f(this,Y,0),f(this,Q,e),f(this,dt,i=>{f(this,Y,t(this,Y)-e[i]),e[i]=0;}),f(this,Et,(i,s,r,o)=>{if(h(this,a,w).call(this,s))return 0;if(!st(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!st(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,wt,(i,s,r)=>{if(e[i]=s,t(this,G)){let o=t(this,G)-e[i];for(;t(this,Y)>o;)h(this,a,Ft).call(this,true);}f(this,Y,t(this,Y)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,Y));});},dt=new WeakMap,wt=new WeakMap,Et=new WeakMap,nt=function*({allowStale:e=this.allowStale}={}){if(t(this,U))for(let i=t(this,O);!(!h(this,a,Vt).call(this,i)||((e||!t(this,q).call(this,i))&&(yield i),i===t(this,P)));)i=t(this,W)[i];},rt=function*({allowStale:e=this.allowStale}={}){if(t(this,U))for(let i=t(this,P);!(!h(this,a,Vt).call(this,i)||((e||!t(this,q).call(this,i))&&(yield i),i===t(this,O)));)i=t(this,I)[i];},Vt=function(e){return e!==void 0&&t(this,E).get(t(this,x)[e])===e},Ft=function(e){var o;let i=t(this,P),s=t(this,x)[i],r=t(this,g)[i];return t(this,at)&&h(this,a,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,R))&&(t(this,tt)&&((o=t(this,$))==null||o.call(this,r,s,"evict")),t(this,R)&&t(this,D)?.push([r,s,"evict"])),t(this,dt).call(this,i),t(this,k)?.[i]&&(clearTimeout(t(this,k)[i]),t(this,k)[i]=void 0),e&&(t(this,x)[i]=void 0,t(this,g)[i]=void 0,t(this,J).push(i)),t(this,U)===1?(f(this,P,f(this,O,0)),t(this,J).length=0):f(this,P,t(this,I)[i]),t(this,E).delete(s),Ct(this,U)._--,i},jt=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(h(this,a,w).call(this,o))return o;let n=new Pt,{signal:d}=s;d?.addEventListener("abort",()=>n.abort(d.reason),{signal:n.signal});let u={signal:n.signal,options:s,context:r},S=(c,_=false)=>{let{aborted:p}=n.signal,F=s.ignoreFetchAbort&&c!==void 0,M=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&c!==void 0);if(s.status&&(p&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,F&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!F&&!_)return b(n.signal.reason,M);let z=A,T=t(this,g)[i];return (T===A||F&&_&&T===void 0)&&(c===void 0?z.__staleWhileFetching!==void 0?t(this,g)[i]=z.__staleWhileFetching:h(this,a,ot).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,c,u.options))),c},L=c=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=c),b(c,false)),b=(c,_)=>{let{aborted:p}=n.signal,F=p&&s.allowStaleOnFetchAbort,M=F||s.allowStaleOnFetchRejection,z=M||s.noDeleteOnFetchRejection,T=A;if(t(this,g)[i]===A&&(!z||!_&&T.__staleWhileFetching===void 0?h(this,a,ot).call(this,e,"fetch"):F||(t(this,g)[i]=T.__staleWhileFetching)),M)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw c},m=(c,_)=>{var F;let p=(F=t(this,St))==null?void 0:F.call(this,e,o,u);p&&p instanceof Promise&&p.then(M=>c(M===void 0?void 0:M),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(c(void 0),s.allowStaleOnFetchAbort&&(c=M=>S(M,true)));});};s.status&&(s.status.fetchDispatched=true);let A=new Promise(m).then(S,L),C=Object.assign(A,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,C,{...u.options,status:void 0}),i=t(this,E).get(e)):t(this,g)[i]=C,C},w=function(e){if(!t(this,at))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Pt},Gt=function(e,i){t(this,W)[i]=e,t(this,I)[e]=i;},At=function(e){e!==t(this,O)&&(e===t(this,P)?f(this,P,t(this,I)[e]):h(this,a,Gt).call(this,t(this,W)[e],t(this,I)[e]),h(this,a,Gt).call(this,t(this,O),e),f(this,O,e));},ot=function(e,i){var r,o;let s=false;if(t(this,U)!==0){let n=t(this,E).get(e);if(n!==void 0)if(t(this,k)?.[n]&&(clearTimeout(t(this,k)?.[n]),t(this,k)[n]=void 0),s=true,t(this,U)===1)h(this,a,Wt).call(this,i);else {t(this,dt).call(this,n);let d=t(this,g)[n];if(h(this,a,w).call(this,d)?d.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,R))&&(t(this,tt)&&((r=t(this,$))==null||r.call(this,d,e,i)),t(this,R)&&t(this,D)?.push([d,e,i])),t(this,E).delete(e),t(this,x)[n]=void 0,t(this,g)[n]=void 0,n===t(this,O))f(this,O,t(this,W)[n]);else if(n===t(this,P))f(this,P,t(this,I)[n]);else {let u=t(this,W)[n];t(this,I)[u]=t(this,I)[n];let S=t(this,I)[n];t(this,W)[S]=t(this,W)[n];}Ct(this,U)._--,t(this,J).push(n);}}if(t(this,R)&&t(this,D)?.length){let n=t(this,D),d;for(;d=n?.shift();)(o=t(this,B))==null||o.call(this,...d);}return s},Wt=function(e){var i,s;for(let r of h(this,a,rt).call(this,{allowStale:true})){let o=t(this,g)[r];if(h(this,a,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=t(this,x)[r];t(this,tt)&&((i=t(this,$))==null||i.call(this,o,n,e)),t(this,R)&&t(this,D)?.push([o,n,e]);}}if(t(this,E).clear(),t(this,g).fill(void 0),t(this,x).fill(void 0),t(this,H)&&t(this,Z)){t(this,H).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,P,0),f(this,O,0),t(this,J).length=0,f(this,Y,0),f(this,U,0),t(this,R)&&t(this,D)){let r=t(this,D),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}};var Lt=Ht;var zt=class{constructor(e){v(this,"cache");v(this,"map",new Map);this.cache=new Lt({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 Ut="1.5.3";var kt="repeat";function qt(l){return {type:"pause",duration:l}}var Kt="__game_layer__";var oe={};var $t={};ce($t,{createExportableElement:()=>ae});var xt;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(xt||(xt={}));function ae(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw xt.error("Error creating exportable element",l,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function he(){console.info(`
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var N=require('@drincs/pixi-vn/canvas'),Yt=require('@drincs/pixi-vn/characters'),et=require('@drincs/pixi-vn/history'),j=require('@drincs/pixi-vn/narration'),ht=require('@drincs/pixi-vn/sound'),V=require('@drincs/pixi-vn/storage'),unifier=require('@drincs/pixi-vn/unifier');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var N__namespace=/*#__PURE__*/_interopNamespace(N);var Yt__namespace=/*#__PURE__*/_interopNamespace(Yt);var et__namespace=/*#__PURE__*/_interopNamespace(et);var j__namespace=/*#__PURE__*/_interopNamespace(j);var ht__namespace=/*#__PURE__*/_interopNamespace(ht);var V__namespace=/*#__PURE__*/_interopNamespace(V);var Jt=Object.defineProperty;var Qt=l=>{throw TypeError(l)};var le=(l,e,i)=>e in l?Jt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var ce=(l,e)=>{for(var i in e)Jt(l,i,{get:e[i],enumerable:true});};var v=(l,e,i)=>le(l,typeof e!="symbol"?e+"":e,i),It=(l,e,i)=>e.has(l)||Qt("Cannot "+i);var t=(l,e,i)=>(It(l,e,"read from private field"),i?i.call(l):e.get(l)),y=(l,e,i)=>e.has(l)?Qt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),f=(l,e,i,s)=>(It(l,e,"write to private field"),e.set(l,i),i),h=(l,e,i)=>(It(l,e,"access private method"),i);var Ct=(l,e,i,s)=>({set _(r){f(l,e,r);},get _(){return t(l,e,s)}});var fe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ie=new Set,Rt=typeof process=="object"&&process?process:{},se=(l,e,i,s)=>{typeof Rt.emitWarning=="function"?Rt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Pt=globalThis.AbortController,Zt=globalThis.AbortSignal;if(typeof Pt>"u"){Zt=class{constructor(){v(this,"onabort");v(this,"_onabort",[]);v(this,"reason");v(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},Pt=class{constructor(){v(this,"signal",new Zt);e();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let l=Rt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,se("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 de=l=>!ie.has(l);var st=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),ne=l=>st(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?_t:null:null,_t=class extends Array{constructor(e){super(e),this.fill(0);}},yt,lt=class lt{constructor(e,i){v(this,"heap");v(this,"length");if(!t(lt,yt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}static create(e){let i=ne(e);if(!i)return [];f(lt,yt,true);let s=new lt(e,i);return f(lt,yt,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};yt=new WeakMap,y(lt,yt,false);var Nt=lt,te,ee,K,G,$,ct,B,St,vt,X,O,Y,U,x,g,I,W,P,D,J,C,Q,Z,H,k,tt,at,R,bt,a,Mt,ft,it,Tt,q,re,dt,wt,Et,nt,rt,Vt,Ft,jt,w,Gt,At,ot,Wt,Ht=class Ht{constructor(e){y(this,a);y(this,K);y(this,G);y(this,$);y(this,ct);y(this,B);y(this,St);y(this,vt);y(this,X);v(this,"ttl");v(this,"ttlResolution");v(this,"ttlAutopurge");v(this,"updateAgeOnGet");v(this,"updateAgeOnHas");v(this,"allowStale");v(this,"noDisposeOnSet");v(this,"noUpdateTTL");v(this,"maxEntrySize");v(this,"sizeCalculation");v(this,"noDeleteOnFetchRejection");v(this,"noDeleteOnStaleGet");v(this,"allowStaleOnFetchAbort");v(this,"allowStaleOnFetchRejection");v(this,"ignoreFetchAbort");y(this,O);y(this,Y);y(this,U);y(this,x);y(this,g);y(this,I);y(this,W);y(this,P);y(this,D);y(this,J);y(this,C);y(this,Q);y(this,Z);y(this,H);y(this,k);y(this,tt);y(this,at);y(this,R);y(this,bt);y(this,ft,()=>{});y(this,it,()=>{});y(this,Tt,()=>{});y(this,q,()=>false);y(this,dt,e=>{});y(this,wt,(e,i,s)=>{});y(this,Et,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});v(this,te,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:d,allowStale:u,dispose:S,onInsert:z,disposeAfter:b,noDisposeOnSet:m,noUpdateTTL:A,maxSize:F=0,maxEntrySize:c=0,sizeCalculation:_,fetchMethod:p,memoMethod:T,noDeleteOnFetchRejection:M,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:ut,ignoreFetchAbort:pt,perf:Dt}=e;if(Dt!==void 0&&typeof Dt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,Dt??fe),i!==0&&!st(i))throw new TypeError("max option must be a nonnegative integer");let mt=i?ne(i):Array;if(!mt)throw new Error("invalid max value: "+i);if(f(this,K,i),f(this,G,F),this.maxEntrySize=c||t(this,G),this.sizeCalculation=_,this.sizeCalculation){if(!t(this,G)&&!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(T!==void 0&&typeof T!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,vt,T),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,St,p),f(this,at,!!p),f(this,U,new Map),f(this,x,new Array(i).fill(void 0)),f(this,g,new Array(i).fill(void 0)),f(this,I,new mt(i)),f(this,W,new mt(i)),f(this,P,0),f(this,D,0),f(this,J,Nt.create(i)),f(this,O,0),f(this,Y,0),typeof S=="function"&&f(this,$,S),typeof z=="function"&&f(this,ct,z),typeof b=="function"?(f(this,B,b),f(this,C,[])):(f(this,B,void 0),f(this,C,void 0)),f(this,tt,!!t(this,$)),f(this,bt,!!t(this,ct)),f(this,R,!!t(this,B)),this.noDisposeOnSet=!!m,this.noUpdateTTL=!!A,this.noDeleteOnFetchRejection=!!M,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!ut,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(t(this,G)!==0&&!st(t(this,G)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,a,re).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!d,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,a,Mt).call(this);}if(t(this,K)===0&&this.ttl===0&&t(this,G)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,K)&&!t(this,G)){let gt="LRU_CACHE_UNBOUNDED";de(gt)&&(ie.add(gt),se("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",gt,Ht));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,H),autopurgeTimers:t(e,k),sizes:t(e,Q),keyMap:t(e,U),keyList:t(e,x),valList:t(e,g),next:t(e,I),prev:t(e,W),get head(){return t(e,P)},get tail(){return t(e,D)},free:t(e,J),isBackgroundFetch:i=>{var s;return h(s=e,a,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return h(n=e,a,jt).call(n,i,s,r,o)},moveToTail:i=>{var s;return h(s=e,a,At).call(s,i)},indexes:i=>{var s;return h(s=e,a,nt).call(s,i)},rindexes:i=>{var s;return h(s=e,a,rt).call(s,i)},isStale:i=>{var s;return t(s=e,q).call(s,i)}}}get max(){return t(this,K)}get maxSize(){return t(this,G)}get calculatedSize(){return t(this,Y)}get size(){return t(this,O)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,vt)}get dispose(){return t(this,$)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,U).has(e)?1/0:0}*entries(){for(let e of h(this,a,nt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*rentries(){for(let e of h(this,a,rt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*keys(){for(let e of h(this,a,nt).call(this)){let i=t(this,x)[e];i!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of h(this,a,rt).call(this)){let i=t(this,x)[e];i!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of h(this,a,nt).call(this))t(this,g)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of h(this,a,rt).call(this))t(this,g)[e]!==void 0&&!h(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(ee=Symbol.iterator,te=Symbol.toStringTag,ee)](){return this.entries()}find(e,i={}){for(let s of h(this,a,nt).call(this)){let r=t(this,g)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,x)[s],this))return this.get(t(this,x)[s],i)}}forEach(e,i=this){for(let s of h(this,a,nt).call(this)){let r=t(this,g)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,x)[s],this);}}rforEach(e,i=this){for(let s of h(this,a,rt).call(this)){let r=t(this,g)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,x)[s],this);}}purgeStale(){let e=false;for(let i of h(this,a,rt).call(this,{allowStale:true}))t(this,q).call(this,i)&&(h(this,a,ot).call(this,t(this,x)[i],"expire"),e=true);return e}info(e){let i=t(this,U).get(e);if(i===void 0)return;let s=t(this,g)[i],r=h(this,a,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,H)&&t(this,Z)){let n=t(this,H)[i],d=t(this,Z)[i];if(n&&d){let u=n-(t(this,X).now()-d);o.ttl=u,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of h(this,a,nt).call(this,{allowStale:true})){let s=t(this,x)[i],r=t(this,g)[i],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(t(this,H)&&t(this,Z)){n.ttl=t(this,H)[i];let d=t(this,X).now()-t(this,Z)[i];n.start=Math.floor(Date.now()-d);}t(this,Q)&&(n.size=t(this,Q)[i]),e.unshift([s,n]);}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 m,A,F,c;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:d=this.sizeCalculation,status:u}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,z=t(this,Et).call(this,e,i,s.size||0,d);if(this.maxEntrySize&&z>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,a,ot).call(this,e,"set"),this;let b=t(this,O)===0?void 0:t(this,U).get(e);if(b===void 0)b=t(this,O)===0?t(this,D):t(this,J).length!==0?t(this,J).pop():t(this,O)===t(this,K)?h(this,a,Ft).call(this,false):t(this,O),t(this,x)[b]=e,t(this,g)[b]=i,t(this,U).set(e,b),t(this,I)[t(this,D)]=b,t(this,W)[b]=t(this,D),f(this,D,b),Ct(this,O)._++,t(this,wt).call(this,b,z,u),u&&(u.set="add"),S=false,t(this,bt)&&((m=t(this,ct))==null||m.call(this,i,e,"add"));else {h(this,a,At).call(this,b);let _=t(this,g)[b];if(i!==_){if(t(this,at)&&h(this,a,w).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=_;p!==void 0&&!n&&(t(this,tt)&&((A=t(this,$))==null||A.call(this,p,e,"set")),t(this,R)&&t(this,C)?.push([p,e,"set"]));}else n||(t(this,tt)&&((F=t(this,$))==null||F.call(this,_,e,"set")),t(this,R)&&t(this,C)?.push([_,e,"set"]));if(t(this,dt).call(this,b),t(this,wt).call(this,b,z,u),t(this,g)[b]=i,u){u.set="replace";let p=_&&h(this,a,w).call(this,_)?_.__staleWhileFetching:_;p!==void 0&&(u.oldValue=p);}}else u&&(u.set="update");t(this,bt)&&this.onInsert?.(i,e,i===_?"update":"replace");}if(r!==0&&!t(this,H)&&h(this,a,Mt).call(this),t(this,H)&&(S||t(this,Tt).call(this,b,r,o),u&&t(this,it).call(this,u,b)),!n&&t(this,R)&&t(this,C)){let _=t(this,C),p;for(;p=_?.shift();)(c=t(this,B))==null||c.call(this,...p);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,g)[t(this,P)];if(h(this,a,Ft).call(this,!0),h(this,a,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,R)&&t(this,C)){let i=t(this,C),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,U).get(e);if(o!==void 0){let n=t(this,g)[o];if(h(this,a,w).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(t(this,q).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ft).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,U).get(e);if(r===void 0||!s&&t(this,q).call(this,r))return;let o=t(this,g)[r];return h(this,a,w).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:d=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:m=this.allowStaleOnFetchRejection,ignoreFetchAbort:A=this.ignoreFetchAbort,allowStaleOnFetchAbort:F=this.allowStaleOnFetchAbort,context:c,forceRefresh:_=false,status:p,signal:T}=i;if(!t(this,at))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:p});let M={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:d,size:u,sizeCalculation:S,noUpdateTTL:z,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:m,allowStaleOnFetchAbort:F,ignoreFetchAbort:A,status:p,signal:T},L=t(this,U).get(e);if(L===void 0){p&&(p.fetch="miss");let E=h(this,a,jt).call(this,e,L,M,c);return E.__returned=E}else {let E=t(this,g)[L];if(h(this,a,w).call(this,E)){let gt=s&&E.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",gt&&(p.returnedStale=true)),gt?E.__staleWhileFetching:E.__returned=E}let ut=t(this,q).call(this,L);if(!_&&!ut)return p&&(p.fetch="hit"),h(this,a,At).call(this,L),r&&t(this,ft).call(this,L),p&&t(this,it).call(this,p,L),E;let pt=h(this,a,jt).call(this,e,L,M,c),mt=pt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=ut?"stale":"refresh",mt&&ut&&(p.returnedStale=true)),mt?pt.__staleWhileFetching:pt.__returned=pt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,vt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,d=this.get(e,n);if(!o&&d!==void 0)return d;let u=s(e,d,{options:n,context:r});return this.set(e,u,n),u}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,d=t(this,U).get(e);if(d!==void 0){let u=t(this,g)[d],S=h(this,a,w).call(this,u);return n&&t(this,it).call(this,n,d),t(this,q).call(this,d)?(n&&(n.get="stale"),S?(n&&s&&u.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?u.__staleWhileFetching:void 0):(o||h(this,a,ot).call(this,e,"expire"),n&&s&&(n.returnedStale=true),s?u:void 0)):(n&&(n.get="hit"),S?u.__staleWhileFetching:(h(this,a,At).call(this,d),r&&t(this,ft).call(this,d),u))}else n&&(n.get="miss");}delete(e){return h(this,a,ot).call(this,e,"delete")}clear(){return h(this,a,Wt).call(this,"delete")}};K=new WeakMap,G=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,St=new WeakMap,vt=new WeakMap,X=new WeakMap,O=new WeakMap,Y=new WeakMap,U=new WeakMap,x=new WeakMap,g=new WeakMap,I=new WeakMap,W=new WeakMap,P=new WeakMap,D=new WeakMap,J=new WeakMap,C=new WeakMap,Q=new WeakMap,Z=new WeakMap,H=new WeakMap,k=new WeakMap,tt=new WeakMap,at=new WeakMap,R=new WeakMap,bt=new WeakMap,a=new WeakSet,Mt=function(){let e=new _t(t(this,K)),i=new _t(t(this,K));f(this,H,e),f(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,K)):void 0;f(this,k,s),f(this,Tt,(n,d,u=t(this,X).now())=>{if(i[n]=d!==0?u:0,e[n]=d,s?.[n]&&(clearTimeout(s[n]),s[n]=void 0),d!==0&&s){let S=setTimeout(()=>{t(this,q).call(this,n)&&h(this,a,ot).call(this,t(this,x)[n],"expire");},d+1);S.unref&&S.unref(),s[n]=S;}}),f(this,ft,n=>{i[n]=e[n]!==0?t(this,X).now():0;}),f(this,it,(n,d)=>{if(e[d]){let u=e[d],S=i[d];if(!u||!S)return;n.ttl=u,n.start=S,n.now=r||o();let z=n.now-S;n.remainingTTL=u-z;}});let r=0,o=()=>{let n=t(this,X).now();if(this.ttlResolution>0){r=n;let d=setTimeout(()=>r=0,this.ttlResolution);d.unref&&d.unref();}return n};this.getRemainingTTL=n=>{let d=t(this,U).get(n);if(d===void 0)return 0;let u=e[d],S=i[d];if(!u||!S)return 1/0;let z=(r||o())-S;return u-z},f(this,q,n=>{let d=i[n],u=e[n];return !!u&&!!d&&(r||o())-d>u});},ft=new WeakMap,it=new WeakMap,Tt=new WeakMap,q=new WeakMap,re=function(){let e=new _t(t(this,K));f(this,Y,0),f(this,Q,e),f(this,dt,i=>{f(this,Y,t(this,Y)-e[i]),e[i]=0;}),f(this,Et,(i,s,r,o)=>{if(h(this,a,w).call(this,s))return 0;if(!st(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!st(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,wt,(i,s,r)=>{if(e[i]=s,t(this,G)){let o=t(this,G)-e[i];for(;t(this,Y)>o;)h(this,a,Ft).call(this,true);}f(this,Y,t(this,Y)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,Y));});},dt=new WeakMap,wt=new WeakMap,Et=new WeakMap,nt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,D);!(!h(this,a,Vt).call(this,i)||((e||!t(this,q).call(this,i))&&(yield i),i===t(this,P)));)i=t(this,W)[i];},rt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,P);!(!h(this,a,Vt).call(this,i)||((e||!t(this,q).call(this,i))&&(yield i),i===t(this,D)));)i=t(this,I)[i];},Vt=function(e){return e!==void 0&&t(this,U).get(t(this,x)[e])===e},Ft=function(e){var o;let i=t(this,P),s=t(this,x)[i],r=t(this,g)[i];return t(this,at)&&h(this,a,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,R))&&(t(this,tt)&&((o=t(this,$))==null||o.call(this,r,s,"evict")),t(this,R)&&t(this,C)?.push([r,s,"evict"])),t(this,dt).call(this,i),t(this,k)?.[i]&&(clearTimeout(t(this,k)[i]),t(this,k)[i]=void 0),e&&(t(this,x)[i]=void 0,t(this,g)[i]=void 0,t(this,J).push(i)),t(this,O)===1?(f(this,P,f(this,D,0)),t(this,J).length=0):f(this,P,t(this,I)[i]),t(this,U).delete(s),Ct(this,O)._--,i},jt=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(h(this,a,w).call(this,o))return o;let n=new Pt,{signal:d}=s;d?.addEventListener("abort",()=>n.abort(d.reason),{signal:n.signal});let u={signal:n.signal,options:s,context:r},S=(c,_=false)=>{let{aborted:p}=n.signal,T=s.ignoreFetchAbort&&c!==void 0,M=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&c!==void 0);if(s.status&&(p&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,T&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!T&&!_)return b(n.signal.reason,M);let L=A,E=t(this,g)[i];return (E===A||T&&_&&E===void 0)&&(c===void 0?L.__staleWhileFetching!==void 0?t(this,g)[i]=L.__staleWhileFetching:h(this,a,ot).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,c,u.options))),c},z=c=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=c),b(c,false)),b=(c,_)=>{let{aborted:p}=n.signal,T=p&&s.allowStaleOnFetchAbort,M=T||s.allowStaleOnFetchRejection,L=M||s.noDeleteOnFetchRejection,E=A;if(t(this,g)[i]===A&&(!L||!_&&E.__staleWhileFetching===void 0?h(this,a,ot).call(this,e,"fetch"):T||(t(this,g)[i]=E.__staleWhileFetching)),M)return s.status&&E.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),E.__staleWhileFetching;if(E.__returned===E)throw c},m=(c,_)=>{var T;let p=(T=t(this,St))==null?void 0:T.call(this,e,o,u);p&&p instanceof Promise&&p.then(M=>c(M===void 0?void 0:M),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(c(void 0),s.allowStaleOnFetchAbort&&(c=M=>S(M,true)));});};s.status&&(s.status.fetchDispatched=true);let A=new Promise(m).then(S,z),F=Object.assign(A,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,F,{...u.options,status:void 0}),i=t(this,U).get(e)):t(this,g)[i]=F,F},w=function(e){if(!t(this,at))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Pt},Gt=function(e,i){t(this,W)[i]=e,t(this,I)[e]=i;},At=function(e){e!==t(this,D)&&(e===t(this,P)?f(this,P,t(this,I)[e]):h(this,a,Gt).call(this,t(this,W)[e],t(this,I)[e]),h(this,a,Gt).call(this,t(this,D),e),f(this,D,e));},ot=function(e,i){var r,o;let s=false;if(t(this,O)!==0){let n=t(this,U).get(e);if(n!==void 0)if(t(this,k)?.[n]&&(clearTimeout(t(this,k)?.[n]),t(this,k)[n]=void 0),s=true,t(this,O)===1)h(this,a,Wt).call(this,i);else {t(this,dt).call(this,n);let d=t(this,g)[n];if(h(this,a,w).call(this,d)?d.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,R))&&(t(this,tt)&&((r=t(this,$))==null||r.call(this,d,e,i)),t(this,R)&&t(this,C)?.push([d,e,i])),t(this,U).delete(e),t(this,x)[n]=void 0,t(this,g)[n]=void 0,n===t(this,D))f(this,D,t(this,W)[n]);else if(n===t(this,P))f(this,P,t(this,I)[n]);else {let u=t(this,W)[n];t(this,I)[u]=t(this,I)[n];let S=t(this,I)[n];t(this,W)[S]=t(this,W)[n];}Ct(this,O)._--,t(this,J).push(n);}}if(t(this,R)&&t(this,C)?.length){let n=t(this,C),d;for(;d=n?.shift();)(o=t(this,B))==null||o.call(this,...d);}return s},Wt=function(e){var i,s;for(let r of h(this,a,rt).call(this,{allowStale:true})){let o=t(this,g)[r];if(h(this,a,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=t(this,x)[r];t(this,tt)&&((i=t(this,$))==null||i.call(this,o,n,e)),t(this,R)&&t(this,C)?.push([o,n,e]);}}if(t(this,U).clear(),t(this,g).fill(void 0),t(this,x).fill(void 0),t(this,H)&&t(this,Z)){t(this,H).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,P,0),f(this,D,0),t(this,J).length=0,f(this,Y,0),f(this,O,0),t(this,R)&&t(this,C)){let r=t(this,C),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}};var zt=Ht;var Lt=class{constructor(e){v(this,"cache");v(this,"map",new Map);this.cache=new zt({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 Ut="1.5.5";var kt="repeat";function qt(l){return {type:"pause",duration:l}}var Kt="__game_layer__";var oe={};var $t={};ce($t,{createExportableElement:()=>ae});var xt;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(xt||(xt={}));function ae(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw xt.error("Error creating exportable element",l,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function he(){console.info(`
|
|
2
2
|
_______ _ _ _ ____ ____ ____ _____
|
|
3
3
|
|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|
|
|
4
4
|
| |__) |__ _ __ __ \\_| \\ \\ / / | \\ | |
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
_| |_ | | > ' < | | \\ ' / _| |_\\ |_
|
|
7
7
|
|_____| [___][__]\`\\_][___] \\_/ |_____|\\____|
|
|
8
8
|
|
|
9
|
-
`);}function Bt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}exports.Game=void 0;(b=>{async function l(m,A,
|
|
9
|
+
`);}function Bt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}exports.Game=void 0;(b=>{async function l(m,A,F){if(unifier.GameUnifier.init({navigate:A?.navigate,getCurrentGameStepState:()=>{let c={};try{c=N__namespace.canvas.export();}catch{}return {path:Bt(),storage:V__namespace.storage.export(),canvas:c,sound:ht__namespace.sound.export(),labelIndex:j__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:j__namespace.narration.openedLabels}},restoreGameStepState:async(c,_)=>{et__namespace.HistoryManagerStatic._originalStepData=c,j__namespace.NarrationManagerStatic.openedLabels=c.openedLabels,V__namespace.storage.restore(c.storage);try{await N__namespace.canvas.restore(c.canvas);}catch{}ht__namespace.sound.restore(c.sound),_(c.path);},getStepCounter:()=>j__namespace.narration.stepCounter,setStepCounter:c=>{j__namespace.NarrationManagerStatic._stepCounter=c;},getOpenedLabels:()=>j__namespace.narration.openedLabels.length,addHistoryItem:(c,_)=>et__namespace.stepHistory.add(c,_),getCharacter:c=>Yt__namespace.RegisteredCharacters.get(c),processNavigationRequests:(c,_)=>{let p=c,T=Promise.resolve();return c>0?(p--,T=j__namespace.narration.continue(_)):c<0&&(p=0,T=et__namespace.stepHistory.back(_,{steps:c*-1})),{newValue:p,result:T}},onPreContinue:async()=>{try{let c=N__namespace.CanvasManagerStatic._tickersToCompleteOnStepEnd.tikersIds.map(({id:p})=>N__namespace.canvas.forceCompletionOfTicker(p)),_=N__namespace.CanvasManagerStatic._tickersToCompleteOnStepEnd.stepAlias.map(({alias:p,id:T})=>N__namespace.canvas.forceCompletionOfTicker(T,p));await Promise.all([...c,..._]),N__namespace.CanvasManagerStatic._tickersToCompleteOnStepEnd={tikersIds:[],stepAlias:[]};}catch{}},getVariable:c=>V__namespace.storage.get(c),setVariable:(c,_)=>V__namespace.storage.set(c,_),removeVariable:c=>V__namespace.storage.remove(c),getFlag:c=>V__namespace.storage.getFlag(c),setFlag:(c,_)=>V__namespace.storage.setFlag(c,_),onLabelClosing:c=>V__namespace.StorageManagerStatic.clearOldTempVariables(c)}),he(),!m||!A){xt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await N__namespace.canvas.init(m,A,F)}b.init=l;function e(){V__namespace.storage.clear();try{N__namespace.canvas.clear();}catch{}ht__namespace.sound.clear(),j__namespace.narration.clear(),et__namespace.stepHistory.clear();}b.clear=e;function i(){let m={};try{m=N__namespace.canvas.export();}catch{}return {pixivn_version:Ut,stepData:j__namespace.narration.export(),storageData:V__namespace.storage.export(),canvasData:m,soundData:ht__namespace.sound.export(),historyData:et__namespace.stepHistory.export(),path:Bt()}}b.exportGameState=i;async function s(m,A){m.stepData.hasOwnProperty("stepsHistory")&&m.stepData.stepsHistory&&(m.historyData.stepsHistory=m.stepData.stepsHistory),m.stepData.hasOwnProperty("originalStepData")&&m.stepData.originalStepData&&(m.historyData.originalStepData=m.stepData.originalStepData),et__namespace.stepHistory.restore(m.historyData);let F=et__namespace.stepHistory.lastKey;if(typeof F=="number"){let c=et__namespace.stepHistory.stepsInfoMap.get(F)||null;await j__namespace.narration.restore(m.stepData,c);}V__namespace.storage.restore(m.storageData);try{await N__namespace.canvas.restore(m.canvasData);}catch{}ht__namespace.sound.restore(m.soundData),await A(m.path);}b.restoreGameState=s;function r(m){return JSON.parse(m)}b.jsonToGameState=r;function o(m){unifier.GameUnifier.onEnd=m;}b.onEnd=o;function n(m){unifier.GameUnifier.onError=async(A,F,c)=>m(A,F,c);}b.onError=n;function d(m){j__namespace.NarrationManagerStatic.onStepStart=m;}b.onStepStart=d;function u(m){j__namespace.NarrationManagerStatic.onLoadingLabel=m;}b.onLoadingLabel=u;function S(m){j__namespace.NarrationManagerStatic.onStepEnd=m;}b.onStepEnd=S;function z(m){unifier.GameUnifier.navigate=m;}b.onNavigate=z;})(exports.Game||(exports.Game={}));var Me={characterUtils:Yt__namespace,canvasUtils:N__namespace,narrationUtils:j__namespace,soundUtils:ht__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Kt,Pause:qt,Repeat:kt,PIXIVN_VERSION:Ut,...$t,...oe,canvas:N__namespace.canvas,narration:j__namespace.narration,sound:ht__namespace.sound,storage:V__namespace.storage,history:et__namespace.stepHistory,Game:exports.Game,GameUnifier:unifier.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Kt;exports.CachedMap=Lt;exports.PIXIVN_VERSION=Ut;exports.Pause=qt;exports.Repeat=kt;exports.createExportableElement=ae;exports.default=Me;Object.keys(N).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return N[k]}})});Object.keys(Yt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return Yt[k]}})});Object.keys(et).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return et[k]}})});Object.keys(j).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return j[k]}})});Object.keys(ht).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return ht[k]}})});Object.keys(V).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return V[k]}})});Object.keys(unifier).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return unifier[k]}})});
|
package/dist/index.d.cts
CHANGED
|
@@ -355,7 +355,7 @@ interface ContainerMemory<C extends ContainerChild = ContainerChild> extends Con
|
|
|
355
355
|
elements: CanvasBaseItemMemory[];
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
var version = "1.5.
|
|
358
|
+
var version = "1.5.5";
|
|
359
359
|
|
|
360
360
|
declare const Repeat: RepeatType;
|
|
361
361
|
/**
|
|
@@ -555,6 +555,7 @@ declare namespace Game {
|
|
|
555
555
|
* width: 1920,
|
|
556
556
|
* height: 1080,
|
|
557
557
|
* backgroundColor: "#303030"
|
|
558
|
+
* resizeMode: "contain"
|
|
558
559
|
* })
|
|
559
560
|
* ```
|
|
560
561
|
*/
|
|
@@ -564,8 +565,6 @@ declare namespace Game {
|
|
|
564
565
|
* @default "pixi-vn-canvas"
|
|
565
566
|
*/
|
|
566
567
|
id?: string;
|
|
567
|
-
width: number;
|
|
568
|
-
height: number;
|
|
569
568
|
/**
|
|
570
569
|
* The route navigate function.
|
|
571
570
|
* You can set this function after the initialization using {@link GameUnifier.navigate}
|
|
@@ -573,6 +572,11 @@ declare namespace Game {
|
|
|
573
572
|
* @returns
|
|
574
573
|
*/
|
|
575
574
|
navigate?: (path: string) => void | Promise<void>;
|
|
575
|
+
/**
|
|
576
|
+
* The resize mode of the canvas.
|
|
577
|
+
* @default "contain"
|
|
578
|
+
*/
|
|
579
|
+
resizeMode?: "contain" | "none";
|
|
576
580
|
}, devtoolsOptions?: Devtools): Promise<void>;
|
|
577
581
|
/**
|
|
578
582
|
* Initialize only the GameUnifier, and not the PixiJS Application and the interface div.
|
package/dist/index.d.ts
CHANGED
|
@@ -355,7 +355,7 @@ interface ContainerMemory<C extends ContainerChild = ContainerChild> extends Con
|
|
|
355
355
|
elements: CanvasBaseItemMemory[];
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
var version = "1.5.
|
|
358
|
+
var version = "1.5.5";
|
|
359
359
|
|
|
360
360
|
declare const Repeat: RepeatType;
|
|
361
361
|
/**
|
|
@@ -555,6 +555,7 @@ declare namespace Game {
|
|
|
555
555
|
* width: 1920,
|
|
556
556
|
* height: 1080,
|
|
557
557
|
* backgroundColor: "#303030"
|
|
558
|
+
* resizeMode: "contain"
|
|
558
559
|
* })
|
|
559
560
|
* ```
|
|
560
561
|
*/
|
|
@@ -564,8 +565,6 @@ declare namespace Game {
|
|
|
564
565
|
* @default "pixi-vn-canvas"
|
|
565
566
|
*/
|
|
566
567
|
id?: string;
|
|
567
|
-
width: number;
|
|
568
|
-
height: number;
|
|
569
568
|
/**
|
|
570
569
|
* The route navigate function.
|
|
571
570
|
* You can set this function after the initialization using {@link GameUnifier.navigate}
|
|
@@ -573,6 +572,11 @@ declare namespace Game {
|
|
|
573
572
|
* @returns
|
|
574
573
|
*/
|
|
575
574
|
navigate?: (path: string) => void | Promise<void>;
|
|
575
|
+
/**
|
|
576
|
+
* The resize mode of the canvas.
|
|
577
|
+
* @default "contain"
|
|
578
|
+
*/
|
|
579
|
+
resizeMode?: "contain" | "none";
|
|
576
580
|
}, devtoolsOptions?: Devtools): Promise<void>;
|
|
577
581
|
/**
|
|
578
582
|
* Initialize only the GameUnifier, and not the PixiJS Application and the interface div.
|