@drincs/pixi-vn 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/CanvasManager.cjs +1 -1
- package/dist/canvas/CanvasManager.js +1 -1
- package/dist/canvas/CanvasManagerStatic.cjs +1 -1
- package/dist/canvas/CanvasManagerStatic.js +1 -1
- package/dist/canvas/components/Container.cjs +1 -1
- package/dist/canvas/components/Container.js +1 -1
- package/dist/canvas/components/ImageContainer.cjs +1 -1
- package/dist/canvas/components/ImageContainer.js +1 -1
- package/dist/canvas/components/ImageSprite.cjs +2 -2
- package/dist/canvas/components/ImageSprite.js +2 -2
- package/dist/canvas/components/Sprite.cjs +1 -1
- package/dist/canvas/components/Sprite.js +1 -1
- package/dist/canvas/components/Text.cjs +1 -1
- package/dist/canvas/components/Text.js +1 -1
- package/dist/canvas/components/VideoSprite.cjs +2 -2
- package/dist/canvas/components/VideoSprite.js +2 -2
- package/dist/canvas/decorators/canvas-element-decorator.cjs +1 -1
- package/dist/canvas/decorators/canvas-element-decorator.js +1 -1
- package/dist/canvas/decorators/event-decorator.cjs +1 -1
- package/dist/canvas/decorators/event-decorator.js +1 -1
- package/dist/canvas/functions/canvas-effect.cjs +1 -1
- package/dist/canvas/functions/canvas-effect.js +1 -1
- package/dist/canvas/functions/canvas-import-utility.cjs +1 -1
- package/dist/canvas/functions/canvas-import-utility.js +1 -1
- package/dist/canvas/functions/canvas-transition.cjs +1 -1
- package/dist/canvas/functions/canvas-transition.js +1 -1
- package/dist/canvas/functions/image-container-utility.cjs +1 -1
- package/dist/canvas/functions/image-container-utility.js +1 -1
- package/dist/canvas/functions/image-utility.cjs +1 -1
- package/dist/canvas/functions/image-utility.js +1 -1
- package/dist/canvas/functions/video-utility.cjs +1 -1
- package/dist/canvas/functions/video-utility.js +1 -1
- package/dist/canvas/index.cjs +1 -1
- package/dist/canvas/index.js +1 -1
- package/dist/canvas/tickers/classes/TickerBase.cjs +1 -1
- package/dist/canvas/tickers/classes/TickerBase.js +1 -1
- package/dist/canvas/tickers/components/FadeAlphaTicker.cjs +1 -1
- package/dist/canvas/tickers/components/FadeAlphaTicker.js +1 -1
- package/dist/canvas/tickers/components/MoveTicker.cjs +1 -1
- package/dist/canvas/tickers/components/MoveTicker.js +1 -1
- package/dist/canvas/tickers/components/RotateTicker.cjs +1 -1
- package/dist/canvas/tickers/components/RotateTicker.js +1 -1
- package/dist/canvas/tickers/components/ZoomTicker.cjs +1 -1
- package/dist/canvas/tickers/components/ZoomTicker.js +1 -1
- package/dist/canvas/tickers/decorators/ticker-decorator.cjs +1 -1
- package/dist/canvas/tickers/decorators/ticker-decorator.js +1 -1
- package/dist/canvas/tickers/functions/ticker-texture-utility.cjs +1 -1
- package/dist/canvas/tickers/functions/ticker-texture-utility.js +1 -1
- package/dist/canvas/tickers/index.cjs +1 -1
- package/dist/canvas/tickers/index.js +1 -1
- package/dist/character/classes/CharacterBaseModel.cjs +17 -17
- package/dist/character/classes/CharacterBaseModel.js +17 -17
- package/dist/character/classes/CharacterStoredClass.cjs +16 -16
- package/dist/character/classes/CharacterStoredClass.js +16 -16
- package/dist/character/decorators/character-decorator.cjs +1 -1
- package/dist/character/decorators/character-decorator.js +1 -1
- package/dist/character/index.cjs +16 -16
- package/dist/character/index.js +16 -16
- package/dist/classes/CachedMap.cjs +1 -1
- package/dist/classes/CachedMap.d.cts +1 -1
- package/dist/classes/CachedMap.d.ts +1 -1
- package/dist/classes/CachedMap.js +1 -1
- package/dist/classes/index.cjs +1 -1
- package/dist/classes/index.js +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +5 -1
- package/dist/constants.d.ts +5 -1
- package/dist/constants.js +1 -1
- package/dist/history/HistoryManager.cjs +2 -2
- package/dist/history/HistoryManager.d.cts +24 -13
- package/dist/history/HistoryManager.d.ts +24 -13
- package/dist/history/HistoryManager.js +2 -2
- package/dist/history/HistoryManagerStatic.cjs +1 -1
- package/dist/history/HistoryManagerStatic.d.cts +9 -8
- package/dist/history/HistoryManagerStatic.d.ts +9 -8
- package/dist/history/HistoryManagerStatic.js +1 -1
- package/dist/history/index.cjs +2 -2
- package/dist/history/index.d.cts +4 -2
- package/dist/history/index.d.ts +4 -2
- package/dist/history/index.js +2 -2
- package/dist/history/interfaces/HistoryManagerInterface.d.cts +54 -11
- package/dist/history/interfaces/HistoryManagerInterface.d.ts +54 -11
- package/dist/{index-CWhYJ7yq.d.ts → index-CvpVN1rC.d.ts} +3 -3
- package/dist/{index-CVn6zVij.d.cts → index-DCnX_VPi.d.cts} +3 -3
- package/dist/index.cjs +73 -73
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +73 -73
- package/dist/narration/NarrationManager.cjs +16 -16
- package/dist/narration/NarrationManager.d.cts +1 -1
- package/dist/narration/NarrationManager.d.ts +1 -1
- package/dist/narration/NarrationManager.js +16 -16
- package/dist/narration/NarrationManagerStatic.cjs +1 -1
- package/dist/narration/NarrationManagerStatic.js +1 -1
- package/dist/narration/classes/ChoiceMenuOption.cjs +1 -1
- package/dist/narration/classes/ChoiceMenuOption.js +1 -1
- package/dist/narration/decorators/RegisteredLabels.cjs +1 -1
- package/dist/narration/decorators/RegisteredLabels.js +1 -1
- package/dist/narration/decorators/newLabel.cjs +1 -1
- package/dist/narration/decorators/newLabel.js +1 -1
- package/dist/narration/index.cjs +17 -17
- package/dist/narration/index.d.cts +2 -2
- package/dist/narration/index.d.ts +2 -2
- package/dist/narration/index.js +17 -17
- package/dist/narration/interfaces/HistoryStep.d.cts +5 -5
- package/dist/narration/interfaces/HistoryStep.d.ts +5 -5
- package/dist/narration/interfaces/{NarrativeHistory.d.cts → NarrationHistory.d.cts} +2 -2
- package/dist/narration/interfaces/{NarrativeHistory.d.ts → NarrationHistory.d.ts} +2 -2
- package/dist/narration/interfaces/NarrationManagerInterface.d.cts +1 -1
- package/dist/narration/interfaces/NarrationManagerInterface.d.ts +1 -1
- package/dist/pixi-devtools/additionalPositionsProperties.cjs +1 -1
- package/dist/pixi-devtools/additionalPositionsProperties.js +1 -1
- package/dist/pixi-vn.d.d.cts +44 -1
- package/dist/pixi-vn.d.d.ts +44 -1
- package/dist/storage/StorageManager.cjs +1 -1
- package/dist/storage/StorageManager.js +1 -1
- package/dist/storage/StorageManagerStatic.cjs +1 -1
- package/dist/storage/StorageManagerStatic.js +1 -1
- package/dist/storage/classes/StoredClassModel.cjs +1 -1
- package/dist/storage/classes/StoredClassModel.js +1 -1
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/utils/diff-utility.d.cts +2 -2
- package/dist/utils/diff-utility.d.ts +2 -2
- package/package.json +3 -3
- /package/dist/narration/interfaces/{NarrativeHistory.cjs → NarrationHistory.cjs} +0 -0
- /package/dist/narration/interfaces/{NarrativeHistory.js → NarrationHistory.js} +0 -0
package/dist/history/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var te=Object.create;var J=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var oe=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var se=(n,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of ie(t))!ae.call(n,p)&&p!==a&&J(n,p,{get:()=>t[p],enumerable:!(o=re(t,p))||o.enumerable});return n};var le=(n,t,a)=>(a=n!=null?te(ne(n)):{},se(J(a,"default",{value:n,enumerable:true}),n));var q=oe((j,Y)=>{(function(n,t){var a=t(n);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return a});else if(typeof j=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))Y.exports=a;else {var o=n.DeepDiff;a.noConflict=function(){return n.DeepDiff===a&&(n.DeepDiff=o),a},n.DeepDiff=a;}})(j,function(n){var t=["N","E","A","D"];function a(r,i){r.super_=i,r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});}function o(r,i){Object.defineProperty(this,"kind",{value:r,enumerable:true}),i&&i.length&&Object.defineProperty(this,"path",{value:i,enumerable:true});}function p(r,i,e){p.super_.call(this,"E",r),Object.defineProperty(this,"lhs",{value:i,enumerable:true}),Object.defineProperty(this,"rhs",{value:e,enumerable:true});}a(p,o);function y(r,i){y.super_.call(this,"N",r),Object.defineProperty(this,"rhs",{value:i,enumerable:true});}a(y,o);function b(r,i){b.super_.call(this,"D",r),Object.defineProperty(this,"lhs",{value:i,enumerable:true});}a(b,o);function h(r,i,e){h.super_.call(this,"A",r),Object.defineProperty(this,"index",{value:i,enumerable:true}),Object.defineProperty(this,"item",{value:e,enumerable:true});}a(h,o);function G(r,i,e){var s=r.slice((i)+1||r.length);return r.length=i<0?r.length+i:i,r.push.apply(r,s),r}function S(r){var i=typeof r;return i!=="object"?i:r===Math?"math":r===null?"null":Array.isArray(r)?"array":Object.prototype.toString.call(r)==="[object Date]"?"date":typeof r.toString=="function"&&/^\/.*\//.test(r.toString())?"regexp":"object"}function v(r){var i=0;if(r.length===0)return i;for(var e=0;e<r.length;e++){var s=r.charCodeAt(e);i=(i<<5)-i+s,i=i&i;}return i}function H(r){var i=0,e=S(r);if(e==="array"){r.forEach(function(C){i+=H(C);});var s="[type: array, hash: "+i+"]";return i+v(s)}if(e==="object"){for(var l in r)if(r.hasOwnProperty(l)){var m="[ type: object, key: "+l+", value hash: "+H(r[l])+"]";i+=v(m);}return i}var d="[ type: "+e+" ; value: "+r+"]";return i+v(d)}function E(r,i,e,s,l,m,d,C){e=e||[],l=l||[],d=d||[];var g=l.slice(0);if(typeof m<"u"&&m!==null){if(s){if(typeof s=="function"&&s(g,m))return;if(typeof s=="object"){if(s.prefilter&&s.prefilter(g,m))return;if(s.normalize){var L=s.normalize(g,m,r,i);L&&(r=L[0],i=L[1]);}}}g.push(m);}S(r)==="regexp"&&S(i)==="regexp"&&(r=r.toString(),i=i.toString());var P=typeof r,ee=typeof i,c,N,D,I,F=P!=="undefined"||d&&d.length>0&&d[d.length-1].lhs&&Object.getOwnPropertyDescriptor(d[d.length-1].lhs,m),B=ee!=="undefined"||d&&d.length>0&&d[d.length-1].rhs&&Object.getOwnPropertyDescriptor(d[d.length-1].rhs,m);if(!F&&B)e.push(new y(g,i));else if(!B&&F)e.push(new b(g,r));else if(S(r)!==S(i))e.push(new p(g,r,i));else if(S(r)==="date"&&r-i!==0)e.push(new p(g,r,i));else if(P==="object"&&r!==null&&i!==null){for(c=d.length-1;c>-1;--c)if(d[c].lhs===r){I=true;break}if(I)r!==i&&e.push(new p(g,r,i));else {if(d.push({lhs:r,rhs:i}),Array.isArray(r)){for(C&&(r.sort(function(z,A){return H(z)-H(A)}),i.sort(function(z,A){return H(z)-H(A)})),c=i.length-1,N=r.length-1;c>N;)e.push(new h(g,c,new y(void 0,i[c--])));for(;N>c;)e.push(new h(g,N,new b(void 0,r[N--])));for(;c>=0;--c)E(r[c],i[c],e,s,g,c,d,C);}else {var $=Object.keys(r),_=Object.keys(i);for(c=0;c<$.length;++c)D=$[c],I=_.indexOf(D),I>=0?(E(r[D],i[D],e,s,g,D,d,C),_[I]=null):E(r[D],void 0,e,s,g,D,d,C);for(c=0;c<_.length;++c)D=_[c],D&&E(void 0,i[D],e,s,g,D,d,C);}d.length=d.length-1;}}else r!==i&&(P==="number"&&isNaN(r)&&isNaN(i)||e.push(new p(g,r,i)));}function T(r,i,e,s,l){var m=[];if(E(r,i,m,s,null,null,null,l),e)for(var d=0;d<m.length;++d)e(m[d]);return m}function U(r,i,e,s,l,m,d){return E(r,i,e,s,l,m,d,true)}function M(r,i,e,s){var l=s?function(d){d&&s.push(d);}:void 0,m=T(r,i,l,e);return s||(m.length?m:void 0)}function W(r,i,e,s){var l=s?function(d){d&&s.push(d);}:void 0,m=T(r,i,l,e,true);return s||(m.length?m:void 0)}function k(r,i,e){if(e.path&&e.path.length){var s=r[i],l,m=e.path.length-1;for(l=0;l<m;l++)s=s[e.path[l]];switch(e.kind){case "A":k(s[e.path[l]],e.index,e.item);break;case "D":delete s[e.path[l]];break;case "E":case "N":s[e.path[l]]=e.rhs;break}}else switch(e.kind){case "A":k(r[i],e.index,e.item);break;case "D":r=G(r,i);break;case "E":case "N":r[i]=e.rhs;break}return r}function R(r,i,e){if(typeof e>"u"&&i&&~t.indexOf(i.kind)&&(e=i),r&&e&&e.kind){for(var s=r,l=-1,m=e.path?e.path.length-1:0;++l<m;)typeof s[e.path[l]]>"u"&&(s[e.path[l]]=typeof e.path[l+1]<"u"&&typeof e.path[l+1]=="number"?[]:{}),s=s[e.path[l]];switch(e.kind){case "A":e.path&&typeof s[e.path[l]]>"u"&&(s[e.path[l]]=[]),k(e.path?s[e.path[l]]:s,e.index,e.item);break;case "D":delete s[e.path[l]];break;case "E":case "N":s[e.path[l]]=e.rhs;break}}}function V(r,i,e){if(e.path&&e.path.length){var s=r[i],l,m=e.path.length-1;for(l=0;l<m;l++)s=s[e.path[l]];switch(e.kind){case "A":V(s[e.path[l]],e.index,e.item);break;case "D":s[e.path[l]]=e.lhs;break;case "E":s[e.path[l]]=e.lhs;break;case "N":delete s[e.path[l]];break}}else switch(e.kind){case "A":V(r[i],e.index,e.item);break;case "D":r[i]=e.lhs;break;case "E":r[i]=e.lhs;break;case "N":r=G(r,i);break}return r}function X(r,i,e){if(r&&i&&e&&e.kind){var s=r,l,m;for(m=e.path.length-1,l=0;l<m;l++)typeof s[e.path[l]]>"u"&&(s[e.path[l]]={}),s=s[e.path[l]];switch(e.kind){case "A":V(s[e.path[l]],e.index,e.item);break;case "D":s[e.path[l]]=e.lhs;break;case "E":s[e.path[l]]=e.lhs;break;case "N":delete s[e.path[l]];break}}}function Z(r,i,e){if(r&&i){var s=function(l){(!e||e(r,i,l))&&R(r,i,l);};T(r,i,s);}}return Object.defineProperties(M,{diff:{value:M,enumerable:true},orderIndependentDiff:{value:W,enumerable:true},observableDiff:{value:T,enumerable:true},orderIndependentObservableDiff:{value:U,enumerable:true},orderIndepHash:{value:H,enumerable:true},applyDiff:{value:Z,enumerable:true},applyChange:{value:R,enumerable:true},revertChange:{value:X,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),M.DeepDiff=M,n&&(n.DeepDiff=M),M});});var Q=le(q());var f;(p=>(p.log=(y,...b)=>console.log(`[Pixi\u2019VN] ${y}`,...b),p.warn=(y,...b)=>console.warn(`[Pixi\u2019VN] ${y}`,...b),p.error=(y,...b)=>console.error(`[Pixi\u2019VN] ${y}`,...b),p.info=(y,...b)=>console.info(`[Pixi\u2019VN] ${y}`,...b)))(f||={});var w=class n{static init(t){n._getStepCounter=t.getStepCounter,n._setStepCounter=t.setStepCounter,n._getCurrentGameStepState=t.getCurrentGameStepState,n._restoreGameStepState=t.restoreGameStepState,n._getOpenedLabels=t.getOpenedLabels,t.onGoNextEnd&&(n._onGoNextEnd=t.onGoNextEnd),n._getVariable=t.getVariable,n._setVariable=t.setVariable,n._removeVariable=t.removeVariable,n._getFlag=t.getFlag,n._setFlag=t.setFlag,t.onLabelClosing&&(n._onLabelClosing=t.onLabelClosing),n._addHistoryItem=t.addHistoryItem,n._getCurrentStepsRunningNumber=t.getCurrentStepsRunningNumber,n._getCharacter=t.getCharacter;}static _getStepCounter=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return n._getStepCounter()}static set stepCounter(t){n._setStepCounter(t);}static _getCurrentGameStepState=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return n._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return n._restoreGameStepState}static _getOpenedLabels=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return n._getOpenedLabels()}static _onGoNextEnd=async()=>{};static get onGoNextEnd(){return n._onGoNextEnd}static _getVariable=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return n._getVariable}static _setVariable=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return n._setVariable}static _removeVariable=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return n._removeVariable}static _getFlag=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return n._getFlag}static _setFlag=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return n._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return n._onLabelClosing}static _addHistoryItem=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return n._addHistoryItem}static _getCurrentStepsRunningNumber=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentStepsRunningNumber(){return n._getCurrentStepsRunningNumber()}static _getCharacter=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")};static get getCharacter(){return n._getCharacter}static onEnd;static onError};function x(n){try{if(typeof n>"u")return n;let t=JSON.stringify(n);return JSON.parse(t)}catch(t){throw f.error("Error creating exportable element",n,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function K(n,t){let a=x(n);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(o=>{"type"in o?pe(a,o):ue(a,o);}),a}function pe(n,t){let a=n;t.path&&t.path.length>0?t.path.forEach((o,p)=>{if(t.path&&p===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":a[o]=t.oldValue;break;case "CREATE":Array.isArray(a)&&typeof o=="number"?a.splice(o,1):delete a[o];break}else a=a[o];}):f.warn("No path found, skipping diff",t);}function ue(n,t){let a=n;t.path&&t.path.length>0?t.path.forEach((o,p)=>{if(t.path&&p===t.path.length-1){if(t.kind==="E"||t.kind==="D")a[o]=t.lhs;else if(t.kind==="N")Number.isInteger(o)?Array.isArray(a)&&a.splice(o,1):typeof o=="string"&&delete a[o];else if(t.kind==="A"){let y=t.index;t.item.kind==="N"?a[o].splice(y,1):t.item.kind==="E"||t.item.kind==="D"?a[o][y]=t.item.lhs:t.item.kind==="A"?f.warn("Nested array found, skipping diff",t):f.warn("No array found, skipping diff",t);}}else a=a[o];}):f.warn("No path found, skipping diff",t);}var u=class n{static _stepsHistory=[];static get stepsHistory(){return x(n._stepsHistory)}static stepLimitSaved=20;static goBackRunning=false;static get lastHistoryStep(){return n._stepsHistory.length>0?n._stepsHistory[n._stepsHistory.length-1]:null}static _originalStepData=void 0;static get originalStepData(){return n._originalStepData?x(n._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){n._originalStepData=x(t);}};var O=class{get stepsHistory(){return u.stepsHistory}internalRestoreOldGameState(t,a){if(t<=0||u._stepsHistory.length==0)return a;let o=u.lastHistoryStep;if(o?.diff)try{let p=K(a,o.diff);return w.stepCounter=o.index,u._stepsHistory.pop(),this.internalRestoreOldGameState(t-1,p)}catch(p){return f.error("Error applying diff",p),a}else return f.error("You can't go back, there is no step to go back"),a}async goBack(t,a=1){if(a<=0){f.warn("The parameter steps must be greater than 0");return}if(u._stepsHistory.length<=1){f.warn("You can't go back, there is no step to go back");return}if(u.goBackRunning){f.warn("Go back is already running");return}u.goBackRunning=true;try{let o=x(this.internalRestoreOldGameState(a,u.originalStepData));o?await w.restoreGameStepState(o,t):f.error("Error going back"),u.goBackRunning=!1;}catch(o){f.error("Error going back",o),u.goBackRunning=false;}}add(t={},a={}){let o=u.originalStepData,{ignoreSameStep:p}=a,y=w.currentGameStepState;if(!p&&this.isSameStep(o,y))return;u._stepsHistory.push({});let b=u._stepsHistory.length-1;(async()=>{try{let G=(0,Q.diff)(o,y);u._stepsHistory[b]={...t,diff:G};}catch(G){f.error("Error adding history step",G);}})(),u.originalStepData=y;}historyStepMapper(t,a){let{step:o,choiceIndexMade:p,inputValue:y,dialodueGlue:b}=t,h=o.dialogue||o.dialoge;b&&(h=void 0);let G=o.choices;if(a&&o.currentLabel&&o.choiceIndexMade!==void 0&&(a.choiceIndexMade=o.choiceIndexMade),o.inputValue&&a&&(a.inputValue=o.inputValue),h||G){let S=G?.map((v,H)=>{let E=false;return v.oneTime&&o.alreadyMadeChoices&&o.alreadyMadeChoices.includes(H)&&(E=true),{text:v.text,type:v.type,isResponse:false,hidden:E}});if(S){if(S.every(v=>v.hidden)){let v=S.find(H=>H.hidden===false);v&&(v.hidden=false);}p!==void 0&&(S[p].isResponse=true);}return {dialogue:h?{...h,character:h.character?w.getCharacter(h.character)||h.character:void 0}:void 0,playerMadeChoice:typeof p=="number",choices:S,stepIndex:o.index,inputValue:y}}}get narrativeHistory(){let t=[],a={},o=u.stepsHistory;for(let p=o.length-1;p>=0;p--){let y=o[p],b={...a};a={choiceIndexMade:void 0,inputValue:void 0};let h=this.historyStepMapper({step:y,choiceIndexMade:b.choiceIndexMade,inputValue:b.inputValue,dialodueGlue:y.dialogGlue},a);h&&t.push(h);}return t.reverse()}get latestCurrentLabelHistory(){let t=[],a={},o=u.stepsHistory,p=o[o.length-1],y=p.currentLabel,b=p.index;for(let h=o.length-1;h>=0&&o[h].currentLabel===y&&o[h].index<=b;h--){let G=o[h],S={...a};a={choiceIndexMade:void 0,inputValue:void 0};let v=this.historyStepMapper({step:G,choiceIndexMade:S.choiceIndexMade,inputValue:S.inputValue,dialodueGlue:G.dialogGlue},a);v&&t.push(v);}return t.reverse()}removeNarrativeHistory(t){t?u._stepsHistory.splice(0,t):u._stepsHistory=[];}get canGoBack(){return u._stepsHistory.length<=1?false:!!u.lastHistoryStep?.diff}blockGoBack(){w.currentStepsRunningNumber===0&&u._stepsHistory.length>1&&(u._stepsHistory[u._stepsHistory.length-1]={...u._stepsHistory[u._stepsHistory.length-1],diff:void 0});}isSameStep(t,a){if(t.openedLabels.length===a.openedLabels.length)try{let o=JSON.stringify(t.openedLabels),p=JSON.stringify(a.openedLabels);if(o===p&&t.path===a.path&&t.labelIndex===a.labelIndex)return !0}catch(o){return f.error("Error comparing opened labels",o),true}return false}clear(){u._stepsHistory=[],u._originalStepData=void 0;}get stepLimitSaved(){return u.stepLimitSaved}set stepLimitSaved(t){u.stepLimitSaved=t;}export(){let t=u._stepsHistory.length-this.stepLimitSaved,a=u._stepsHistory.map((o,p)=>({diff:t>p?void 0:o.diff,...o}));return {stepsHistory:x(a),originalStepData:x(u._originalStepData)}}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?u._stepsHistory=t.stepsHistory:f.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?u._originalStepData=t.originalStepData:f.warn("Could not import originalStepData data, so will be ignored");}catch(a){f.error("Error importing data",a);}}};var Oe=new O;
|
|
2
|
-
exports.HistoryManagerStatic=
|
|
1
|
+
'use strict';var ce=Object.create;var re=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var be=(l,e)=>()=>(e||l((e={exports:{}}).exports,e),e.exports);var Se=(l,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of me(e))!ge.call(l,r)&&r!==t&&re(l,r,{get:()=>e[r],enumerable:!(i=pe(e,r))||i.enumerable});return l};var ve=(l,e,t)=>(t=l!=null?ce(ye(l)):{},Se(re(t,"default",{value:l,enumerable:true}),l));var se=be((X,ne)=>{(function(l,e){var t=e(l);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return t});else if(typeof X=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))ne.exports=t;else {var i=l.DeepDiff;t.noConflict=function(){return l.DeepDiff===t&&(l.DeepDiff=i),t},l.DeepDiff=t;}})(X,function(l){var e=["N","E","A","D"];function t(o,a){o.super_=a,o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}});}function i(o,a){Object.defineProperty(this,"kind",{value:o,enumerable:true}),a&&a.length&&Object.defineProperty(this,"path",{value:a,enumerable:true});}function r(o,a,n){r.super_.call(this,"E",o),Object.defineProperty(this,"lhs",{value:a,enumerable:true}),Object.defineProperty(this,"rhs",{value:n,enumerable:true});}t(r,i);function s(o,a){s.super_.call(this,"N",o),Object.defineProperty(this,"rhs",{value:a,enumerable:true});}t(s,i);function h(o,a){h.super_.call(this,"D",o),Object.defineProperty(this,"lhs",{value:a,enumerable:true});}t(h,i);function c(o,a,n){c.super_.call(this,"A",o),Object.defineProperty(this,"index",{value:a,enumerable:true}),Object.defineProperty(this,"item",{value:n,enumerable:true});}t(c,i);function d(o,a,n){var f=o.slice((a)+1||o.length);return o.length=a<0?o.length+a:a,o.push.apply(o,f),o}function y(o){var a=typeof o;return a!=="object"?a:o===Math?"math":o===null?"null":Array.isArray(o)?"array":Object.prototype.toString.call(o)==="[object Date]"?"date":typeof o.toString=="function"&&/^\/.*\//.test(o.toString())?"regexp":"object"}function _(o){var a=0;if(o.length===0)return a;for(var n=0;n<o.length;n++){var f=o.charCodeAt(n);a=(a<<5)-a+f,a=a&a;}return a}function m(o){var a=0,n=y(o);if(n==="array"){o.forEach(function(R){a+=m(R);});var f="[type: array, hash: "+a+"]";return a+_(f)}if(n==="object"){for(var u in o)if(o.hasOwnProperty(u)){var v="[ type: object, key: "+u+", value hash: "+m(o[u])+"]";a+=_(v);}return a}var g="[ type: "+n+" ; value: "+o+"]";return a+_(g)}function w(o,a,n,f,u,v,g,R){n=n||[],u=u||[],g=g||[];var O=u.slice(0);if(typeof v<"u"&&v!==null){if(f){if(typeof f=="function"&&f(O,v))return;if(typeof f=="object"){if(f.prefilter&&f.prefilter(O,v))return;if(f.normalize){var $=f.normalize(O,v,o,a);$&&(o=$[0],a=$[1]);}}}O.push(v);}y(o)==="regexp"&&y(a)==="regexp"&&(o=o.toString(),a=a.toString());var Y=typeof o,de=typeof a,D,P,z,j,ee=Y!=="undefined"||g&&g.length>0&&g[g.length-1].lhs&&Object.getOwnPropertyDescriptor(g[g.length-1].lhs,v),te=de!=="undefined"||g&&g.length>0&&g[g.length-1].rhs&&Object.getOwnPropertyDescriptor(g[g.length-1].rhs,v);if(!ee&&te)n.push(new s(O,a));else if(!te&&ee)n.push(new h(O,o));else if(y(o)!==y(a))n.push(new r(O,o,a));else if(y(o)==="date"&&o-a!==0)n.push(new r(O,o,a));else if(Y==="object"&&o!==null&&a!==null){for(D=g.length-1;D>-1;--D)if(g[D].lhs===o){j=true;break}if(j)o!==a&&n.push(new r(O,o,a));else {if(g.push({lhs:o,rhs:a}),Array.isArray(o)){for(R&&(o.sort(function(J,q){return m(J)-m(q)}),a.sort(function(J,q){return m(J)-m(q)})),D=a.length-1,P=o.length-1;D>P;)n.push(new c(O,D,new s(void 0,a[D--])));for(;P>D;)n.push(new c(O,P,new h(void 0,o[P--])));for(;D>=0;--D)w(o[D],a[D],n,f,O,D,g,R);}else {var ie=Object.keys(o),U=Object.keys(a);for(D=0;D<ie.length;++D)z=ie[D],j=U.indexOf(z),j>=0?(w(o[z],a[z],n,f,O,z,g,R),U[j]=null):w(o[z],void 0,n,f,O,z,g,R);for(D=0;D<U.length;++D)z=U[D],z&&w(void 0,a[z],n,f,O,z,g,R);}g.length=g.length-1;}}else o!==a&&(Y==="number"&&isNaN(o)&&isNaN(a)||n.push(new r(O,o,a)));}function E(o,a,n,f,u){var v=[];if(w(o,a,v,f,null,null,null,u),n)for(var g=0;g<v.length;++g)n(v[g]);return v}function N(o,a,n,f,u,v,g){return w(o,a,n,f,u,v,g,true)}function G(o,a,n,f){var u=f?function(g){g&&f.push(g);}:void 0,v=E(o,a,u,n);return f||(v.length?v:void 0)}function T(o,a,n,f){var u=f?function(g){g&&f.push(g);}:void 0,v=E(o,a,u,n,true);return f||(v.length?v:void 0)}function S(o,a,n){if(n.path&&n.path.length){var f=o[a],u,v=n.path.length-1;for(u=0;u<v;u++)f=f[n.path[u]];switch(n.kind){case "A":S(f[n.path[u]],n.index,n.item);break;case "D":delete f[n.path[u]];break;case "E":case "N":f[n.path[u]]=n.rhs;break}}else switch(n.kind){case "A":S(o[a],n.index,n.item);break;case "D":o=d(o,a);break;case "E":case "N":o[a]=n.rhs;break}return o}function H(o,a,n){if(typeof n>"u"&&a&&~e.indexOf(a.kind)&&(n=a),o&&n&&n.kind){for(var f=o,u=-1,v=n.path?n.path.length-1:0;++u<v;)typeof f[n.path[u]]>"u"&&(f[n.path[u]]=typeof n.path[u+1]<"u"&&typeof n.path[u+1]=="number"?[]:{}),f=f[n.path[u]];switch(n.kind){case "A":n.path&&typeof f[n.path[u]]>"u"&&(f[n.path[u]]=[]),S(n.path?f[n.path[u]]:f,n.index,n.item);break;case "D":delete f[n.path[u]];break;case "E":case "N":f[n.path[u]]=n.rhs;break}}}function x(o,a,n){if(n.path&&n.path.length){var f=o[a],u,v=n.path.length-1;for(u=0;u<v;u++)f=f[n.path[u]];switch(n.kind){case "A":x(f[n.path[u]],n.index,n.item);break;case "D":f[n.path[u]]=n.lhs;break;case "E":f[n.path[u]]=n.lhs;break;case "N":delete f[n.path[u]];break}}else switch(n.kind){case "A":x(o[a],n.index,n.item);break;case "D":o[a]=n.lhs;break;case "E":o[a]=n.lhs;break;case "N":o=d(o,a);break}return o}function A(o,a,n){if(o&&a&&n&&n.kind){var f=o,u,v;for(v=n.path.length-1,u=0;u<v;u++)typeof f[n.path[u]]>"u"&&(f[n.path[u]]={}),f=f[n.path[u]];switch(n.kind){case "A":x(f[n.path[u]],n.index,n.item);break;case "D":f[n.path[u]]=n.lhs;break;case "E":f[n.path[u]]=n.lhs;break;case "N":delete f[n.path[u]];break}}}function C(o,a,n){if(o&&a){var f=function(u){(!n||n(o,a,u))&&H(o,a,u);};E(o,a,f);}}return Object.defineProperties(G,{diff:{value:G,enumerable:true},orderIndependentDiff:{value:T,enumerable:true},observableDiff:{value:E,enumerable:true},orderIndependentObservableDiff:{value:N,enumerable:true},orderIndepHash:{value:m,enumerable:true},applyDiff:{value:C,enumerable:true},applyChange:{value:H,enumerable:true},revertChange:{value:A,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),G.DeepDiff=G,l&&(l.DeepDiff=G),G});});var ue=ve(se());var b;(r=>(r.log=(s,...h)=>console.log(`[Pixi\u2019VN] ${s}`,...h),r.warn=(s,...h)=>console.warn(`[Pixi\u2019VN] ${s}`,...h),r.error=(s,...h)=>console.error(`[Pixi\u2019VN] ${s}`,...h),r.info=(s,...h)=>console.info(`[Pixi\u2019VN] ${s}`,...h)))(b||={});var F=class l{static init(e){l._getStepCounter=e.getStepCounter,l._setStepCounter=e.setStepCounter,l._getCurrentGameStepState=e.getCurrentGameStepState,l._restoreGameStepState=e.restoreGameStepState,l._getOpenedLabels=e.getOpenedLabels,e.onGoNextEnd&&(l._onGoNextEnd=e.onGoNextEnd),l._getVariable=e.getVariable,l._setVariable=e.setVariable,l._removeVariable=e.removeVariable,l._getFlag=e.getFlag,l._setFlag=e.setFlag,e.onLabelClosing&&(l._onLabelClosing=e.onLabelClosing),l._addHistoryItem=e.addHistoryItem,l._getCurrentStepsRunningNumber=e.getCurrentStepsRunningNumber,l._getCharacter=e.getCharacter;}static _getStepCounter=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return l._getStepCounter()}static set stepCounter(e){l._setStepCounter(e);}static _getCurrentGameStepState=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return l._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return l._restoreGameStepState}static _getOpenedLabels=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return l._getOpenedLabels()}static _onGoNextEnd=async()=>{};static get onGoNextEnd(){return l._onGoNextEnd}static _getVariable=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return l._getVariable}static _setVariable=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return l._setVariable}static _removeVariable=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return l._removeVariable}static _getFlag=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return l._getFlag}static _setFlag=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return l._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return l._onLabelClosing}static _addHistoryItem=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return l._addHistoryItem}static _getCurrentStepsRunningNumber=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentStepsRunningNumber(){return l._getCurrentStepsRunningNumber()}static _getCharacter=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")};static get getCharacter(){return l._getCharacter}static onEnd;static onError};function M(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw b.error("Error creating exportable element",l,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function oe(l,e){let t=M(l);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(i=>{"type"in i?we(t,i):_e(t,i);}),t}function we(l,e){let t=l;e.path&&e.path.length>0?e.path.forEach((i,r)=>{if(e.path&&r===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":t[i]=e.oldValue;break;case "CREATE":Array.isArray(t)&&typeof i=="number"?t.splice(i,1):delete t[i];break}else t=t[i];}):b.warn("No path found, skipping diff",e);}function _e(l,e){let t=l;e.path&&e.path.length>0?e.path.forEach((i,r)=>{if(e.path&&r===e.path.length-1){if(e.kind==="E"||e.kind==="D")t[i]=e.lhs;else if(e.kind==="N")Number.isInteger(i)?Array.isArray(t)&&t.splice(i,1):typeof i=="string"&&delete t[i];else if(e.kind==="A"){let s=e.index;e.item.kind==="N"?t[i].splice(s,1):e.item.kind==="E"||e.item.kind==="D"?t[i][s]=e.item.lhs:e.item.kind==="A"?b.warn("Nested array found, skipping diff",e):b.warn("No array found, skipping diff",e);}}else t=t[i];}):b.warn("No path found, skipping diff",e);}var k=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,le=new Set,Q=typeof process=="object"&&process?process:{},he=(l,e,t,i)=>{typeof Q.emitWarning=="function"?Q.emitWarning(l,e,t,i):console.error(`[${t}] ${e}: ${l}`);},K=globalThis.AbortController,ae=globalThis.AbortSignal;if(typeof K>"u"){ae=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,r){this._onabort.push(r);}},K=class{constructor(){e();}signal=new ae;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i);}}};let l=Q.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),I=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),fe=l=>I(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?V:null:null,V=class extends Array{constructor(e){super(e),this.fill(0);}},Z=class l{heap;length;static#l=false;static create(e){let t=fe(e);if(!t)return [];l.#l=true;let i=new l(e,t);return l.#l=false,i}constructor(e,t){if(!l.#l)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},B=class l{#l;#u;#m;#A;#y;#T;#z;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#g;#r;#i;#e;#h;#d;#a;#s;#b;#o;#S;#v;#c;#w;#H;#f;#M;static unsafeExposeInternals(e){return {starts:e.#v,ttls:e.#c,sizes:e.#S,keyMap:e.#r,keyList:e.#i,valList:e.#e,next:e.#h,prev:e.#d,get head(){return e.#a},get tail(){return e.#s},free:e.#b,isBackgroundFetch:t=>e.#t(t),backgroundFetch:(t,i,r,s)=>e.#I(t,i,r,s),moveToTail:t=>e.#x(t),indexes:t=>e.#_(t),rindexes:t=>e.#E(t),isStale:t=>e.#p(t)}}get max(){return this.#l}get maxSize(){return this.#u}get calculatedSize(){return this.#g}get size(){return this.#n}get fetchMethod(){return this.#T}get memoMethod(){return this.#z}get dispose(){return this.#m}get onInsert(){return this.#A}get disposeAfter(){return this.#y}constructor(e){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:s,updateAgeOnGet:h,updateAgeOnHas:c,allowStale:d,dispose:y,onInsert:_,disposeAfter:m,noDisposeOnSet:w,noUpdateTTL:E,maxSize:N=0,maxEntrySize:G=0,sizeCalculation:T,fetchMethod:S,memoMethod:H,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:o,ignoreFetchAbort:a}=e;if(t!==0&&!I(t))throw new TypeError("max option must be a nonnegative integer");let n=t?fe(t):Array;if(!n)throw new Error("invalid max value: "+t);if(this.#l=t,this.#u=N,this.maxEntrySize=G||this.#u,this.sizeCalculation=T,this.sizeCalculation){if(!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(H!==void 0&&typeof H!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#z=H,S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#T=S,this.#H=!!S,this.#r=new Map,this.#i=new Array(t).fill(void 0),this.#e=new Array(t).fill(void 0),this.#h=new n(t),this.#d=new n(t),this.#a=0,this.#s=0,this.#b=Z.create(t),this.#n=0,this.#g=0,typeof y=="function"&&(this.#m=y),typeof _=="function"&&(this.#A=_),typeof m=="function"?(this.#y=m,this.#o=[]):(this.#y=void 0,this.#o=void 0),this.#w=!!this.#m,this.#M=!!this.#A,this.#f=!!this.#y,this.noDisposeOnSet=!!w,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!o,this.ignoreFetchAbort=!!a,this.maxEntrySize!==0){if(this.#u!==0&&!I(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!I(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#W();}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!c,this.ttlResolution=I(r)||r===0?r:1,this.ttlAutopurge=!!s,this.ttl=i||0,this.ttl){if(!I(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#L();}if(this.#l===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#l&&!this.#u){let f="LRU_CACHE_UNBOUNDED";Ee(f)&&(le.add(f),he("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",f,l));}}getRemainingTTL(e){return this.#r.has(e)?1/0:0}#L(){let e=new V(this.#l),t=new V(this.#l);this.#c=e,this.#v=t,this.#R=(s,h,c=k.now())=>{if(t[s]=h!==0?c:0,e[s]=h,h!==0&&this.ttlAutopurge){let d=setTimeout(()=>{this.#p(s)&&this.#G(this.#i[s],"expire");},h+1);d.unref&&d.unref();}},this.#O=s=>{t[s]=e[s]!==0?k.now():0;},this.#D=(s,h)=>{if(e[h]){let c=e[h],d=t[h];if(!c||!d)return;s.ttl=c,s.start=d,s.now=i||r();let y=s.now-d;s.remainingTTL=c-y;}};let i=0,r=()=>{let s=k.now();if(this.ttlResolution>0){i=s;let h=setTimeout(()=>i=0,this.ttlResolution);h.unref&&h.unref();}return s};this.getRemainingTTL=s=>{let h=this.#r.get(s);if(h===void 0)return 0;let c=e[h],d=t[h];if(!c||!d)return 1/0;let y=(i||r())-d;return c-y},this.#p=s=>{let h=t[s],c=e[s];return !!c&&!!h&&(i||r())-h>c};}#O=()=>{};#D=()=>{};#R=()=>{};#p=()=>false;#W(){let e=new V(this.#l);this.#g=0,this.#S=e,this.#C=t=>{this.#g-=e[t],e[t]=0;},this.#k=(t,i,r,s)=>{if(this.#t(i))return 0;if(!I(r))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(r=s(i,t),!I(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},this.#N=(t,i,r)=>{if(e[t]=i,this.#u){let s=this.#u-e[t];for(;this.#g>s;)this.#F(true);}this.#g+=e[t],r&&(r.entrySize=i,r.totalCalculatedSize=this.#g);};}#C=e=>{};#N=(e,t,i)=>{};#k=(e,t,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#_({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#s;!(!this.#V(t)||((e||!this.#p(t))&&(yield t),t===this.#a));)t=this.#d[t];}*#E({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#a;!(!this.#V(t)||((e||!this.#p(t))&&(yield t),t===this.#s));)t=this.#h[t];}#V(e){return e!==void 0&&this.#r.get(this.#i[e])===e}*entries(){for(let e of this.#_())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield [this.#i[e],this.#e[e]]);}*rentries(){for(let e of this.#E())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield [this.#i[e],this.#e[e]]);}*keys(){for(let e of this.#_()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t);}}*rkeys(){for(let e of this.#E()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t);}}*values(){for(let e of this.#_())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e]);}*rvalues(){for(let e of this.#E())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e]);}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let i of this.#_()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;if(s!==void 0&&e(s,this.#i[i],this))return this.get(this.#i[i],t)}}forEach(e,t=this){for(let i of this.#_()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,this.#i[i],this);}}rforEach(e,t=this){for(let i of this.#E()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,this.#i[i],this);}}purgeStale(){let e=false;for(let t of this.#E({allowStale:true}))this.#p(t)&&(this.#G(this.#i[t],"expire"),e=true);return e}info(e){let t=this.#r.get(e);if(t===void 0)return;let i=this.#e[t],r=this.#t(i)?i.__staleWhileFetching:i;if(r===void 0)return;let s={value:r};if(this.#c&&this.#v){let h=this.#c[t],c=this.#v[t];if(h&&c){let d=h-(k.now()-c);s.ttl=d,s.start=Date.now();}}return this.#S&&(s.size=this.#S[t]),s}dump(){let e=[];for(let t of this.#_({allowStale:true})){let i=this.#i[t],r=this.#e[t],s=this.#t(r)?r.__staleWhileFetching:r;if(s===void 0||i===void 0)continue;let h={value:s};if(this.#c&&this.#v){h.ttl=this.#c[t];let c=k.now()-this.#v[t];h.start=Math.floor(Date.now()-c);}this.#S&&(h.size=this.#S[t]),e.unshift([i,h]);}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=k.now()-r;}this.set(t,i.value,i);}}set(e,t,i={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:s,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:d}=i,{noUpdateTTL:y=this.noUpdateTTL}=i,_=this.#k(e,t,i.size||0,c);if(this.maxEntrySize&&_>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),this.#G(e,"set"),this;let m=this.#n===0?void 0:this.#r.get(e);if(m===void 0)m=this.#n===0?this.#s:this.#b.length!==0?this.#b.pop():this.#n===this.#l?this.#F(false):this.#n,this.#i[m]=e,this.#e[m]=t,this.#r.set(e,m),this.#h[this.#s]=m,this.#d[m]=this.#s,this.#s=m,this.#n++,this.#N(m,_,d),d&&(d.set="add"),y=false,this.#M&&this.#A?.(t,e,"add");else {this.#x(m);let w=this.#e[m];if(t!==w){if(this.#H&&this.#t(w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=w;E!==void 0&&!h&&(this.#w&&this.#m?.(E,e,"set"),this.#f&&this.#o?.push([E,e,"set"]));}else h||(this.#w&&this.#m?.(w,e,"set"),this.#f&&this.#o?.push([w,e,"set"]));if(this.#C(m),this.#N(m,_,d),this.#e[m]=t,d){d.set="replace";let E=w&&this.#t(w)?w.__staleWhileFetching:w;E!==void 0&&(d.oldValue=E);}}else d&&(d.set="update");this.#M&&this.onInsert?.(t,e,t===w?"update":"replace");}if(r!==0&&!this.#c&&this.#L(),this.#c&&(y||this.#R(m,r,s),d&&this.#D(d,m)),!h&&this.#f&&this.#o){let w=this.#o,E;for(;E=w?.shift();)this.#y?.(...E);}return this}pop(){try{for(;this.#n;){let e=this.#e[this.#a];if(this.#F(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#f&&this.#o){let e=this.#o,t;for(;t=e?.shift();)this.#y?.(...t);}}}#F(e){let t=this.#a,i=this.#i[t],r=this.#e[t];return this.#H&&this.#t(r)?r.__abortController.abort(new Error("evicted")):(this.#w||this.#f)&&(this.#w&&this.#m?.(r,i,"evict"),this.#f&&this.#o?.push([r,i,"evict"])),this.#C(t),e&&(this.#i[t]=void 0,this.#e[t]=void 0,this.#b.push(t)),this.#n===1?(this.#a=this.#s=0,this.#b.length=0):this.#a=this.#h[t],this.#r.delete(i),this.#n--,t}has(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=t,s=this.#r.get(e);if(s!==void 0){let h=this.#e[s];if(this.#t(h)&&h.__staleWhileFetching===void 0)return false;if(this.#p(s))r&&(r.has="stale",this.#D(r,s));else return i&&this.#O(s),r&&(r.has="hit",this.#D(r,s)),true}else r&&(r.has="miss");return false}peek(e,t={}){let{allowStale:i=this.allowStale}=t,r=this.#r.get(e);if(r===void 0||!i&&this.#p(r))return;let s=this.#e[r];return this.#t(s)?s.__staleWhileFetching:s}#I(e,t,i,r){let s=t===void 0?void 0:this.#e[t];if(this.#t(s))return s;let h=new K,{signal:c}=i;c?.addEventListener("abort",()=>h.abort(c.reason),{signal:h.signal});let d={signal:h.signal,options:i,context:r},y=(G,T=false)=>{let{aborted:S}=h.signal,H=i.ignoreFetchAbort&&G!==void 0;if(i.status&&(S&&!T?(i.status.fetchAborted=true,i.status.fetchError=h.signal.reason,H&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),S&&!H&&!T)return m(h.signal.reason);let x=E;return this.#e[t]===E&&(G===void 0?x.__staleWhileFetching?this.#e[t]=x.__staleWhileFetching:this.#G(e,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(e,G,d.options))),G},_=G=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=G),m(G)),m=G=>{let{aborted:T}=h.signal,S=T&&i.allowStaleOnFetchAbort,H=S||i.allowStaleOnFetchRejection,x=H||i.noDeleteOnFetchRejection,A=E;if(this.#e[t]===E&&(!x||A.__staleWhileFetching===void 0?this.#G(e,"fetch"):S||(this.#e[t]=A.__staleWhileFetching)),H)return i.status&&A.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw G},w=(G,T)=>{let S=this.#T?.(e,s,d);S&&S instanceof Promise&&S.then(H=>G(H===void 0?void 0:H),T),h.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(G(void 0),i.allowStaleOnFetchAbort&&(G=H=>y(H,true)));});};i.status&&(i.status.fetchDispatched=true);let E=new Promise(w).then(y,_),N=Object.assign(E,{__abortController:h,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,N,{...d.options,status:void 0}),t=this.#r.get(e)):this.#e[t]=N,N}#t(e){if(!this.#H)return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof K}async fetch(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:d=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:_=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:E=this.ignoreFetchAbort,allowStaleOnFetchAbort:N=this.allowStaleOnFetchAbort,context:G,forceRefresh:T=false,status:S,signal:H}=t;if(!this.#H)return S&&(S.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:s,status:S});let x={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:s,ttl:h,noDisposeOnSet:c,size:d,sizeCalculation:y,noUpdateTTL:_,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:N,ignoreFetchAbort:E,status:S,signal:H},A=this.#r.get(e);if(A===void 0){S&&(S.fetch="miss");let C=this.#I(e,A,x,G);return C.__returned=C}else {let C=this.#e[A];if(this.#t(C)){let u=i&&C.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",u&&(S.returnedStale=true)),u?C.__staleWhileFetching:C.__returned=C}let o=this.#p(A);if(!T&&!o)return S&&(S.fetch="hit"),this.#x(A),r&&this.#O(A),S&&this.#D(S,A),C;let a=this.#I(e,A,x,G),f=a.__staleWhileFetching!==void 0&&i;return S&&(S.fetch=o?"stale":"refresh",f&&o&&(S.returnedStale=true)),f?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let i=await this.fetch(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let i=this.#z;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:s,...h}=t,c=this.get(e,h);if(!s&&c!==void 0)return c;let d=i(e,c,{options:h,context:r});return this.set(e,d,h),d}get(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:h}=t,c=this.#r.get(e);if(c!==void 0){let d=this.#e[c],y=this.#t(d);return h&&this.#D(h,c),this.#p(c)?(h&&(h.get="stale"),y?(h&&i&&d.__staleWhileFetching!==void 0&&(h.returnedStale=true),i?d.__staleWhileFetching:void 0):(s||this.#G(e,"expire"),h&&i&&(h.returnedStale=true),i?d:void 0)):(h&&(h.get="hit"),y?d.__staleWhileFetching:(this.#x(c),r&&this.#O(c),d))}else h&&(h.get="miss");}#P(e,t){this.#d[t]=e,this.#h[e]=t;}#x(e){e!==this.#s&&(e===this.#a?this.#a=this.#h[e]:this.#P(this.#d[e],this.#h[e]),this.#P(this.#s,e),this.#s=e);}delete(e){return this.#G(e,"delete")}#G(e,t){let i=false;if(this.#n!==0){let r=this.#r.get(e);if(r!==void 0)if(i=true,this.#n===1)this.#j(t);else {this.#C(r);let s=this.#e[r];if(this.#t(s)?s.__abortController.abort(new Error("deleted")):(this.#w||this.#f)&&(this.#w&&this.#m?.(s,e,t),this.#f&&this.#o?.push([s,e,t])),this.#r.delete(e),this.#i[r]=void 0,this.#e[r]=void 0,r===this.#s)this.#s=this.#d[r];else if(r===this.#a)this.#a=this.#h[r];else {let h=this.#d[r];this.#h[h]=this.#h[r];let c=this.#h[r];this.#d[c]=this.#d[r];}this.#n--,this.#b.push(r);}}if(this.#f&&this.#o?.length){let r=this.#o,s;for(;s=r?.shift();)this.#y?.(...s);}return i}clear(){return this.#j("delete")}#j(e){for(let t of this.#E({allowStale:true})){let i=this.#e[t];if(this.#t(i))i.__abortController.abort(new Error("deleted"));else {let r=this.#i[t];this.#w&&this.#m?.(i,r,e),this.#f&&this.#o?.push([i,r,e]);}}if(this.#r.clear(),this.#e.fill(void 0),this.#i.fill(void 0),this.#c&&this.#v&&(this.#c.fill(0),this.#v.fill(0)),this.#S&&this.#S.fill(0),this.#a=0,this.#s=0,this.#b.length=0,this.#g=0,this.#n=0,this.#f&&this.#o){let t=this.#o,i;for(;i=t?.shift();)this.#y?.(...i);}}};var L=class{cache;map=new Map;constructor(e){this.cache=new B({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}get entries(){return this.map.entries}keys(){return this.map.keys()}get values(){return this.map.values}};var p=class l{static _diffHistory=new L({cacheSize:5});static _stepsInfoHistory=new L({cacheSize:5});static _narrationHistory=new L({cacheSize:50});static stepLimitSaved=20;static goBackRunning=false;static _originalStepData=void 0;static get originalStepData(){return l._originalStepData?M(l._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){l._originalStepData=M(e);}};var W=class{get stepsInfoMap(){return p._stepsInfoHistory}get diffMap(){return p._diffHistory}get narrationMap(){return p._narrationHistory}get size(){return p._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return p._stepsInfoHistory.keys()}get(e){let t=p._narrationHistory.get(e);if(!(t&&Object.keys(t).length===1&&t.stepIndex!==void 0))return t}delete(e){p._stepsInfoHistory.delete(e),p._diffHistory.delete(e),p._narrationHistory.delete(e);}internalRestoreOldGameState(e,t){if(e<=0||this.size==0)return t;let i=this.lastKey;if(typeof i!="number")return b.error("You can't go back, there is no step to go back"),t;let r=p._diffHistory.get(i);if(r)try{let s=oe(t,r);return F.stepCounter=i,this.delete(i),this.internalRestoreOldGameState(e-1,s)}catch(s){return b.error("Error applying diff",s),t}else return b.error("You can't go back, there is no step to go back"),t}async goBack(e,t=1){if(t<=0){b.warn("The parameter steps must be greater than 0");return}if(p._diffHistory.size<1){b.warn("You can't go back, there is no step to go back");return}if(p.goBackRunning){b.warn("Go back is already running");return}p.goBackRunning=true;try{let i=M(this.internalRestoreOldGameState(t,p.originalStepData));i?await F.restoreGameStepState(i,e):b.error("Error going back"),p.goBackRunning=!1;}catch(i){b.error("Error going back",i),p.goBackRunning=false;}}add(e,t={}){let i=p.originalStepData,{ignoreSameStep:r}=t,s=F.currentGameStepState;if(!r&&this.isSameStep(i,s))return;let h=this.lastKey;(async()=>{try{let d,y;typeof h=="number"&&(d=p._stepsInfoHistory.get(h),y=p._narrationHistory.get(h));let _=(0,ue.diff)(i,s);p._stepsInfoHistory.set(e.index,e),_?p._diffHistory.set(e.index,_):b.warn("It was not possible to create the difference between the two steps");let m={},w=this.itemMapper({step:e},m);if(p._narrationHistory.set(e.index,w),d&&y&&typeof h=="number"){let E=this.itemMapper({...m,step:d},{});p._narrationHistory.set(h,E);}}catch(d){b.error("Error adding history step",d);}})(),p.originalStepData=s;}itemMapper(e,t){let{step:i,choiceIndexMade:r,inputValue:s,removeDialogue:h}=e,c=i.dialogue||i.dialoge;t&&i.isGlued&&(t.removeDialogue=true),h&&(c=void 0);let d=i.choices;if(t&&i.currentLabel&&i.choiceIndexMade!==void 0&&(t.choiceIndexMade=i.choiceIndexMade),i.inputValue&&t&&(t.inputValue=i.inputValue),c||d||s){let y=d?.map((_,m)=>{let w=false;return _.oneTime&&i.alreadyMadeChoices&&i.alreadyMadeChoices.includes(m)&&(w=true),{text:_.text,type:_.type,isResponse:false,hidden:w}});if(y){if(y.every(_=>_.hidden)){let _=y.find(m=>m.hidden===false);_&&(_.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:c?{...c,character:c.character?F.getCharacter(c.character)||c.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,stepIndex:i.index,inputValue:s}}return {stepIndex:i.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((i,r)=>i-r).forEach(i=>{let r=this.get(i);r&&e.push(r);}),e}get latestCurrentLabelHistory(){let e=[],t=Array.from(this.keys()).sort((c,d)=>d-c),i=t.shift();if(typeof i!="number")return e;let r=p._stepsInfoHistory.get(i);if(!r)return e;let s=r.currentLabel,h=r.index;return t.every(c=>{let d=this.get(c);if(d){let y=p._stepsInfoHistory.get(c);if(!y||!(y.currentLabel===s&&y.index<=h))return false;e.push(d);}return h=c,true}),e.reverse()}removeNarrativeHistory(e){if(e){let t=Array.from(this.keys()).sort((i,r)=>i-r);t=t.slice(0,e),t.forEach(i=>{p._narrationHistory.delete(i),p._stepsInfoHistory.delete(i),p._diffHistory.delete(i);});}else p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:p._diffHistory.has(e)}blockGoBack(){F.currentStepsRunningNumber===0&&p._diffHistory.clear();}isSameStep(e,t){if(e.openedLabels.length===t.openedLabels.length)try{let i=JSON.stringify(e.openedLabels),r=JSON.stringify(t.openedLabels);if(i===r&&e.path===t.path&&e.labelIndex===t.labelIndex)return !0}catch(i){return b.error("Error comparing opened labels",i),true}return false}clear(){p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear(),p._originalStepData=void 0;}get stepLimitSaved(){return p.stepLimitSaved}set stepLimitSaved(e){p.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((i,r)=>i-r);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let t=[];return e.forEach(i=>{let r=p._stepsInfoHistory.get(i);if(r){let s=p._diffHistory.get(i);t.push({...r,diff:s});}}),{stepsHistory:M(t),originalStepData:M(p._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((i,r)=>i-r),t={};e.forEach(i=>{let r=p._stepsInfoHistory.get(i);if(r){let s={...t};t={};let h=this.itemMapper({step:r,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},t);h&&p._narrationHistory.set(i,h);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(i=>{i.diff&&p._diffHistory.set(i.index,i.diff);let r={...i,diff:void 0};p._stepsInfoHistory.set(i.index,r);}),this.restoreNarrativeHistory()):b.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?p._originalStepData=e.originalStepData:b.warn("Could not import originalStepData data, so will be ignored");}catch(t){b.error("Error importing data",t);}}};var Ze=new W;
|
|
2
|
+
exports.HistoryManagerStatic=p;exports.stepHistory=Ze;
|
package/dist/history/index.d.cts
CHANGED
|
@@ -2,16 +2,18 @@ import HistoryManagerInterface from './interfaces/HistoryManagerInterface.cjs';
|
|
|
2
2
|
export { default as HistoryManagerStatic } from './HistoryManagerStatic.cjs';
|
|
3
3
|
export { default as HistoryGameState } from './interfaces/HistoryGameState.cjs';
|
|
4
4
|
import '@drincs/pixi-vn';
|
|
5
|
-
import '../narration/interfaces/HistoryStep.cjs';
|
|
6
5
|
import 'deep-diff';
|
|
7
6
|
import 'microdiff';
|
|
7
|
+
import '../classes/CachedMap.cjs';
|
|
8
|
+
import 'lru-cache';
|
|
9
|
+
import '../narration/interfaces/HistoryStep.cjs';
|
|
8
10
|
import '../storage/types/StorageElementType.cjs';
|
|
9
11
|
import '../narration/interfaces/StoredChoiceInterface.cjs';
|
|
10
12
|
import '../narration/types/CloseType.cjs';
|
|
11
13
|
import '../narration/types/LabelIdType.cjs';
|
|
12
14
|
import '../narration/types/LabelRunModeType.cjs';
|
|
13
15
|
import '../narration/interfaces/DialogueInterface.cjs';
|
|
14
|
-
import '../narration/interfaces/
|
|
16
|
+
import '../narration/interfaces/NarrationHistory.cjs';
|
|
15
17
|
import '../narration/types/HistoryChoiceMenuOption.cjs';
|
|
16
18
|
|
|
17
19
|
declare const stepHistory: HistoryManagerInterface;
|
package/dist/history/index.d.ts
CHANGED
|
@@ -2,16 +2,18 @@ import HistoryManagerInterface from './interfaces/HistoryManagerInterface.js';
|
|
|
2
2
|
export { default as HistoryManagerStatic } from './HistoryManagerStatic.js';
|
|
3
3
|
export { default as HistoryGameState } from './interfaces/HistoryGameState.js';
|
|
4
4
|
import '@drincs/pixi-vn';
|
|
5
|
-
import '../narration/interfaces/HistoryStep.js';
|
|
6
5
|
import 'deep-diff';
|
|
7
6
|
import 'microdiff';
|
|
7
|
+
import '../classes/CachedMap.js';
|
|
8
|
+
import 'lru-cache';
|
|
9
|
+
import '../narration/interfaces/HistoryStep.js';
|
|
8
10
|
import '../storage/types/StorageElementType.js';
|
|
9
11
|
import '../narration/interfaces/StoredChoiceInterface.js';
|
|
10
12
|
import '../narration/types/CloseType.js';
|
|
11
13
|
import '../narration/types/LabelIdType.js';
|
|
12
14
|
import '../narration/types/LabelRunModeType.js';
|
|
13
15
|
import '../narration/interfaces/DialogueInterface.js';
|
|
14
|
-
import '../narration/interfaces/
|
|
16
|
+
import '../narration/interfaces/NarrationHistory.js';
|
|
15
17
|
import '../narration/types/HistoryChoiceMenuOption.js';
|
|
16
18
|
|
|
17
19
|
declare const stepHistory: HistoryManagerInterface;
|
package/dist/history/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var te=Object.create;var J=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var oe=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var se=(n,t,a,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let p of ie(t))!ae.call(n,p)&&p!==a&&J(n,p,{get:()=>t[p],enumerable:!(o=re(t,p))||o.enumerable});return n};var le=(n,t,a)=>(a=n!=null?te(ne(n)):{},se(J(a,"default",{value:n,enumerable:true}),n));var q=oe((j,Y)=>{(function(n,t){var a=t(n);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return a});else if(typeof j=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))Y.exports=a;else {var o=n.DeepDiff;a.noConflict=function(){return n.DeepDiff===a&&(n.DeepDiff=o),a},n.DeepDiff=a;}})(j,function(n){var t=["N","E","A","D"];function a(r,i){r.super_=i,r.prototype=Object.create(i.prototype,{constructor:{value:r,enumerable:false,writable:true,configurable:true}});}function o(r,i){Object.defineProperty(this,"kind",{value:r,enumerable:true}),i&&i.length&&Object.defineProperty(this,"path",{value:i,enumerable:true});}function p(r,i,e){p.super_.call(this,"E",r),Object.defineProperty(this,"lhs",{value:i,enumerable:true}),Object.defineProperty(this,"rhs",{value:e,enumerable:true});}a(p,o);function y(r,i){y.super_.call(this,"N",r),Object.defineProperty(this,"rhs",{value:i,enumerable:true});}a(y,o);function b(r,i){b.super_.call(this,"D",r),Object.defineProperty(this,"lhs",{value:i,enumerable:true});}a(b,o);function h(r,i,e){h.super_.call(this,"A",r),Object.defineProperty(this,"index",{value:i,enumerable:true}),Object.defineProperty(this,"item",{value:e,enumerable:true});}a(h,o);function G(r,i,e){var s=r.slice((i)+1||r.length);return r.length=i<0?r.length+i:i,r.push.apply(r,s),r}function S(r){var i=typeof r;return i!=="object"?i:r===Math?"math":r===null?"null":Array.isArray(r)?"array":Object.prototype.toString.call(r)==="[object Date]"?"date":typeof r.toString=="function"&&/^\/.*\//.test(r.toString())?"regexp":"object"}function v(r){var i=0;if(r.length===0)return i;for(var e=0;e<r.length;e++){var s=r.charCodeAt(e);i=(i<<5)-i+s,i=i&i;}return i}function H(r){var i=0,e=S(r);if(e==="array"){r.forEach(function(C){i+=H(C);});var s="[type: array, hash: "+i+"]";return i+v(s)}if(e==="object"){for(var l in r)if(r.hasOwnProperty(l)){var m="[ type: object, key: "+l+", value hash: "+H(r[l])+"]";i+=v(m);}return i}var d="[ type: "+e+" ; value: "+r+"]";return i+v(d)}function E(r,i,e,s,l,m,d,C){e=e||[],l=l||[],d=d||[];var g=l.slice(0);if(typeof m<"u"&&m!==null){if(s){if(typeof s=="function"&&s(g,m))return;if(typeof s=="object"){if(s.prefilter&&s.prefilter(g,m))return;if(s.normalize){var L=s.normalize(g,m,r,i);L&&(r=L[0],i=L[1]);}}}g.push(m);}S(r)==="regexp"&&S(i)==="regexp"&&(r=r.toString(),i=i.toString());var P=typeof r,ee=typeof i,c,N,D,I,F=P!=="undefined"||d&&d.length>0&&d[d.length-1].lhs&&Object.getOwnPropertyDescriptor(d[d.length-1].lhs,m),B=ee!=="undefined"||d&&d.length>0&&d[d.length-1].rhs&&Object.getOwnPropertyDescriptor(d[d.length-1].rhs,m);if(!F&&B)e.push(new y(g,i));else if(!B&&F)e.push(new b(g,r));else if(S(r)!==S(i))e.push(new p(g,r,i));else if(S(r)==="date"&&r-i!==0)e.push(new p(g,r,i));else if(P==="object"&&r!==null&&i!==null){for(c=d.length-1;c>-1;--c)if(d[c].lhs===r){I=true;break}if(I)r!==i&&e.push(new p(g,r,i));else {if(d.push({lhs:r,rhs:i}),Array.isArray(r)){for(C&&(r.sort(function(z,A){return H(z)-H(A)}),i.sort(function(z,A){return H(z)-H(A)})),c=i.length-1,N=r.length-1;c>N;)e.push(new h(g,c,new y(void 0,i[c--])));for(;N>c;)e.push(new h(g,N,new b(void 0,r[N--])));for(;c>=0;--c)E(r[c],i[c],e,s,g,c,d,C);}else {var $=Object.keys(r),_=Object.keys(i);for(c=0;c<$.length;++c)D=$[c],I=_.indexOf(D),I>=0?(E(r[D],i[D],e,s,g,D,d,C),_[I]=null):E(r[D],void 0,e,s,g,D,d,C);for(c=0;c<_.length;++c)D=_[c],D&&E(void 0,i[D],e,s,g,D,d,C);}d.length=d.length-1;}}else r!==i&&(P==="number"&&isNaN(r)&&isNaN(i)||e.push(new p(g,r,i)));}function T(r,i,e,s,l){var m=[];if(E(r,i,m,s,null,null,null,l),e)for(var d=0;d<m.length;++d)e(m[d]);return m}function U(r,i,e,s,l,m,d){return E(r,i,e,s,l,m,d,true)}function M(r,i,e,s){var l=s?function(d){d&&s.push(d);}:void 0,m=T(r,i,l,e);return s||(m.length?m:void 0)}function W(r,i,e,s){var l=s?function(d){d&&s.push(d);}:void 0,m=T(r,i,l,e,true);return s||(m.length?m:void 0)}function k(r,i,e){if(e.path&&e.path.length){var s=r[i],l,m=e.path.length-1;for(l=0;l<m;l++)s=s[e.path[l]];switch(e.kind){case "A":k(s[e.path[l]],e.index,e.item);break;case "D":delete s[e.path[l]];break;case "E":case "N":s[e.path[l]]=e.rhs;break}}else switch(e.kind){case "A":k(r[i],e.index,e.item);break;case "D":r=G(r,i);break;case "E":case "N":r[i]=e.rhs;break}return r}function R(r,i,e){if(typeof e>"u"&&i&&~t.indexOf(i.kind)&&(e=i),r&&e&&e.kind){for(var s=r,l=-1,m=e.path?e.path.length-1:0;++l<m;)typeof s[e.path[l]]>"u"&&(s[e.path[l]]=typeof e.path[l+1]<"u"&&typeof e.path[l+1]=="number"?[]:{}),s=s[e.path[l]];switch(e.kind){case "A":e.path&&typeof s[e.path[l]]>"u"&&(s[e.path[l]]=[]),k(e.path?s[e.path[l]]:s,e.index,e.item);break;case "D":delete s[e.path[l]];break;case "E":case "N":s[e.path[l]]=e.rhs;break}}}function V(r,i,e){if(e.path&&e.path.length){var s=r[i],l,m=e.path.length-1;for(l=0;l<m;l++)s=s[e.path[l]];switch(e.kind){case "A":V(s[e.path[l]],e.index,e.item);break;case "D":s[e.path[l]]=e.lhs;break;case "E":s[e.path[l]]=e.lhs;break;case "N":delete s[e.path[l]];break}}else switch(e.kind){case "A":V(r[i],e.index,e.item);break;case "D":r[i]=e.lhs;break;case "E":r[i]=e.lhs;break;case "N":r=G(r,i);break}return r}function X(r,i,e){if(r&&i&&e&&e.kind){var s=r,l,m;for(m=e.path.length-1,l=0;l<m;l++)typeof s[e.path[l]]>"u"&&(s[e.path[l]]={}),s=s[e.path[l]];switch(e.kind){case "A":V(s[e.path[l]],e.index,e.item);break;case "D":s[e.path[l]]=e.lhs;break;case "E":s[e.path[l]]=e.lhs;break;case "N":delete s[e.path[l]];break}}}function Z(r,i,e){if(r&&i){var s=function(l){(!e||e(r,i,l))&&R(r,i,l);};T(r,i,s);}}return Object.defineProperties(M,{diff:{value:M,enumerable:true},orderIndependentDiff:{value:W,enumerable:true},observableDiff:{value:T,enumerable:true},orderIndependentObservableDiff:{value:U,enumerable:true},orderIndepHash:{value:H,enumerable:true},applyDiff:{value:Z,enumerable:true},applyChange:{value:R,enumerable:true},revertChange:{value:X,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),M.DeepDiff=M,n&&(n.DeepDiff=M),M});});var Q=le(q());var f;(p=>(p.log=(y,...b)=>console.log(`[Pixi\u2019VN] ${y}`,...b),p.warn=(y,...b)=>console.warn(`[Pixi\u2019VN] ${y}`,...b),p.error=(y,...b)=>console.error(`[Pixi\u2019VN] ${y}`,...b),p.info=(y,...b)=>console.info(`[Pixi\u2019VN] ${y}`,...b)))(f||={});var w=class n{static init(t){n._getStepCounter=t.getStepCounter,n._setStepCounter=t.setStepCounter,n._getCurrentGameStepState=t.getCurrentGameStepState,n._restoreGameStepState=t.restoreGameStepState,n._getOpenedLabels=t.getOpenedLabels,t.onGoNextEnd&&(n._onGoNextEnd=t.onGoNextEnd),n._getVariable=t.getVariable,n._setVariable=t.setVariable,n._removeVariable=t.removeVariable,n._getFlag=t.getFlag,n._setFlag=t.setFlag,t.onLabelClosing&&(n._onLabelClosing=t.onLabelClosing),n._addHistoryItem=t.addHistoryItem,n._getCurrentStepsRunningNumber=t.getCurrentStepsRunningNumber,n._getCharacter=t.getCharacter;}static _getStepCounter=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return n._getStepCounter()}static set stepCounter(t){n._setStepCounter(t);}static _getCurrentGameStepState=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return n._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return n._restoreGameStepState}static _getOpenedLabels=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return n._getOpenedLabels()}static _onGoNextEnd=async()=>{};static get onGoNextEnd(){return n._onGoNextEnd}static _getVariable=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return n._getVariable}static _setVariable=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return n._setVariable}static _removeVariable=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return n._removeVariable}static _getFlag=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return n._getFlag}static _setFlag=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return n._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return n._onLabelClosing}static _addHistoryItem=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return n._addHistoryItem}static _getCurrentStepsRunningNumber=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentStepsRunningNumber(){return n._getCurrentStepsRunningNumber()}static _getCharacter=()=>{throw f.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")};static get getCharacter(){return n._getCharacter}static onEnd;static onError};function x(n){try{if(typeof n>"u")return n;let t=JSON.stringify(n);return JSON.parse(t)}catch(t){throw f.error("Error creating exportable element",n,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}function K(n,t){let a=x(n);return t.length>1&&"type"in t[0]&&(t=t.reverse()),t.forEach(o=>{"type"in o?pe(a,o):ue(a,o);}),a}function pe(n,t){let a=n;t.path&&t.path.length>0?t.path.forEach((o,p)=>{if(t.path&&p===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":a[o]=t.oldValue;break;case "CREATE":Array.isArray(a)&&typeof o=="number"?a.splice(o,1):delete a[o];break}else a=a[o];}):f.warn("No path found, skipping diff",t);}function ue(n,t){let a=n;t.path&&t.path.length>0?t.path.forEach((o,p)=>{if(t.path&&p===t.path.length-1){if(t.kind==="E"||t.kind==="D")a[o]=t.lhs;else if(t.kind==="N")Number.isInteger(o)?Array.isArray(a)&&a.splice(o,1):typeof o=="string"&&delete a[o];else if(t.kind==="A"){let y=t.index;t.item.kind==="N"?a[o].splice(y,1):t.item.kind==="E"||t.item.kind==="D"?a[o][y]=t.item.lhs:t.item.kind==="A"?f.warn("Nested array found, skipping diff",t):f.warn("No array found, skipping diff",t);}}else a=a[o];}):f.warn("No path found, skipping diff",t);}var u=class n{static _stepsHistory=[];static get stepsHistory(){return x(n._stepsHistory)}static stepLimitSaved=20;static goBackRunning=false;static get lastHistoryStep(){return n._stepsHistory.length>0?n._stepsHistory[n._stepsHistory.length-1]:null}static _originalStepData=void 0;static get originalStepData(){return n._originalStepData?x(n._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){n._originalStepData=x(t);}};var O=class{get stepsHistory(){return u.stepsHistory}internalRestoreOldGameState(t,a){if(t<=0||u._stepsHistory.length==0)return a;let o=u.lastHistoryStep;if(o?.diff)try{let p=K(a,o.diff);return w.stepCounter=o.index,u._stepsHistory.pop(),this.internalRestoreOldGameState(t-1,p)}catch(p){return f.error("Error applying diff",p),a}else return f.error("You can't go back, there is no step to go back"),a}async goBack(t,a=1){if(a<=0){f.warn("The parameter steps must be greater than 0");return}if(u._stepsHistory.length<=1){f.warn("You can't go back, there is no step to go back");return}if(u.goBackRunning){f.warn("Go back is already running");return}u.goBackRunning=true;try{let o=x(this.internalRestoreOldGameState(a,u.originalStepData));o?await w.restoreGameStepState(o,t):f.error("Error going back"),u.goBackRunning=!1;}catch(o){f.error("Error going back",o),u.goBackRunning=false;}}add(t={},a={}){let o=u.originalStepData,{ignoreSameStep:p}=a,y=w.currentGameStepState;if(!p&&this.isSameStep(o,y))return;u._stepsHistory.push({});let b=u._stepsHistory.length-1;(async()=>{try{let G=(0,Q.diff)(o,y);u._stepsHistory[b]={...t,diff:G};}catch(G){f.error("Error adding history step",G);}})(),u.originalStepData=y;}historyStepMapper(t,a){let{step:o,choiceIndexMade:p,inputValue:y,dialodueGlue:b}=t,h=o.dialogue||o.dialoge;b&&(h=void 0);let G=o.choices;if(a&&o.currentLabel&&o.choiceIndexMade!==void 0&&(a.choiceIndexMade=o.choiceIndexMade),o.inputValue&&a&&(a.inputValue=o.inputValue),h||G){let S=G?.map((v,H)=>{let E=false;return v.oneTime&&o.alreadyMadeChoices&&o.alreadyMadeChoices.includes(H)&&(E=true),{text:v.text,type:v.type,isResponse:false,hidden:E}});if(S){if(S.every(v=>v.hidden)){let v=S.find(H=>H.hidden===false);v&&(v.hidden=false);}p!==void 0&&(S[p].isResponse=true);}return {dialogue:h?{...h,character:h.character?w.getCharacter(h.character)||h.character:void 0}:void 0,playerMadeChoice:typeof p=="number",choices:S,stepIndex:o.index,inputValue:y}}}get narrativeHistory(){let t=[],a={},o=u.stepsHistory;for(let p=o.length-1;p>=0;p--){let y=o[p],b={...a};a={choiceIndexMade:void 0,inputValue:void 0};let h=this.historyStepMapper({step:y,choiceIndexMade:b.choiceIndexMade,inputValue:b.inputValue,dialodueGlue:y.dialogGlue},a);h&&t.push(h);}return t.reverse()}get latestCurrentLabelHistory(){let t=[],a={},o=u.stepsHistory,p=o[o.length-1],y=p.currentLabel,b=p.index;for(let h=o.length-1;h>=0&&o[h].currentLabel===y&&o[h].index<=b;h--){let G=o[h],S={...a};a={choiceIndexMade:void 0,inputValue:void 0};let v=this.historyStepMapper({step:G,choiceIndexMade:S.choiceIndexMade,inputValue:S.inputValue,dialodueGlue:G.dialogGlue},a);v&&t.push(v);}return t.reverse()}removeNarrativeHistory(t){t?u._stepsHistory.splice(0,t):u._stepsHistory=[];}get canGoBack(){return u._stepsHistory.length<=1?false:!!u.lastHistoryStep?.diff}blockGoBack(){w.currentStepsRunningNumber===0&&u._stepsHistory.length>1&&(u._stepsHistory[u._stepsHistory.length-1]={...u._stepsHistory[u._stepsHistory.length-1],diff:void 0});}isSameStep(t,a){if(t.openedLabels.length===a.openedLabels.length)try{let o=JSON.stringify(t.openedLabels),p=JSON.stringify(a.openedLabels);if(o===p&&t.path===a.path&&t.labelIndex===a.labelIndex)return !0}catch(o){return f.error("Error comparing opened labels",o),true}return false}clear(){u._stepsHistory=[],u._originalStepData=void 0;}get stepLimitSaved(){return u.stepLimitSaved}set stepLimitSaved(t){u.stepLimitSaved=t;}export(){let t=u._stepsHistory.length-this.stepLimitSaved,a=u._stepsHistory.map((o,p)=>({diff:t>p?void 0:o.diff,...o}));return {stepsHistory:x(a),originalStepData:x(u._originalStepData)}}async restore(t){this.clear();try{t.hasOwnProperty("stepsHistory")?u._stepsHistory=t.stepsHistory:f.warn("Could not import stepsHistory data, so will be ignored"),t.hasOwnProperty("originalStepData")?u._originalStepData=t.originalStepData:f.warn("Could not import originalStepData data, so will be ignored");}catch(a){f.error("Error importing data",a);}}};var Oe=new O;
|
|
2
|
-
export{
|
|
1
|
+
var ce=Object.create;var re=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ye=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var be=(l,e)=>()=>(e||l((e={exports:{}}).exports,e),e.exports);var Se=(l,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of me(e))!ge.call(l,r)&&r!==t&&re(l,r,{get:()=>e[r],enumerable:!(i=pe(e,r))||i.enumerable});return l};var ve=(l,e,t)=>(t=l!=null?ce(ye(l)):{},Se(re(t,"default",{value:l,enumerable:true}),l));var se=be((X,ne)=>{(function(l,e){var t=e(l);if(typeof define=="function"&&define.amd)define("DeepDiff",function(){return t});else if(typeof X=="object"||typeof navigator=="object"&&navigator.product.match(/ReactNative/i))ne.exports=t;else {var i=l.DeepDiff;t.noConflict=function(){return l.DeepDiff===t&&(l.DeepDiff=i),t},l.DeepDiff=t;}})(X,function(l){var e=["N","E","A","D"];function t(o,a){o.super_=a,o.prototype=Object.create(a.prototype,{constructor:{value:o,enumerable:false,writable:true,configurable:true}});}function i(o,a){Object.defineProperty(this,"kind",{value:o,enumerable:true}),a&&a.length&&Object.defineProperty(this,"path",{value:a,enumerable:true});}function r(o,a,n){r.super_.call(this,"E",o),Object.defineProperty(this,"lhs",{value:a,enumerable:true}),Object.defineProperty(this,"rhs",{value:n,enumerable:true});}t(r,i);function s(o,a){s.super_.call(this,"N",o),Object.defineProperty(this,"rhs",{value:a,enumerable:true});}t(s,i);function h(o,a){h.super_.call(this,"D",o),Object.defineProperty(this,"lhs",{value:a,enumerable:true});}t(h,i);function c(o,a,n){c.super_.call(this,"A",o),Object.defineProperty(this,"index",{value:a,enumerable:true}),Object.defineProperty(this,"item",{value:n,enumerable:true});}t(c,i);function d(o,a,n){var f=o.slice((a)+1||o.length);return o.length=a<0?o.length+a:a,o.push.apply(o,f),o}function y(o){var a=typeof o;return a!=="object"?a:o===Math?"math":o===null?"null":Array.isArray(o)?"array":Object.prototype.toString.call(o)==="[object Date]"?"date":typeof o.toString=="function"&&/^\/.*\//.test(o.toString())?"regexp":"object"}function _(o){var a=0;if(o.length===0)return a;for(var n=0;n<o.length;n++){var f=o.charCodeAt(n);a=(a<<5)-a+f,a=a&a;}return a}function m(o){var a=0,n=y(o);if(n==="array"){o.forEach(function(R){a+=m(R);});var f="[type: array, hash: "+a+"]";return a+_(f)}if(n==="object"){for(var u in o)if(o.hasOwnProperty(u)){var v="[ type: object, key: "+u+", value hash: "+m(o[u])+"]";a+=_(v);}return a}var g="[ type: "+n+" ; value: "+o+"]";return a+_(g)}function w(o,a,n,f,u,v,g,R){n=n||[],u=u||[],g=g||[];var O=u.slice(0);if(typeof v<"u"&&v!==null){if(f){if(typeof f=="function"&&f(O,v))return;if(typeof f=="object"){if(f.prefilter&&f.prefilter(O,v))return;if(f.normalize){var $=f.normalize(O,v,o,a);$&&(o=$[0],a=$[1]);}}}O.push(v);}y(o)==="regexp"&&y(a)==="regexp"&&(o=o.toString(),a=a.toString());var Y=typeof o,de=typeof a,D,P,z,j,ee=Y!=="undefined"||g&&g.length>0&&g[g.length-1].lhs&&Object.getOwnPropertyDescriptor(g[g.length-1].lhs,v),te=de!=="undefined"||g&&g.length>0&&g[g.length-1].rhs&&Object.getOwnPropertyDescriptor(g[g.length-1].rhs,v);if(!ee&&te)n.push(new s(O,a));else if(!te&&ee)n.push(new h(O,o));else if(y(o)!==y(a))n.push(new r(O,o,a));else if(y(o)==="date"&&o-a!==0)n.push(new r(O,o,a));else if(Y==="object"&&o!==null&&a!==null){for(D=g.length-1;D>-1;--D)if(g[D].lhs===o){j=true;break}if(j)o!==a&&n.push(new r(O,o,a));else {if(g.push({lhs:o,rhs:a}),Array.isArray(o)){for(R&&(o.sort(function(J,q){return m(J)-m(q)}),a.sort(function(J,q){return m(J)-m(q)})),D=a.length-1,P=o.length-1;D>P;)n.push(new c(O,D,new s(void 0,a[D--])));for(;P>D;)n.push(new c(O,P,new h(void 0,o[P--])));for(;D>=0;--D)w(o[D],a[D],n,f,O,D,g,R);}else {var ie=Object.keys(o),U=Object.keys(a);for(D=0;D<ie.length;++D)z=ie[D],j=U.indexOf(z),j>=0?(w(o[z],a[z],n,f,O,z,g,R),U[j]=null):w(o[z],void 0,n,f,O,z,g,R);for(D=0;D<U.length;++D)z=U[D],z&&w(void 0,a[z],n,f,O,z,g,R);}g.length=g.length-1;}}else o!==a&&(Y==="number"&&isNaN(o)&&isNaN(a)||n.push(new r(O,o,a)));}function E(o,a,n,f,u){var v=[];if(w(o,a,v,f,null,null,null,u),n)for(var g=0;g<v.length;++g)n(v[g]);return v}function N(o,a,n,f,u,v,g){return w(o,a,n,f,u,v,g,true)}function G(o,a,n,f){var u=f?function(g){g&&f.push(g);}:void 0,v=E(o,a,u,n);return f||(v.length?v:void 0)}function T(o,a,n,f){var u=f?function(g){g&&f.push(g);}:void 0,v=E(o,a,u,n,true);return f||(v.length?v:void 0)}function S(o,a,n){if(n.path&&n.path.length){var f=o[a],u,v=n.path.length-1;for(u=0;u<v;u++)f=f[n.path[u]];switch(n.kind){case "A":S(f[n.path[u]],n.index,n.item);break;case "D":delete f[n.path[u]];break;case "E":case "N":f[n.path[u]]=n.rhs;break}}else switch(n.kind){case "A":S(o[a],n.index,n.item);break;case "D":o=d(o,a);break;case "E":case "N":o[a]=n.rhs;break}return o}function H(o,a,n){if(typeof n>"u"&&a&&~e.indexOf(a.kind)&&(n=a),o&&n&&n.kind){for(var f=o,u=-1,v=n.path?n.path.length-1:0;++u<v;)typeof f[n.path[u]]>"u"&&(f[n.path[u]]=typeof n.path[u+1]<"u"&&typeof n.path[u+1]=="number"?[]:{}),f=f[n.path[u]];switch(n.kind){case "A":n.path&&typeof f[n.path[u]]>"u"&&(f[n.path[u]]=[]),S(n.path?f[n.path[u]]:f,n.index,n.item);break;case "D":delete f[n.path[u]];break;case "E":case "N":f[n.path[u]]=n.rhs;break}}}function x(o,a,n){if(n.path&&n.path.length){var f=o[a],u,v=n.path.length-1;for(u=0;u<v;u++)f=f[n.path[u]];switch(n.kind){case "A":x(f[n.path[u]],n.index,n.item);break;case "D":f[n.path[u]]=n.lhs;break;case "E":f[n.path[u]]=n.lhs;break;case "N":delete f[n.path[u]];break}}else switch(n.kind){case "A":x(o[a],n.index,n.item);break;case "D":o[a]=n.lhs;break;case "E":o[a]=n.lhs;break;case "N":o=d(o,a);break}return o}function A(o,a,n){if(o&&a&&n&&n.kind){var f=o,u,v;for(v=n.path.length-1,u=0;u<v;u++)typeof f[n.path[u]]>"u"&&(f[n.path[u]]={}),f=f[n.path[u]];switch(n.kind){case "A":x(f[n.path[u]],n.index,n.item);break;case "D":f[n.path[u]]=n.lhs;break;case "E":f[n.path[u]]=n.lhs;break;case "N":delete f[n.path[u]];break}}}function C(o,a,n){if(o&&a){var f=function(u){(!n||n(o,a,u))&&H(o,a,u);};E(o,a,f);}}return Object.defineProperties(G,{diff:{value:G,enumerable:true},orderIndependentDiff:{value:T,enumerable:true},observableDiff:{value:E,enumerable:true},orderIndependentObservableDiff:{value:N,enumerable:true},orderIndepHash:{value:m,enumerable:true},applyDiff:{value:C,enumerable:true},applyChange:{value:H,enumerable:true},revertChange:{value:A,enumerable:true},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:true}}),G.DeepDiff=G,l&&(l.DeepDiff=G),G});});var ue=ve(se());var b;(r=>(r.log=(s,...h)=>console.log(`[Pixi\u2019VN] ${s}`,...h),r.warn=(s,...h)=>console.warn(`[Pixi\u2019VN] ${s}`,...h),r.error=(s,...h)=>console.error(`[Pixi\u2019VN] ${s}`,...h),r.info=(s,...h)=>console.info(`[Pixi\u2019VN] ${s}`,...h)))(b||={});var F=class l{static init(e){l._getStepCounter=e.getStepCounter,l._setStepCounter=e.setStepCounter,l._getCurrentGameStepState=e.getCurrentGameStepState,l._restoreGameStepState=e.restoreGameStepState,l._getOpenedLabels=e.getOpenedLabels,e.onGoNextEnd&&(l._onGoNextEnd=e.onGoNextEnd),l._getVariable=e.getVariable,l._setVariable=e.setVariable,l._removeVariable=e.removeVariable,l._getFlag=e.getFlag,l._setFlag=e.setFlag,e.onLabelClosing&&(l._onLabelClosing=e.onLabelClosing),l._addHistoryItem=e.addHistoryItem,l._getCurrentStepsRunningNumber=e.getCurrentStepsRunningNumber,l._getCharacter=e.getCharacter;}static _getStepCounter=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static _setStepCounter=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get stepCounter(){return l._getStepCounter()}static set stepCounter(e){l._setStepCounter(e);}static _getCurrentGameStepState=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentGameStepState(){return l._getCurrentGameStepState()}static _restoreGameStepState=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get restoreGameStepState(){return l._restoreGameStepState}static _getOpenedLabels=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get openedLabels(){return l._getOpenedLabels()}static _onGoNextEnd=async()=>{};static get onGoNextEnd(){return l._onGoNextEnd}static _getVariable=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getVariable(){return l._getVariable}static _setVariable=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setVariable(){return l._setVariable}static _removeVariable=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get removeVariable(){return l._removeVariable}static _getFlag=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get getFlag(){return l._getFlag}static _setFlag=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get setFlag(){return l._setFlag}static _onLabelClosing=()=>{};static get onLabelClosing(){return l._onLabelClosing}static _addHistoryItem=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get addHistoryItem(){return l._addHistoryItem}static _getCurrentStepsRunningNumber=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")};static get currentStepsRunningNumber(){return l._getCurrentStepsRunningNumber()}static _getCharacter=()=>{throw b.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")};static get getCharacter(){return l._getCharacter}static onEnd;static onError};function M(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw b.error("Error creating exportable element",l,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function oe(l,e){let t=M(l);return e.length>1&&"type"in e[0]&&(e=e.reverse()),e.forEach(i=>{"type"in i?we(t,i):_e(t,i);}),t}function we(l,e){let t=l;e.path&&e.path.length>0?e.path.forEach((i,r)=>{if(e.path&&r===e.path.length-1)switch(e.type){case "CHANGE":case "REMOVE":t[i]=e.oldValue;break;case "CREATE":Array.isArray(t)&&typeof i=="number"?t.splice(i,1):delete t[i];break}else t=t[i];}):b.warn("No path found, skipping diff",e);}function _e(l,e){let t=l;e.path&&e.path.length>0?e.path.forEach((i,r)=>{if(e.path&&r===e.path.length-1){if(e.kind==="E"||e.kind==="D")t[i]=e.lhs;else if(e.kind==="N")Number.isInteger(i)?Array.isArray(t)&&t.splice(i,1):typeof i=="string"&&delete t[i];else if(e.kind==="A"){let s=e.index;e.item.kind==="N"?t[i].splice(s,1):e.item.kind==="E"||e.item.kind==="D"?t[i][s]=e.item.lhs:e.item.kind==="A"?b.warn("Nested array found, skipping diff",e):b.warn("No array found, skipping diff",e);}}else t=t[i];}):b.warn("No path found, skipping diff",e);}var k=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,le=new Set,Q=typeof process=="object"&&process?process:{},he=(l,e,t,i)=>{typeof Q.emitWarning=="function"?Q.emitWarning(l,e,t,i):console.error(`[${t}] ${e}: ${l}`);},K=globalThis.AbortController,ae=globalThis.AbortSignal;if(typeof K>"u"){ae=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,r){this._onabort.push(r);}},K=class{constructor(){e();}signal=new ae;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i);}}};let l=Q.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),I=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),fe=l=>I(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?V:null:null,V=class extends Array{constructor(e){super(e),this.fill(0);}},Z=class l{heap;length;static#l=false;static create(e){let t=fe(e);if(!t)return [];l.#l=true;let i=new l(e,t);return l.#l=false,i}constructor(e,t){if(!l.#l)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},B=class l{#l;#u;#m;#A;#y;#T;#z;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#n;#g;#r;#i;#e;#h;#d;#a;#s;#b;#o;#S;#v;#c;#w;#H;#f;#M;static unsafeExposeInternals(e){return {starts:e.#v,ttls:e.#c,sizes:e.#S,keyMap:e.#r,keyList:e.#i,valList:e.#e,next:e.#h,prev:e.#d,get head(){return e.#a},get tail(){return e.#s},free:e.#b,isBackgroundFetch:t=>e.#t(t),backgroundFetch:(t,i,r,s)=>e.#I(t,i,r,s),moveToTail:t=>e.#x(t),indexes:t=>e.#_(t),rindexes:t=>e.#E(t),isStale:t=>e.#p(t)}}get max(){return this.#l}get maxSize(){return this.#u}get calculatedSize(){return this.#g}get size(){return this.#n}get fetchMethod(){return this.#T}get memoMethod(){return this.#z}get dispose(){return this.#m}get onInsert(){return this.#A}get disposeAfter(){return this.#y}constructor(e){let{max:t=0,ttl:i,ttlResolution:r=1,ttlAutopurge:s,updateAgeOnGet:h,updateAgeOnHas:c,allowStale:d,dispose:y,onInsert:_,disposeAfter:m,noDisposeOnSet:w,noUpdateTTL:E,maxSize:N=0,maxEntrySize:G=0,sizeCalculation:T,fetchMethod:S,memoMethod:H,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:A,allowStaleOnFetchRejection:C,allowStaleOnFetchAbort:o,ignoreFetchAbort:a}=e;if(t!==0&&!I(t))throw new TypeError("max option must be a nonnegative integer");let n=t?fe(t):Array;if(!n)throw new Error("invalid max value: "+t);if(this.#l=t,this.#u=N,this.maxEntrySize=G||this.#u,this.sizeCalculation=T,this.sizeCalculation){if(!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(H!==void 0&&typeof H!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#z=H,S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#T=S,this.#H=!!S,this.#r=new Map,this.#i=new Array(t).fill(void 0),this.#e=new Array(t).fill(void 0),this.#h=new n(t),this.#d=new n(t),this.#a=0,this.#s=0,this.#b=Z.create(t),this.#n=0,this.#g=0,typeof y=="function"&&(this.#m=y),typeof _=="function"&&(this.#A=_),typeof m=="function"?(this.#y=m,this.#o=[]):(this.#y=void 0,this.#o=void 0),this.#w=!!this.#m,this.#M=!!this.#A,this.#f=!!this.#y,this.noDisposeOnSet=!!w,this.noUpdateTTL=!!E,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!C,this.allowStaleOnFetchAbort=!!o,this.ignoreFetchAbort=!!a,this.maxEntrySize!==0){if(this.#u!==0&&!I(this.#u))throw new TypeError("maxSize must be a positive integer if specified");if(!I(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#W();}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!A,this.updateAgeOnGet=!!h,this.updateAgeOnHas=!!c,this.ttlResolution=I(r)||r===0?r:1,this.ttlAutopurge=!!s,this.ttl=i||0,this.ttl){if(!I(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#L();}if(this.#l===0&&this.ttl===0&&this.#u===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#l&&!this.#u){let f="LRU_CACHE_UNBOUNDED";Ee(f)&&(le.add(f),he("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",f,l));}}getRemainingTTL(e){return this.#r.has(e)?1/0:0}#L(){let e=new V(this.#l),t=new V(this.#l);this.#c=e,this.#v=t,this.#R=(s,h,c=k.now())=>{if(t[s]=h!==0?c:0,e[s]=h,h!==0&&this.ttlAutopurge){let d=setTimeout(()=>{this.#p(s)&&this.#G(this.#i[s],"expire");},h+1);d.unref&&d.unref();}},this.#O=s=>{t[s]=e[s]!==0?k.now():0;},this.#D=(s,h)=>{if(e[h]){let c=e[h],d=t[h];if(!c||!d)return;s.ttl=c,s.start=d,s.now=i||r();let y=s.now-d;s.remainingTTL=c-y;}};let i=0,r=()=>{let s=k.now();if(this.ttlResolution>0){i=s;let h=setTimeout(()=>i=0,this.ttlResolution);h.unref&&h.unref();}return s};this.getRemainingTTL=s=>{let h=this.#r.get(s);if(h===void 0)return 0;let c=e[h],d=t[h];if(!c||!d)return 1/0;let y=(i||r())-d;return c-y},this.#p=s=>{let h=t[s],c=e[s];return !!c&&!!h&&(i||r())-h>c};}#O=()=>{};#D=()=>{};#R=()=>{};#p=()=>false;#W(){let e=new V(this.#l);this.#g=0,this.#S=e,this.#C=t=>{this.#g-=e[t],e[t]=0;},this.#k=(t,i,r,s)=>{if(this.#t(i))return 0;if(!I(r))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(r=s(i,t),!I(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},this.#N=(t,i,r)=>{if(e[t]=i,this.#u){let s=this.#u-e[t];for(;this.#g>s;)this.#F(true);}this.#g+=e[t],r&&(r.entrySize=i,r.totalCalculatedSize=this.#g);};}#C=e=>{};#N=(e,t,i)=>{};#k=(e,t,i,r)=>{if(i||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#_({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#s;!(!this.#V(t)||((e||!this.#p(t))&&(yield t),t===this.#a));)t=this.#d[t];}*#E({allowStale:e=this.allowStale}={}){if(this.#n)for(let t=this.#a;!(!this.#V(t)||((e||!this.#p(t))&&(yield t),t===this.#s));)t=this.#h[t];}#V(e){return e!==void 0&&this.#r.get(this.#i[e])===e}*entries(){for(let e of this.#_())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield [this.#i[e],this.#e[e]]);}*rentries(){for(let e of this.#E())this.#e[e]!==void 0&&this.#i[e]!==void 0&&!this.#t(this.#e[e])&&(yield [this.#i[e],this.#e[e]]);}*keys(){for(let e of this.#_()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t);}}*rkeys(){for(let e of this.#E()){let t=this.#i[e];t!==void 0&&!this.#t(this.#e[e])&&(yield t);}}*values(){for(let e of this.#_())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e]);}*rvalues(){for(let e of this.#E())this.#e[e]!==void 0&&!this.#t(this.#e[e])&&(yield this.#e[e]);}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,t={}){for(let i of this.#_()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;if(s!==void 0&&e(s,this.#i[i],this))return this.get(this.#i[i],t)}}forEach(e,t=this){for(let i of this.#_()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,this.#i[i],this);}}rforEach(e,t=this){for(let i of this.#E()){let r=this.#e[i],s=this.#t(r)?r.__staleWhileFetching:r;s!==void 0&&e.call(t,s,this.#i[i],this);}}purgeStale(){let e=false;for(let t of this.#E({allowStale:true}))this.#p(t)&&(this.#G(this.#i[t],"expire"),e=true);return e}info(e){let t=this.#r.get(e);if(t===void 0)return;let i=this.#e[t],r=this.#t(i)?i.__staleWhileFetching:i;if(r===void 0)return;let s={value:r};if(this.#c&&this.#v){let h=this.#c[t],c=this.#v[t];if(h&&c){let d=h-(k.now()-c);s.ttl=d,s.start=Date.now();}}return this.#S&&(s.size=this.#S[t]),s}dump(){let e=[];for(let t of this.#_({allowStale:true})){let i=this.#i[t],r=this.#e[t],s=this.#t(r)?r.__staleWhileFetching:r;if(s===void 0||i===void 0)continue;let h={value:s};if(this.#c&&this.#v){h.ttl=this.#c[t];let c=k.now()-this.#v[t];h.start=Math.floor(Date.now()-c);}this.#S&&(h.size=this.#S[t]),e.unshift([i,h]);}return e}load(e){this.clear();for(let[t,i]of e){if(i.start){let r=Date.now()-i.start;i.start=k.now()-r;}this.set(t,i.value,i);}}set(e,t,i={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:s,noDisposeOnSet:h=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:d}=i,{noUpdateTTL:y=this.noUpdateTTL}=i,_=this.#k(e,t,i.size||0,c);if(this.maxEntrySize&&_>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),this.#G(e,"set"),this;let m=this.#n===0?void 0:this.#r.get(e);if(m===void 0)m=this.#n===0?this.#s:this.#b.length!==0?this.#b.pop():this.#n===this.#l?this.#F(false):this.#n,this.#i[m]=e,this.#e[m]=t,this.#r.set(e,m),this.#h[this.#s]=m,this.#d[m]=this.#s,this.#s=m,this.#n++,this.#N(m,_,d),d&&(d.set="add"),y=false,this.#M&&this.#A?.(t,e,"add");else {this.#x(m);let w=this.#e[m];if(t!==w){if(this.#H&&this.#t(w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=w;E!==void 0&&!h&&(this.#w&&this.#m?.(E,e,"set"),this.#f&&this.#o?.push([E,e,"set"]));}else h||(this.#w&&this.#m?.(w,e,"set"),this.#f&&this.#o?.push([w,e,"set"]));if(this.#C(m),this.#N(m,_,d),this.#e[m]=t,d){d.set="replace";let E=w&&this.#t(w)?w.__staleWhileFetching:w;E!==void 0&&(d.oldValue=E);}}else d&&(d.set="update");this.#M&&this.onInsert?.(t,e,t===w?"update":"replace");}if(r!==0&&!this.#c&&this.#L(),this.#c&&(y||this.#R(m,r,s),d&&this.#D(d,m)),!h&&this.#f&&this.#o){let w=this.#o,E;for(;E=w?.shift();)this.#y?.(...E);}return this}pop(){try{for(;this.#n;){let e=this.#e[this.#a];if(this.#F(!0),this.#t(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#f&&this.#o){let e=this.#o,t;for(;t=e?.shift();)this.#y?.(...t);}}}#F(e){let t=this.#a,i=this.#i[t],r=this.#e[t];return this.#H&&this.#t(r)?r.__abortController.abort(new Error("evicted")):(this.#w||this.#f)&&(this.#w&&this.#m?.(r,i,"evict"),this.#f&&this.#o?.push([r,i,"evict"])),this.#C(t),e&&(this.#i[t]=void 0,this.#e[t]=void 0,this.#b.push(t)),this.#n===1?(this.#a=this.#s=0,this.#b.length=0):this.#a=this.#h[t],this.#r.delete(i),this.#n--,t}has(e,t={}){let{updateAgeOnHas:i=this.updateAgeOnHas,status:r}=t,s=this.#r.get(e);if(s!==void 0){let h=this.#e[s];if(this.#t(h)&&h.__staleWhileFetching===void 0)return false;if(this.#p(s))r&&(r.has="stale",this.#D(r,s));else return i&&this.#O(s),r&&(r.has="hit",this.#D(r,s)),true}else r&&(r.has="miss");return false}peek(e,t={}){let{allowStale:i=this.allowStale}=t,r=this.#r.get(e);if(r===void 0||!i&&this.#p(r))return;let s=this.#e[r];return this.#t(s)?s.__staleWhileFetching:s}#I(e,t,i,r){let s=t===void 0?void 0:this.#e[t];if(this.#t(s))return s;let h=new K,{signal:c}=i;c?.addEventListener("abort",()=>h.abort(c.reason),{signal:h.signal});let d={signal:h.signal,options:i,context:r},y=(G,T=false)=>{let{aborted:S}=h.signal,H=i.ignoreFetchAbort&&G!==void 0;if(i.status&&(S&&!T?(i.status.fetchAborted=true,i.status.fetchError=h.signal.reason,H&&(i.status.fetchAbortIgnored=true)):i.status.fetchResolved=true),S&&!H&&!T)return m(h.signal.reason);let x=E;return this.#e[t]===E&&(G===void 0?x.__staleWhileFetching?this.#e[t]=x.__staleWhileFetching:this.#G(e,"fetch"):(i.status&&(i.status.fetchUpdated=true),this.set(e,G,d.options))),G},_=G=>(i.status&&(i.status.fetchRejected=true,i.status.fetchError=G),m(G)),m=G=>{let{aborted:T}=h.signal,S=T&&i.allowStaleOnFetchAbort,H=S||i.allowStaleOnFetchRejection,x=H||i.noDeleteOnFetchRejection,A=E;if(this.#e[t]===E&&(!x||A.__staleWhileFetching===void 0?this.#G(e,"fetch"):S||(this.#e[t]=A.__staleWhileFetching)),H)return i.status&&A.__staleWhileFetching!==void 0&&(i.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw G},w=(G,T)=>{let S=this.#T?.(e,s,d);S&&S instanceof Promise&&S.then(H=>G(H===void 0?void 0:H),T),h.signal.addEventListener("abort",()=>{(!i.ignoreFetchAbort||i.allowStaleOnFetchAbort)&&(G(void 0),i.allowStaleOnFetchAbort&&(G=H=>y(H,true)));});};i.status&&(i.status.fetchDispatched=true);let E=new Promise(w).then(y,_),N=Object.assign(E,{__abortController:h,__staleWhileFetching:s,__returned:void 0});return t===void 0?(this.set(e,N,{...d.options,status:void 0}),t=this.#r.get(e)):this.#e[t]=N,N}#t(e){if(!this.#H)return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof K}async fetch(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:h=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:d=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:_=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:w=this.allowStaleOnFetchRejection,ignoreFetchAbort:E=this.ignoreFetchAbort,allowStaleOnFetchAbort:N=this.allowStaleOnFetchAbort,context:G,forceRefresh:T=false,status:S,signal:H}=t;if(!this.#H)return S&&(S.fetch="get"),this.get(e,{allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:s,status:S});let x={allowStale:i,updateAgeOnGet:r,noDeleteOnStaleGet:s,ttl:h,noDisposeOnSet:c,size:d,sizeCalculation:y,noUpdateTTL:_,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:N,ignoreFetchAbort:E,status:S,signal:H},A=this.#r.get(e);if(A===void 0){S&&(S.fetch="miss");let C=this.#I(e,A,x,G);return C.__returned=C}else {let C=this.#e[A];if(this.#t(C)){let u=i&&C.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",u&&(S.returnedStale=true)),u?C.__staleWhileFetching:C.__returned=C}let o=this.#p(A);if(!T&&!o)return S&&(S.fetch="hit"),this.#x(A),r&&this.#O(A),S&&this.#D(S,A),C;let a=this.#I(e,A,x,G),f=a.__staleWhileFetching!==void 0&&i;return S&&(S.fetch=o?"stale":"refresh",f&&o&&(S.returnedStale=true)),f?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let i=await this.fetch(e,t);if(i===void 0)throw new Error("fetch() returned undefined");return i}memo(e,t={}){let i=this.#z;if(!i)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:s,...h}=t,c=this.get(e,h);if(!s&&c!==void 0)return c;let d=i(e,c,{options:h,context:r});return this.set(e,d,h),d}get(e,t={}){let{allowStale:i=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:h}=t,c=this.#r.get(e);if(c!==void 0){let d=this.#e[c],y=this.#t(d);return h&&this.#D(h,c),this.#p(c)?(h&&(h.get="stale"),y?(h&&i&&d.__staleWhileFetching!==void 0&&(h.returnedStale=true),i?d.__staleWhileFetching:void 0):(s||this.#G(e,"expire"),h&&i&&(h.returnedStale=true),i?d:void 0)):(h&&(h.get="hit"),y?d.__staleWhileFetching:(this.#x(c),r&&this.#O(c),d))}else h&&(h.get="miss");}#P(e,t){this.#d[t]=e,this.#h[e]=t;}#x(e){e!==this.#s&&(e===this.#a?this.#a=this.#h[e]:this.#P(this.#d[e],this.#h[e]),this.#P(this.#s,e),this.#s=e);}delete(e){return this.#G(e,"delete")}#G(e,t){let i=false;if(this.#n!==0){let r=this.#r.get(e);if(r!==void 0)if(i=true,this.#n===1)this.#j(t);else {this.#C(r);let s=this.#e[r];if(this.#t(s)?s.__abortController.abort(new Error("deleted")):(this.#w||this.#f)&&(this.#w&&this.#m?.(s,e,t),this.#f&&this.#o?.push([s,e,t])),this.#r.delete(e),this.#i[r]=void 0,this.#e[r]=void 0,r===this.#s)this.#s=this.#d[r];else if(r===this.#a)this.#a=this.#h[r];else {let h=this.#d[r];this.#h[h]=this.#h[r];let c=this.#h[r];this.#d[c]=this.#d[r];}this.#n--,this.#b.push(r);}}if(this.#f&&this.#o?.length){let r=this.#o,s;for(;s=r?.shift();)this.#y?.(...s);}return i}clear(){return this.#j("delete")}#j(e){for(let t of this.#E({allowStale:true})){let i=this.#e[t];if(this.#t(i))i.__abortController.abort(new Error("deleted"));else {let r=this.#i[t];this.#w&&this.#m?.(i,r,e),this.#f&&this.#o?.push([i,r,e]);}}if(this.#r.clear(),this.#e.fill(void 0),this.#i.fill(void 0),this.#c&&this.#v&&(this.#c.fill(0),this.#v.fill(0)),this.#S&&this.#S.fill(0),this.#a=0,this.#s=0,this.#b.length=0,this.#g=0,this.#n=0,this.#f&&this.#o){let t=this.#o,i;for(;i=t?.shift();)this.#y?.(...i);}}};var L=class{cache;map=new Map;constructor(e){this.cache=new B({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}get entries(){return this.map.entries}keys(){return this.map.keys()}get values(){return this.map.values}};var p=class l{static _diffHistory=new L({cacheSize:5});static _stepsInfoHistory=new L({cacheSize:5});static _narrationHistory=new L({cacheSize:50});static stepLimitSaved=20;static goBackRunning=false;static _originalStepData=void 0;static get originalStepData(){return l._originalStepData?M(l._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){l._originalStepData=M(e);}};var W=class{get stepsInfoMap(){return p._stepsInfoHistory}get diffMap(){return p._diffHistory}get narrationMap(){return p._narrationHistory}get size(){return p._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return p._stepsInfoHistory.keys()}get(e){let t=p._narrationHistory.get(e);if(!(t&&Object.keys(t).length===1&&t.stepIndex!==void 0))return t}delete(e){p._stepsInfoHistory.delete(e),p._diffHistory.delete(e),p._narrationHistory.delete(e);}internalRestoreOldGameState(e,t){if(e<=0||this.size==0)return t;let i=this.lastKey;if(typeof i!="number")return b.error("You can't go back, there is no step to go back"),t;let r=p._diffHistory.get(i);if(r)try{let s=oe(t,r);return F.stepCounter=i,this.delete(i),this.internalRestoreOldGameState(e-1,s)}catch(s){return b.error("Error applying diff",s),t}else return b.error("You can't go back, there is no step to go back"),t}async goBack(e,t=1){if(t<=0){b.warn("The parameter steps must be greater than 0");return}if(p._diffHistory.size<1){b.warn("You can't go back, there is no step to go back");return}if(p.goBackRunning){b.warn("Go back is already running");return}p.goBackRunning=true;try{let i=M(this.internalRestoreOldGameState(t,p.originalStepData));i?await F.restoreGameStepState(i,e):b.error("Error going back"),p.goBackRunning=!1;}catch(i){b.error("Error going back",i),p.goBackRunning=false;}}add(e,t={}){let i=p.originalStepData,{ignoreSameStep:r}=t,s=F.currentGameStepState;if(!r&&this.isSameStep(i,s))return;let h=this.lastKey;(async()=>{try{let d,y;typeof h=="number"&&(d=p._stepsInfoHistory.get(h),y=p._narrationHistory.get(h));let _=(0,ue.diff)(i,s);p._stepsInfoHistory.set(e.index,e),_?p._diffHistory.set(e.index,_):b.warn("It was not possible to create the difference between the two steps");let m={},w=this.itemMapper({step:e},m);if(p._narrationHistory.set(e.index,w),d&&y&&typeof h=="number"){let E=this.itemMapper({...m,step:d},{});p._narrationHistory.set(h,E);}}catch(d){b.error("Error adding history step",d);}})(),p.originalStepData=s;}itemMapper(e,t){let{step:i,choiceIndexMade:r,inputValue:s,removeDialogue:h}=e,c=i.dialogue||i.dialoge;t&&i.isGlued&&(t.removeDialogue=true),h&&(c=void 0);let d=i.choices;if(t&&i.currentLabel&&i.choiceIndexMade!==void 0&&(t.choiceIndexMade=i.choiceIndexMade),i.inputValue&&t&&(t.inputValue=i.inputValue),c||d||s){let y=d?.map((_,m)=>{let w=false;return _.oneTime&&i.alreadyMadeChoices&&i.alreadyMadeChoices.includes(m)&&(w=true),{text:_.text,type:_.type,isResponse:false,hidden:w}});if(y){if(y.every(_=>_.hidden)){let _=y.find(m=>m.hidden===false);_&&(_.hidden=false);}r!==void 0&&(y[r].isResponse=true);}return {dialogue:c?{...c,character:c.character?F.getCharacter(c.character)||c.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:y,stepIndex:i.index,inputValue:s}}return {stepIndex:i.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((i,r)=>i-r).forEach(i=>{let r=this.get(i);r&&e.push(r);}),e}get latestCurrentLabelHistory(){let e=[],t=Array.from(this.keys()).sort((c,d)=>d-c),i=t.shift();if(typeof i!="number")return e;let r=p._stepsInfoHistory.get(i);if(!r)return e;let s=r.currentLabel,h=r.index;return t.every(c=>{let d=this.get(c);if(d){let y=p._stepsInfoHistory.get(c);if(!y||!(y.currentLabel===s&&y.index<=h))return false;e.push(d);}return h=c,true}),e.reverse()}removeNarrativeHistory(e){if(e){let t=Array.from(this.keys()).sort((i,r)=>i-r);t=t.slice(0,e),t.forEach(i=>{p._narrationHistory.delete(i),p._stepsInfoHistory.delete(i),p._diffHistory.delete(i);});}else p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:p._diffHistory.has(e)}blockGoBack(){F.currentStepsRunningNumber===0&&p._diffHistory.clear();}isSameStep(e,t){if(e.openedLabels.length===t.openedLabels.length)try{let i=JSON.stringify(e.openedLabels),r=JSON.stringify(t.openedLabels);if(i===r&&e.path===t.path&&e.labelIndex===t.labelIndex)return !0}catch(i){return b.error("Error comparing opened labels",i),true}return false}clear(){p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear(),p._originalStepData=void 0;}get stepLimitSaved(){return p.stepLimitSaved}set stepLimitSaved(e){p.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((i,r)=>i-r);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let t=[];return e.forEach(i=>{let r=p._stepsInfoHistory.get(i);if(r){let s=p._diffHistory.get(i);t.push({...r,diff:s});}}),{stepsHistory:M(t),originalStepData:M(p._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((i,r)=>i-r),t={};e.forEach(i=>{let r=p._stepsInfoHistory.get(i);if(r){let s={...t};t={};let h=this.itemMapper({step:r,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},t);h&&p._narrationHistory.set(i,h);}});}async restore(e){this.clear();try{e.hasOwnProperty("stepsHistory")?(e.stepsHistory.forEach(i=>{i.diff&&p._diffHistory.set(i.index,i.diff);let r={...i,diff:void 0};p._stepsInfoHistory.set(i.index,r);}),this.restoreNarrativeHistory()):b.warn("Could not import stepsHistory data, so will be ignored"),e.hasOwnProperty("originalStepData")?p._originalStepData=e.originalStepData:b.warn("Could not import originalStepData data, so will be ignored");}catch(t){b.error("Error importing data",t);}}};var Ze=new W;
|
|
2
|
+
export{p as HistoryManagerStatic,Ze as stepHistory};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { HistoryInfo } from '@drincs/pixi-vn';
|
|
1
|
+
import { HistoryInfo, GameStepState } from '@drincs/pixi-vn';
|
|
2
|
+
import deepDiff__default from 'deep-diff';
|
|
3
|
+
import { Difference } from 'microdiff';
|
|
4
|
+
import CachedMap from '../../classes/CachedMap.cjs';
|
|
2
5
|
import HistoryGameState from './HistoryGameState.cjs';
|
|
3
6
|
import HistoryStep from '../../narration/interfaces/HistoryStep.cjs';
|
|
4
|
-
import
|
|
5
|
-
import '
|
|
6
|
-
import 'microdiff';
|
|
7
|
+
import NarrationHistory from '../../narration/interfaces/NarrationHistory.cjs';
|
|
8
|
+
import 'lru-cache';
|
|
7
9
|
import '../../storage/types/StorageElementType.cjs';
|
|
8
10
|
import '../../narration/interfaces/StoredChoiceInterface.cjs';
|
|
9
11
|
import '../../narration/types/CloseType.cjs';
|
|
@@ -13,22 +15,18 @@ import '../../narration/interfaces/DialogueInterface.cjs';
|
|
|
13
15
|
import '../../narration/types/HistoryChoiceMenuOption.cjs';
|
|
14
16
|
|
|
15
17
|
interface HistoryManagerInterface {
|
|
16
|
-
/**
|
|
17
|
-
* stepHistory is a list of label events and steps that occurred during the progression of the steps.
|
|
18
|
-
*/
|
|
19
|
-
readonly stepsHistory: HistoryStep[];
|
|
20
18
|
/**
|
|
21
19
|
* Get the narrative history.
|
|
22
20
|
* @returns the history of the dialogues, choices and steps
|
|
23
21
|
*/
|
|
24
|
-
readonly narrativeHistory:
|
|
22
|
+
readonly narrativeHistory: NarrationHistory[];
|
|
25
23
|
/**
|
|
26
|
-
* Get the history of the last steps belonging to the current label.
|
|
24
|
+
* Get the history of the last steps belonging to the current label excluding the current step.
|
|
27
25
|
*
|
|
28
26
|
* For example, if the current label A called label B in step 3, and label B was closed and we went on to step 6 of A. the result will include points 4 5 6 of label A
|
|
29
27
|
* @returns the history of the dialogues, choices and steps
|
|
30
28
|
*/
|
|
31
|
-
readonly latestCurrentLabelHistory:
|
|
29
|
+
readonly latestCurrentLabelHistory: NarrationHistory[];
|
|
32
30
|
/**
|
|
33
31
|
* The number of steps to keep in the history into the save file.
|
|
34
32
|
*
|
|
@@ -82,6 +80,51 @@ interface HistoryManagerInterface {
|
|
|
82
80
|
* Clear the history.
|
|
83
81
|
*/
|
|
84
82
|
clear(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Number of items in the history.
|
|
85
|
+
*/
|
|
86
|
+
readonly size: number;
|
|
87
|
+
/**
|
|
88
|
+
* Get the last key (id) of the history.
|
|
89
|
+
*/
|
|
90
|
+
readonly lastKey: number | null;
|
|
91
|
+
/**
|
|
92
|
+
* Get all the keys (id) of the history.
|
|
93
|
+
*/
|
|
94
|
+
keys(): MapIterator<number>;
|
|
95
|
+
/**
|
|
96
|
+
* Get a step from the history.
|
|
97
|
+
*
|
|
98
|
+
* **Note:** If the step not contains any information, this method will return undefined.
|
|
99
|
+
* @param stepIndex The key (id) of the step to get.
|
|
100
|
+
* @returns The step.
|
|
101
|
+
*/
|
|
102
|
+
get(stepIndex: number): NarrationHistory | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Remove a step from the history.
|
|
105
|
+
* @param stepIndex The key (id) of the step to remove.
|
|
106
|
+
* @returns True if the step was removed, false if it was not found.
|
|
107
|
+
*/
|
|
108
|
+
delete(stepIndex: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Map that contains all information about the steps in the history.
|
|
111
|
+
*
|
|
112
|
+
* **Don't edit unless you're sure what you're doing.**
|
|
113
|
+
*/
|
|
114
|
+
readonly stepsInfoMap: CachedMap<number, Omit<HistoryStep, "diff">>;
|
|
115
|
+
/**
|
|
116
|
+
* Map that contains all the differences between the steps in the history.
|
|
117
|
+
* The differences will be used to restore a step.
|
|
118
|
+
*
|
|
119
|
+
* **Don't edit unless you're sure what you're doing.**
|
|
120
|
+
*/
|
|
121
|
+
readonly diffMap: CachedMap<number, deepDiff__default.Diff<GameStepState, GameStepState>[] | Difference[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Map that contains all the narration history.
|
|
124
|
+
*
|
|
125
|
+
* **Don't edit unless you're sure what you're doing.**
|
|
126
|
+
*/
|
|
127
|
+
readonly narrationMap: CachedMap<number, NarrationHistory>;
|
|
85
128
|
/**
|
|
86
129
|
* Export the history to an object.
|
|
87
130
|
* @returns The history in an object.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { HistoryInfo } from '@drincs/pixi-vn';
|
|
1
|
+
import { HistoryInfo, GameStepState } from '@drincs/pixi-vn';
|
|
2
|
+
import deepDiff__default from 'deep-diff';
|
|
3
|
+
import { Difference } from 'microdiff';
|
|
4
|
+
import CachedMap from '../../classes/CachedMap.js';
|
|
2
5
|
import HistoryGameState from './HistoryGameState.js';
|
|
3
6
|
import HistoryStep from '../../narration/interfaces/HistoryStep.js';
|
|
4
|
-
import
|
|
5
|
-
import '
|
|
6
|
-
import 'microdiff';
|
|
7
|
+
import NarrationHistory from '../../narration/interfaces/NarrationHistory.js';
|
|
8
|
+
import 'lru-cache';
|
|
7
9
|
import '../../storage/types/StorageElementType.js';
|
|
8
10
|
import '../../narration/interfaces/StoredChoiceInterface.js';
|
|
9
11
|
import '../../narration/types/CloseType.js';
|
|
@@ -13,22 +15,18 @@ import '../../narration/interfaces/DialogueInterface.js';
|
|
|
13
15
|
import '../../narration/types/HistoryChoiceMenuOption.js';
|
|
14
16
|
|
|
15
17
|
interface HistoryManagerInterface {
|
|
16
|
-
/**
|
|
17
|
-
* stepHistory is a list of label events and steps that occurred during the progression of the steps.
|
|
18
|
-
*/
|
|
19
|
-
readonly stepsHistory: HistoryStep[];
|
|
20
18
|
/**
|
|
21
19
|
* Get the narrative history.
|
|
22
20
|
* @returns the history of the dialogues, choices and steps
|
|
23
21
|
*/
|
|
24
|
-
readonly narrativeHistory:
|
|
22
|
+
readonly narrativeHistory: NarrationHistory[];
|
|
25
23
|
/**
|
|
26
|
-
* Get the history of the last steps belonging to the current label.
|
|
24
|
+
* Get the history of the last steps belonging to the current label excluding the current step.
|
|
27
25
|
*
|
|
28
26
|
* For example, if the current label A called label B in step 3, and label B was closed and we went on to step 6 of A. the result will include points 4 5 6 of label A
|
|
29
27
|
* @returns the history of the dialogues, choices and steps
|
|
30
28
|
*/
|
|
31
|
-
readonly latestCurrentLabelHistory:
|
|
29
|
+
readonly latestCurrentLabelHistory: NarrationHistory[];
|
|
32
30
|
/**
|
|
33
31
|
* The number of steps to keep in the history into the save file.
|
|
34
32
|
*
|
|
@@ -82,6 +80,51 @@ interface HistoryManagerInterface {
|
|
|
82
80
|
* Clear the history.
|
|
83
81
|
*/
|
|
84
82
|
clear(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Number of items in the history.
|
|
85
|
+
*/
|
|
86
|
+
readonly size: number;
|
|
87
|
+
/**
|
|
88
|
+
* Get the last key (id) of the history.
|
|
89
|
+
*/
|
|
90
|
+
readonly lastKey: number | null;
|
|
91
|
+
/**
|
|
92
|
+
* Get all the keys (id) of the history.
|
|
93
|
+
*/
|
|
94
|
+
keys(): MapIterator<number>;
|
|
95
|
+
/**
|
|
96
|
+
* Get a step from the history.
|
|
97
|
+
*
|
|
98
|
+
* **Note:** If the step not contains any information, this method will return undefined.
|
|
99
|
+
* @param stepIndex The key (id) of the step to get.
|
|
100
|
+
* @returns The step.
|
|
101
|
+
*/
|
|
102
|
+
get(stepIndex: number): NarrationHistory | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Remove a step from the history.
|
|
105
|
+
* @param stepIndex The key (id) of the step to remove.
|
|
106
|
+
* @returns True if the step was removed, false if it was not found.
|
|
107
|
+
*/
|
|
108
|
+
delete(stepIndex: number): void;
|
|
109
|
+
/**
|
|
110
|
+
* Map that contains all information about the steps in the history.
|
|
111
|
+
*
|
|
112
|
+
* **Don't edit unless you're sure what you're doing.**
|
|
113
|
+
*/
|
|
114
|
+
readonly stepsInfoMap: CachedMap<number, Omit<HistoryStep, "diff">>;
|
|
115
|
+
/**
|
|
116
|
+
* Map that contains all the differences between the steps in the history.
|
|
117
|
+
* The differences will be used to restore a step.
|
|
118
|
+
*
|
|
119
|
+
* **Don't edit unless you're sure what you're doing.**
|
|
120
|
+
*/
|
|
121
|
+
readonly diffMap: CachedMap<number, deepDiff__default.Diff<GameStepState, GameStepState>[] | Difference[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Map that contains all the narration history.
|
|
124
|
+
*
|
|
125
|
+
* **Don't edit unless you're sure what you're doing.**
|
|
126
|
+
*/
|
|
127
|
+
readonly narrationMap: CachedMap<number, NarrationHistory>;
|
|
85
128
|
/**
|
|
86
129
|
* Export the history to an object.
|
|
87
130
|
* @returns The history in an object.
|
|
@@ -10,8 +10,8 @@ import ChoiceInterface from './narration/interfaces/ChoiceInterface.js';
|
|
|
10
10
|
import DialogueInterface from './narration/interfaces/DialogueInterface.js';
|
|
11
11
|
import HistoryStep from './narration/interfaces/HistoryStep.js';
|
|
12
12
|
import LabelProps from './narration/interfaces/LabelProps.js';
|
|
13
|
+
import NarrationHistory from './narration/interfaces/NarrationHistory.js';
|
|
13
14
|
import NarrationManagerInterface from './narration/interfaces/NarrationManagerInterface.js';
|
|
14
|
-
import NarrativeHistory from './narration/interfaces/NarrativeHistory.js';
|
|
15
15
|
import OpenedLabel from './narration/interfaces/OpenedLabel.js';
|
|
16
16
|
import StepLabelProps from './narration/interfaces/StepLabelProps.js';
|
|
17
17
|
import StepLabelResult from './narration/interfaces/StepLabelResult.js';
|
|
@@ -42,9 +42,9 @@ declare const narrationUtils_LabelProps: typeof LabelProps;
|
|
|
42
42
|
declare const narrationUtils_LabelRunModeType: typeof LabelRunModeType;
|
|
43
43
|
declare const narrationUtils_LabelSteps: typeof LabelSteps;
|
|
44
44
|
declare const narrationUtils_NarrationGameState: typeof NarrationGameState;
|
|
45
|
+
declare const narrationUtils_NarrationHistory: typeof NarrationHistory;
|
|
45
46
|
declare const narrationUtils_NarrationManagerInterface: typeof NarrationManagerInterface;
|
|
46
47
|
declare const narrationUtils_NarrationManagerStatic: typeof NarrationManagerStatic;
|
|
47
|
-
declare const narrationUtils_NarrativeHistory: typeof NarrativeHistory;
|
|
48
48
|
declare const narrationUtils_OpenedLabel: typeof OpenedLabel;
|
|
49
49
|
declare const narrationUtils_RegisteredLabels: typeof RegisteredLabels;
|
|
50
50
|
declare const narrationUtils_StepLabelProps: typeof StepLabelProps;
|
|
@@ -59,7 +59,7 @@ declare const narrationUtils_newChoiceOption: typeof newChoiceOption;
|
|
|
59
59
|
declare const narrationUtils_newCloseChoiceOption: typeof newCloseChoiceOption;
|
|
60
60
|
declare const narrationUtils_newLabel: typeof newLabel;
|
|
61
61
|
declare namespace narrationUtils {
|
|
62
|
-
export { narrationUtils_ChoiceInterface as ChoiceInterface, narrationUtils_ChoiceMenuOption as ChoiceMenuOption, narrationUtils_ChoiceMenuOptionClose as ChoiceMenuOptionClose, narrationUtils_ChoiceOptionInterface as ChoiceOptionInterface, narrationUtils_Close as Close, narrationUtils_CloseChoiceOptionInterface as CloseChoiceOptionInterface, narrationUtils_CloseType as CloseType, narrationUtils_DialogueInterface as DialogueInterface, narrationUtils_HistoryChoiceMenuOption as HistoryChoiceMenuOption, narrationUtils_HistoryStep as HistoryStep, narrationUtils_InputInfo as InputInfo, narrationUtils_Label as Label, narrationUtils_LabelAbstract as LabelAbstract, narrationUtils_LabelProps as LabelProps, narrationUtils_LabelRunModeType as LabelRunModeType, narrationUtils_LabelSteps as LabelSteps, narrationUtils_NarrationGameState as NarrationGameState,
|
|
62
|
+
export { narrationUtils_ChoiceInterface as ChoiceInterface, narrationUtils_ChoiceMenuOption as ChoiceMenuOption, narrationUtils_ChoiceMenuOptionClose as ChoiceMenuOptionClose, narrationUtils_ChoiceOptionInterface as ChoiceOptionInterface, narrationUtils_Close as Close, narrationUtils_CloseChoiceOptionInterface as CloseChoiceOptionInterface, narrationUtils_CloseType as CloseType, narrationUtils_DialogueInterface as DialogueInterface, narrationUtils_HistoryChoiceMenuOption as HistoryChoiceMenuOption, narrationUtils_HistoryStep as HistoryStep, narrationUtils_InputInfo as InputInfo, narrationUtils_Label as Label, narrationUtils_LabelAbstract as LabelAbstract, narrationUtils_LabelProps as LabelProps, narrationUtils_LabelRunModeType as LabelRunModeType, narrationUtils_LabelSteps as LabelSteps, narrationUtils_NarrationGameState as NarrationGameState, narrationUtils_NarrationHistory as NarrationHistory, narrationUtils_NarrationManagerInterface as NarrationManagerInterface, narrationUtils_NarrationManagerStatic as NarrationManagerStatic, narrationUtils_OpenedLabel as OpenedLabel, narrationUtils_RegisteredLabels as RegisteredLabels, narrationUtils_StepLabelProps as StepLabelProps, narrationUtils_StepLabelPropsType as StepLabelPropsType, narrationUtils_StepLabelResult as StepLabelResult, narrationUtils_StepLabelResultType as StepLabelResultType, narrationUtils_StepLabelType as StepLabelType, narrationUtils_StoredChoiceInterface as StoredChoiceInterface, narrationUtils_StoredIndexedChoiceInterface as StoredIndexedChoiceInterface, narrationUtils_narration as narration, narrationUtils_newChoiceOption as newChoiceOption, narrationUtils_newCloseChoiceOption as newCloseChoiceOption, narrationUtils_newLabel as newLabel };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export { narration as a, narrationUtils as n };
|
|
@@ -10,8 +10,8 @@ import ChoiceInterface from './narration/interfaces/ChoiceInterface.cjs';
|
|
|
10
10
|
import DialogueInterface from './narration/interfaces/DialogueInterface.cjs';
|
|
11
11
|
import HistoryStep from './narration/interfaces/HistoryStep.cjs';
|
|
12
12
|
import LabelProps from './narration/interfaces/LabelProps.cjs';
|
|
13
|
+
import NarrationHistory from './narration/interfaces/NarrationHistory.cjs';
|
|
13
14
|
import NarrationManagerInterface from './narration/interfaces/NarrationManagerInterface.cjs';
|
|
14
|
-
import NarrativeHistory from './narration/interfaces/NarrativeHistory.cjs';
|
|
15
15
|
import OpenedLabel from './narration/interfaces/OpenedLabel.cjs';
|
|
16
16
|
import StepLabelProps from './narration/interfaces/StepLabelProps.cjs';
|
|
17
17
|
import StepLabelResult from './narration/interfaces/StepLabelResult.cjs';
|
|
@@ -42,9 +42,9 @@ declare const narrationUtils_LabelProps: typeof LabelProps;
|
|
|
42
42
|
declare const narrationUtils_LabelRunModeType: typeof LabelRunModeType;
|
|
43
43
|
declare const narrationUtils_LabelSteps: typeof LabelSteps;
|
|
44
44
|
declare const narrationUtils_NarrationGameState: typeof NarrationGameState;
|
|
45
|
+
declare const narrationUtils_NarrationHistory: typeof NarrationHistory;
|
|
45
46
|
declare const narrationUtils_NarrationManagerInterface: typeof NarrationManagerInterface;
|
|
46
47
|
declare const narrationUtils_NarrationManagerStatic: typeof NarrationManagerStatic;
|
|
47
|
-
declare const narrationUtils_NarrativeHistory: typeof NarrativeHistory;
|
|
48
48
|
declare const narrationUtils_OpenedLabel: typeof OpenedLabel;
|
|
49
49
|
declare const narrationUtils_RegisteredLabels: typeof RegisteredLabels;
|
|
50
50
|
declare const narrationUtils_StepLabelProps: typeof StepLabelProps;
|
|
@@ -59,7 +59,7 @@ declare const narrationUtils_newChoiceOption: typeof newChoiceOption;
|
|
|
59
59
|
declare const narrationUtils_newCloseChoiceOption: typeof newCloseChoiceOption;
|
|
60
60
|
declare const narrationUtils_newLabel: typeof newLabel;
|
|
61
61
|
declare namespace narrationUtils {
|
|
62
|
-
export { narrationUtils_ChoiceInterface as ChoiceInterface, narrationUtils_ChoiceMenuOption as ChoiceMenuOption, narrationUtils_ChoiceMenuOptionClose as ChoiceMenuOptionClose, narrationUtils_ChoiceOptionInterface as ChoiceOptionInterface, narrationUtils_Close as Close, narrationUtils_CloseChoiceOptionInterface as CloseChoiceOptionInterface, narrationUtils_CloseType as CloseType, narrationUtils_DialogueInterface as DialogueInterface, narrationUtils_HistoryChoiceMenuOption as HistoryChoiceMenuOption, narrationUtils_HistoryStep as HistoryStep, narrationUtils_InputInfo as InputInfo, narrationUtils_Label as Label, narrationUtils_LabelAbstract as LabelAbstract, narrationUtils_LabelProps as LabelProps, narrationUtils_LabelRunModeType as LabelRunModeType, narrationUtils_LabelSteps as LabelSteps, narrationUtils_NarrationGameState as NarrationGameState,
|
|
62
|
+
export { narrationUtils_ChoiceInterface as ChoiceInterface, narrationUtils_ChoiceMenuOption as ChoiceMenuOption, narrationUtils_ChoiceMenuOptionClose as ChoiceMenuOptionClose, narrationUtils_ChoiceOptionInterface as ChoiceOptionInterface, narrationUtils_Close as Close, narrationUtils_CloseChoiceOptionInterface as CloseChoiceOptionInterface, narrationUtils_CloseType as CloseType, narrationUtils_DialogueInterface as DialogueInterface, narrationUtils_HistoryChoiceMenuOption as HistoryChoiceMenuOption, narrationUtils_HistoryStep as HistoryStep, narrationUtils_InputInfo as InputInfo, narrationUtils_Label as Label, narrationUtils_LabelAbstract as LabelAbstract, narrationUtils_LabelProps as LabelProps, narrationUtils_LabelRunModeType as LabelRunModeType, narrationUtils_LabelSteps as LabelSteps, narrationUtils_NarrationGameState as NarrationGameState, narrationUtils_NarrationHistory as NarrationHistory, narrationUtils_NarrationManagerInterface as NarrationManagerInterface, narrationUtils_NarrationManagerStatic as NarrationManagerStatic, narrationUtils_OpenedLabel as OpenedLabel, narrationUtils_RegisteredLabels as RegisteredLabels, narrationUtils_StepLabelProps as StepLabelProps, narrationUtils_StepLabelPropsType as StepLabelPropsType, narrationUtils_StepLabelResult as StepLabelResult, narrationUtils_StepLabelResultType as StepLabelResultType, narrationUtils_StepLabelType as StepLabelType, narrationUtils_StoredChoiceInterface as StoredChoiceInterface, narrationUtils_StoredIndexedChoiceInterface as StoredIndexedChoiceInterface, narrationUtils_narration as narration, narrationUtils_newChoiceOption as newChoiceOption, narrationUtils_newCloseChoiceOption as newCloseChoiceOption, narrationUtils_newLabel as newLabel };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export { narration as a, narrationUtils as n };
|