@drincs/pixi-vn 1.9.4 → 1.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +186 -170
  2. package/dist/{ContainerMemory-DNqSVzLY.d.cts → ContainerMemory-De04YSUc.d.cts} +2 -1
  3. package/dist/{ContainerMemory-DNqSVzLY.d.ts → ContainerMemory-De04YSUc.d.ts} +2 -1
  4. package/dist/canvas.cjs +2 -2
  5. package/dist/canvas.d.cts +1008 -918
  6. package/dist/canvas.d.ts +1008 -918
  7. package/dist/canvas.mjs +2 -2
  8. package/dist/characters.cjs +1 -1
  9. package/dist/characters.d.cts +3 -2
  10. package/dist/characters.d.ts +3 -2
  11. package/dist/characters.mjs +1 -1
  12. package/dist/{chunk-S7HZUIEI.mjs → chunk-A5FN4SNI.mjs} +1 -1
  13. package/dist/chunk-B46NFIFC.mjs +1 -0
  14. package/dist/chunk-FPMP2OWB.mjs +1 -0
  15. package/dist/{chunk-6OABTG5R.mjs → chunk-OJKUK6GL.mjs} +1 -1
  16. package/dist/{chunk-5MVDNAT4.mjs → chunk-WYGKBGMH.mjs} +1 -1
  17. package/dist/chunk-XLRCR56W.mjs +1 -0
  18. package/dist/core.d.cts +12 -5
  19. package/dist/core.d.ts +12 -5
  20. package/dist/filters.cjs +1 -1
  21. package/dist/filters.d.cts +18 -3
  22. package/dist/filters.d.ts +18 -3
  23. package/dist/filters.mjs +1 -1
  24. package/dist/history.cjs +1 -1
  25. package/dist/history.d.cts +10 -5
  26. package/dist/history.d.ts +10 -5
  27. package/dist/history.mjs +1 -1
  28. package/dist/index.cjs +2 -2
  29. package/dist/index.d.cts +16 -7
  30. package/dist/index.d.ts +16 -7
  31. package/dist/index.mjs +2 -2
  32. package/dist/motion.cjs +1 -1
  33. package/dist/motion.d.cts +8 -2
  34. package/dist/motion.d.ts +8 -2
  35. package/dist/motion.mjs +1 -1
  36. package/dist/narration.cjs +2 -2
  37. package/dist/narration.d.cts +7 -2
  38. package/dist/narration.d.ts +7 -2
  39. package/dist/narration.mjs +1 -1
  40. package/dist/pixi/browser.js +182 -148
  41. package/dist/sound.cjs +1 -1
  42. package/dist/sound.d.cts +3 -2
  43. package/dist/sound.d.ts +3 -2
  44. package/dist/sound.mjs +1 -1
  45. package/dist/storage.cjs +1 -1
  46. package/dist/storage.d.cts +7 -2
  47. package/dist/storage.d.ts +7 -2
  48. package/dist/storage.mjs +1 -1
  49. package/dist/tickers.cjs +1 -1
  50. package/dist/tickers.d.cts +72 -1
  51. package/dist/tickers.d.ts +72 -1
  52. package/dist/tickers.mjs +1 -1
  53. package/dist/vite-listener.mjs +1 -1
  54. package/dist/vite.cjs +1 -1
  55. package/dist/vite.d.cts +2 -1
  56. package/dist/vite.d.ts +2 -1
  57. package/dist/vite.mjs +1 -1
  58. package/dist/worker.cjs +1 -1
  59. package/dist/worker.d.cts +2 -1
  60. package/dist/worker.d.ts +2 -1
  61. package/package.json +11 -10
  62. package/dist/chunk-AW5XWF24.mjs +0 -1
  63. package/dist/chunk-K7JIC2F2.mjs +0 -1
