@drincs/pixi-vn-json 1.8.4 → 1.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/importer.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage'),translator=require('@drincs/pixi-vn-json/translator'),unifier=require('@drincs/pixi-vn-json/unifier');var Q=Object.create;var H=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var re=(a,r,t)=>r in a?H(a,r,{enumerable:true,configurable:true,writable:true,value:t}):a[r]=t;var I=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var W=(a,r)=>()=>(r||a((r={exports:{}}).exports,r),r.exports);var ne=(a,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of ee(r))!ie.call(a,n)&&n!==t&&H(a,n,{get:()=>r[n],enumerable:!(o=Z(r,n))||o.enumerable});return a};var oe=(a,r,t)=>(t=a!=null?Q(te(a)):{},ne(H(t,"default",{value:a,enumerable:true}),a));var C=(a,r,t)=>re(a,typeof r!="symbol"?r+"":r,t);var F=W((E,U)=>{(function(a,r){typeof E=="object"?U.exports=E=r():typeof define=="function"&&define.amd?define([],r):a.CryptoJS=r();})(E,function(){var a=a||(function(r,t){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof I=="function")try{o=I("crypto");}catch{}var n=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},u=Object.create||(function(){function e(){}return function(i){var c;return e.prototype=i,c=new e,e.prototype=null,c}})(),s={},p=s.lib={},d=p.Base=(function(){return {extend:function(e){var i=u(this);return e&&i.mixIn(e),(!i.hasOwnProperty("init")||this.init===i.init)&&(i.init=function(){i.$super.init.apply(this,arguments);}),i.init.prototype=i,i.$super=this,i},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=p.WordArray=d.extend({init:function(e,i){e=this.words=e||[],i!=t?this.sigBytes=i:this.sigBytes=e.length*4;},toString:function(e){return (e||x).stringify(this)},concat:function(e){var i=this.words,c=e.words,l=this.sigBytes,S=e.sigBytes;if(this.clamp(),l%4)for(var V=0;V<S;V++){var D=c[V>>>2]>>>24-V%4*8&255;i[l+V>>>2]|=D<<24-(l+V)%4*8;}else for(var _=0;_<S;_+=4)i[l+_>>>2]=c[_>>>2];return this.sigBytes+=S,this},clamp:function(){var e=this.words,i=this.sigBytes;e[i>>>2]&=4294967295<<32-i%4*8,e.length=r.ceil(i/4);},clone:function(){var e=d.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var i=[],c=0;c<e;c+=4)i.push(n());return new y.init(i,e)}}),f=s.enc={},x=f.Hex={stringify:function(e){for(var i=e.words,c=e.sigBytes,l=[],S=0;S<c;S++){var V=i[S>>>2]>>>24-S%4*8&255;l.push((V>>>4).toString(16)),l.push((V&15).toString(16));}return l.join("")},parse:function(e){for(var i=e.length,c=[],l=0;l<i;l+=2)c[l>>>3]|=parseInt(e.substr(l,2),16)<<24-l%8*4;return new y.init(c,i/2)}},b=f.Latin1={stringify:function(e){for(var i=e.words,c=e.sigBytes,l=[],S=0;S<c;S++){var V=i[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(V));}return l.join("")},parse:function(e){for(var i=e.length,c=[],l=0;l<i;l++)c[l>>>2]|=(e.charCodeAt(l)&255)<<24-l%4*8;return new y.init(c,i)}},P=f.Utf8={stringify:function(e){try{return decodeURIComponent(escape(b.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return b.parse(unescape(encodeURIComponent(e)))}},g=p.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(e){typeof e=="string"&&(e=P.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(e){var i,c=this._data,l=c.words,S=c.sigBytes,V=this.blockSize,D=V*4,_=S/D;e?_=r.ceil(_):_=r.max((_|0)-this._minBufferSize,0);var T=_*V,z=r.min(T*4,S);if(T){for(var k=0;k<T;k+=V)this._doProcessBlock(l,k);i=l.splice(0,T),c.sigBytes-=z;}return new y.init(i,z)},clone:function(){var e=d.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});p.Hasher=g.extend({cfg:d.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var i=this._doFinalize();return i},blockSize:512/32,_createHelper:function(e){return function(i,c){return new e.init(c).finalize(i)}},_createHmacHelper:function(e){return function(i,c){return new m.HMAC.init(e,c).finalize(i)}}});var m=s.algo={};return s})(Math);return a});});var M=W((A,G)=>{(function(a,r){typeof A=="object"?G.exports=A=r(F()):typeof define=="function"&&define.amd?define(["./core"],r):r(a.CryptoJS);})(A,function(a){return (function(){var r=a,t=r.lib,o=t.WordArray,n=t.Hasher,u=r.algo,s=[],p=u.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,y){for(var f=this._hash.words,x=f[0],b=f[1],P=f[2],g=f[3],h=f[4],m=0;m<80;m++){if(m<16)s[m]=d[y+m]|0;else {var e=s[m-3]^s[m-8]^s[m-14]^s[m-16];s[m]=e<<1|e>>>31;}var i=(x<<5|x>>>27)+h+s[m];m<20?i+=(b&P|~b&g)+1518500249:m<40?i+=(b^P^g)+1859775393:m<60?i+=(b&P|b&g|P&g)-1894007588:i+=(b^P^g)-899497514,h=g,g=P,P=b<<30|b>>>2,b=x,x=i;}f[0]=f[0]+x|0,f[1]=f[1]+b|0,f[2]=f[2]+P|0,f[3]=f[3]+g|0,f[4]=f[4]+h|0;},_doFinalize:function(){var d=this._data,y=d.words,f=this._nDataBytes*8,x=d.sigBytes*8;return y[x>>>5]|=128<<24-x%32,y[(x+64>>>9<<4)+14]=Math.floor(f/4294967296),y[(x+64>>>9<<4)+15]=f,d.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var d=n.clone.call(this);return d._hash=this._hash.clone(),d}});r.SHA1=n._createHelper(p),r.HmacSHA1=n._createHmacHelper(p);})(),a.SHA1});});var L;(n=>(n.log=(u,...s)=>console.log(`[Pixi\u2019VN Json] ${u}`,...s),n.warn=(u,...s)=>console.warn(`[Pixi\u2019VN Json] ${u}`,...s),n.error=(u,...s)=>console.error(`[Pixi\u2019VN Json] ${u}`,...s),n.info=(u,...s)=>console.info(`[Pixi\u2019VN Json] ${u}`,...s)))(L||(L={}));async function se(a,r={}){let{operationStringConvert:t,skipEmptyDialogs:o}=r;if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {L.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=a.map(async p=>{if(typeof p=="string")try{p=JSON.parse(p);}catch(d){L.error("Error parsing imported Pixi'VN JSON",d),p={};}return p}),s=(await Promise.all(n)).map(async p=>{let d=[];if(p.initialOperations){let y={};[...storage.storage.storage.keys()].forEach((f,x)=>{y[f]=storage.storage.storage.get(f);}),storage.storage.startingStorage=y;}if(p.labels){let y=p.labels;for(let f in y)try{let x=y[f],b=new w(f,x,void 0,r);narration.RegisteredLabels.add(b);}catch(x){L.error(`Error creating JSON label ${f}`,x);}}return Promise.all(d)});await Promise.all(s);}var K=oe(M());var $="___param___";function X(a){try{if(typeof a>"u")return a;let r=JSON.stringify(a);return JSON.parse(r)}catch(r){throw L.error("Error creating exportable element",a,r),new Error("[Pixi\u2019VN] Error creating exportable element")}}function q(a){let r="";return a.values.forEach(t=>{if(typeof t=="string")r+=t;else {let o=unifier.JsonUnifier.getLogichValue(t);r+=`${o}`;}}),r}async function j(a,r){let t=unifier.JsonUnifier.getLogichValue(a);if(t)switch(t.type){case "sound":unifier.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await unifier.JsonUnifier.loadAssets(t);break;case "image":await unifier.JsonUnifier.imageOperation(t);break;case "video":await unifier.JsonUnifier.videoOperation(t);break;case "imagecontainer":await unifier.JsonUnifier.imageContainerOperation(t);break;case "text":await unifier.JsonUnifier.textOperation(t);break;case "canvaselement":await unifier.JsonUnifier.canvasElementOperation(t);break;case "value":unifier.JsonUnifier.setStorageValue(t);break;case "operationtoconvert":if(r){let o=q(t),n=await r(o);n&&await j(n,r);}break;case "input":case "dialogue":unifier.JsonUnifier.narrationOperation(t);break;case "fade":case "move":case "rotate":case "zoom":unifier.JsonUnifier.tickerOperation(t);break;case "shake":await unifier.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":unifier.JsonUnifier.animateOperation(t);break}}var w=class extends narration.LabelAbstract{constructor(t,o,n,u={}){n||(n={}),n.onLoadingLabel=async()=>{for(let s of o){let p;if(typeof s=="function"?p=s():p=s,p=unifier.JsonUnifier.getConditionalStep(p),p.operations){let d=p.operations.map(y=>unifier.JsonUnifier.loadAssets(y));await Promise.all(d);}}};super(t,n);C(this,"_steps");C(this,"operationStringConvert");C(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=u.operationStringConvert,this.skipEmptyDialogs=u.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let o=this._steps[t];return this.stepConverter(o)}getStepSha(t){if(t<0||t>=this.steps.length)return;let o=this._steps[t];return (0, K.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let o="";if(Array.isArray(t)){let n=[];t.forEach(u=>{if(typeof u=="string")n.push(u);else if(u&&typeof u=="object"){let s=unifier.JsonUnifier.getLogichValue(u);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=unifier.JsonUnifier.getLogichValue(s)||""),Array.isArray(s)?n=n.map(p=>`${p}`).concat(s):n.push(`${s}`)):n.push(`${u}`);}else n.push(`${u}`);}),o=n;}else {let n=unifier.JsonUnifier.getLogichValue(t)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=unifier.JsonUnifier.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(t){if(t==null)return;let o=unifier.JsonUnifier.getLogichValue(t);return o==null?`${o}`:typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:translator.translator.t(this.getDialogueText(o.text))}:translator.translator.t(this.getDialogueText(`${o}`))}getChoices(t){return unifier.JsonUnifier.getLogichValue(t)?.map(u=>unifier.JsonUnifier.getLogichValue(u)).filter(u=>u!==void 0)}stepConverter(t){return async o=>{let n=typeof t=="function"?t():t;n=X(n),n=unifier.JsonUnifier.getConditionalStep(n);let u=this.operationStringConvert?g=>this.operationStringConvert(g,n,o):void 0,{operations:s=[]}=n;for(let g of s)await j(g,u);let{labelToOpen:p=[]}=n,d=this.getChoices(n.choices),y=unifier.JsonUnifier.getLogichValue(n.glueEnabled),f=this.getDialogue(n.dialogue),x=[];Array.isArray(p)||(p=[p]),p.forEach(g=>{let h=unifier.JsonUnifier.getLogichValue(g);h&&x.push(h);});let b=unifier.JsonUnifier.getLogichValue(n.goNextStep),P=unifier.JsonUnifier.getLogichValue(n.end);if(d){let g=d.map(h=>{let m="";if(Array.isArray(h.text)){let i=[];h.text.forEach(c=>{if(typeof c=="string")i.push(translator.translator.t(c));else if(c&&typeof c=="object"){let l=unifier.JsonUnifier.getLogichValue(c);l&&!Array.isArray(l)&&typeof l=="object"&&(l=unifier.JsonUnifier.getLogichValue(l)||""),l&&(Array.isArray(l)?i=i.concat(translator.translator.t(l)):i.push(translator.translator.t(l)));}}),m=i;}else typeof h.text=="string"&&(m=translator.translator.t(h.text));return {label:h.label,text:m,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});narration.narration.choiceMenuOptions=g;}else narration.narration.choiceMenuOptions=void 0;f!==void 0&&(narration.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(b=true)),y?storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):y===false&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let g of x){let h=g.label;typeof h=="object"&&(h=unifier.JsonUnifier.getLogichValue(h)||"");let m=g.params?.map(e=>unifier.JsonUnifier.getLogichValue(e));o={...o,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${$}${narration.narration.openedLabels.length}`,m),await narration.narration.callLabel(h,o)):(storage.storage.setTempVariable(`${$}${narration.narration.openedLabels.length}`,m),await narration.narration.callLabel(h,o));}P==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(o,{runNow:true})):P==="label_end"&&narration.narration.closeCurrentLabel(),b&&await narration.narration.goNext(o,{runNow:true});}}};exports.LabelJson=w;exports.importPixiVNJson=se;
1
+ 'use strict';var narration=require('@drincs/pixi-vn/narration'),unifier=require('@drincs/pixi-vn-json/unifier'),translator=require('@drincs/pixi-vn-json/translator'),storage=require('@drincs/pixi-vn/storage');var Q=Object.create;var I=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var re=(a,i,t)=>i in a?I(a,i,{enumerable:true,configurable:true,writable:true,value:t}):a[i]=t;var H=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(i,t)=>(typeof require<"u"?require:i)[t]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var z=(a,i)=>()=>(i||a((i={exports:{}}).exports,i),i.exports);var ne=(a,i,t,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of ee(i))!ie.call(a,n)&&n!==t&&I(a,n,{get:()=>i[n],enumerable:!(o=Z(i,n))||o.enumerable});return a};var oe=(a,i,t)=>(t=a!=null?Q(te(a)):{},ne(I(t,"default",{value:a,enumerable:true}),a));var C=(a,i,t)=>re(a,typeof i!="symbol"?i+"":i,t);var G=z((A,F)=>{(function(a,i){typeof A=="object"?F.exports=A=i():typeof define=="function"&&define.amd?define([],i):a.CryptoJS=i();})(A,function(){var a=a||(function(i,t){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof H=="function")try{o=H("crypto");}catch{}var n=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||(function(){function e(){}return function(r){var c;return e.prototype=r,c=new e,e.prototype=null,c}})(),s={},u=s.lib={},d=u.Base=(function(){return {extend:function(e){var r=l(this);return e&&r.mixIn(e),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments);}),r.init.prototype=r,r.$super=this,r},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),x=u.WordArray=d.extend({init:function(e,r){e=this.words=e||[],r!=t?this.sigBytes=r:this.sigBytes=e.length*4;},toString:function(e){return (e||V).stringify(this)},concat:function(e){var r=this.words,c=e.words,f=this.sigBytes,v=e.sigBytes;if(this.clamp(),f%4)for(var S=0;S<v;S++){var D=c[S>>>2]>>>24-S%4*8&255;r[f+S>>>2]|=D<<24-(f+S)%4*8;}else for(var _=0;_<v;_+=4)r[f+_>>>2]=c[_>>>2];return this.sigBytes+=v,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=i.ceil(r/4);},clone:function(){var e=d.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var r=[],c=0;c<e;c+=4)r.push(n());return new x.init(r,e)}}),p=s.enc={},V=p.Hex={stringify:function(e){for(var r=e.words,c=e.sigBytes,f=[],v=0;v<c;v++){var S=r[v>>>2]>>>24-v%4*8&255;f.push((S>>>4).toString(16)),f.push((S&15).toString(16));}return f.join("")},parse:function(e){for(var r=e.length,c=[],f=0;f<r;f+=2)c[f>>>3]|=parseInt(e.substr(f,2),16)<<24-f%8*4;return new x.init(c,r/2)}},b=p.Latin1={stringify:function(e){for(var r=e.words,c=e.sigBytes,f=[],v=0;v<c;v++){var S=r[v>>>2]>>>24-v%4*8&255;f.push(String.fromCharCode(S));}return f.join("")},parse:function(e){for(var r=e.length,c=[],f=0;f<r;f++)c[f>>>2]|=(e.charCodeAt(f)&255)<<24-f%4*8;return new x.init(c,r)}},N=p.Utf8={stringify:function(e){try{return decodeURIComponent(escape(b.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return b.parse(unescape(encodeURIComponent(e)))}},g=u.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new x.init,this._nDataBytes=0;},_append:function(e){typeof e=="string"&&(e=N.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(e){var r,c=this._data,f=c.words,v=c.sigBytes,S=this.blockSize,D=S*4,_=v/D;e?_=i.ceil(_):_=i.max((_|0)-this._minBufferSize,0);var T=_*S,j=i.min(T*4,v);if(T){for(var k=0;k<T;k+=S)this._doProcessBlock(f,k);r=f.splice(0,T),c.sigBytes-=j;}return new x.init(r,j)},clone:function(){var e=d.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});u.Hasher=g.extend({cfg:d.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(e){return function(r,c){return new e.init(c).finalize(r)}},_createHmacHelper:function(e){return function(r,c){return new y.HMAC.init(e,c).finalize(r)}}});var y=s.algo={};return s})(Math);return a});});var X=z((E,M)=>{(function(a,i){typeof E=="object"?M.exports=E=i(G()):typeof define=="function"&&define.amd?define(["./core"],i):i(a.CryptoJS);})(E,function(a){return (function(){var i=a,t=i.lib,o=t.WordArray,n=t.Hasher,l=i.algo,s=[],u=l.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,x){for(var p=this._hash.words,V=p[0],b=p[1],N=p[2],g=p[3],h=p[4],y=0;y<80;y++){if(y<16)s[y]=d[x+y]|0;else {var e=s[y-3]^s[y-8]^s[y-14]^s[y-16];s[y]=e<<1|e>>>31;}var r=(V<<5|V>>>27)+h+s[y];y<20?r+=(b&N|~b&g)+1518500249:y<40?r+=(b^N^g)+1859775393:y<60?r+=(b&N|b&g|N&g)-1894007588:r+=(b^N^g)-899497514,h=g,g=N,N=b<<30|b>>>2,b=V,V=r;}p[0]=p[0]+V|0,p[1]=p[1]+b|0,p[2]=p[2]+N|0,p[3]=p[3]+g|0,p[4]=p[4]+h|0;},_doFinalize:function(){var d=this._data,x=d.words,p=this._nDataBytes*8,V=d.sigBytes*8;return x[V>>>5]|=128<<24-V%32,x[(V+64>>>9<<4)+14]=Math.floor(p/4294967296),x[(V+64>>>9<<4)+15]=p,d.sigBytes=x.length*4,this._process(),this._hash},clone:function(){var d=n.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=n._createHelper(u),i.HmacSHA1=n._createHmacHelper(u);})(),a.SHA1});});var L;(n=>(n.log=(l,...s)=>console.log(`[Pixi\u2019VN Json] ${l}`,...s),n.warn=(l,...s)=>console.warn(`[Pixi\u2019VN Json] ${l}`,...s),n.error=(l,...s)=>console.error(`[Pixi\u2019VN Json] ${l}`,...s),n.info=(l,...s)=>console.info(`[Pixi\u2019VN Json] ${l}`,...s)))(L||(L={}));function W(a){let i="";return a.values.forEach(t=>{if(typeof t=="string")i+=t;else {let o=unifier.JsonUnifier.getLogichValue(t);i+=`${o}`;}}),i}async function R(a,i){let t=unifier.JsonUnifier.getLogichValue(a);if(t)switch(t.type){case "sound":unifier.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await unifier.JsonUnifier.loadAssets(t);break;case "image":await unifier.JsonUnifier.imageOperation(t);break;case "video":await unifier.JsonUnifier.videoOperation(t);break;case "imagecontainer":await unifier.JsonUnifier.imageContainerOperation(t);break;case "text":await unifier.JsonUnifier.textOperation(t);break;case "canvaselement":await unifier.JsonUnifier.canvasElementOperation(t);break;case "value":unifier.JsonUnifier.setStorageValue(t);break;case "operationtoconvert":if(i){let o=W(t),n=await i(o);n&&await R(n,i);}break;case "input":case "dialogue":unifier.JsonUnifier.narrationOperation(t);break;case "fade":case "move":case "rotate":case "zoom":unifier.JsonUnifier.tickerOperation(t);break;case "shake":await unifier.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":unifier.JsonUnifier.animateOperation(t);break}}function U(a){let i=unifier.JsonUnifier.getLogichValue(a);if(i)switch(i.type){case "value":i.storageOperationType==="set"&&(i.storageType==="storage"||i.storageType==="tempstorage")&&unifier.JsonUnifier.setInitialStorageValue(i);break}}async function le(a,i={}){if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {L.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let t=a.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(s){L.error("Error parsing imported Pixi'VN JSON",s),l={};}return l}),n=(await Promise.all(t)).map(async l=>{let s=[];if(l.initialOperations)for(let u of l.initialOperations)U(u);if(l.labels){let u=l.labels;for(let d in u)try{let x=u[d],p=new w(d,x,void 0,i);narration.RegisteredLabels.add(p);}catch(x){L.error(`Error creating JSON label ${d}`,x);}}return Promise.all(s)});await Promise.all(n);}var K=oe(X());var $="___param___";function q(a){try{if(typeof a>"u")return a;let i=JSON.stringify(a);return JSON.parse(i)}catch(i){throw L.error("Error creating exportable element",a,i),new Error("[Pixi\u2019VN] Error creating exportable element")}}var w=class extends narration.LabelAbstract{constructor(t,o,n,l={}){n||(n={}),n.onLoadingLabel=async()=>{for(let s of o){let u;if(typeof s=="function"?u=s():u=s,u=unifier.JsonUnifier.getConditionalStep(u),u.operations){let d=u.operations.map(x=>unifier.JsonUnifier.loadAssets(x));await Promise.all(d);}}};super(t,n);C(this,"_steps");C(this,"operationStringConvert");C(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=l.operationStringConvert,this.skipEmptyDialogs=l.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let o=this._steps[t];return this.stepConverter(o)}getStepSha(t){if(t<0||t>=this.steps.length)return;let o=this._steps[t];return (0, K.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let o="";if(Array.isArray(t)){let n=[];t.forEach(l=>{if(typeof l=="string")n.push(l);else if(l&&typeof l=="object"){let s=unifier.JsonUnifier.getLogichValue(l);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=unifier.JsonUnifier.getLogichValue(s)||""),Array.isArray(s)?n=n.map(u=>`${u}`).concat(s):n.push(`${s}`)):n.push(`${l}`);}else n.push(`${l}`);}),o=n;}else {let n=unifier.JsonUnifier.getLogichValue(t)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=unifier.JsonUnifier.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(t){if(t==null)return;let o=unifier.JsonUnifier.getLogichValue(t);return o==null?`${o}`:typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:translator.translator.t(this.getDialogueText(o.text))}:translator.translator.t(this.getDialogueText(`${o}`))}getChoices(t){return unifier.JsonUnifier.getLogichValue(t)?.map(l=>unifier.JsonUnifier.getLogichValue(l)).filter(l=>l!==void 0)}stepConverter(t){return async o=>{let n=typeof t=="function"?t():t;n=q(n),n=unifier.JsonUnifier.getConditionalStep(n);let l=this.operationStringConvert?g=>this.operationStringConvert(g,n,o):void 0,{operations:s=[]}=n;for(let g of s)await R(g,l);let{labelToOpen:u=[]}=n,d=this.getChoices(n.choices),x=unifier.JsonUnifier.getLogichValue(n.glueEnabled),p=this.getDialogue(n.dialogue),V=[];Array.isArray(u)||(u=[u]),u.forEach(g=>{let h=unifier.JsonUnifier.getLogichValue(g);h&&V.push(h);});let b=unifier.JsonUnifier.getLogichValue(n.goNextStep),N=unifier.JsonUnifier.getLogichValue(n.end);if(d){let g=d.map(h=>{let y="";if(Array.isArray(h.text)){let r=[];h.text.forEach(c=>{if(typeof c=="string")r.push(translator.translator.t(c));else if(c&&typeof c=="object"){let f=unifier.JsonUnifier.getLogichValue(c);f&&!Array.isArray(f)&&typeof f=="object"&&(f=unifier.JsonUnifier.getLogichValue(f)||""),f&&(Array.isArray(f)?r=r.concat(translator.translator.t(f)):r.push(translator.translator.t(f)));}}),y=r;}else typeof h.text=="string"&&(y=translator.translator.t(h.text));return {label:h.label,text:y,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});narration.narration.choiceMenuOptions=g;}else narration.narration.choiceMenuOptions=void 0;p!==void 0&&(narration.narration.dialogue=p,this.skipEmptyDialogs&&typeof p=="string"&&(p===""||RegExp(/^\s+$/).test(p))&&(b=true)),x?storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):x===false&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let g of V){let h=g.label;typeof h=="object"&&(h=unifier.JsonUnifier.getLogichValue(h)||"");let y=g.params?.map(e=>unifier.JsonUnifier.getLogichValue(e));o={...o,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${$}${narration.narration.openedLabels.length}`,y),await narration.narration.callLabel(h,o)):(storage.storage.setTempVariable(`${$}${narration.narration.openedLabels.length}`,y),await narration.narration.callLabel(h,o));}N==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(o,{runNow:true})):N==="label_end"&&narration.narration.closeCurrentLabel(),b&&await narration.narration.goNext(o,{runNow:true});}}};exports.LabelJson=w;exports.importPixiVNJson=le;
package/dist/importer.mjs CHANGED
@@ -1 +1 @@
1
- import {RegisteredLabels,LabelAbstract,narration}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';import {translator}from'@drincs/pixi-vn-json/translator';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';var Q=Object.create;var H=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var re=(a,r,t)=>r in a?H(a,r,{enumerable:true,configurable:true,writable:true,value:t}):a[r]=t;var I=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var W=(a,r)=>()=>(r||a((r={exports:{}}).exports,r),r.exports);var ne=(a,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of ee(r))!ie.call(a,n)&&n!==t&&H(a,n,{get:()=>r[n],enumerable:!(o=Z(r,n))||o.enumerable});return a};var oe=(a,r,t)=>(t=a!=null?Q(te(a)):{},ne(H(t,"default",{value:a,enumerable:true}),a));var C=(a,r,t)=>re(a,typeof r!="symbol"?r+"":r,t);var F=W((E,U)=>{(function(a,r){typeof E=="object"?U.exports=E=r():typeof define=="function"&&define.amd?define([],r):a.CryptoJS=r();})(E,function(){var a=a||(function(r,t){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof I=="function")try{o=I("crypto");}catch{}var n=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},u=Object.create||(function(){function e(){}return function(i){var c;return e.prototype=i,c=new e,e.prototype=null,c}})(),s={},p=s.lib={},d=p.Base=(function(){return {extend:function(e){var i=u(this);return e&&i.mixIn(e),(!i.hasOwnProperty("init")||this.init===i.init)&&(i.init=function(){i.$super.init.apply(this,arguments);}),i.init.prototype=i,i.$super=this,i},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=p.WordArray=d.extend({init:function(e,i){e=this.words=e||[],i!=t?this.sigBytes=i:this.sigBytes=e.length*4;},toString:function(e){return (e||x).stringify(this)},concat:function(e){var i=this.words,c=e.words,l=this.sigBytes,S=e.sigBytes;if(this.clamp(),l%4)for(var V=0;V<S;V++){var D=c[V>>>2]>>>24-V%4*8&255;i[l+V>>>2]|=D<<24-(l+V)%4*8;}else for(var _=0;_<S;_+=4)i[l+_>>>2]=c[_>>>2];return this.sigBytes+=S,this},clamp:function(){var e=this.words,i=this.sigBytes;e[i>>>2]&=4294967295<<32-i%4*8,e.length=r.ceil(i/4);},clone:function(){var e=d.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var i=[],c=0;c<e;c+=4)i.push(n());return new y.init(i,e)}}),f=s.enc={},x=f.Hex={stringify:function(e){for(var i=e.words,c=e.sigBytes,l=[],S=0;S<c;S++){var V=i[S>>>2]>>>24-S%4*8&255;l.push((V>>>4).toString(16)),l.push((V&15).toString(16));}return l.join("")},parse:function(e){for(var i=e.length,c=[],l=0;l<i;l+=2)c[l>>>3]|=parseInt(e.substr(l,2),16)<<24-l%8*4;return new y.init(c,i/2)}},b=f.Latin1={stringify:function(e){for(var i=e.words,c=e.sigBytes,l=[],S=0;S<c;S++){var V=i[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(V));}return l.join("")},parse:function(e){for(var i=e.length,c=[],l=0;l<i;l++)c[l>>>2]|=(e.charCodeAt(l)&255)<<24-l%4*8;return new y.init(c,i)}},P=f.Utf8={stringify:function(e){try{return decodeURIComponent(escape(b.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return b.parse(unescape(encodeURIComponent(e)))}},g=p.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(e){typeof e=="string"&&(e=P.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(e){var i,c=this._data,l=c.words,S=c.sigBytes,V=this.blockSize,D=V*4,_=S/D;e?_=r.ceil(_):_=r.max((_|0)-this._minBufferSize,0);var T=_*V,z=r.min(T*4,S);if(T){for(var k=0;k<T;k+=V)this._doProcessBlock(l,k);i=l.splice(0,T),c.sigBytes-=z;}return new y.init(i,z)},clone:function(){var e=d.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});p.Hasher=g.extend({cfg:d.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var i=this._doFinalize();return i},blockSize:512/32,_createHelper:function(e){return function(i,c){return new e.init(c).finalize(i)}},_createHmacHelper:function(e){return function(i,c){return new m.HMAC.init(e,c).finalize(i)}}});var m=s.algo={};return s})(Math);return a});});var M=W((A,G)=>{(function(a,r){typeof A=="object"?G.exports=A=r(F()):typeof define=="function"&&define.amd?define(["./core"],r):r(a.CryptoJS);})(A,function(a){return (function(){var r=a,t=r.lib,o=t.WordArray,n=t.Hasher,u=r.algo,s=[],p=u.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,y){for(var f=this._hash.words,x=f[0],b=f[1],P=f[2],g=f[3],h=f[4],m=0;m<80;m++){if(m<16)s[m]=d[y+m]|0;else {var e=s[m-3]^s[m-8]^s[m-14]^s[m-16];s[m]=e<<1|e>>>31;}var i=(x<<5|x>>>27)+h+s[m];m<20?i+=(b&P|~b&g)+1518500249:m<40?i+=(b^P^g)+1859775393:m<60?i+=(b&P|b&g|P&g)-1894007588:i+=(b^P^g)-899497514,h=g,g=P,P=b<<30|b>>>2,b=x,x=i;}f[0]=f[0]+x|0,f[1]=f[1]+b|0,f[2]=f[2]+P|0,f[3]=f[3]+g|0,f[4]=f[4]+h|0;},_doFinalize:function(){var d=this._data,y=d.words,f=this._nDataBytes*8,x=d.sigBytes*8;return y[x>>>5]|=128<<24-x%32,y[(x+64>>>9<<4)+14]=Math.floor(f/4294967296),y[(x+64>>>9<<4)+15]=f,d.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var d=n.clone.call(this);return d._hash=this._hash.clone(),d}});r.SHA1=n._createHelper(p),r.HmacSHA1=n._createHmacHelper(p);})(),a.SHA1});});var L;(n=>(n.log=(u,...s)=>console.log(`[Pixi\u2019VN Json] ${u}`,...s),n.warn=(u,...s)=>console.warn(`[Pixi\u2019VN Json] ${u}`,...s),n.error=(u,...s)=>console.error(`[Pixi\u2019VN Json] ${u}`,...s),n.info=(u,...s)=>console.info(`[Pixi\u2019VN Json] ${u}`,...s)))(L||(L={}));async function se(a,r={}){let{operationStringConvert:t,skipEmptyDialogs:o}=r;if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {L.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let n=a.map(async p=>{if(typeof p=="string")try{p=JSON.parse(p);}catch(d){L.error("Error parsing imported Pixi'VN JSON",d),p={};}return p}),s=(await Promise.all(n)).map(async p=>{let d=[];if(p.initialOperations){let y={};[...storage.storage.keys()].forEach((f,x)=>{y[f]=storage.storage.get(f);}),storage.startingStorage=y;}if(p.labels){let y=p.labels;for(let f in y)try{let x=y[f],b=new w(f,x,void 0,r);RegisteredLabels.add(b);}catch(x){L.error(`Error creating JSON label ${f}`,x);}}return Promise.all(d)});await Promise.all(s);}var K=oe(M());var $="___param___";function X(a){try{if(typeof a>"u")return a;let r=JSON.stringify(a);return JSON.parse(r)}catch(r){throw L.error("Error creating exportable element",a,r),new Error("[Pixi\u2019VN] Error creating exportable element")}}function q(a){let r="";return a.values.forEach(t=>{if(typeof t=="string")r+=t;else {let o=JsonUnifier.getLogichValue(t);r+=`${o}`;}}),r}async function j(a,r){let t=JsonUnifier.getLogichValue(a);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t);break;case "operationtoconvert":if(r){let o=q(t),n=await r(o);n&&await j(n,r);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "fade":case "move":case "rotate":case "zoom":JsonUnifier.tickerOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break}}var w=class extends LabelAbstract{constructor(t,o,n,u={}){n||(n={}),n.onLoadingLabel=async()=>{for(let s of o){let p;if(typeof s=="function"?p=s():p=s,p=JsonUnifier.getConditionalStep(p),p.operations){let d=p.operations.map(y=>JsonUnifier.loadAssets(y));await Promise.all(d);}}};super(t,n);C(this,"_steps");C(this,"operationStringConvert");C(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=u.operationStringConvert,this.skipEmptyDialogs=u.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let o=this._steps[t];return this.stepConverter(o)}getStepSha(t){if(t<0||t>=this.steps.length)return;let o=this._steps[t];return (0, K.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let o="";if(Array.isArray(t)){let n=[];t.forEach(u=>{if(typeof u=="string")n.push(u);else if(u&&typeof u=="object"){let s=JsonUnifier.getLogichValue(u);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=JsonUnifier.getLogichValue(s)||""),Array.isArray(s)?n=n.map(p=>`${p}`).concat(s):n.push(`${s}`)):n.push(`${u}`);}else n.push(`${u}`);}),o=n;}else {let n=JsonUnifier.getLogichValue(t)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=JsonUnifier.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(t){if(t==null)return;let o=JsonUnifier.getLogichValue(t);return o==null?`${o}`:typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:translator.t(this.getDialogueText(o.text))}:translator.t(this.getDialogueText(`${o}`))}getChoices(t){return JsonUnifier.getLogichValue(t)?.map(u=>JsonUnifier.getLogichValue(u)).filter(u=>u!==void 0)}stepConverter(t){return async o=>{let n=typeof t=="function"?t():t;n=X(n),n=JsonUnifier.getConditionalStep(n);let u=this.operationStringConvert?g=>this.operationStringConvert(g,n,o):void 0,{operations:s=[]}=n;for(let g of s)await j(g,u);let{labelToOpen:p=[]}=n,d=this.getChoices(n.choices),y=JsonUnifier.getLogichValue(n.glueEnabled),f=this.getDialogue(n.dialogue),x=[];Array.isArray(p)||(p=[p]),p.forEach(g=>{let h=JsonUnifier.getLogichValue(g);h&&x.push(h);});let b=JsonUnifier.getLogichValue(n.goNextStep),P=JsonUnifier.getLogichValue(n.end);if(d){let g=d.map(h=>{let m="";if(Array.isArray(h.text)){let i=[];h.text.forEach(c=>{if(typeof c=="string")i.push(translator.t(c));else if(c&&typeof c=="object"){let l=JsonUnifier.getLogichValue(c);l&&!Array.isArray(l)&&typeof l=="object"&&(l=JsonUnifier.getLogichValue(l)||""),l&&(Array.isArray(l)?i=i.concat(translator.t(l)):i.push(translator.t(l)));}}),m=i;}else typeof h.text=="string"&&(m=translator.t(h.text));return {label:h.label,text:m,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});narration.choiceMenuOptions=g;}else narration.choiceMenuOptions=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(b=true)),y?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):y===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let g of x){let h=g.label;typeof h=="object"&&(h=JsonUnifier.getLogichValue(h)||"");let m=g.params?.map(e=>JsonUnifier.getLogichValue(e));o={...o,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${$}${narration.openedLabels.length}`,m),await narration.callLabel(h,o)):(storage.setTempVariable(`${$}${narration.openedLabels.length}`,m),await narration.callLabel(h,o));}P==="game_end"?(narration.closeAllLabels(),await narration.goNext(o,{runNow:true})):P==="label_end"&&narration.closeCurrentLabel(),b&&await narration.goNext(o,{runNow:true});}}};export{w as LabelJson,se as importPixiVNJson};
1
+ import {RegisteredLabels,LabelAbstract,narration}from'@drincs/pixi-vn/narration';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';import {translator}from'@drincs/pixi-vn-json/translator';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var Q=Object.create;var I=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var re=(a,i,t)=>i in a?I(a,i,{enumerable:true,configurable:true,writable:true,value:t}):a[i]=t;var H=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(i,t)=>(typeof require<"u"?require:i)[t]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var z=(a,i)=>()=>(i||a((i={exports:{}}).exports,i),i.exports);var ne=(a,i,t,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of ee(i))!ie.call(a,n)&&n!==t&&I(a,n,{get:()=>i[n],enumerable:!(o=Z(i,n))||o.enumerable});return a};var oe=(a,i,t)=>(t=a!=null?Q(te(a)):{},ne(I(t,"default",{value:a,enumerable:true}),a));var C=(a,i,t)=>re(a,typeof i!="symbol"?i+"":i,t);var G=z((A,F)=>{(function(a,i){typeof A=="object"?F.exports=A=i():typeof define=="function"&&define.amd?define([],i):a.CryptoJS=i();})(A,function(){var a=a||(function(i,t){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof H=="function")try{o=H("crypto");}catch{}var n=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||(function(){function e(){}return function(r){var c;return e.prototype=r,c=new e,e.prototype=null,c}})(),s={},u=s.lib={},d=u.Base=(function(){return {extend:function(e){var r=l(this);return e&&r.mixIn(e),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments);}),r.init.prototype=r,r.$super=this,r},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var r in e)e.hasOwnProperty(r)&&(this[r]=e[r]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),x=u.WordArray=d.extend({init:function(e,r){e=this.words=e||[],r!=t?this.sigBytes=r:this.sigBytes=e.length*4;},toString:function(e){return (e||V).stringify(this)},concat:function(e){var r=this.words,c=e.words,f=this.sigBytes,v=e.sigBytes;if(this.clamp(),f%4)for(var S=0;S<v;S++){var D=c[S>>>2]>>>24-S%4*8&255;r[f+S>>>2]|=D<<24-(f+S)%4*8;}else for(var _=0;_<v;_+=4)r[f+_>>>2]=c[_>>>2];return this.sigBytes+=v,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=i.ceil(r/4);},clone:function(){var e=d.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var r=[],c=0;c<e;c+=4)r.push(n());return new x.init(r,e)}}),p=s.enc={},V=p.Hex={stringify:function(e){for(var r=e.words,c=e.sigBytes,f=[],v=0;v<c;v++){var S=r[v>>>2]>>>24-v%4*8&255;f.push((S>>>4).toString(16)),f.push((S&15).toString(16));}return f.join("")},parse:function(e){for(var r=e.length,c=[],f=0;f<r;f+=2)c[f>>>3]|=parseInt(e.substr(f,2),16)<<24-f%8*4;return new x.init(c,r/2)}},b=p.Latin1={stringify:function(e){for(var r=e.words,c=e.sigBytes,f=[],v=0;v<c;v++){var S=r[v>>>2]>>>24-v%4*8&255;f.push(String.fromCharCode(S));}return f.join("")},parse:function(e){for(var r=e.length,c=[],f=0;f<r;f++)c[f>>>2]|=(e.charCodeAt(f)&255)<<24-f%4*8;return new x.init(c,r)}},N=p.Utf8={stringify:function(e){try{return decodeURIComponent(escape(b.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return b.parse(unescape(encodeURIComponent(e)))}},g=u.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new x.init,this._nDataBytes=0;},_append:function(e){typeof e=="string"&&(e=N.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(e){var r,c=this._data,f=c.words,v=c.sigBytes,S=this.blockSize,D=S*4,_=v/D;e?_=i.ceil(_):_=i.max((_|0)-this._minBufferSize,0);var T=_*S,j=i.min(T*4,v);if(T){for(var k=0;k<T;k+=S)this._doProcessBlock(f,k);r=f.splice(0,T),c.sigBytes-=j;}return new x.init(r,j)},clone:function(){var e=d.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});u.Hasher=g.extend({cfg:d.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(e){return function(r,c){return new e.init(c).finalize(r)}},_createHmacHelper:function(e){return function(r,c){return new y.HMAC.init(e,c).finalize(r)}}});var y=s.algo={};return s})(Math);return a});});var X=z((E,M)=>{(function(a,i){typeof E=="object"?M.exports=E=i(G()):typeof define=="function"&&define.amd?define(["./core"],i):i(a.CryptoJS);})(E,function(a){return (function(){var i=a,t=i.lib,o=t.WordArray,n=t.Hasher,l=i.algo,s=[],u=l.SHA1=n.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,x){for(var p=this._hash.words,V=p[0],b=p[1],N=p[2],g=p[3],h=p[4],y=0;y<80;y++){if(y<16)s[y]=d[x+y]|0;else {var e=s[y-3]^s[y-8]^s[y-14]^s[y-16];s[y]=e<<1|e>>>31;}var r=(V<<5|V>>>27)+h+s[y];y<20?r+=(b&N|~b&g)+1518500249:y<40?r+=(b^N^g)+1859775393:y<60?r+=(b&N|b&g|N&g)-1894007588:r+=(b^N^g)-899497514,h=g,g=N,N=b<<30|b>>>2,b=V,V=r;}p[0]=p[0]+V|0,p[1]=p[1]+b|0,p[2]=p[2]+N|0,p[3]=p[3]+g|0,p[4]=p[4]+h|0;},_doFinalize:function(){var d=this._data,x=d.words,p=this._nDataBytes*8,V=d.sigBytes*8;return x[V>>>5]|=128<<24-V%32,x[(V+64>>>9<<4)+14]=Math.floor(p/4294967296),x[(V+64>>>9<<4)+15]=p,d.sigBytes=x.length*4,this._process(),this._hash},clone:function(){var d=n.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=n._createHelper(u),i.HmacSHA1=n._createHmacHelper(u);})(),a.SHA1});});var L;(n=>(n.log=(l,...s)=>console.log(`[Pixi\u2019VN Json] ${l}`,...s),n.warn=(l,...s)=>console.warn(`[Pixi\u2019VN Json] ${l}`,...s),n.error=(l,...s)=>console.error(`[Pixi\u2019VN Json] ${l}`,...s),n.info=(l,...s)=>console.info(`[Pixi\u2019VN Json] ${l}`,...s)))(L||(L={}));function W(a){let i="";return a.values.forEach(t=>{if(typeof t=="string")i+=t;else {let o=JsonUnifier.getLogichValue(t);i+=`${o}`;}}),i}async function R(a,i){let t=JsonUnifier.getLogichValue(a);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t);break;case "operationtoconvert":if(i){let o=W(t),n=await i(o);n&&await R(n,i);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "fade":case "move":case "rotate":case "zoom":JsonUnifier.tickerOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break}}function U(a){let i=JsonUnifier.getLogichValue(a);if(i)switch(i.type){case "value":i.storageOperationType==="set"&&(i.storageType==="storage"||i.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(i);break}}async function le(a,i={}){if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {L.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let t=a.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(s){L.error("Error parsing imported Pixi'VN JSON",s),l={};}return l}),n=(await Promise.all(t)).map(async l=>{let s=[];if(l.initialOperations)for(let u of l.initialOperations)U(u);if(l.labels){let u=l.labels;for(let d in u)try{let x=u[d],p=new w(d,x,void 0,i);RegisteredLabels.add(p);}catch(x){L.error(`Error creating JSON label ${d}`,x);}}return Promise.all(s)});await Promise.all(n);}var K=oe(X());var $="___param___";function q(a){try{if(typeof a>"u")return a;let i=JSON.stringify(a);return JSON.parse(i)}catch(i){throw L.error("Error creating exportable element",a,i),new Error("[Pixi\u2019VN] Error creating exportable element")}}var w=class extends LabelAbstract{constructor(t,o,n,l={}){n||(n={}),n.onLoadingLabel=async()=>{for(let s of o){let u;if(typeof s=="function"?u=s():u=s,u=JsonUnifier.getConditionalStep(u),u.operations){let d=u.operations.map(x=>JsonUnifier.loadAssets(x));await Promise.all(d);}}};super(t,n);C(this,"_steps");C(this,"operationStringConvert");C(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=l.operationStringConvert,this.skipEmptyDialogs=l.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let o=this._steps[t];return this.stepConverter(o)}getStepSha(t){if(t<0||t>=this.steps.length)return;let o=this._steps[t];return (0, K.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let o="";if(Array.isArray(t)){let n=[];t.forEach(l=>{if(typeof l=="string")n.push(l);else if(l&&typeof l=="object"){let s=JsonUnifier.getLogichValue(l);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=JsonUnifier.getLogichValue(s)||""),Array.isArray(s)?n=n.map(u=>`${u}`).concat(s):n.push(`${s}`)):n.push(`${l}`);}else n.push(`${l}`);}),o=n;}else {let n=JsonUnifier.getLogichValue(t)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=JsonUnifier.getLogichValue(n)||""),o=n;}return `${o}`}getDialogue(t){if(t==null)return;let o=JsonUnifier.getLogichValue(t);return o==null?`${o}`:typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:translator.t(this.getDialogueText(o.text))}:translator.t(this.getDialogueText(`${o}`))}getChoices(t){return JsonUnifier.getLogichValue(t)?.map(l=>JsonUnifier.getLogichValue(l)).filter(l=>l!==void 0)}stepConverter(t){return async o=>{let n=typeof t=="function"?t():t;n=q(n),n=JsonUnifier.getConditionalStep(n);let l=this.operationStringConvert?g=>this.operationStringConvert(g,n,o):void 0,{operations:s=[]}=n;for(let g of s)await R(g,l);let{labelToOpen:u=[]}=n,d=this.getChoices(n.choices),x=JsonUnifier.getLogichValue(n.glueEnabled),p=this.getDialogue(n.dialogue),V=[];Array.isArray(u)||(u=[u]),u.forEach(g=>{let h=JsonUnifier.getLogichValue(g);h&&V.push(h);});let b=JsonUnifier.getLogichValue(n.goNextStep),N=JsonUnifier.getLogichValue(n.end);if(d){let g=d.map(h=>{let y="";if(Array.isArray(h.text)){let r=[];h.text.forEach(c=>{if(typeof c=="string")r.push(translator.t(c));else if(c&&typeof c=="object"){let f=JsonUnifier.getLogichValue(c);f&&!Array.isArray(f)&&typeof f=="object"&&(f=JsonUnifier.getLogichValue(f)||""),f&&(Array.isArray(f)?r=r.concat(translator.t(f)):r.push(translator.t(f)));}}),y=r;}else typeof h.text=="string"&&(y=translator.t(h.text));return {label:h.label,text:y,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});narration.choiceMenuOptions=g;}else narration.choiceMenuOptions=void 0;p!==void 0&&(narration.dialogue=p,this.skipEmptyDialogs&&typeof p=="string"&&(p===""||RegExp(/^\s+$/).test(p))&&(b=true)),x?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):x===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let g of V){let h=g.label;typeof h=="object"&&(h=JsonUnifier.getLogichValue(h)||"");let y=g.params?.map(e=>JsonUnifier.getLogichValue(e));o={...o,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${$}${narration.openedLabels.length}`,y),await narration.callLabel(h,o)):(storage.setTempVariable(`${$}${narration.openedLabels.length}`,y),await narration.callLabel(h,o));}N==="game_end"?(narration.closeAllLabels(),await narration.goNext(o,{runNow:true})):N==="label_end"&&narration.closeCurrentLabel(),b&&await narration.goNext(o,{runNow:true});}}};export{w as LabelJson,le as importPixiVNJson};
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var importer=require('@drincs/pixi-vn-json/importer'),translator=require('@drincs/pixi-vn-json/translator'),unifier=require('@drincs/pixi-vn-json/unifier'),canvas=require('@drincs/pixi-vn/canvas'),narration=require('@drincs/pixi-vn/narration'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var y="___param___";async function E(e){let i=unifier.JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await canvas.Assets.load(i.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await canvas.Assets.loadBundle(i.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(i.aliases);break}break}}var r;(n=>(n.log=(l,...u)=>console.log(`[Pixi\u2019VN Json] ${l}`,...u),n.warn=(l,...u)=>console.warn(`[Pixi\u2019VN Json] ${l}`,...u),n.error=(l,...u)=>console.error(`[Pixi\u2019VN Json] ${l}`,...u),n.info=(l,...u)=>console.info(`[Pixi\u2019VN Json] ${l}`,...u)))(r||(r={}));async function b(e,i,a){switch(a.type){case "fade":await canvas.showWithFade(i.alias,e,a.props,a.priority);break;case "dissolve":await canvas.showWithDissolve(i.alias,e,a.props,a.priority);break;case "movein":case "moveout":await canvas.moveIn(i.alias,e,a.props,a.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(i.alias,e,a.props,a.priority);break;case "pushin":case "pushout":await canvas.pushIn(i.alias,e,a.props,a.priority);break}}function h(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function I(e){switch(e.operationType){case "show":if(e.transition){let a=new canvas.ImageSprite(e.props,e.url||e.alias);await b(a,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Image with alias ${e.alias} not found.`);break;case "remove":h(e);break}}async function v(e){switch(e.operationType){case "show":if(e.transition){let n=new canvas.VideoSprite(e.props,e.url||e.alias);await b(n,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Video with alias ${e.alias} not found.`);break;case "remove":h(e);break;case "pause":let a=canvas.canvas.find(e.alias);a?a.paused=true:r.error(`Video with alias ${e.alias} not found.`);break;case "resume":let o=canvas.canvas.find(e.alias);o?o.paused=false:r.error(`Video with alias ${e.alias} not found.`);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let a=new canvas.ImageContainer(e.props,e.urls);await b(a,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":h(e);break}}async function _(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let a=new canvas.Text(e.props);await b(a,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Text with alias ${e.alias} not found.`);break;case "remove":h(e);break}}async function R(e){switch(e.operationType){case "edit":try{let i=canvas.canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):r.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){r.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":h(e);break}}function L(e){switch(e.type){case "fade":let i=new canvas.FadeAlphaTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,i);break;case "move":let a=new canvas.MoveTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,a);break;case "rotate":let o=new canvas.RotateTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,o);break;case "zoom":let n=new canvas.ZoomTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,n);break}}async function D(e){switch(e.type){case "shake":await canvas.shakeEffect(e.alias,e.props,e.priority);break}}function M(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function F(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function $(e){switch(e.operationType){case "play":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(e.alias);break;case "pause":pixiVn.sound.pause(e.alias);break;case "resume":pixiVn.sound.resume(e.alias);break;case "volume":pixiVn.sound.volume(e.alias,e.value);break}}function j(e){try{if(typeof e>"u")return e;let i=JSON.stringify(e);return JSON.parse(i)}catch(i){throw r.error("Error creating exportable element",e,i),new Error("[Pixi\u2019VN] Error creating exportable element")}}function U(e){let i=t(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=t(i):a=i,e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.setVariable(e.key,a);break;case "tempstorage":storage.storage.setTempVariable(e.key,a);break;case "params":let o=storage.storage.getVariable(`${y}${narration.narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=a),storage.storage.setTempVariable(`${y}${narration.narration.openedLabels.length-1}`,o);break}}function t(e){let i=we(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return Ne(i);case "arithmetic":case "arithmeticsingle":return Te(i);case "compare":case "valueCondition":case "union":return be(i)}return i}function Te(e){let i=t(e.leftValue);switch(e.type){case "arithmetic":let a=t(e.rightValue);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return i+a;case "-":return i-a;case "%":return i%a;case "POW":return Math.pow(i,a);case "RANDOM":return narration.narration.getRandomNumber(i,a)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function Ne(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.storage.getVariable(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return t(e.operation);case "params":let i=storage.storage.getVariable(`${y}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];r.warn("getValue params not found");return}return e}function be(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=t(e.leftValue),a=t(e.rightValue);switch(e.operator){case "==":return i===a;case "!=":return i!==a;case "<":return i<a;case "<=":return i<=a;case ">":return i>a;case ">=":return i>=a;case "CONTAINS":return i.toString().includes(a.toString())}break;case "valueCondition":return !!t(e.value);case "union":return Pe(e)}return !!e}function Pe(e){if(e.unionType==="not")return !t(e.condition);let i=e.unionType==="and";for(let a=0;a<e.conditions.length;a++)if(i=t(e.conditions[a])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Je(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function we(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Se(e);case "ifelse":return t(e.condition)?t(e.then):t(e.else);case "stepswitch":let a=t(e.elements)||[];if(a.length===0){r.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=Je(0,a.length-1);return t(a[o]);case "loop":let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>a.length-1&&(n=n%a.length),t(a[n]);case "sequential":let l,u=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(l=t(a[a.length-1])),u>a.length-1?l:t(a[u]);case "sequentialrandom":let p=narration.NarrationManagerStatic.getRandomNumber(0,a.length-1,{nestedId:e.nestedId,onceOnly:true});if(p==null&&e.end=="lastItem"){let x=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!x||!x?.usedRandomNumbers){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let V=x.usedRandomNumbers[`0-${a.length-1}`];return t(a[V[V.length-1]])}if(p==null){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return t(a[p])}}return e}function J(e){if(e.conditionalStep){let i=j(t(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return J(a)}else storage.storage.getFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function Se(e){let i=e.firstItem,a=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(l=>{let u=t(l);a.push(u);});else {let l=t(n);a.push(l);}});let o=i?[i,...a]:a;if(o.length===0){r.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator.translator.t(o);if(typeof o[0]=="object"){let n=o,l,u=n.map((s,m)=>{s=J(s);let d=t(s.dialogue)||"";return m===0?(l=t(s.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),l===false&&(d=`
1
+ 'use strict';var importer=require('@drincs/pixi-vn-json/importer'),translator=require('@drincs/pixi-vn-json/translator'),unifier=require('@drincs/pixi-vn-json/unifier'),canvas=require('@drincs/pixi-vn/canvas'),narration=require('@drincs/pixi-vn/narration'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var V="___param___";async function E(e){let a=unifier.JsonUnifier.getLogichValue(e);if(a)switch(a.type){case "assets":switch(a.operationType){case "load":await canvas.Assets.load(a.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(a.aliases);break}break;case "bundle":switch(a.operationType){case "load":await canvas.Assets.loadBundle(a.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(a.aliases);break}break}}var r;(n=>(n.log=(l,...u)=>console.log(`[Pixi\u2019VN Json] ${l}`,...u),n.warn=(l,...u)=>console.warn(`[Pixi\u2019VN Json] ${l}`,...u),n.error=(l,...u)=>console.error(`[Pixi\u2019VN Json] ${l}`,...u),n.info=(l,...u)=>console.info(`[Pixi\u2019VN Json] ${l}`,...u)))(r||(r={}));async function b(e,a,i){switch(i.type){case "fade":await canvas.showWithFade(a.alias,e,i.props,i.priority);break;case "dissolve":await canvas.showWithDissolve(a.alias,e,i.props,i.priority);break;case "movein":case "moveout":await canvas.moveIn(a.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(a.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await canvas.pushIn(a.alias,e,i.props,i.priority);break}}function T(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function I(e){switch(e.operationType){case "show":if(e.transition){let i=new canvas.ImageSprite(e.props,e.url||e.alias);await b(i,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`Image with alias ${e.alias} not found.`);break;case "remove":T(e);break}}async function v(e){switch(e.operationType){case "show":if(e.transition){let n=new canvas.VideoSprite(e.props,e.url||e.alias);await b(n,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`Video with alias ${e.alias} not found.`);break;case "remove":T(e);break;case "pause":let i=canvas.canvas.find(e.alias);i?i.paused=true:r.error(`Video with alias ${e.alias} not found.`);break;case "resume":let o=canvas.canvas.find(e.alias);o?o.paused=false:r.error(`Video with alias ${e.alias} not found.`);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let i=new canvas.ImageContainer(e.props,e.urls);await b(i,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":T(e);break}}async function _(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let i=new canvas.Text(e.props);await b(i,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`Text with alias ${e.alias} not found.`);break;case "remove":T(e);break}}async function R(e){switch(e.operationType){case "edit":try{let a=canvas.canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):r.error(`Canvas Element with alias ${e.alias} not found.`);}catch(a){r.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,a);}break;case "remove":T(e);break}}function L(e){switch(e.type){case "fade":let a=new canvas.FadeAlphaTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,a);break;case "move":let i=new canvas.MoveTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,i);break;case "rotate":let o=new canvas.RotateTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,o);break;case "zoom":let n=new canvas.ZoomTicker(e.props,e.duration,e.priority);canvas.canvas.addTicker(e.alias,n);break}}async function D(e){switch(e.type){case "shake":await canvas.shakeEffect(e.alias,e.props,e.priority);break}}function M(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function F(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function $(e){switch(e.operationType){case "play":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(e.alias);break;case "pause":pixiVn.sound.pause(e.alias);break;case "resume":pixiVn.sound.resume(e.alias);break;case "volume":pixiVn.sound.volume(e.alias,e.value);break}}function j(e){try{if(typeof e>"u")return e;let a=JSON.stringify(e);return JSON.parse(a)}catch(a){throw r.error("Error creating exportable element",e,a),new Error("[Pixi\u2019VN] Error creating exportable element")}}function U(e){let a=t(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=t(a):i=a,e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.setVariable(e.key,i);break;case "tempstorage":storage.storage.setTempVariable(e.key,i);break;case "params":let o=storage.storage.getVariable(`${V}${narration.narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=i),storage.storage.setTempVariable(`${V}${narration.narration.openedLabels.length-1}`,o);break}}function z(e){let a=t(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=t(a):i=a,e.storageType){case "storage":case "tempstorage":storage.storage.startingStorage={[e.key]:i};break}}function t(e){let a=we(e);if(a&&typeof a=="object"&&"type"in a)switch(a.type){case "value":return be(a);case "arithmetic":case "arithmeticsingle":return Ne(a);case "compare":case "valueCondition":case "union":return Pe(a)}return a}function Ne(e){let a=t(e.leftValue);switch(e.type){case "arithmetic":let i=t(e.rightValue);switch(e.operator){case "*":return a*i;case "/":return a/i;case "+":return a+i;case "-":return a-i;case "%":return a%i;case "POW":return Math.pow(a,i);case "RANDOM":return narration.narration.getRandomNumber(a,i)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(a);case "FLOOR":return Math.floor(a);case "FLOAT":return parseFloat(a)}break}}function be(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.storage.getVariable(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return t(e.operation);case "params":let a=storage.storage.getVariable(`${V}${narration.narration.openedLabels.length-1}`)||[];if(a&&a.length>e.key)return a[e.key];r.warn("getValue params not found");return}return e}function Pe(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let a=t(e.leftValue),i=t(e.rightValue);switch(e.operator){case "==":return a===i;case "!=":return a!==i;case "<":return a<i;case "<=":return a<=i;case ">":return a>i;case ">=":return a>=i;case "CONTAINS":return a.toString().includes(i.toString())}break;case "valueCondition":return !!t(e.value);case "union":return Je(e)}return !!e}function Je(e){if(e.unionType==="not")return !t(e.condition);let a=e.unionType==="and";for(let i=0;i<e.conditions.length;i++)if(a=t(e.conditions[i])||false,e.unionType==="and"){if(!a)return false}else if(a)return true;return a}function Se(e,a){return Math.floor(Math.random()*(a-e+1)+e)}function we(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ke(e);case "ifelse":return t(e.condition)?t(e.then):t(e.else);case "stepswitch":let i=t(e.elements)||[];if(i.length===0){r.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=Se(0,i.length-1);return t(i[o]);case "loop":let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>i.length-1&&(n=n%i.length),t(i[n]);case "sequential":let l,u=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(l=t(i[i.length-1])),u>i.length-1?l:t(i[u]);case "sequentialrandom":let p=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(p==null&&e.end=="lastItem"){let x=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!x||!x?.usedRandomNumbers){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let y=x.usedRandomNumbers[`0-${i.length-1}`];return t(i[y[y.length-1]])}if(p==null){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return t(i[p])}}return e}function J(e){if(e.conditionalStep){let a=j(t(e.conditionalStep));if(a?.glueEnabled===void 0&&delete a?.glueEnabled,a?.goNextStep===void 0&&delete a?.goNextStep,a?.end===void 0&&delete a?.end,a?.choices===void 0&&delete a?.choices,a?.dialogue===void 0&&delete a?.dialogue,a?.labelToOpen===void 0&&delete a?.labelToOpen,a?.operations===void 0&&delete a?.operations,a){let i={...e,conditionalStep:void 0,...a};return J(i)}else storage.storage.getFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function ke(e){let a=e.firstItem,i=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(l=>{let u=t(l);i.push(u);});else {let l=t(n);i.push(l);}});let o=a?[a,...i]:i;if(o.length===0){r.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator.translator.t(o);if(typeof o[0]=="object"){let n=o,l,u=n.map((s,m)=>{s=J(s);let d=t(s.dialogue)||"";return m===0?(l=t(s.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),l===false&&(d=`
2
2
 
3
- `+d),l=t(s.glueEnabled)||false,d)}),p=t(u[0]),x=typeof p=="object"&&"character"in p?p.character:void 0,V=u.flatMap(s=>{let m;s&&typeof s=="object"&&"text"in s?m=s.text:m=s;let d;return Array.isArray(m)?d=m.map(q=>{let Y=t(q);return translator.translator.t(`${Y}`)}):d=t(m)||"",translator.translator.t(d)}),z=n.find(s=>s.end),X=n.find(s=>s.choices),C=false,O=false;n.length>0&&(n[0].glueEnabled&&n[0].goNextStep&&n[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),C=n[n.length-1].glueEnabled,O=n.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let W=n.find(s=>s.labelToOpen),w=[];return n.forEach(s=>{s.operations&&w.forEach(m=>{w.push(m);});}),{dialogue:x?{character:x,text:V}:V,end:z?.end,choices:X?.choices,glueEnabled:C,goNextStep:O,labelToOpen:W?.labelToOpen,operations:w}}}function li(){unifier.JsonUnifier.init({animateOperation:M,canvasElementOperation:R,effectOperation:D,imageContainerOperation:A,imageOperation:I,textOperation:_,narrationOperation:F,loadAssets:E,soundOperation:$,tickerOperation:L,videoOperation:v,setStorageValue:U,getLogichValue:t,getConditionalStep:J});}exports.PIXIVNJSON_PARAM_ID=y;exports.init=li;Object.keys(importer).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return importer[k]}})});Object.keys(translator).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return translator[k]}})});Object.keys(unifier).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return unifier[k]}})});
3
+ `+d),l=t(s.glueEnabled)||false,d)}),p=t(u[0]),x=typeof p=="object"&&"character"in p?p.character:void 0,y=u.flatMap(s=>{let m;s&&typeof s=="object"&&"text"in s?m=s.text:m=s;let d;return Array.isArray(m)?d=m.map(Y=>{let K=t(Y);return translator.translator.t(`${K}`)}):d=t(m)||"",translator.translator.t(d)}),X=n.find(s=>s.end),W=n.find(s=>s.choices),C=false,O=false;n.length>0&&(n[0].glueEnabled&&n[0].goNextStep&&n[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),C=n[n.length-1].glueEnabled,O=n.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let q=n.find(s=>s.labelToOpen),S=[];return n.forEach(s=>{s.operations&&S.forEach(m=>{S.push(m);});}),{dialogue:x?{character:x,text:y}:y,end:X?.end,choices:W?.choices,glueEnabled:C,goNextStep:O,labelToOpen:q?.labelToOpen,operations:S}}}function ua(){unifier.JsonUnifier.init({animateOperation:M,canvasElementOperation:R,effectOperation:D,imageContainerOperation:A,imageOperation:I,textOperation:_,narrationOperation:F,loadAssets:E,soundOperation:$,tickerOperation:L,videoOperation:v,setStorageValue:U,setInitialStorageValue:z,getLogichValue:t,getConditionalStep:J});}exports.PIXIVNJSON_PARAM_ID=V;exports.init=ua;Object.keys(importer).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return importer[k]}})});Object.keys(translator).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return translator[k]}})});Object.keys(unifier).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return unifier[k]}})});
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export*from'@drincs/pixi-vn-json/importer';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';export*from'@drincs/pixi-vn-json/unifier';import {canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,Assets,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var y="___param___";async function E(e){let i=JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await Assets.load(i.aliases);break;case "lazyload":Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await Assets.loadBundle(i.aliases);break;case "lazyload":Assets.backgroundLoadBundle(i.aliases);break}break}}var r;(n=>(n.log=(l,...u)=>console.log(`[Pixi\u2019VN Json] ${l}`,...u),n.warn=(l,...u)=>console.warn(`[Pixi\u2019VN Json] ${l}`,...u),n.error=(l,...u)=>console.error(`[Pixi\u2019VN Json] ${l}`,...u),n.info=(l,...u)=>console.info(`[Pixi\u2019VN Json] ${l}`,...u)))(r||(r={}));async function b(e,i,a){switch(a.type){case "fade":await showWithFade(i.alias,e,a.props,a.priority);break;case "dissolve":await showWithDissolve(i.alias,e,a.props,a.priority);break;case "movein":case "moveout":await moveIn(i.alias,e,a.props,a.priority);break;case "zoomin":case "zoomout":await zoomIn(i.alias,e,a.props,a.priority);break;case "pushin":case "pushout":await pushIn(i.alias,e,a.props,a.priority);break}}function h(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function I(e){switch(e.operationType){case "show":if(e.transition){let a=new ImageSprite(e.props,e.url||e.alias);await b(a,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Image with alias ${e.alias} not found.`);break;case "remove":h(e);break}}async function v(e){switch(e.operationType){case "show":if(e.transition){let n=new VideoSprite(e.props,e.url||e.alias);await b(n,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Video with alias ${e.alias} not found.`);break;case "remove":h(e);break;case "pause":let a=canvas.find(e.alias);a?a.paused=true:r.error(`Video with alias ${e.alias} not found.`);break;case "resume":let o=canvas.find(e.alias);o?o.paused=false:r.error(`Video with alias ${e.alias} not found.`);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let a=new ImageContainer(e.props,e.urls);await b(a,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":h(e);break}}async function _(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator$1.t(e.text),e.transition){let a=new Text(e.props);await b(a,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Text with alias ${e.alias} not found.`);break;case "remove":h(e);break}}async function R(e){switch(e.operationType){case "edit":try{let i=canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):r.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){r.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":h(e);break}}function L(e){switch(e.type){case "fade":let i=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,i);break;case "move":let a=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "rotate":let o=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,o);break;case "zoom":let n=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,n);break}}async function D(e){switch(e.type){case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}function M(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function F(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function $(e){switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(e.alias);break;case "pause":sound.pause(e.alias);break;case "resume":sound.resume(e.alias);break;case "volume":sound.volume(e.alias,e.value);break}}function j(e){try{if(typeof e>"u")return e;let i=JSON.stringify(e);return JSON.parse(i)}catch(i){throw r.error("Error creating exportable element",e,i),new Error("[Pixi\u2019VN] Error creating exportable element")}}function U(e){let i=t(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=t(i):a=i,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,a);break;case "tempstorage":storage.setTempVariable(e.key,a);break;case "params":let o=storage.getVariable(`${y}${narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=a),storage.setTempVariable(`${y}${narration.openedLabels.length-1}`,o);break}}function t(e){let i=we(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return Ne(i);case "arithmetic":case "arithmeticsingle":return Te(i);case "compare":case "valueCondition":case "union":return be(i)}return i}function Te(e){let i=t(e.leftValue);switch(e.type){case "arithmetic":let a=t(e.rightValue);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return i+a;case "-":return i-a;case "%":return i%a;case "POW":return Math.pow(i,a);case "RANDOM":return narration.getRandomNumber(i,a)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function Ne(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.getVariable(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return t(e.operation);case "params":let i=storage.getVariable(`${y}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];r.warn("getValue params not found");return}return e}function be(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=t(e.leftValue),a=t(e.rightValue);switch(e.operator){case "==":return i===a;case "!=":return i!==a;case "<":return i<a;case "<=":return i<=a;case ">":return i>a;case ">=":return i>=a;case "CONTAINS":return i.toString().includes(a.toString())}break;case "valueCondition":return !!t(e.value);case "union":return Pe(e)}return !!e}function Pe(e){if(e.unionType==="not")return !t(e.condition);let i=e.unionType==="and";for(let a=0;a<e.conditions.length;a++)if(i=t(e.conditions[a])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function Je(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function we(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Se(e);case "ifelse":return t(e.condition)?t(e.then):t(e.else);case "stepswitch":let a=t(e.elements)||[];if(a.length===0){r.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=Je(0,a.length-1);return t(a[o]);case "loop":let n=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>a.length-1&&(n=n%a.length),t(a[n]);case "sequential":let l,u=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(l=t(a[a.length-1])),u>a.length-1?l:t(a[u]);case "sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,a.length-1,{nestedId:e.nestedId,onceOnly:true});if(p==null&&e.end=="lastItem"){let x=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!x||!x?.usedRandomNumbers){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let V=x.usedRandomNumbers[`0-${a.length-1}`];return t(a[V[V.length-1]])}if(p==null){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return t(a[p])}}return e}function J(e){if(e.conditionalStep){let i=j(t(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return J(a)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function Se(e){let i=e.firstItem,a=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(l=>{let u=t(l);a.push(u);});else {let l=t(n);a.push(l);}});let o=i?[i,...a]:a;if(o.length===0){r.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator$1.t(o);if(typeof o[0]=="object"){let n=o,l,u=n.map((s,m)=>{s=J(s);let d=t(s.dialogue)||"";return m===0?(l=t(s.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),l===false&&(d=`
1
+ export*from'@drincs/pixi-vn-json/importer';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';export*from'@drincs/pixi-vn-json/unifier';import {canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,Assets,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var V="___param___";async function E(e){let a=JsonUnifier.getLogichValue(e);if(a)switch(a.type){case "assets":switch(a.operationType){case "load":await Assets.load(a.aliases);break;case "lazyload":Assets.backgroundLoad(a.aliases);break}break;case "bundle":switch(a.operationType){case "load":await Assets.loadBundle(a.aliases);break;case "lazyload":Assets.backgroundLoadBundle(a.aliases);break}break}}var r;(n=>(n.log=(l,...u)=>console.log(`[Pixi\u2019VN Json] ${l}`,...u),n.warn=(l,...u)=>console.warn(`[Pixi\u2019VN Json] ${l}`,...u),n.error=(l,...u)=>console.error(`[Pixi\u2019VN Json] ${l}`,...u),n.info=(l,...u)=>console.info(`[Pixi\u2019VN Json] ${l}`,...u)))(r||(r={}));async function b(e,a,i){switch(i.type){case "fade":await showWithFade(a.alias,e,i.props,i.priority);break;case "dissolve":await showWithDissolve(a.alias,e,i.props,i.priority);break;case "movein":case "moveout":await moveIn(a.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(a.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(a.alias,e,i.props,i.priority);break}}function T(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function I(e){switch(e.operationType){case "show":if(e.transition){let i=new ImageSprite(e.props,e.url||e.alias);await b(i,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`Image with alias ${e.alias} not found.`);break;case "remove":T(e);break}}async function v(e){switch(e.operationType){case "show":if(e.transition){let n=new VideoSprite(e.props,e.url||e.alias);await b(n,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`Video with alias ${e.alias} not found.`);break;case "remove":T(e);break;case "pause":let i=canvas.find(e.alias);i?i.paused=true:r.error(`Video with alias ${e.alias} not found.`);break;case "resume":let o=canvas.find(e.alias);o?o.paused=false:r.error(`Video with alias ${e.alias} not found.`);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let i=new ImageContainer(e.props,e.urls);await b(i,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":T(e);break}}async function _(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator$1.t(e.text),e.transition){let i=new Text(e.props);await b(i,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):r.error(`Text with alias ${e.alias} not found.`);break;case "remove":T(e);break}}async function R(e){switch(e.operationType){case "edit":try{let a=canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):r.error(`Canvas Element with alias ${e.alias} not found.`);}catch(a){r.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,a);}break;case "remove":T(e);break}}function L(e){switch(e.type){case "fade":let a=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "move":let i=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,i);break;case "rotate":let o=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,o);break;case "zoom":let n=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,n);break}}async function D(e){switch(e.type){case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}function M(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function F(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function $(e){switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(e.alias);break;case "pause":sound.pause(e.alias);break;case "resume":sound.resume(e.alias);break;case "volume":sound.volume(e.alias,e.value);break}}function j(e){try{if(typeof e>"u")return e;let a=JSON.stringify(e);return JSON.parse(a)}catch(a){throw r.error("Error creating exportable element",e,a),new Error("[Pixi\u2019VN] Error creating exportable element")}}function U(e){let a=t(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=t(a):i=a,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,i);break;case "tempstorage":storage.setTempVariable(e.key,i);break;case "params":let o=storage.getVariable(`${V}${narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=i),storage.setTempVariable(`${V}${narration.openedLabels.length-1}`,o);break}}function z(e){let a=t(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=t(a):i=a,e.storageType){case "storage":case "tempstorage":storage.startingStorage={[e.key]:i};break}}function t(e){let a=we(e);if(a&&typeof a=="object"&&"type"in a)switch(a.type){case "value":return be(a);case "arithmetic":case "arithmeticsingle":return Ne(a);case "compare":case "valueCondition":case "union":return Pe(a)}return a}function Ne(e){let a=t(e.leftValue);switch(e.type){case "arithmetic":let i=t(e.rightValue);switch(e.operator){case "*":return a*i;case "/":return a/i;case "+":return a+i;case "-":return a-i;case "%":return a%i;case "POW":return Math.pow(a,i);case "RANDOM":return narration.getRandomNumber(a,i)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(a);case "FLOOR":return Math.floor(a);case "FLOAT":return parseFloat(a)}break}}function be(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.getVariable(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return t(e.operation);case "params":let a=storage.getVariable(`${V}${narration.openedLabels.length-1}`)||[];if(a&&a.length>e.key)return a[e.key];r.warn("getValue params not found");return}return e}function Pe(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let a=t(e.leftValue),i=t(e.rightValue);switch(e.operator){case "==":return a===i;case "!=":return a!==i;case "<":return a<i;case "<=":return a<=i;case ">":return a>i;case ">=":return a>=i;case "CONTAINS":return a.toString().includes(i.toString())}break;case "valueCondition":return !!t(e.value);case "union":return Je(e)}return !!e}function Je(e){if(e.unionType==="not")return !t(e.condition);let a=e.unionType==="and";for(let i=0;i<e.conditions.length;i++)if(a=t(e.conditions[i])||false,e.unionType==="and"){if(!a)return false}else if(a)return true;return a}function Se(e,a){return Math.floor(Math.random()*(a-e+1)+e)}function we(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ke(e);case "ifelse":return t(e.condition)?t(e.then):t(e.else);case "stepswitch":let i=t(e.elements)||[];if(i.length===0){r.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=Se(0,i.length-1);return t(i[o]);case "loop":let n=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>i.length-1&&(n=n%i.length),t(i[n]);case "sequential":let l,u=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(l=t(i[i.length-1])),u>i.length-1?l:t(i[u]);case "sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(p==null&&e.end=="lastItem"){let x=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!x||!x?.usedRandomNumbers){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let y=x.usedRandomNumbers[`0-${i.length-1}`];return t(i[y[y.length-1]])}if(p==null){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return t(i[p])}}return e}function J(e){if(e.conditionalStep){let a=j(t(e.conditionalStep));if(a?.glueEnabled===void 0&&delete a?.glueEnabled,a?.goNextStep===void 0&&delete a?.goNextStep,a?.end===void 0&&delete a?.end,a?.choices===void 0&&delete a?.choices,a?.dialogue===void 0&&delete a?.dialogue,a?.labelToOpen===void 0&&delete a?.labelToOpen,a?.operations===void 0&&delete a?.operations,a){let i={...e,conditionalStep:void 0,...a};return J(i)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function ke(e){let a=e.firstItem,i=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(l=>{let u=t(l);i.push(u);});else {let l=t(n);i.push(l);}});let o=a?[a,...i]:i;if(o.length===0){r.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator$1.t(o);if(typeof o[0]=="object"){let n=o,l,u=n.map((s,m)=>{s=J(s);let d=t(s.dialogue)||"";return m===0?(l=t(s.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),l===false&&(d=`
2
2
 
3
- `+d),l=t(s.glueEnabled)||false,d)}),p=t(u[0]),x=typeof p=="object"&&"character"in p?p.character:void 0,V=u.flatMap(s=>{let m;s&&typeof s=="object"&&"text"in s?m=s.text:m=s;let d;return Array.isArray(m)?d=m.map(q=>{let Y=t(q);return translator$1.t(`${Y}`)}):d=t(m)||"",translator$1.t(d)}),z=n.find(s=>s.end),X=n.find(s=>s.choices),C=false,O=false;n.length>0&&(n[0].glueEnabled&&n[0].goNextStep&&n[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),C=n[n.length-1].glueEnabled,O=n.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let W=n.find(s=>s.labelToOpen),w=[];return n.forEach(s=>{s.operations&&w.forEach(m=>{w.push(m);});}),{dialogue:x?{character:x,text:V}:V,end:z?.end,choices:X?.choices,glueEnabled:C,goNextStep:O,labelToOpen:W?.labelToOpen,operations:w}}}function li(){JsonUnifier.init({animateOperation:M,canvasElementOperation:R,effectOperation:D,imageContainerOperation:A,imageOperation:I,textOperation:_,narrationOperation:F,loadAssets:E,soundOperation:$,tickerOperation:L,videoOperation:v,setStorageValue:U,getLogichValue:t,getConditionalStep:J});}export{y as PIXIVNJSON_PARAM_ID,li as init};
3
+ `+d),l=t(s.glueEnabled)||false,d)}),p=t(u[0]),x=typeof p=="object"&&"character"in p?p.character:void 0,y=u.flatMap(s=>{let m;s&&typeof s=="object"&&"text"in s?m=s.text:m=s;let d;return Array.isArray(m)?d=m.map(Y=>{let K=t(Y);return translator$1.t(`${K}`)}):d=t(m)||"",translator$1.t(d)}),X=n.find(s=>s.end),W=n.find(s=>s.choices),C=false,O=false;n.length>0&&(n[0].glueEnabled&&n[0].goNextStep&&n[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),C=n[n.length-1].glueEnabled,O=n.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let q=n.find(s=>s.labelToOpen),S=[];return n.forEach(s=>{s.operations&&S.forEach(m=>{S.push(m);});}),{dialogue:x?{character:x,text:y}:y,end:X?.end,choices:W?.choices,glueEnabled:C,goNextStep:O,labelToOpen:q?.labelToOpen,operations:S}}}function ua(){JsonUnifier.init({animateOperation:M,canvasElementOperation:R,effectOperation:D,imageContainerOperation:A,imageOperation:I,textOperation:_,narrationOperation:F,loadAssets:E,soundOperation:$,tickerOperation:L,videoOperation:v,setStorageValue:U,setInitialStorageValue:z,getLogichValue:t,getConditionalStep:J});}export{V as PIXIVNJSON_PARAM_ID,ua as init};
package/dist/unifier.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var x=Object.defineProperty;var P=(a,i,s)=>i in a?x(a,i,{enumerable:true,configurable:true,writable:true,value:s}):a[i]=s;var o=(a,i,s)=>P(a,typeof i!="symbol"?i+"":i,s);var t;(c=>(c.log=(r,...n)=>console.log(`[Pixi\u2019VN Json] ${r}`,...n),c.warn=(r,...n)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...n),c.error=(r,...n)=>console.error(`[Pixi\u2019VN Json] ${r}`,...n),c.info=(r,...n)=>console.info(`[Pixi\u2019VN Json] ${r}`,...n)))(t||(t={}));var e=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.tickerOperation&&(e._tickerOperation=i.tickerOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return e._loadAssets}static get soundOperation(){return e._soundOperation}static get imageOperation(){return e._imageOperation}static get videoOperation(){return e._videoOperation}static get textOperation(){return e._textOperation}static get imageContainerOperation(){return e._imageContainerOperation}static get canvasElementOperation(){return e._canvasElementOperation}static get setStorageValue(){return e._setStorageValue}static get narrationOperation(){return e._narrationOperation}static get tickerOperation(){return e._tickerOperation}static get effectOperation(){return e._effectOperation}static get animateOperation(){return e._animateOperation}static get getLogichValue(){return e._getLogichValue}static get getConditionalStep(){return e._getConditionalStep}};o(e,"_loadAssets",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_textOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_narrationOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_tickerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var p=e;exports.JsonUnifier=p;
1
+ 'use strict';var x=Object.defineProperty;var P=(n,i,s)=>i in n?x(n,i,{enumerable:true,configurable:true,writable:true,value:s}):n[i]=s;var o=(n,i,s)=>P(n,typeof i!="symbol"?i+"":i,s);var t;(c=>(c.log=(r,...a)=>console.log(`[Pixi\u2019VN Json] ${r}`,...a),c.warn=(r,...a)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...a),c.error=(r,...a)=>console.error(`[Pixi\u2019VN Json] ${r}`,...a),c.info=(r,...a)=>console.info(`[Pixi\u2019VN Json] ${r}`,...a)))(t||(t={}));var e=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(e._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.tickerOperation&&(e._tickerOperation=i.tickerOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return e._loadAssets}static get soundOperation(){return e._soundOperation}static get imageOperation(){return e._imageOperation}static get videoOperation(){return e._videoOperation}static get textOperation(){return e._textOperation}static get imageContainerOperation(){return e._imageContainerOperation}static get canvasElementOperation(){return e._canvasElementOperation}static get setStorageValue(){return e._setStorageValue}static get setInitialStorageValue(){return e._setInitialStorageValue}static get narrationOperation(){return e._narrationOperation}static get tickerOperation(){return e._tickerOperation}static get effectOperation(){return e._effectOperation}static get animateOperation(){return e._animateOperation}static get getLogichValue(){return e._getLogichValue}static get getConditionalStep(){return e._getConditionalStep}};o(e,"_loadAssets",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_textOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setInitialStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_narrationOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_tickerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var p=e;exports.JsonUnifier=p;
@@ -57,8 +57,95 @@ type PixiVNJsonConditionalResultToCombine<T> = {
57
57
  secondConditionalItem?: PixiVNJsonStepSwitchElementType<T>[];
58
58
  };
59
59
 
60
+ type PixiVNJsonUnionConditionAndOr = {
61
+ type: "union";
62
+ conditions: PixiVNJsonConditions[];
63
+ unionType: "and" | "or";
64
+ };
65
+ type PixiVNJsonUnionConditionNot = {
66
+ type: "union";
67
+ condition: PixiVNJsonConditions;
68
+ unionType: "not";
69
+ };
70
+ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
71
+
72
+ /**
73
+ * Comparation for PixiVNJson.
74
+ * In this comparation, the values to be converted to string and compared.
75
+ */
76
+ type PixiVNJsonComparation = {
77
+ type: "compare";
78
+ /**
79
+ * Left value of the comparation
80
+ */
81
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
82
+ /**
83
+ * Right value of the comparation
84
+ */
85
+ rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
86
+ /**
87
+ * Operator of the comparation
88
+ */
89
+ operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
90
+ };
91
+ type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
92
+ /**
93
+ * Conditions for PixiVNJson
94
+ */
95
+ type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
96
+
97
+ /**
98
+ * If-Else condition for PixiVNJson
99
+ */
100
+ interface PixiVNJsonIfElse<Then> {
101
+ type: "ifelse";
102
+ /**
103
+ * The list of conditions to be checked.
104
+ */
105
+ condition: PixiVNJsonConditions;
106
+ /**
107
+ * The value to be returned if the condition is true.
108
+ */
109
+ then: Then | PixiVNJsonIfElse<Then>;
110
+ /**
111
+ * The value to be returned if the condition is false.
112
+ */
113
+ else?: Then | PixiVNJsonIfElse<Then>;
114
+ }
115
+
60
116
  type PixiVNJsonConditionalStatements<Then> = PixiVNJsonStepSwitch<Then> | PixiVNJsonIfElse<Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>>;
61
117
 
118
+ interface PixiVNJsonArithmeticOperationsArithmetic {
119
+ type: "arithmetic";
120
+ /**
121
+ * Left value of the arithmetic operation
122
+ */
123
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
124
+ /**
125
+ * Right value of the arithmetic operation
126
+ */
127
+ rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
128
+ /**
129
+ * Operator of the arithmetic operation
130
+ */
131
+ operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
132
+ }
133
+ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
134
+ type: "arithmeticsingle";
135
+ /**
136
+ * Left value of the arithmetic operation
137
+ */
138
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
139
+ /**
140
+ * Operator of the arithmetic operation
141
+ */
142
+ operator: "INT" | "FLOOR" | "FLOAT";
143
+ }
144
+ /**
145
+ * Arithmetic operations for the PixiVNJson
146
+ */
147
+ type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
148
+
62
149
  type PixiVNJsonStorageGet = {
63
150
  type: "value";
64
151
  storageOperationType: "get";
@@ -159,93 +246,6 @@ type PixiVNJsonFlagSet = {
159
246
  };
160
247
  type PixiVNJsonValueSet = PixiVNJsonOnlyStorageSet | PixiVNJsonFlagSet | PixiVNJsonOnlyParamSet;
161
248
 
162
- interface PixiVNJsonArithmeticOperationsArithmetic {
163
- type: "arithmetic";
164
- /**
165
- * Left value of the arithmetic operation
166
- */
167
- leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
168
- /**
169
- * Right value of the arithmetic operation
170
- */
171
- rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
172
- /**
173
- * Operator of the arithmetic operation
174
- */
175
- operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
176
- }
177
- interface PixiVNJsonArithmeticOperationsArithmeticSingle {
178
- type: "arithmeticsingle";
179
- /**
180
- * Left value of the arithmetic operation
181
- */
182
- leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
183
- /**
184
- * Operator of the arithmetic operation
185
- */
186
- operator: "INT" | "FLOOR" | "FLOAT";
187
- }
188
- /**
189
- * Arithmetic operations for the PixiVNJson
190
- */
191
- type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
192
-
193
- type PixiVNJsonUnionConditionAndOr = {
194
- type: "union";
195
- conditions: PixiVNJsonConditions[];
196
- unionType: "and" | "or";
197
- };
198
- type PixiVNJsonUnionConditionNot = {
199
- type: "union";
200
- condition: PixiVNJsonConditions;
201
- unionType: "not";
202
- };
203
- type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
204
-
205
- /**
206
- * Comparation for PixiVNJson.
207
- * In this comparation, the values to be converted to string and compared.
208
- */
209
- type PixiVNJsonComparation = {
210
- type: "compare";
211
- /**
212
- * Left value of the comparation
213
- */
214
- leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
215
- /**
216
- * Right value of the comparation
217
- */
218
- rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
219
- /**
220
- * Operator of the comparation
221
- */
222
- operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
223
- };
224
- type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
225
- /**
226
- * Conditions for PixiVNJson
227
- */
228
- type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
229
-
230
- /**
231
- * If-Else condition for PixiVNJson
232
- */
233
- interface PixiVNJsonIfElse<Then> {
234
- type: "ifelse";
235
- /**
236
- * The list of conditions to be checked.
237
- */
238
- condition: PixiVNJsonConditions;
239
- /**
240
- * The value to be returned if the condition is true.
241
- */
242
- then: Then | PixiVNJsonIfElse<Then>;
243
- /**
244
- * The value to be returned if the condition is false.
245
- */
246
- else?: Then | PixiVNJsonIfElse<Then>;
247
- }
248
-
249
249
  type PixiVNJsonAnimateBase<T extends CanvasBaseInterface<any>> = {
250
250
  type: "animate";
251
251
  alias: string | string[];
@@ -575,6 +575,7 @@ declare class JsonUnifier {
575
575
  textOperation?: (operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasTextShow | PixiVNJsonTextEdit) => Promise<void>;
576
576
  canvasElementOperation?: (operation: PixiVNJsonCanvasRemove | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>>) => Promise<void>;
577
577
  setStorageValue?: (value: PixiVNJsonValueSet) => void;
578
+ setInitialStorageValue: (value: PixiVNJsonOnlyStorageSet) => void;
578
579
  narrationOperation?: (operation: PixiVNJsonNarration) => void;
579
580
  tickerOperation?: (operation: PixiVNJsonCanvasTicker) => void;
580
581
  effectOperation?: (operation: PixiVNJsonCanvasEffect) => Promise<void>;
@@ -598,6 +599,8 @@ declare class JsonUnifier {
598
599
  static get canvasElementOperation(): (operation: PixiVNJsonCanvasRemove | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>>) => Promise<void>;
599
600
  private static _setStorageValue;
600
601
  static get setStorageValue(): (value: PixiVNJsonValueSet) => void;
602
+ private static _setInitialStorageValue;
603
+ static get setInitialStorageValue(): (value: PixiVNJsonOnlyStorageSet) => void;
601
604
  private static _narrationOperation;
602
605
  static get narrationOperation(): (operation: PixiVNJsonNarration) => void;
603
606
  private static _tickerOperation;
package/dist/unifier.d.ts CHANGED
@@ -57,8 +57,95 @@ type PixiVNJsonConditionalResultToCombine<T> = {
57
57
  secondConditionalItem?: PixiVNJsonStepSwitchElementType<T>[];
58
58
  };
59
59
 
60
+ type PixiVNJsonUnionConditionAndOr = {
61
+ type: "union";
62
+ conditions: PixiVNJsonConditions[];
63
+ unionType: "and" | "or";
64
+ };
65
+ type PixiVNJsonUnionConditionNot = {
66
+ type: "union";
67
+ condition: PixiVNJsonConditions;
68
+ unionType: "not";
69
+ };
70
+ type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
71
+
72
+ /**
73
+ * Comparation for PixiVNJson.
74
+ * In this comparation, the values to be converted to string and compared.
75
+ */
76
+ type PixiVNJsonComparation = {
77
+ type: "compare";
78
+ /**
79
+ * Left value of the comparation
80
+ */
81
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
82
+ /**
83
+ * Right value of the comparation
84
+ */
85
+ rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
86
+ /**
87
+ * Operator of the comparation
88
+ */
89
+ operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
90
+ };
91
+ type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
92
+ /**
93
+ * Conditions for PixiVNJson
94
+ */
95
+ type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
96
+
97
+ /**
98
+ * If-Else condition for PixiVNJson
99
+ */
100
+ interface PixiVNJsonIfElse<Then> {
101
+ type: "ifelse";
102
+ /**
103
+ * The list of conditions to be checked.
104
+ */
105
+ condition: PixiVNJsonConditions;
106
+ /**
107
+ * The value to be returned if the condition is true.
108
+ */
109
+ then: Then | PixiVNJsonIfElse<Then>;
110
+ /**
111
+ * The value to be returned if the condition is false.
112
+ */
113
+ else?: Then | PixiVNJsonIfElse<Then>;
114
+ }
115
+
60
116
  type PixiVNJsonConditionalStatements<Then> = PixiVNJsonStepSwitch<Then> | PixiVNJsonIfElse<Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>>;
61
117
 
118
+ interface PixiVNJsonArithmeticOperationsArithmetic {
119
+ type: "arithmetic";
120
+ /**
121
+ * Left value of the arithmetic operation
122
+ */
123
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
124
+ /**
125
+ * Right value of the arithmetic operation
126
+ */
127
+ rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
128
+ /**
129
+ * Operator of the arithmetic operation
130
+ */
131
+ operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
132
+ }
133
+ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
134
+ type: "arithmeticsingle";
135
+ /**
136
+ * Left value of the arithmetic operation
137
+ */
138
+ leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
139
+ /**
140
+ * Operator of the arithmetic operation
141
+ */
142
+ operator: "INT" | "FLOOR" | "FLOAT";
143
+ }
144
+ /**
145
+ * Arithmetic operations for the PixiVNJson
146
+ */
147
+ type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
148
+
62
149
  type PixiVNJsonStorageGet = {
63
150
  type: "value";
64
151
  storageOperationType: "get";
@@ -159,93 +246,6 @@ type PixiVNJsonFlagSet = {
159
246
  };
160
247
  type PixiVNJsonValueSet = PixiVNJsonOnlyStorageSet | PixiVNJsonFlagSet | PixiVNJsonOnlyParamSet;
161
248
 
162
- interface PixiVNJsonArithmeticOperationsArithmetic {
163
- type: "arithmetic";
164
- /**
165
- * Left value of the arithmetic operation
166
- */
167
- leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
168
- /**
169
- * Right value of the arithmetic operation
170
- */
171
- rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
172
- /**
173
- * Operator of the arithmetic operation
174
- */
175
- operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
176
- }
177
- interface PixiVNJsonArithmeticOperationsArithmeticSingle {
178
- type: "arithmeticsingle";
179
- /**
180
- * Left value of the arithmetic operation
181
- */
182
- leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
183
- /**
184
- * Operator of the arithmetic operation
185
- */
186
- operator: "INT" | "FLOOR" | "FLOAT";
187
- }
188
- /**
189
- * Arithmetic operations for the PixiVNJson
190
- */
191
- type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
192
-
193
- type PixiVNJsonUnionConditionAndOr = {
194
- type: "union";
195
- conditions: PixiVNJsonConditions[];
196
- unionType: "and" | "or";
197
- };
198
- type PixiVNJsonUnionConditionNot = {
199
- type: "union";
200
- condition: PixiVNJsonConditions;
201
- unionType: "not";
202
- };
203
- type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
204
-
205
- /**
206
- * Comparation for PixiVNJson.
207
- * In this comparation, the values to be converted to string and compared.
208
- */
209
- type PixiVNJsonComparation = {
210
- type: "compare";
211
- /**
212
- * Left value of the comparation
213
- */
214
- leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
215
- /**
216
- * Right value of the comparation
217
- */
218
- rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
219
- /**
220
- * Operator of the comparation
221
- */
222
- operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
223
- };
224
- type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
225
- /**
226
- * Conditions for PixiVNJson
227
- */
228
- type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
229
-
230
- /**
231
- * If-Else condition for PixiVNJson
232
- */
233
- interface PixiVNJsonIfElse<Then> {
234
- type: "ifelse";
235
- /**
236
- * The list of conditions to be checked.
237
- */
238
- condition: PixiVNJsonConditions;
239
- /**
240
- * The value to be returned if the condition is true.
241
- */
242
- then: Then | PixiVNJsonIfElse<Then>;
243
- /**
244
- * The value to be returned if the condition is false.
245
- */
246
- else?: Then | PixiVNJsonIfElse<Then>;
247
- }
248
-
249
249
  type PixiVNJsonAnimateBase<T extends CanvasBaseInterface<any>> = {
250
250
  type: "animate";
251
251
  alias: string | string[];
@@ -575,6 +575,7 @@ declare class JsonUnifier {
575
575
  textOperation?: (operation: PixiVNJsonCanvasRemove | PixiVNJsonCanvasTextShow | PixiVNJsonTextEdit) => Promise<void>;
576
576
  canvasElementOperation?: (operation: PixiVNJsonCanvasRemove | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>>) => Promise<void>;
577
577
  setStorageValue?: (value: PixiVNJsonValueSet) => void;
578
+ setInitialStorageValue: (value: PixiVNJsonOnlyStorageSet) => void;
578
579
  narrationOperation?: (operation: PixiVNJsonNarration) => void;
579
580
  tickerOperation?: (operation: PixiVNJsonCanvasTicker) => void;
580
581
  effectOperation?: (operation: PixiVNJsonCanvasEffect) => Promise<void>;
@@ -598,6 +599,8 @@ declare class JsonUnifier {
598
599
  static get canvasElementOperation(): (operation: PixiVNJsonCanvasRemove | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory<ContainerChild>>) => Promise<void>;
599
600
  private static _setStorageValue;
600
601
  static get setStorageValue(): (value: PixiVNJsonValueSet) => void;
602
+ private static _setInitialStorageValue;
603
+ static get setInitialStorageValue(): (value: PixiVNJsonOnlyStorageSet) => void;
601
604
  private static _narrationOperation;
602
605
  static get narrationOperation(): (operation: PixiVNJsonNarration) => void;
603
606
  private static _tickerOperation;
package/dist/unifier.mjs CHANGED
@@ -1 +1 @@
1
- var x=Object.defineProperty;var P=(a,i,s)=>i in a?x(a,i,{enumerable:true,configurable:true,writable:true,value:s}):a[i]=s;var o=(a,i,s)=>P(a,typeof i!="symbol"?i+"":i,s);var t;(c=>(c.log=(r,...n)=>console.log(`[Pixi\u2019VN Json] ${r}`,...n),c.warn=(r,...n)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...n),c.error=(r,...n)=>console.error(`[Pixi\u2019VN Json] ${r}`,...n),c.info=(r,...n)=>console.info(`[Pixi\u2019VN Json] ${r}`,...n)))(t||(t={}));var e=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.tickerOperation&&(e._tickerOperation=i.tickerOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return e._loadAssets}static get soundOperation(){return e._soundOperation}static get imageOperation(){return e._imageOperation}static get videoOperation(){return e._videoOperation}static get textOperation(){return e._textOperation}static get imageContainerOperation(){return e._imageContainerOperation}static get canvasElementOperation(){return e._canvasElementOperation}static get setStorageValue(){return e._setStorageValue}static get narrationOperation(){return e._narrationOperation}static get tickerOperation(){return e._tickerOperation}static get effectOperation(){return e._effectOperation}static get animateOperation(){return e._animateOperation}static get getLogichValue(){return e._getLogichValue}static get getConditionalStep(){return e._getConditionalStep}};o(e,"_loadAssets",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_textOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_narrationOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_tickerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var p=e;export{p as JsonUnifier};
1
+ var x=Object.defineProperty;var P=(n,i,s)=>i in n?x(n,i,{enumerable:true,configurable:true,writable:true,value:s}):n[i]=s;var o=(n,i,s)=>P(n,typeof i!="symbol"?i+"":i,s);var t;(c=>(c.log=(r,...a)=>console.log(`[Pixi\u2019VN Json] ${r}`,...a),c.warn=(r,...a)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...a),c.error=(r,...a)=>console.error(`[Pixi\u2019VN Json] ${r}`,...a),c.info=(r,...a)=>console.info(`[Pixi\u2019VN Json] ${r}`,...a)))(t||(t={}));var e=class e{static init(i){i.loadAssets&&(e._loadAssets=i.loadAssets),i.soundOperation&&(e._soundOperation=i.soundOperation),i.imageOperation&&(e._imageOperation=i.imageOperation),i.videoOperation&&(e._videoOperation=i.videoOperation),i.imageContainerOperation&&(e._imageContainerOperation=i.imageContainerOperation),i.textOperation&&(e._textOperation=i.textOperation),i.canvasElementOperation&&(e._canvasElementOperation=i.canvasElementOperation),i.setStorageValue&&(e._setStorageValue=i.setStorageValue),i.setInitialStorageValue&&(e._setInitialStorageValue=i.setInitialStorageValue),i.narrationOperation&&(e._narrationOperation=i.narrationOperation),i.tickerOperation&&(e._tickerOperation=i.tickerOperation),i.effectOperation&&(e._effectOperation=i.effectOperation),i.animateOperation&&(e._animateOperation=i.animateOperation),i.getLogichValue&&(e._getLogichValue=i.getLogichValue),i.getConditionalStep&&(e._getConditionalStep=i.getConditionalStep);}static get loadAssets(){return e._loadAssets}static get soundOperation(){return e._soundOperation}static get imageOperation(){return e._imageOperation}static get videoOperation(){return e._videoOperation}static get textOperation(){return e._textOperation}static get imageContainerOperation(){return e._imageContainerOperation}static get canvasElementOperation(){return e._canvasElementOperation}static get setStorageValue(){return e._setStorageValue}static get setInitialStorageValue(){return e._setInitialStorageValue}static get narrationOperation(){return e._narrationOperation}static get tickerOperation(){return e._tickerOperation}static get effectOperation(){return e._effectOperation}static get animateOperation(){return e._animateOperation}static get getLogichValue(){return e._getLogichValue}static get getConditionalStep(){return e._getConditionalStep}};o(e,"_loadAssets",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_soundOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_videoOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_imageContainerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_textOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_canvasElementOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_setInitialStorageValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_narrationOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_tickerOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_effectOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_animateOperation",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getLogichValue",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),o(e,"_getConditionalStep",()=>{throw t.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var p=e;export{p as JsonUnifier};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-json",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN can be integrated with JSON files to create a visual novel.",
6
6
  "main": "./dist/index.cjs",