@drincs/pixi-vn 1.9.1 → 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,7 +24,7 @@ For a quick start, various project templates are available, built with React. Le
24
24
 
25
25
  - **[Visual Novel](https://pixi-vn.com/start/make-visual-novel)**: a classic dialogue-driven experience, with characters, backgrounds, and choices.
26
26
  - **[Point & Click Adventure](https://pixi-vn.com/nqtr/make-point-and-click)**: an adventure game where the player explores scenes and interacts with objects and characters.
27
- - **Interactive Fiction**: feels like reading a book. Unlike a visual novel, images are shown as vignettes, just as illustrations would appear on a page.
27
+ - **[Interactive Fiction](https://pixi-vn.com/start/make-interactive-fiction)**: feels like reading a book. Unlike a visual novel, images are shown as vignettes, just as illustrations would appear on a page.
28
28
 
29
29
  To create a new project from a template, run:
30
30
 
@@ -36,16 +36,16 @@ npm create pixi-vn@latest
36
36
 
37
37
  Pixi’VN is independent of any distribution technology, but strong emphasis is being placed on [Roves](https://roves.pixi-vn.com/), built by the same team behind Pixi’VN.
38
38
 
39
- | Platform | [Roves](https://roves.pixi-vn.com/) | [Tauri](https://v2.tauri.app/) | [Electron](https://www.electronjs.org/) |
40
- | -------- | -- | -- | -- |
41
- | Windows | ✅ | ✅ | ✅ |
42
- | macOS | ✅ | ✅ | ✅ |
43
- | Linux | ✅ | ✅ | ✅ |
44
- | Android | ✅ | ✅ | ❌ |
45
- | iOS | 🚧 | ✅ | ❌ |
46
- | Nintendo | 🚧 | ❌ | ❌ |
47
- | PlayStation | 🚧 | ❌ | ❌ |
48
- | Xbox | 🚧 | ❌ | ❌ |
39
+ | Platform | [Roves](https://roves.pixi-vn.com/) | [Tauri](https://v2.tauri.app/) | [Electron](https://www.electronjs.org/) |
40
+ | ----------- | ----------------------------------- | ------------------------------ | --------------------------------------- |
41
+ | Windows | ✅ | ✅ | ✅ |
42
+ | macOS | ✅ | ✅ | ✅ |
43
+ | Linux | ✅ | ✅ | ✅ |
44
+ | Android | ✅ | ✅ | ❌ |
45
+ | iOS | 🚧 | ✅ | ❌ |
46
+ | Nintendo | 🚧 | ❌ | ❌ |
47
+ | PlayStation | 🚧 | ❌ | ❌ |
48
+ | Xbox | 🚧 | ❌ | ❌ |
49
49
 
50
50
  ## Wiki
51
51
 
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var V=require('@drincs/pixi-vn/canvas'),Zt=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),H=require('@drincs/pixi-vn/history'),_=require('@drincs/pixi-vn/narration'),mt=require('@drincs/pixi-vn/sound'),z=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');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 V__namespace=/*#__PURE__*/_interopNamespace(V);var Zt__namespace=/*#__PURE__*/_interopNamespace(Zt);var H__namespace=/*#__PURE__*/_interopNamespace(H);var ___namespace=/*#__PURE__*/_interopNamespace(_);var mt__namespace=/*#__PURE__*/_interopNamespace(mt);var z__namespace=/*#__PURE__*/_interopNamespace(z);var se=Object.defineProperty;var re=l=>{throw TypeError(l)};var be=(l,e,i)=>e in l?se(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var we=(l,e)=>{for(var i in e)se(l,i,{get:e[i],enumerable:true});};var G=(l,e,i)=>be(l,typeof e!="symbol"?e+"":e,i),Ht=(l,e,i)=>e.has(l)||re("Cannot "+i);var t=(l,e,i)=>(Ht(l,e,"read from private field"),i?i.call(l):e.get(l)),v=(l,e,i)=>e.has(l)?re("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),u=(l,e,i,s)=>(Ht(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(Ht(l,e,"access private method"),i);var It=(l,e,i,s)=>({set _(r){u(l,e,r);},get _(){return t(l,e,s)}});var xe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,le=new Set,kt=typeof process=="object"&&process?process:{},he=(l,e,i,s)=>{typeof kt.emitWarning=="function"?kt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},jt=globalThis.AbortController,ne=globalThis.AbortSignal;if(typeof jt>"u"){ne=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},jt=class{constructor(){e();}signal=new ne;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let l=kt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,he("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 Ee=l=>!le.has(l);var dt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),ce=l=>dt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(l){super(l),this.fill(0);}},at,xt,Ue=(at=class{heap;length;static create(e){let i=ce(e);if(!i)return [];u(at,xt,true);let s=new at(e,i);return u(at,xt,false),s}constructor(e,i){if(!t(at,xt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},xt=new WeakMap,v(at,xt,false),at),oe,ae,X,W,Z,vt,tt,Et,Ut,et,R,it,L,T,f,F,Y,j,I,st,D,rt,nt,q,B,ot,gt,M,Tt,a,Kt,yt,ht,Rt,$,pe,St,At,Pt,pt,ut,Wt,Nt,Gt,U,Yt,Lt,ft,qt,Ot,de=(Ot=class{constructor(e){v(this,a);v(this,X);v(this,W);v(this,Z);v(this,vt);v(this,tt);v(this,Et);v(this,Ut);v(this,et);G(this,"ttl");G(this,"ttlResolution");G(this,"ttlAutopurge");G(this,"updateAgeOnGet");G(this,"updateAgeOnHas");G(this,"allowStale");G(this,"noDisposeOnSet");G(this,"noUpdateTTL");G(this,"maxEntrySize");G(this,"sizeCalculation");G(this,"noDeleteOnFetchRejection");G(this,"noDeleteOnStaleGet");G(this,"allowStaleOnFetchAbort");G(this,"allowStaleOnFetchRejection");G(this,"ignoreFetchAbort");v(this,R);v(this,it);v(this,L);v(this,T);v(this,f);v(this,F);v(this,Y);v(this,j);v(this,I);v(this,st);v(this,D);v(this,rt);v(this,nt);v(this,q);v(this,B);v(this,ot);v(this,gt);v(this,M);v(this,Tt);v(this,yt,()=>{});v(this,ht,()=>{});v(this,Rt,()=>{});v(this,$,()=>false);v(this,St,e=>{});v(this,At,(e,i,s)=>{});v(this,Pt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});G(this,oe,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:h,allowStale:p,dispose:y,onInsert:P,disposeAfter:S,noDisposeOnSet:lt,noUpdateTTL:k,maxSize:J=0,maxEntrySize:A=0,sizeCalculation:x,fetchMethod:g,memoMethod:O,noDeleteOnFetchRejection:d,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:m,ignoreFetchAbort:E,perf:N}=e;if(N!==void 0&&typeof N?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,et,N??xe),i!==0&&!dt(i))throw new TypeError("max option must be a nonnegative integer");let K=i?ce(i):Array;if(!K)throw new Error("invalid max value: "+i);if(u(this,X,i),u(this,W,J),this.maxEntrySize=A||t(this,W),this.sizeCalculation=x,this.sizeCalculation){if(!t(this,W)&&!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(O!==void 0&&typeof O!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,Ut,O),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,Et,g),u(this,gt,!!g),u(this,L,new Map),u(this,T,new Array(i).fill(void 0)),u(this,f,new Array(i).fill(void 0)),u(this,F,new K(i)),u(this,Y,new K(i)),u(this,j,0),u(this,I,0),u(this,st,Ue.create(i)),u(this,R,0),u(this,it,0),typeof y=="function"&&u(this,Z,y),typeof P=="function"&&u(this,vt,P),typeof S=="function"?(u(this,tt,S),u(this,D,[])):(u(this,tt,void 0),u(this,D,void 0)),u(this,ot,!!t(this,Z)),u(this,Tt,!!t(this,vt)),u(this,M,!!t(this,tt)),this.noDisposeOnSet=!!lt,this.noUpdateTTL=!!k,this.noDeleteOnFetchRejection=!!d,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!m,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(t(this,W)!==0&&!dt(t(this,W)))throw new TypeError("maxSize must be a positive integer if specified");if(!dt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,pe).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!h,this.ttlResolution=dt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!dt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,Kt).call(this);}if(t(this,X)===0&&this.ttl===0&&t(this,W)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,X)&&!t(this,W)){let _t="LRU_CACHE_UNBOUNDED";Ee(_t)&&(le.add(_t),he("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_t,Ot));}}get perf(){return t(this,et)}static unsafeExposeInternals(e){return {starts:t(e,nt),ttls:t(e,q),autopurgeTimers:t(e,B),sizes:t(e,rt),keyMap:t(e,L),keyList:t(e,T),valList:t(e,f),next:t(e,F),prev:t(e,Y),get head(){return t(e,j)},get tail(){return t(e,I)},free:t(e,st),isBackgroundFetch:i=>{var s;return c(s=e,a,U).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=e,a,Gt).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=e,a,Lt).call(s,i)},indexes:i=>{var s;return c(s=e,a,pt).call(s,i)},rindexes:i=>{var s;return c(s=e,a,ut).call(s,i)},isStale:i=>{var s;return t(s=e,$).call(s,i)}}}get max(){return t(this,X)}get maxSize(){return t(this,W)}get calculatedSize(){return t(this,it)}get size(){return t(this,R)}get fetchMethod(){return t(this,Et)}get memoMethod(){return t(this,Ut)}get dispose(){return t(this,Z)}get onInsert(){return t(this,vt)}get disposeAfter(){return t(this,tt)}getRemainingTTL(e){return t(this,L).has(e)?1/0:0}*entries(){for(let e of c(this,a,pt).call(this))t(this,f)[e]!==void 0&&t(this,T)[e]!==void 0&&!c(this,a,U).call(this,t(this,f)[e])&&(yield [t(this,T)[e],t(this,f)[e]]);}*rentries(){for(let e of c(this,a,ut).call(this))t(this,f)[e]!==void 0&&t(this,T)[e]!==void 0&&!c(this,a,U).call(this,t(this,f)[e])&&(yield [t(this,T)[e],t(this,f)[e]]);}*keys(){for(let e of c(this,a,pt).call(this)){let i=t(this,T)[e];i!==void 0&&!c(this,a,U).call(this,t(this,f)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,ut).call(this)){let i=t(this,T)[e];i!==void 0&&!c(this,a,U).call(this,t(this,f)[e])&&(yield i);}}*values(){for(let e of c(this,a,pt).call(this))t(this,f)[e]!==void 0&&!c(this,a,U).call(this,t(this,f)[e])&&(yield t(this,f)[e]);}*rvalues(){for(let e of c(this,a,ut).call(this))t(this,f)[e]!==void 0&&!c(this,a,U).call(this,t(this,f)[e])&&(yield t(this,f)[e]);}[(ae=Symbol.iterator,oe=Symbol.toStringTag,ae)](){return this.entries()}find(e,i={}){for(let s of c(this,a,pt).call(this)){let r=t(this,f)[s],o=c(this,a,U).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,T)[s],this))return this.get(t(this,T)[s],i)}}forEach(e,i=this){for(let s of c(this,a,pt).call(this)){let r=t(this,f)[s],o=c(this,a,U).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,T)[s],this);}}rforEach(e,i=this){for(let s of c(this,a,ut).call(this)){let r=t(this,f)[s],o=c(this,a,U).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,T)[s],this);}}purgeStale(){let e=false;for(let i of c(this,a,ut).call(this,{allowStale:true}))t(this,$).call(this,i)&&(c(this,a,ft).call(this,t(this,T)[i],"expire"),e=true);return e}info(e){let i=t(this,L).get(e);if(i===void 0)return;let s=t(this,f)[i],r=c(this,a,U).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,q)&&t(this,nt)){let n=t(this,q)[i],h=t(this,nt)[i];if(n&&h){let p=n-(t(this,et).now()-h);o.ttl=p,o.start=Date.now();}}return t(this,rt)&&(o.size=t(this,rt)[i]),o}dump(){let e=[];for(let i of c(this,a,pt).call(this,{allowStale:true})){let s=t(this,T)[i],r=t(this,f)[i],o=c(this,a,U).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(t(this,q)&&t(this,nt)){n.ttl=t(this,q)[i];let h=t(this,et).now()-t(this,nt)[i];n.start=Math.floor(Date.now()-h);}t(this,rt)&&(n.size=t(this,rt)[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,et).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var lt,k,J,A;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:p}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,P=t(this,Pt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&P>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),c(this,a,ft).call(this,e,"set"),this;let S=t(this,R)===0?void 0:t(this,L).get(e);if(S===void 0)S=t(this,R)===0?t(this,I):t(this,st).length!==0?t(this,st).pop():t(this,R)===t(this,X)?c(this,a,Nt).call(this,false):t(this,R),t(this,T)[S]=e,t(this,f)[S]=i,t(this,L).set(e,S),t(this,F)[t(this,I)]=S,t(this,Y)[S]=t(this,I),u(this,I,S),It(this,R)._++,t(this,At).call(this,S,P,p),p&&(p.set="add"),y=false,t(this,Tt)&&((lt=t(this,vt))==null||lt.call(this,i,e,"add"));else {c(this,a,Lt).call(this,S);let x=t(this,f)[S];if(i!==x){if(t(this,gt)&&c(this,a,U).call(this,x)){x.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=x;g!==void 0&&!n&&(t(this,ot)&&((k=t(this,Z))==null||k.call(this,g,e,"set")),t(this,M)&&t(this,D)?.push([g,e,"set"]));}else n||(t(this,ot)&&((J=t(this,Z))==null||J.call(this,x,e,"set")),t(this,M)&&t(this,D)?.push([x,e,"set"]));if(t(this,St).call(this,S),t(this,At).call(this,S,P,p),t(this,f)[S]=i,p){p.set="replace";let g=x&&c(this,a,U).call(this,x)?x.__staleWhileFetching:x;g!==void 0&&(p.oldValue=g);}}else p&&(p.set="update");t(this,Tt)&&this.onInsert?.(i,e,i===x?"update":"replace");}if(r!==0&&!t(this,q)&&c(this,a,Kt).call(this),t(this,q)&&(y||t(this,Rt).call(this,S,r,o),p&&t(this,ht).call(this,p,S)),!n&&t(this,M)&&t(this,D)){let x=t(this,D),g;for(;g=x?.shift();)(A=t(this,tt))==null||A.call(this,...g);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,f)[t(this,j)];if(c(this,a,Nt).call(this,!0),c(this,a,U).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,M)&&t(this,D)){let i=t(this,D),s;for(;s=i?.shift();)(e=t(this,tt))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,L).get(e);if(o!==void 0){let n=t(this,f)[o];if(c(this,a,U).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(t(this,$).call(this,o))r&&(r.has="stale",t(this,ht).call(this,r,o));else return s&&t(this,yt).call(this,o),r&&(r.has="hit",t(this,ht).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,L).get(e);if(r===void 0||!s&&t(this,$).call(this,r))return;let o=t(this,f)[r];return c(this,a,U).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:h=this.noDisposeOnSet,size:p=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:P=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:lt=this.allowStaleOnFetchRejection,ignoreFetchAbort:k=this.ignoreFetchAbort,allowStaleOnFetchAbort:J=this.allowStaleOnFetchAbort,context:A,forceRefresh:x=false,status:g,signal:O}=i;if(!t(this,gt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:g});let d={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:h,size:p,sizeCalculation:y,noUpdateTTL:P,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:lt,allowStaleOnFetchAbort:J,ignoreFetchAbort:k,status:g,signal:O},b=t(this,L).get(e);if(b===void 0){g&&(g.fetch="miss");let w=c(this,a,Gt).call(this,e,b,d,A);return w.__returned=w}else {let w=t(this,f)[b];if(c(this,a,U).call(this,w)){let K=s&&w.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",K&&(g.returnedStale=true)),K?w.__staleWhileFetching:w.__returned=w}let m=t(this,$).call(this,b);if(!x&&!m)return g&&(g.fetch="hit"),c(this,a,Lt).call(this,b),r&&t(this,yt).call(this,b),g&&t(this,ht).call(this,g,b),w;let E=c(this,a,Gt).call(this,e,b,d,A),N=E.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=m?"stale":"refresh",N&&m&&(g.returnedStale=true)),N?E.__staleWhileFetching:E.__returned=E}}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,Ut);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,h=this.get(e,n);if(!o&&h!==void 0)return h;let p=s(e,h,{options:n,context:r});return this.set(e,p,n),p}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,h=t(this,L).get(e);if(h!==void 0){let p=t(this,f)[h],y=c(this,a,U).call(this,p);return n&&t(this,ht).call(this,n,h),t(this,$).call(this,h)?(n&&(n.get="stale"),y?(n&&s&&p.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?p.__staleWhileFetching:void 0):(o||c(this,a,ft).call(this,e,"expire"),n&&s&&(n.returnedStale=true),s?p:void 0)):(n&&(n.get="hit"),y?p.__staleWhileFetching:(c(this,a,Lt).call(this,h),r&&t(this,yt).call(this,h),p))}else n&&(n.get="miss");}delete(e){return c(this,a,ft).call(this,e,"delete")}clear(){return c(this,a,qt).call(this,"delete")}},X=new WeakMap,W=new WeakMap,Z=new WeakMap,vt=new WeakMap,tt=new WeakMap,Et=new WeakMap,Ut=new WeakMap,et=new WeakMap,R=new WeakMap,it=new WeakMap,L=new WeakMap,T=new WeakMap,f=new WeakMap,F=new WeakMap,Y=new WeakMap,j=new WeakMap,I=new WeakMap,st=new WeakMap,D=new WeakMap,rt=new WeakMap,nt=new WeakMap,q=new WeakMap,B=new WeakMap,ot=new WeakMap,gt=new WeakMap,M=new WeakMap,Tt=new WeakMap,a=new WeakSet,Kt=function(){let e=new Dt(t(this,X)),i=new Dt(t(this,X));u(this,q,e),u(this,nt,i);let s=this.ttlAutopurge?new Array(t(this,X)):void 0;u(this,B,s),u(this,Rt,(h,p,y=t(this,et).now())=>{i[h]=p!==0?y:0,e[h]=p,r(h,p);}),u(this,yt,h=>{i[h]=e[h]!==0?t(this,et).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,p)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),p&&p!==0&&s){let y=setTimeout(()=>{t(this,$).call(this,h)&&c(this,a,ft).call(this,t(this,T)[h],"expire");},p+1);y.unref&&y.unref(),s[h]=y;}}:()=>{};u(this,ht,(h,p)=>{if(e[p]){let y=e[p],P=i[p];if(!y||!P)return;h.ttl=y,h.start=P,h.now=o||n();let S=h.now-P;h.remainingTTL=y-S;}});let o=0,n=()=>{let h=t(this,et).now();if(this.ttlResolution>0){o=h;let p=setTimeout(()=>o=0,this.ttlResolution);p.unref&&p.unref();}return h};this.getRemainingTTL=h=>{let p=t(this,L).get(h);if(p===void 0)return 0;let y=e[p],P=i[p];if(!y||!P)return 1/0;let S=(o||n())-P;return y-S},u(this,$,h=>{let p=i[h],y=e[h];return !!y&&!!p&&(o||n())-p>y});},yt=new WeakMap,ht=new WeakMap,Rt=new WeakMap,$=new WeakMap,pe=function(){let e=new Dt(t(this,X));u(this,it,0),u(this,rt,e),u(this,St,i=>{u(this,it,t(this,it)-e[i]),e[i]=0;}),u(this,Pt,(i,s,r,o)=>{if(c(this,a,U).call(this,s))return 0;if(!dt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!dt(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,At,(i,s,r)=>{if(e[i]=s,t(this,W)){let o=t(this,W)-e[i];for(;t(this,it)>o;)c(this,a,Nt).call(this,true);}u(this,it,t(this,it)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,it));});},St=new WeakMap,At=new WeakMap,Pt=new WeakMap,pt=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,I);!(!c(this,a,Wt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,j)));)i=t(this,Y)[i];},ut=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,j);!(!c(this,a,Wt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,I)));)i=t(this,F)[i];},Wt=function(e){return e!==void 0&&t(this,L).get(t(this,T)[e])===e},Nt=function(e){var o;let i=t(this,j),s=t(this,T)[i],r=t(this,f)[i];return t(this,gt)&&c(this,a,U).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,ot)||t(this,M))&&(t(this,ot)&&((o=t(this,Z))==null||o.call(this,r,s,"evict")),t(this,M)&&t(this,D)?.push([r,s,"evict"])),t(this,St).call(this,i),t(this,B)?.[i]&&(clearTimeout(t(this,B)[i]),t(this,B)[i]=void 0),e&&(t(this,T)[i]=void 0,t(this,f)[i]=void 0,t(this,st).push(i)),t(this,R)===1?(u(this,j,u(this,I,0)),t(this,st).length=0):u(this,j,t(this,F)[i]),t(this,L).delete(s),It(this,R)._--,i},Gt=function(e,i,s,r){let o=i===void 0?void 0:t(this,f)[i];if(c(this,a,U).call(this,o))return o;let n=new jt,{signal:h}=s;h?.addEventListener("abort",()=>n.abort(h.reason),{signal:n.signal});let p={signal:n.signal,options:s,context:r},y=(A,x=false)=>{let{aborted:g}=n.signal,O=s.ignoreFetchAbort&&A!==void 0,d=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(g&&!x?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,O&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!O&&!x)return S(n.signal.reason,d);let b=k,w=t(this,f)[i];return (w===k||O&&x&&w===void 0)&&(A===void 0?b.__staleWhileFetching!==void 0?t(this,f)[i]=b.__staleWhileFetching:c(this,a,ft).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,A,p.options))),A},P=A=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=A),S(A,false)),S=(A,x)=>{let{aborted:g}=n.signal,O=g&&s.allowStaleOnFetchAbort,d=O||s.allowStaleOnFetchRejection,b=d||s.noDeleteOnFetchRejection,w=k;if(t(this,f)[i]===k&&(!b||!x&&w.__staleWhileFetching===void 0?c(this,a,ft).call(this,e,"fetch"):O||(t(this,f)[i]=w.__staleWhileFetching)),d)return s.status&&w.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw A},lt=(A,x)=>{var O;let g=(O=t(this,Et))==null?void 0:O.call(this,e,o,p);g&&g instanceof Promise&&g.then(d=>A(d===void 0?void 0:d),x),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(A(void 0),s.allowStaleOnFetchAbort&&(A=d=>y(d,true)));});};s.status&&(s.status.fetchDispatched=true);let k=new Promise(lt).then(y,P),J=Object.assign(k,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,J,{...p.options,status:void 0}),i=t(this,L).get(e)):t(this,f)[i]=J,J},U=function(e){if(!t(this,gt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof jt},Yt=function(e,i){t(this,Y)[i]=e,t(this,F)[e]=i;},Lt=function(e){e!==t(this,I)&&(e===t(this,j)?u(this,j,t(this,F)[e]):c(this,a,Yt).call(this,t(this,Y)[e],t(this,F)[e]),c(this,a,Yt).call(this,t(this,I),e),u(this,I,e));},ft=function(e,i){var r,o;let s=false;if(t(this,R)!==0){let n=t(this,L).get(e);if(n!==void 0)if(t(this,B)?.[n]&&(clearTimeout(t(this,B)?.[n]),t(this,B)[n]=void 0),s=true,t(this,R)===1)c(this,a,qt).call(this,i);else {t(this,St).call(this,n);let h=t(this,f)[n];if(c(this,a,U).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,ot)||t(this,M))&&(t(this,ot)&&((r=t(this,Z))==null||r.call(this,h,e,i)),t(this,M)&&t(this,D)?.push([h,e,i])),t(this,L).delete(e),t(this,T)[n]=void 0,t(this,f)[n]=void 0,n===t(this,I))u(this,I,t(this,Y)[n]);else if(n===t(this,j))u(this,j,t(this,F)[n]);else {let p=t(this,Y)[n];t(this,F)[p]=t(this,F)[n];let y=t(this,F)[n];t(this,Y)[y]=t(this,Y)[n];}It(this,R)._--,t(this,st).push(n);}}if(t(this,M)&&t(this,D)?.length){let n=t(this,D),h;for(;h=n?.shift();)(o=t(this,tt))==null||o.call(this,...h);}return s},qt=function(e){var i,s;for(let r of c(this,a,ut).call(this,{allowStale:true})){let o=t(this,f)[r];if(c(this,a,U).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=t(this,T)[r];t(this,ot)&&((i=t(this,Z))==null||i.call(this,o,n,e)),t(this,M)&&t(this,D)?.push([o,n,e]);}}if(t(this,L).clear(),t(this,f).fill(void 0),t(this,T).fill(void 0),t(this,q)&&t(this,nt)){t(this,q).fill(0),t(this,nt).fill(0);for(let r of t(this,B)??[])r!==void 0&&clearTimeout(r);t(this,B)?.fill(void 0);}if(t(this,rt)&&t(this,rt).fill(0),u(this,j,0),u(this,I,0),t(this,st).length=0,u(this,it,0),u(this,R,0),t(this,M)&&t(this,D)){let r=t(this,D),o;for(;o=r?.shift();)(s=t(this,tt))==null||s.call(this,...o);}},Ot);var Ft=class{cache;map=new Map;constructor(e){this.cache=new de({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ct="1.9.1";var Bt={version:Ct};var $t="__game_layer__";var Te={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var fe={};var Xt={};we(Xt,{createExportableElement:()=>ge});var bt;(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)))(bt||={});function ge(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw bt.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Oe=typeof window<"u"&&typeof document<"u",me=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Bt.version}`],_e=31,Le="background:#2f90da;color:#fff;font-weight:bold;",Re="background:#c832bb;color:#fff;font-weight:bold;",Pe="background:transparent;font-weight:bold;",Jt=` v${Bt.version}`;function ve(){if(!Oe)return;let l=[],e=[];for(let i=0;i<me.length;i++){let s=me[i],r=s.endsWith(Jt),o=r?s.slice(0,-Jt.length):s,n=o.slice(0,_e),h=o.slice(_e),p=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(p),e.push(Le,n,Re,h),r&&e.push(Pe,Jt);}console.info(l.join(`
2
- `),...e);}function Qt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}ve();exports.Game=void 0;(O=>{async function l(d,b,w){if(core.GameUnifier.init({navigate:b?.navigate,getCurrentGameStepState:()=>{let m=V__namespace.canvas.isInitialized?V__namespace.canvas.export():{};return {path:Qt(),storage:z__namespace.storage.export(),canvas:m,sound:mt__namespace.sound.export(),labelIndex:___namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:___namespace.narration.openedLabels}},restoreGameStepState:async(m,E)=>{H__namespace.HistoryManagerStatic._originalStepData=m,___namespace.NarrationManagerStatic.openedLabels=m.openedLabels,z__namespace.storage.restore(m.storage);try{V__namespace.canvas.isInitialized&&await V__namespace.canvas.restore(m.canvas),await mt__namespace.sound.restore(m.sound);}catch(N){bt.error("Error restoring game step state:",N);}await E(m.path);},getStepCounter:()=>___namespace.narration.stepCounter,setStepCounter:m=>{___namespace.NarrationManagerStatic._stepCounter=m;},getOpenedLabels:()=>___namespace.narration.openedLabels.length,addHistoryItem:(m,E)=>H__namespace.stepHistory.add(m,E),getCharacter:m=>Zt__namespace.RegisteredCharacters.get(m),processNavigationRequests:(m,E)=>{let N=m,K=Promise.resolve();return m>0?(N--,K=___namespace.narration.continue(E)):m<0&&(N=0,K=H__namespace.stepHistory.back(E,{steps:m*-1})),{newValue:N,result:K}},animate:(m,E,N,K)=>motion.motion.animate(m,E,N,K),getVariable:(m,E)=>z__namespace.StorageRegistry.getVariable(m,E),setVariable:(m,E,N)=>z__namespace.StorageRegistry.setVariable(m,E,N),removeVariable:(m,E)=>z__namespace.StorageRegistry.removeVariable(m,E),getFlag:m=>z__namespace.storage.flags.get(m),setFlag:(m,E)=>z__namespace.storage.flags.set(m,E),onLabelClosing:m=>z__namespace.StorageRegistry.clearOldTempVariables(m)}),!d||!b){bt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await V__namespace.canvas.init(d,b,w)}O.init=l;function e(){z__namespace.storage.clear(),V__namespace.canvas.isInitialized&&V__namespace.canvas.clear(),mt__namespace.sound.clear(),___namespace.narration.clear(),H__namespace.stepHistory.clear();}O.clear=e;function i(){let d=V__namespace.canvas.isInitialized?V__namespace.canvas.export():{};return {pixivn_version:Ct,stepData:___namespace.narration.export(),storageData:z__namespace.storage.export(),canvasData:d,soundData:mt__namespace.sound.export(),historyData:H__namespace.stepHistory.export(),path:Qt()}}O.exportGameState=i;async function s(d){H__namespace.stepHistory.restore(d.historyData);let b=H__namespace.stepHistory.lastKey;if(typeof b=="number"){let w=H__namespace.stepHistory.stepsInfoMap.get(b)||null;await ___namespace.narration.restore(d.stepData,w);}z__namespace.storage.restore(d.storageData);try{V__namespace.canvas.isInitialized&&await V__namespace.canvas.restore(d.canvasData),await mt__namespace.sound.restore(d.soundData);}catch{}await core.GameUnifier.navigate(d.path);}O.restoreGameState=s;async function r(d,b){return O.clear(),await ___namespace.narration.call(d,b)}O.start=r;function o(d){return JSON.parse(d)}O.jsonToGameState=o;function n(d){core.GameUnifier.onEnd=d;}O.onEnd=n;function h(d){return core.GameUnifier.addOnError(d)}O.addOnError=h;function p(d){return core.GameUnifier.removeOnError(d)}O.removeOnError=p;function y(d){___namespace.NarrationManagerStatic.onStepStart=d;}O.onStepStart=y;function P(d){___namespace.NarrationManagerStatic.onLoadingLabel=d;}O.onLoadingLabel=P;function S(d){___namespace.NarrationManagerStatic.onStepEnd=d;}O.onStepEnd=S;function lt(d){___namespace.NarrationManagerStatic.onLabelStarting=d;}O.onLabelStarting=lt;function k(d){___namespace.NarrationManagerStatic.onLabelClosing=d;}O.onLabelClosing=k;function J(d){core.GameUnifier.navigate=d;}O.onNavigate=J;function A(d){return core.GameUnifier.addOnPreContinue(d)}O.addOnPreContinue=A;function x(d){return core.GameUnifier.removeOnPreContinue(d)}O.removeOnPreContinue=x;(K=>{let d,b={};function w(_t){b=_t;}K.setProps=w;function m(_t){d&&E();let te=_t?.windowKey??"pixiVN",Mt=[],wt=C=>({...b,...C}),zt={Game:O,narration:___namespace.narration,storage:z__namespace.storage,stepHistory:H__namespace.stepHistory,get props(){return b},start:(C,Q)=>O.start(C,wt(Q)),continue:(C,Q)=>___namespace.narration.continue(wt(C),Q),call:(C,Q)=>___namespace.narration.call(C,wt(Q)),jump:(C,Q)=>___namespace.narration.jump(C,wt(Q)),selectChoice:(C,Q)=>{let ie=___namespace.narration.choices.list?.find(Vt=>Vt.choiceIndex===C);if(!ie){let Vt=___namespace.narration.choices.list?.map(Se=>Se.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${C}. Available: ${Vt}`)}return ___namespace.narration.choices.select(ie,wt(Q))},setInput:C=>{___namespace.narration.input.value=C;},goBack:(C,Q)=>H__namespace.stepHistory.back(wt(C),Q),closeCurrentLabel:()=>___namespace.narration.labels.closeCurrent(),closeAllLabels:()=>___namespace.narration.labels.closeAll(),getState:()=>({dialogue:___namespace.narration.dialogue,dialogueGlue:___namespace.narration.dialogGlue,choices:___namespace.narration.choices.list,input:{isRequired:___namespace.narration.input.isRequired,type:___namespace.narration.input.type,value:___namespace.narration.input.value},canContinue:___namespace.narration.canContinue,canGoBack:H__namespace.stepHistory.canGoBack,labelsOpened:___namespace.narration.labels.opened,currentLabelId:___namespace.narration.labels.current?.id,stepCounter:___namespace.narration.stepCounter}),get errors(){return Mt.slice()},clearErrors:()=>{Mt.length=0;}},ee=C=>{Mt.push({error:C,timestamp:Date.now()});};return O.addOnError(ee),typeof window<"u"?window[te]=zt:bt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),d={api:zt,windowKey:te,errorHandler:ee},zt}K.enable=m;function E(){d&&(O.removeOnError(d.errorHandler),typeof window<"u"&&window[d.windowKey]===d.api&&delete window[d.windowKey],d=void 0);}K.disable=E;function N(){return d!==void 0}K.isEnabled=N;})(O.testing||={});})(exports.Game||={});var ai={characterUtils:Zt__namespace,canvasUtils:V__namespace,narrationUtils:___namespace,soundUtils:mt__namespace,CANVAS_APP_GAME_LAYER_ALIAS:$t,PIXIVN_VERSION:Ct,...Xt,...fe,canvas:V__namespace.canvas,narration:___namespace.narration,sound:mt__namespace.sound,storage:z__namespace.storage,history:H__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=$t;exports.CachedMap=Ft;exports.PIXIVN_VERSION=Ct;exports.SYSTEM_RESERVED_STORAGE_KEYS=Te;exports.createExportableElement=ge;exports.default=ai;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(Zt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return Zt[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(H).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return H[k]}})});Object.keys(_).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return _[k]}})});Object.keys(mt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return mt[k]}})});Object.keys(z).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return z[k]}})});
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var k=require('@drincs/pixi-vn/canvas'),$t=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),ot=require('@drincs/pixi-vn/history'),L=require('@drincs/pixi-vn/narration'),gt=require('@drincs/pixi-vn/sound'),K=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');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 k__namespace=/*#__PURE__*/_interopNamespace(k);var $t__namespace=/*#__PURE__*/_interopNamespace($t);var ot__namespace=/*#__PURE__*/_interopNamespace(ot);var L__namespace=/*#__PURE__*/_interopNamespace(L);var gt__namespace=/*#__PURE__*/_interopNamespace(gt);var K__namespace=/*#__PURE__*/_interopNamespace(K);var Xt=Object.defineProperty;var Jt=l=>{throw TypeError(l)};var me=(l,e,i)=>e in l?Xt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var ge=(l,e)=>{for(var i in e)Xt(l,i,{get:e[i],enumerable:true});};var N=(l,e,i)=>me(l,typeof e!="symbol"?e+"":e,i),Ft=(l,e,i)=>e.has(l)||Jt("Cannot "+i);var t=(l,e,i)=>(Ft(l,e,"read from private field"),i?i.call(l):e.get(l)),b=(l,e,i)=>e.has(l)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),p=(l,e,i,s)=>(Ft(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(Ft(l,e,"access private method"),i);var Rt=(l,e,i,s)=>({set _(r){p(l,e,r);},get _(){return t(l,e,s)}});var _e=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ee=new Set,Mt=typeof process=="object"&&process?process:{},ie=(l,e,i,s)=>{typeof Mt.emitWarning=="function"?Mt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Gt=globalThis.AbortController,Qt=globalThis.AbortSignal;if(typeof Gt>"u"){Qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new Qt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let l=Mt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,ie("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 ve=l=>!ee.has(l);var ct=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),se=l=>ct(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?Pt:null:null,Pt=class extends Array{constructor(l){super(l),this.fill(0);}},at,bt,ye=(at=class{heap;length;static create(e){let i=se(e);if(!i)return [];p(at,bt,true);let s=new at(e,i);return p(at,bt,false),s}constructor(e,i){if(!t(at,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},bt=new WeakMap,b(at,bt,false),at),Zt,te,J,W,Q,_t,Z,St,Tt,tt,I,et,R,x,g,z,Y,M,C,it,G,st,rt,q,B,nt,ft,V,wt,a,zt,vt,lt,At,$,ne,yt,xt,Ot,dt,pt,Vt,It,Ct,w,Ht,Ut,ut,kt,Et,re=(Et=class{constructor(e){b(this,a);b(this,J);b(this,W);b(this,Q);b(this,_t);b(this,Z);b(this,St);b(this,Tt);b(this,tt);N(this,"ttl");N(this,"ttlResolution");N(this,"ttlAutopurge");N(this,"updateAgeOnGet");N(this,"updateAgeOnHas");N(this,"allowStale");N(this,"noDisposeOnSet");N(this,"noUpdateTTL");N(this,"maxEntrySize");N(this,"sizeCalculation");N(this,"noDeleteOnFetchRejection");N(this,"noDeleteOnStaleGet");N(this,"allowStaleOnFetchAbort");N(this,"allowStaleOnFetchRejection");N(this,"ignoreFetchAbort");b(this,I);b(this,et);b(this,R);b(this,x);b(this,g);b(this,z);b(this,Y);b(this,M);b(this,C);b(this,it);b(this,G);b(this,st);b(this,rt);b(this,q);b(this,B);b(this,nt);b(this,ft);b(this,V);b(this,wt);b(this,vt,()=>{});b(this,lt,()=>{});b(this,At,()=>{});b(this,$,()=>false);b(this,yt,e=>{});b(this,xt,(e,i,s)=>{});b(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});N(this,Zt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:h,allowStale:d,dispose:y,onInsert:O,disposeAfter:S,noDisposeOnSet:j,noUpdateTTL:D,maxSize:H=0,maxEntrySize:f=0,sizeCalculation:_,fetchMethod:m,memoMethod:U,noDeleteOnFetchRejection:u,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:v,ignoreFetchAbort:A,perf:F}=e;if(F!==void 0&&typeof F?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,tt,F??_e),i!==0&&!ct(i))throw new TypeError("max option must be a nonnegative integer");let X=i?se(i):Array;if(!X)throw new Error("invalid max value: "+i);if(p(this,J,i),p(this,W,H),this.maxEntrySize=f||t(this,W),this.sizeCalculation=_,this.sizeCalculation){if(!t(this,W)&&!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(U!==void 0&&typeof U!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,Tt,U),m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,St,m),p(this,ft,!!m),p(this,R,new Map),p(this,x,new Array(i).fill(void 0)),p(this,g,new Array(i).fill(void 0)),p(this,z,new X(i)),p(this,Y,new X(i)),p(this,M,0),p(this,C,0),p(this,it,ye.create(i)),p(this,I,0),p(this,et,0),typeof y=="function"&&p(this,Q,y),typeof O=="function"&&p(this,_t,O),typeof S=="function"?(p(this,Z,S),p(this,G,[])):(p(this,Z,void 0),p(this,G,void 0)),p(this,nt,!!t(this,Q)),p(this,wt,!!t(this,_t)),p(this,V,!!t(this,Z)),this.noDisposeOnSet=!!j,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!u,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(t(this,W)!==0&&!ct(t(this,W)))throw new TypeError("maxSize must be a positive integer if specified");if(!ct(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,ne).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!h,this.ttlResolution=ct(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ct(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,zt).call(this);}if(t(this,J)===0&&this.ttl===0&&t(this,W)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,J)&&!t(this,W)){let jt="LRU_CACHE_UNBOUNDED";ve(jt)&&(ee.add(jt),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",jt,Et));}}get perf(){return t(this,tt)}static unsafeExposeInternals(e){return {starts:t(e,rt),ttls:t(e,q),autopurgeTimers:t(e,B),sizes:t(e,st),keyMap:t(e,R),keyList:t(e,x),valList:t(e,g),next:t(e,z),prev:t(e,Y),get head(){return t(e,M)},get tail(){return t(e,C)},free:t(e,it),isBackgroundFetch:i=>{var s;return c(s=e,a,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return c(n=e,a,Ct).call(n,i,s,r,o)},moveToTail:i=>{var s;return c(s=e,a,Ut).call(s,i)},indexes:i=>{var s;return c(s=e,a,dt).call(s,i)},rindexes:i=>{var s;return c(s=e,a,pt).call(s,i)},isStale:i=>{var s;return t(s=e,$).call(s,i)}}}get max(){return t(this,J)}get maxSize(){return t(this,W)}get calculatedSize(){return t(this,et)}get size(){return t(this,I)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,Tt)}get dispose(){return t(this,Q)}get onInsert(){return t(this,_t)}get disposeAfter(){return t(this,Z)}getRemainingTTL(e){return t(this,R).has(e)?1/0:0}*entries(){for(let e of c(this,a,dt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*rentries(){for(let e of c(this,a,pt).call(this))t(this,g)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield [t(this,x)[e],t(this,g)[e]]);}*keys(){for(let e of c(this,a,dt).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,pt).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of c(this,a,dt).call(this))t(this,g)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of c(this,a,pt).call(this))t(this,g)[e]!==void 0&&!c(this,a,w).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(te=Symbol.iterator,Zt=Symbol.toStringTag,te)](){return this.entries()}find(e,i={}){for(let s of c(this,a,dt).call(this)){let r=t(this,g)[s],o=c(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 c(this,a,dt).call(this)){let r=t(this,g)[s],o=c(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 c(this,a,pt).call(this)){let r=t(this,g)[s],o=c(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 c(this,a,pt).call(this,{allowStale:true}))t(this,$).call(this,i)&&(c(this,a,ut).call(this,t(this,x)[i],"expire"),e=true);return e}info(e){let i=t(this,R).get(e);if(i===void 0)return;let s=t(this,g)[i],r=c(this,a,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,q)&&t(this,rt)){let n=t(this,q)[i],h=t(this,rt)[i];if(n&&h){let d=n-(t(this,tt).now()-h);o.ttl=d,o.start=Date.now();}}return t(this,st)&&(o.size=t(this,st)[i]),o}dump(){let e=[];for(let i of c(this,a,dt).call(this,{allowStale:true})){let s=t(this,x)[i],r=t(this,g)[i],o=c(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(t(this,q)&&t(this,rt)){n.ttl=t(this,q)[i];let h=t(this,tt).now()-t(this,rt)[i];n.start=Math.floor(Date.now()-h);}t(this,st)&&(n.size=t(this,st)[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,tt).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var j,D,H,f;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:d}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,O=t(this,Ot).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&O>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),c(this,a,ut).call(this,e,"set"),this;let S=t(this,I)===0?void 0:t(this,R).get(e);if(S===void 0)S=t(this,I)===0?t(this,C):t(this,it).length!==0?t(this,it).pop():t(this,I)===t(this,J)?c(this,a,It).call(this,false):t(this,I),t(this,x)[S]=e,t(this,g)[S]=i,t(this,R).set(e,S),t(this,z)[t(this,C)]=S,t(this,Y)[S]=t(this,C),p(this,C,S),Rt(this,I)._++,t(this,xt).call(this,S,O,d),d&&(d.set="add"),y=false,t(this,wt)&&((j=t(this,_t))==null||j.call(this,i,e,"add"));else {c(this,a,Ut).call(this,S);let _=t(this,g)[S];if(i!==_){if(t(this,ft)&&c(this,a,w).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:m}=_;m!==void 0&&!n&&(t(this,nt)&&((D=t(this,Q))==null||D.call(this,m,e,"set")),t(this,V)&&t(this,G)?.push([m,e,"set"]));}else n||(t(this,nt)&&((H=t(this,Q))==null||H.call(this,_,e,"set")),t(this,V)&&t(this,G)?.push([_,e,"set"]));if(t(this,yt).call(this,S),t(this,xt).call(this,S,O,d),t(this,g)[S]=i,d){d.set="replace";let m=_&&c(this,a,w).call(this,_)?_.__staleWhileFetching:_;m!==void 0&&(d.oldValue=m);}}else d&&(d.set="update");t(this,wt)&&this.onInsert?.(i,e,i===_?"update":"replace");}if(r!==0&&!t(this,q)&&c(this,a,zt).call(this),t(this,q)&&(y||t(this,At).call(this,S,r,o),d&&t(this,lt).call(this,d,S)),!n&&t(this,V)&&t(this,G)){let _=t(this,G),m;for(;m=_?.shift();)(f=t(this,Z))==null||f.call(this,...m);}return this}pop(){var e;try{for(;t(this,I);){let i=t(this,g)[t(this,M)];if(c(this,a,It).call(this,!0),c(this,a,w).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,G)){let i=t(this,G),s;for(;s=i?.shift();)(e=t(this,Z))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,R).get(e);if(o!==void 0){let n=t(this,g)[o];if(c(this,a,w).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(t(this,$).call(this,o))r&&(r.has="stale",t(this,lt).call(this,r,o));else return s&&t(this,vt).call(this,o),r&&(r.has="hit",t(this,lt).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,R).get(e);if(r===void 0||!s&&t(this,$).call(this,r))return;let o=t(this,g)[r];return c(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:h=this.noDisposeOnSet,size:d=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:O=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:j=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:f,forceRefresh:_=false,status:m,signal:U}=i;if(!t(this,ft))return m&&(m.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:m});let u={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:h,size:d,sizeCalculation:y,noUpdateTTL:O,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:H,ignoreFetchAbort:D,status:m,signal:U},E=t(this,R).get(e);if(E===void 0){m&&(m.fetch="miss");let T=c(this,a,Ct).call(this,e,E,u,f);return T.__returned=T}else {let T=t(this,g)[E];if(c(this,a,w).call(this,T)){let X=s&&T.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",X&&(m.returnedStale=true)),X?T.__staleWhileFetching:T.__returned=T}let v=t(this,$).call(this,E);if(!_&&!v)return m&&(m.fetch="hit"),c(this,a,Ut).call(this,E),r&&t(this,vt).call(this,E),m&&t(this,lt).call(this,m,E),T;let A=c(this,a,Ct).call(this,e,E,u,f),F=A.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=v?"stale":"refresh",F&&v&&(m.returnedStale=true)),F?A.__staleWhileFetching:A.__returned=A}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,Tt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,h=this.get(e,n);if(!o&&h!==void 0)return h;let d=s(e,h,{options:n,context:r});return this.set(e,d,n),d}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,h=t(this,R).get(e);if(h!==void 0){let d=t(this,g)[h],y=c(this,a,w).call(this,d);return n&&t(this,lt).call(this,n,h),t(this,$).call(this,h)?(n&&(n.get="stale"),y?(n&&s&&d.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?d.__staleWhileFetching:void 0):(o||c(this,a,ut).call(this,e,"expire"),n&&s&&(n.returnedStale=true),s?d:void 0)):(n&&(n.get="hit"),y?d.__staleWhileFetching:(c(this,a,Ut).call(this,h),r&&t(this,vt).call(this,h),d))}else n&&(n.get="miss");}delete(e){return c(this,a,ut).call(this,e,"delete")}clear(){return c(this,a,kt).call(this,"delete")}},J=new WeakMap,W=new WeakMap,Q=new WeakMap,_t=new WeakMap,Z=new WeakMap,St=new WeakMap,Tt=new WeakMap,tt=new WeakMap,I=new WeakMap,et=new WeakMap,R=new WeakMap,x=new WeakMap,g=new WeakMap,z=new WeakMap,Y=new WeakMap,M=new WeakMap,C=new WeakMap,it=new WeakMap,G=new WeakMap,st=new WeakMap,rt=new WeakMap,q=new WeakMap,B=new WeakMap,nt=new WeakMap,ft=new WeakMap,V=new WeakMap,wt=new WeakMap,a=new WeakSet,zt=function(){let e=new Pt(t(this,J)),i=new Pt(t(this,J));p(this,q,e),p(this,rt,i);let s=this.ttlAutopurge?new Array(t(this,J)):void 0;p(this,B,s),p(this,At,(h,d,y=t(this,tt).now())=>{i[h]=d!==0?y:0,e[h]=d,r(h,d);}),p(this,vt,h=>{i[h]=e[h]!==0?t(this,tt).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,d)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),d&&d!==0&&s){let y=setTimeout(()=>{t(this,$).call(this,h)&&c(this,a,ut).call(this,t(this,x)[h],"expire");},d+1);y.unref&&y.unref(),s[h]=y;}}:()=>{};p(this,lt,(h,d)=>{if(e[d]){let y=e[d],O=i[d];if(!y||!O)return;h.ttl=y,h.start=O,h.now=o||n();let S=h.now-O;h.remainingTTL=y-S;}});let o=0,n=()=>{let h=t(this,tt).now();if(this.ttlResolution>0){o=h;let d=setTimeout(()=>o=0,this.ttlResolution);d.unref&&d.unref();}return h};this.getRemainingTTL=h=>{let d=t(this,R).get(h);if(d===void 0)return 0;let y=e[d],O=i[d];if(!y||!O)return 1/0;let S=(o||n())-O;return y-S},p(this,$,h=>{let d=i[h],y=e[h];return !!y&&!!d&&(o||n())-d>y});},vt=new WeakMap,lt=new WeakMap,At=new WeakMap,$=new WeakMap,ne=function(){let e=new Pt(t(this,J));p(this,et,0),p(this,st,e),p(this,yt,i=>{p(this,et,t(this,et)-e[i]),e[i]=0;}),p(this,Ot,(i,s,r,o)=>{if(c(this,a,w).call(this,s))return 0;if(!ct(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!ct(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}),p(this,xt,(i,s,r)=>{if(e[i]=s,t(this,W)){let o=t(this,W)-e[i];for(;t(this,et)>o;)c(this,a,It).call(this,true);}p(this,et,t(this,et)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,et));});},yt=new WeakMap,xt=new WeakMap,Ot=new WeakMap,dt=function*({allowStale:e=this.allowStale}={}){if(t(this,I))for(let i=t(this,C);!(!c(this,a,Vt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,M)));)i=t(this,Y)[i];},pt=function*({allowStale:e=this.allowStale}={}){if(t(this,I))for(let i=t(this,M);!(!c(this,a,Vt).call(this,i)||((e||!t(this,$).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,z)[i];},Vt=function(e){return e!==void 0&&t(this,R).get(t(this,x)[e])===e},It=function(e){var o;let i=t(this,M),s=t(this,x)[i],r=t(this,g)[i];return t(this,ft)&&c(this,a,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,nt)||t(this,V))&&(t(this,nt)&&((o=t(this,Q))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,G)?.push([r,s,"evict"])),t(this,yt).call(this,i),t(this,B)?.[i]&&(clearTimeout(t(this,B)[i]),t(this,B)[i]=void 0),e&&(t(this,x)[i]=void 0,t(this,g)[i]=void 0,t(this,it).push(i)),t(this,I)===1?(p(this,M,p(this,C,0)),t(this,it).length=0):p(this,M,t(this,z)[i]),t(this,R).delete(s),Rt(this,I)._--,i},Ct=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(c(this,a,w).call(this,o))return o;let n=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>n.abort(h.reason),{signal:n.signal});let d={signal:n.signal,options:s,context:r},y=(f,_=false)=>{let{aborted:m}=n.signal,U=s.ignoreFetchAbort&&f!==void 0,u=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&f!==void 0);if(s.status&&(m&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,U&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),m&&!U&&!_)return S(n.signal.reason,u);let E=D,T=t(this,g)[i];return (T===D||U&&_&&T===void 0)&&(f===void 0?E.__staleWhileFetching!==void 0?t(this,g)[i]=E.__staleWhileFetching:c(this,a,ut).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,f,d.options))),f},O=f=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=f),S(f,false)),S=(f,_)=>{let{aborted:m}=n.signal,U=m&&s.allowStaleOnFetchAbort,u=U||s.allowStaleOnFetchRejection,E=u||s.noDeleteOnFetchRejection,T=D;if(t(this,g)[i]===D&&(!E||!_&&T.__staleWhileFetching===void 0?c(this,a,ut).call(this,e,"fetch"):U||(t(this,g)[i]=T.__staleWhileFetching)),u)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw f},j=(f,_)=>{var U;let m=(U=t(this,St))==null?void 0:U.call(this,e,o,d);m&&m instanceof Promise&&m.then(u=>f(u===void 0?void 0:u),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(f(void 0),s.allowStaleOnFetchAbort&&(f=u=>y(u,true)));});};s.status&&(s.status.fetchDispatched=true);let D=new Promise(j).then(y,O),H=Object.assign(D,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,H,{...d.options,status:void 0}),i=t(this,R).get(e)):t(this,g)[i]=H,H},w=function(e){if(!t(this,ft))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Ht=function(e,i){t(this,Y)[i]=e,t(this,z)[e]=i;},Ut=function(e){e!==t(this,C)&&(e===t(this,M)?p(this,M,t(this,z)[e]):c(this,a,Ht).call(this,t(this,Y)[e],t(this,z)[e]),c(this,a,Ht).call(this,t(this,C),e),p(this,C,e));},ut=function(e,i){var r,o;let s=false;if(t(this,I)!==0){let n=t(this,R).get(e);if(n!==void 0)if(t(this,B)?.[n]&&(clearTimeout(t(this,B)?.[n]),t(this,B)[n]=void 0),s=true,t(this,I)===1)c(this,a,kt).call(this,i);else {t(this,yt).call(this,n);let h=t(this,g)[n];if(c(this,a,w).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,nt)||t(this,V))&&(t(this,nt)&&((r=t(this,Q))==null||r.call(this,h,e,i)),t(this,V)&&t(this,G)?.push([h,e,i])),t(this,R).delete(e),t(this,x)[n]=void 0,t(this,g)[n]=void 0,n===t(this,C))p(this,C,t(this,Y)[n]);else if(n===t(this,M))p(this,M,t(this,z)[n]);else {let d=t(this,Y)[n];t(this,z)[d]=t(this,z)[n];let y=t(this,z)[n];t(this,Y)[y]=t(this,Y)[n];}Rt(this,I)._--,t(this,it).push(n);}}if(t(this,V)&&t(this,G)?.length){let n=t(this,G),h;for(;h=n?.shift();)(o=t(this,Z))==null||o.call(this,...h);}return s},kt=function(e){var i,s;for(let r of c(this,a,pt).call(this,{allowStale:true})){let o=t(this,g)[r];if(c(this,a,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=t(this,x)[r];t(this,nt)&&((i=t(this,Q))==null||i.call(this,o,n,e)),t(this,V)&&t(this,G)?.push([o,n,e]);}}if(t(this,R).clear(),t(this,g).fill(void 0),t(this,x).fill(void 0),t(this,q)&&t(this,rt)){t(this,q).fill(0),t(this,rt).fill(0);for(let r of t(this,B)??[])r!==void 0&&clearTimeout(r);t(this,B)?.fill(void 0);}if(t(this,st)&&t(this,st).fill(0),p(this,M,0),p(this,C,0),t(this,it).length=0,p(this,et,0),p(this,I,0),t(this,V)&&t(this,G)){let r=t(this,G),o;for(;o=r?.shift();)(s=t(this,Z))==null||s.call(this,...o);}},Et);var Dt=class{cache;map=new Map;constructor(e){this.cache=new re({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Lt="1.9.2";var Kt={version:Lt};var Wt="__game_layer__";var be={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ae={};var Yt={};ge(Yt,{createExportableElement:()=>le});var mt;(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)))(mt||={});function le(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw mt.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}function ce(l){let e,i={},s={};function r(y){i=y;}function o(y){s=y;}function n(y){e&&h();let O=y?.windowKey??"pixiVN",S=[],j=f=>({...i,...f}),D={Game:l,narration:L__namespace.narration,storage:K__namespace.storage,stepHistory:ot__namespace.stepHistory,get props(){return i},start:(f,_)=>s.start?s.start(f,_):l.start(f,j(_)),continue:(f,_)=>s.continue?s.continue():L__namespace.narration.continue(j(f),_),call:(f,_)=>s.call?s.call(f,_):L__namespace.narration.call(f,j(_)),jump:(f,_)=>s.jump?s.jump(f,_):L__namespace.narration.jump(f,j(_)),selectChoice:(f,_)=>{let m=L__namespace.narration.choices.list?.find(U=>U.choiceIndex===f);if(!m){let U=L__namespace.narration.choices.list?.map(u=>u.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${f}. Available: ${U}`)}return s.selectChoice?s.selectChoice(m):L__namespace.narration.choices.select(m,j(_))},setInput:f=>{L__namespace.narration.input.value=f;},goBack:(f,_)=>s.back?s.back():ot__namespace.stepHistory.back(j(f),_),closeCurrentLabel:()=>L__namespace.narration.labels.closeCurrent(),closeAllLabels:()=>L__namespace.narration.labels.closeAll(),getState:()=>({dialogue:L__namespace.narration.dialogue,dialogueGlue:L__namespace.narration.dialogGlue,choices:L__namespace.narration.choices.list,input:{isRequired:L__namespace.narration.input.isRequired,type:L__namespace.narration.input.type,value:L__namespace.narration.input.value},canContinue:L__namespace.narration.canContinue,canGoBack:ot__namespace.stepHistory.canGoBack,labelsOpened:L__namespace.narration.labels.opened,currentLabelId:L__namespace.narration.labels.current?.id,stepCounter:L__namespace.narration.stepCounter}),get errors(){return S.slice()},clearErrors:()=>{S.length=0;}},H=f=>{S.push({error:f,timestamp:Date.now()});};return l.addOnError(H),typeof window<"u"?window[O]=D:mt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),e={api:D,windowKey:O,errorHandler:H},D}function h(){e&&(l.removeOnError(e.errorHandler),typeof window<"u"&&window[e.windowKey]===e.api&&delete window[e.windowKey],e=void 0);}function d(){return e!==void 0}return {setProps:r,setActions:o,enable:n,disable:h,isEnabled:d}}var Te=typeof window<"u"&&typeof document<"u",de=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Kt.version}`],pe=31,we="background:#2f90da;color:#fff;font-weight:bold;",xe="background:#c832bb;color:#fff;font-weight:bold;",Ee="background:transparent;font-weight:bold;",qt=` v${Kt.version}`;function ue(){if(!Te)return;let l=[],e=[];for(let i=0;i<de.length;i++){let s=de[i],r=s.endsWith(qt),o=r?s.slice(0,-qt.length):s,n=o.slice(0,pe),h=o.slice(pe),d=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(d),e.push(we,n,xe,h),r&&e.push(Ee,qt);}console.info(l.join(`
2
+ `),...e);}function Bt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}ue();exports.Game=void 0;(U=>{async function l(u,E,T){if(core.GameUnifier.init({navigate:E?.navigate,getCurrentGameStepState:()=>{let v=k__namespace.canvas.isInitialized?k__namespace.canvas.export():{};return {path:Bt(),storage:K__namespace.storage.export(),canvas:v,sound:gt__namespace.sound.export(),labelIndex:L__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:L__namespace.narration.openedLabels}},restoreGameStepState:async(v,A)=>{ot__namespace.HistoryManagerStatic._originalStepData=v,L__namespace.NarrationManagerStatic.openedLabels=v.openedLabels,K__namespace.storage.restore(v.storage);try{k__namespace.canvas.isInitialized&&await k__namespace.canvas.restore(v.canvas),await gt__namespace.sound.restore(v.sound);}catch(F){mt.error("Error restoring game step state:",F);}await A(v.path);},getStepCounter:()=>L__namespace.narration.stepCounter,setStepCounter:v=>{L__namespace.NarrationManagerStatic._stepCounter=v;},getOpenedLabels:()=>L__namespace.narration.openedLabels.length,addHistoryItem:(v,A)=>ot__namespace.stepHistory.add(v,A),getCharacter:v=>$t__namespace.RegisteredCharacters.get(v),processNavigationRequests:(v,A)=>{let F=v,X=Promise.resolve();return v>0?(F--,X=L__namespace.narration.continue(A)):v<0&&(F=0,X=ot__namespace.stepHistory.back(A,{steps:v*-1})),{newValue:F,result:X}},animate:(v,A,F,X)=>motion.motion.animate(v,A,F,X),getVariable:(v,A)=>K__namespace.StorageRegistry.getVariable(v,A),setVariable:(v,A,F)=>K__namespace.StorageRegistry.setVariable(v,A,F),removeVariable:(v,A)=>K__namespace.StorageRegistry.removeVariable(v,A),getFlag:v=>K__namespace.storage.flags.get(v),setFlag:(v,A)=>K__namespace.storage.flags.set(v,A),onLabelClosing:v=>K__namespace.StorageRegistry.clearOldTempVariables(v)}),!u||!E){mt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await k__namespace.canvas.init(u,E,T)}U.init=l;function e(){K__namespace.storage.clear(),k__namespace.canvas.isInitialized&&k__namespace.canvas.clear(),gt__namespace.sound.clear(),L__namespace.narration.clear(),ot__namespace.stepHistory.clear();}U.clear=e;function i(){let u=k__namespace.canvas.isInitialized?k__namespace.canvas.export():{};return {pixivn_version:Lt,stepData:L__namespace.narration.export(),storageData:K__namespace.storage.export(),canvasData:u,soundData:gt__namespace.sound.export(),historyData:ot__namespace.stepHistory.export(),path:Bt()}}U.exportGameState=i;async function s(u){ot__namespace.stepHistory.restore(u.historyData);let E=ot__namespace.stepHistory.lastKey;if(typeof E=="number"){let T=ot__namespace.stepHistory.stepsInfoMap.get(E)||null;await L__namespace.narration.restore(u.stepData,T);}K__namespace.storage.restore(u.storageData);try{k__namespace.canvas.isInitialized&&await k__namespace.canvas.restore(u.canvasData),await gt__namespace.sound.restore(u.soundData);}catch{}await core.GameUnifier.navigate(u.path);}U.restoreGameState=s;async function r(u,E){return U.clear(),await L__namespace.narration.call(u,E)}U.start=r;function o(u){return JSON.parse(u)}U.jsonToGameState=o;function n(u){core.GameUnifier.onEnd=u;}U.onEnd=n;function h(u){return core.GameUnifier.addOnError(u)}U.addOnError=h;function d(u){return core.GameUnifier.removeOnError(u)}U.removeOnError=d;function y(u){L__namespace.NarrationManagerStatic.onStepStart=u;}U.onStepStart=y;function O(u){L__namespace.NarrationManagerStatic.onLoadingLabel=u;}U.onLoadingLabel=O;function S(u){L__namespace.NarrationManagerStatic.onStepEnd=u;}U.onStepEnd=S;function j(u){L__namespace.NarrationManagerStatic.onLabelStarting=u;}U.onLabelStarting=j;function D(u){L__namespace.NarrationManagerStatic.onLabelClosing=u;}U.onLabelClosing=D;function H(u){core.GameUnifier.navigate=u;}U.onNavigate=H;function f(u){return core.GameUnifier.addOnPreContinue(u)}U.addOnPreContinue=f;function _(u){return core.GameUnifier.removeOnPreContinue(u)}U.removeOnPreContinue=_,U.testing=ce(U);})(exports.Game||={});var ri={characterUtils:$t__namespace,canvasUtils:k__namespace,narrationUtils:L__namespace,soundUtils:gt__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Wt,PIXIVN_VERSION:Lt,...Yt,...ae,canvas:k__namespace.canvas,narration:L__namespace.narration,sound:gt__namespace.sound,storage:K__namespace.storage,history:ot__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Wt;exports.CachedMap=Dt;exports.PIXIVN_VERSION=Lt;exports.SYSTEM_RESERVED_STORAGE_KEYS=be;exports.createExportableElement=le;exports.default=ri;Object.keys(k).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return k[k]}})});Object.keys($t).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return $t[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(ot).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return ot[k]}})});Object.keys(L).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return L[k]}})});Object.keys(gt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return gt[k]}})});Object.keys(K).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return K[k]}})});
package/dist/index.d.cts CHANGED
@@ -1,20 +1,20 @@
1
+ import * as historyUtils from '@drincs/pixi-vn/history';
2
+ export * from '@drincs/pixi-vn/history';
3
+ import * as narrationUtils from '@drincs/pixi-vn/narration';
4
+ import { NarrationGameState } from '@drincs/pixi-vn/narration';
5
+ export * from '@drincs/pixi-vn/narration';
6
+ import * as storageUtils from '@drincs/pixi-vn/storage';
7
+ export * from '@drincs/pixi-vn/storage';
1
8
  import * as canvasUtils from '@drincs/pixi-vn/canvas';
2
9
  export * from '@drincs/pixi-vn/canvas';
3
10
  import * as characterUtils from '@drincs/pixi-vn/characters';
4
11
  export * from '@drincs/pixi-vn/characters';
5
12
  import { OnErrorHandler, GameUnifier } from '@drincs/pixi-vn/core';
6
13
  export * from '@drincs/pixi-vn/core';
7
- import * as historyUtils from '@drincs/pixi-vn/history';
8
- export * from '@drincs/pixi-vn/history';
9
- import * as narrationUtils from '@drincs/pixi-vn/narration';
10
- import { NarrationGameState } from '@drincs/pixi-vn/narration';
11
- export * from '@drincs/pixi-vn/narration';
12
14
  import { ApplicationOptions } from '@drincs/pixi-vn/pixi.js';
13
15
  export { AllFederatedEventMap, ApplicationOptions, AssetSrc, AssetsBundle, AssetsManifest, FederatedEvent, LoadParserName, ResolvedAsset, ResolvedSrc, UnresolvedAsset } from '@drincs/pixi-vn/pixi.js';
14
16
  import * as soundUtils from '@drincs/pixi-vn/sound';
15
17
  export * from '@drincs/pixi-vn/sound';
16
- import * as storageUtils from '@drincs/pixi-vn/storage';
17
- export * from '@drincs/pixi-vn/storage';
18
18
  export { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
19
19
  import { e as CanvasGameState } from './ContainerMemory-BpDgacyr.cjs';
20
20
  import { H as HistoryGameState } from './HistoryGameState-CGfvq5iL.cjs';
@@ -29,7 +29,111 @@ import 'microdiff';
29
29
  import 'tone';
30
30
  import './StorageElementType-C7ETezlL.cjs';
31
31
 
32
- var version = "1.9.1";
32
+ /**
33
+ * One error captured by {@link createGameTesting}'s `enable` while testing is active, via
34
+ * `Game.addOnError`.
35
+ */
36
+ interface GameTestingErrorEntry {
37
+ error: unknown;
38
+ timestamp: number;
39
+ }
40
+ /**
41
+ * A read-only snapshot of everything a test session typically needs to decide its next
42
+ * action, gathered from {@link narrationUtils.narration} and {@link historyUtils.stepHistory}
43
+ * in a single call instead of reading several properties one by one.
44
+ */
45
+ interface GameTestingState {
46
+ dialogue: narrationUtils.DialogueInterface | undefined;
47
+ dialogueGlue: boolean;
48
+ choices: narrationUtils.StoredIndexedChoiceInterface[] | undefined;
49
+ input: {
50
+ isRequired: boolean;
51
+ type: string | undefined;
52
+ value: storageUtils.StorageElementType;
53
+ };
54
+ canContinue: boolean;
55
+ canGoBack: boolean;
56
+ labelsOpened: narrationUtils.OpenedLabel[];
57
+ currentLabelId: string | undefined;
58
+ stepCounter: number;
59
+ }
60
+ /**
61
+ * The object attached to `window` (and returned) by `enable`. Every action method
62
+ * merges the most recent props passed to `setProps` with any `extraProps` given here,
63
+ * then delegates to the matching narration/history call — so calling these behaves exactly
64
+ * like a real player action (the same `navigate`/`t`/`toast`/etc. the real UI uses).
65
+ *
66
+ * `narration`, `storage`, `stepHistory` and `Game` are also exposed directly for anything not
67
+ * covered by the action methods (e.g. `storage.set(...)`, `Game.exportGameState()`).
68
+ */
69
+ interface GameTestingAPI<TGame, T extends {} = {}> {
70
+ readonly Game: TGame;
71
+ readonly narration: narrationUtils.NarrationManagerInterface;
72
+ readonly storage: storageUtils.StorageManagerInterface;
73
+ readonly stepHistory: historyUtils.HistoryManagerInterface;
74
+ /**
75
+ * The most recent props passed to `setProps` — whatever your app's `StepLabelProps`
76
+ * augmentation defines (e.g. `navigate`, `toast`). Useful to drive the app's UI directly
77
+ * during a test session — e.g. `pixiVN.props.navigate("/settings")` — not just narration,
78
+ * for full control over what's on screen.
79
+ */
80
+ readonly props: narrationUtils.StepLabelPropsType<T>;
81
+ /** `Game.start` using the live props plus any `extraProps`. */
82
+ start(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
83
+ /** {@link narrationUtils.NarrationManagerInterface.continue} using the live props plus any `extraProps`. */
84
+ continue(extraProps?: Partial<T>, options?: {
85
+ steps?: number;
86
+ runNow?: boolean;
87
+ }): Promise<narrationUtils.StepLabelResultType>;
88
+ /** {@link narrationUtils.NarrationManagerInterface.call} using the live props plus any `extraProps`. */
89
+ call(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
90
+ /** {@link narrationUtils.NarrationManagerInterface.jump} using the live props plus any `extraProps`. */
91
+ jump(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
92
+ /**
93
+ * Selects the currently open choice with this `choiceIndex` (as seen in
94
+ * `getState().choices`), using the live props plus any `extraProps`.
95
+ * @throws when no open choice has that index.
96
+ */
97
+ selectChoice(choiceIndex: number, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
98
+ /** Resolves a pending `narration.input.request(...)` with `value`, exactly like the player typing an answer and confirming. */
99
+ setInput(value: storageUtils.StorageElementType): void;
100
+ /** {@link historyUtils.HistoryManagerInterface.back} using the live props plus any `extraProps`. */
101
+ goBack(extraProps?: Partial<T>, options?: {
102
+ steps?: number;
103
+ }): Promise<narrationUtils.StepLabelResultType>;
104
+ /** {@link narrationUtils.NarrationLabelsInterface.closeCurrent} */
105
+ closeCurrentLabel(): void;
106
+ /** {@link narrationUtils.NarrationLabelsInterface.closeAll}. **Can end the game.** */
107
+ closeAllLabels(): void;
108
+ /** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
109
+ getState(): GameTestingState;
110
+ /** Errors caught via `Game.addOnError` since `enable()` was called (or since the last {@link clearErrors}). */
111
+ readonly errors: GameTestingErrorEntry[];
112
+ clearErrors(): void;
113
+ }
114
+ /**
115
+ * Per-action overrides an app can register via `setActions` so `Game.testing`'s
116
+ * window-exposed actions run the app's own narration functions — with whatever UI-only side
117
+ * effects they add (loading state, blocking while a menu is open, refreshing cached interface
118
+ * data, ...) — instead of calling {@link narrationUtils.narration} / {@link
119
+ * historyUtils.stepHistory} directly. Any action left undefined keeps the default behavior.
120
+ *
121
+ * `continue`/`back` take no arguments: the `extraProps`/`options` a caller passes to the
122
+ * corresponding {@link GameTestingAPI} method are ignored when an override is registered,
123
+ * since the override already has its own way to gather props (and typically doesn't support
124
+ * stepped/replay options). `selectChoice` receives the resolved choice item instead of the
125
+ * raw `choiceIndex`, since looking it up is already handled before the override runs.
126
+ */
127
+ interface GameTestingActions<T extends {} = {}> {
128
+ continue?: () => Promise<void>;
129
+ back?: () => Promise<void>;
130
+ selectChoice?: (item: narrationUtils.StoredIndexedChoiceInterface) => Promise<void>;
131
+ start?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<void>;
132
+ jump?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
133
+ call?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
134
+ }
135
+
136
+ var version = "1.9.2";
33
137
 
34
138
  /**
35
139
  * Is a special alias to indicate the game layer.
@@ -374,116 +478,23 @@ declare namespace Game {
374
478
  * action — call it unconditionally from wherever your app builds those props (e.g. at the end
375
479
  * of a `useGameProps()`-style hook), since every action needs up-to-date props whether or not
376
480
  * testing happens to be enabled right now.
481
+ * - `setActions(actions)` is optional: if the app wraps `narration`/`stepHistory` in its own
482
+ * functions to handle UI-only concerns (a loading indicator, blocking while a menu is open,
483
+ * refreshing cached interface data, ...), it can register those functions so `continue()`,
484
+ * `goBack()`, `selectChoice()`, `start()`, `jump()` and `call()` drive the game through them
485
+ * instead of calling `narration`/`stepHistory` directly — same as a real player action would.
377
486
  * See the `pixi-vn-testing` skill for the full guide (activation patterns, the complete command
378
487
  * surface, and cookbook snippets for a browser-driven test session).
379
488
  */
380
- namespace testing {
381
- /**
382
- * One error captured by {@link enable} while testing is active, via {@link Game.addOnError}.
383
- */
384
- interface GameTestingErrorEntry {
385
- error: unknown;
386
- timestamp: number;
387
- }
388
- /**
389
- * A read-only snapshot of everything a test session typically needs to decide its next
390
- * action, gathered from {@link narrationUtils.narration} and {@link historyUtils.stepHistory}
391
- * in a single call instead of reading several properties one by one.
392
- */
393
- interface GameTestingState {
394
- dialogue: narrationUtils.DialogueInterface | undefined;
395
- dialogueGlue: boolean;
396
- choices: narrationUtils.StoredIndexedChoiceInterface[] | undefined;
397
- input: {
398
- isRequired: boolean;
399
- type: string | undefined;
400
- value: storageUtils.StorageElementType;
401
- };
402
- canContinue: boolean;
403
- canGoBack: boolean;
404
- labelsOpened: narrationUtils.OpenedLabel[];
405
- currentLabelId: string | undefined;
406
- stepCounter: number;
407
- }
408
- /**
409
- * The object attached to `window` (and returned) by {@link enable}. Every action method
410
- * merges the most recent props passed to {@link setProps} with any `extraProps` given here,
411
- * then delegates to the matching narration/history call — so calling these behaves exactly
412
- * like a real player action (the same `navigate`/`t`/`toast`/etc. the real UI uses).
413
- *
414
- * `narration`, `storage`, `stepHistory` and `Game` are also exposed directly for anything not
415
- * covered by the action methods (e.g. `storage.set(...)`, `Game.exportGameState()`).
416
- */
417
- interface GameTestingAPI<T extends {} = {}> {
418
- readonly Game: typeof Game;
419
- readonly narration: narrationUtils.NarrationManagerInterface;
420
- readonly storage: storageUtils.StorageManagerInterface;
421
- readonly stepHistory: historyUtils.HistoryManagerInterface;
422
- /**
423
- * The most recent props passed to {@link setProps} — whatever your app's `StepLabelProps`
424
- * augmentation defines (e.g. `navigate`, `toast`). Useful to drive the app's UI directly
425
- * during a test session — e.g. `pixiVN.props.navigate("/settings")` — not just narration,
426
- * for full control over what's on screen.
427
- */
428
- readonly props: narrationUtils.StepLabelPropsType<T>;
429
- /** {@link Game.start} using the live props plus any `extraProps`. */
430
- start(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
431
- /** {@link narrationUtils.NarrationManagerInterface.continue} using the live props plus any `extraProps`. */
432
- continue(extraProps?: Partial<T>, options?: {
433
- steps?: number;
434
- runNow?: boolean;
435
- }): Promise<narrationUtils.StepLabelResultType>;
436
- /** {@link narrationUtils.NarrationManagerInterface.call} using the live props plus any `extraProps`. */
437
- call(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
438
- /** {@link narrationUtils.NarrationManagerInterface.jump} using the live props plus any `extraProps`. */
439
- jump(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
440
- /**
441
- * Selects the currently open choice with this `choiceIndex` (as seen in
442
- * `getState().choices`), using the live props plus any `extraProps`.
443
- * @throws when no open choice has that index.
444
- */
445
- selectChoice(choiceIndex: number, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
446
- /** Resolves a pending `narration.input.request(...)` with `value`, exactly like the player typing an answer and confirming. */
447
- setInput(value: storageUtils.StorageElementType): void;
448
- /** {@link historyUtils.HistoryManagerInterface.back} using the live props plus any `extraProps`. */
449
- goBack(extraProps?: Partial<T>, options?: {
450
- steps?: number;
451
- }): Promise<narrationUtils.StepLabelResultType>;
452
- /** {@link narrationUtils.NarrationLabelsInterface.closeCurrent} */
453
- closeCurrentLabel(): void;
454
- /** {@link narrationUtils.NarrationLabelsInterface.closeAll}. **Can end the game.** */
455
- closeAllLabels(): void;
456
- /** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
457
- getState(): GameTestingState;
458
- /** Errors caught via {@link Game.addOnError} since `enable()` was called (or since the last {@link clearErrors}). */
459
- readonly errors: GameTestingErrorEntry[];
460
- clearErrors(): void;
461
- }
462
- /**
463
- * Updates the live props every {@link GameTestingAPI} action merges `extraProps` on top of.
464
- * Call this unconditionally from wherever your app builds its `StepLabelProps` (e.g. the end
465
- * of a `useGameProps()`-style hook that already runs throughout the app) — it's a cheap
466
- * assignment, safe to call whether or not testing is currently {@link enable}d.
467
- * @param props The app's current `StepLabelProps` (the same object your UI passes to
468
- * `narration.continue`/`Game.start`).
469
- */
470
- function setProps<T extends {} = {}>(props: narrationUtils.StepLabelPropsType<T>): void;
471
- /**
472
- * Enables the testing API: builds it, attaches it to `window[windowKey]` (default
473
- * `"pixiVN"`), and returns it. Calling this again replaces the previous session.
474
- * @param options.windowKey The property name to attach the API under on `window`. @default "pixiVN"
475
- */
476
- function enable<T extends {} = {}>(options?: {
489
+ const testing: {
490
+ setProps: <T extends {} = {}>(props: narrationUtils.StepLabelPropsType<T>) => void;
491
+ setActions: <T extends {} = {}>(actions: GameTestingActions<T>) => void;
492
+ enable: <T extends {} = {}>(options?: {
477
493
  windowKey?: string;
478
- }): GameTestingAPI<T>;
479
- /**
480
- * Disables a session started with {@link enable}: removes the error handler and, if it's
481
- * still the current value, deletes `window[windowKey]`. No-op if testing isn't enabled.
482
- */
483
- function disable(): void;
484
- /** Whether a testing session is currently active. */
485
- function isEnabled(): boolean;
486
- }
494
+ } | undefined) => GameTestingAPI<typeof Game, T>;
495
+ disable: () => void;
496
+ isEnabled: () => boolean;
497
+ };
487
498
  }
488
499
  declare const _default: {
489
500
  canvas: canvasUtils.CanvasManagerInterface;
@@ -502,4 +513,4 @@ declare const _default: {
502
513
  PIXIVN_VERSION: string;
503
514
  };
504
515
 
505
- export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
516
+ export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, type GameTestingAPI, type GameTestingActions, type GameTestingErrorEntry, type GameTestingState, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,20 @@
1
+ import * as historyUtils from '@drincs/pixi-vn/history';
2
+ export * from '@drincs/pixi-vn/history';
3
+ import * as narrationUtils from '@drincs/pixi-vn/narration';
4
+ import { NarrationGameState } from '@drincs/pixi-vn/narration';
5
+ export * from '@drincs/pixi-vn/narration';
6
+ import * as storageUtils from '@drincs/pixi-vn/storage';
7
+ export * from '@drincs/pixi-vn/storage';
1
8
  import * as canvasUtils from '@drincs/pixi-vn/canvas';
2
9
  export * from '@drincs/pixi-vn/canvas';
3
10
  import * as characterUtils from '@drincs/pixi-vn/characters';
4
11
  export * from '@drincs/pixi-vn/characters';
5
12
  import { OnErrorHandler, GameUnifier } from '@drincs/pixi-vn/core';
6
13
  export * from '@drincs/pixi-vn/core';
7
- import * as historyUtils from '@drincs/pixi-vn/history';
8
- export * from '@drincs/pixi-vn/history';
9
- import * as narrationUtils from '@drincs/pixi-vn/narration';
10
- import { NarrationGameState } from '@drincs/pixi-vn/narration';
11
- export * from '@drincs/pixi-vn/narration';
12
14
  import { ApplicationOptions } from '@drincs/pixi-vn/pixi.js';
13
15
  export { AllFederatedEventMap, ApplicationOptions, AssetSrc, AssetsBundle, AssetsManifest, FederatedEvent, LoadParserName, ResolvedAsset, ResolvedSrc, UnresolvedAsset } from '@drincs/pixi-vn/pixi.js';
14
16
  import * as soundUtils from '@drincs/pixi-vn/sound';
15
17
  export * from '@drincs/pixi-vn/sound';
16
- import * as storageUtils from '@drincs/pixi-vn/storage';
17
- export * from '@drincs/pixi-vn/storage';
18
18
  export { C as CachedMap } from './CachedMap-DZLvJAnA.js';
19
19
  import { e as CanvasGameState } from './ContainerMemory-BpDgacyr.js';
20
20
  import { H as HistoryGameState } from './HistoryGameState-C8ATx9K6.js';
@@ -29,7 +29,111 @@ import 'microdiff';
29
29
  import 'tone';
30
30
  import './StorageElementType-C7ETezlL.js';
31
31
 
32
- var version = "1.9.1";
32
+ /**
33
+ * One error captured by {@link createGameTesting}'s `enable` while testing is active, via
34
+ * `Game.addOnError`.
35
+ */
36
+ interface GameTestingErrorEntry {
37
+ error: unknown;
38
+ timestamp: number;
39
+ }
40
+ /**
41
+ * A read-only snapshot of everything a test session typically needs to decide its next
42
+ * action, gathered from {@link narrationUtils.narration} and {@link historyUtils.stepHistory}
43
+ * in a single call instead of reading several properties one by one.
44
+ */
45
+ interface GameTestingState {
46
+ dialogue: narrationUtils.DialogueInterface | undefined;
47
+ dialogueGlue: boolean;
48
+ choices: narrationUtils.StoredIndexedChoiceInterface[] | undefined;
49
+ input: {
50
+ isRequired: boolean;
51
+ type: string | undefined;
52
+ value: storageUtils.StorageElementType;
53
+ };
54
+ canContinue: boolean;
55
+ canGoBack: boolean;
56
+ labelsOpened: narrationUtils.OpenedLabel[];
57
+ currentLabelId: string | undefined;
58
+ stepCounter: number;
59
+ }
60
+ /**
61
+ * The object attached to `window` (and returned) by `enable`. Every action method
62
+ * merges the most recent props passed to `setProps` with any `extraProps` given here,
63
+ * then delegates to the matching narration/history call — so calling these behaves exactly
64
+ * like a real player action (the same `navigate`/`t`/`toast`/etc. the real UI uses).
65
+ *
66
+ * `narration`, `storage`, `stepHistory` and `Game` are also exposed directly for anything not
67
+ * covered by the action methods (e.g. `storage.set(...)`, `Game.exportGameState()`).
68
+ */
69
+ interface GameTestingAPI<TGame, T extends {} = {}> {
70
+ readonly Game: TGame;
71
+ readonly narration: narrationUtils.NarrationManagerInterface;
72
+ readonly storage: storageUtils.StorageManagerInterface;
73
+ readonly stepHistory: historyUtils.HistoryManagerInterface;
74
+ /**
75
+ * The most recent props passed to `setProps` — whatever your app's `StepLabelProps`
76
+ * augmentation defines (e.g. `navigate`, `toast`). Useful to drive the app's UI directly
77
+ * during a test session — e.g. `pixiVN.props.navigate("/settings")` — not just narration,
78
+ * for full control over what's on screen.
79
+ */
80
+ readonly props: narrationUtils.StepLabelPropsType<T>;
81
+ /** `Game.start` using the live props plus any `extraProps`. */
82
+ start(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
83
+ /** {@link narrationUtils.NarrationManagerInterface.continue} using the live props plus any `extraProps`. */
84
+ continue(extraProps?: Partial<T>, options?: {
85
+ steps?: number;
86
+ runNow?: boolean;
87
+ }): Promise<narrationUtils.StepLabelResultType>;
88
+ /** {@link narrationUtils.NarrationManagerInterface.call} using the live props plus any `extraProps`. */
89
+ call(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
90
+ /** {@link narrationUtils.NarrationManagerInterface.jump} using the live props plus any `extraProps`. */
91
+ jump(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
92
+ /**
93
+ * Selects the currently open choice with this `choiceIndex` (as seen in
94
+ * `getState().choices`), using the live props plus any `extraProps`.
95
+ * @throws when no open choice has that index.
96
+ */
97
+ selectChoice(choiceIndex: number, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
98
+ /** Resolves a pending `narration.input.request(...)` with `value`, exactly like the player typing an answer and confirming. */
99
+ setInput(value: storageUtils.StorageElementType): void;
100
+ /** {@link historyUtils.HistoryManagerInterface.back} using the live props plus any `extraProps`. */
101
+ goBack(extraProps?: Partial<T>, options?: {
102
+ steps?: number;
103
+ }): Promise<narrationUtils.StepLabelResultType>;
104
+ /** {@link narrationUtils.NarrationLabelsInterface.closeCurrent} */
105
+ closeCurrentLabel(): void;
106
+ /** {@link narrationUtils.NarrationLabelsInterface.closeAll}. **Can end the game.** */
107
+ closeAllLabels(): void;
108
+ /** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
109
+ getState(): GameTestingState;
110
+ /** Errors caught via `Game.addOnError` since `enable()` was called (or since the last {@link clearErrors}). */
111
+ readonly errors: GameTestingErrorEntry[];
112
+ clearErrors(): void;
113
+ }
114
+ /**
115
+ * Per-action overrides an app can register via `setActions` so `Game.testing`'s
116
+ * window-exposed actions run the app's own narration functions — with whatever UI-only side
117
+ * effects they add (loading state, blocking while a menu is open, refreshing cached interface
118
+ * data, ...) — instead of calling {@link narrationUtils.narration} / {@link
119
+ * historyUtils.stepHistory} directly. Any action left undefined keeps the default behavior.
120
+ *
121
+ * `continue`/`back` take no arguments: the `extraProps`/`options` a caller passes to the
122
+ * corresponding {@link GameTestingAPI} method are ignored when an override is registered,
123
+ * since the override already has its own way to gather props (and typically doesn't support
124
+ * stepped/replay options). `selectChoice` receives the resolved choice item instead of the
125
+ * raw `choiceIndex`, since looking it up is already handled before the override runs.
126
+ */
127
+ interface GameTestingActions<T extends {} = {}> {
128
+ continue?: () => Promise<void>;
129
+ back?: () => Promise<void>;
130
+ selectChoice?: (item: narrationUtils.StoredIndexedChoiceInterface) => Promise<void>;
131
+ start?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<void>;
132
+ jump?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
133
+ call?: (label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, props?: T) => Promise<narrationUtils.StepLabelResultType>;
134
+ }
135
+
136
+ var version = "1.9.2";
33
137
 
34
138
  /**
35
139
  * Is a special alias to indicate the game layer.
@@ -374,116 +478,23 @@ declare namespace Game {
374
478
  * action — call it unconditionally from wherever your app builds those props (e.g. at the end
375
479
  * of a `useGameProps()`-style hook), since every action needs up-to-date props whether or not
376
480
  * testing happens to be enabled right now.
481
+ * - `setActions(actions)` is optional: if the app wraps `narration`/`stepHistory` in its own
482
+ * functions to handle UI-only concerns (a loading indicator, blocking while a menu is open,
483
+ * refreshing cached interface data, ...), it can register those functions so `continue()`,
484
+ * `goBack()`, `selectChoice()`, `start()`, `jump()` and `call()` drive the game through them
485
+ * instead of calling `narration`/`stepHistory` directly — same as a real player action would.
377
486
  * See the `pixi-vn-testing` skill for the full guide (activation patterns, the complete command
378
487
  * surface, and cookbook snippets for a browser-driven test session).
379
488
  */
380
- namespace testing {
381
- /**
382
- * One error captured by {@link enable} while testing is active, via {@link Game.addOnError}.
383
- */
384
- interface GameTestingErrorEntry {
385
- error: unknown;
386
- timestamp: number;
387
- }
388
- /**
389
- * A read-only snapshot of everything a test session typically needs to decide its next
390
- * action, gathered from {@link narrationUtils.narration} and {@link historyUtils.stepHistory}
391
- * in a single call instead of reading several properties one by one.
392
- */
393
- interface GameTestingState {
394
- dialogue: narrationUtils.DialogueInterface | undefined;
395
- dialogueGlue: boolean;
396
- choices: narrationUtils.StoredIndexedChoiceInterface[] | undefined;
397
- input: {
398
- isRequired: boolean;
399
- type: string | undefined;
400
- value: storageUtils.StorageElementType;
401
- };
402
- canContinue: boolean;
403
- canGoBack: boolean;
404
- labelsOpened: narrationUtils.OpenedLabel[];
405
- currentLabelId: string | undefined;
406
- stepCounter: number;
407
- }
408
- /**
409
- * The object attached to `window` (and returned) by {@link enable}. Every action method
410
- * merges the most recent props passed to {@link setProps} with any `extraProps` given here,
411
- * then delegates to the matching narration/history call — so calling these behaves exactly
412
- * like a real player action (the same `navigate`/`t`/`toast`/etc. the real UI uses).
413
- *
414
- * `narration`, `storage`, `stepHistory` and `Game` are also exposed directly for anything not
415
- * covered by the action methods (e.g. `storage.set(...)`, `Game.exportGameState()`).
416
- */
417
- interface GameTestingAPI<T extends {} = {}> {
418
- readonly Game: typeof Game;
419
- readonly narration: narrationUtils.NarrationManagerInterface;
420
- readonly storage: storageUtils.StorageManagerInterface;
421
- readonly stepHistory: historyUtils.HistoryManagerInterface;
422
- /**
423
- * The most recent props passed to {@link setProps} — whatever your app's `StepLabelProps`
424
- * augmentation defines (e.g. `navigate`, `toast`). Useful to drive the app's UI directly
425
- * during a test session — e.g. `pixiVN.props.navigate("/settings")` — not just narration,
426
- * for full control over what's on screen.
427
- */
428
- readonly props: narrationUtils.StepLabelPropsType<T>;
429
- /** {@link Game.start} using the live props plus any `extraProps`. */
430
- start(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
431
- /** {@link narrationUtils.NarrationManagerInterface.continue} using the live props plus any `extraProps`. */
432
- continue(extraProps?: Partial<T>, options?: {
433
- steps?: number;
434
- runNow?: boolean;
435
- }): Promise<narrationUtils.StepLabelResultType>;
436
- /** {@link narrationUtils.NarrationManagerInterface.call} using the live props plus any `extraProps`. */
437
- call(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
438
- /** {@link narrationUtils.NarrationManagerInterface.jump} using the live props plus any `extraProps`. */
439
- jump(label: narrationUtils.LabelAbstract<any, T> | narrationUtils.LabelIdType, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
440
- /**
441
- * Selects the currently open choice with this `choiceIndex` (as seen in
442
- * `getState().choices`), using the live props plus any `extraProps`.
443
- * @throws when no open choice has that index.
444
- */
445
- selectChoice(choiceIndex: number, extraProps?: Partial<T>): Promise<narrationUtils.StepLabelResultType>;
446
- /** Resolves a pending `narration.input.request(...)` with `value`, exactly like the player typing an answer and confirming. */
447
- setInput(value: storageUtils.StorageElementType): void;
448
- /** {@link historyUtils.HistoryManagerInterface.back} using the live props plus any `extraProps`. */
449
- goBack(extraProps?: Partial<T>, options?: {
450
- steps?: number;
451
- }): Promise<narrationUtils.StepLabelResultType>;
452
- /** {@link narrationUtils.NarrationLabelsInterface.closeCurrent} */
453
- closeCurrentLabel(): void;
454
- /** {@link narrationUtils.NarrationLabelsInterface.closeAll}. **Can end the game.** */
455
- closeAllLabels(): void;
456
- /** A snapshot of dialogue/choices/input/canContinue/canGoBack/labels — see {@link GameTestingState}. */
457
- getState(): GameTestingState;
458
- /** Errors caught via {@link Game.addOnError} since `enable()` was called (or since the last {@link clearErrors}). */
459
- readonly errors: GameTestingErrorEntry[];
460
- clearErrors(): void;
461
- }
462
- /**
463
- * Updates the live props every {@link GameTestingAPI} action merges `extraProps` on top of.
464
- * Call this unconditionally from wherever your app builds its `StepLabelProps` (e.g. the end
465
- * of a `useGameProps()`-style hook that already runs throughout the app) — it's a cheap
466
- * assignment, safe to call whether or not testing is currently {@link enable}d.
467
- * @param props The app's current `StepLabelProps` (the same object your UI passes to
468
- * `narration.continue`/`Game.start`).
469
- */
470
- function setProps<T extends {} = {}>(props: narrationUtils.StepLabelPropsType<T>): void;
471
- /**
472
- * Enables the testing API: builds it, attaches it to `window[windowKey]` (default
473
- * `"pixiVN"`), and returns it. Calling this again replaces the previous session.
474
- * @param options.windowKey The property name to attach the API under on `window`. @default "pixiVN"
475
- */
476
- function enable<T extends {} = {}>(options?: {
489
+ const testing: {
490
+ setProps: <T extends {} = {}>(props: narrationUtils.StepLabelPropsType<T>) => void;
491
+ setActions: <T extends {} = {}>(actions: GameTestingActions<T>) => void;
492
+ enable: <T extends {} = {}>(options?: {
477
493
  windowKey?: string;
478
- }): GameTestingAPI<T>;
479
- /**
480
- * Disables a session started with {@link enable}: removes the error handler and, if it's
481
- * still the current value, deletes `window[windowKey]`. No-op if testing isn't enabled.
482
- */
483
- function disable(): void;
484
- /** Whether a testing session is currently active. */
485
- function isEnabled(): boolean;
486
- }
494
+ } | undefined) => GameTestingAPI<typeof Game, T>;
495
+ disable: () => void;
496
+ isEnabled: () => boolean;
497
+ };
487
498
  }
488
499
  declare const _default: {
489
500
  canvas: canvasUtils.CanvasManagerInterface;
@@ -502,4 +513,4 @@ declare const _default: {
502
513
  PIXIVN_VERSION: string;
503
514
  };
504
515
 
505
- export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
516
+ export { CANVAS_APP_GAME_LAYER_ALIAS, Game, type GameState, type GameStepStateData, type GameTestingAPI, type GameTestingActions, type GameTestingErrorEntry, type GameTestingState, version as PIXIVN_VERSION, SYSTEM_RESERVED_STORAGE_KEYS, createExportableElement, _default as default };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {f,b,g,e,d,h,i}from'./chunk-K7JIC2F2.mjs';import*as V from'@drincs/pixi-vn/canvas';export*from'@drincs/pixi-vn/canvas';import*as Qt from'@drincs/pixi-vn/characters';export*from'@drincs/pixi-vn/characters';import {PixiError,GameUnifier}from'@drincs/pixi-vn/core';export*from'@drincs/pixi-vn/core';import*as H from'@drincs/pixi-vn/history';export*from'@drincs/pixi-vn/history';import*as m from'@drincs/pixi-vn/narration';export*from'@drincs/pixi-vn/narration';import*as mt from'@drincs/pixi-vn/sound';export*from'@drincs/pixi-vn/sound';import*as z from'@drincs/pixi-vn/storage';export*from'@drincs/pixi-vn/storage';import {motion}from'@drincs/pixi-vn/motion';var ye=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ne=new Set,Ht=typeof process=="object"&&process?process:{},oe=(_,e,i,s)=>{typeof Ht.emitWarning=="function"?Ht.emitWarning(_,e,i,s):console.error(`[${i}] ${e}: ${_}`);},jt=globalThis.AbortController,ie=globalThis.AbortSignal;if(typeof jt>"u"){ie=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},jt=class{constructor(){e();}signal=new ie;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let _=Ht.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{_&&(_=false,oe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var Se=_=>!ne.has(_);var dt=_=>_&&_===Math.floor(_)&&_>0&&isFinite(_),ae=_=>dt(_)?_<=Math.pow(2,8)?Uint8Array:_<=Math.pow(2,16)?Uint16Array:_<=Math.pow(2,32)?Uint32Array:_<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(_){super(_),this.fill(0);}},at,xt,be=(at=class{heap;length;static create(e){let i=ae(e);if(!i)return [];g(at,xt,true);let s=new at(e,i);return g(at,xt,false),s}constructor(e$1,i){if(!e(at,xt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},xt=new WeakMap,f(at,xt,false),at),se,re,X,W,Z,vt,tt,Et,Ut,et,R,it,L,T,u,F,Y,j,I,st,D,rt,nt,q,B,ot,gt,M,Tt,a,kt,yt,ht,Rt,$,he,St,At,Pt,pt,ut,Kt,Nt,Gt,U,Wt,Lt,ft,Yt,Ot,le=(Ot=class{constructor(e$1){f(this,a);f(this,X);f(this,W);f(this,Z);f(this,vt);f(this,tt);f(this,Et);f(this,Ut);f(this,et);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f(this,R);f(this,it);f(this,L);f(this,T);f(this,u);f(this,F);f(this,Y);f(this,j);f(this,I);f(this,st);f(this,D);f(this,rt);f(this,nt);f(this,q);f(this,B);f(this,ot);f(this,gt);f(this,M);f(this,Tt);f(this,yt,()=>{});f(this,ht,()=>{});f(this,Rt,()=>{});f(this,$,()=>false);f(this,St,e=>{});f(this,At,(e,i,s)=>{});f(this,Pt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,se,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:l,allowStale:d$1,dispose:y,onInsert:P,disposeAfter:S,noDisposeOnSet:lt,noUpdateTTL:k,maxSize:J=0,maxEntrySize:A=0,sizeCalculation:x,fetchMethod:f$1,memoMethod:O,noDeleteOnFetchRejection:c,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:g$1,ignoreFetchAbort:E,perf:N}=e$1;if(N!==void 0&&typeof N?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,et,N??ye),i!==0&&!dt(i))throw new TypeError("max option must be a nonnegative integer");let K=i?ae(i):Array;if(!K)throw new Error("invalid max value: "+i);if(g(this,X,i),g(this,W,J),this.maxEntrySize=A||e(this,W),this.sizeCalculation=x,this.sizeCalculation){if(!e(this,W)&&!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(O!==void 0&&typeof O!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,Ut,O),f$1!==void 0&&typeof f$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,Et,f$1),g(this,gt,!!f$1),g(this,L,new Map),g(this,T,new Array(i).fill(void 0)),g(this,u,new Array(i).fill(void 0)),g(this,F,new K(i)),g(this,Y,new K(i)),g(this,j,0),g(this,I,0),g(this,st,be.create(i)),g(this,R,0),g(this,it,0),typeof y=="function"&&g(this,Z,y),typeof P=="function"&&g(this,vt,P),typeof S=="function"?(g(this,tt,S),g(this,D,[])):(g(this,tt,void 0),g(this,D,void 0)),g(this,ot,!!e(this,Z)),g(this,Tt,!!e(this,vt)),g(this,M,!!e(this,tt)),this.noDisposeOnSet=!!lt,this.noUpdateTTL=!!k,this.noDeleteOnFetchRejection=!!c,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!g$1,this.ignoreFetchAbort=!!E,this.maxEntrySize!==0){if(e(this,W)!==0&&!dt(e(this,W)))throw new TypeError("maxSize must be a positive integer if specified");if(!dt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,a,he).call(this);}if(this.allowStale=!!d$1,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!l,this.ttlResolution=dt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!dt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,a,kt).call(this);}if(e(this,X)===0&&this.ttl===0&&e(this,W)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,X)&&!e(this,W)){let _t="LRU_CACHE_UNBOUNDED";Se(_t)&&(ne.add(_t),oe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_t,Ot));}}get perf(){return e(this,et)}static unsafeExposeInternals(e$1){return {starts:e(e$1,nt),ttls:e(e$1,q),autopurgeTimers:e(e$1,B),sizes:e(e$1,rt),keyMap:e(e$1,L),keyList:e(e$1,T),valList:e(e$1,u),next:e(e$1,F),prev:e(e$1,Y),get head(){return e(e$1,j)},get tail(){return e(e$1,I)},free:e(e$1,st),isBackgroundFetch:i=>{var s;return h(s=e$1,a,U).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return h(n=e$1,a,Gt).call(n,i,s,r,o)},moveToTail:i=>{var s;return h(s=e$1,a,Lt).call(s,i)},indexes:i=>{var s;return h(s=e$1,a,pt).call(s,i)},rindexes:i=>{var s;return h(s=e$1,a,ut).call(s,i)},isStale:i=>{var s;return e(s=e$1,$).call(s,i)}}}get max(){return e(this,X)}get maxSize(){return e(this,W)}get calculatedSize(){return e(this,it)}get size(){return e(this,R)}get fetchMethod(){return e(this,Et)}get memoMethod(){return e(this,Ut)}get dispose(){return e(this,Z)}get onInsert(){return e(this,vt)}get disposeAfter(){return e(this,tt)}getRemainingTTL(e$1){return e(this,L).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,a,pt).call(this))e(this,u)[e$1]!==void 0&&e(this,T)[e$1]!==void 0&&!h(this,a,U).call(this,e(this,u)[e$1])&&(yield [e(this,T)[e$1],e(this,u)[e$1]]);}*rentries(){for(let e$1 of h(this,a,ut).call(this))e(this,u)[e$1]!==void 0&&e(this,T)[e$1]!==void 0&&!h(this,a,U).call(this,e(this,u)[e$1])&&(yield [e(this,T)[e$1],e(this,u)[e$1]]);}*keys(){for(let e$1 of h(this,a,pt).call(this)){let i=e(this,T)[e$1];i!==void 0&&!h(this,a,U).call(this,e(this,u)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,a,ut).call(this)){let i=e(this,T)[e$1];i!==void 0&&!h(this,a,U).call(this,e(this,u)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,a,pt).call(this))e(this,u)[e$1]!==void 0&&!h(this,a,U).call(this,e(this,u)[e$1])&&(yield e(this,u)[e$1]);}*rvalues(){for(let e$1 of h(this,a,ut).call(this))e(this,u)[e$1]!==void 0&&!h(this,a,U).call(this,e(this,u)[e$1])&&(yield e(this,u)[e$1]);}[(re=Symbol.iterator,se=Symbol.toStringTag,re)](){return this.entries()}find(e$1,i={}){for(let s of h(this,a,pt).call(this)){let r=e(this,u)[s],o=h(this,a,U).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e$1(o,e(this,T)[s],this))return this.get(e(this,T)[s],i)}}forEach(e$1,i=this){for(let s of h(this,a,pt).call(this)){let r=e(this,u)[s],o=h(this,a,U).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e$1.call(i,o,e(this,T)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,a,ut).call(this)){let r=e(this,u)[s],o=h(this,a,U).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e$1.call(i,o,e(this,T)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,a,ut).call(this,{allowStale:true}))e(this,$).call(this,i)&&(h(this,a,ft).call(this,e(this,T)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,L).get(e$1);if(i===void 0)return;let s=e(this,u)[i],r=h(this,a,U).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,q)&&e(this,nt)){let n=e(this,q)[i],l=e(this,nt)[i];if(n&&l){let d=n-(e(this,et).now()-l);o.ttl=d,o.start=Date.now();}}return e(this,rt)&&(o.size=e(this,rt)[i]),o}dump(){let e$1=[];for(let i of h(this,a,pt).call(this,{allowStale:true})){let s=e(this,T)[i],r=e(this,u)[i],o=h(this,a,U).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,q)&&e(this,nt)){n.ttl=e(this,q)[i];let l=e(this,et).now()-e(this,nt)[i];n.start=Math.floor(Date.now()-l);}e(this,rt)&&(n.size=e(this,rt)[i]),e$1.unshift([s,n]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let r=Date.now()-s.start;s.start=e(this,et).now()-r;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var lt,k,J,A;if(i$1===void 0)return this.delete(e$1),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:d}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,P=e(this,Pt).call(this,e$1,i$1,s.size||0,l);if(this.maxEntrySize&&P>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),h(this,a,ft).call(this,e$1,"set"),this;let S=e(this,R)===0?void 0:e(this,L).get(e$1);if(S===void 0)S=e(this,R)===0?e(this,I):e(this,st).length!==0?e(this,st).pop():e(this,R)===e(this,X)?h(this,a,Nt).call(this,false):e(this,R),e(this,T)[S]=e$1,e(this,u)[S]=i$1,e(this,L).set(e$1,S),e(this,F)[e(this,I)]=S,e(this,Y)[S]=e(this,I),g(this,I,S),i(this,R)._++,e(this,At).call(this,S,P,d),d&&(d.set="add"),y=false,e(this,Tt)&&((lt=e(this,vt))==null||lt.call(this,i$1,e$1,"add"));else {h(this,a,Lt).call(this,S);let x=e(this,u)[S];if(i$1!==x){if(e(this,gt)&&h(this,a,U).call(this,x)){x.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=x;f!==void 0&&!n&&(e(this,ot)&&((k=e(this,Z))==null||k.call(this,f,e$1,"set")),e(this,M)&&e(this,D)?.push([f,e$1,"set"]));}else n||(e(this,ot)&&((J=e(this,Z))==null||J.call(this,x,e$1,"set")),e(this,M)&&e(this,D)?.push([x,e$1,"set"]));if(e(this,St).call(this,S),e(this,At).call(this,S,P,d),e(this,u)[S]=i$1,d){d.set="replace";let f=x&&h(this,a,U).call(this,x)?x.__staleWhileFetching:x;f!==void 0&&(d.oldValue=f);}}else d&&(d.set="update");e(this,Tt)&&this.onInsert?.(i$1,e$1,i$1===x?"update":"replace");}if(r!==0&&!e(this,q)&&h(this,a,kt).call(this),e(this,q)&&(y||e(this,Rt).call(this,S,r,o),d&&e(this,ht).call(this,d,S)),!n&&e(this,M)&&e(this,D)){let x=e(this,D),f;for(;f=x?.shift();)(A=e(this,tt))==null||A.call(this,...f);}return this}pop(){var e$1;try{for(;e(this,R);){let i=e(this,u)[e(this,j)];if(h(this,a,Nt).call(this,!0),h(this,a,U).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,M)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(e$1=e(this,tt))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,L).get(e$1);if(o!==void 0){let n=e(this,u)[o];if(h(this,a,U).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,$).call(this,o))r&&(r.has="stale",e(this,ht).call(this,r,o));else return s&&e(this,yt).call(this,o),r&&(r.has="hit",e(this,ht).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,L).get(e$1);if(r===void 0||!s&&e(this,$).call(this,r))return;let o=e(this,u)[r];return h(this,a,U).call(this,o)?o.__staleWhileFetching:o}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:d=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:P=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:lt=this.allowStaleOnFetchRejection,ignoreFetchAbort:k=this.ignoreFetchAbort,allowStaleOnFetchAbort:J=this.allowStaleOnFetchAbort,context:A,forceRefresh:x=false,status:f,signal:O}=i;if(!e(this,gt))return f&&(f.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:f});let c={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:l,size:d,sizeCalculation:y,noUpdateTTL:P,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:lt,allowStaleOnFetchAbort:J,ignoreFetchAbort:k,status:f,signal:O},b=e(this,L).get(e$1);if(b===void 0){f&&(f.fetch="miss");let w=h(this,a,Gt).call(this,e$1,b,c,A);return w.__returned=w}else {let w=e(this,u)[b];if(h(this,a,U).call(this,w)){let K=s&&w.__staleWhileFetching!==void 0;return f&&(f.fetch="inflight",K&&(f.returnedStale=true)),K?w.__staleWhileFetching:w.__returned=w}let g=e(this,$).call(this,b);if(!x&&!g)return f&&(f.fetch="hit"),h(this,a,Lt).call(this,b),r&&e(this,yt).call(this,b),f&&e(this,ht).call(this,f,b),w;let E=h(this,a,Gt).call(this,e$1,b,c,A),N=E.__staleWhileFetching!==void 0&&s;return f&&(f.fetch=g?"stale":"refresh",N&&g&&(f.returnedStale=true)),N?E.__staleWhileFetching:E.__returned=E}}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$1,i={}){let s=e(this,Ut);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,l=this.get(e$1,n);if(!o&&l!==void 0)return l;let d=s(e$1,l,{options:n,context:r});return this.set(e$1,d,n),d}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,l=e(this,L).get(e$1);if(l!==void 0){let d=e(this,u)[l],y=h(this,a,U).call(this,d);return n&&e(this,ht).call(this,n,l),e(this,$).call(this,l)?(n&&(n.get="stale"),y?(n&&s&&d.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?d.__staleWhileFetching:void 0):(o||h(this,a,ft).call(this,e$1,"expire"),n&&s&&(n.returnedStale=true),s?d:void 0)):(n&&(n.get="hit"),y?d.__staleWhileFetching:(h(this,a,Lt).call(this,l),r&&e(this,yt).call(this,l),d))}else n&&(n.get="miss");}delete(e){return h(this,a,ft).call(this,e,"delete")}clear(){return h(this,a,Yt).call(this,"delete")}},X=new WeakMap,W=new WeakMap,Z=new WeakMap,vt=new WeakMap,tt=new WeakMap,Et=new WeakMap,Ut=new WeakMap,et=new WeakMap,R=new WeakMap,it=new WeakMap,L=new WeakMap,T=new WeakMap,u=new WeakMap,F=new WeakMap,Y=new WeakMap,j=new WeakMap,I=new WeakMap,st=new WeakMap,D=new WeakMap,rt=new WeakMap,nt=new WeakMap,q=new WeakMap,B=new WeakMap,ot=new WeakMap,gt=new WeakMap,M=new WeakMap,Tt=new WeakMap,a=new WeakSet,kt=function(){let e$1=new Dt(e(this,X)),i=new Dt(e(this,X));g(this,q,e$1),g(this,nt,i);let s=this.ttlAutopurge?new Array(e(this,X)):void 0;g(this,B,s),g(this,Rt,(l,d,y=e(this,et).now())=>{i[l]=d!==0?y:0,e$1[l]=d,r(l,d);}),g(this,yt,l=>{i[l]=e$1[l]!==0?e(this,et).now():0,r(l,e$1[l]);});let r=this.ttlAutopurge?(l,d)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),d&&d!==0&&s){let y=setTimeout(()=>{e(this,$).call(this,l)&&h(this,a,ft).call(this,e(this,T)[l],"expire");},d+1);y.unref&&y.unref(),s[l]=y;}}:()=>{};g(this,ht,(l,d)=>{if(e$1[d]){let y=e$1[d],P=i[d];if(!y||!P)return;l.ttl=y,l.start=P,l.now=o||n();let S=l.now-P;l.remainingTTL=y-S;}});let o=0,n=()=>{let l=e(this,et).now();if(this.ttlResolution>0){o=l;let d=setTimeout(()=>o=0,this.ttlResolution);d.unref&&d.unref();}return l};this.getRemainingTTL=l=>{let d=e(this,L).get(l);if(d===void 0)return 0;let y=e$1[d],P=i[d];if(!y||!P)return 1/0;let S=(o||n())-P;return y-S},g(this,$,l=>{let d=i[l],y=e$1[l];return !!y&&!!d&&(o||n())-d>y});},yt=new WeakMap,ht=new WeakMap,Rt=new WeakMap,$=new WeakMap,he=function(){let e$1=new Dt(e(this,X));g(this,it,0),g(this,rt,e$1),g(this,St,i=>{g(this,it,e(this,it)-e$1[i]),e$1[i]=0;}),g(this,Pt,(i,s,r,o)=>{if(h(this,a,U).call(this,s))return 0;if(!dt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!dt(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}),g(this,At,(i,s,r)=>{if(e$1[i]=s,e(this,W)){let o=e(this,W)-e$1[i];for(;e(this,it)>o;)h(this,a,Nt).call(this,true);}g(this,it,e(this,it)+e$1[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,it));});},St=new WeakMap,At=new WeakMap,Pt=new WeakMap,pt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,R))for(let i=e(this,I);!(!h(this,a,Kt).call(this,i)||((e$1||!e(this,$).call(this,i))&&(yield i),i===e(this,j)));)i=e(this,Y)[i];},ut=function*({allowStale:e$1=this.allowStale}={}){if(e(this,R))for(let i=e(this,j);!(!h(this,a,Kt).call(this,i)||((e$1||!e(this,$).call(this,i))&&(yield i),i===e(this,I)));)i=e(this,F)[i];},Kt=function(e$1){return e$1!==void 0&&e(this,L).get(e(this,T)[e$1])===e$1},Nt=function(e$1){var o;let i$1=e(this,j),s=e(this,T)[i$1],r=e(this,u)[i$1];return e(this,gt)&&h(this,a,U).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,ot)||e(this,M))&&(e(this,ot)&&((o=e(this,Z))==null||o.call(this,r,s,"evict")),e(this,M)&&e(this,D)?.push([r,s,"evict"])),e(this,St).call(this,i$1),e(this,B)?.[i$1]&&(clearTimeout(e(this,B)[i$1]),e(this,B)[i$1]=void 0),e$1&&(e(this,T)[i$1]=void 0,e(this,u)[i$1]=void 0,e(this,st).push(i$1)),e(this,R)===1?(g(this,j,g(this,I,0)),e(this,st).length=0):g(this,j,e(this,F)[i$1]),e(this,L).delete(s),i(this,R)._--,i$1},Gt=function(e$1,i,s,r){let o=i===void 0?void 0:e(this,u)[i];if(h(this,a,U).call(this,o))return o;let n=new jt,{signal:l}=s;l?.addEventListener("abort",()=>n.abort(l.reason),{signal:n.signal});let d={signal:n.signal,options:s,context:r},y=(A,x=false)=>{let{aborted:f}=n.signal,O=s.ignoreFetchAbort&&A!==void 0,c=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&A!==void 0);if(s.status&&(f&&!x?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,O&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),f&&!O&&!x)return S(n.signal.reason,c);let b=k,w=e(this,u)[i];return (w===k||O&&x&&w===void 0)&&(A===void 0?b.__staleWhileFetching!==void 0?e(this,u)[i]=b.__staleWhileFetching:h(this,a,ft).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,A,d.options))),A},P=A=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=A),S(A,false)),S=(A,x)=>{let{aborted:f}=n.signal,O=f&&s.allowStaleOnFetchAbort,c=O||s.allowStaleOnFetchRejection,b=c||s.noDeleteOnFetchRejection,w=k;if(e(this,u)[i]===k&&(!b||!x&&w.__staleWhileFetching===void 0?h(this,a,ft).call(this,e$1,"fetch"):O||(e(this,u)[i]=w.__staleWhileFetching)),c)return s.status&&w.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw A},lt=(A,x)=>{var O;let f=(O=e(this,Et))==null?void 0:O.call(this,e$1,o,d);f&&f instanceof Promise&&f.then(c=>A(c===void 0?void 0:c),x),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(A(void 0),s.allowStaleOnFetchAbort&&(A=c=>y(c,true)));});};s.status&&(s.status.fetchDispatched=true);let k=new Promise(lt).then(y,P),J=Object.assign(k,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e$1,J,{...d.options,status:void 0}),i=e(this,L).get(e$1)):e(this,u)[i]=J,J},U=function(e$1){if(!e(this,gt))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof jt},Wt=function(e$1,i){e(this,Y)[i]=e$1,e(this,F)[e$1]=i;},Lt=function(e$1){e$1!==e(this,I)&&(e$1===e(this,j)?g(this,j,e(this,F)[e$1]):h(this,a,Wt).call(this,e(this,Y)[e$1],e(this,F)[e$1]),h(this,a,Wt).call(this,e(this,I),e$1),g(this,I,e$1));},ft=function(e$1,i$1){var r,o;let s=false;if(e(this,R)!==0){let n=e(this,L).get(e$1);if(n!==void 0)if(e(this,B)?.[n]&&(clearTimeout(e(this,B)?.[n]),e(this,B)[n]=void 0),s=true,e(this,R)===1)h(this,a,Yt).call(this,i$1);else {e(this,St).call(this,n);let l=e(this,u)[n];if(h(this,a,U).call(this,l)?l.__abortController.abort(new Error("deleted")):(e(this,ot)||e(this,M))&&(e(this,ot)&&((r=e(this,Z))==null||r.call(this,l,e$1,i$1)),e(this,M)&&e(this,D)?.push([l,e$1,i$1])),e(this,L).delete(e$1),e(this,T)[n]=void 0,e(this,u)[n]=void 0,n===e(this,I))g(this,I,e(this,Y)[n]);else if(n===e(this,j))g(this,j,e(this,F)[n]);else {let d=e(this,Y)[n];e(this,F)[d]=e(this,F)[n];let y=e(this,F)[n];e(this,Y)[y]=e(this,Y)[n];}i(this,R)._--,e(this,st).push(n);}}if(e(this,M)&&e(this,D)?.length){let n=e(this,D),l;for(;l=n?.shift();)(o=e(this,tt))==null||o.call(this,...l);}return s},Yt=function(e$1){var i,s;for(let r of h(this,a,ut).call(this,{allowStale:true})){let o=e(this,u)[r];if(h(this,a,U).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,T)[r];e(this,ot)&&((i=e(this,Z))==null||i.call(this,o,n,e$1)),e(this,M)&&e(this,D)?.push([o,n,e$1]);}}if(e(this,L).clear(),e(this,u).fill(void 0),e(this,T).fill(void 0),e(this,q)&&e(this,nt)){e(this,q).fill(0),e(this,nt).fill(0);for(let r of e(this,B)??[])r!==void 0&&clearTimeout(r);e(this,B)?.fill(void 0);}if(e(this,rt)&&e(this,rt).fill(0),g(this,j,0),g(this,I,0),e(this,st).length=0,g(this,it,0),g(this,R,0),e(this,M)&&e(this,D)){let r=e(this,D),o;for(;o=r?.shift();)(s=e(this,tt))==null||s.call(this,...o);}},Ot);var Ft=class{cache;map=new Map;constructor(e){this.cache=new le({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ct="1.9.1";var qt={version:Ct};var Bt="__game_layer__";var we={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var de={};var $t={};b($t,{createExportableElement:()=>pe});var bt;(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)))(bt||={});function pe(_){try{if(typeof _>"u")return _;let e=JSON.stringify(_);return JSON.parse(e)}catch(e){throw bt.error("Error creating exportable element",_,e),new PixiError("not_json_serializable","Error creating exportable element")}}var Ee=typeof window<"u"&&typeof document<"u",ue=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${qt.version}`],fe=31,Ue="background:#2f90da;color:#fff;font-weight:bold;",Te="background:#c832bb;color:#fff;font-weight:bold;",Ae="background:transparent;font-weight:bold;",Xt=` v${qt.version}`;function ge(){if(!Ee)return;let _=[],e=[];for(let i=0;i<ue.length;i++){let s=ue[i],r=s.endsWith(Xt),o=r?s.slice(0,-Xt.length):s,n=o.slice(0,fe),l=o.slice(fe),d=r?"%c%s%c%s%c%s":"%c%s%c%s";_.push(d),e.push(Ue,n,Te,l),r&&e.push(Ae,Xt);}console.info(_.join(`
2
- `),...e);}function Jt(){let _=window.location.pathname+window.location.hash;return _.includes("#")&&(_=_.split("#")[1]),_}ge();var me;(O=>{async function _(c,b,w){if(GameUnifier.init({navigate:b?.navigate,getCurrentGameStepState:()=>{let g=V.canvas.isInitialized?V.canvas.export():{};return {path:Jt(),storage:z.storage.export(),canvas:g,sound:mt.sound.export(),labelIndex:m.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:m.narration.openedLabels}},restoreGameStepState:async(g,E)=>{H.HistoryManagerStatic._originalStepData=g,m.NarrationManagerStatic.openedLabels=g.openedLabels,z.storage.restore(g.storage);try{V.canvas.isInitialized&&await V.canvas.restore(g.canvas),await mt.sound.restore(g.sound);}catch(N){bt.error("Error restoring game step state:",N);}await E(g.path);},getStepCounter:()=>m.narration.stepCounter,setStepCounter:g=>{m.NarrationManagerStatic._stepCounter=g;},getOpenedLabels:()=>m.narration.openedLabels.length,addHistoryItem:(g,E)=>H.stepHistory.add(g,E),getCharacter:g=>Qt.RegisteredCharacters.get(g),processNavigationRequests:(g,E)=>{let N=g,K=Promise.resolve();return g>0?(N--,K=m.narration.continue(E)):g<0&&(N=0,K=H.stepHistory.back(E,{steps:g*-1})),{newValue:N,result:K}},animate:(g,E,N,K)=>motion.animate(g,E,N,K),getVariable:(g,E)=>z.StorageRegistry.getVariable(g,E),setVariable:(g,E,N)=>z.StorageRegistry.setVariable(g,E,N),removeVariable:(g,E)=>z.StorageRegistry.removeVariable(g,E),getFlag:g=>z.storage.flags.get(g),setFlag:(g,E)=>z.storage.flags.set(g,E),onLabelClosing:g=>z.StorageRegistry.clearOldTempVariables(g)}),!c||!b){bt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await V.canvas.init(c,b,w)}O.init=_;function e(){z.storage.clear(),V.canvas.isInitialized&&V.canvas.clear(),mt.sound.clear(),m.narration.clear(),H.stepHistory.clear();}O.clear=e;function i(){let c=V.canvas.isInitialized?V.canvas.export():{};return {pixivn_version:Ct,stepData:m.narration.export(),storageData:z.storage.export(),canvasData:c,soundData:mt.sound.export(),historyData:H.stepHistory.export(),path:Jt()}}O.exportGameState=i;async function s(c){H.stepHistory.restore(c.historyData);let b=H.stepHistory.lastKey;if(typeof b=="number"){let w=H.stepHistory.stepsInfoMap.get(b)||null;await m.narration.restore(c.stepData,w);}z.storage.restore(c.storageData);try{V.canvas.isInitialized&&await V.canvas.restore(c.canvasData),await mt.sound.restore(c.soundData);}catch{}await GameUnifier.navigate(c.path);}O.restoreGameState=s;async function r(c,b){return O.clear(),await m.narration.call(c,b)}O.start=r;function o(c){return JSON.parse(c)}O.jsonToGameState=o;function n(c){GameUnifier.onEnd=c;}O.onEnd=n;function l(c){return GameUnifier.addOnError(c)}O.addOnError=l;function d(c){return GameUnifier.removeOnError(c)}O.removeOnError=d;function y(c){m.NarrationManagerStatic.onStepStart=c;}O.onStepStart=y;function P(c){m.NarrationManagerStatic.onLoadingLabel=c;}O.onLoadingLabel=P;function S(c){m.NarrationManagerStatic.onStepEnd=c;}O.onStepEnd=S;function lt(c){m.NarrationManagerStatic.onLabelStarting=c;}O.onLabelStarting=lt;function k(c){m.NarrationManagerStatic.onLabelClosing=c;}O.onLabelClosing=k;function J(c){GameUnifier.navigate=c;}O.onNavigate=J;function A(c){return GameUnifier.addOnPreContinue(c)}O.addOnPreContinue=A;function x(c){return GameUnifier.removeOnPreContinue(c)}O.removeOnPreContinue=x;(K=>{let c,b={};function w(_t){b=_t;}K.setProps=w;function g(_t){c&&E();let Zt=_t?.windowKey??"pixiVN",Mt=[],wt=C=>({...b,...C}),zt={Game:O,narration:m.narration,storage:z.storage,stepHistory:H.stepHistory,get props(){return b},start:(C,Q)=>O.start(C,wt(Q)),continue:(C,Q)=>m.narration.continue(wt(C),Q),call:(C,Q)=>m.narration.call(C,wt(Q)),jump:(C,Q)=>m.narration.jump(C,wt(Q)),selectChoice:(C,Q)=>{let ee=m.narration.choices.list?.find(Vt=>Vt.choiceIndex===C);if(!ee){let Vt=m.narration.choices.list?.map(_e=>_e.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${C}. Available: ${Vt}`)}return m.narration.choices.select(ee,wt(Q))},setInput:C=>{m.narration.input.value=C;},goBack:(C,Q)=>H.stepHistory.back(wt(C),Q),closeCurrentLabel:()=>m.narration.labels.closeCurrent(),closeAllLabels:()=>m.narration.labels.closeAll(),getState:()=>({dialogue:m.narration.dialogue,dialogueGlue:m.narration.dialogGlue,choices:m.narration.choices.list,input:{isRequired:m.narration.input.isRequired,type:m.narration.input.type,value:m.narration.input.value},canContinue:m.narration.canContinue,canGoBack:H.stepHistory.canGoBack,labelsOpened:m.narration.labels.opened,currentLabelId:m.narration.labels.current?.id,stepCounter:m.narration.stepCounter}),get errors(){return Mt.slice()},clearErrors:()=>{Mt.length=0;}},te=C=>{Mt.push({error:C,timestamp:Date.now()});};return O.addOnError(te),typeof window<"u"?window[Zt]=zt:bt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),c={api:zt,windowKey:Zt,errorHandler:te},zt}K.enable=g;function E(){c&&(O.removeOnError(c.errorHandler),typeof window<"u"&&window[c.windowKey]===c.api&&delete window[c.windowKey],c=void 0);}K.disable=E;function N(){return c!==void 0}K.isEnabled=N;})(O.testing||={});})(me||={});var ii={characterUtils:Qt,canvasUtils:V,narrationUtils:m,soundUtils:mt,CANVAS_APP_GAME_LAYER_ALIAS:Bt,PIXIVN_VERSION:Ct,...$t,...de,canvas:V.canvas,narration:m.narration,sound:mt.sound,storage:z.storage,history:H.stepHistory,Game:me,GameUnifier:GameUnifier};export{Bt as CANVAS_APP_GAME_LAYER_ALIAS,Ft as CachedMap,me as Game,Ct as PIXIVN_VERSION,we as SYSTEM_RESERVED_STORAGE_KEYS,pe as createExportableElement,ii as default};
1
+ import {f,b,g,e,d,h,i}from'./chunk-K7JIC2F2.mjs';import*as k from'@drincs/pixi-vn/canvas';export*from'@drincs/pixi-vn/canvas';import*as Bt from'@drincs/pixi-vn/characters';export*from'@drincs/pixi-vn/characters';import {PixiError,GameUnifier}from'@drincs/pixi-vn/core';export*from'@drincs/pixi-vn/core';import*as ot from'@drincs/pixi-vn/history';export*from'@drincs/pixi-vn/history';import*as L from'@drincs/pixi-vn/narration';export*from'@drincs/pixi-vn/narration';import*as gt from'@drincs/pixi-vn/sound';export*from'@drincs/pixi-vn/sound';import*as K from'@drincs/pixi-vn/storage';export*from'@drincs/pixi-vn/storage';import {motion}from'@drincs/pixi-vn/motion';var ue=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Qt=new Set,Ft=typeof process=="object"&&process?process:{},Zt=(g,e,i,s)=>{typeof Ft.emitWarning=="function"?Ft.emitWarning(g,e,i,s):console.error(`[${i}] ${e}: ${g}`);},Gt=globalThis.AbortController,$t=globalThis.AbortSignal;if(typeof Gt>"u"){$t=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new $t;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let g=Ft.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{g&&(g=false,Zt("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 fe=g=>!Qt.has(g);var ct=g=>g&&g===Math.floor(g)&&g>0&&isFinite(g),te=g=>ct(g)?g<=Math.pow(2,8)?Uint8Array:g<=Math.pow(2,16)?Uint16Array:g<=Math.pow(2,32)?Uint32Array:g<=Number.MAX_SAFE_INTEGER?Pt:null:null,Pt=class extends Array{constructor(g){super(g),this.fill(0);}},at,bt,me=(at=class{heap;length;static create(e){let i=te(e);if(!i)return [];g(at,bt,true);let s=new at(e,i);return g(at,bt,false),s}constructor(e$1,i){if(!e(at,bt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},bt=new WeakMap,f(at,bt,false),at),Xt,Jt,J,W,Q,_t,Z,St,Tt,tt,I,et,R,x,m,z,Y,M,C,it,G,st,rt,q,B,nt,ft,V,wt,a,Mt,vt,lt,At,$,ie,yt,xt,Ot,dt,pt,zt,It,Ct,w,Vt,Ut,ut,Ht,Et,ee=(Et=class{constructor(e$1){f(this,a);f(this,J);f(this,W);f(this,Q);f(this,_t);f(this,Z);f(this,St);f(this,Tt);f(this,tt);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f(this,I);f(this,et);f(this,R);f(this,x);f(this,m);f(this,z);f(this,Y);f(this,M);f(this,C);f(this,it);f(this,G);f(this,st);f(this,rt);f(this,q);f(this,B);f(this,nt);f(this,ft);f(this,V);f(this,wt);f(this,vt,()=>{});f(this,lt,()=>{});f(this,At,()=>{});f(this,$,()=>false);f(this,yt,e=>{});f(this,xt,(e,i,s)=>{});f(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Xt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:l,allowStale:c,dispose:y,onInsert:O,disposeAfter:S,noDisposeOnSet:j,noUpdateTTL:D,maxSize:H=0,maxEntrySize:u=0,sizeCalculation:_,fetchMethod:f$1,memoMethod:U,noDeleteOnFetchRejection:d$1,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:T,allowStaleOnFetchAbort:v,ignoreFetchAbort:A,perf:F}=e$1;if(F!==void 0&&typeof F?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,tt,F??ue),i!==0&&!ct(i))throw new TypeError("max option must be a nonnegative integer");let X=i?te(i):Array;if(!X)throw new Error("invalid max value: "+i);if(g(this,J,i),g(this,W,H),this.maxEntrySize=u||e(this,W),this.sizeCalculation=_,this.sizeCalculation){if(!e(this,W)&&!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(U!==void 0&&typeof U!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,Tt,U),f$1!==void 0&&typeof f$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,St,f$1),g(this,ft,!!f$1),g(this,R,new Map),g(this,x,new Array(i).fill(void 0)),g(this,m,new Array(i).fill(void 0)),g(this,z,new X(i)),g(this,Y,new X(i)),g(this,M,0),g(this,C,0),g(this,it,me.create(i)),g(this,I,0),g(this,et,0),typeof y=="function"&&g(this,Q,y),typeof O=="function"&&g(this,_t,O),typeof S=="function"?(g(this,Z,S),g(this,G,[])):(g(this,Z,void 0),g(this,G,void 0)),g(this,nt,!!e(this,Q)),g(this,wt,!!e(this,_t)),g(this,V,!!e(this,Z)),this.noDisposeOnSet=!!j,this.noUpdateTTL=!!D,this.noDeleteOnFetchRejection=!!d$1,this.allowStaleOnFetchRejection=!!T,this.allowStaleOnFetchAbort=!!v,this.ignoreFetchAbort=!!A,this.maxEntrySize!==0){if(e(this,W)!==0&&!ct(e(this,W)))throw new TypeError("maxSize must be a positive integer if specified");if(!ct(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,a,ie).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!l,this.ttlResolution=ct(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!ct(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,a,Mt).call(this);}if(e(this,J)===0&&this.ttl===0&&e(this,W)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,J)&&!e(this,W)){let jt="LRU_CACHE_UNBOUNDED";fe(jt)&&(Qt.add(jt),Zt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",jt,Et));}}get perf(){return e(this,tt)}static unsafeExposeInternals(e$1){return {starts:e(e$1,rt),ttls:e(e$1,q),autopurgeTimers:e(e$1,B),sizes:e(e$1,st),keyMap:e(e$1,R),keyList:e(e$1,x),valList:e(e$1,m),next:e(e$1,z),prev:e(e$1,Y),get head(){return e(e$1,M)},get tail(){return e(e$1,C)},free:e(e$1,it),isBackgroundFetch:i=>{var s;return h(s=e$1,a,w).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return h(n=e$1,a,Ct).call(n,i,s,r,o)},moveToTail:i=>{var s;return h(s=e$1,a,Ut).call(s,i)},indexes:i=>{var s;return h(s=e$1,a,dt).call(s,i)},rindexes:i=>{var s;return h(s=e$1,a,pt).call(s,i)},isStale:i=>{var s;return e(s=e$1,$).call(s,i)}}}get max(){return e(this,J)}get maxSize(){return e(this,W)}get calculatedSize(){return e(this,et)}get size(){return e(this,I)}get fetchMethod(){return e(this,St)}get memoMethod(){return e(this,Tt)}get dispose(){return e(this,Q)}get onInsert(){return e(this,_t)}get disposeAfter(){return e(this,Z)}getRemainingTTL(e$1){return e(this,R).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,a,dt).call(this))e(this,m)[e$1]!==void 0&&e(this,x)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield [e(this,x)[e$1],e(this,m)[e$1]]);}*rentries(){for(let e$1 of h(this,a,pt).call(this))e(this,m)[e$1]!==void 0&&e(this,x)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield [e(this,x)[e$1],e(this,m)[e$1]]);}*keys(){for(let e$1 of h(this,a,dt).call(this)){let i=e(this,x)[e$1];i!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,a,pt).call(this)){let i=e(this,x)[e$1];i!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,a,dt).call(this))e(this,m)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield e(this,m)[e$1]);}*rvalues(){for(let e$1 of h(this,a,pt).call(this))e(this,m)[e$1]!==void 0&&!h(this,a,w).call(this,e(this,m)[e$1])&&(yield e(this,m)[e$1]);}[(Jt=Symbol.iterator,Xt=Symbol.toStringTag,Jt)](){return this.entries()}find(e$1,i={}){for(let s of h(this,a,dt).call(this)){let r=e(this,m)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e$1(o,e(this,x)[s],this))return this.get(e(this,x)[s],i)}}forEach(e$1,i=this){for(let s of h(this,a,dt).call(this)){let r=e(this,m)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e$1.call(i,o,e(this,x)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,a,pt).call(this)){let r=e(this,m)[s],o=h(this,a,w).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e$1.call(i,o,e(this,x)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,a,pt).call(this,{allowStale:true}))e(this,$).call(this,i)&&(h(this,a,ut).call(this,e(this,x)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,R).get(e$1);if(i===void 0)return;let s=e(this,m)[i],r=h(this,a,w).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,q)&&e(this,rt)){let n=e(this,q)[i],l=e(this,rt)[i];if(n&&l){let c=n-(e(this,tt).now()-l);o.ttl=c,o.start=Date.now();}}return e(this,st)&&(o.size=e(this,st)[i]),o}dump(){let e$1=[];for(let i of h(this,a,dt).call(this,{allowStale:true})){let s=e(this,x)[i],r=e(this,m)[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(e(this,q)&&e(this,rt)){n.ttl=e(this,q)[i];let l=e(this,tt).now()-e(this,rt)[i];n.start=Math.floor(Date.now()-l);}e(this,st)&&(n.size=e(this,st)[i]),e$1.unshift([s,n]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let r=Date.now()-s.start;s.start=e(this,tt).now()-r;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var j,D,H,u;if(i$1===void 0)return this.delete(e$1),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=s,{noUpdateTTL:y=this.noUpdateTTL}=s,O=e(this,Ot).call(this,e$1,i$1,s.size||0,l);if(this.maxEntrySize&&O>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),h(this,a,ut).call(this,e$1,"set"),this;let S=e(this,I)===0?void 0:e(this,R).get(e$1);if(S===void 0)S=e(this,I)===0?e(this,C):e(this,it).length!==0?e(this,it).pop():e(this,I)===e(this,J)?h(this,a,It).call(this,false):e(this,I),e(this,x)[S]=e$1,e(this,m)[S]=i$1,e(this,R).set(e$1,S),e(this,z)[e(this,C)]=S,e(this,Y)[S]=e(this,C),g(this,C,S),i(this,I)._++,e(this,xt).call(this,S,O,c),c&&(c.set="add"),y=false,e(this,wt)&&((j=e(this,_t))==null||j.call(this,i$1,e$1,"add"));else {h(this,a,Ut).call(this,S);let _=e(this,m)[S];if(i$1!==_){if(e(this,ft)&&h(this,a,w).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=_;f!==void 0&&!n&&(e(this,nt)&&((D=e(this,Q))==null||D.call(this,f,e$1,"set")),e(this,V)&&e(this,G)?.push([f,e$1,"set"]));}else n||(e(this,nt)&&((H=e(this,Q))==null||H.call(this,_,e$1,"set")),e(this,V)&&e(this,G)?.push([_,e$1,"set"]));if(e(this,yt).call(this,S),e(this,xt).call(this,S,O,c),e(this,m)[S]=i$1,c){c.set="replace";let f=_&&h(this,a,w).call(this,_)?_.__staleWhileFetching:_;f!==void 0&&(c.oldValue=f);}}else c&&(c.set="update");e(this,wt)&&this.onInsert?.(i$1,e$1,i$1===_?"update":"replace");}if(r!==0&&!e(this,q)&&h(this,a,Mt).call(this),e(this,q)&&(y||e(this,At).call(this,S,r,o),c&&e(this,lt).call(this,c,S)),!n&&e(this,V)&&e(this,G)){let _=e(this,G),f;for(;f=_?.shift();)(u=e(this,Z))==null||u.call(this,...f);}return this}pop(){var e$1;try{for(;e(this,I);){let i=e(this,m)[e(this,M)];if(h(this,a,It).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(e(this,V)&&e(this,G)){let i=e(this,G),s;for(;s=i?.shift();)(e$1=e(this,Z))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,R).get(e$1);if(o!==void 0){let n=e(this,m)[o];if(h(this,a,w).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,$).call(this,o))r&&(r.has="stale",e(this,lt).call(this,r,o));else return s&&e(this,vt).call(this,o),r&&(r.has="hit",e(this,lt).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,R).get(e$1);if(r===void 0||!s&&e(this,$).call(this,r))return;let o=e(this,m)[r];return h(this,a,w).call(this,o)?o.__staleWhileFetching:o}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:O=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:j=this.allowStaleOnFetchRejection,ignoreFetchAbort:D=this.ignoreFetchAbort,allowStaleOnFetchAbort:H=this.allowStaleOnFetchAbort,context:u,forceRefresh:_=false,status:f,signal:U}=i;if(!e(this,ft))return f&&(f.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:f});let d={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:l,size:c,sizeCalculation:y,noUpdateTTL:O,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:j,allowStaleOnFetchAbort:H,ignoreFetchAbort:D,status:f,signal:U},E=e(this,R).get(e$1);if(E===void 0){f&&(f.fetch="miss");let T=h(this,a,Ct).call(this,e$1,E,d,u);return T.__returned=T}else {let T=e(this,m)[E];if(h(this,a,w).call(this,T)){let X=s&&T.__staleWhileFetching!==void 0;return f&&(f.fetch="inflight",X&&(f.returnedStale=true)),X?T.__staleWhileFetching:T.__returned=T}let v=e(this,$).call(this,E);if(!_&&!v)return f&&(f.fetch="hit"),h(this,a,Ut).call(this,E),r&&e(this,vt).call(this,E),f&&e(this,lt).call(this,f,E),T;let A=h(this,a,Ct).call(this,e$1,E,d,u),F=A.__staleWhileFetching!==void 0&&s;return f&&(f.fetch=v?"stale":"refresh",F&&v&&(f.returnedStale=true)),F?A.__staleWhileFetching:A.__returned=A}}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$1,i={}){let s=e(this,Tt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,l=this.get(e$1,n);if(!o&&l!==void 0)return l;let c=s(e$1,l,{options:n,context:r});return this.set(e$1,c,n),c}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,l=e(this,R).get(e$1);if(l!==void 0){let c=e(this,m)[l],y=h(this,a,w).call(this,c);return n&&e(this,lt).call(this,n,l),e(this,$).call(this,l)?(n&&(n.get="stale"),y?(n&&s&&c.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||h(this,a,ut).call(this,e$1,"expire"),n&&s&&(n.returnedStale=true),s?c:void 0)):(n&&(n.get="hit"),y?c.__staleWhileFetching:(h(this,a,Ut).call(this,l),r&&e(this,vt).call(this,l),c))}else n&&(n.get="miss");}delete(e){return h(this,a,ut).call(this,e,"delete")}clear(){return h(this,a,Ht).call(this,"delete")}},J=new WeakMap,W=new WeakMap,Q=new WeakMap,_t=new WeakMap,Z=new WeakMap,St=new WeakMap,Tt=new WeakMap,tt=new WeakMap,I=new WeakMap,et=new WeakMap,R=new WeakMap,x=new WeakMap,m=new WeakMap,z=new WeakMap,Y=new WeakMap,M=new WeakMap,C=new WeakMap,it=new WeakMap,G=new WeakMap,st=new WeakMap,rt=new WeakMap,q=new WeakMap,B=new WeakMap,nt=new WeakMap,ft=new WeakMap,V=new WeakMap,wt=new WeakMap,a=new WeakSet,Mt=function(){let e$1=new Pt(e(this,J)),i=new Pt(e(this,J));g(this,q,e$1),g(this,rt,i);let s=this.ttlAutopurge?new Array(e(this,J)):void 0;g(this,B,s),g(this,At,(l,c,y=e(this,tt).now())=>{i[l]=c!==0?y:0,e$1[l]=c,r(l,c);}),g(this,vt,l=>{i[l]=e$1[l]!==0?e(this,tt).now():0,r(l,e$1[l]);});let r=this.ttlAutopurge?(l,c)=>{if(s?.[l]&&(clearTimeout(s[l]),s[l]=void 0),c&&c!==0&&s){let y=setTimeout(()=>{e(this,$).call(this,l)&&h(this,a,ut).call(this,e(this,x)[l],"expire");},c+1);y.unref&&y.unref(),s[l]=y;}}:()=>{};g(this,lt,(l,c)=>{if(e$1[c]){let y=e$1[c],O=i[c];if(!y||!O)return;l.ttl=y,l.start=O,l.now=o||n();let S=l.now-O;l.remainingTTL=y-S;}});let o=0,n=()=>{let l=e(this,tt).now();if(this.ttlResolution>0){o=l;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return l};this.getRemainingTTL=l=>{let c=e(this,R).get(l);if(c===void 0)return 0;let y=e$1[c],O=i[c];if(!y||!O)return 1/0;let S=(o||n())-O;return y-S},g(this,$,l=>{let c=i[l],y=e$1[l];return !!y&&!!c&&(o||n())-c>y});},vt=new WeakMap,lt=new WeakMap,At=new WeakMap,$=new WeakMap,ie=function(){let e$1=new Pt(e(this,J));g(this,et,0),g(this,st,e$1),g(this,yt,i=>{g(this,et,e(this,et)-e$1[i]),e$1[i]=0;}),g(this,Ot,(i,s,r,o)=>{if(h(this,a,w).call(this,s))return 0;if(!ct(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!ct(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}),g(this,xt,(i,s,r)=>{if(e$1[i]=s,e(this,W)){let o=e(this,W)-e$1[i];for(;e(this,et)>o;)h(this,a,It).call(this,true);}g(this,et,e(this,et)+e$1[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,et));});},yt=new WeakMap,xt=new WeakMap,Ot=new WeakMap,dt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,I))for(let i=e(this,C);!(!h(this,a,zt).call(this,i)||((e$1||!e(this,$).call(this,i))&&(yield i),i===e(this,M)));)i=e(this,Y)[i];},pt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,I))for(let i=e(this,M);!(!h(this,a,zt).call(this,i)||((e$1||!e(this,$).call(this,i))&&(yield i),i===e(this,C)));)i=e(this,z)[i];},zt=function(e$1){return e$1!==void 0&&e(this,R).get(e(this,x)[e$1])===e$1},It=function(e$1){var o;let i$1=e(this,M),s=e(this,x)[i$1],r=e(this,m)[i$1];return e(this,ft)&&h(this,a,w).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,nt)||e(this,V))&&(e(this,nt)&&((o=e(this,Q))==null||o.call(this,r,s,"evict")),e(this,V)&&e(this,G)?.push([r,s,"evict"])),e(this,yt).call(this,i$1),e(this,B)?.[i$1]&&(clearTimeout(e(this,B)[i$1]),e(this,B)[i$1]=void 0),e$1&&(e(this,x)[i$1]=void 0,e(this,m)[i$1]=void 0,e(this,it).push(i$1)),e(this,I)===1?(g(this,M,g(this,C,0)),e(this,it).length=0):g(this,M,e(this,z)[i$1]),e(this,R).delete(s),i(this,I)._--,i$1},Ct=function(e$1,i,s,r){let o=i===void 0?void 0:e(this,m)[i];if(h(this,a,w).call(this,o))return o;let n=new Gt,{signal:l}=s;l?.addEventListener("abort",()=>n.abort(l.reason),{signal:n.signal});let c={signal:n.signal,options:s,context:r},y=(u,_=false)=>{let{aborted:f}=n.signal,U=s.ignoreFetchAbort&&u!==void 0,d=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&u!==void 0);if(s.status&&(f&&!_?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,U&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),f&&!U&&!_)return S(n.signal.reason,d);let E=D,T=e(this,m)[i];return (T===D||U&&_&&T===void 0)&&(u===void 0?E.__staleWhileFetching!==void 0?e(this,m)[i]=E.__staleWhileFetching:h(this,a,ut).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,u,c.options))),u},O=u=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=u),S(u,false)),S=(u,_)=>{let{aborted:f}=n.signal,U=f&&s.allowStaleOnFetchAbort,d=U||s.allowStaleOnFetchRejection,E=d||s.noDeleteOnFetchRejection,T=D;if(e(this,m)[i]===D&&(!E||!_&&T.__staleWhileFetching===void 0?h(this,a,ut).call(this,e$1,"fetch"):U||(e(this,m)[i]=T.__staleWhileFetching)),d)return s.status&&T.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),T.__staleWhileFetching;if(T.__returned===T)throw u},j=(u,_)=>{var U;let f=(U=e(this,St))==null?void 0:U.call(this,e$1,o,c);f&&f instanceof Promise&&f.then(d=>u(d===void 0?void 0:d),_),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(u(void 0),s.allowStaleOnFetchAbort&&(u=d=>y(d,true)));});};s.status&&(s.status.fetchDispatched=true);let D=new Promise(j).then(y,O),H=Object.assign(D,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e$1,H,{...c.options,status:void 0}),i=e(this,R).get(e$1)):e(this,m)[i]=H,H},w=function(e$1){if(!e(this,ft))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Vt=function(e$1,i){e(this,Y)[i]=e$1,e(this,z)[e$1]=i;},Ut=function(e$1){e$1!==e(this,C)&&(e$1===e(this,M)?g(this,M,e(this,z)[e$1]):h(this,a,Vt).call(this,e(this,Y)[e$1],e(this,z)[e$1]),h(this,a,Vt).call(this,e(this,C),e$1),g(this,C,e$1));},ut=function(e$1,i$1){var r,o;let s=false;if(e(this,I)!==0){let n=e(this,R).get(e$1);if(n!==void 0)if(e(this,B)?.[n]&&(clearTimeout(e(this,B)?.[n]),e(this,B)[n]=void 0),s=true,e(this,I)===1)h(this,a,Ht).call(this,i$1);else {e(this,yt).call(this,n);let l=e(this,m)[n];if(h(this,a,w).call(this,l)?l.__abortController.abort(new Error("deleted")):(e(this,nt)||e(this,V))&&(e(this,nt)&&((r=e(this,Q))==null||r.call(this,l,e$1,i$1)),e(this,V)&&e(this,G)?.push([l,e$1,i$1])),e(this,R).delete(e$1),e(this,x)[n]=void 0,e(this,m)[n]=void 0,n===e(this,C))g(this,C,e(this,Y)[n]);else if(n===e(this,M))g(this,M,e(this,z)[n]);else {let c=e(this,Y)[n];e(this,z)[c]=e(this,z)[n];let y=e(this,z)[n];e(this,Y)[y]=e(this,Y)[n];}i(this,I)._--,e(this,it).push(n);}}if(e(this,V)&&e(this,G)?.length){let n=e(this,G),l;for(;l=n?.shift();)(o=e(this,Z))==null||o.call(this,...l);}return s},Ht=function(e$1){var i,s;for(let r of h(this,a,pt).call(this,{allowStale:true})){let o=e(this,m)[r];if(h(this,a,w).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,x)[r];e(this,nt)&&((i=e(this,Q))==null||i.call(this,o,n,e$1)),e(this,V)&&e(this,G)?.push([o,n,e$1]);}}if(e(this,R).clear(),e(this,m).fill(void 0),e(this,x).fill(void 0),e(this,q)&&e(this,rt)){e(this,q).fill(0),e(this,rt).fill(0);for(let r of e(this,B)??[])r!==void 0&&clearTimeout(r);e(this,B)?.fill(void 0);}if(e(this,st)&&e(this,st).fill(0),g(this,M,0),g(this,C,0),e(this,it).length=0,g(this,et,0),g(this,I,0),e(this,V)&&e(this,G)){let r=e(this,G),o;for(;o=r?.shift();)(s=e(this,Z))==null||s.call(this,...o);}},Et);var Dt=class{cache;map=new Map;constructor(e){this.cache=new ee({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Lt="1.9.2";var kt={version:Lt};var Kt="__game_layer__";var ge={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var re={};var Wt={};b(Wt,{createExportableElement:()=>ne});var mt;(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)))(mt||={});function ne(g){try{if(typeof g>"u")return g;let e=JSON.stringify(g);return JSON.parse(e)}catch(e){throw mt.error("Error creating exportable element",g,e),new PixiError("not_json_serializable","Error creating exportable element")}}function ae(g){let e,i={},s={};function r(y){i=y;}function o(y){s=y;}function n(y){e&&l();let O=y?.windowKey??"pixiVN",S=[],j=u=>({...i,...u}),D={Game:g,narration:L.narration,storage:K.storage,stepHistory:ot.stepHistory,get props(){return i},start:(u,_)=>s.start?s.start(u,_):g.start(u,j(_)),continue:(u,_)=>s.continue?s.continue():L.narration.continue(j(u),_),call:(u,_)=>s.call?s.call(u,_):L.narration.call(u,j(_)),jump:(u,_)=>s.jump?s.jump(u,_):L.narration.jump(u,j(_)),selectChoice:(u,_)=>{let f=L.narration.choices.list?.find(U=>U.choiceIndex===u);if(!f){let U=L.narration.choices.list?.map(d=>d.choiceIndex).join(", ")??"none (no choice menu is open)";throw new Error(`Game.testing: no open choice with index ${u}. Available: ${U}`)}return s.selectChoice?s.selectChoice(f):L.narration.choices.select(f,j(_))},setInput:u=>{L.narration.input.value=u;},goBack:(u,_)=>s.back?s.back():ot.stepHistory.back(j(u),_),closeCurrentLabel:()=>L.narration.labels.closeCurrent(),closeAllLabels:()=>L.narration.labels.closeAll(),getState:()=>({dialogue:L.narration.dialogue,dialogueGlue:L.narration.dialogGlue,choices:L.narration.choices.list,input:{isRequired:L.narration.input.isRequired,type:L.narration.input.type,value:L.narration.input.value},canContinue:L.narration.canContinue,canGoBack:ot.stepHistory.canGoBack,labelsOpened:L.narration.labels.opened,currentLabelId:L.narration.labels.current?.id,stepCounter:L.narration.stepCounter}),get errors(){return S.slice()},clearErrors:()=>{S.length=0;}},H=u=>{S.push({error:u,timestamp:Date.now()});};return g.addOnError(H),typeof window<"u"?window[O]=D:mt.warn('Game.testing.enable(): "window" is not defined, so the API was not attached globally (it was still returned).'),e={api:D,windowKey:O,errorHandler:H},D}function l(){e&&(g.removeOnError(e.errorHandler),typeof window<"u"&&window[e.windowKey]===e.api&&delete window[e.windowKey],e=void 0);}function c(){return e!==void 0}return {setProps:r,setActions:o,enable:n,disable:l,isEnabled:c}}var ve=typeof window<"u"&&typeof document<"u",le=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${kt.version}`],he=31,ye="background:#2f90da;color:#fff;font-weight:bold;",be="background:#c832bb;color:#fff;font-weight:bold;",Se="background:transparent;font-weight:bold;",Yt=` v${kt.version}`;function ce(){if(!ve)return;let g=[],e=[];for(let i=0;i<le.length;i++){let s=le[i],r=s.endsWith(Yt),o=r?s.slice(0,-Yt.length):s,n=o.slice(0,he),l=o.slice(he),c=r?"%c%s%c%s%c%s":"%c%s%c%s";g.push(c),e.push(ye,n,be,l),r&&e.push(Se,Yt);}console.info(g.join(`
2
+ `),...e);}function qt(){let g=window.location.pathname+window.location.hash;return g.includes("#")&&(g=g.split("#")[1]),g}ce();var de;(U=>{async function g(d,E,T){if(GameUnifier.init({navigate:E?.navigate,getCurrentGameStepState:()=>{let v=k.canvas.isInitialized?k.canvas.export():{};return {path:qt(),storage:K.storage.export(),canvas:v,sound:gt.sound.export(),labelIndex:L.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:L.narration.openedLabels}},restoreGameStepState:async(v,A)=>{ot.HistoryManagerStatic._originalStepData=v,L.NarrationManagerStatic.openedLabels=v.openedLabels,K.storage.restore(v.storage);try{k.canvas.isInitialized&&await k.canvas.restore(v.canvas),await gt.sound.restore(v.sound);}catch(F){mt.error("Error restoring game step state:",F);}await A(v.path);},getStepCounter:()=>L.narration.stepCounter,setStepCounter:v=>{L.NarrationManagerStatic._stepCounter=v;},getOpenedLabels:()=>L.narration.openedLabels.length,addHistoryItem:(v,A)=>ot.stepHistory.add(v,A),getCharacter:v=>Bt.RegisteredCharacters.get(v),processNavigationRequests:(v,A)=>{let F=v,X=Promise.resolve();return v>0?(F--,X=L.narration.continue(A)):v<0&&(F=0,X=ot.stepHistory.back(A,{steps:v*-1})),{newValue:F,result:X}},animate:(v,A,F,X)=>motion.animate(v,A,F,X),getVariable:(v,A)=>K.StorageRegistry.getVariable(v,A),setVariable:(v,A,F)=>K.StorageRegistry.setVariable(v,A,F),removeVariable:(v,A)=>K.StorageRegistry.removeVariable(v,A),getFlag:v=>K.storage.flags.get(v),setFlag:(v,A)=>K.storage.flags.set(v,A),onLabelClosing:v=>K.StorageRegistry.clearOldTempVariables(v)}),!d||!E){mt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await k.canvas.init(d,E,T)}U.init=g;function e(){K.storage.clear(),k.canvas.isInitialized&&k.canvas.clear(),gt.sound.clear(),L.narration.clear(),ot.stepHistory.clear();}U.clear=e;function i(){let d=k.canvas.isInitialized?k.canvas.export():{};return {pixivn_version:Lt,stepData:L.narration.export(),storageData:K.storage.export(),canvasData:d,soundData:gt.sound.export(),historyData:ot.stepHistory.export(),path:qt()}}U.exportGameState=i;async function s(d){ot.stepHistory.restore(d.historyData);let E=ot.stepHistory.lastKey;if(typeof E=="number"){let T=ot.stepHistory.stepsInfoMap.get(E)||null;await L.narration.restore(d.stepData,T);}K.storage.restore(d.storageData);try{k.canvas.isInitialized&&await k.canvas.restore(d.canvasData),await gt.sound.restore(d.soundData);}catch{}await GameUnifier.navigate(d.path);}U.restoreGameState=s;async function r(d,E){return U.clear(),await L.narration.call(d,E)}U.start=r;function o(d){return JSON.parse(d)}U.jsonToGameState=o;function n(d){GameUnifier.onEnd=d;}U.onEnd=n;function l(d){return GameUnifier.addOnError(d)}U.addOnError=l;function c(d){return GameUnifier.removeOnError(d)}U.removeOnError=c;function y(d){L.NarrationManagerStatic.onStepStart=d;}U.onStepStart=y;function O(d){L.NarrationManagerStatic.onLoadingLabel=d;}U.onLoadingLabel=O;function S(d){L.NarrationManagerStatic.onStepEnd=d;}U.onStepEnd=S;function j(d){L.NarrationManagerStatic.onLabelStarting=d;}U.onLabelStarting=j;function D(d){L.NarrationManagerStatic.onLabelClosing=d;}U.onLabelClosing=D;function H(d){GameUnifier.navigate=d;}U.onNavigate=H;function u(d){return GameUnifier.addOnPreContinue(d)}U.addOnPreContinue=u;function _(d){return GameUnifier.removeOnPreContinue(d)}U.removeOnPreContinue=_,U.testing=ae(U);})(de||={});var Ze={characterUtils:Bt,canvasUtils:k,narrationUtils:L,soundUtils:gt,CANVAS_APP_GAME_LAYER_ALIAS:Kt,PIXIVN_VERSION:Lt,...Wt,...re,canvas:k.canvas,narration:L.narration,sound:gt.sound,storage:K.storage,history:ot.stepHistory,Game:de,GameUnifier:GameUnifier};export{Kt as CANVAS_APP_GAME_LAYER_ALIAS,Dt as CachedMap,de as Game,Lt as PIXIVN_VERSION,ge as SYSTEM_RESERVED_STORAGE_KEYS,ne as createExportableElement,Ze as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.9.1",
3
+ "version": "1.9.2",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN is a very versatile and powerful game/story-driven engine.",
6
6
  "main": "./dist/index.cjs",