package/dist/worker.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var i=class extends Error{code;constructor(t,r,a,o,m){super(`[Pixi\u2019VN] ${r}`),this.code=t,a==="canvas"&&(this.canvasElementInfo=o,this.parent=m);}canvasElementInfo;parent};var n;(o=>(o.log=(m,...l)=>console.log(`[Pixi\u2019VN] ${m}`,...l),o.warn=(m,...l)=>console.warn(`[Pixi\u2019VN] ${m}`,...l),o.error=(m,...l)=>console.error(`[Pixi\u2019VN] ${m}`,...l),o.info=(m,...l)=>console.info(`[Pixi\u2019VN] ${m}`,...l)))(n||={});(class e{static init(t){t.navigate&&(e._navigate=t.navigate),e._getStepCounter=t.getStepCounter,e._setStepCounter=t.setStepCounter,e._getCurrentGameStepState=t.getCurrentGameStepState,e._restoreGameStepState=t.restoreGameStepState,e._getOpenedLabels=t.getOpenedLabels,e._processNavigationRequests=t.processNavigationRequests,e._getVariable=t.getVariable,e._setVariable=t.setVariable,e._removeVariable=t.removeVariable,e._getFlag=t.getFlag,e._setFlag=t.setFlag,t.onLabelClosing&&(e._onLabelClosing=t.onLabelClosing),e._addHistoryItem=t.addHistoryItem,e._getCharacter=t.getCharacter,e._animate=t.animate,e._animateFilter=t.animateFilter,e._removeCanvasComponent=t.removeCanvasComponent,e._canvasComponentExists=t.canvasComponentExists;}static _navigate=()=>{n.warn("Navigate function not initialized. You should add the navigate function in the Game.init() method.");};static get navigate(){return e._navigate}static set navigate(t){e._navigate=t;}static _getStepCounter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return e._getStepCounter()}static set stepCounter(t){e._setStepCounter(t);}static _getCurrentGameStepState=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return e._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return e._restoreGameStepState}static _getOpenedLabels=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return e._getOpenedLabels()}static _onPreContinueHandlers=[];static addOnPreContinue(t){e._onPreContinueHandlers.push(t);}static removeOnPreContinue(t){e._onPreContinueHandlers=e._onPreContinueHandlers.filter(r=>r!==t);}static clearOnPreContinueHandlers(){e._onPreContinueHandlers=[];}static async runOnPreContinue(){let t=e._onPreContinueHandlers.slice();await Promise.all(t.map(r=>r()));}static get onPreContinue(){return e.runOnPreContinue}static navigationRequestsCount=0;static processNavigationLock=Promise.resolve();static get continueRequestsCount(){return e.navigationRequestsCount}static increaseContinueRequest(t=1){e.navigationRequestsCount+=t;}static get backRequestsCount(){return -1*e.navigationRequestsCount}static increaseBackRequest(t=1){e.navigationRequestsCount-=t;}static _processNavigationRequests=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static async processNavigationRequests(t){let r=e._processNavigationRequests(e.navigationRequestsCount,t);return e.navigationRequestsCount=r.newValue,await r.result}static _getVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return e._getVariable}static _setVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return e._setVariable}static _removeVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return e._removeVariable}static _getFlag=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return e._getFlag}static _setFlag=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return e._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return e._onLabelClosing}static _addHistoryItem=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return e._addHistoryItem}static runningStepsCount=0;static _getCharacter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented.")};static get getCharacter(){return e._getCharacter}static onEnd;static _onErrorHandlers=[];static addOnError(t){return e._onErrorHandlers.push(t),()=>e.removeOnError(t)}static removeOnError(t){e._onErrorHandlers=e._onErrorHandlers.filter(r=>r!==t);}static clearOnErrorHandlers(){e._onErrorHandlers.length=0;}static async runOnError(t,r){for(let a of e._onErrorHandlers.slice())try{await a(t,r);}catch(o){n.error("Error in onError handler",o);}}static _animate=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get animate(){return e._animate}static _animateFilter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get animateFilter(){return e._animateFilter}static _removeCanvasComponent=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get removeCanvasComponent(){return e._removeCanvasComponent}static _canvasComponentExists=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get canvasComponentExists(){return e._canvasComponentExists}});function y(e){try{if(typeof e>"u")return e;let t=JSON.stringify(e);return JSON.parse(t)}catch(t){throw n.error("Error creating exportable element",e,t),new i("not_json_serializable","Error creating exportable element")}}function h(e,t){let r=y(e);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(a=>{k(r,a);}),r}function k(e,t){let r=e;t.path&&t.path.length>0?t.path.forEach((a,o)=>{if(t.path&&o===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":r[a]=t.oldValue;break;case "CREATE":Array.isArray(r)&&typeof a=="number"?r.splice(a,1):delete r[a];break}else r=r[a];}):n.warn("No path found, skipping diff",t);}var w=["Date","RegExp","String","Number"],E=Object.getOwnPropertyNames(globalThis.Temporal||{});function c(e,t,r={cyclesFix:true},a=[]){let o=[],m=Array.isArray(e);for(let p in e){let s=e[p],v=m?+p:p;if(!(p in t)){o.push({type:"REMOVE",path:[v],oldValue:s});continue}let u=t[p],G=typeof s=="object"&&typeof u=="object"&&Array.isArray(s)===Array.isArray(u),g=G&&s?Object.getPrototypeOf(s)?.constructor?.name:void 0;if(s&&u&&G&&!w.includes(g)&&!E.includes(g)&&(!r.cyclesFix||!a.includes(s))){r.cyclesFix&&a.push(s);let S=c(s,u,r,a);r.cyclesFix&&a.pop();for(let C of S)C.path.unshift(v),o.push(C);}else Object.is(s,u)||E.includes(g)&&String(s)===String(u)||w.includes(g)&&(isNaN(s)?s+""==u+"":+s==+u)||o.push({path:[v],type:"CHANGE",value:u,oldValue:s});}let l=Array.isArray(t);for(let p in t)p in e||o.push({type:"CREATE",path:[l?+p:p],value:t[p]});return o}var b=new Map;function x(e,t){b.set(e,t);}function P(e){b.delete(e);}function T(e){return b.get(e)}async function M(e){try{switch(e.type){case "restore-diff":{let t=h(e.state,e.diff);return {id:e.id,type:"restore-diff-result",result:t}}case "diff":{let t=c(e.before,e.after);return {id:e.id,type:"diff-result",result:t}}case "clone":{let t=JSON.parse(JSON.stringify(e.value));return {id:e.id,type:"clone-result",result:t}}case "custom":{let t=T(e.kind);if(!t)throw new Error(`No game worker handler registered for kind "${e.kind}"`);let r=await t(e.payload);return {id:e.id,type:"custom-result",result:r}}}}catch(t){return {id:e.id,type:"error",error:t instanceof Error?t.message:String(t)}}}var d=class e{static _worker;static _pending=new Map;static _nextId=0;static get isAvailable(){return e._worker!==void 0}static register(t){e.unregister(),e._worker=t,t.addEventListener("message",e._handleMessage);}static unregister(){let t=e._worker;if(t){t.removeEventListener("message",e._handleMessage),e._worker=void 0;for(let{reject:r}of e._pending.values())r(new Error("Game worker was unregistered"));e._pending.clear();}}static _handleMessage=t=>{let r=e._pending.get(t.data.id);r&&(e._pending.delete(t.data.id),t.data.type==="error"?r.reject(new Error(t.data.error)):r.resolve(t.data.result));};static _request(t){let r=e._worker;if(!r)return Promise.reject(new Error("No game worker is registered"));let a=e._nextId++;return new Promise((o,m)=>{e._pending.set(a,{resolve:o,reject:m});try{r.postMessage({...t,id:a});}catch(l){e._pending.delete(a),n.error("Error posting message to game worker",l),m(l);}})}static async restoreDiff(t,r){return await e._request({type:"restore-diff",state:t,diff:r})}static async diff(t,r){return await e._request({type:"diff",before:t,after:r})}static async clone(t){return await e._request({type:"clone",value:t})}static async custom(t,r){return await e._request({type:"custom",kind:t,payload:r})}};async function R(e,t){if(d.isAvailable)try{return await d.restoreDiff(e,t)}catch(r){n.warn("Game worker failed to restore diff, falling back to the main thread",r);}return h(e,t)}async function O(e,t){if(d.isAvailable)try{return await d.diff(e,t)}catch(r){n.warn("Game worker failed to compute diff, falling back to the main thread",r);}return c(e,t)}async function H(e){if(d.isAvailable)try{return await d.clone(e)}catch(t){n.warn("Game worker failed to clone value, falling back to the main thread",t);}return y(e)}exports.GameWorkerManager=d;exports.cloneMaybeOffloaded=H;exports.diffMaybeOffloaded=O;exports.handleGameWorkerMessage=M;exports.registerGameWorkerHandler=x;exports.restoreDiffMaybeOffloaded=R;exports.unregisterGameWorkerHandler=P;
1
+ 'use strict';var i=class extends Error{code;constructor(t,r,a,o,m){super(`[Pixi\u2019VN] ${r}`),this.code=t,a==="canvas"&&(this.canvasElementInfo=o,this.parent=m);}canvasElementInfo;parent};var n;(o=>(o.log=(m,...l)=>console.log(`[Pixi\u2019VN] ${m}`,...l),o.warn=(m,...l)=>console.warn(`[Pixi\u2019VN] ${m}`,...l),o.error=(m,...l)=>console.error(`[Pixi\u2019VN] ${m}`,...l),o.info=(m,...l)=>console.info(`[Pixi\u2019VN] ${m}`,...l)))(n||={});(class e{static init(t){t.navigate&&(e._navigate=t.navigate),e._getStepCounter=t.getStepCounter,e._setStepCounter=t.setStepCounter,e._getCurrentGameStepState=t.getCurrentGameStepState,e._restoreGameStepState=t.restoreGameStepState,e._getOpenedLabels=t.getOpenedLabels,e._processNavigationRequests=t.processNavigationRequests,e._getVariable=t.getVariable,e._setVariable=t.setVariable,e._removeVariable=t.removeVariable,e._getFlag=t.getFlag,e._setFlag=t.setFlag,t.onLabelClosing&&(e._onLabelClosing=t.onLabelClosing),e._addHistoryItem=t.addHistoryItem,e._getCharacter=t.getCharacter,e._animate=t.animate,e._animateFilter=t.animateFilter,e._removeCanvasComponent=t.removeCanvasComponent,e._canvasComponentExists=t.canvasComponentExists;}static _navigate=()=>{n.warn("Navigate function not initialized. You should add the navigate function in the Game.init() method.");};static get navigate(){return e._navigate}static set navigate(t){e._navigate=t;}static _getStepCounter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return e._getStepCounter()}static set stepCounter(t){e._setStepCounter(t);}static _getCurrentGameStepState=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return e._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return e._restoreGameStepState}static _getOpenedLabels=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return e._getOpenedLabels()}static _onPreContinueHandlers=[];static addOnPreContinue(t){e._onPreContinueHandlers.push(t);}static removeOnPreContinue(t){e._onPreContinueHandlers=e._onPreContinueHandlers.filter(r=>r!==t);}static clearOnPreContinueHandlers(){e._onPreContinueHandlers=[];}static async runOnPreContinue(){let t=e._onPreContinueHandlers.slice();await Promise.all(t.map(r=>r()));}static get onPreContinue(){return e.runOnPreContinue}static navigationRequestsCount=0;static processNavigationLock=Promise.resolve();static get continueRequestsCount(){return e.navigationRequestsCount}static increaseContinueRequest(t=1){e.navigationRequestsCount+=t;}static get backRequestsCount(){return -1*e.navigationRequestsCount}static increaseBackRequest(t=1){e.navigationRequestsCount-=t;}static _processNavigationRequests=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static async processNavigationRequests(t){let r=e._processNavigationRequests(e.navigationRequestsCount,t);return e.navigationRequestsCount=r.newValue,await r.result}static _getVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return e._getVariable}static _setVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return e._setVariable}static _removeVariable=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return e._removeVariable}static _getFlag=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return e._getFlag}static _setFlag=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return e._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return e._onLabelClosing}static _addHistoryItem=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return e._addHistoryItem}static runningStepsCount=0;static _getCharacter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented.")};static get getCharacter(){return e._getCharacter}static onEnd;static _onErrorHandlers=[];static addOnError(t){return e._onErrorHandlers.push(t),()=>e.removeOnError(t)}static removeOnError(t){e._onErrorHandlers=e._onErrorHandlers.filter(r=>r!==t);}static clearOnErrorHandlers(){e._onErrorHandlers.length=0;}static async runOnError(t,r){for(let a of e._onErrorHandlers.slice())try{await a(t,r);}catch(o){n.error("Error in onError handler",o);}}static _animate=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get animate(){return e._animate}static _animateFilter=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get animateFilter(){return e._animateFilter}static _removeCanvasComponent=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get removeCanvasComponent(){return e._removeCanvasComponent}static _canvasComponentExists=()=>{throw n.error("Method not implemented, you should initialize the Game: Game.init()"),new i("not_implemented","Method not implemented, you should initialize the Game: Game.init()")};static get canvasComponentExists(){return e._canvasComponentExists}});function y(e){try{if(typeof e>"u")return e;let t=JSON.stringify(e);return JSON.parse(t)}catch(t){throw n.error("Error creating exportable element",e,t),new i("not_json_serializable","Error creating exportable element")}}function h(e,t){let r=y(e);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(a=>{S(r,a);}),r}function S(e,t){let r=e;t.path&&t.path.length>0?t.path.forEach((a,o)=>{if(t.path&&o===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":r[a]=t.oldValue;break;case "CREATE":Array.isArray(r)&&typeof a=="number"?r.splice(a,1):delete r[a];break}else r=r[a];}):n.warn("No path found, skipping diff",t);}var w=["Date","RegExp","String","Number"],E=Object.getOwnPropertyNames(globalThis.Temporal||{});function c(e,t,r={cyclesFix:true},a=[]){let o=[],m=Array.isArray(e);for(let p in e){let s=e[p],v=m?+p:p;if(!(p in t)){o.push({type:"REMOVE",path:[v],oldValue:s});continue}let u=t[p],G=typeof s=="object"&&typeof u=="object"&&Array.isArray(s)===Array.isArray(u),g=G&&s?Object.getPrototypeOf(s)?.constructor?.name:void 0;if(s&&u&&G&&!w.includes(g)&&!E.includes(g)&&(!r.cyclesFix||!a.includes(s))){r.cyclesFix&&a.push(s);let k=c(s,u,r,a);r.cyclesFix&&a.pop();for(let C of k)C.path.unshift(v),o.push(C);}else Object.is(s,u)||E.includes(g)&&String(s)===String(u)||w.includes(g)&&(isNaN(s)?s+""==u+"":+s==+u)||o.push({path:[v],type:"CHANGE",value:u,oldValue:s});}let l=Array.isArray(t);for(let p in t)p in e||o.push({type:"CREATE",path:[l?+p:p],value:t[p]});return o}var b=new Map;function x(e,t){b.set(e,t);}function P(e){b.delete(e);}function T(e){return b.get(e)}async function M(e){try{switch(e.type){case "restore-diff":{let t=h(e.state,e.diff);return {id:e.id,type:"restore-diff-result",result:t}}case "diff":{let t=c(e.before,e.after);return {id:e.id,type:"diff-result",result:t}}case "clone":{let t=JSON.parse(JSON.stringify(e.value));return {id:e.id,type:"clone-result",result:t}}case "custom":{let t=T(e.kind);if(!t)throw new Error(`No game worker handler registered for kind "${e.kind}"`);let r=await t(e.payload);return {id:e.id,type:"custom-result",result:r}}}}catch(t){return {id:e.id,type:"error",error:t instanceof Error?t.message:String(t)}}}var d=class e{static _worker;static _pending=new Map;static _nextId=0;static get isAvailable(){return e._worker!==void 0}static register(t){e.unregister(),e._worker=t,t.addEventListener("message",e._handleMessage);}static unregister(){let t=e._worker;if(t){t.removeEventListener("message",e._handleMessage),e._worker=void 0;for(let{reject:r}of e._pending.values())r(new Error("Game worker was unregistered"));e._pending.clear();}}static _handleMessage=t=>{let r=e._pending.get(t.data.id);r&&(e._pending.delete(t.data.id),t.data.type==="error"?r.reject(new Error(t.data.error)):r.resolve(t.data.result));};static _request(t){let r=e._worker;if(!r)return Promise.reject(new Error("No game worker is registered"));let a=e._nextId++;return new Promise((o,m)=>{e._pending.set(a,{resolve:o,reject:m});try{r.postMessage({...t,id:a});}catch(l){e._pending.delete(a),n.error("Error posting message to game worker",l),m(l);}})}static async restoreDiff(t,r){return await e._request({type:"restore-diff",state:t,diff:r})}static async diff(t,r){return await e._request({type:"diff",before:t,after:r})}static async clone(t){return await e._request({type:"clone",value:t})}static async custom(t,r){return await e._request({type:"custom",kind:t,payload:r})}};async function R(e,t){if(d.isAvailable)try{return await d.restoreDiff(e,t)}catch(r){n.warn("Game worker failed to restore diff, falling back to the main thread",r);}return h(e,t)}async function O(e,t){if(d.isAvailable)try{return await d.diff(e,t)}catch(r){n.warn("Game worker failed to compute diff, falling back to the main thread",r);}return c(e,t)}async function H(e){if(d.isAvailable)try{return await d.clone(e)}catch(t){n.warn("Game worker failed to clone value, falling back to the main thread",t);}return y(e)}exports.GameWorkerManager=d;exports.cloneMaybeOffloaded=H;exports.diffMaybeOffloaded=O;exports.handleGameWorkerMessage=M;exports.registerGameWorkerHandler=x;exports.restoreDiffMaybeOffloaded=R;exports.unregisterGameWorkerHandler=P;
package/dist/worker.d.cts CHANGED
@@ -150,4 +150,5 @@ declare function diffMaybeOffloaded(before: object, after: object): Promise<Diff
150
150
  */
151
151
  declare function cloneMaybeOffloaded<T extends object>(value: T): Promise<T>;
152
152
 
153
- export { type GameWorkerHandler, GameWorkerManager, type GameWorkerRequest, type GameWorkerResponse, cloneMaybeOffloaded, diffMaybeOffloaded, handleGameWorkerMessage, registerGameWorkerHandler, restoreDiffMaybeOffloaded, unregisterGameWorkerHandler };
153
+ export { GameWorkerManager, cloneMaybeOffloaded, diffMaybeOffloaded, handleGameWorkerMessage, registerGameWorkerHandler, restoreDiffMaybeOffloaded, unregisterGameWorkerHandler };
154
+ export type { GameWorkerHandler, GameWorkerRequest, GameWorkerResponse };
package/dist/worker.d.ts CHANGED
@@ -150,4 +150,5 @@ declare function diffMaybeOffloaded(before: object, after: object): Promise<Diff
150
150
  */
151
151
  declare function cloneMaybeOffloaded<T extends object>(value: T): Promise<T>;
152
152
 
153
- export { type GameWorkerHandler, GameWorkerManager, type GameWorkerRequest, type GameWorkerResponse, cloneMaybeOffloaded, diffMaybeOffloaded, handleGameWorkerMessage, registerGameWorkerHandler, restoreDiffMaybeOffloaded, unregisterGameWorkerHandler };
153
+ export { GameWorkerManager, cloneMaybeOffloaded, diffMaybeOffloaded, handleGameWorkerMessage, registerGameWorkerHandler, restoreDiffMaybeOffloaded, unregisterGameWorkerHandler };
154
+ export type { GameWorkerHandler, GameWorkerRequest, GameWorkerResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
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",
@@ -19,6 +19,7 @@
19
19
  "check": "biome check",
20
20
  "format": "biome format --write",
21
21
  "test": "vitest",
22
+ "test:cdn": "npm run build && node scripts/test-pencode-local.mjs",
22
23
  "docs": "typedoc",
23
24
  "skills:validate": "node scripts/validate-skills.mjs",
24
25
  "sandbox": "npm run build && node scripts/sync-sandbox.mjs && npm run start --workspace=sandbox"
@@ -186,25 +187,25 @@
186
187
  }
187
188
  },
188
189
  "devDependencies": {
189
- "@biomejs/biome": "^2.4.12",
190
+ "@biomejs/biome": "^2.5.15",
190
191
  "@types/crypto-js": "^4.2.2",
191
192
  "@types/mime-db": "^1.43.6",
192
193
  "crypto-js": "^4.2.0",
193
- "jsdom": "^29.0.2",
194
+ "jsdom": "^27.4.0",
194
195
  "keyv": "^5.6.0",
195
- "lru-cache": "11.2.7",
196
- "microdiff": "^1.5.0",
196
+ "lru-cache": "10.4.3",
197
+ "microdiff": "^1.6.0",
197
198
  "mime-db": "^1.54.0",
198
199
  "picocolors": "^1.1.1",
199
200
  "ts-node": "^10.9.2",
200
201
  "tsconfig-paths": "^4.2.0",
201
- "tsup": "^8.5.1",
202
- "typedoc": "^0.28.19",
203
- "typedoc-plugin-markdown": "^4.11.0",
202
+ "tsup": "^9.0.0",
203
+ "typedoc": "^0.28.20",
204
+ "typedoc-plugin-markdown": "^4.14.1",
204
205
  "typescript": "^5.9.3",
205
- "vite": "^8.0.9",
206
+ "vite": "^8.3.4",
206
207
  "vite-tsconfig-paths": "^6.1.1",
207
- "vitest": "^4.1.5"
208
+ "vitest": "^4.1.12"
208
209
  },
209
210
  "keywords": [
210
211
  "2d",
@@ -1 +0,0 @@
1
- var Ht=Object.create;var Tt=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Bt=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty;var Ut=l=>{throw TypeError(l)};var Xt=(l,e,i)=>e in l?Tt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var ee=(l=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(l,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):l)(function(l){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+l+'" is not supported')});var ie=(l,e)=>()=>(e||l((e={exports:{}}).exports,e),e.exports);var Yt=(l,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let h of $t(e))!qt.call(l,h)&&h!==i&&Tt(l,h,{get:()=>e[h],enumerable:!(s=Kt(e,h))||s.enumerable});return l};var se=(l,e,i)=>(i=l!=null?Ht(Bt(l)):{},Yt(e||!l||!l.__esModule?Tt(i,"default",{value:l,enumerable:true}):i,l));var x=(l,e,i)=>Xt(l,typeof e!="symbol"?e+"":e,i),xt=(l,e,i)=>e.has(l)||Ut("Cannot "+i);var t=(l,e,i)=>(xt(l,e,"read from private field"),i?i.call(l):e.get(l)),g=(l,e,i)=>e.has(l)?Ut("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),f=(l,e,i,s)=>(xt(l,e,"write to private field"),e.set(l,i),i),a=(l,e,i)=>(xt(l,e,"access private method"),i);var bt=(l,e,i,s)=>({set _(h){f(l,e,h);},get _(){return t(l,e,s)}});var Jt;(h=>(h.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),h.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),h.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),h.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(Jt||={});var Qt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Nt=new Set,zt=typeof process=="object"&&process?process:{},It=(l,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Ft=globalThis.AbortController,Gt=globalThis.AbortSignal;if(typeof Ft>"u"){Gt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Ft=class{constructor(){e();}signal=new Gt;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=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,It("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 Zt=l=>!Nt.has(l);var tt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),Vt=l=>tt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?_t:null:null,_t=class extends Array{constructor(l){super(l),this.fill(0);}},J,ct,te=(J=class{heap;length;static create(e){let i=Vt(e);if(!i)return [];f(J,ct,true);let s=new J(e,i);return f(J,ct,false),s}constructor(e,i){if(!t(J,ct))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]}},ct=new WeakMap,g(J,ct,false),J),Mt,jt,V,U,P,ot,k,ft,dt,H,O,K,A,y,d,W,G,z,F,$,E,B,q,M,j,X,ht,D,pt,r,Rt,nt,Q,St,N,kt,rt,gt,yt,et,it,Ct,At,Ot,S,Wt,vt,st,Dt,wt,Pt=(wt=class{constructor(e){g(this,r);g(this,V);g(this,U);g(this,P);g(this,ot);g(this,k);g(this,ft);g(this,dt);g(this,H);x(this,"ttl");x(this,"ttlResolution");x(this,"ttlAutopurge");x(this,"updateAgeOnGet");x(this,"updateAgeOnHas");x(this,"allowStale");x(this,"noDisposeOnSet");x(this,"noUpdateTTL");x(this,"maxEntrySize");x(this,"sizeCalculation");x(this,"noDeleteOnFetchRejection");x(this,"noDeleteOnStaleGet");x(this,"allowStaleOnFetchAbort");x(this,"allowStaleOnFetchRejection");x(this,"ignoreFetchAbort");g(this,O);g(this,K);g(this,A);g(this,y);g(this,d);g(this,W);g(this,G);g(this,z);g(this,F);g(this,$);g(this,E);g(this,B);g(this,q);g(this,M);g(this,j);g(this,X);g(this,ht);g(this,D);g(this,pt);g(this,nt,()=>{});g(this,Q,()=>{});g(this,St,()=>{});g(this,N,()=>false);g(this,rt,e=>{});g(this,gt,(e,i,s)=>{});g(this,yt,(e,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});x(this,Mt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:u,allowStale:c,dispose:w,onInsert:T,disposeAfter:m,noDisposeOnSet:Z,noUpdateTTL:I,maxSize:Y=0,maxEntrySize:b=0,sizeCalculation:v,fetchMethod:p,memoMethod:R,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:_,allowStaleOnFetchAbort:mt,ignoreFetchAbort:lt,perf:at}=e;if(at!==void 0&&typeof at?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,H,at??Qt),i!==0&&!tt(i))throw new TypeError("max option must be a nonnegative integer");let ut=i?Vt(i):Array;if(!ut)throw new Error("invalid max value: "+i);if(f(this,V,i),f(this,U,Y),this.maxEntrySize=b||t(this,U),this.sizeCalculation=v,this.sizeCalculation){if(!t(this,U)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,dt,R),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,ft,p),f(this,ht,!!p),f(this,A,new Map),f(this,y,new Array(i).fill(void 0)),f(this,d,new Array(i).fill(void 0)),f(this,W,new ut(i)),f(this,G,new ut(i)),f(this,z,0),f(this,F,0),f(this,$,te.create(i)),f(this,O,0),f(this,K,0),typeof w=="function"&&f(this,P,w),typeof T=="function"&&f(this,ot,T),typeof m=="function"?(f(this,k,m),f(this,E,[])):(f(this,k,void 0),f(this,E,void 0)),f(this,X,!!t(this,P)),f(this,pt,!!t(this,ot)),f(this,D,!!t(this,k)),this.noDisposeOnSet=!!Z,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!_,this.allowStaleOnFetchAbort=!!mt,this.ignoreFetchAbort=!!lt,this.maxEntrySize!==0){if(t(this,U)!==0&&!tt(t(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!tt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");a(this,r,kt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!u,this.ttlResolution=tt(h)||h===0?h:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!tt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");a(this,r,Rt).call(this);}if(t(this,V)===0&&this.ttl===0&&t(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,V)&&!t(this,U)){let Et="LRU_CACHE_UNBOUNDED";Zt(Et)&&(Nt.add(Et),It("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Et,wt));}}get perf(){return t(this,H)}static unsafeExposeInternals(e){return {starts:t(e,q),ttls:t(e,M),autopurgeTimers:t(e,j),sizes:t(e,B),keyMap:t(e,A),keyList:t(e,y),valList:t(e,d),next:t(e,W),prev:t(e,G),get head(){return t(e,z)},get tail(){return t(e,F)},free:t(e,$),isBackgroundFetch:i=>{var s;return a(s=e,r,S).call(s,i)},backgroundFetch:(i,s,h,n)=>{var o;return a(o=e,r,Ot).call(o,i,s,h,n)},moveToTail:i=>{var s;return a(s=e,r,vt).call(s,i)},indexes:i=>{var s;return a(s=e,r,et).call(s,i)},rindexes:i=>{var s;return a(s=e,r,it).call(s,i)},isStale:i=>{var s;return t(s=e,N).call(s,i)}}}get max(){return t(this,V)}get maxSize(){return t(this,U)}get calculatedSize(){return t(this,K)}get size(){return t(this,O)}get fetchMethod(){return t(this,ft)}get memoMethod(){return t(this,dt)}get dispose(){return t(this,P)}get onInsert(){return t(this,ot)}get disposeAfter(){return t(this,k)}getRemainingTTL(e){return t(this,A).has(e)?1/0:0}*entries(){for(let e of a(this,r,et).call(this))t(this,d)[e]!==void 0&&t(this,y)[e]!==void 0&&!a(this,r,S).call(this,t(this,d)[e])&&(yield [t(this,y)[e],t(this,d)[e]]);}*rentries(){for(let e of a(this,r,it).call(this))t(this,d)[e]!==void 0&&t(this,y)[e]!==void 0&&!a(this,r,S).call(this,t(this,d)[e])&&(yield [t(this,y)[e],t(this,d)[e]]);}*keys(){for(let e of a(this,r,et).call(this)){let i=t(this,y)[e];i!==void 0&&!a(this,r,S).call(this,t(this,d)[e])&&(yield i);}}*rkeys(){for(let e of a(this,r,it).call(this)){let i=t(this,y)[e];i!==void 0&&!a(this,r,S).call(this,t(this,d)[e])&&(yield i);}}*values(){for(let e of a(this,r,et).call(this))t(this,d)[e]!==void 0&&!a(this,r,S).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}*rvalues(){for(let e of a(this,r,it).call(this))t(this,d)[e]!==void 0&&!a(this,r,S).call(this,t(this,d)[e])&&(yield t(this,d)[e]);}[(jt=Symbol.iterator,Mt=Symbol.toStringTag,jt)](){return this.entries()}find(e,i={}){for(let s of a(this,r,et).call(this)){let h=t(this,d)[s],n=a(this,r,S).call(this,h)?h.__staleWhileFetching:h;if(n!==void 0&&e(n,t(this,y)[s],this))return this.get(t(this,y)[s],i)}}forEach(e,i=this){for(let s of a(this,r,et).call(this)){let h=t(this,d)[s],n=a(this,r,S).call(this,h)?h.__staleWhileFetching:h;n!==void 0&&e.call(i,n,t(this,y)[s],this);}}rforEach(e,i=this){for(let s of a(this,r,it).call(this)){let h=t(this,d)[s],n=a(this,r,S).call(this,h)?h.__staleWhileFetching:h;n!==void 0&&e.call(i,n,t(this,y)[s],this);}}purgeStale(){let e=false;for(let i of a(this,r,it).call(this,{allowStale:true}))t(this,N).call(this,i)&&(a(this,r,st).call(this,t(this,y)[i],"expire"),e=true);return e}info(e){let i=t(this,A).get(e);if(i===void 0)return;let s=t(this,d)[i],h=a(this,r,S).call(this,s)?s.__staleWhileFetching:s;if(h===void 0)return;let n={value:h};if(t(this,M)&&t(this,q)){let o=t(this,M)[i],u=t(this,q)[i];if(o&&u){let c=o-(t(this,H).now()-u);n.ttl=c,n.start=Date.now();}}return t(this,B)&&(n.size=t(this,B)[i]),n}dump(){let e=[];for(let i of a(this,r,et).call(this,{allowStale:true})){let s=t(this,y)[i],h=t(this,d)[i],n=a(this,r,S).call(this,h)?h.__staleWhileFetching:h;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,M)&&t(this,q)){o.ttl=t(this,M)[i];let u=t(this,H).now()-t(this,q)[i];o.start=Math.floor(Date.now()-u);}t(this,B)&&(o.size=t(this,B)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let h=Date.now()-s.start;s.start=t(this,H).now()-h;}this.set(i,s.value,s);}}set(e,i,s={}){var Z,I,Y,b;if(i===void 0)return this.delete(e),this;let{ttl:h=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:u=this.sizeCalculation,status:c}=s,{noUpdateTTL:w=this.noUpdateTTL}=s,T=t(this,yt).call(this,e,i,s.size||0,u);if(this.maxEntrySize&&T>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),a(this,r,st).call(this,e,"set"),this;let m=t(this,O)===0?void 0:t(this,A).get(e);if(m===void 0)m=t(this,O)===0?t(this,F):t(this,$).length!==0?t(this,$).pop():t(this,O)===t(this,V)?a(this,r,At).call(this,false):t(this,O),t(this,y)[m]=e,t(this,d)[m]=i,t(this,A).set(e,m),t(this,W)[t(this,F)]=m,t(this,G)[m]=t(this,F),f(this,F,m),bt(this,O)._++,t(this,gt).call(this,m,T,c),c&&(c.set="add"),w=false,t(this,pt)&&((Z=t(this,ot))==null||Z.call(this,i,e,"add"));else {a(this,r,vt).call(this,m);let v=t(this,d)[m];if(i!==v){if(t(this,ht)&&a(this,r,S).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=v;p!==void 0&&!o&&(t(this,X)&&((I=t(this,P))==null||I.call(this,p,e,"set")),t(this,D)&&t(this,E)?.push([p,e,"set"]));}else o||(t(this,X)&&((Y=t(this,P))==null||Y.call(this,v,e,"set")),t(this,D)&&t(this,E)?.push([v,e,"set"]));if(t(this,rt).call(this,m),t(this,gt).call(this,m,T,c),t(this,d)[m]=i,c){c.set="replace";let p=v&&a(this,r,S).call(this,v)?v.__staleWhileFetching:v;p!==void 0&&(c.oldValue=p);}}else c&&(c.set="update");t(this,pt)&&this.onInsert?.(i,e,i===v?"update":"replace");}if(h!==0&&!t(this,M)&&a(this,r,Rt).call(this),t(this,M)&&(w||t(this,St).call(this,m,h,n),c&&t(this,Q).call(this,c,m)),!o&&t(this,D)&&t(this,E)){let v=t(this,E),p;for(;p=v?.shift();)(b=t(this,k))==null||b.call(this,...p);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,d)[t(this,z)];if(a(this,r,At).call(this,!0),a(this,r,S).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,D)&&t(this,E)){let i=t(this,E),s;for(;s=i?.shift();)(e=t(this,k))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h}=i,n=t(this,A).get(e);if(n!==void 0){let o=t(this,d)[n];if(a(this,r,S).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,N).call(this,n))h&&(h.has="stale",t(this,Q).call(this,h,n));else return s&&t(this,nt).call(this,n),h&&(h.has="hit",t(this,Q).call(this,h,n)),true}else h&&(h.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,h=t(this,A).get(e);if(h===void 0||!s&&t(this,N).call(this,h))return;let n=t(this,d)[h];return a(this,r,S).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:u=this.noDisposeOnSet,size:c=0,sizeCalculation:w=this.sizeCalculation,noUpdateTTL:T=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Z=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:Y=this.allowStaleOnFetchAbort,context:b,forceRefresh:v=false,status:p,signal:R}=i;if(!t(this,ht))return p&&(p.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:h,noDeleteOnStaleGet:n,status:p});let L={allowStale:s,updateAgeOnGet:h,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:u,size:c,sizeCalculation:w,noUpdateTTL:T,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:Y,ignoreFetchAbort:I,status:p,signal:R},C=t(this,A).get(e);if(C===void 0){p&&(p.fetch="miss");let _=a(this,r,Ot).call(this,e,C,L,b);return _.__returned=_}else {let _=t(this,d)[C];if(a(this,r,S).call(this,_)){let ut=s&&_.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",ut&&(p.returnedStale=true)),ut?_.__staleWhileFetching:_.__returned=_}let mt=t(this,N).call(this,C);if(!v&&!mt)return p&&(p.fetch="hit"),a(this,r,vt).call(this,C),h&&t(this,nt).call(this,C),p&&t(this,Q).call(this,p,C),_;let lt=a(this,r,Ot).call(this,e,C,L,b),at=lt.__staleWhileFetching!==void 0&&s;return p&&(p.fetch=mt?"stale":"refresh",at&&mt&&(p.returnedStale=true)),at?lt.__staleWhileFetching:lt.__returned=lt}}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,dt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:n,...o}=i,u=this.get(e,o);if(!n&&u!==void 0)return u;let c=s(e,u,{options:o,context:h});return this.set(e,c,o),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,u=t(this,A).get(e);if(u!==void 0){let c=t(this,d)[u],w=a(this,r,S).call(this,c);return o&&t(this,Q).call(this,o,u),t(this,N).call(this,u)?(o&&(o.get="stale"),w?(o&&s&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?c.__staleWhileFetching:void 0):(n||a(this,r,st).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?c:void 0)):(o&&(o.get="hit"),w?c.__staleWhileFetching:(a(this,r,vt).call(this,u),h&&t(this,nt).call(this,u),c))}else o&&(o.get="miss");}delete(e){return a(this,r,st).call(this,e,"delete")}clear(){return a(this,r,Dt).call(this,"delete")}},V=new WeakMap,U=new WeakMap,P=new WeakMap,ot=new WeakMap,k=new WeakMap,ft=new WeakMap,dt=new WeakMap,H=new WeakMap,O=new WeakMap,K=new WeakMap,A=new WeakMap,y=new WeakMap,d=new WeakMap,W=new WeakMap,G=new WeakMap,z=new WeakMap,F=new WeakMap,$=new WeakMap,E=new WeakMap,B=new WeakMap,q=new WeakMap,M=new WeakMap,j=new WeakMap,X=new WeakMap,ht=new WeakMap,D=new WeakMap,pt=new WeakMap,r=new WeakSet,Rt=function(){let e=new _t(t(this,V)),i=new _t(t(this,V));f(this,M,e),f(this,q,i);let s=this.ttlAutopurge?new Array(t(this,V)):void 0;f(this,j,s),f(this,St,(u,c,w=t(this,H).now())=>{i[u]=c!==0?w:0,e[u]=c,h(u,c);}),f(this,nt,u=>{i[u]=e[u]!==0?t(this,H).now():0,h(u,e[u]);});let h=this.ttlAutopurge?(u,c)=>{if(s?.[u]&&(clearTimeout(s[u]),s[u]=void 0),c&&c!==0&&s){let w=setTimeout(()=>{t(this,N).call(this,u)&&a(this,r,st).call(this,t(this,y)[u],"expire");},c+1);w.unref&&w.unref(),s[u]=w;}}:()=>{};f(this,Q,(u,c)=>{if(e[c]){let w=e[c],T=i[c];if(!w||!T)return;u.ttl=w,u.start=T,u.now=n||o();let m=u.now-T;u.remainingTTL=w-m;}});let n=0,o=()=>{let u=t(this,H).now();if(this.ttlResolution>0){n=u;let c=setTimeout(()=>n=0,this.ttlResolution);c.unref&&c.unref();}return u};this.getRemainingTTL=u=>{let c=t(this,A).get(u);if(c===void 0)return 0;let w=e[c],T=i[c];if(!w||!T)return 1/0;let m=(n||o())-T;return w-m},f(this,N,u=>{let c=i[u],w=e[u];return !!w&&!!c&&(n||o())-c>w});},nt=new WeakMap,Q=new WeakMap,St=new WeakMap,N=new WeakMap,kt=function(){let e=new _t(t(this,V));f(this,K,0),f(this,B,e),f(this,rt,i=>{f(this,K,t(this,K)-e[i]),e[i]=0;}),f(this,yt,(i,s,h,n)=>{if(a(this,r,S).call(this,s))return 0;if(!tt(h))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(h=n(s,i),!tt(h))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 h}),f(this,gt,(i,s,h)=>{if(e[i]=s,t(this,U)){let n=t(this,U)-e[i];for(;t(this,K)>n;)a(this,r,At).call(this,true);}f(this,K,t(this,K)+e[i]),h&&(h.entrySize=s,h.totalCalculatedSize=t(this,K));});},rt=new WeakMap,gt=new WeakMap,yt=new WeakMap,et=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,F);!(!a(this,r,Ct).call(this,i)||((e||!t(this,N).call(this,i))&&(yield i),i===t(this,z)));)i=t(this,G)[i];},it=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,z);!(!a(this,r,Ct).call(this,i)||((e||!t(this,N).call(this,i))&&(yield i),i===t(this,F)));)i=t(this,W)[i];},Ct=function(e){return e!==void 0&&t(this,A).get(t(this,y)[e])===e},At=function(e){var n;let i=t(this,z),s=t(this,y)[i],h=t(this,d)[i];return t(this,ht)&&a(this,r,S).call(this,h)?h.__abortController.abort(new Error("evicted")):(t(this,X)||t(this,D))&&(t(this,X)&&((n=t(this,P))==null||n.call(this,h,s,"evict")),t(this,D)&&t(this,E)?.push([h,s,"evict"])),t(this,rt).call(this,i),t(this,j)?.[i]&&(clearTimeout(t(this,j)[i]),t(this,j)[i]=void 0),e&&(t(this,y)[i]=void 0,t(this,d)[i]=void 0,t(this,$).push(i)),t(this,O)===1?(f(this,z,f(this,F,0)),t(this,$).length=0):f(this,z,t(this,W)[i]),t(this,A).delete(s),bt(this,O)._--,i},Ot=function(e,i,s,h){let n=i===void 0?void 0:t(this,d)[i];if(a(this,r,S).call(this,n))return n;let o=new Ft,{signal:u}=s;u?.addEventListener("abort",()=>o.abort(u.reason),{signal:o.signal});let c={signal:o.signal,options:s,context:h},w=(b,v=false)=>{let{aborted:p}=o.signal,R=s.ignoreFetchAbort&&b!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&b!==void 0);if(s.status&&(p&&!v?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,R&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),p&&!R&&!v)return m(o.signal.reason,L);let C=I,_=t(this,d)[i];return (_===I||R&&v&&_===void 0)&&(b===void 0?C.__staleWhileFetching!==void 0?t(this,d)[i]=C.__staleWhileFetching:a(this,r,st).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,b,c.options))),b},T=b=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=b),m(b,false)),m=(b,v)=>{let{aborted:p}=o.signal,R=p&&s.allowStaleOnFetchAbort,L=R||s.allowStaleOnFetchRejection,C=L||s.noDeleteOnFetchRejection,_=I;if(t(this,d)[i]===I&&(!C||!v&&_.__staleWhileFetching===void 0?a(this,r,st).call(this,e,"fetch"):R||(t(this,d)[i]=_.__staleWhileFetching)),L)return s.status&&_.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),_.__staleWhileFetching;if(_.__returned===_)throw b},Z=(b,v)=>{var R;let p=(R=t(this,ft))==null?void 0:R.call(this,e,n,c);p&&p instanceof Promise&&p.then(L=>b(L===void 0?void 0:L),v),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(b(void 0),s.allowStaleOnFetchAbort&&(b=L=>w(L,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(Z).then(w,T),Y=Object.assign(I,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,Y,{...c.options,status:void 0}),i=t(this,A).get(e)):t(this,d)[i]=Y,Y},S=function(e){if(!t(this,ht))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},Wt=function(e,i){t(this,G)[i]=e,t(this,W)[e]=i;},vt=function(e){e!==t(this,F)&&(e===t(this,z)?f(this,z,t(this,W)[e]):a(this,r,Wt).call(this,t(this,G)[e],t(this,W)[e]),a(this,r,Wt).call(this,t(this,F),e),f(this,F,e));},st=function(e,i){var h,n;let s=false;if(t(this,O)!==0){let o=t(this,A).get(e);if(o!==void 0)if(t(this,j)?.[o]&&(clearTimeout(t(this,j)?.[o]),t(this,j)[o]=void 0),s=true,t(this,O)===1)a(this,r,Dt).call(this,i);else {t(this,rt).call(this,o);let u=t(this,d)[o];if(a(this,r,S).call(this,u)?u.__abortController.abort(new Error("deleted")):(t(this,X)||t(this,D))&&(t(this,X)&&((h=t(this,P))==null||h.call(this,u,e,i)),t(this,D)&&t(this,E)?.push([u,e,i])),t(this,A).delete(e),t(this,y)[o]=void 0,t(this,d)[o]=void 0,o===t(this,F))f(this,F,t(this,G)[o]);else if(o===t(this,z))f(this,z,t(this,W)[o]);else {let c=t(this,G)[o];t(this,W)[c]=t(this,W)[o];let w=t(this,W)[o];t(this,G)[w]=t(this,G)[o];}bt(this,O)._--,t(this,$).push(o);}}if(t(this,D)&&t(this,E)?.length){let o=t(this,E),u;for(;u=o?.shift();)(n=t(this,k))==null||n.call(this,...u);}return s},Dt=function(e){var i,s;for(let h of a(this,r,it).call(this,{allowStale:true})){let n=t(this,d)[h];if(a(this,r,S).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,y)[h];t(this,X)&&((i=t(this,P))==null||i.call(this,n,o,e)),t(this,D)&&t(this,E)?.push([n,o,e]);}}if(t(this,A).clear(),t(this,d).fill(void 0),t(this,y).fill(void 0),t(this,M)&&t(this,q)){t(this,M).fill(0),t(this,q).fill(0);for(let h of t(this,j)??[])h!==void 0&&clearTimeout(h);t(this,j)?.fill(void 0);}if(t(this,B)&&t(this,B).fill(0),f(this,z,0),f(this,F,0),t(this,$).length=0,f(this,K,0),f(this,O,0),t(this,D)&&t(this,E)){let h=t(this,E),n;for(;n=h?.shift();)(s=t(this,k))==null||s.call(this,...n);}},wt);var Lt=class{cache;map=new Map;constructor(e){this.cache=new Pt({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()}};export{ee as a,ie as b,se as c,Lt as d,Jt as e};
@@ -1 +0,0 @@
1
- var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var h=b=>{throw TypeError(b)};var n=(b,a,c)=>a in b?f(b,a,{enumerable:true,configurable:true,writable:true,value:c}):b[a]=c;var r=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports),s=(b,a)=>{for(var c in a)f(b,c,{get:a[c],enumerable:true});},o=(b,a,c,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of k(a))!m.call(b,e)&&e!==c&&f(b,e,{get:()=>a[e],enumerable:!(d=j(a,e))||d.enumerable});return b};var t=(b,a,c)=>(c=b!=null?i(l(b)):{},o(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:true}):c,b));var u=(b,a,c)=>n(b,typeof a!="symbol"?a+"":a,c),g=(b,a,c)=>a.has(b)||h("Cannot "+c);var p=(b,a,c)=>(g(b,a,"read from private field"),c?c.call(b):a.get(b)),v=(b,a,c)=>a.has(b)?h("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(b):a.set(b,c),q=(b,a,c,d)=>(g(b,a,"write to private field"),d?d.call(b,c):a.set(b,c),c),w=(b,a,c)=>(g(b,a,"access private method"),c);var x=(b,a,c,d)=>({set _(e){q(b,a,e,c);},get _(){return p(b,a,d)}});export{r as a,s as b,t as c,u as d,p as e,v as f,q as g,w as h,x as i};